Obtains and parses the entry given by `key`.
(&self, key: &Key)
| 210 | |
| 211 | /// Obtains and parses the entry given by `key`. |
| 212 | fn get_entry(&self, key: &Key) -> io::Result<Entry> { |
| 213 | let key = key.serialized(); |
| 214 | let raw = match self.storage.get(key) { |
| 215 | Ok(Some(content)) => content, |
| 216 | Ok(None) => return Err(io::Error::new(io::ErrorKind::NotFound, "File not found")), |
| 217 | Err(e) => { |
| 218 | return Err(io::Error::other(format!( |
| 219 | "Failed to get local storage entry with key {}: {:?}", |
| 220 | key, e |
| 221 | ))); |
| 222 | } |
| 223 | }; |
| 224 | |
| 225 | match serde_json::from_str(&raw) { |
| 226 | Ok(entry) => Ok(entry), |
| 227 | Err(e) => Err(io::Error::new( |
| 228 | io::ErrorKind::InvalidData, |
| 229 | format!("Failed to parse local storage entry with key {}: {:?}", key, e), |
| 230 | )), |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | #[async_trait(?Send)] |
no test coverage detected