pub struct ThemeRegistry { /* private fields */ }Expand description
All themes known to an application: the built-in ones plus any loaded from disk.
A loaded file with the same id as a built-in theme replaces it.
Implementations§
Source§impl ThemeRegistry
impl ThemeRegistry
Sourcepub fn add_source(&mut self, id: &str, file: &str, text: &str) -> bool
pub fn add_source(&mut self, id: &str, file: &str, text: &str) -> bool
Adds or replaces theme id from TOML text. Returns whether the file was usable.
Sourcepub fn load_dir(&mut self, dir: &Path) -> Result<()>
pub fn load_dir(&mut self, dir: &Path) -> Result<()>
Loads every *.toml file in dir; the file stem is the theme id.
§Errors
Returns the I/O error when the directory cannot be read. A file that cannot be read is skipped and reported in the diagnostics.
Sourcepub fn list(&self) -> Vec<(String, String)>
pub fn list(&self) -> Vec<(String, String)>
(id, display name) of every theme, sorted by id; for a settings screen.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Problems found while loading files.
Sourcepub fn resolve_or_default(&self, id: &str) -> (Theme, Vec<Diagnostic>)
pub fn resolve_or_default(&self, id: &str) -> (Theme, Vec<Diagnostic>)
Resolves theme id, falling back to the pristine built-in default theme when id
cannot be built. Diagnostics explain why a fallback happened.
Trait Implementations§
Source§impl Clone for ThemeRegistry
impl Clone for ThemeRegistry
Source§fn clone(&self) -> ThemeRegistry
fn clone(&self) -> ThemeRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ThemeRegistry
impl RefUnwindSafe for ThemeRegistry
impl Send for ThemeRegistry
impl Sync for ThemeRegistry
impl Unpin for ThemeRegistry
impl UnsafeUnpin for ThemeRegistry
impl UnwindSafe for ThemeRegistry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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