Skip to main content

PropType

Trait PropType 

pub trait PropType: Sized {
    // Required methods
    fn ty() -> Type;
    fn from_value(value: &Value) -> Result<Self, String>;

    // Provided method
    fn read(value: &Value, source: &mut dyn Source) -> Result<Self, String> { ... }
}
Expand description

A Rust type a prop (or state, or an event’s value) may have: its Type in a description, and how a Value of it reads.

Required Methods§

fn ty() -> Type

fn from_value(value: &Value) -> Result<Self, String>

§Errors

The value is of another type.

Provided Methods§

fn read(value: &Value, source: &mut dyn Source) -> Result<Self, String>

The value as the instance source gives it: what it reads beside the value itself (the event an offered action fires) is the instance’s.

§Errors

The value is of another type.

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§

§

impl PropType for bool

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<bool, String>

§

impl PropType for f64

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<f64, String>

§

impl PropType for i64

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<i64, String>

§

impl PropType for String

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<String, String>

§

impl PropType for RichText

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<RichText, String>

§

impl<K, V> PropType for BTreeMap<K, V>
where K: PropType + Ord, V: PropType,

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<BTreeMap<K, V>, String>

§

fn read( value: &Value, source: &mut dyn Source, ) -> Result<BTreeMap<K, V>, String>

§

impl<T> PropType for Option<T>
where T: PropType,

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<Option<T>, String>

§

fn read(value: &Value, source: &mut dyn Source) -> Result<Option<T>, String>

§

impl<T> PropType for BTreeSet<T>
where T: PropType + Ord,

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<BTreeSet<T>, String>

§

impl<T> PropType for Vec<T>
where T: PropType,

§

fn ty() -> Type

§

fn from_value(value: &Value) -> Result<Vec<T>, String>

§

fn read(value: &Value, source: &mut dyn Source) -> Result<Vec<T>, String>

Implementors§