Setting

Trait Setting 

Source
pub trait Setting {
    type Item: Copy;

    // Required methods
    fn set(&self, value: Self::Item);
    fn set_string(&self, value: &str);
    fn get(&self) -> Self::Item;

    // Provided method
    fn is_valid(&self, _value: &str) -> bool { ... }
}
Expand description

A setting can be set and get

A setting can be multiple borrowed since the update function does not require a &mut self mutating reference

§Example

    use embedded_multi_page_hmi::{CellSetting, Setting};
    let setting: CellSetting<f32> = Default::default();
    let s1 = &setting;
    let s2 = &setting;
    assert_eq!(0.0f32, s1.get());
    assert_eq!(0.0f32, s2.get());
    s1.set(32.0);
    assert_eq!(32.0f32, s1.get());
    assert_eq!(32.0f32, s2.get());

Required Associated Types§

Required Methods§

Source

fn set(&self, value: Self::Item)

Set the value of the setting

The set function does not require a &mut self parameter on purpose

Source

fn set_string(&self, value: &str)

Set the value of the setting obtained from string slice

The set function does not require a &mut self parameter on purpose

Source

fn get(&self) -> Self::Item

Get the value of the setting into a string slice

Provided Methods§

Source

fn is_valid(&self, _value: &str) -> bool

Check if a certain string represented setting value meets the type spec of the setting.

An example is a range check of the number, or check for a certain regex pattern.

Implementors§

Source§

impl<T: Copy + FromStr> Setting for CellSetting<T>
where <T as FromStr>::Err: Debug,

Source§

type Item = T