pub struct DeviceState {
pub device_info: DeviceInfo,
pub device_data: DeviceData,
pub model: Option<DeviceModel>,
pub pins: Vec<PinData>,
pub encoders: Vec<EncoderData>,
pub pwm: PwmData,
pub last_update: u64,
pub status: ThreadStatus,
pub error_message: Option<String>,
pub custom_values: HashMap<String, String>,
}Expand description
Device state that is shared between threads.
This struct contains all the state information for a device, including device information, pin data, encoder data, and PWM data.
Fields§
§device_info: DeviceInfoDevice information
device_data: DeviceDataDevice data
model: Option<DeviceModel>Device model
pins: Vec<PinData>Pin data
encoders: Vec<EncoderData>Encoder data
pwm: PwmDataPWM data
last_update: u64Last update timestamp
status: ThreadStatusThread status
error_message: Option<String>Error message if any
custom_values: HashMap<String, String>Custom state values
Implementations§
Source§impl DeviceState
impl DeviceState
Sourcepub fn new(device_info: DeviceInfo, device_data: DeviceData) -> Self
pub fn new(device_info: DeviceInfo, device_data: DeviceData) -> Self
Sourcepub fn update_from_device(&mut self, device: &PoKeysDevice)
pub fn update_from_device(&mut self, device: &PoKeysDevice)
Sourcepub fn get_digital_input(&self, pin: u32) -> Option<bool>
pub fn get_digital_input(&self, pin: u32) -> Option<bool>
Sourcepub fn get_analog_input(&self, pin: u32) -> Option<u32>
pub fn get_analog_input(&self, pin: u32) -> Option<u32>
Sourcepub fn get_encoder_value(&self, encoder_index: u32) -> Option<i32>
pub fn get_encoder_value(&self, encoder_index: u32) -> Option<i32>
Trait Implementations§
Source§impl Clone for DeviceState
impl Clone for DeviceState
Source§fn clone(&self) -> DeviceState
fn clone(&self) -> DeviceState
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 DeviceState
impl Debug for DeviceState
Source§impl<'de> Deserialize<'de> for DeviceState
impl<'de> Deserialize<'de> for DeviceState
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
Auto Trait Implementations§
impl Freeze for DeviceState
impl RefUnwindSafe for DeviceState
impl Send for DeviceState
impl Sync for DeviceState
impl Unpin for DeviceState
impl UnwindSafe for DeviceState
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