// Read from substream and deserialize the received bytes.
Read from substream and deserialize the received bytes.
Read from substream and deserialize the received bytes .
async fn read_and_parse<TRq: DeserializeOwned>(io: &mut NegotiatedSubstream) -> Result<TRq, io::Error> {
    read_length_prefixed(io, usize::MAX)
        .map(|res| match res {
            Ok(bytes) => {
                serde_json::from_slice(bytes.as_slice()).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
            }
            Err(e) => Err(io::Error::new(io::ErrorKind::Other, e)),
        })
        .await
}
async fn read_and_parse < TRq : DeserializeOwned > ( io : & mut NegotiatedSubstream ) -> Result < TRq , io :: Error > { read_length_prefixed ( io , usize :: MAX ) . map ( | res | match res { Ok ( bytes ) => { serde_json :: from_slice ( bytes . as_slice ( ) ) . map_err ( | e | io :: Error :: new ( io :: ErrorKind :: InvalidData , e ) ) } Err ( e ) => Err ( io :: Error :: new ( io :: ErrorKind :: Other , e ) ) , } ) . await }
Read from substream and deserialize the received bytes.
Read from substream and deserialize the received bytes .
io
&mut NegotiatedSubstream