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 TypedValue
s 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 asToCss
. - 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§
Sourcefn to_typed(&self) -> Option<TypedValue>
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.