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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use std::fmt;
use failure::{Backtrace, Fail};
use ::chunk_io::{ChunkSerializationError, ChunkDeserializationError};
use ::messages::{MessageSerializationError, MessageDeserializationError};
#[derive(Debug)]
pub struct ServerSessionError {
pub kind: ServerSessionErrorKind,
}
#[derive(Debug, Fail)]
pub enum ServerSessionErrorKind {
#[fail(display = "An error occurred deserializing incoming data: {}", _0)]
ChunkDeserializationError(#[cause] ChunkDeserializationError),
#[fail(display = "An error occurred serializing outbound messages: {}", _0)]
ChunkSerializationError(#[cause] ChunkSerializationError),
#[fail(display = "An error occurred while attempting to turn an RTMP message into a message payload: {}", _0)]
MessageSerializationError(#[cause] MessageSerializationError),
#[fail(display = "An error occurred while attempting to turn a message payload into an RTMP message: {}", _0)]
MessageDeserializationError(#[cause] MessageDeserializationError),
#[fail(display = "Attempted to accept or reject request id {} but no outstanding requests have that id", _0)]
InvalidOutstandingRequest(u32),
#[fail(display = "The connection request did not have a non-empty RTMP app name")]
NoAppNameForConnectionRequest,
#[fail(display = "The request id specified could not be matched to an outstanding request")]
InvalidRequestId,
#[fail(display = "The '{}' action was attempted on non-existant stream id {}", action, stream_id)]
ActionAttemptedOnInactiveStream {
action: String,
stream_id: u32,
}
}
impl fmt::Display for ServerSessionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.kind, f)
}
}
impl Fail for ServerSessionError {
fn cause(&self) -> Option<&dyn Fail> {
self.kind.cause()
}
fn backtrace(&self) -> Option<&Backtrace> {
self.kind.backtrace()
}
}
impl From<ChunkSerializationError> for ServerSessionError {
fn from(kind: ChunkSerializationError) -> Self {
ServerSessionError { kind: ServerSessionErrorKind::ChunkSerializationError(kind) }
}
}
impl From<ChunkDeserializationError> for ServerSessionError {
fn from(kind: ChunkDeserializationError) -> Self {
ServerSessionError { kind: ServerSessionErrorKind::ChunkDeserializationError(kind) }
}
}
impl From<MessageSerializationError> for ServerSessionError {
fn from(kind: MessageSerializationError) -> Self {
ServerSessionError { kind: ServerSessionErrorKind::MessageSerializationError(kind) }
}
}
impl From<MessageDeserializationError> for ServerSessionError {
fn from(kind: MessageDeserializationError) -> Self {
ServerSessionError { kind: ServerSessionErrorKind::MessageDeserializationError(kind) }
}
}