Skip to content

Commit

Permalink
Re-export serde-bytes & heapless-bytes behind bytes feature flag, and…
Browse files Browse the repository at this point in the history
… implement AtatLen for heapless_bytes type
  • Loading branch information
MathiasKoch committed Sep 16, 2021
1 parent 6ddd82c commit ae37507
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion atat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ nb = "^1"
heapless = { version = "^0.7.0", features = ["serde"] }
serde_at = { path = "../serde_at", version = "^0.13.1-alpha.0", optional = true }
atat_derive = { path = "../atat_derive", version = "^0.13.1-alpha.0", optional = true }
serde_bytes = { version = "0.11.5", default-features = false, optional = true }
heapless-bytes = { version = "0.3.0", optional = true }
bbqueue = "0.5"

log = { version = "^0.4", default-features = false, optional = true }
Expand All @@ -39,9 +41,11 @@ stm32l4xx-hal = { git = "https://github.com/MathiasKoch/stm32l4xx-hal", branch =
] }

[features]
default = ["derive"]
default = ["derive", "bytes"]
derive = ["atat_derive", "serde_at"]

bytes = ["heapless-bytes", "serde_bytes"]

std = ["serde_at/std"]

defmt-default = ["defmt"]
Expand Down
5 changes: 5 additions & 0 deletions atat/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ pub trait AtatLen {
const LEN: usize;
}

#[cfg(feature = "bytes")]
impl<const N: usize> AtatLen for heapless_bytes::Bytes<N> {
const LEN: usize = N;
}

macro_rules! impl_length {
($type:ty, $len:expr) => {
#[allow(clippy::use_self)]
Expand Down
3 changes: 3 additions & 0 deletions atat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ pub use bbqueue;
#[cfg(feature = "bytes")]
pub use serde_bytes;

#[cfg(feature = "bytes")]
pub use heapless_bytes;

#[cfg(feature = "derive")]
pub use atat_derive;
#[cfg(feature = "derive")]
Expand Down

0 comments on commit ae37507

Please sign in to comment.