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.
Only SettingsStore actually debounces on it — its writes are
frequent enough (every Signal::set) that coalescing matters.
WindowStateService accepts the same parameter (so open can
call both uniformly) but ignores it: SettingsFile’s writes are
always a synchronous locked read-modify-write now, so there is
nothing left to debounce (see file.rs’s and window_state.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