MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / read_to_string

Method read_to_string

crates/chat-cli/src/os/fs/mod.rs:179–196  ·  view source on GitHub ↗
(&self, path: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

177 }
178
179 pub async fn read_to_string(&self, path: impl AsRef<Path>) -> io::Result<String> {
180 match self {
181 Self::Real => fs::read_to_string(path).await,
182 Self::Chroot(root) => fs::read_to_string(append(root.path(), path)).await,
183 Self::Fake(map) => {
184 let Ok(lock) = map.lock() else {
185 return Err(io::Error::other("poisoned lock"));
186 };
187 let Some(data) = lock.get(path.as_ref()) else {
188 return Err(io::Error::new(io::ErrorKind::NotFound, "not found"));
189 };
190 match String::from_utf8(data.clone()) {
191 Ok(string) => Ok(string),
192 Err(err) => Err(io::Error::new(io::ErrorKind::InvalidData, err)),
193 }
194 },
195 }
196 }
197
198 pub fn read_to_string_sync(&self, path: impl AsRef<Path>) -> io::Result<String> {
199 match self {

Callers 15

newMethod · 0.80
add_then_remove_cycleFunction · 0.80
executeMethod · 0.80
add_file_to_contextFunction · 0.80
load_agent_executionFunction · 0.80
invokeMethod · 0.80
calculate_diff_linesMethod · 0.80

Calls 5

appendFunction · 0.70
pathMethod · 0.45
getMethod · 0.45
as_refMethod · 0.45
cloneMethod · 0.45