async-flow 0.1.5

Async abstractions for flow-based programming (FBP).
Documentation
// This is free and unencumbered software released into the public domain.

use super::{RecvError, SendError, TryRecvError, TrySendError};
use alloc::boxed::Box;
use thiserror::Error;

pub type Result<T = (), E = Error> = core::result::Result<T, E>;

#[derive(Debug, Error)]
pub enum Error {
    #[error("{0}")]
    Recv(#[from] RecvError),

    #[error("{0}")]
    TryRecv(#[from] TryRecvError),

    #[error("{0}")]
    Send(#[from] SendError),

    #[error("{0}")]
    TrySend(#[from] TrySendError),

    #[cfg(feature = "tokio")]
    #[error("{0}")]
    Join(#[from] tokio::task::JoinError),

    #[cfg(feature = "std")]
    #[error("{0}")]
    Stdio(#[from] std::io::Error),

    #[error("{0}")]
    Other(#[from] Box<dyn core::error::Error + Send + Sync>),
}

#[cfg(feature = "serde")]
impl From<serde_json::Error> for Error {
    fn from(value: serde_json::Error) -> Self {
        Error::Other(Box::new(value))
    }
}