simple_channels/mpsc/
error.rs1use core::fmt;
2use std::error::Error;
3
4#[derive(PartialEq, Eq, Clone, Copy)]
9pub struct SendError<T>(pub T);
10
11impl<T> fmt::Debug for SendError<T> {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 f.debug_tuple("SendError").finish()
14 }
15}
16
17impl<T> fmt::Display for SendError<T> {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 "sending on a disconnected channel".fmt(f)
20 }
21}
22
23impl<T: Send> Error for SendError<T> {}
24
25#[derive(PartialEq, Eq, Clone, Copy, Debug)]
30pub enum RecvError {
31 Disconnected,
33}
34
35impl fmt::Display for RecvError {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 "receiving on an empty and disconnected channel".fmt(f)
38 }
39}
40
41impl Error for RecvError {}
42
43#[derive(PartialEq, Eq, Clone, Copy, Debug)]
45pub enum TryRecvError {
46 Empty,
48 Disconnected,
50}
51
52impl fmt::Display for TryRecvError {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 match *self {
55 TryRecvError::Empty => "receiving on an empty channel".fmt(f),
56 TryRecvError::Disconnected => "receiving on an empty and disconnected channel".fmt(f),
57 }
58 }
59}
60
61impl Error for TryRecvError {}