pub struct DeviceModel {
pub name: String,
pub pins: HashMap<u8, PinModel>,
}Expand description
Device model defining the capabilities of all pins on a device
Fields§
§name: StringDevice model name
pins: HashMap<u8, PinModel>Map of pin numbers to pin models
Implementations§
Source§impl DeviceModel
impl DeviceModel
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the device model
Checks that the model is well-formed and that all related capabilities are properly defined.
§Returns
Result<()>- Ok if the model is valid, an error otherwise
Sourcepub fn is_pin_capability_supported(&self, pin_num: u8, capability: &str) -> bool
pub fn is_pin_capability_supported(&self, pin_num: u8, capability: &str) -> bool
Sourcepub fn get_pin_capabilities(&self, pin_num: u8) -> Vec<String>
pub fn get_pin_capabilities(&self, pin_num: u8) -> Vec<String>
Get related capabilities for a specific capability
For example, if the capability is “Encoder_1A”, this will return [(“Encoder_1B”, pin_num)] where pin_num is the pin that has the “Encoder_1B” capability.
§Arguments
pin_num- The pin number with the capabilitycapability- The capability to find related capabilities for
§Returns
Vec<(String, u8)>- List of related capabilities and their pin numbers
Sourcepub fn validate_pin_capability(
&self,
pin_num: u8,
capability: &str,
) -> Result<()>
pub fn validate_pin_capability( &self, pin_num: u8, capability: &str, ) -> Result<()>
Validate that a pin can be configured with a specific capability
This checks both that the pin supports the capability and that any related capabilities are properly configured.
§Arguments
pin_num- The pin number to checkcapability- The capability to check for
§Returns
Result<()>- Ok if the capability is valid, an error otherwise
Sourcepub fn validate_led_matrix_config(&self, config: &LedMatrixConfig) -> Result<()>
pub fn validate_led_matrix_config(&self, config: &LedMatrixConfig) -> Result<()>
Trait Implementations§
Source§impl Clone for DeviceModel
impl Clone for DeviceModel
Source§fn clone(&self) -> DeviceModel
fn clone(&self) -> DeviceModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceModel
impl Debug for DeviceModel
Source§impl<'de> Deserialize<'de> for DeviceModel
impl<'de> Deserialize<'de> for DeviceModel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DeviceModel
impl PartialEq for DeviceModel
Source§impl Serialize for DeviceModel
impl Serialize for DeviceModel
impl StructuralPartialEq for DeviceModel
Auto Trait Implementations§
impl Freeze for DeviceModel
impl RefUnwindSafe for DeviceModel
impl Send for DeviceModel
impl Sync for DeviceModel
impl Unpin for DeviceModel
impl UnwindSafe for DeviceModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more