pub struct PluginStorage { /* private fields */ }Expand description
Durable, plugin-private, per-vault key/value storage.
A plugin that maintains derived state — an embedding index, a cached parse, a reconciliation watermark — needs somewhere to put it that is not the vault’s notes. Writing derived state as notes would pollute the user’s vault, the link graph, and the search corpus.
Isolation is structural rather than declared: the host namespaces every key under the calling plugin’s own space, so a plugin cannot name another plugin’s data, and there is no capability to grant. Storage lives beside the vault it describes, so it travels and is discarded with that vault.
Values are opaque bytes. Writes are atomic at the individual key: a concurrent reader sees either the previous value or the new one, never a partial write. There is no transaction across keys.
Implementations§
Source§impl PluginStorage
impl PluginStorage
Sourcepub fn new(store: Arc<dyn PluginStore>) -> Self
pub fn new(store: Arc<dyn PluginStore>) -> Self
Wrap a host implementation.
Sourcepub async fn get(&self, vault: &str, key: &str) -> PluginResult<Option<Vec<u8>>>
pub async fn get(&self, vault: &str, key: &str) -> PluginResult<Option<Vec<u8>>>
Read a value, or None when the key was never written.
Sourcepub async fn put(
&self,
vault: &str,
key: &str,
value: &[u8],
) -> PluginResult<()>
pub async fn put( &self, vault: &str, key: &str, value: &[u8], ) -> PluginResult<()>
Write a value, replacing any previous one.
Trait Implementations§
Source§impl Clone for PluginStorage
impl Clone for PluginStorage
Source§fn clone(&self) -> PluginStorage
fn clone(&self) -> PluginStorage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more