Skip to main content

SettingsBundle

Struct SettingsBundle 

Source
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

Source

pub fn new() -> Self

Default bundle: opens the K/V store under general.toml, no window-state persistence.

Source

pub fn with_store_name(self, name: impl Into<String>) -> Self

Override the K/V store filename (without .toml). Default: general.

Source

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

Source

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

Source

pub fn store_name(&self) -> &str

The filename stem (without .toml) used for the K/V store.

Source

pub fn debounce(&self) -> Duration

The debounce window passed to every service this bundle opens (see with_debounce for which services actually honor it).

Source

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

Source§

fn clone(&self) -> SettingsBundle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SettingsBundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SettingsBundle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.