1*0bce4e4cSHarlanC use crate::amf0::errors::{self, Amf0WriteError}; 2*0bce4e4cSHarlanC use crate::chunk::errors::UnpackError; 3*0bce4e4cSHarlanC use crate::messages::errors::MessageError; 4*0bce4e4cSHarlanC use crate::netconnection::errors::NetConnectionError; 5*0bce4e4cSHarlanC use crate::netstream::errors::NetStreamError; 6*0bce4e4cSHarlanC use crate::protocol_control_messages::errors::ControlMessagesError; 7*0bce4e4cSHarlanC use crate::user_control_messages::errors::EventMessagesError; 8*0bce4e4cSHarlanC use crate::chunk::errors::PackError; 9*0bce4e4cSHarlanC use crate::handshake::errors::HandshakeError; 10*0bce4e4cSHarlanC 11*0bce4e4cSHarlanC use liverust_lib::netio::bytes_errors::BytesWriteError; 12*0bce4e4cSHarlanC use liverust_lib::netio::netio_errors::NetIOError; 13*0bce4e4cSHarlanC 14*0bce4e4cSHarlanC use tokio::time::Elapsed; 15*0bce4e4cSHarlanC 16*0bce4e4cSHarlanC 17*0bce4e4cSHarlanC 18*0bce4e4cSHarlanC // pub struct ServerError { 19*0bce4e4cSHarlanC // pub value: ServerErrorValue, 20*0bce4e4cSHarlanC // } 21*0bce4e4cSHarlanC 22*0bce4e4cSHarlanC // pub enum ServerErrorValue { 23*0bce4e4cSHarlanC // Amf0WriteError(Amf0WriteError), 24*0bce4e4cSHarlanC // BytesWriteError(BytesWriteError), 25*0bce4e4cSHarlanC // TimeoutError(Elapsed), 26*0bce4e4cSHarlanC // UnPackError(UnpackError), 27*0bce4e4cSHarlanC // MessageError(MessageError), 28*0bce4e4cSHarlanC // ControlMessagesError(ControlMessagesError), 29*0bce4e4cSHarlanC // NetConnectionError(NetConnectionError), 30*0bce4e4cSHarlanC // NetStreamError(NetStreamError), 31*0bce4e4cSHarlanC // EventMessagesError(EventMessagesError), 32*0bce4e4cSHarlanC // NetIOError(NetIOError), 33*0bce4e4cSHarlanC // PackError(PackError), 34*0bce4e4cSHarlanC // Amf0ValueCountNotCorrect, 35*0bce4e4cSHarlanC // Amf0ValueTypeNotCorrect, 36*0bce4e4cSHarlanC // } 37*0bce4e4cSHarlanC 38*0bce4e4cSHarlanC // impl From<Amf0WriteError> for ServerError { 39*0bce4e4cSHarlanC // fn from(error: Amf0WriteError) -> Self { 40*0bce4e4cSHarlanC // ServerError { 41*0bce4e4cSHarlanC // value: ServerErrorValue::Amf0WriteError(error), 42*0bce4e4cSHarlanC // } 43*0bce4e4cSHarlanC // } 44*0bce4e4cSHarlanC // } 45*0bce4e4cSHarlanC 46*0bce4e4cSHarlanC // impl From<BytesWriteError> for ServerError { 47*0bce4e4cSHarlanC // fn from(error: BytesWriteError) -> Self { 48*0bce4e4cSHarlanC // ServerError { 49*0bce4e4cSHarlanC // value: ServerErrorValue::BytesWriteError(error), 50*0bce4e4cSHarlanC // } 51*0bce4e4cSHarlanC // } 52*0bce4e4cSHarlanC // } 53*0bce4e4cSHarlanC 54*0bce4e4cSHarlanC // impl From<Elapsed> for ServerError { 55*0bce4e4cSHarlanC // fn from(error: Elapsed) -> Self { 56*0bce4e4cSHarlanC // ServerError { 57*0bce4e4cSHarlanC // value: ServerErrorValue::TimeoutError(error), 58*0bce4e4cSHarlanC // } 59*0bce4e4cSHarlanC // } 60*0bce4e4cSHarlanC // } 61*0bce4e4cSHarlanC 62*0bce4e4cSHarlanC // impl From<UnpackError> for ServerError { 63*0bce4e4cSHarlanC // fn from(error: UnpackError) -> Self { 64*0bce4e4cSHarlanC // ServerError { 65*0bce4e4cSHarlanC // value: ServerErrorValue::UnPackError(error), 66*0bce4e4cSHarlanC // } 67*0bce4e4cSHarlanC // } 68*0bce4e4cSHarlanC // } 69*0bce4e4cSHarlanC 70*0bce4e4cSHarlanC // impl From<MessageError> for ServerError { 71*0bce4e4cSHarlanC // fn from(error: MessageError) -> Self { 72*0bce4e4cSHarlanC // ServerError { 73*0bce4e4cSHarlanC // value: ServerErrorValue::MessageError(error), 74*0bce4e4cSHarlanC // } 75*0bce4e4cSHarlanC // } 76*0bce4e4cSHarlanC // } 77*0bce4e4cSHarlanC 78*0bce4e4cSHarlanC // impl From<ControlMessagesError> for ServerError { 79*0bce4e4cSHarlanC // fn from(error: ControlMessagesError) -> Self { 80*0bce4e4cSHarlanC // ServerError { 81*0bce4e4cSHarlanC // value: ServerErrorValue::ControlMessagesError(error), 82*0bce4e4cSHarlanC // } 83*0bce4e4cSHarlanC // } 84*0bce4e4cSHarlanC // } 85*0bce4e4cSHarlanC 86*0bce4e4cSHarlanC // impl From<NetConnectionError> for ServerError { 87*0bce4e4cSHarlanC // fn from(error: NetConnectionError) -> Self { 88*0bce4e4cSHarlanC // ServerError { 89*0bce4e4cSHarlanC // value: ServerErrorValue::NetConnectionError(error), 90*0bce4e4cSHarlanC // } 91*0bce4e4cSHarlanC // } 92*0bce4e4cSHarlanC // } 93*0bce4e4cSHarlanC 94*0bce4e4cSHarlanC // impl From<NetStreamError> for ServerError { 95*0bce4e4cSHarlanC // fn from(error: NetStreamError) -> Self { 96*0bce4e4cSHarlanC // ServerError { 97*0bce4e4cSHarlanC // value: ServerErrorValue::NetStreamError(error), 98*0bce4e4cSHarlanC // } 99*0bce4e4cSHarlanC // } 100*0bce4e4cSHarlanC // } 101*0bce4e4cSHarlanC 102*0bce4e4cSHarlanC // impl From<EventMessagesError> for ServerError { 103*0bce4e4cSHarlanC // fn from(error: EventMessagesError) -> Self { 104*0bce4e4cSHarlanC // ServerError { 105*0bce4e4cSHarlanC // value: ServerErrorValue::EventMessagesError(error), 106*0bce4e4cSHarlanC // } 107*0bce4e4cSHarlanC // } 108*0bce4e4cSHarlanC // } 109*0bce4e4cSHarlanC 110*0bce4e4cSHarlanC // impl From<NetIOError> for ServerError { 111*0bce4e4cSHarlanC // fn from(error: NetIOError) -> Self { 112*0bce4e4cSHarlanC // ServerError { 113*0bce4e4cSHarlanC // value: ServerErrorValue::NetIOError(error), 114*0bce4e4cSHarlanC // } 115*0bce4e4cSHarlanC // } 116*0bce4e4cSHarlanC // } 117*0bce4e4cSHarlanC 118*0bce4e4cSHarlanC pub struct SessionError { 119*0bce4e4cSHarlanC pub value: SessionErrorValue, 120*0bce4e4cSHarlanC } 121*0bce4e4cSHarlanC 122*0bce4e4cSHarlanC pub enum SessionErrorValue { 123*0bce4e4cSHarlanC Amf0WriteError(Amf0WriteError), 124*0bce4e4cSHarlanC BytesWriteError(BytesWriteError), 125*0bce4e4cSHarlanC TimeoutError(Elapsed), 126*0bce4e4cSHarlanC UnPackError(UnpackError), 127*0bce4e4cSHarlanC MessageError(MessageError), 128*0bce4e4cSHarlanC ControlMessagesError(ControlMessagesError), 129*0bce4e4cSHarlanC NetConnectionError(NetConnectionError), 130*0bce4e4cSHarlanC NetStreamError(NetStreamError), 131*0bce4e4cSHarlanC EventMessagesError(EventMessagesError), 132*0bce4e4cSHarlanC NetIOError(NetIOError), 133*0bce4e4cSHarlanC PackError(PackError), 134*0bce4e4cSHarlanC HandshakeError(HandshakeError), 135*0bce4e4cSHarlanC 136*0bce4e4cSHarlanC Amf0ValueCountNotCorrect, 137*0bce4e4cSHarlanC Amf0ValueTypeNotCorrect, 138*0bce4e4cSHarlanC } 139*0bce4e4cSHarlanC 140*0bce4e4cSHarlanC impl From<Amf0WriteError> for SessionError { 141*0bce4e4cSHarlanC fn from(error: Amf0WriteError) -> Self { 142*0bce4e4cSHarlanC SessionError { 143*0bce4e4cSHarlanC value: SessionErrorValue::Amf0WriteError(error), 144*0bce4e4cSHarlanC } 145*0bce4e4cSHarlanC } 146*0bce4e4cSHarlanC } 147*0bce4e4cSHarlanC 148*0bce4e4cSHarlanC impl From<BytesWriteError> for SessionError { 149*0bce4e4cSHarlanC fn from(error: BytesWriteError) -> Self { 150*0bce4e4cSHarlanC SessionError { 151*0bce4e4cSHarlanC value: SessionErrorValue::BytesWriteError(error), 152*0bce4e4cSHarlanC } 153*0bce4e4cSHarlanC } 154*0bce4e4cSHarlanC } 155*0bce4e4cSHarlanC 156*0bce4e4cSHarlanC impl From<Elapsed> for SessionError { 157*0bce4e4cSHarlanC fn from(error: Elapsed) -> Self { 158*0bce4e4cSHarlanC SessionError { 159*0bce4e4cSHarlanC value: SessionErrorValue::TimeoutError(error), 160*0bce4e4cSHarlanC } 161*0bce4e4cSHarlanC } 162*0bce4e4cSHarlanC } 163*0bce4e4cSHarlanC 164*0bce4e4cSHarlanC impl From<UnpackError> for SessionError { 165*0bce4e4cSHarlanC fn from(error: UnpackError) -> Self { 166*0bce4e4cSHarlanC SessionError { 167*0bce4e4cSHarlanC value: SessionErrorValue::UnPackError(error), 168*0bce4e4cSHarlanC } 169*0bce4e4cSHarlanC } 170*0bce4e4cSHarlanC } 171*0bce4e4cSHarlanC 172*0bce4e4cSHarlanC impl From<MessageError> for SessionError { 173*0bce4e4cSHarlanC fn from(error: MessageError) -> Self { 174*0bce4e4cSHarlanC SessionError { 175*0bce4e4cSHarlanC value: SessionErrorValue::MessageError(error), 176*0bce4e4cSHarlanC } 177*0bce4e4cSHarlanC } 178*0bce4e4cSHarlanC } 179*0bce4e4cSHarlanC 180*0bce4e4cSHarlanC impl From<ControlMessagesError> for SessionError { 181*0bce4e4cSHarlanC fn from(error: ControlMessagesError) -> Self { 182*0bce4e4cSHarlanC SessionError { 183*0bce4e4cSHarlanC value: SessionErrorValue::ControlMessagesError(error), 184*0bce4e4cSHarlanC } 185*0bce4e4cSHarlanC } 186*0bce4e4cSHarlanC } 187*0bce4e4cSHarlanC 188*0bce4e4cSHarlanC impl From<NetConnectionError> for SessionError { 189*0bce4e4cSHarlanC fn from(error: NetConnectionError) -> Self { 190*0bce4e4cSHarlanC SessionError { 191*0bce4e4cSHarlanC value: SessionErrorValue::NetConnectionError(error), 192*0bce4e4cSHarlanC } 193*0bce4e4cSHarlanC } 194*0bce4e4cSHarlanC } 195*0bce4e4cSHarlanC 196*0bce4e4cSHarlanC impl From<NetStreamError> for SessionError { 197*0bce4e4cSHarlanC fn from(error: NetStreamError) -> Self { 198*0bce4e4cSHarlanC SessionError { 199*0bce4e4cSHarlanC value: SessionErrorValue::NetStreamError(error), 200*0bce4e4cSHarlanC } 201*0bce4e4cSHarlanC } 202*0bce4e4cSHarlanC } 203*0bce4e4cSHarlanC 204*0bce4e4cSHarlanC impl From<EventMessagesError> for SessionError { 205*0bce4e4cSHarlanC fn from(error: EventMessagesError) -> Self { 206*0bce4e4cSHarlanC SessionError { 207*0bce4e4cSHarlanC value: SessionErrorValue::EventMessagesError(error), 208*0bce4e4cSHarlanC } 209*0bce4e4cSHarlanC } 210*0bce4e4cSHarlanC } 211*0bce4e4cSHarlanC 212*0bce4e4cSHarlanC impl From<NetIOError> for SessionError { 213*0bce4e4cSHarlanC fn from(error: NetIOError) -> Self { 214*0bce4e4cSHarlanC SessionError { 215*0bce4e4cSHarlanC value: SessionErrorValue::NetIOError(error), 216*0bce4e4cSHarlanC } 217*0bce4e4cSHarlanC } 218*0bce4e4cSHarlanC } 219*0bce4e4cSHarlanC 220*0bce4e4cSHarlanC impl From<PackError> for SessionError { 221*0bce4e4cSHarlanC fn from(error: PackError) -> Self { 222*0bce4e4cSHarlanC SessionError { 223*0bce4e4cSHarlanC value: SessionErrorValue::PackError(error), 224*0bce4e4cSHarlanC } 225*0bce4e4cSHarlanC } 226*0bce4e4cSHarlanC } 227*0bce4e4cSHarlanC 228*0bce4e4cSHarlanC impl From<HandshakeError> for SessionError { 229*0bce4e4cSHarlanC fn from(error: HandshakeError) -> Self { 230*0bce4e4cSHarlanC SessionError { 231*0bce4e4cSHarlanC value: SessionErrorValue::HandshakeError(error), 232*0bce4e4cSHarlanC } 233*0bce4e4cSHarlanC } 234*0bce4e4cSHarlanC } 235*0bce4e4cSHarlanC 236*0bce4e4cSHarlanC 237