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§
Sourcefn storage_path(&self) -> &Path
fn storage_path(&self) -> &Path
Get plugin’s private storage directory
Sourcefn get(&self, key: &str) -> PluginResult<Option<Value>>
fn get(&self, key: &str) -> PluginResult<Option<Value>>
Read a value from plugin’s key-value store
Sourcefn set(&mut self, key: &str, value: &Value) -> PluginResult<()>
fn set(&mut self, key: &str, value: &Value) -> PluginResult<()>
Write a value to plugin’s key-value store
Sourcefn delete(&mut self, key: &str) -> PluginResult<bool>
fn delete(&mut self, key: &str) -> PluginResult<bool>
Delete a key
Sourcefn keys(&self) -> PluginResult<Vec<String>>
fn keys(&self) -> PluginResult<Vec<String>>
List all keys
Sourcefn clear(&mut self) -> PluginResult<()>
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".