pub enum CanId {
Standard(u16),
Extended(u32),
}Expand description
CAN identifier (standard or extended).
CAN supports two types of identifiers:
- Standard: 11-bit identifier (0x000-0x7FF)
- Extended: 29-bit identifier (0x00000000-0x1FFFFFFF)
§Examples
use canlink_hal::CanId;
let std_id = CanId::Standard(0x123);
assert!(std_id.is_standard());
assert_eq!(std_id.raw(), 0x123);
let ext_id = CanId::Extended(0x12345678);
assert!(ext_id.is_extended());
assert_eq!(ext_id.raw(), 0x12345678);Variants§
Standard(u16)
Standard 11-bit ID (0x000-0x7FF)
Extended(u32)
Extended 29-bit ID (0x00000000-0x1FFFFFFF)
Implementations§
Source§impl CanId
impl CanId
Sourcepub fn raw(&self) -> u32
pub fn raw(&self) -> u32
Get the raw ID value as u32.
§Examples
use canlink_hal::CanId;
assert_eq!(CanId::Standard(0x123).raw(), 0x123);
assert_eq!(CanId::Extended(0x12345678).raw(), 0x12345678);Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Check if this is a standard frame ID.
§Examples
use canlink_hal::CanId;
assert!(CanId::Standard(0x123).is_standard());
assert!(!CanId::Extended(0x123).is_standard());Sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Check if this is an extended frame ID.
§Examples
use canlink_hal::CanId;
assert!(!CanId::Standard(0x123).is_extended());
assert!(CanId::Extended(0x123).is_extended());Trait Implementations§
Source§impl<'de> Deserialize<'de> for CanId
impl<'de> Deserialize<'de> for CanId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.