pub struct IndividualAddress { /* private fields */ }Expand description
KNX Individual Address (Area.Line.Device)
Used to identify physical devices on the KNX bus.
§Examples
use knx_pico::IndividualAddress;
// Create from components
let addr = IndividualAddress::new(1, 1, 5).unwrap();
assert_eq!(addr.to_string(), "1.1.5");
// Create from raw u16
let addr = IndividualAddress::from(0x1105u16);
assert_eq!(addr.area(), 1);
assert_eq!(addr.line(), 1);
assert_eq!(addr.device(), 5);
// Parse from string
let addr: IndividualAddress = "1.1.5".parse().unwrap();
assert_eq!(u16::from(addr), 0x1105);Implementations§
Source§impl IndividualAddress
impl IndividualAddress
Sourcepub const MAX_DEVICE: u8 = 255u8
pub const MAX_DEVICE: u8 = 255u8
Maximum device value (8 bits)
Sourcepub fn new(area: u8, line: u8, device: u8) -> Result<Self>
pub fn new(area: u8, line: u8, device: u8) -> Result<Self>
Create a new Individual Address from components.
§Arguments
area- Area (0-15)line- Line (0-15)device- Device (0-255)
§Errors
Returns KnxError::AddressOutOfRange if any component is out of range.
§Examples
use knx_pico::IndividualAddress;
let addr = IndividualAddress::new(1, 1, 5)?;
assert_eq!(addr.to_string(), "1.1.5");Sourcepub fn from_array(parts: [u8; 3]) -> Result<Self>
pub fn from_array(parts: [u8; 3]) -> Result<Self>
Create from a 3-element array [area, line, device].
Convenient for creating addresses from array literals.
§Examples
use knx_pico::IndividualAddress;
let addr = IndividualAddress::from_array([1, 1, 5])?;
assert_eq!(addr.to_string(), "1.1.5");Trait Implementations§
Source§impl Clone for IndividualAddress
impl Clone for IndividualAddress
Source§fn clone(&self) -> IndividualAddress
fn clone(&self) -> IndividualAddress
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 IndividualAddress
impl Debug for IndividualAddress
Source§impl Display for IndividualAddress
impl Display for IndividualAddress
Source§impl Format for IndividualAddress
impl Format for IndividualAddress
Source§impl From<IndividualAddress> for u16
impl From<IndividualAddress> for u16
Source§fn from(addr: IndividualAddress) -> u16
fn from(addr: IndividualAddress) -> u16
Converts to this type from the input type.
Source§impl From<u16> for IndividualAddress
impl From<u16> for IndividualAddress
Source§impl FromStr for IndividualAddress
impl FromStr for IndividualAddress
Source§impl Hash for IndividualAddress
impl Hash for IndividualAddress
Source§impl PartialEq for IndividualAddress
impl PartialEq for IndividualAddress
impl Copy for IndividualAddress
impl Eq for IndividualAddress
impl StructuralPartialEq for IndividualAddress
Auto Trait Implementations§
impl Freeze for IndividualAddress
impl RefUnwindSafe for IndividualAddress
impl Send for IndividualAddress
impl Sync for IndividualAddress
impl Unpin for IndividualAddress
impl UnwindSafe for IndividualAddress
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