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
use websocket::zero_copy::Frame;
#[derive(Debug, Clone)]
pub enum Packet {
Ping(Vec<u8>),
Pong(Vec<u8>),
Text(String),
Binary(Vec<u8>),
Close(u16, String),
}
impl<'a> From<&'a Packet> for Frame<'a> {
fn from(pkt: &'a Packet) -> Frame<'a> {
use websocket::zero_copy::Frame as F;
use self::Packet as P;
match *pkt {
P::Ping(ref x) => F::Ping(x),
P::Pong(ref x) => F::Pong(x),
P::Text(ref x) => F::Text(x),
P::Binary(ref x) => F::Binary(x),
P::Close(c, ref t) => F::Close(c, t),
}
}
}