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>;
// Provided methods
fn set_many(
&self,
values: &BTreeMap<String, String>,
) -> Result<(), PreferencesError> { ... }
fn flush(&self) -> Result<(), PreferencesError> { ... }
}Expand description
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§
Sourcefn remove(&self, key: &str) -> Result<(), PreferencesError>
fn remove(&self, key: &str) -> Result<(), PreferencesError>
Removes key. Succeeds if it is already absent.
Sourcefn clear(&self) -> Result<(), PreferencesError>
fn clear(&self) -> Result<(), PreferencesError>
Removes everything.
Provided Methods§
Sourcefn set_many(
&self,
values: &BTreeMap<String, String>,
) -> Result<(), PreferencesError>
fn set_many( &self, values: &BTreeMap<String, String>, ) -> Result<(), PreferencesError>
Writes a group of values. File-backed stores replace the file once.
A failure may leave pending values visible; retry this batch or call flush.
Sourcefn flush(&self) -> Result<(), PreferencesError>
fn flush(&self) -> Result<(), PreferencesError>
Retries pending writes. Success means the backend accepted all pending data.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".