mod refresh_coordinator;
mod stats;
use crate::error::Error;
pub use refresh_coordinator::{RefreshCoordinator, RefreshTask};
pub use stats::RefreshStats;
use std::fmt::Display;
#[derive(Debug)]
pub enum EnqueueError {
AlreadyProcessing,
QueueFull,
Closed,
}
impl Display for EnqueueError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EnqueueError::AlreadyProcessing => write!(f, "Already processing"),
EnqueueError::QueueFull => write!(f, "Queue full"),
EnqueueError::Closed => write!(f, "Coordinator closed"),
}
}
}
impl std::error::Error for EnqueueError {}
impl From<EnqueueError> for Error {
fn from(e: EnqueueError) -> Self {
match e {
EnqueueError::AlreadyProcessing => {
Error::Plugin("Refresh already in progress".to_string())
}
EnqueueError::QueueFull => Error::Plugin("Refresh queue full".to_string()),
EnqueueError::Closed => Error::Plugin("Refresh coordinator closed".to_string()),
}
}
}