Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions embedded-can/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `core::error::Error` implementations for every custom `impl Error`
- Increased MSRV to 1.81 due to `core::error::Error`

### Added

- `as_raw_unchecked` getter function for `Id`

## [v0.4.1] - 2022-09-28

### Removed
Expand Down
18 changes: 18 additions & 0 deletions embedded-can/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ pub enum Id {
Extended(ExtendedId),
}

impl Id {
/// Returns the CAN Identifier as a raw 32-bit integer, ignoring the distinction between
/// standard ID and extended ID.
///
/// This function ignores that a standard ID and an extended ID are different IDs, even
/// if their numerical values are the same. It should only be used if the raw numerical value
/// is required and the distinction between standard ID and extended ID is irrelevant.
///
/// In all other cases, it is recommended to de-structure the ID with a match statement.
#[inline]
pub fn as_raw_unchecked(&self) -> u32 {
match self {
Id::Standard(id) => id.as_raw() as u32,
Id::Extended(id) => id.as_raw(),
}
}
}

/// Implement `Ord` according to the CAN arbitration rules
///
/// When performing arbitration, frames are looked at bit for bit starting
Expand Down