Trait ToTyped

Source
pub trait ToTyped {
    // Provided method
    fn to_typed(&self) -> Option<TypedValue> { ... }
}
Expand description

Reifies a value into its Typed OM representation.

This trait is the Typed OM analogue of ToCss. Instead of serializing values into CSS syntax, it converts them into TypedValues that can be exposed to the DOM as CSSStyleValue subclasses.

This trait is derivable with #[derive(ToTyped)]. The derived implementation behaves as follows:

  • For enums whose variants are all unit variants (representing keywords), it automatically reifies the value as TypedValue::Keyword, using the same serialization logic as ToCss.
  • For all other cases, the derived implementation does not attempt to reify anything and falls back to the default method (which always returns None).

Over time, the derive may be extended to cover additional common patterns, similar to how ToCss supports multiple attribute annotations.

Provided Methods§

Source

fn to_typed(&self) -> Option<TypedValue>

Attempt to convert self into a TypedValue.

Returns Some(TypedValue) if the value can be reified into a property-agnostic CSSStyleValue subclass. Returns None if the value is unrepresentable, in which case reification produces a property-tied CSSStyleValue instead.

Implementations on Foreign Types§

Source§

impl ToTyped for Au

Source§

impl<'a> ToTyped for f32

Source§

impl<'a> ToTyped for i8

Source§

impl<'a> ToTyped for i32

Source§

impl<T> ToTyped for Box<T>
where T: ?Sized + ToTyped,

Implementors§