Struct databento::historical::timeseries::AsyncDbnDecoder
source · pub struct AsyncDbnDecoder<R>where
R: AsyncReadExt + Unpin,{ /* private fields */ }
historical
only.Expand description
An async decoder for Databento Binary Encoding (DBN), both metadata and records.
Implementations§
source§impl<R> Decoder<R>where
R: AsyncReadExt + Unpin,
impl<R> Decoder<R>where
R: AsyncReadExt + Unpin,
sourcepub async fn new(reader: R) -> Result<Decoder<R>, Error>
pub async fn new(reader: R) -> Result<Decoder<R>, Error>
Creates a new async DBN Decoder
from reader
. Will upgrade records from
previous DBN version to the current version.
§Errors
This function will return an error if it is unable to parse the metadata in
reader
or the input is encoded in a newer version of DBN.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.
sourcepub async fn with_upgrade_policy(
reader: R,
upgrade_policy: VersionUpgradePolicy,
) -> Result<Decoder<R>, Error>
pub async fn with_upgrade_policy( reader: R, upgrade_policy: VersionUpgradePolicy, ) -> Result<Decoder<R>, Error>
Creates a new async DBN Decoder
from reader
. It will decode records from
previous DBN versions according to upgrade_policy
.
§Errors
This function will return an error if it is unable to parse the metadata in
reader
or the input is encoded in a newer version of DBN.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes the decoder and returns the inner reader.
sourcepub fn set_upgrade_policy(&mut self, upgrade_policy: VersionUpgradePolicy)
pub fn set_upgrade_policy(&mut self, upgrade_policy: VersionUpgradePolicy)
Sets the behavior for decoding DBN data of previous versions.
sourcepub async fn decode_record<'a, T>(&'a mut self) -> Result<Option<&'a T>, Error>where
T: HasRType + 'a,
pub async fn decode_record<'a, T>(&'a mut self) -> Result<Option<&'a T>, Error>where
T: HasRType + 'a,
Tries to decode a single record and returns a reference to the record that
lasts until the next method call. Returns Ok(None)
if reader
has been
exhausted.
§Errors
This function returns an error if the underlying reader returns an error. If
the next record is of a different type than T
, this function returns a
Error::Conversion
error.
§Cancel safety
This method is cancel safe. It can be used within a tokio::select!
statement
without the potential for corrupting the input stream.
sourcepub async fn decode_record_ref(
&mut self,
) -> Result<Option<RecordRef<'_>>, Error>
pub async fn decode_record_ref( &mut self, ) -> Result<Option<RecordRef<'_>>, Error>
Tries to decode a single record and returns a reference to the record that
lasts until the next method call. Returns Ok(None)
if reader
has been
exhausted.
§Errors
This function returns an error if the underlying reader returns an error. It will also return an error if it encounters an invalid record.
§Cancel safety
This method is cancel safe. It can be used within a tokio::select!
statement
without the potential for corrupting the input stream.
source§impl<R> Decoder<ZstdDecoder<BufReader<R>>>where
R: AsyncReadExt + Unpin,
impl<R> Decoder<ZstdDecoder<BufReader<R>>>where
R: AsyncReadExt + Unpin,
sourcepub async fn with_zstd(
reader: R,
) -> Result<Decoder<ZstdDecoder<BufReader<R>>>, Error>
pub async fn with_zstd( reader: R, ) -> Result<Decoder<ZstdDecoder<BufReader<R>>>, Error>
Creates a new async DBN Decoder
from Zstandard-compressed reader
.
§Errors
This function will return an error if it is unable to parse the metadata in reader
.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.
source§impl<R> Decoder<ZstdDecoder<R>>where
R: AsyncBufReadExt + Unpin,
impl<R> Decoder<ZstdDecoder<R>>where
R: AsyncBufReadExt + Unpin,
sourcepub async fn with_zstd_buffer(
reader: R,
) -> Result<Decoder<ZstdDecoder<R>>, Error>
pub async fn with_zstd_buffer( reader: R, ) -> Result<Decoder<ZstdDecoder<R>>, Error>
Creates a new async DBN Decoder
from Zstandard-compressed buffered reader
.
§Errors
This function will return an error if it is unable to parse the metadata in reader
.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.
source§impl Decoder<BufReader<File>>
impl Decoder<BufReader<File>>
sourcepub async fn from_file(
path: impl AsRef<Path>,
) -> Result<Decoder<BufReader<File>>, Error>
pub async fn from_file( path: impl AsRef<Path>, ) -> Result<Decoder<BufReader<File>>, Error>
Creates a new async DBN Decoder
from the file at path
.
§Errors
This function will return an error if it is unable to read the file at path
or
if it is unable to parse the metadata in the file.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.
source§impl Decoder<ZstdDecoder<BufReader<File>>>
impl Decoder<ZstdDecoder<BufReader<File>>>
sourcepub async fn from_zstd_file(
path: impl AsRef<Path>,
) -> Result<Decoder<ZstdDecoder<BufReader<File>>>, Error>
pub async fn from_zstd_file( path: impl AsRef<Path>, ) -> Result<Decoder<ZstdDecoder<BufReader<File>>>, Error>
Creates a new async DBN Decoder
from the Zstandard-compressed file at path
.
§Errors
This function will return an error if it is unable to read the file at path
or
if it is unable to parse the metadata in the file.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select!
statement and another branch completes first, the metadata
may have been partially read, corrupting the stream.