Skip to main content

SettingsSource

Trait SettingsSource 

Source
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§

Source

fn load(&self) -> Map<String, Value>

Source

fn update_section(&self, name: &str, values: Map<String, Value>) -> Result<()>

Source

fn revision(&self) -> u64

Source

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§

Source

fn update_section_by( &self, name: &str, values: Map<String, Value>, origin: &ChangeOrigin, ) -> Result<()>

Source

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

As Self::update_section.

Source

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

As Self::update_section.

Source

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

As Self::update_section.

Source

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.

Source

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.

Source

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.

Source

fn flush_pending(&self)

Source

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".

Implementations on Foreign Types§

Source§

impl<T: SettingsSource + ?Sized> SettingsSource for Arc<T>

Source§

fn load(&self) -> Map<String, Value>

Source§

fn update_section(&self, name: &str, values: Map<String, Value>) -> Result<()>

Source§

fn update_section_by( &self, name: &str, values: Map<String, Value>, origin: &ChangeOrigin, ) -> Result<()>

Source§

fn update_section_with( &self, name: &str, origin: &ChangeOrigin, change: &mut SectionChange<'_>, ) -> Result<()>

Source§

fn update_sections( &self, sections: Vec<(String, Map<String, Value>)>, origin: &ChangeOrigin, ) -> Result<()>

Source§

fn compare_update_sections( &self, expected: &[(&str, Map<String, Value>)], sections: Vec<(String, Map<String, Value>)>, origin: &ChangeOrigin, ) -> Result<ConditionalUpdate>

Source§

fn readonly_refusal( &self, name: &str, values: &Map<String, Value>, ) -> Option<String>

Source§

fn step( &self, section: &str, app: Option<&str>, undo: bool, invokers: &[String], ) -> Result<bool>

Source§

fn stamps(&self, section: &str) -> Result<Vec<Stamp>>

Source§

fn flush_pending(&self)

Source§

fn take_deferred_failures(&self) -> Vec<DeferredFailure>

Source§

fn revision(&self) -> u64

Source§

fn changes(&self) -> &ChangeSignal

Implementors§