use std::fmt;
use super::{
flush_error::{ProducerTryFlushError, ProducerTryFlushErrorKind},
flush_result::ProducerTryFlushAccepted,
};
use crate::producer::ingress::ProducerPortFlushError;
pub type ProducerTryCloseAccepted = ProducerTryFlushAccepted;
pub type ProducerTryCloseErrorKind = ProducerTryFlushErrorKind;
#[derive(Debug)]
pub struct ProducerTryCloseError {
inner: ProducerTryFlushError,
}
impl ProducerTryCloseError {
pub const fn kind(&self) -> ProducerTryCloseErrorKind {
self.inner.kind()
}
pub fn detail(&self) -> Option<&str> {
self.inner.detail()
}
pub(super) const fn moment_unrepresentable() -> Self {
Self {
inner: ProducerTryFlushError::moment_unrepresentable(),
}
}
pub(super) fn from_port(error: ProducerPortFlushError) -> Self {
Self {
inner: ProducerTryFlushError::from_port(error),
}
}
}
impl fmt::Display for ProducerTryCloseError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.detail() {
Some(detail) => write!(
formatter,
"producer try_close failed: {:?}: {detail}",
self.kind()
),
None => write!(formatter, "producer try_close failed: {:?}", self.kind()),
}
}
}
impl std::error::Error for ProducerTryCloseError {}