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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::io;
use derive_more::{Display, From};
mod codec;
mod frame;
mod mask;
mod proto;
mod sink;
mod stream;
pub use self::codec::{Codec, Frame, Item, Message};
pub use self::frame::Parser;
pub use self::proto::{hash_key, CloseCode, CloseReason, OpCode};
pub use self::sink::WsSink;
pub use self::stream::{StreamDecoder, StreamEncoder};
#[derive(Debug, Display)]
pub enum WsError<E> {
Service(E),
KeepAlive,
Protocol(ProtocolError),
Io(io::Error),
}
#[derive(Debug, Display, From)]
pub enum ProtocolError {
#[display(fmt = "Received an unmasked frame from client")]
UnmaskedFrame,
#[display(fmt = "Received a masked frame from server")]
MaskedFrame,
#[display(fmt = "Invalid opcode: {}", _0)]
InvalidOpcode(u8),
#[display(fmt = "Invalid control frame length: {}", _0)]
InvalidLength(usize),
#[display(fmt = "Bad web socket op code")]
BadOpCode,
#[display(fmt = "A payload reached size limit.")]
Overflow,
#[display(fmt = "Continuation is not started.")]
ContinuationNotStarted,
#[display(fmt = "Received new continuation but it is already started")]
ContinuationStarted,
#[display(fmt = "Unknown continuation fragment.")]
ContinuationFragment(OpCode),
}