StorageProvider

Trait StorageProvider 

Source
pub trait StorageProvider:
    Environment
    + Send
    + Sync {
    // Required methods
    fn GetStorageValue<'life0, 'life1, 'async_trait>(
        &'life0 self,
        IsGlobalScope: bool,
        Key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn UpdateStorageValue<'life0, 'async_trait>(
        &'life0 self,
        IsGlobalScope: bool,
        Key: String,
        ValueToSet: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn GetAllStorage<'life0, 'async_trait>(
        &'life0 self,
        IsGlobalScope: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Value, CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn SetAllStorage<'life0, 'async_trait>(
        &'life0 self,
        IsGlobalScope: bool,
        FullState: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

An abstract service contract for an environment component that provides persistent key-value storage, similar to VS Code’s Memento API.

This trait is implemented by MountainEnvironment and is responsible for reading from and writing to the appropriate JSON storage files on disk, separating global state from workspace-specific state.

Required Methods§

Source

fn GetStorageValue<'life0, 'life1, 'async_trait>( &'life0 self, IsGlobalScope: bool, Key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a value from storage for a given key and scope.

§Parameters
  • IsGlobalScope: If true, retrieves from global storage; otherwise, retrieves from the current workspace’s storage.
  • Key: The key of the value to retrieve.
§Returns

A Result containing an Option<Value>. It resolves to Ok(Some(Value)) if the key exists, Ok(None) if it does not, or an Err on failure (e.g., I/O error).

Source

fn UpdateStorageValue<'life0, 'async_trait>( &'life0 self, IsGlobalScope: bool, Key: String, ValueToSet: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates or stores a value in storage for a given key and scope.

§Parameters
  • IsGlobalScope: If true, updates global storage; otherwise, workspace storage.
  • Key: The key of the value to update.
  • ValueToSet: The serde_json::Value to store. If this is None, the key should be deleted from storage.
Source

fn GetAllStorage<'life0, 'async_trait>( &'life0 self, IsGlobalScope: bool, ) -> Pin<Box<dyn Future<Output = Result<Value, CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the entire storage state for a given scope.

Source

fn SetAllStorage<'life0, 'async_trait>( &'life0 self, IsGlobalScope: bool, FullState: Value, ) -> Pin<Box<dyn Future<Output = Result<(), CommonError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Overwrites the entire storage state for a given scope with a new state.

Implementors§