#[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
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("Aranet\u{2622} 30ED1"), Some(DeviceType::AranetRadiation));
assert_eq!(DeviceType::from_name("Unknown Device"), None);Sourcepub fn has_temperature(&self) -> bool
pub fn has_temperature(&self) -> bool
Returns true if this device type has a temperature sensor.
Sourcepub fn has_humidity(&self) -> bool
pub fn has_humidity(&self) -> bool
Returns true if this device type has a humidity sensor.
Sourcepub fn has_pressure(&self) -> bool
pub fn has_pressure(&self) -> bool
Returns true if this device type has a pressure sensor.
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
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,
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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.