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

Method put

web/src/store.rs:289–304  ·  view source on GitHub ↗
(&mut self, name: &str, content: &[u8])

Source from the content-addressed store, hash-verified

287 }
288
289 async fn put(&mut self, name: &str, content: &[u8]) -> io::Result<()> {
290 let key = Key::for_name(name);
291
292 // There is no information we care about the old entry so we can replace it all in one go
293 // with a new one.
294 let entry = Entry::new(content, self.clock.now()?);
295
296 let key = key.serialized();
297 match self.storage.set(key, &serde_json::to_string(&entry)?) {
298 Ok(()) => Ok(()),
299 Err(e) => Err(io::Error::other(format!(
300 "Failed to put local storage entry with key {}: {:?}",
301 key, e
302 ))),
303 }
304 }
305}
306
307/// Factory for web drives.

Callers 1

test_webdrive_putFunction · 0.45

Calls 3

nowMethod · 0.80
serializedMethod · 0.80
setMethod · 0.80

Tested by 1

test_webdrive_putFunction · 0.36