1pub use crate::sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError};
2use crate::{error, fmt};
3
4#[derive(PartialEq, Eq, Clone, Copy)]
10#[unstable(feature = "mpmc_channel", issue = "126840")]
11pub enum SendTimeoutError<T> {
12 Timeout(T),
17
18 Disconnected(T),
20}
21
22#[unstable(feature = "mpmc_channel", issue = "126840")]
23impl<T> fmt::Debug for SendTimeoutError<T> {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 "SendTimeoutError(..)".fmt(f)
26 }
27}
28
29#[unstable(feature = "mpmc_channel", issue = "126840")]
30impl<T> fmt::Display for SendTimeoutError<T> {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 match *self {
33 SendTimeoutError::Timeout(..) => "timed out waiting on send operation".fmt(f),
34 SendTimeoutError::Disconnected(..) => "sending on a disconnected channel".fmt(f),
35 }
36 }
37}
38
39#[unstable(feature = "mpmc_channel", issue = "126840")]
40impl<T> error::Error for SendTimeoutError<T> {}
41
42#[unstable(feature = "mpmc_channel", issue = "126840")]
43impl<T> From<SendError<T>> for SendTimeoutError<T> {
44 fn from(err: SendError<T>) -> SendTimeoutError<T> {
45 match err {
46 SendError(e) => SendTimeoutError::Disconnected(e),
47 }
48 }
49}