pub struct Id<P: IsProtocol>(/* private fields */);
Expand description
Represents a Controller Area Network (CAN) identifier of a specific protocol.
Implementations§
Source§impl Id<J1939>
impl Id<J1939>
Sourcepub const fn into_raw_parts(self) -> (u8, bool, bool, u8, u8, u8)
pub const fn into_raw_parts(self) -> (u8, bool, bool, u8, u8, u8)
Decomposes the 29-bit J1939 identifier into its raw parts.
Returns a tuple containing the priority, reserved flag, data page flag, PDU format, PDU specific, and source address bits.
§Examples
let id_a = IdJ1939::from_hex("00FF00FF");
let (p, r, dp, pf, ps, sa) = id_a.into_raw_parts();
Sourcepub fn from_raw_parts(
priority: u8,
reserved: bool,
data_page: bool,
pdu_format: u8,
pdu_specific: u8,
source_addr: u8,
) -> Result<Self, Error>
pub fn from_raw_parts( priority: u8, reserved: bool, data_page: bool, pdu_format: u8, pdu_specific: u8, source_addr: u8, ) -> Result<Self, Error>
Constructs a 29-bit J1939 identifier from its raw parts.
§Arguments
priority
:u8
.reserved
:bool
.data_page
:bool
.pdu_format
:u8
.pdu_specific
:u8
.source_addr
:u8
.
§Errors
- If priority value is invalid
§Examples
let expected_id = IdJ1939::from_hex("00FF00FF");
let id_a = IdJ1939::from_raw_parts(0x0, false, false, 0xFF, 0x00, 0xFF);
assert_eq!(expected_id, id_a.unwrap());
Sourcepub const fn priority(&self) -> u8
pub const fn priority(&self) -> u8
Returns the priority bits indicating the priority level.
0 = highest priority
Sourcepub const fn pdu_format(&self) -> u8
pub const fn pdu_format(&self) -> u8
Returns the PDU format bits specifying the Protocol Data Unit format.
Sourcepub const fn pdu_specific(&self) -> u8
pub const fn pdu_specific(&self) -> u8
Returns the PDU specific bits providing additional details about the PDU.
Sourcepub fn source_address(&self) -> SourceAddr
pub fn source_address(&self) -> SourceAddr
Returns the source address bits identifying the source of the data.
Trait Implementations§
Source§impl<P: Ord + IsProtocol> Ord for Id<P>
impl<P: Ord + IsProtocol> Ord for Id<P>
Source§impl<P: PartialOrd + IsProtocol> PartialOrd for Id<P>
impl<P: PartialOrd + IsProtocol> PartialOrd for Id<P>
impl<P: Copy + IsProtocol> Copy for Id<P>
impl<P: Eq + IsProtocol> Eq for Id<P>
impl<P: IsProtocol> StructuralPartialEq for Id<P>
Auto Trait Implementations§
impl<P> Freeze for Id<P>where
P: Freeze,
impl<P> RefUnwindSafe for Id<P>where
P: RefUnwindSafe,
impl<P> Send for Id<P>where
P: Send,
impl<P> Sync for Id<P>where
P: Sync,
impl<P> Unpin for Id<P>where
P: Unpin,
impl<P> UnwindSafe for Id<P>where
P: UnwindSafe,
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