Skip to main content

Frame

Struct Frame 

Source
pub struct Frame { /* private fields */ }
Expand description

A CAN FD frame.

Implementations§

Source§

impl Frame

Source

pub fn new(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>

Creates a new classic CAN data frame.

§Errors

FrameError::PayloadTooLong when payload is longer than 8 bytes.

Source

pub fn new_request(id: impl Into<Id>, len: usize) -> Result<Self, FrameError>

Creates a new classic CAN request frame.

A request frame carries no payload. len is the payload length that the frame asks for.

§Errors

FrameError::PayloadTooLong when len is greater than 8.

Source

pub fn new_fd(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>

Creates a new CAN FD data frame.

The data phase uses the nominal bit rate unless Frame::with_bit_rate_switch is set.

§Errors

FrameError::PayloadTooLong when payload is longer than 64 bytes.

Source

pub fn with_bit_rate_switch(self, bit_rate_switch: bool) -> Self

Sets whether the data phase is sent at the FD bit rate.

Only a CAN FD frame can switch bit rate; the setting is ignored on a classic frame.

Source

pub fn payload(&self) -> &[u8]

Returns the payload the frame carries.

Source

pub fn len(&self) -> usize

Returns the payload length in bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether the frame carries no payload.

Source

pub fn requested_len(&self) -> usize

Returns the payload length a request frame asks for, in bytes.

Zero for a data frame, whose length is Frame::len.

Source

pub fn dlc(&self) -> u8

Returns the data length code the frame is sent with.

A payload length that no code expresses is padded up to the next one, so a received copy of the frame can be longer than Frame::len.

Source

pub fn id(&self) -> Id

Returns the arbitration identifier.

Source

pub fn is_extended(&self) -> bool

Returns whether the identifier is a 29-bit extended one.

Source

pub fn is_request(&self) -> bool

Returns whether this is a request frame, which carries no payload.

Source

pub fn is_fd(&self) -> bool

Returns whether the frame uses the CAN FD format.

Source

pub fn is_bit_rate_switched(&self) -> bool

Returns whether the data phase uses the FD bit rate.

Source

pub fn error_state_indicator(&self) -> bool

Returns the error state indicator of the transmitting node.

Source

pub fn timestamp(&self) -> u64

Returns the timestamp captured when the frame was received.

Zero for a frame that was not received; see CanFd::start_timestamp_timer.

Trait Implementations§

Source§

impl Clone for Frame

Available on crate feature unstable only.
Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Frame

Available on crate feature unstable only.
Source§

impl Debug for Frame

Available on crate feature unstable only.
Source§

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

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

impl From<ClassicFrame> for Frame

Available on crate feature unstable only.
Source§

fn from(frame: ClassicFrame) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<Frame> for ClassicFrame

Available on crate feature unstable only.
Source§

fn try_from(frame: Frame) -> Result<Self, FrameError>

§Errors

FrameError::NotClassic when the frame uses the CAN FD format.

Source§

type Error = FrameError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

§

impl UnwindSafe for Frame

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.