Skip to main content

FromFeatureStateProperty

Trait FromFeatureStateProperty 

Source
pub trait FromFeatureStateProperty: Sized {
    // Required method
    fn from_feature_state_property(prop: &PropertyValue) -> Option<Self>;
}
Expand description

Conversion from a PropertyValue stored in feature-state to a concrete style value type.

Types that have a natural representation in PropertyValue (f32 from Number, bool from Bool, String from String) implement this directly. Types without a mapping (e.g. [f32; 4] colour tuples, enum variants) return None so the fallback value is used instead.

This trait is intentionally sealed to StyleInterpolatable implementors and does not need to be implemented by downstream code.

Required Methods§

Source

fn from_feature_state_property(prop: &PropertyValue) -> Option<Self>

Attempt to convert a property value. Returns None when the PropertyValue variant does not map to Self.

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 FromFeatureStateProperty for bool

Source§

impl FromFeatureStateProperty for f32

Source§

impl FromFeatureStateProperty for String

Source§

impl FromFeatureStateProperty for [f32; 4]

Source§

fn from_feature_state_property(_prop: &PropertyValue) -> Option<Self>

Colour tuples cannot be expressed in a single PropertyValue today.

Implementors§