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§
Sourcefn set(&self, value: Self::Item)
fn set(&self, value: Self::Item)
Set the value of the setting
The set function does not require a &mut self parameter on purpose
Sourcefn set_string(&self, value: &str)
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