Skip to main content

AsyncEncodeRecord

Trait AsyncEncodeRecord 

Source
pub trait AsyncEncodeRecord {
    // Required methods
    async fn encode_record<R: DbnEncodable>(&mut self, record: &R) -> Result<()>;
    async fn flush(&mut self) -> Result<()>;
    async fn shutdown(&mut self) -> Result<()>;

    // Provided method
    async fn encode_records<R: DbnEncodable>(
        &mut self,
        records: &[R],
    ) -> Result<()> { ... }
}
Available on crate feature async only.
Expand description

Trait for async encoding of DBN records of a specific type.

Required Methods§

Source

async fn encode_record<R: DbnEncodable>(&mut self, record: &R) -> Result<()>

Encodes a single DBN record of type R.

§Errors

This function returns an error if it’s unable to write to the underlying writer or there’s a serialization error.

§Cancel safety

This method is not cancellation safe. If this method is used in a tokio::select! statement and another branch completes first, then the record may have been partially written, but future calls will begin writing the encoded record from the beginning.

Source

async fn flush(&mut self) -> Result<()>

Flushes any buffered content to the true output.

§Errors

This function returns an error if it’s unable to flush the underlying writer.

Source

async fn shutdown(&mut self) -> Result<()>

Initiates or attempts to shut down the inner writer.

§Errors

This function returns an error if the shut down did not complete successfully.

Provided Methods§

Source

async fn encode_records<R: DbnEncodable>(&mut self, records: &[R]) -> Result<()>

Encodes a slice of DBN records.

§Errors

This function returns an error if it’s unable to write to the underlying writer or there’s a serialization error.

§Cancel safety

This method is not cancellation safe. If this method is used in a tokio::select! statement and another branch completes first, then the record may have been partially written, but future calls will begin writing the encoded record from the beginning.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, E> AsyncEncodeRecord for SplitEncoder<S, E>
where S: Splitter<E>, E: AsyncEncodeRecord,

Source§

impl<W> AsyncEncodeRecord for dbn::encode::dbn::AsyncEncoder<W>
where W: AsyncWriteExt + Unpin,

Source§

impl<W> AsyncEncodeRecord for RecordEncoder<W>
where W: AsyncWriteExt + Unpin,

Source§

impl<W> AsyncEncodeRecord for dbn::encode::json::AsyncEncoder<W>
where W: AsyncWriteExt + Unpin,