use crate::features; use crate::{Error, Model}; mod pro; pub use pro::Pro; #[derive(Debug)] pub enum Device { Pro(Pro), } impl Device { fn as_basic(&self) -> &dyn features::Basic { match self { Device::Pro(pro) => pro, } } } impl RawDevice for Device { fn execute(&self, command_id: impl Into, data: T) -> Result where T: serde::Serialize, U: serde::de::DeserializeOwned { match self { Device::Pro(pro) => pro.execute(command_id, data), } } } impl features::Basic for Device { fn get_model(&self) -> Model { self.as_basic().get_model() } fn get_status(&self) -> Result { self.as_basic().get_status() } fn get_user_retry_count(&self) -> Result { self.as_basic().get_user_retry_count() } fn get_admin_retry_count(&self) -> Result { self.as_basic().get_admin_retry_count() } } impl From for Device { fn from(pro: Pro) -> Device { Device::Pro(pro) } } pub(crate) trait RawDevice { fn execute(&self, command_id: impl Into, data: T) -> Result where T: serde::Serialize, U: serde::de::DeserializeOwned; }