5
5
6
6
use core:: fmt;
7
7
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
+
8
12
#[ cfg( feature = "alloc" ) ]
9
13
extern crate alloc;
10
14
@@ -14,6 +18,7 @@ mod impls;
14
18
///
15
19
/// This is the `embedded-io` equivalent of [`std::io::SeekFrom`].
16
20
#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
21
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
17
22
pub enum SeekFrom {
18
23
/// Sets the offset to the provided number of bytes.
19
24
Start ( u64 ) ,
@@ -47,8 +52,6 @@ impl From<std::io::SeekFrom> for SeekFrom {
47
52
}
48
53
}
49
54
50
- #[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
51
- #[ non_exhaustive]
52
55
/// Possible kinds of errors.
53
56
///
54
57
/// 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 {
59
62
///
60
63
/// - `WouldBlock` is removed, since `embedded-io` traits are always blocking. See the [crate-level documentation](crate) for details.
61
64
/// - `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]
62
68
pub enum ErrorKind {
63
69
/// Unspecified error kind.
64
70
Other ,
@@ -214,6 +220,7 @@ impl<T: ?Sized + ErrorType> ErrorType for &mut T {
214
220
215
221
/// Error returned by [`Read::read_exact`]
216
222
#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
223
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
217
224
pub enum ReadExactError < E > {
218
225
/// An EOF error was encountered before reading the exact amount of requested bytes.
219
226
UnexpectedEof ,
@@ -266,6 +273,7 @@ impl<E: fmt::Debug> std::error::Error for ReadExactError<E> {}
266
273
267
274
/// Error returned by [`Write::write_fmt`]
268
275
#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
276
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
269
277
pub enum WriteFmtError < E > {
270
278
/// [`Write::write`] wrote zero bytes
271
279
WriteZero ,
@@ -293,6 +301,7 @@ impl<E: fmt::Debug> std::error::Error for WriteFmtError<E> {}
293
301
294
302
/// Error returned by [`Write::write_all`]
295
303
#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
304
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
296
305
pub enum WriteAllError < E > {
297
306
/// [`Write::write`] wrote zero bytes
298
307
WriteZero ,
0 commit comments