pub trait Frame: Sized {
// Required methods
fn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>;
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>;
fn is_extended(&self) -> bool;
fn is_remote_frame(&self) -> bool;
fn id(&self) -> Id;
fn dlc(&self) -> usize;
fn data(&self) -> &[u8] ⓘ;
// Provided methods
fn is_standard(&self) -> bool { ... }
fn is_data_frame(&self) -> bool { ... }
}Expand description
A CAN2.0 Frame
Required Methods§
Sourcefn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>
fn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>
Creates a new frame.
This will return None if the data slice is too long.
Sourcefn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>
Creates a new remote frame (RTR bit set).
This will return None if the data length code (DLC) is not valid.
Sourcefn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Returns true if this frame is a extended frame.
Sourcefn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
Returns true if this frame is a remote frame.
Provided Methods§
Sourcefn is_standard(&self) -> bool
fn is_standard(&self) -> bool
Returns true if this frame is a standard frame.
Sourcefn is_data_frame(&self) -> bool
fn is_data_frame(&self) -> bool
Returns true if this frame is a data frame.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Frame for CanAnyFrame
impl Frame for CanAnyFrame
Source§fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanAnyFrame>
fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanAnyFrame>
Create a new CAN frame If the data
Source§fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<CanAnyFrame>
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<CanAnyFrame>
Create a new remote transmission request frame.
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
Check if frame is a remote transmission request.
Source§impl Frame for CanFrame
impl Frame for CanFrame
Source§impl Frame for CanDataFrame
impl Frame for CanDataFrame
Source§fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanDataFrame>
fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanDataFrame>
Create a new CAN 2.0 data frame
Source§fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanDataFrame>
fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanDataFrame>
Create a new remote transmission request frame.
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
Check if frame is a remote transmission request.
Source§impl Frame for CanErrorFrame
impl Frame for CanErrorFrame
Source§fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanErrorFrame>
fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanErrorFrame>
Create an error frame.
Note that an application would not normally ever create an error frame. This is included mainly to aid in implementing mocks and other tests for an application.
This will set the error bit in the CAN ID word.
Source§fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanErrorFrame>
fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanErrorFrame>
The application should not create an error frame. This will always return None.
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
Check if frame is a remote transmission request.
Source§fn is_data_frame(&self) -> bool
fn is_data_frame(&self) -> bool
Check if frame is a data frame.
Source§impl Frame for CanFdFrame
impl Frame for CanFdFrame
Source§fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanFdFrame>
fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<CanFdFrame>
CAN FD frames don’t support remote
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
The FD frames don’t support remote request
Source§impl Frame for CanRemoteFrame
impl Frame for CanRemoteFrame
Source§fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanRemoteFrame>
fn new(id: impl Into<Id>, data: &[u8]) -> Option<CanRemoteFrame>
Create a new CAN 2.0 remote frame
Source§fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<CanRemoteFrame>
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<CanRemoteFrame>
Create a new remote transmission request frame.
This will set the RTR flag in the CAN ID word.
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
Check if frame is a remote transmission request.