Skip to content

Commit 3c41607

Browse files
committed
add feature and Format derive
1 parent 1c585d4 commit 3c41607

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

embedded-can/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ repository = "https://github.com/rust-embedded/embedded-hal"
1414

1515
[dependencies]
1616
nb = "1"
17+
defmt = { version = "0.3", optional = true }
18+
19+
[features]
20+
defmt-03 = ["dep:defmt"]

embedded-can/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ This project is developed and maintained by the [HAL team](https://github.com/ru
1313

1414
[API reference]: https://docs.rs/embedded-can
1515

16+
## Optional features
17+
18+
- **`defmt-03`**: Derive `defmt::Format` from `defmt` 0.3 for enums and structs.
19+
1620
## Minimum Supported Rust Version (MSRV)
1721

1822
This crate is guaranteed to compile on stable Rust 1.60 and up. It *might*

embedded-can/src/id.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
/// Standard 11-bit CAN Identifier (`0..=0x7FF`).
44
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
5+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
56
pub struct StandardId(u16);
67

78
impl StandardId {
@@ -44,6 +45,7 @@ impl StandardId {
4445

4546
/// Extended 29-bit CAN Identifier (`0..=1FFF_FFFF`).
4647
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
48+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
4749
pub struct ExtendedId(u32);
4850

4951
impl ExtendedId {
@@ -93,6 +95,7 @@ impl ExtendedId {
9395

9496
/// A CAN Identifier (standard or extended).
9597
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
98+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
9699
pub enum Id {
97100
/// Standard 11-bit Identifier (`0..=0x7FF`).
98101
Standard(StandardId),

embedded-can/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl Error for core::convert::Infallible {
7373
/// free to define more specific or additional error types. However, by providing
7474
/// a mapping to these common CAN errors, generic code can still react to them.
7575
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
76+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
7677
#[non_exhaustive]
7778
pub enum ErrorKind {
7879
/// The peripheral receive buffer was overrun.

0 commit comments

Comments
 (0)