pub struct GroupAddress { /* private fields */ }Expand description
KNX Group Address
Used for logical grouping of devices and functions.
§Examples
use knx_pico::GroupAddress;
// Create 3-level address
let addr = GroupAddress::new(1, 2, 3).unwrap();
assert_eq!(addr.to_string(), "1/2/3");
// Create 2-level address
let addr = GroupAddress::new_2level(1, 234).unwrap();
assert_eq!(addr.to_string_2level(), "1/234");
// Create from raw u16
let addr = GroupAddress::from(0x0A03u16);
assert_eq!(addr.main(), 1);
assert_eq!(addr.middle(), 2);
assert_eq!(addr.sub(), 3);
// Parse from string (auto-detects format)
let addr: GroupAddress = "1/2/3".parse().unwrap();
assert_eq!(u16::from(addr), 0x0A03);Implementations§
Source§impl GroupAddress
impl GroupAddress
Sourcepub const MAX_MIDDLE: u8 = 7u8
pub const MAX_MIDDLE: u8 = 7u8
Maximum middle group value (3 bits)
Sourcepub const MAX_SUB_2LEVEL: u16 = 2_047u16
pub const MAX_SUB_2LEVEL: u16 = 2_047u16
Maximum sub value for 2-level format (11 bits)
Sourcepub fn new_2level(main: u8, sub: u16) -> Result<Self>
pub fn new_2level(main: u8, sub: u16) -> Result<Self>
Sourcepub fn from_array(parts: [u8; 3]) -> Result<Self>
pub fn from_array(parts: [u8; 3]) -> Result<Self>
Create from a 3-element array [main, middle, sub].
Convenient for creating 3-level addresses from array literals.
§Examples
use knx_pico::GroupAddress;
let addr = GroupAddress::from_array([1, 2, 3])?;
assert_eq!(addr.to_string(), "1/2/3");Sourcepub const fn sub_2level(self) -> u16
pub const fn sub_2level(self) -> u16
Get the sub group component for 2-level format (0-2047).
Sourcepub fn to_string_3level(&self) -> String<16>
pub fn to_string_3level(&self) -> String<16>
Format as 3-level string (Main/Middle/Sub).
§Panics
May panic if the formatted string exceeds 16 bytes capacity, though this should never occur in practice as the maximum length is “31/7/255” (9 bytes).
Sourcepub fn to_string_2level(&self) -> String<16>
pub fn to_string_2level(&self) -> String<16>
Format as 2-level string (Main/Sub).
§Panics
May panic if the formatted string exceeds 16 bytes capacity, though this should never occur in practice as the maximum length is “31/2047” (8 bytes).
Trait Implementations§
Source§impl Clone for GroupAddress
impl Clone for GroupAddress
Source§fn clone(&self) -> GroupAddress
fn clone(&self) -> GroupAddress
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 GroupAddress
impl Debug for GroupAddress
Source§impl Display for GroupAddress
impl Display for GroupAddress
Source§impl Format for GroupAddress
impl Format for GroupAddress
Source§impl From<GroupAddress> for u16
impl From<GroupAddress> for u16
Source§fn from(addr: GroupAddress) -> u16
fn from(addr: GroupAddress) -> u16
Converts to this type from the input type.
Source§impl From<u16> for GroupAddress
impl From<u16> for GroupAddress
Source§impl FromStr for GroupAddress
impl FromStr for GroupAddress
Source§impl Hash for GroupAddress
impl Hash for GroupAddress
Source§impl PartialEq for GroupAddress
impl PartialEq for GroupAddress
impl Copy for GroupAddress
impl Eq for GroupAddress
impl StructuralPartialEq for GroupAddress
Auto Trait Implementations§
impl Freeze for GroupAddress
impl RefUnwindSafe for GroupAddress
impl Send for GroupAddress
impl Sync for GroupAddress
impl Unpin for GroupAddress
impl UnwindSafe for GroupAddress
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