55
66use core:: fmt;
77
8+ // needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
9+ #[ cfg( feature = "defmt-03" ) ]
10+ use defmt_03 as defmt;
11+
812#[ cfg( feature = "alloc" ) ]
913extern crate alloc;
1014
@@ -14,6 +18,7 @@ mod impls;
1418///
1519/// This is the `embedded-io` equivalent of [`std::io::SeekFrom`].
1620#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
21+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1722pub enum SeekFrom {
1823 /// Sets the offset to the provided number of bytes.
1924 Start ( u64 ) ,
@@ -47,8 +52,6 @@ impl From<std::io::SeekFrom> for SeekFrom {
4752 }
4853}
4954
50- #[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
51- #[ non_exhaustive]
5255/// Possible kinds of errors.
5356///
5457/// This list is intended to grow over time and it is not recommended to
@@ -59,6 +62,9 @@ impl From<std::io::SeekFrom> for SeekFrom {
5962///
6063/// - `WouldBlock` is removed, since `embedded-io` traits are always blocking. See the [crate-level documentation](crate) for details.
6164/// - `WriteZero` is removed, since it is a separate variant in [`WriteAllError`] and [`WriteFmtError`].
65+ #[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
66+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
67+ #[ non_exhaustive]
6268pub enum ErrorKind {
6369 /// Unspecified error kind.
6470 Other ,
@@ -214,6 +220,7 @@ impl<T: ?Sized + ErrorType> ErrorType for &mut T {
214220
215221/// Error returned by [`Read::read_exact`]
216222#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
223+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
217224pub enum ReadExactError < E > {
218225 /// An EOF error was encountered before reading the exact amount of requested bytes.
219226 UnexpectedEof ,
@@ -266,6 +273,7 @@ impl<E: fmt::Debug> std::error::Error for ReadExactError<E> {}
266273
267274/// Error returned by [`Write::write_fmt`]
268275#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
276+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
269277pub enum WriteFmtError < E > {
270278 /// [`Write::write`] wrote zero bytes
271279 WriteZero ,
@@ -293,6 +301,7 @@ impl<E: fmt::Debug> std::error::Error for WriteFmtError<E> {}
293301
294302/// Error returned by [`Write::write_all`]
295303#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
304+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
296305pub enum WriteAllError < E > {
297306 /// [`Write::write`] wrote zero bytes
298307 WriteZero ,
0 commit comments