Add defmt support for mpsc errors.
This commit is contained in:
parent
1e1cd0506a
commit
170121cdf6
@ -386,6 +386,7 @@ where
|
|||||||
///
|
///
|
||||||
/// [`try_recv`]: super::Receiver::try_recv
|
/// [`try_recv`]: super::Receiver::try_recv
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||||
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub enum TryRecvError {
|
pub enum TryRecvError {
|
||||||
/// A message could not be received because the channel is empty.
|
/// A message could not be received because the channel is empty.
|
||||||
Empty,
|
Empty,
|
||||||
@ -404,6 +405,14 @@ impl<T> fmt::Display for SendError<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
impl<T> defmt::Format for SendError<T> {
|
||||||
|
fn format(&self, fmt: defmt::Formatter<'_>) {
|
||||||
|
defmt::write!(fmt, "channel closed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// This enumeration is the list of the possible error outcomes for the
|
/// This enumeration is the list of the possible error outcomes for the
|
||||||
/// [try_send](super::Sender::try_send) method.
|
/// [try_send](super::Sender::try_send) method.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -430,6 +439,20 @@ impl<T> fmt::Display for TrySendError<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
impl<T> defmt::Format for TrySendError<T> {
|
||||||
|
fn format(&self, fmt: defmt::Formatter<'_>) {
|
||||||
|
defmt::write!(
|
||||||
|
fmt,
|
||||||
|
"{}",
|
||||||
|
match self {
|
||||||
|
TrySendError::Full(..) => "no available capacity",
|
||||||
|
TrySendError::Closed(..) => "channel closed",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ChannelState<T, const N: usize> {
|
struct ChannelState<T, const N: usize> {
|
||||||
buf: [MaybeUninit<UnsafeCell<T>>; N],
|
buf: [MaybeUninit<UnsafeCell<T>>; N],
|
||||||
read_pos: usize,
|
read_pos: usize,
|
||||||
|
Loading…
Reference in New Issue
Block a user