Skip to main content

ConfigManager

Struct ConfigManager 

Source
pub struct ConfigManager {
    pub dirty: bool,
    /* private fields */
}
Expand description

Watches config.toml for changes via periodic timestamp polling.

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: bool

Set to true by poll when the file changed.

Implementations§

Source§

impl ConfigManager

Source

pub fn new(dir: PathBuf) -> Self

Create a new manager, immediately loading the config from dir.

Source

pub fn poll(&mut self)

Re-read config from disk. Call this once per frame.

Source

pub fn ack(&mut self)

Acknowledge the dirty flag (call after applying changes).

Source

pub fn config(&self) -> &Config

Source

pub fn error(&self) -> Option<&str>

Error message from the last failed config load/parse, if any.

Source

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.

Source

pub fn save_custom_theme(&mut self, colors: CustomThemeColors)

Set custom theme colour overrides in config and persist.

Source

pub fn tick_rate(&self) -> Duration

Source

pub fn set_tick_rate(&mut self, duration: Duration)

Source

pub fn clear_custom_theme(&mut self)

Remove custom theme colour overrides from config and persist.

Trait Implementations§

Source§

impl Debug for ConfigManager

Source§

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

Formats the value using the given formatter. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.