use crate::RetainedBytes;
use super::{Lane, LaneLimits, MailboxLimits};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct DrainReport {
pub(super) drained: usize,
pub(super) status: DrainStatus,
}
impl DrainReport {
pub const fn drained(self) -> usize {
self.drained
}
pub const fn status(self) -> DrainStatus {
self.status
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DrainStatus {
Idle,
MorePending,
Closed,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct LaneSnapshot {
pub(super) limits: LaneLimits,
pub(super) queued_messages: usize,
pub(super) retained_bytes: RetainedBytes,
pub(super) message_rejections: u64,
pub(super) byte_rejections: u64,
}
impl LaneSnapshot {
pub const fn limits(self) -> LaneLimits {
self.limits
}
pub const fn queued_messages(self) -> usize {
self.queued_messages
}
pub const fn retained_bytes(self) -> RetainedBytes {
self.retained_bytes
}
pub const fn message_rejections(self) -> u64 {
self.message_rejections
}
pub const fn byte_rejections(self) -> u64 {
self.byte_rejections
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct MailboxSnapshot {
pub(super) control: LaneSnapshot,
pub(super) work: LaneSnapshot,
pub(super) live_senders: usize,
pub(super) receiver_alive: bool,
pub(super) closed_rejections: u64,
pub(super) wake_failures: u64,
pub(super) wake_requested: bool,
}
impl MailboxSnapshot {
pub const fn lane(self, lane: Lane) -> LaneSnapshot {
match lane {
Lane::Control => self.control,
Lane::Work => self.work,
}
}
pub const fn limits(self) -> MailboxLimits {
MailboxLimits::new(self.control.limits, self.work.limits)
}
pub const fn live_senders(self) -> usize {
self.live_senders
}
pub const fn receiver_alive(self) -> bool {
self.receiver_alive
}
pub const fn closed_rejections(self) -> u64 {
self.closed_rejections
}
pub const fn wake_failures(self) -> u64 {
self.wake_failures
}
pub const fn wake_requested(self) -> bool {
self.wake_requested
}
}