pub struct MemoryStore { /* private fields */ }Expand description
A store keeping its scopes in memory: a handler for settings that
last the session, a stand-in in tests. MemoryStore::change stands
for a change made elsewhere: its watchers are told. Clones share the
values.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn new(scopes: &[ValueScope]) -> MemoryStore
pub fn new(scopes: &[ValueScope]) -> MemoryStore
A store of these scopes, claiming every setting.
Sourcepub fn claiming(
self,
claim: impl Fn(&str) -> bool + Send + Sync + 'static,
) -> Self
pub fn claiming( self, claim: impl Fn(&str) -> bool + Send + Sync + 'static, ) -> Self
Claims only the settings claim accepts.
Sourcepub fn with(self, scope: ValueScope, values: Values) -> Self
pub fn with(self, scope: ValueScope, values: Values) -> Self
Sets a scope’s values, as kept before the app starts (no watcher is told).
Sourcepub fn values(&self, scope: ValueScope) -> Values
pub fn values(&self, scope: ValueScope) -> Values
A scope’s values as kept now.
Sourcepub fn saves(&self) -> Vec<(ValueScope, Changes)>
pub fn saves(&self) -> Vec<(ValueScope, Changes)>
Every save asked, in order.
Sourcepub fn fail_saves(&self, error: Option<&str>)
pub fn fail_saves(&self, error: Option<&str>)
Makes every save fail with error (None: they succeed again).
Sourcepub fn change(&self, scope: ValueScope, changes: Changes)
pub fn change(&self, scope: ValueScope, changes: Changes)
A change made elsewhere: kept, and its watchers told.
Trait Implementations§
Source§impl Clone for MemoryStore
impl Clone for MemoryStore
Source§fn clone(&self) -> MemoryStore
fn clone(&self) -> MemoryStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl SettingsStore for MemoryStore
impl SettingsStore for MemoryStore
Source§fn scopes(&self) -> Vec<ValueScope>
fn scopes(&self) -> Vec<ValueScope>
The scopes it keeps (
app, and host scopes such as a library).Source§fn claims(&self, setting: &str) -> bool
fn claims(&self, setting: &str) -> bool
Whether it keeps this setting (by id). Everything by default.
Source§fn save(&self, scope: ValueScope, changes: &Changes) -> Result<(), String>
fn save(&self, scope: ValueScope, changes: &Changes) -> Result<(), String>
Keeps the values that changed in a scope. Never called on the UI
thread (but on the web).
Auto Trait Implementations§
impl Freeze for MemoryStore
impl !RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl !UnwindSafe for MemoryStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more