homie_controller

Trait Value

Source
pub trait Value: ToString + FromStr {
    // Required method
    fn datatype() -> Datatype;

    // Provided methods
    fn valid_for(
        datatype: Option<Datatype>,
        format: &Option<String>,
    ) -> Result<(), ValueError> { ... }
    fn valid_for_format(_format: &str) -> Result<(), ValueError> { ... }
}
Expand description

The value of a Homie property. This has implementations corresponding to the possible property datatypes.

Required Methods§

Source

fn datatype() -> Datatype

The Homie datatype corresponding to this type.

Provided Methods§

Source

fn valid_for( datatype: Option<Datatype>, format: &Option<String>, ) -> Result<(), ValueError>

Check whether this value type is valid for the given property datatype and format string.

Returns Ok(()) if so, or Err(WrongFormat(...)) or Err(WrongDatatype(...)) if not.

The default implementation checks the datatype, and delegates to valid_for_format to check the format.

Source

fn valid_for_format(_format: &str) -> Result<(), ValueError>

Check whether this value type is valid for the given property format string.

Returns Ok(()) if so, or Err(WrongFormat(...)) if not.

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

Source§

impl Value for f64

Source§

impl Value for i64

Source§

impl Value for String

Implementors§

Source§

impl Value for EnumValue

Source§

impl<T: Color> Value for T