MCPcopy Create free account
hub / github.com/endbasic/endbasic / get_entry

Method get_entry

web/src/store.rs:212–232  ·  view source on GitHub ↗

Obtains and parses the entry given by `key`.

(&self, key: &Key)

Source from the content-addressed store, hash-verified

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)]

Callers 2

enumerateMethod · 0.80
getMethod · 0.80

Calls 2

serializedMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected