Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SettingsBundleError

SettingsBundle — declarative configuration for the teksilo-app integration.

Public types

KindName
enumSettingsBundleError — Errors surfaced by SettingsBundle::open
structSettingsBundle — Declarative configuration for the persistence services an app wants installed
structOpenedSettings — The outcome of SettingsBundle::open: ready-to-register handles

Public functions

SettingsBundle

ReturnsFunction
Constructors
Selfnew()
Builder methods
Selfwith_store_name(name: impl Into<String>)
Selfwith_window_state(enabled: bool)
Selfwith_debounce(delay: Duration)
Methods
&strstore_name()
Durationdebounce()
Result<OpenedSettings, SettingsBundleError>open(paths: &AppPaths)

OpenedSettings

ReturnsFunction
Methods
Result<(), SettingsBundleError>flush_all()

Detailed description

TeksiloAppBuilder::settings(bundle) consumes a SettingsBundle, opens the requested services against the app's AppPaths, and registers each one in the application's app_state registry so it is reachable from any handler via the SettingsExt trait (use teksilo_settings::SettingsExt;).

What's in the bundle

Only services the framework can construct without app-level type information:

  • SettingsStore — the dynamic K/V store for scalar settings.
  • WindowStateService — per-window geometry persistence (opt-in via with_window_state).

Anything that needs an app-defined item type (recently-opened projects/files, color palettes, saved searches) is not in the bundle. Apps construct an MruList<T> for each such collection and register it themselves via TeksiloAppBuilder::app_state(handle).

Example

use teksilo_settings::{AppPaths, SettingsBundle};
use std::time::Duration;

let paths = AppPaths::for_testing(std::env::temp_dir());
let opened = SettingsBundle::new()
    .with_window_state(true)
    .with_debounce(Duration::ZERO)
    .open(&paths)
    .expect("bundle open failed");
// opened.store and opened.window_state are now ready to register.

API reference

📖 Full rustdoc API for this module

pub enum SettingsBundleError

Import: use teksilo::settings::SettingsBundleError;

Errors surfaced by SettingsBundle::open.

#![allow(unused)]
fn main() {
pub enum SettingsBundleError { /* variants */ }
}

Variants

  • Store (SettingsStoreError) — The K/V store could not be opened or flushed.
  • File (SettingsFileError) — A settings file (e.g. the window-state file) could not be opened or flushed.

pub struct SettingsBundle

Import: use teksilo::prelude::SettingsBundle; — in teksilo::prelude::*.

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));
#![allow(unused)]
fn main() {
pub struct SettingsBundle { /* fields */ }
}

Methods

pub fn new() -> Self

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

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

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

pub fn with_window_state(mut self, enabled: bool) -> Self (default: false)

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

pub fn with_debounce(mut self, delay: Duration) -> Self (default: DEFAULT_DEBOUNCE)

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

pub fn store_name(&self) -> &str

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

pub fn debounce(&self) -> Duration

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

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.

pub struct OpenedSettings

Import: use teksilo::settings::OpenedSettings;

The outcome of SettingsBundle::open: ready-to-register handles.

Clone is cheap and shared, not deep. Each contained service is internally Rc<>-shaped (matching ListModel<T> / TreeModel<T> / Signal<T>); cloning produces a second handle to the same in-memory state and the same shared I/O thread queue. Mutations through any clone are visible to every clone, and flush_all / Drop semantics are unchanged.

#![allow(unused)]
fn main() {
pub struct OpenedSettings { /* fields */ }
}

Fields

  • store: SettingsStore
  • window_state: Option<WindowStateService>
  • registry: SettingsRegistry — Registry mapping every managed service's canonical path to its live Reloadable handle, so a crate::SettingsWatcher event can be dispatched to the right one. Exposed so application code can register its own ad hoc crate::SettingsFile / crate::PersistedListModel / crate::MruList handles into the same registry (reachable elsewhere via ctx.app_state::<SettingsRegistry>() once installed).

Other fields are not public.

Methods

pub fn flush_all(&self) -> Result<(), SettingsBundleError>

Synchronously flush every active service.