use std::num::NonZeroUsize;
use crate::RetainedBytes;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum Lane {
Control,
Work,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct LaneLimits {
messages: NonZeroUsize,
retained_bytes: RetainedBytes,
}
impl LaneLimits {
pub const fn new(messages: NonZeroUsize, retained_bytes: RetainedBytes) -> Self {
Self {
messages,
retained_bytes,
}
}
pub const fn messages(self) -> NonZeroUsize {
self.messages
}
pub const fn retained_bytes(self) -> RetainedBytes {
self.retained_bytes
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct MailboxLimits {
control: LaneLimits,
work: LaneLimits,
}
impl MailboxLimits {
pub const fn new(control: LaneLimits, work: LaneLimits) -> Self {
Self { control, work }
}
pub const fn lane(self, lane: Lane) -> LaneLimits {
match lane {
Lane::Control => self.control,
Lane::Work => self.work,
}
}
pub const fn control(self) -> LaneLimits {
self.control
}
pub const fn work(self) -> LaneLimits {
self.work
}
}