pub struct Tokens { /* private fields */ }Expand description
One origin’s declared tokens, in declaration order. Built with the
chaining constructors and handed to crate::Core::set_tokens whole;
each call replaces the caller’s table.
Implementations§
Source§impl Tokens
impl Tokens
pub fn new() -> Tokens
Sourcepub fn color(self, name: impl Into<String>, c: Color) -> Tokens
pub fn color(self, name: impl Into<String>, c: Color) -> Tokens
A colour with one value for both bases.
Sourcepub fn color_themed(
self,
name: impl Into<String>,
light: Color,
dark: Color,
) -> Tokens
pub fn color_themed( self, name: impl Into<String>, light: Color, dark: Color, ) -> Tokens
A colour with a value per base.
pub fn color_token(self, name: impl Into<String>, token: ColorToken) -> Tokens
Sourcepub fn derive(
self,
name: impl Into<String>,
from: &str,
ops: impl IntoIterator<Item = ColorOp>,
) -> Tokens
pub fn derive( self, name: impl Into<String>, from: &str, ops: impl IntoIterator<Item = ColorOp>, ) -> Tokens
A colour computed from another: from is a colour
token already in this table or a theme role, and ops the steps
applied to it in order, each colour operand likewise a name
declared before this one. A source that resolves to nothing —
undeclared, a length, this token itself, or one declared after it
— drops the declaration and is reported by Tokens::unresolved;
the core raises unknown-token for each when the table is set. An
empty chain is an alias.
Sourcepub fn length(self, name: impl Into<String>, px: f32) -> Tokens
pub fn length(self, name: impl Into<String>, px: f32) -> Tokens
A length in logical px, before env.scale.
Sourcepub fn id(&self, name: &str) -> Option<TokenRef>
pub fn id(&self, name: &str) -> Option<TokenRef>
The reference a declared name resolves to in this table alone — what a Rust app holds instead of the name.
pub fn color_id(&self, name: &str) -> Option<TokenRef>
pub fn length_id(&self, name: &str) -> Option<TokenRef>
Sourcepub fn colors(&self) -> &[(String, ColorToken)]
pub fn colors(&self) -> &[(String, ColorToken)]
The colours, in declaration order.
Sourcepub fn unresolved(&self) -> &[Unresolved]
pub fn unresolved(&self) -> &[Unresolved]
The derived tokens this declaration dropped, with the source that did not resolve.
pub fn is_empty(&self) -> bool
Sourcepub fn resolve_color(&self, i: u16, theme: &Theme) -> Color
pub fn resolve_color(&self, i: u16, theme: &Theme) -> Color
The colour token at i under theme: a value’s half, or a
derived token’s recipe folded over its source’s — recursing
through a derived source, which is always an earlier index. A
derived colour comes back rounded to eight bits a channel, so it is
exactly what a reader gets through 0xRRGGBBAA.
Sourcepub fn halves(&self, i: u16, theme: &Theme) -> (Color, Color)
pub fn halves(&self, i: u16, theme: &Theme) -> (Color, Color)
Both halves of the colour token at i, the light first: a value’s
as declared; a derived token’s computed under theme for the half
in effect and under a theme of the other appearance with the same
accent for the other — what the devtools show beside the swatch.
Trait Implementations§
impl StructuralPartialEq for Tokens
Auto Trait Implementations§
impl Freeze for Tokens
impl RefUnwindSafe for Tokens
impl Send for Tokens
impl Sync for Tokens
impl Unpin for Tokens
impl UnsafeUnpin for Tokens
impl UnwindSafe for Tokens
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.