async_flow/error/
send_error.rs

1// This is free and unencumbered software released into the public domain.
2
3use thiserror::Error;
4
5#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
6#[error("SendError")]
7pub enum SendError {
8    #[error("failed to send message on unconnected port")]
9    Unconnected,
10
11    #[error("failed to send message on disconnected port")]
12    Disconnected,
13
14    #[error("failed to send message on closed port")]
15    Closed,
16}
17
18impl From<crate::io::PortState> for SendError {
19    fn from(input: crate::io::PortState) -> Self {
20        use crate::io::PortState::*;
21        match input {
22            Unconnected => Self::Unconnected,
23            Connected => unreachable!(),
24            Disconnected => Self::Disconnected,
25            Closed => Self::Closed,
26        }
27    }
28}
29
30#[cfg(feature = "flume")]
31impl<T> From<flume::SendError<T>> for SendError {
32    fn from(_input: flume::SendError<T>) -> Self {
33        Self // TODO
34    }
35}
36
37#[cfg(feature = "tokio")]
38impl<T> From<tokio::sync::mpsc::error::SendError<T>> for SendError {
39    fn from(_input: tokio::sync::mpsc::error::SendError<T>) -> Self {
40        Self::Disconnected
41    }
42}