diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-08-29 23:42:59 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-29 23:42:59 +0000 |
| commit | fdb2c4946aeef968704c358fb52d5fea69e80dcc (patch) | |
| tree | 223a503d25c07dc99220f860b587c1ce2a0e0012 | |
| parent | 40b576584e96fb44ead4e73b30b654b04c6f1128 (diff) | |
| parent | 5e613d9abbb945e7fc7d4c895d645bfad6a3d2c8 (diff) | |
Merge pull request #1843 from embassy-rs/fmt-sync
Sync all fmt.rs files.
| -rw-r--r-- | cyw43/src/fmt.rs | 18 | ||||
| -rw-r--r-- | embassy-boot/boot/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-boot/nrf/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-boot/rp/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-boot/stm32/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-executor/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-futures/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-hal-internal/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-lora/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-net-driver-channel/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-net-enc28j60/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-net-esp-hosted/src/fmt.rs | 5 | ||||
| -rw-r--r-- | embassy-net-ppp/src/fmt.rs | 5 | ||||
| -rw-r--r-- | embassy-net/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-nrf/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-rp/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-stm32/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-sync/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-time/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-usb/src/fmt.rs | 45 |
21 files changed, 719 insertions, 119 deletions
diff --git a/cyw43/src/fmt.rs b/cyw43/src/fmt.rs index 9534c101c..78e583c1c 100644 --- a/cyw43/src/fmt.rs +++ b/cyw43/src/fmt.rs | |||
| @@ -83,14 +83,17 @@ macro_rules! todo { | |||
| 83 | }; | 83 | }; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 86 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 87 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 88 | { | 89 | ::core::unreachable!($($x)*) |
| 89 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 90 | ::core::unreachable!($($x)*); | 91 | } |
| 91 | #[cfg(feature = "defmt")] | 92 | |
| 92 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 93 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 94 | }; | 97 | }; |
| 95 | } | 98 | } |
| 96 | 99 | ||
| @@ -226,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | |||
| 226 | } | 229 | } |
| 227 | } | 230 | } |
| 228 | 231 | ||
| 229 | pub struct Bytes<'a>(pub &'a [u8]); | 232 | #[allow(unused)] |
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 230 | 234 | ||
| 231 | impl<'a> Debug for Bytes<'a> { | 235 | impl<'a> Debug for Bytes<'a> { |
| 232 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
diff --git a/embassy-boot/boot/src/fmt.rs b/embassy-boot/boot/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-boot/boot/src/fmt.rs +++ b/embassy-boot/boot/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-boot/nrf/src/fmt.rs b/embassy-boot/nrf/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-boot/nrf/src/fmt.rs +++ b/embassy-boot/nrf/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-boot/rp/src/fmt.rs b/embassy-boot/rp/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-boot/rp/src/fmt.rs +++ b/embassy-boot/rp/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-boot/stm32/src/fmt.rs b/embassy-boot/stm32/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-boot/stm32/src/fmt.rs +++ b/embassy-boot/stm32/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-executor/src/fmt.rs b/embassy-executor/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-executor/src/fmt.rs +++ b/embassy-executor/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-futures/src/fmt.rs b/embassy-futures/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-futures/src/fmt.rs +++ b/embassy-futures/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-hal-internal/src/fmt.rs b/embassy-hal-internal/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-hal-internal/src/fmt.rs +++ b/embassy-hal-internal/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-lora/src/fmt.rs b/embassy-lora/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-lora/src/fmt.rs +++ b/embassy-lora/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-net-driver-channel/src/fmt.rs b/embassy-net-driver-channel/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-net-driver-channel/src/fmt.rs +++ b/embassy-net-driver-channel/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-net-enc28j60/src/fmt.rs b/embassy-net-enc28j60/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-net-enc28j60/src/fmt.rs +++ b/embassy-net-enc28j60/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-net-esp-hosted/src/fmt.rs b/embassy-net-esp-hosted/src/fmt.rs index 91984bde1..78e583c1c 100644 --- a/embassy-net-esp-hosted/src/fmt.rs +++ b/embassy-net-esp-hosted/src/fmt.rs | |||
| @@ -93,7 +93,7 @@ macro_rules! unreachable { | |||
| 93 | #[cfg(feature = "defmt")] | 93 | #[cfg(feature = "defmt")] |
| 94 | macro_rules! unreachable { | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | 95 | ($($x:tt)*) => { |
| 96 | ::defmt::unreachable!($($x)*); | 96 | ::defmt::unreachable!($($x)*) |
| 97 | }; | 97 | }; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -229,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | |||
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | pub struct Bytes<'a>(pub &'a [u8]); | 232 | #[allow(unused)] |
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 233 | 234 | ||
| 234 | impl<'a> Debug for Bytes<'a> { | 235 | impl<'a> Debug for Bytes<'a> { |
| 235 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
diff --git a/embassy-net-ppp/src/fmt.rs b/embassy-net-ppp/src/fmt.rs index 91984bde1..78e583c1c 100644 --- a/embassy-net-ppp/src/fmt.rs +++ b/embassy-net-ppp/src/fmt.rs | |||
| @@ -93,7 +93,7 @@ macro_rules! unreachable { | |||
| 93 | #[cfg(feature = "defmt")] | 93 | #[cfg(feature = "defmt")] |
| 94 | macro_rules! unreachable { | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | 95 | ($($x:tt)*) => { |
| 96 | ::defmt::unreachable!($($x)*); | 96 | ::defmt::unreachable!($($x)*) |
| 97 | }; | 97 | }; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -229,7 +229,8 @@ impl<T, E> Try for Result<T, E> { | |||
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | pub struct Bytes<'a>(pub &'a [u8]); | 232 | #[allow(unused)] |
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 233 | 234 | ||
| 234 | impl<'a> Debug for Bytes<'a> { | 235 | impl<'a> Debug for Bytes<'a> { |
| 235 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
diff --git a/embassy-net/src/fmt.rs b/embassy-net/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-net/src/fmt.rs +++ b/embassy-net/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-nrf/src/fmt.rs b/embassy-nrf/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-nrf/src/fmt.rs +++ b/embassy-nrf/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-rp/src/fmt.rs b/embassy-rp/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-rp/src/fmt.rs +++ b/embassy-rp/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-stm32-wpan/src/fmt.rs b/embassy-stm32-wpan/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-stm32-wpan/src/fmt.rs +++ b/embassy-stm32-wpan/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-stm32/src/fmt.rs b/embassy-stm32/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-stm32/src/fmt.rs +++ b/embassy-stm32/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-sync/src/fmt.rs b/embassy-sync/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-sync/src/fmt.rs +++ b/embassy-sync/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-time/src/fmt.rs b/embassy-time/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-time/src/fmt.rs +++ b/embassy-time/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-usb/src/fmt.rs b/embassy-usb/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-usb/src/fmt.rs +++ b/embassy-usb/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
