#[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
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
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§fn eq(&self, other: &ExtendedId) -> bool
fn eq(&self, other: &ExtendedId) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<StandardId> for CanId
impl PartialEq<StandardId> for CanId
Source§fn eq(&self, other: &StandardId) -> bool
fn eq(&self, other: &StandardId) -> bool
self and other values to be equal, and is used by ==.