dbuff 0.1.0

Double-buffered state with async command chains, streaming, and keyed task pools for ratatui applications
Documentation
#[cfg(feature = "error-stack")]
pub(crate) trait ErasedError: std::fmt::Debug + std::fmt::Display + Send + Sync {}
#[cfg(feature = "error-stack")]
impl<T> ErasedError for T where T: std::fmt::Debug + std::fmt::Display + Send + Sync {}

/// A type-erased error that implements [`std::error::Error`].
///
/// Used as the context type for [`error_stack::Report`] in the
/// [`on_error`](DomainExecutor::on_error) handler when the `error-stack`
/// feature is enabled. Wraps `Box<dyn ErasedError>` to allow any command error
/// to be captured in a `Report` with full stack traces.
#[cfg(feature = "error-stack")]
pub struct BoxError(pub(crate) Box<dyn ErasedError>);

#[cfg(feature = "error-stack")]
impl std::fmt::Display for BoxError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

#[cfg(feature = "error-stack")]
impl std::fmt::Debug for BoxError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

#[cfg(feature = "error-stack")]
impl std::error::Error for BoxError {}

/// The library's known error context type.
///
/// Used as the top-level context in [`error_stack::Report`] passed to
/// [`on_error`](DomainExecutor::on_error) handlers. Callers can use
/// [`Report::change_context`](error_stack::Report::change_context) to layer
/// their own context on top.
#[cfg(feature = "error-stack")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DbuffErr;

#[cfg(feature = "error-stack")]
impl std::fmt::Display for DbuffErr {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "command execution failed")
    }
}

#[cfg(feature = "error-stack")]
impl std::error::Error for DbuffErr {}