Skip to main content

Control

Struct Control 

Source
pub struct Control(/* private fields */);
Expand description

A data-link control field.

Implementations§

Source§

impl Control

Source

pub const fn new(value: u8) -> Self

Creates a control field from its wire value.

Source

pub const fn snd_nke() -> Self

Creates an SND-NKE control field.

Source

pub const fn req_ud1(fcb: bool) -> Self

Creates a REQ-UD1 control field with the requested frame-count bit.

Source

pub const fn req_ud2(fcb: bool) -> Self

Creates a REQ-UD2 control field with the requested frame-count bit.

Examples found in repository?
examples/request_data_alloc.rs (line 15)
14fn main() -> Result<(), ShortFrameError> {
15    let request = ShortFrame::new(Control::req_ud2(false), Address::new(1))?;
16    let encoded = request.encode();
17
18    assert_eq!(encoded, [0x10, 0x5b, 0x01, 0x5c, 0x16]);
19    Ok(())
20}
More examples
Hide additional examples
examples/request_data_no_alloc.rs (line 15)
14fn main() -> Result<(), ShortFrameError> {
15    let request = ShortFrame::new(Control::req_ud2(false), Address::new(1))?;
16
17    let mut output = [0_u8; ShortFrame::LEN];
18    let encoded = request.encode_into(&mut output)?;
19
20    assert_eq!(encoded, [0x10, 0x5b, 0x01, 0x5c, 0x16]);
21    Ok(())
22}
Source

pub const fn snd_ud(bit5: bool) -> Self

Creates an SND-UD control field with bit 5 clear or set.

Source

pub const fn snd_ud2() -> Self

Creates an SND-UD2 control field.

Source

pub const fn rsp_ud(acd: bool, dfc: bool) -> Self

Creates an RSP-UD control field with access-demand and data-flow-control flags.

Source

pub const fn value(self) -> u8

Returns the wire value.

Source

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
Hide additional 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}
Source

pub const fn direction(self) -> Option<Direction>

Returns the direction of a supported communication.

Source

pub const fn frame_count_bit(self) -> Option<bool>

Returns the frame-count bit for a message sent by a master.

Source

pub const fn frame_count_valid(self) -> Option<bool>

Returns the frame-count-valid bit for a message sent by a master.

Source

pub const fn access_demand(self) -> Option<bool>

Returns the access-demand bit for a message sent by a slave.

Source

pub const fn data_flow_control(self) -> Option<bool>

Returns the data-flow-control bit for a message sent by a slave.

Trait Implementations§

Source§

impl Clone for Control

Source§

fn clone(&self) -> Control

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Control

Source§

impl Debug for Control

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Control

Source§

impl From<u8> for Control

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl Hash for Control

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Control

Source§

fn eq(&self, other: &Control) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Control

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.