use super::envelope::Envelope;
use std::collections::VecDeque;

pub struct Channel {
    pub name: String,
    pub queue: VecDeque<Envelope>,
}

impl Channel {
    pub fn new(name: impl Into<String>) -> Self {
        Self {
            name: name.into(),
            queue: VecDeque::new(),
        }
    }
    pub fn push(&mut self, e: Envelope) {
        self.queue.push_back(e);
    }
    pub fn pop(&mut self) -> Option<Envelope> {
        self.queue.pop_front()
    }
    pub fn len(&self) -> usize {
        self.queue.len()
    }
    pub fn is_empty(&self) -> bool {
        self.queue.is_empty()
    }
}
