#[repr(C)]pub enum CanId {
Standard(StandardId),
Extended(ExtendedId),
}
Expand description
A CAN ID, either standard (11 bit) or extended (29 bits).
Variants§
Implementations§
Source§impl CanId
impl CanId
Sourcepub const fn new(id: u32) -> Result<Self, InvalidId>
pub const fn new(id: u32) -> Result<Self, InvalidId>
Create a new CAN ID from a raw value.
If the value fits in a 11 bit standard CAN ID,
this function will return Self::Standard
.
a standard ID will be created.
Otherwise, if the value fits in a 29 bits extended CAN ID,
this function returns Self::Extended
.
If the value doesn’t fit in either, this function returns an error.
Sourcepub const fn new_standard(id: u16) -> Result<Self, InvalidId>
pub const fn new_standard(id: u16) -> Result<Self, InvalidId>
Create a new standard CAN ID from a raw value.
If the value doesn’t fit in a standard 11 bit CAN ID, this function returns an error.
Sourcepub const fn new_extended(id: u32) -> Result<Self, InvalidId>
pub const fn new_extended(id: u32) -> Result<Self, InvalidId>
Create a new extended CAN ID from a raw value.
If the value doesn’t fit in an extended 29 bit CAN ID, this function returns an error.
Sourcepub const fn as_standard(self) -> Option<StandardId>
pub const fn as_standard(self) -> Option<StandardId>
Get self
as a StandardId
, or None
if this is an extended ID.
Note: This function always returns None
if self
is an extended ID.
It doesn’t matter if the value would have fit in a StandardId
.
Use Self::to_standard()
if you want to try to convert extended IDs to standard IDs.
Sourcepub const fn as_extended(self) -> Option<ExtendedId>
pub const fn as_extended(self) -> Option<ExtendedId>
Get self
as an ExtendedId
, or None
if this is a standard ID.
Use Self::to_extended()
if you want to convert standard IDs to extended IDs.
Sourcepub const fn to_standard(self) -> Result<StandardId, InvalidId>
pub const fn to_standard(self) -> Result<StandardId, InvalidId>
Try to convert the ID to a standard ID.
Returns an error if the value doesn’t fit in a standard ID.
Sourcepub const fn to_extended(self) -> ExtendedId
pub const fn to_extended(self) -> ExtendedId
Convert the ID to an extended ID.
Trait Implementations§
Source§impl From<CanId> for ExtendedId
impl From<CanId> for ExtendedId
Source§impl From<ExtendedId> for CanId
impl From<ExtendedId> for CanId
Source§fn from(value: ExtendedId) -> Self
fn from(value: ExtendedId) -> Self
Source§impl From<StandardId> for CanId
impl From<StandardId> for CanId
Source§fn from(value: StandardId) -> Self
fn from(value: StandardId) -> Self
Source§impl Ord for CanId
impl Ord for CanId
Source§impl PartialEq<CanId> for ExtendedId
impl PartialEq<CanId> for ExtendedId
Source§impl PartialEq<CanId> for StandardId
impl PartialEq<CanId> for StandardId
Source§impl PartialEq<ExtendedId> for CanId
impl PartialEq<ExtendedId> for CanId
Source§impl PartialEq<StandardId> for CanId
impl PartialEq<StandardId> for CanId
Source§impl PartialOrd for CanId
impl PartialOrd for CanId
Source§impl TryFrom<CanId> for StandardId
impl TryFrom<CanId> for StandardId
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)