postage/sink/
errors.rs

1/// An error type returned by `Sink::try_send`, when the sink is full, or is closed.
2#[derive(Debug, PartialEq, Eq)]
3pub enum TrySendError<T> {
4    /// The sink could accept the item at a later time
5    Pending(T),
6    /// The sink is closed, and will never accept the item
7    Rejected(T),
8}
9
10impl<T> std::fmt::Display for TrySendError<T>
11where
12    T: std::fmt::Debug,
13{
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        f.write_fmt(format_args!("{:?}", &self))?;
16
17        Ok(())
18    }
19}
20
21impl<T> std::error::Error for TrySendError<T> where T: std::fmt::Debug {}
22
23/// An error type returned by `Sink::send`, if the sink is closed while a send is in progress.
24#[derive(Debug, PartialEq, Eq)]
25pub struct SendError<T>(pub T);
26
27impl<T> std::fmt::Display for SendError<T>
28where
29    T: std::fmt::Debug,
30{
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        f.write_fmt(format_args!("{:?}", &self))?;
33
34        Ok(())
35    }
36}
37
38impl<T> std::error::Error for SendError<T> where T: std::fmt::Debug {}