Skip to main content

ColorComponentType

Trait ColorComponentType 

Source
pub trait ColorComponentType: Sized + Clone {
    // Required methods
    fn from_value(value: f32) -> Self;
    fn units() -> CalcUnits;
    fn try_from_token(token: &Token<'_>) -> Result<Self, ()>;
    fn try_from_leaf(leaf: &Leaf) -> Result<Self, ()>;
}
Expand description

An utility trait that allows the construction of ColorComponent ValueType’s after parsing a color component.

Required Methods§

Source

fn from_value(value: f32) -> Self

Construct a new component from a single value.

Source

fn units() -> CalcUnits

Return the CalcUnits flags that the impl can handle.

Source

fn try_from_token(token: &Token<'_>) -> Result<Self, ()>

Try to create a new component from the given token.

Source

fn try_from_leaf(leaf: &Leaf) -> Result<Self, ()>

Try to create a new component from the given [CalcNodeLeaf] that was resolved from a [CalcNode].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ColorComponentType for f32

The raw f32 here is for .

Source§

fn from_value(value: f32) -> Self

Source§

fn units() -> CalcUnits

Source§

fn try_from_token(token: &Token<'_>) -> Result<Self, ()>

Source§

fn try_from_leaf(leaf: &Leaf) -> Result<Self, ()>

Implementors§