pub struct Control(/* private fields */);Expand description
A data-link control field.
Implementations§
Source§impl Control
impl Control
Sourcepub const fn req_ud1(fcb: bool) -> Self
pub const fn req_ud1(fcb: bool) -> Self
Creates a REQ-UD1 control field with the requested frame-count bit.
Sourcepub const fn req_ud2(fcb: bool) -> Self
pub const fn req_ud2(fcb: bool) -> Self
Creates a REQ-UD2 control field with the requested frame-count bit.
Examples found in repository?
More examples
Sourcepub const fn snd_ud(bit5: bool) -> Self
pub const fn snd_ud(bit5: bool) -> Self
Creates an SND-UD control field with bit 5 clear or set.
Sourcepub const fn rsp_ud(acd: bool, dfc: bool) -> Self
pub const fn rsp_ud(acd: bool, dfc: bool) -> Self
Creates an RSP-UD control field with access-demand and data-flow-control flags.
Sourcepub const fn communication_type(self) -> CommunicationType
pub const fn communication_type(self) -> CommunicationType
Returns the supported communication type represented by this field.
Examples found in repository?
examples/decode_exact_alloc.rs (line 22)
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 22)
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 direction(self) -> Option<Direction>
pub const fn direction(self) -> Option<Direction>
Returns the direction of a supported communication.
Sourcepub const fn frame_count_bit(self) -> Option<bool>
pub const fn frame_count_bit(self) -> Option<bool>
Returns the frame-count bit for a message sent by a master.
Sourcepub const fn frame_count_valid(self) -> Option<bool>
pub const fn frame_count_valid(self) -> Option<bool>
Returns the frame-count-valid bit for a message sent by a master.
Sourcepub const fn access_demand(self) -> Option<bool>
pub const fn access_demand(self) -> Option<bool>
Returns the access-demand bit for a message sent by a slave.
Sourcepub const fn data_flow_control(self) -> Option<bool>
pub const fn data_flow_control(self) -> Option<bool>
Returns the data-flow-control bit for a message sent by a slave.
Trait Implementations§
impl Copy for Control
impl Eq for Control
impl StructuralPartialEq for Control
Auto Trait Implementations§
impl Freeze for Control
impl RefUnwindSafe for Control
impl Send for Control
impl Sync for Control
impl Unpin for Control
impl UnsafeUnpin for Control
impl UnwindSafe for Control
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