pub trait KvStore {
// Required methods
fn get(
&self,
key: &str,
out: &mut [u8],
) -> impl Future<Output = Result<Option<usize>>>;
fn set(&self, key: &str, value: &[u8]) -> impl Future<Output = Result<()>>;
fn remove(&self, key: &str) -> impl Future<Output = Result<()>>;
fn remove_prefix(&self, prefix: &str) -> impl Future<Output = Result<()>>;
}Expand description
Non-volatile storage, as opaque blobs under string keys.
The store never sees a Matter type: this crate serialises everything itself, prefixes each blob with a schema version, and treats an unknown newer version as a failure rather than a value to guess at. That keeps the platform’s job to five methods and keeps migrations in one place.
Required Methods§
Sourcefn get(
&self,
key: &str,
out: &mut [u8],
) -> impl Future<Output = Result<Option<usize>>>
fn get( &self, key: &str, out: &mut [u8], ) -> impl Future<Output = Result<Option<usize>>>
Reads the value of key into out, returning how many octets it holds.
Returns Ok(None) when the key is absent — which is not an error, it is how a
factory-fresh node reads every key.
Sourcefn set(&self, key: &str, value: &[u8]) -> impl Future<Output = Result<()>>
fn set(&self, key: &str, value: &[u8]) -> impl Future<Output = Result<()>>
Writes value to key, replacing what was there.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".