use thiserror::Error;
use super::MAX_PUSH_RATE;
#[non_exhaustive]
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
pub enum PushError {
#[error("push queue full")]
QueueFull,
#[error("push queue closed")]
Closed,
#[error("push rate limit reached")]
RateLimited,
#[error("push frame of {size} bytes exceeds the {max}-byte frame limit")]
FrameTooLarge {
size: usize,
max: usize,
},
}
#[non_exhaustive]
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum PushConfigError {
#[error("invalid rate {0}; must be between 1 and {max}", max = MAX_PUSH_RATE)]
InvalidRate(usize),
#[error(
"invalid capacities; high={high}, low={low}; each must be between 1 and {max}",
max = tokio::sync::Semaphore::MAX_PERMITS
)]
InvalidCapacity {
high: usize,
low: usize,
},
}