/// Tries to deserialize a record of type T from the journal stream.  It might return
/// ReadResult::Reset if a reset marker is encountered, or ReadResult::ChecksumMismatch (which
/// is expected at the end of the journal stream).
Tries to deserialize a record of type T from the journal stream.  It might return
ReadResult::Reset if a reset marker is encountered, or ReadResult::ChecksumMismatch (which
is expected at the end of the journal stream).
Tries to deserialize a record of type T from the journal stream . It might return ReadResult :: Reset if a reset marker is encountered or ReadResult :: ChecksumMismatch ( which is expected at the end of the journal stream ) .
pub async fn deserialize<T>(&mut self) -> Result<ReadResult<T>, Error>
    where
        for<'de> T: Deserialize<'de>,
    {
        self.fill_buf().await?;
        let mut cursor = std::io::Cursor::new(self.buffer());
        match deserialize_from(&mut cursor) {
            Ok(record) => {
                let consumed = cursor.position() as usize;
                self.consume(consumed);
                Ok(ReadResult::Some(record))
            }
            Err(e) => {
                if self.found_reset {
                    self.found_reset = false;
                    // Fix up buf_range now...
                    self.consume(self.buf_range.end - self.buf_range.start);
                    self.buf_range = self.buf.len() - self.block_size as usize
                        ..self.buf.len() - std::mem::size_of::<Checksum>();
                    return Ok(ReadResult::Reset);
                } else if let bincode::ErrorKind::Io(io_error) = &*e {
                    if io_error.kind() == std::io::ErrorKind::UnexpectedEof && self.bad_checksum {
                        return Ok(ReadResult::ChecksumMismatch);
                    }
                }
                Err(e.into())
            }
        }
    }
pub async fn deserialize < T > ( & mut self ) -> Result < ReadResult < T > , Error > where for < ' de > T : Deserialize < ' de > , { self . fill_buf ( ) . await ? ; let mut cursor = std :: io :: Cursor :: new ( self . buffer ( ) ) ; match deserialize_from ( & mut cursor ) { Ok ( record ) => { let consumed = cursor . position ( ) as usize ; self . consume ( consumed ) ; Ok ( ReadResult :: Some ( record ) ) } Err ( e ) => { if self . found_reset { self . found_reset = false ; // Fix up buf_range now... self . consume ( self . buf_range . end - self . buf_range . start ) ; self . buf_range = self . buf . len ( ) - self . block_size as usize .. self . buf . len ( ) - std :: mem :: size_of :: < Checksum > ( ) ; return Ok ( ReadResult :: Reset ) ; } else if let bincode :: ErrorKind :: Io ( io_error ) = & * e { if io_error . kind ( ) == std :: io :: ErrorKind :: UnexpectedEof && self . bad_checksum { return Ok ( ReadResult :: ChecksumMismatch ) ; } } Err ( e . into ( ) ) } } }
Tries to deserialize a record of type T from the journal stream.
Tries to deserialize a record of type T from the journal stream .
&mut self