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

Method read_to_string_sync

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

Source from the content-addressed store, hash-verified

196 }
197
198 pub fn read_to_string_sync(&self, path: impl AsRef<Path>) -> io::Result<String> {
199 match self {
200 Self::Real => std::fs::read_to_string(path),
201 Self::Chroot(root) => std::fs::read_to_string(append(root.path(), path)),
202 Self::Fake(map) => {
203 let Ok(lock) = map.lock() else {
204 return Err(io::Error::other("poisoned lock"));
205 };
206 let Some(data) = lock.get(path.as_ref()) else {
207 return Err(io::Error::new(io::ErrorKind::NotFound, "not found"));
208 };
209 match String::from_utf8(data.clone()) {
210 Ok(string) => Ok(string),
211 Err(err) => Err(io::Error::new(io::ErrorKind::InvalidData, err)),
212 }
213 },
214 }
215 }
216
217 /// Creates a future that will open a file for writing and write the entire
218 /// contents of `contents` to it.

Callers 1

queue_descriptionMethod · 0.80

Calls 5

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

Tested by

no test coverage detected