Skip to main content

DynDecoder

Struct DynDecoder 

Source
pub struct DynDecoder<'a, R>(/* private fields */)
where
    R: BufRead;
Expand description

A decoder whose Encoding and Compression are determined at runtime by peeking at the first few bytes.

Implementations§

Source§

impl<R> DynDecoder<'_, BufReader<R>>
where R: Read,

Source

pub fn new( reader: R, compression: Compression, upgrade_policy: VersionUpgradePolicy, ) -> Result<Self>

Creates a new DynDecoder from a reader, with the specified compression. It will decode records from previous DBN versions according to upgrade_policy.

§Errors

This function will return an error if it fails to parse the metadata.

Source

pub fn new_inferred( reader: R, upgrade_policy: VersionUpgradePolicy, ) -> Result<Self>

Creates a new DynDecoder from a reader, inferring the encoding and compression. If reader also implements io::BufRead, it is better to use inferred_with_buffer(). It will decode records from previous DBN versions according to upgrade_policy.

§Errors

This function will return an error if it is unable to determine the encoding of reader or it fails to parse the metadata.

Source§

impl<R> DynDecoder<'_, R>
where R: BufRead,

Source

pub fn with_buffer( reader: R, compression: Compression, upgrade_policy: VersionUpgradePolicy, ) -> Result<Self>

Creates a new DynDecoder from a buffered reader with the specified compression.It will decode records from previous DBN versions according to upgrade_policy.

§Errors

This function will return an error if it is unable to determine the encoding of reader or it fails to parse the metadata.

Source

pub fn inferred_with_buffer( reader: R, upgrade_policy: VersionUpgradePolicy, ) -> Result<Self>

Creates a new DynDecoder from a buffered reader, inferring the encoding and compression.It will decode records from previous DBN versions according to upgrade_policy.

§Errors

This function will return an error if it is unable to determine the encoding of reader or it fails to parse the metadata.

Source§

impl DynDecoder<'_, BufReader<File>>

Source

pub fn from_file( path: impl AsRef<Path>, upgrade_policy: VersionUpgradePolicy, ) -> Result<Self>

Creates a new DynDecoder from the file at path. It will decode records from previous DBN versions according to upgrade_policy.

§Errors

This function will return an error if the file doesn’t exist, it is unable to determine the encoding of the file or it fails to parse the metadata.

Trait Implementations§

Source§

impl<R> DbnMetadata for DynDecoder<'_, R>
where R: BufRead,

Source§

fn metadata(&self) -> &Metadata

Returns an immutable reference to the decoded Metadata.
Source§

fn metadata_mut(&mut self) -> &mut Metadata

Returns a mutable reference to the decoded Metadata.
Source§

impl<R> DecodeRecord for DynDecoder<'_, R>
where R: BufRead,

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. Read more
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. Read more
Source§

impl<R> DecodeRecordRef for DynDecoder<'_, R>
where R: BufRead,

Source§

fn decode_record_ref(&mut self) -> Result<Option<RecordRef<'_>>>

Tries to decode a generic reference a record. Returns Ok(None) if input has been exhausted. Read more
Source§

impl<R> DecodeStream for DynDecoder<'_, R>
where R: BufRead,

Source§

fn decode_stream<T: HasRType>(self) -> StreamIterDecoder<Self, T>
where Self: Sized,

Converts the decoder into a streaming iterator of records of type T. This lazily decodes the data.

Auto Trait Implementations§

§

impl<'a, R> Freeze for DynDecoder<'a, R>
where R: Freeze,

§

impl<'a, R> RefUnwindSafe for DynDecoder<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for DynDecoder<'a, R>
where R: Send,

§

impl<'a, R> Sync for DynDecoder<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for DynDecoder<'a, R>
where R: Unpin,

§

impl<'a, R> !UnwindSafe for DynDecoder<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,