Struct databento::historical::timeseries::AsyncDbnDecoder

source ·
pub struct AsyncDbnDecoder<R>
where R: AsyncReadExt + Unpin,
{ /* private fields */ }
Available on crate feature 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,

source

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.

source

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.

source

pub fn get_mut(&mut self) -> &mut R

Returns a mutable reference to the inner reader.

source

pub fn into_inner(self) -> R

Consumes the decoder and returns the inner reader.

source

pub fn metadata(&self) -> &Metadata

Returns a reference to the decoded metadata.

source

pub fn set_upgrade_policy(&mut self, upgrade_policy: VersionUpgradePolicy)

Sets the behavior for decoding DBN data of previous versions.

source

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.

source

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,

source

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>>

source

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>>

source

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>>>

source

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.

Auto Trait Implementations§

§

impl<R> Freeze for Decoder<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Decoder<R>
where R: RefUnwindSafe,

§

impl<R> Send for Decoder<R>
where R: Send,

§

impl<R> Sync for Decoder<R>
where R: Sync,

§

impl<R> Unpin for Decoder<R>

§

impl<R> UnwindSafe for Decoder<R>
where R: UnwindSafe,

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T