pub struct SettingsWatcher { /* private fields */ }Expand description
Active directory watcher over one or more settings directories. One
per TeksiloAppBuilder::run invocation (when a settings bundle with
watching enabled is configured).
Owns the notify::RecommendedWatcher background thread for its whole
lifetime; dropping the SettingsWatcher stops the watcher and cleans
up. Kept alive by the caller for as long as live reload is wanted —
teksilo-app stores it on its window-loop handler, exactly like
teksilo-i18n’s FtlFileWatcher.
Implementations§
Source§impl SettingsWatcher
impl SettingsWatcher
Sourcepub fn new(dirs: Vec<PathBuf>, sink: SettingsReloadSink) -> Result<Self, Error>
pub fn new(dirs: Vec<PathBuf>, sink: SettingsReloadSink) -> Result<Self, Error>
Build a watcher over dirs (deduplicated by canonical path, so
passing the same directory twice — e.g. AppPaths::for_testing,
whose config_dir() and data_dir() are the same tempdir — never
double-watches or double-fires) and a sink callback.
A directory that does not exist (or can’t be canonicalized for
any other reason) is logged and skipped — not fatal — since a
freshly-installed app may not have created its data directory yet
when this is called. As long as at least the config directory
exists (which AppPaths implies by the time SettingsBundle has
successfully opened anything in it), watching still works for the
files that matter.