1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()
}
}