Trait dbn::decode::DecodeDbn

source ·
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§

source

fn metadata(&self) -> &Metadata

Returns a reference to the decoded Metadata.

source

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.

source

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.

source

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.

Provided Methods§

source

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 schema of the data being decoded doesn’t correspond with T.

Implementors§

source§

impl<'a, R> DecodeDbn for DynDecoder<'a, R>where R: BufRead,

source§

impl<R> DecodeDbn for dbn::decode::dbn::Decoder<R>where R: Read,

source§

impl<R: BufRead> DecodeDbn for dbn::decode::dbz::Decoder<R>