use crate::{Action, TelnetError, TelnetOption};
use std::collections::VecDeque;
#[derive(Debug)]
pub enum Event {
Data(Box<[u8]>),
UnknownIAC(u8),
Negotiation(Action, TelnetOption),
Subnegotiation(TelnetOption, Box<[u8]>),
TimedOut,
NoData,
Error(TelnetError),
}
#[repr(transparent)]
pub struct TelnetEventQueue(VecDeque<Event>);
impl TelnetEventQueue {
pub fn new() -> TelnetEventQueue {
TelnetEventQueue(VecDeque::new())
}
pub fn push_event(&mut self, event: Event) {
self.0.push_back(event);
}
pub fn take_event(&mut self) -> Option<Event> {
self.0.pop_front()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}