pub async fn recv<U>(
        &self,
        codec: &U,
    ) -> Result<Option<U::Item>, Either<U::Error, io::Error>>
    where
        U: Decoder,
    {
        loop {
            return match poll_fn(|cx| self.poll_recv(codec, cx)).await {
                Ok(item) => Ok(Some(item)),
                Err(RecvError::KeepAlive) => Err(Either::Right(io::Error::new(
                    io::ErrorKind::Other,
                    "Keep-alive",
                ))),
                Err(RecvError::Stop) => Err(Either::Right(io::Error::new(
                    io::ErrorKind::Other,
                    "Dispatcher stopped",
                ))),
                Err(RecvError::WriteBackpressure) => {
                    poll_fn(|cx| self.poll_flush(cx, false))
                        .await
                        .map_err(Either::Right)?;
                    continue;
                }
                Err(RecvError::Decoder(err)) => Err(Either::Left(err)),
                Err(RecvError::PeerGone(Some(err))) => Err(Either::Right(err)),
                Err(RecvError::PeerGone(None)) => Ok(None),
            };
        }
    }
/// Read incoming io stream and decode codec item.
Read incoming io stream and decode codec item.
Read incoming io stream and decode codec item .
pub async fn recv<U>(
        &self,
        codec: &U,
    ) -> Result<Option<U::Item>, Either<U::Error, io::Error>>
    where
        U: Decoder,
    {
        loop {
            return match poll_fn(|cx| self.poll_recv(codec, cx)).await {
                Ok(item) => Ok(Some(item)),
                Err(RecvError::KeepAlive) => Err(Either::Right(io::Error::new(
                    io::ErrorKind::Other,
                    "Keep-alive",
                ))),
                Err(RecvError::Stop) => Err(Either::Right(io::Error::new(
                    io::ErrorKind::Other,
                    "Dispatcher stopped",
                ))),
                Err(RecvError::WriteBackpressure) => {
                    poll_fn(|cx| self.poll_flush(cx, false))
                        .await
                        .map_err(Either::Right)?;
                    continue;
                }
                Err(RecvError::Decoder(err)) => Err(Either::Left(err)),
                Err(RecvError::PeerGone(Some(err))) => Err(Either::Right(err)),
                Err(RecvError::PeerGone(None)) => Ok(None),
            };
        }
    }
pub async fn recv < U > ( & self , codec : & U , ) -> Result < Option < U :: Item > , Either < U :: Error , io :: Error > > where U : Decoder , { loop { return match poll_fn ( | cx | self . poll_recv ( codec , cx ) ) . await { Ok ( item ) => Ok ( Some ( item ) ) , Err ( RecvError :: KeepAlive ) => Err ( Either :: Right ( io :: Error :: new ( io :: ErrorKind :: Other , " " , ) ) ) , Err ( RecvError :: Stop ) => Err ( Either :: Right ( io :: Error :: new ( io :: ErrorKind :: Other , " " , ) ) ) , Err ( RecvError :: WriteBackpressure ) => { poll_fn ( | cx | self . poll_flush ( cx , false ) ) . await . map_err ( Either :: Right ) ? ; continue ; } Err ( RecvError :: Decoder ( err ) ) => Err ( Either :: Left ( err ) ) , Err ( RecvError :: PeerGone ( Some ( err ) ) ) => Err ( Either :: Right ( err ) ) , Err ( RecvError :: PeerGone ( None ) ) => Ok ( None ) , } ; } }
Read incoming io stream and decode codec item.
Read incoming io stream and decode codec item .
&self
codec
&U
&self
codec
&U