Skip to content

Commit 9db215f

Browse files
committed
raw ID getter function
1 parent 5209452 commit 9db215f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

embedded-can/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- Added `core::error::Error` implementations for every custom `impl Error`
1111
- Increased MSRV to 1.81 due to `core::error::Error`
1212

13+
### Added
14+
15+
- `as_raw` getter function for `Id`
16+
1317
## [v0.4.1] - 2022-09-28
1418

1519
### Removed

embedded-can/src/id.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ pub enum Id {
104104
Extended(ExtendedId),
105105
}
106106

107+
impl Id {
108+
/// Returns the CAN Identifier as a raw 32-bit integer.
109+
#[inline]
110+
pub fn as_raw(&self) -> u32 {
111+
match self {
112+
Id::Standard(id) => id.as_raw() as u32,
113+
Id::Extended(id) => id.as_raw(),
114+
}
115+
}
116+
}
117+
107118
/// Implement `Ord` according to the CAN arbitration rules
108119
///
109120
/// When performing arbitration, frames are looked at bit for bit starting

0 commit comments

Comments
 (0)