use std::any::type_name;
use std::fmt;
#[derive(Clone, PartialEq, Eq)]
pub struct SendError<T>(T);
impl<T> SendError<T> {
pub fn as_inner(&self) -> &T {
&self.0
}
pub fn into_inner(self) -> T {
self.0
}
pub(super) fn new(value: T) -> Self {
Self(value)
}
}
impl<T> fmt::Display for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("sending on a disconnected channel")
}
}
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SendError<{}>(..)", type_name::<T>())
}
}
impl<T> std::error::Error for SendError<T> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RecvError {
Disconnected,
}
impl fmt::Display for RecvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("receiving on a disconnected channel")
}
}
impl std::error::Error for RecvError {}