use thiserror::Error;
use tokio::sync::{mpsc::error::SendError, oneshot::error::RecvError};
#[derive(Error, Debug)]
pub enum BatchError {
#[error("Unable to send item to the worker for batching: channel closed")]
Tx,
#[error("Error while waiting for batch results: channel closed. {}", .0)]
Rx(RecvError),
}
pub type Result<T> = std::result::Result<T, BatchError>;
impl From<RecvError> for BatchError {
fn from(rx_err: RecvError) -> Self {
BatchError::Rx(rx_err)
}
}
impl<T> From<SendError<T>> for BatchError {
fn from(_tx_err: SendError<T>) -> Self {
BatchError::Tx
}
}