pub struct ThemeManager { /* private fields */ }Expand description
Manages the active theme and optionally watches a theme file for changes.
Implementations§
Source§impl ThemeManager
impl ThemeManager
Sourcepub fn watch_file(&mut self, path: impl Into<PathBuf>) -> Result<()>
pub fn watch_file(&mut self, path: impl Into<PathBuf>) -> Result<()>
Start watching a theme file for changes.
The file format is auto-detected from the extension (.toml or .json).
On each call to ThemeManager::check_reload, the file’s mtime is
compared to the last known value; if it changed, the theme is reloaded.
Sourcepub fn theme_handle(&self) -> Arc<RwLock<Theme>>
pub fn theme_handle(&self) -> Arc<RwLock<Theme>>
Get a handle to the shared theme lock.
Sourcepub fn set_theme_by_name(&self, name: &str) -> bool
pub fn set_theme_by_name(&self, name: &str) -> bool
Set the active theme by name (“dark” or “light”).
Returns true if the name was recognized.
Sourcepub fn check_reload(&mut self) -> bool
pub fn check_reload(&mut self) -> bool
Check if the watched file has changed and reload if so.
Call this periodically (e.g. once per event-loop tick).
Returns true if the theme was reloaded.
Sourcepub fn set_poll_interval(&mut self, interval: Duration)
pub fn set_poll_interval(&mut self, interval: Duration)
Set the polling interval for file watching (default 1s).
Auto Trait Implementations§
impl Freeze for ThemeManager
impl !RefUnwindSafe for ThemeManager
impl Send for ThemeManager
impl Sync for ThemeManager
impl Unpin for ThemeManager
impl UnsafeUnpin for ThemeManager
impl !UnwindSafe for ThemeManager
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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