Struct syntastica::theme::Theme
pub struct Theme(/* private fields */);
Expand description
A raw theme which may contain links to other items inside.
Internally, this type stores a map from String
s to ThemeValue
s. This map can be
retrieved using Theme::into_inner
. The map keys do not all have to be in THEME_KEYS
;
other custom keys can be used, for example to define a set of colors and reuse them with links
everywhere else.
When using the serde
feature, this type
implements serde’s Serialize
and Deserialize
traits.
Instantiation
The easiest way to create a Theme
is with the theme!
macro.
Alternatively, a Theme
may be created from a BTreeMap<String, ThemeValue>
using
Theme::new
.
Implementations§
§impl Theme
impl Theme
pub fn new(highlights: BTreeMap<String, ThemeValue, Global>) -> Theme
pub fn new(highlights: BTreeMap<String, ThemeValue, Global>) -> Theme
Create a new Theme
from a map of theme keys to ThemeValue
s.
pub fn into_inner(self) -> BTreeMap<String, ThemeValue, Global>
pub fn into_inner(self) -> BTreeMap<String, ThemeValue, Global>
Consume self
and return the contained theme map.
May be used to merge multiple Theme
s together.
pub fn resolve_links(self) -> Result<ResolvedTheme, Error>
pub fn resolve_links(self) -> Result<ResolvedTheme, Error>
Try to resolve all links in this Theme
and return a ResolvedTheme
.
Errors
The function may return the following errors:
Error::InvalidHex
if a color string was an invalid hexadecimal literal.Error::InvalidLink
if a link points to a non-existent key.
Trait Implementations§
§impl<'de> Deserialize<'de> for Theme
impl<'de> Deserialize<'de> for Theme
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Theme, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Theme, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
§impl Serialize for Theme
impl Serialize for Theme
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
§impl TryFrom<Theme> for ResolvedTheme
impl TryFrom<Theme> for ResolvedTheme
§fn try_from(value: Theme) -> Result<ResolvedTheme, Error>
fn try_from(value: Theme) -> Result<ResolvedTheme, Error>
Try to create a ResolvedTheme
from a Theme
by calling Theme::resolve_links
.
impl Eq for Theme
impl StructuralEq for Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnwindSafe for Theme
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<'a, T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<'a, T, C> TryComponentsInto<C> for Twhere C: TryFromComponents<T>,
§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more