Skip to main content

Reloadable

Trait Reloadable 

Source
pub trait Reloadable {
    // Required methods
    fn path(&self) -> &Path;
    fn reload_from_disk(&self) -> Result<bool, SettingsFileError>;
}
Expand description

A persisted type that can be told “the file may have changed on disk — go look,” and will push any genuinely new content into its live signals/models.

This is the hook a file-system watcher calls when it observes a write to one of this crate’s managed files. It is deliberately decoupled from any particular watcher implementation (inotify, kqueue, ReadDirectoryChangesW) — this crate only defines the contract; wiring an actual watcher onto it is a separate concern (a file-watcher module built on top of this trait).

Required Methods§

Source

fn path(&self) -> &Path

The file this instance reads from and writes to. A watcher uses this to know which path to associate with which Reloadable handle.

Source

fn reload_from_disk(&self) -> Result<bool, SettingsFileError>

Re-read the file from disk and push any genuinely new content into live signals/models.

Returns Ok(true) if the in-memory state changed as a result, Ok(false) if nothing needed to change (including the common self-write-notification case — see the module docs’ “self-write suppression contract”). Ok(false) is a hard guarantee that nothing was touched: no signal fired, no model mutated.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Reloadable for SettingsStore

Source§

impl Reloadable for WindowStateService

Source§

impl<T> Reloadable for MruList<T>
where T: PartialEq + MruEntry,

Source§

impl<T> Reloadable for PersistedListModel<T>
where T: Keyed + Clone + Serialize + DeserializeOwned + Send + PartialEq + 'static,

Source§

impl<T> Reloadable for SettingsFile<T>

The content-equality backstop on top of SettingsFile::reload_if_stale — see reload.rs’s module docs for the two-layer contract. Requires T: PartialEq (only for this impl block; every other SettingsFile method is unaffected), since this is the only place that needs to ask “is the freshly-read value actually different from what’s live.”