pub struct KeyValue<Ev> { /* private fields */ }
Implementations§
source§impl<Ev> KeyValue<Ev>where
Ev: 'static,
impl<Ev> KeyValue<Ev>where Ev: 'static,
pub fn new(context: CapabilityContext<KeyValueOperation, Ev>) -> Self
sourcepub fn read<F>(&self, key: &str, make_event: F)where
F: Fn(KeyValueOutput) -> Ev + Send + Sync + 'static,
pub fn read<F>(&self, key: &str, make_event: F)where F: Fn(KeyValueOutput) -> Ev + Send + Sync + 'static,
Read a value under key
, will dispatch the event with a
KeyValueOutput::Read(Option<Vec<u8>>)
as payload
sourcepub fn write<F>(&self, key: &str, value: Vec<u8>, make_event: F)where
F: Fn(KeyValueOutput) -> Ev + Send + Sync + 'static,
pub fn write<F>(&self, key: &str, value: Vec<u8>, make_event: F)where F: Fn(KeyValueOutput) -> Ev + Send + Sync + 'static,
Set key
to be the provided value
. Typically the bytes would be
a value serialized/deserialized by the app.
Will dispatch the event with a KeyValueOutput::Write(bool)
as payload