use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum MailboxKind {
#[default]
Unbounded,
Bounded,
UnboundedDeque,
UnboundedPriority,
UnboundedStablePriority,
}
#[derive(Debug, Clone)]
pub struct MailboxConfig {
pub kind: MailboxKind,
pub capacity: usize,
pub push_timeout: Duration,
}
impl Default for MailboxConfig {
fn default() -> Self {
Self { kind: MailboxKind::Unbounded, capacity: 1_000, push_timeout: Duration::from_secs(10) }
}
}
#[derive(Debug, Clone, Default)]
pub struct Mailbox {
pub config: MailboxConfig,
}
impl Mailbox {
pub fn new(config: MailboxConfig) -> Self {
Self { config }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_mailbox_kind_unbounded() {
assert_eq!(Mailbox::default().config.kind, MailboxKind::Unbounded);
}
}