Skip to main content

SettingsStorage

Trait SettingsStorage 

Source
pub trait SettingsStorage: Send + Sync {
    // Required method
    fn with_lock(
        &mut self,
        scope: SettingsScope,
        f: &mut dyn FnMut(Option<String>) -> Result<Option<String>, String>,
    ) -> Result<(), String>;
}
Expand description

Storage backend for settings documents.

Ports the TypeScript SettingsStorage interface: with_lock hands the current raw document text (or None when the file does not exist) to f; the callback returns the next text to persist, or Ok(None) to perform no write. A callback Err aborts without writing.

Required Methods§

Source

fn with_lock( &mut self, scope: SettingsScope, f: &mut dyn FnMut(Option<String>) -> Result<Option<String>, String>, ) -> Result<(), String>

Run f under the scope’s exclusive lock.

§Errors

Returns the lock, read, write, or callback error message.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§