#[non_exhaustive]#[repr(u8)]pub enum DeviceType {
Aranet4 = 241,
Aranet2 = 242,
AranetRadon = 243,
AranetRadiation = 244,
}Expand description
Type of Aranet device.
This enum is marked #[non_exhaustive] to allow adding new device types
in future versions without breaking downstream code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Aranet4 = 241
Aranet4 CO2, temperature, humidity, and pressure sensor.
Aranet2 = 242
Aranet2 temperature and humidity sensor.
AranetRadon = 243
Aranet Radon sensor.
AranetRadiation = 244
Aranet Radiation sensor.
Implementations§
Source§impl DeviceType
impl DeviceType
Sourcepub fn from_name(name: &str) -> Option<DeviceType>
pub fn from_name(name: &str) -> Option<DeviceType>
Detect device type from a device name.
Analyzes the device name (case-insensitive) to determine the device type
based on common naming patterns. Uses word-boundary-aware matching to avoid
false positives (e.g., "Aranet4" won’t match "NotAranet4Device").
§Examples
use aranet_types::DeviceType;
assert_eq!(DeviceType::from_name("Aranet4 12345"), Some(DeviceType::Aranet4));
assert_eq!(DeviceType::from_name("Aranet2 Home"), Some(DeviceType::Aranet2));
assert_eq!(DeviceType::from_name("Aranet4"), Some(DeviceType::Aranet4));
assert_eq!(DeviceType::from_name("AranetRn+ 306B8"), Some(DeviceType::AranetRadon));
assert_eq!(DeviceType::from_name("RN+ Radon"), Some(DeviceType::AranetRadon));
assert_eq!(DeviceType::from_name("Aranet Radiation"), Some(DeviceType::AranetRadiation));
assert_eq!(DeviceType::from_name("Unknown Device"), None);Sourcepub fn readings_characteristic(&self) -> Uuid
pub fn readings_characteristic(&self) -> Uuid
Returns the BLE characteristic UUID for reading current sensor values.
- Aranet4: Uses
CURRENT_READINGS_DETAIL(f0cd3001) - Other devices: Use
CURRENT_READINGS_DETAIL_ALT(f0cd3003)
§Examples
use aranet_types::DeviceType;
use aranet_types::ble;
assert_eq!(DeviceType::Aranet4.readings_characteristic(), ble::CURRENT_READINGS_DETAIL);
assert_eq!(DeviceType::Aranet2.readings_characteristic(), ble::CURRENT_READINGS_DETAIL_ALT);Trait Implementations§
Source§impl Clone for DeviceType
impl Clone for DeviceType
Source§fn clone(&self) -> DeviceType
fn clone(&self) -> DeviceType
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 DeviceType
impl Debug for DeviceType
Source§impl<'de> Deserialize<'de> for DeviceType
impl<'de> Deserialize<'de> for DeviceType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DeviceType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DeviceType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for DeviceType
impl Display for DeviceType
Source§impl Hash for DeviceType
impl Hash for DeviceType
Source§impl PartialEq for DeviceType
impl PartialEq for DeviceType
Source§impl Serialize for DeviceType
impl Serialize for DeviceType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<u8> for DeviceType
impl TryFrom<u8> for DeviceType
Source§fn try_from(value: u8) -> Result<DeviceType, <DeviceType as TryFrom<u8>>::Error>
fn try_from(value: u8) -> Result<DeviceType, <DeviceType as TryFrom<u8>>::Error>
Convert a byte value to a DeviceType.
§Examples
use aranet_types::DeviceType;
assert_eq!(DeviceType::try_from(0xF1), Ok(DeviceType::Aranet4));
assert_eq!(DeviceType::try_from(0xF2), Ok(DeviceType::Aranet2));
assert!(DeviceType::try_from(0x00).is_err());Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
impl Copy for DeviceType
impl Eq for DeviceType
impl StructuralPartialEq for DeviceType
Auto Trait Implementations§
impl Freeze for DeviceType
impl RefUnwindSafe for DeviceType
impl Send for DeviceType
impl Sync for DeviceType
impl Unpin for DeviceType
impl UnwindSafe for DeviceType
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