pub struct ConfigManager {
pub dirty: bool,
/* private fields */
}Expand description
Watches config.toml for changes via filesystem notifications, with
periodic mtime polling as a fallback.
Call ConfigManager::poll once per frame in the main loop. When the
file has been modified externally dirty is set to true and the new
config is available via ConfigManager::config.
Fields§
§dirty: boolSet to true by poll when the file changed.
Implementations§
Source§impl ConfigManager
impl ConfigManager
Sourcepub fn new(dir: PathBuf) -> Self
pub fn new(dir: PathBuf) -> Self
Create a new manager, immediately loading the config from dir and
attempting to set up a filesystem watcher.
Sourcepub fn poll(&mut self)
pub fn poll(&mut self)
Re-read config from disk. Call this once per frame.
When a filesystem watcher is active, events are drained immediately (no throttling). The mtime-based polling fallback runs every 30 frames on platforms without a working watcher.
pub fn config(&self) -> &Config
Sourcepub fn error(&self) -> Option<&str>
pub fn error(&self) -> Option<&str>
Error message from the last failed config load/parse, if any.
Sourcepub fn save_theme(&mut self, theme_name: &str)
pub fn save_theme(&mut self, theme_name: &str)
Update the theme field and immediately persist.
When selecting a built-in theme, custom overrides are cleared so they
don’t leak into the newly chosen theme.
Sourcepub fn save_custom_theme(&mut self, colors: CustomThemeColors)
pub fn save_custom_theme(&mut self, colors: CustomThemeColors)
Set custom theme colour overrides in config and persist.
pub fn tick_rate(&self) -> Duration
pub fn set_tick_rate(&mut self, duration: Duration)
Sourcepub fn clear_custom_theme(&mut self)
pub fn clear_custom_theme(&mut self)
Remove custom theme colour overrides from config and persist.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for ConfigManager
impl Freeze for ConfigManager
impl RefUnwindSafe for ConfigManager
impl Send for ConfigManager
impl Unpin for ConfigManager
impl UnsafeUnpin for ConfigManager
impl UnwindSafe for ConfigManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more