pub struct Theme { /* private fields */ }Implementations§
Source§impl Theme
impl Theme
Sourcepub fn from_styles(styles: BTreeMap<String, Style>) -> Self
pub fn from_styles(styles: BTreeMap<String, Style>) -> Self
Creates a theme from a style map after normalizing capture names.
Sourcepub fn insert(
&mut self,
capture_name: impl AsRef<str>,
style: Style,
) -> Option<Style>
pub fn insert( &mut self, capture_name: impl AsRef<str>, style: Style, ) -> Option<Style>
Inserts or replaces a style for a capture name.
Capture names are normalized (trimmed, lowercased, optional @ removed).
Returns the previously associated style, if any.
Sourcepub fn get_exact(&self, capture_name: &str) -> Option<&Style>
pub fn get_exact(&self, capture_name: &str) -> Option<&Style>
Returns the exact style for a capture after normalization.
Sourcepub fn resolve(&self, capture_name: &str) -> Option<&Style>
pub fn resolve(&self, capture_name: &str) -> Option<&Style>
Resolves a style using dotted-name fallback and finally normal.
For example, comment.documentation falls back to comment before
attempting normal.
Sourcepub fn from_json_str(input: &str) -> Result<Self, ThemeError>
pub fn from_json_str(input: &str) -> Result<Self, ThemeError>
Parses a theme from JSON.
Both wrapped ({ "styles": { ... } }) and flat style documents are accepted.
§Errors
Returns an error if the JSON cannot be parsed.
Sourcepub fn from_toml_str(input: &str) -> Result<Self, ThemeError>
pub fn from_toml_str(input: &str) -> Result<Self, ThemeError>
Sourcepub fn from_builtin(theme: BuiltinTheme) -> Result<Self, ThemeError>
pub fn from_builtin(theme: BuiltinTheme) -> Result<Self, ThemeError>
Loads a built-in theme from embedded JSON.
§Errors
Returns an error if embedded theme JSON fails to parse.
Sourcepub fn from_builtin_name(name: &str) -> Result<Self, ThemeError>
pub fn from_builtin_name(name: &str) -> Result<Self, ThemeError>
Loads a built-in theme from a name or alias.
§Errors
Returns ThemeError::UnknownBuiltinTheme for unknown names.
Trait Implementations§
impl Eq for Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.