pub struct CanId { /* private fields */ }Expand description
A CAN arbitration identifier.
CAN comes in two identifier widths: the original standard 11-bit form and the extended 29-bit form that higher-layer protocols such as J1939 use to pack a priority, a parameter group, and addresses into the ID itself. This type holds either, always masked to its width.
§Examples
use pamoja_can::CanId;
let std = CanId::standard(0x123);
assert!(!std.is_extended());
assert_eq!(std.raw(), 0x123);
// Values wider than the identifier are masked to fit.
assert_eq!(CanId::standard(0xFFFF).raw(), 0x7FF);Implementations§
Source§impl CanId
impl CanId
Sourcepub const STANDARD_MASK: u32 = 0x7FF
pub const STANDARD_MASK: u32 = 0x7FF
The mask of a standard 11-bit identifier.
Sourcepub const EXTENDED_MASK: u32 = 0x1FFF_FFFF
pub const EXTENDED_MASK: u32 = 0x1FFF_FFFF
The mask of an extended 29-bit identifier.
Sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Reports whether this is an extended 29-bit identifier.
§Returns
true for an extended identifier, false for a standard one.
Trait Implementations§
impl Copy for CanId
impl Eq for CanId
impl StructuralPartialEq for CanId
Auto Trait Implementations§
impl Freeze for CanId
impl RefUnwindSafe for CanId
impl Send for CanId
impl Sync for CanId
impl Unpin for CanId
impl UnsafeUnpin for CanId
impl UnwindSafe for CanId
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