pub struct SettingsBundle { /* private fields */ }Expand description
Declarative configuration for the persistence services an app wants installed.
use teksilo_settings::SettingsBundle;
use std::time::Duration;
let bundle = SettingsBundle::new()
.with_window_state(true)
.with_debounce(Duration::from_millis(250));Implementations§
Source§impl SettingsBundle
impl SettingsBundle
Sourcepub fn new() -> Self
pub fn new() -> Self
Default bundle: opens the K/V store under general.toml,
no window-state persistence.
Sourcepub fn with_store_name(self, name: impl Into<String>) -> Self
pub fn with_store_name(self, name: impl Into<String>) -> Self
Override the K/V store filename (without .toml). Default: general.
Sourcepub fn with_window_state(self, enabled: bool) -> Self
pub fn with_window_state(self, enabled: bool) -> Self
Enable the window-state service. The service stores
per-label entries, so a multi-window app records each
window’s geometry under its own label (e.g. "main",
"log", "inspector").
Sourcepub fn with_debounce(self, delay: Duration) -> Self
pub fn with_debounce(self, delay: Duration) -> Self
Override the debounce window passed to every service this bundle opens.
Both SettingsStore and WindowStateService actually debounce
on it: SettingsStore’s writes are frequent enough (every
Signal::set) that coalescing matters, and WindowStateService’s
record fires once per reported window-geometry frame during a
drag, so it schedules its own coalesced write through the same
delay via a DebouncedWriter (see window_state.rs’s module docs,
“record is debounced, not synchronous”). It is a plain
crate::SettingsFile — not opened by this bundle — whose writes
are always a synchronous locked read-modify-write, with nothing
left to debounce (see file.rs’s module docs).
Sourcepub fn store_name(&self) -> &str
pub fn store_name(&self) -> &str
The filename stem (without .toml) used for the K/V store.
Sourcepub fn debounce(&self) -> Duration
pub fn debounce(&self) -> Duration
The debounce window passed to every service this bundle opens
(see with_debounce for which services
actually honor it).
Sourcepub fn open(
self,
paths: &AppPaths,
) -> Result<OpenedSettings, SettingsBundleError>
pub fn open( self, paths: &AppPaths, ) -> Result<OpenedSettings, SettingsBundleError>
Open every requested service against paths.
Every opened service is also registered into a fresh
SettingsRegistry (exposed as OpenedSettings::registry) under
its canonical path, so a crate::SettingsWatcher event naming
that path can be dispatched straight to it. The registration
handles are retained internally by OpenedSettings — see its
field docs — so they stay alive (and thus dispatchable) for as
long as the returned OpenedSettings (or any clone of it) is.
Trait Implementations§
Source§impl Clone for SettingsBundle
impl Clone for SettingsBundle
Source§fn clone(&self) -> SettingsBundle
fn clone(&self) -> SettingsBundle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more