Skip to content
Merged
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
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ rust-version = "1.56.0"
members = [
"generate-api",
]

[features]
defmt = ["dep:defmt"]

[dependencies]
defmt = { version = "1.0.1", optional = true }
8 changes: 8 additions & 0 deletions generate-api/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ impl CodeGenerator {
#![no_std]

#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UnknownLocale;

"#,
Expand Down Expand Up @@ -575,6 +576,13 @@ impl CodeGenerator {
}}
}}

#[cfg(feature = "defmt")]
impl defmt::Format for Locale {{
fn format(&self, f: defmt::Formatter) {{
defmt::write!(f, "{{:?}}", self);
}}
}}

impl core::str::FromStr for Locale {{
type Err = UnknownLocale;

Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![no_std]

#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UnknownLocale;

#[allow(non_snake_case,non_camel_case_types,dead_code,unused_imports)]
Expand Down Expand Up @@ -56140,6 +56141,13 @@ impl core::fmt::Debug for Locale {
}
}

#[cfg(feature = "defmt")]
impl defmt::Format for Locale {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "{:?}", self);
}
}

impl core::str::FromStr for Locale {
type Err = UnknownLocale;

Expand Down
Loading