pub struct Address(/* private fields */);Expand description
A data-link address.
Implementations§
Source§impl Address
impl Address
Sourcepub const fn new(value: u8) -> Self
pub const fn new(value: u8) -> Self
Creates an address from its wire value.
Examples found in repository?
More examples
Sourcepub const fn value(self) -> u8
pub const fn value(self) -> u8
Returns the wire value.
Examples found in repository?
examples/decode_exact_alloc.rs (line 25)
17fn main() -> Result<(), DecodeError> {
18 let frame = decode(&[0x10, 0x5b, 0x01, 0x5c, 0x16])?;
19
20 if let Frame::Short(short) = &frame {
21 assert_eq!(
22 short.control().communication_type(),
23 CommunicationType::ReqUd2
24 );
25 assert_eq!(short.address().value(), 1);
26 }
27
28 assert_eq!(frame.encode(), [0x10, 0x5b, 0x01, 0x5c, 0x16]);
29 Ok(())
30}More examples
examples/decode_exact_no_alloc.rs (line 25)
17fn main() -> Result<(), DecodeError> {
18 let frame = decode(&[0x10, 0x5b, 0x01, 0x5c, 0x16])?;
19
20 if let Frame::Short(short) = &frame {
21 assert_eq!(
22 short.control().communication_type(),
23 CommunicationType::ReqUd2
24 );
25 assert_eq!(short.address().value(), 1);
26 }
27
28 let mut output = [0_u8; LongFrame::MAX_LEN];
29 assert_eq!(
30 frame
31 .encode_into(&mut output)
32 .expect("maximum frame buffer is large enough"),
33 [0x10, 0x5b, 0x01, 0x5c, 0x16]
34 );
35
36 Ok(())
37}Sourcepub const fn kind(self) -> AddressKind
pub const fn kind(self) -> AddressKind
Classifies the address according to EN 13757-2.
Sourcepub const fn expects_response(self) -> bool
pub const fn expects_response(self) -> bool
Returns whether a slave response may be expected.
Trait Implementations§
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnsafeUnpin for Address
impl UnwindSafe for Address
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