(&self, path: impl AsRef<Path>)
| 161 | } |
| 162 | |
| 163 | pub async fn read(&self, path: impl AsRef<Path>) -> io::Result<Vec<u8>> { |
| 164 | match self { |
| 165 | Self::Real => fs::read(path).await, |
| 166 | Self::Chroot(root) => fs::read(append(root.path(), path)).await, |
| 167 | Self::Fake(map) => { |
| 168 | let Ok(lock) = map.lock() else { |
| 169 | return Err(io::Error::other("poisoned lock")); |
| 170 | }; |
| 171 | let Some(data) = lock.get(path.as_ref()) else { |
| 172 | return Err(io::Error::new(io::ErrorKind::NotFound, "not found")); |
| 173 | }; |
| 174 | Ok(data.clone()) |
| 175 | }, |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | pub async fn read_to_string(&self, path: impl AsRef<Path>) -> io::Result<String> { |
| 180 | match self { |
no test coverage detected