pub trait DecodeRecord {
// Required method
fn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>;
// Provided method
fn decode_records<T: HasRType + Clone>(self) -> Result<Vec<T>>
where Self: Sized { ... }
}Expand description
Trait for types that decode DBN records of a particular type.
Required Methods§
Sourcefn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>
fn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>
Tries to decode a reference to a single record of type T. Returns Ok(None)
if the input has been exhausted.
§Errors
This function returns an error if the underlying reader returns an error of a
kind other than io::ErrorKind::UnexpectedEof upon reading.
If the next record is of a different type than T, an
Error::Conversion will be returned.
If the length property of the record is invalid, an
Error::Decode will be returned.
Provided Methods§
Sourcefn decode_records<T: HasRType + Clone>(self) -> Result<Vec<T>>where
Self: Sized,
fn decode_records<T: HasRType + Clone>(self) -> Result<Vec<T>>where
Self: Sized,
Tries to decode all records into a Vec. This eagerly decodes the data.
§Errors
This function returns an error if the underlying reader returns an error of a
kind other than io::ErrorKind::UnexpectedEof upon reading.
If any of the records is of a different type than T, an
Error::Conversion will be returned.
If the length property of any of the records is invalid, a
Error::Decode will be returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.