#![forbid(unsafe_code)]
use core::fmt;
use core::fmt::Debug;
#[derive(Debug, PartialEq, Eq)]
pub enum SendError {
Closed,
ReceiveClosed,
}
impl core::error::Error for SendError {}
impl fmt::Display for SendError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(
match *self {
SendError::Closed => "send to a closed channel",
SendError::ReceiveClosed => "send to a half closed channel",
},
f,
)
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum SendErrorTimeout {
Closed,
ReceiveClosed,
Timeout,
}
impl core::error::Error for SendErrorTimeout {}
impl fmt::Display for SendErrorTimeout {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(
match *self {
SendErrorTimeout::Closed => "send to a closed channel",
SendErrorTimeout::ReceiveClosed => "send to a half closed channel",
SendErrorTimeout::Timeout => "send timeout",
},
f,
)
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum ReceiveError {
Closed,
SendClosed,
}
impl core::error::Error for ReceiveError {}
impl fmt::Display for ReceiveError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(
match *self {
ReceiveError::Closed => "receive from a closed channel",
ReceiveError::SendClosed => "receive from a half closed channel",
},
f,
)
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum ReceiveErrorTimeout {
Closed,
SendClosed,
Timeout,
}
impl core::error::Error for ReceiveErrorTimeout {}
impl fmt::Display for ReceiveErrorTimeout {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(
match *self {
ReceiveErrorTimeout::Closed => "receive from a closed channel",
ReceiveErrorTimeout::SendClosed => "receive from a half closed channel",
ReceiveErrorTimeout::Timeout => "receive timeout",
},
f,
)
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct CloseError();
impl core::error::Error for CloseError {}
impl fmt::Display for CloseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt("channel is already closed", f)
}
}