Skip to main content

PreferencesStore

Trait PreferencesStore 

Source
pub trait PreferencesStore: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Option<String>;
    fn set(&self, key: &str, value: &str) -> Result<(), PreferencesError>;
    fn remove(&self, key: &str) -> Result<(), PreferencesError>;
    fn keys(&self) -> Vec<String>;
    fn clear(&self) -> Result<(), PreferencesError>;
}
Expand description

Re-export framework services (HTTP, URI, etc.) from the dedicated services crate. Durable key/value storage owned by the application.

Implementations are Send + Sync: preferences are written from wherever the decision is made, including a worker thread.

Required Methods§

Source

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

Reads key, or None when it has never been written.

Source

fn set(&self, key: &str, value: &str) -> Result<(), PreferencesError>

Writes key.

Source

fn remove(&self, key: &str) -> Result<(), PreferencesError>

Removes key. Succeeds if it is already absent.

Source

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

Every key currently stored, in sorted order.

Source

fn clear(&self) -> Result<(), PreferencesError>

Removes everything.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl PreferencesStore for FilePreferences

Available on non-WebAssembly only.
Source§

impl PreferencesStore for MemoryPreferences