Skip to main content

FromProp

Trait FromProp 

Source
pub trait FromProp: Sized {
    const TYPE_NAME: &'static str;

    // Required method
    fn from_prop(
        pi: &PropInput<'_>,
        widget: &str,
        prop: &str,
    ) -> Result<Self, InflateError>;
}
Expand description

Convert a resolved prop (PropInput) into a setter’s argument type.

This is the typed edge between the untyped template/hole world and a widget’s strongly-typed builder. A build closure calls f32::from_prop(v, ..) to get the value for .spacing(f32). Implement it for your own prop types so inflatable!-registered widgets can accept them (mirrors the extensibility of the widget registry itself).

Required Associated Constants§

Source

const TYPE_NAME: &'static str

The name shown in a InflateError::PropType when extraction fails.

Required Methods§

Source

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromProp for String

Source§

const TYPE_NAME: &'static str = "string"

Source§

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Source§

impl FromProp for bool

Source§

const TYPE_NAME: &'static str = "bool"

Source§

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Source§

impl FromProp for f32

Source§

const TYPE_NAME: &'static str = "f32"

Source§

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Source§

impl FromProp for f64

Source§

const TYPE_NAME: &'static str = "f64"

Source§

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Source§

impl FromProp for i64

Source§

const TYPE_NAME: &'static str = "i64"

Source§

fn from_prop( pi: &PropInput<'_>, widget: &str, prop: &str, ) -> Result<Self, InflateError>

Implementors§

Source§

impl FromProp for Handler

A handler is always a hole (a closure can’t be a literal). The compiled binary wraps it as Handler and puts it in the hole array; here we downcast it back.

Source§

const TYPE_NAME: &'static str = "handler"