pub struct SettingsHandle<T> { /* private fields */ }Implementations§
Source§impl<T> SettingsHandle<T>
impl<T> SettingsHandle<T>
Sourcepub fn new(initial: T, backend: Box<dyn StorageBackend>) -> SettingsHandle<T>
pub fn new(initial: T, backend: Box<dyn StorageBackend>) -> SettingsHandle<T>
Creates a settings handle and initializes diff state from the backend.
Sourcepub fn new_with_stored(
initial: T,
backend: Box<dyn StorageBackend>,
stored: HashMap<String, StoredValue>,
) -> SettingsHandle<T>
pub fn new_with_stored( initial: T, backend: Box<dyn StorageBackend>, stored: HashMap<String, StoredValue>, ) -> SettingsHandle<T>
Creates a settings handle with caller-provided persisted values.
This constructor is used when startup code has already loaded persisted values to resolve the initial settings snapshot. Passing the same map into the handle keeps the cross-process diff state aligned with that snapshot without reading the backend a second time.
Sourcepub fn new_with_stored_and_applier(
initial: T,
backend: Box<dyn StorageBackend>,
stored: HashMap<String, StoredValue>,
external_applier: Box<dyn Fn(&mut T, &str, &StoredValue) -> ApplyResult + Sync + Send>,
) -> SettingsHandle<T>
pub fn new_with_stored_and_applier( initial: T, backend: Box<dyn StorageBackend>, stored: HashMap<String, StoredValue>, external_applier: Box<dyn Fn(&mut T, &str, &StoredValue) -> ApplyResult + Sync + Send>, ) -> SettingsHandle<T>
Creates a settings handle with caller-provided persisted values and an external applier.
This constructor is used by generated settings code that has already
loaded stored values and can also map persisted storage keys back onto
fields in T. The applier is called when the cross-process diff loop
observes an external stored-value change; successful applications update
the in-memory snapshot before the corresponding change event is
broadcast.
pub fn snapshot(&self) -> Arc<T>
pub fn on_change(&self) -> Receiver<ChangeEvent>
pub fn write_field( &self, key: &str, old_value: Option<StoredValue>, new_value: StoredValue, mutator: impl FnOnce(&mut T), ) -> Result<(), SettingsError>
Trait Implementations§
Source§impl<T> Clone for SettingsHandle<T>
impl<T> Clone for SettingsHandle<T>
Source§fn clone(&self) -> SettingsHandle<T>
fn clone(&self) -> SettingsHandle<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more