pub trait SettingsSource: Send + Sync {
Show 13 methods
// Required methods
fn load(&self) -> Map<String, Value>;
fn update_section(
&self,
name: &str,
values: Map<String, Value>,
) -> Result<()>;
fn revision(&self) -> u64;
fn changes(&self) -> &ChangeSignal;
// Provided methods
fn update_section_by(
&self,
name: &str,
values: Map<String, Value>,
origin: &ChangeOrigin,
) -> Result<()> { ... }
fn update_section_with(
&self,
name: &str,
origin: &ChangeOrigin,
change: &mut SectionChange<'_>,
) -> Result<()> { ... }
fn update_sections(
&self,
sections: Vec<(String, Map<String, Value>)>,
origin: &ChangeOrigin,
) -> Result<()> { ... }
fn compare_update_sections(
&self,
_expected: &[(&str, Map<String, Value>)],
_sections: Vec<(String, Map<String, Value>)>,
_origin: &ChangeOrigin,
) -> Result<ConditionalUpdate> { ... }
fn readonly_refusal(
&self,
_name: &str,
_values: &Map<String, Value>,
) -> Option<String> { ... }
fn step(
&self,
_section: &str,
_app: Option<&str>,
_undo: bool,
_invokers: &[String],
) -> Result<bool> { ... }
fn stamps(&self, _section: &str) -> Result<Vec<Stamp>> { ... }
fn flush_pending(&self) { ... }
fn take_deferred_failures(&self) -> Vec<DeferredFailure> { ... }
}Required Methods§
fn load(&self) -> Map<String, Value>
fn update_section(&self, name: &str, values: Map<String, Value>) -> Result<()>
fn revision(&self) -> u64
Sourcefn changes(&self) -> &ChangeSignal
fn changes(&self) -> &ChangeSignal
Rings every time Self::revision changes, so a reader waiting for
a change wakes at once instead of looking again and again.
Provided Methods§
fn update_section_by( &self, name: &str, values: Map<String, Value>, origin: &ChangeOrigin, ) -> Result<()>
Sourcefn update_section_with(
&self,
name: &str,
origin: &ChangeOrigin,
change: &mut SectionChange<'_>,
) -> Result<()>
fn update_section_with( &self, name: &str, origin: &ChangeOrigin, change: &mut SectionChange<'_>, ) -> Result<()>
Read section name and merge what change makes of it, recording
origin, as one step no other write to this source lands inside.
This is the read-modify-write behind a typed key’s update: a toggle
pressed twice in quick succession flips twice.
The default reads and then writes, which is atomic only where the source’s writer serialises them itself (an app’s settings channel, whose host applies writes in order); a source that owns its document overrides it to hold its lock across both.
§Errors
Sourcefn update_sections(
&self,
sections: Vec<(String, Map<String, Value>)>,
origin: &ChangeOrigin,
) -> Result<()>
fn update_sections( &self, sections: Vec<(String, Map<String, Value>)>, origin: &ChangeOrigin, ) -> Result<()>
Merge each of sections as one change made by origin: one step history takes back
together, a choice spanning sections (the model agents answer with) included.
§Errors
Sourcefn compare_update_sections(
&self,
_expected: &[(&str, Map<String, Value>)],
_sections: Vec<(String, Map<String, Value>)>,
_origin: &ChangeOrigin,
) -> Result<ConditionalUpdate>
fn compare_update_sections( &self, _expected: &[(&str, Map<String, Value>)], _sections: Vec<(String, Map<String, Value>)>, _origin: &ChangeOrigin, ) -> Result<ConditionalUpdate>
Self::update_sections, only if each of expected (a section, and what it held when
the caller read it) still holds what it did. Superseded means a newer change replaced
what the caller read.
§Errors
Sourcefn readonly_refusal(
&self,
_name: &str,
_values: &Map<String, Value>,
) -> Option<String>
fn readonly_refusal( &self, _name: &str, _values: &Map<String, Value>, ) -> Option<String>
Why writing values to section name is refused — a field the section declares read only
would change — asked before the settings channel writes an app’s values there. The field
is changed by the action a section declares and by nothing else, so no app’s write reaches
it. None from a source that keeps no such declarations.
Sourcefn step(
&self,
_section: &str,
_app: Option<&str>,
_undo: bool,
_invokers: &[String],
) -> Result<bool>
fn step( &self, _section: &str, _app: Option<&str>, _undo: bool, _invokers: &[String], ) -> Result<bool>
Take back (undo) or bring back the last step any of invokers (actors, as a change
names them) took on section section, of the app app where the section keeps each
app’s preferences apart. Whether there was one.
§Errors
The settings’ history is not kept here, or the step was refused.
Sourcefn stamps(&self, _section: &str) -> Result<Vec<Stamp>>
fn stamps(&self, _section: &str) -> Result<Vec<Stamp>>
The changes of section section, oldest first, each as the stamp it carries in the
settings’ history (or will, once written): which setter set what, and who invoked it.
§Errors
The settings’ history is not kept here.
fn flush_pending(&self)
fn take_deferred_failures(&self) -> Vec<DeferredFailure>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".