Skip to main content

PluginStorage

Struct PluginStorage 

Source
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

Source

pub fn new(store: Arc<dyn PluginStore>) -> Self

Wrap a host implementation.

Source

pub async fn get(&self, vault: &str, key: &str) -> PluginResult<Option<Vec<u8>>>

Read a value, or None when the key was never written.

Source

pub async fn put( &self, vault: &str, key: &str, value: &[u8], ) -> PluginResult<()>

Write a value, replacing any previous one.

Source

pub async fn delete(&self, vault: &str, key: &str) -> PluginResult<()>

Remove a value. Removing a key that does not exist succeeds.

Source

pub async fn list(&self, vault: &str, prefix: &str) -> PluginResult<Vec<String>>

List keys beginning with prefix, sorted. An empty prefix lists all.

Trait Implementations§

Source§

impl Clone for PluginStorage

Source§

fn clone(&self) -> PluginStorage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PluginStorage

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.