1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 03:42:59 +01:00

better FramedTransportError

This commit is contained in:
Nikolay Kim 2018-09-24 22:31:05 -07:00
parent d5d2c81c68
commit 13c66a2ac4

View File

@ -159,10 +159,16 @@ where
} }
/// Framed transport errors /// Framed transport errors
pub enum FramedTransportError<E1, E2, E3> { pub enum FramedTransportError<E, U: Encoder + Decoder> {
Service(E1), Service(E),
Encoder(E2), Encoder(<U as Encoder>::Error),
Decoder(E3), Decoder(<U as Decoder>::Error),
}
impl<E, U: Encoder + Decoder> From<E> for FramedTransportError<E, U> {
fn from(err: E) -> Self {
FramedTransportError::Service(err)
}
} }
/// FramedTransport - is a future that reads frames from Framed object /// FramedTransport - is a future that reads frames from Framed object
@ -185,8 +191,8 @@ where
enum TransportState<S: Service, U: Encoder + Decoder> { enum TransportState<S: Service, U: Encoder + Decoder> {
Processing, Processing,
Error(FramedTransportError<S::Error, <U as Encoder>::Error, <U as Decoder>::Error>), Error(FramedTransportError<S::Error, U>),
EncoderError(FramedTransportError<S::Error, <U as Encoder>::Error, <U as Decoder>::Error>), EncoderError(FramedTransportError<S::Error, U>),
Stopping, Stopping,
} }
@ -345,7 +351,7 @@ where
<U as Encoder>::Error: 'static, <U as Encoder>::Error: 'static,
{ {
type Item = (); type Item = ();
type Error = FramedTransportError<S::Error, <U as Encoder>::Error, <U as Decoder>::Error>; type Error = FramedTransportError<S::Error, U>;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match mem::replace(&mut self.state, TransportState::Processing) { match mem::replace(&mut self.state, TransportState::Processing) {