Skip to main content

PluginStorage

Trait PluginStorage 

Source
pub trait PluginStorage {
    // Required methods
    fn storage_path(&self) -> &Path;
    fn get(&self, key: &str) -> PluginResult<Option<Value>>;
    fn set(&mut self, key: &str, value: &Value) -> PluginResult<()>;
    fn delete(&mut self, key: &str) -> PluginResult<bool>;
    fn keys(&self) -> PluginResult<Vec<String>>;
    fn clear(&mut self) -> PluginResult<()>;
}
Expand description

Storage API for plugins (sandboxed to plugin directory)

Storage location: .progit/plugins/<plugin-name>/state.json

Required Methods§

Source

fn storage_path(&self) -> &Path

Get plugin’s private storage directory

Source

fn get(&self, key: &str) -> PluginResult<Option<Value>>

Read a value from plugin’s key-value store

Source

fn set(&mut self, key: &str, value: &Value) -> PluginResult<()>

Write a value to plugin’s key-value store

Source

fn delete(&mut self, key: &str) -> PluginResult<bool>

Delete a key

Source

fn keys(&self) -> PluginResult<Vec<String>>

List all keys

Source

fn clear(&mut self) -> PluginResult<()>

Clear all stored data

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§