pub trait DecodeDbn: BufferSlice {
// Required methods
fn metadata(&self) -> &Metadata;
fn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>;
fn decode_record_ref(&mut self) -> Result<Option<RecordRef<'_>>>;
fn decode_stream<T: HasRType>(self) -> Result<StreamIterDecoder<Self, T>>
where Self: Sized;
// Provided method
fn decode_records<T: HasRType + Clone>(self) -> Result<Vec<T>>
where Self: Sized { ... }
}Expand description
Trait for types that decode DBN records.
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,
io::ErrorKind::InvalidData will be returned.
sourcefn decode_record_ref(&mut self) -> Result<Option<RecordRef<'_>>>
fn decode_record_ref(&mut self) -> Result<Option<RecordRef<'_>>>
Tries to decode a generic reference a record.
Errors
This function returns an error if the underlying reader returns an
error of a kind other than io::ErrorKind::UnexpectedEof upon reading.
sourcefn decode_stream<T: HasRType>(self) -> Result<StreamIterDecoder<Self, T>>where
Self: Sized,
fn decode_stream<T: HasRType>(self) -> Result<StreamIterDecoder<Self, T>>where Self: Sized,
Tries to convert the decoder into a streaming iterator. This lazily decodes the data.
Errors
This function returns an error if schema of the data being decoded doesn’t
correspond with T.