use core::fmt;
use crate::ProducerObserverError;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ProducerFlushError {
ExecutionUnavailable,
Observer(ProducerObserverError),
}
impl fmt::Display for ProducerFlushError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ExecutionUnavailable => {
formatter.write_str("producer execution became unavailable before flush")
}
Self::Observer(error) => error.fmt(formatter),
}
}
}
impl std::error::Error for ProducerFlushError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::ExecutionUnavailable => None,
Self::Observer(error) => Some(error),
}
}
}