use std::{
io,
sync::Arc,
};
use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum RejectedExecution {
#[error("task rejected because the executor service is shut down")]
Shutdown,
#[error("task rejected because the executor service is saturated")]
Saturated,
#[error("task rejected because the executor service failed to spawn a worker: {source}")]
WorkerSpawnFailed {
source: Arc<io::Error>,
},
}
impl PartialEq for RejectedExecution {
fn eq(&self, other: &Self) -> bool {
matches!(
(self, other),
(Self::Shutdown, Self::Shutdown)
| (Self::Saturated, Self::Saturated)
| (
Self::WorkerSpawnFailed { .. },
Self::WorkerSpawnFailed { .. }
)
)
}
}
impl Eq for RejectedExecution {}