Struct dbn::decode::DynDecoder
source · pub struct DynDecoder<'a, R>(/* private fields */)
where
R: BufRead;Expand description
A decoder implementing DecodeDbn whose Encoding and
Compression are determined at runtime by peeking at the first few bytes.
Implementations§
source§impl<'a, R> DynDecoder<'a, BufReader<R>>where
R: Read,
impl<'a, R> DynDecoder<'a, BufReader<R>>where R: Read,
sourcepub fn new(
reader: R,
compression: Compression,
upgrade_policy: VersionUpgradePolicy
) -> Result<Self>
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.
sourcepub fn new_inferred(
reader: R,
upgrade_policy: VersionUpgradePolicy
) -> Result<Self>
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<'a, R> DynDecoder<'a, R>where
R: BufRead,
impl<'a, R> DynDecoder<'a, R>where R: BufRead,
sourcepub fn with_buffer(
reader: R,
compression: Compression,
upgrade_policy: VersionUpgradePolicy
) -> Result<Self>
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.
sourcepub fn inferred_with_buffer(
reader: R,
upgrade_policy: VersionUpgradePolicy
) -> Result<Self>
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<'a> DynDecoder<'a, BufReader<File>>
impl<'a> DynDecoder<'a, BufReader<File>>
sourcepub fn from_file(
path: impl AsRef<Path>,
upgrade_policy: VersionUpgradePolicy
) -> Result<Self>
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<'a, R> DecodeDbn for DynDecoder<'a, R>where
R: BufRead,
impl<'a, R> DecodeDbn for DynDecoder<'a, R>where R: BufRead,
source§fn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>
fn decode_record<T: HasRType>(&mut self) -> Result<Option<&T>>
T. Returns Ok(None)
if the input has been exhausted. Read moresource§fn decode_stream<T: HasRType>(self) -> StreamIterDecoder<Self, T>where
Self: Sized,
fn decode_stream<T: HasRType>(self) -> StreamIterDecoder<Self, T>where Self: Sized,
T. This
lazily decodes the data.