AsyncRecordEncoder

Struct AsyncRecordEncoder 

Source
pub struct AsyncRecordEncoder<W>
where W: AsyncWriteExt + Unpin,
{ /* private fields */ }
Available on crate feature async only.
Expand description

An async encoder of DBN records.

Implementations§

Source§

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

Source

pub fn new(writer: W) -> Self

Creates a new instance of RecordEncoder that will forward its output to writer.

Source

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

Encode a single DBN record of type R.

§Errors

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

§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

pub async fn encode_ref(&mut self, record_ref: RecordRef<'_>) -> 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.

§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

pub fn get_ref(&self) -> &W

Returns a reference to the underlying writer.

Source

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

Returns a mutable reference to the underlying writer.

Source

pub fn into_inner(self) -> W

Consumes the encoder returning the original writer.

Trait Implementations§

Source§

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

Source§

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

Encodes a single DBN record of type R. Read more
Source§

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

Flushes any buffered content to the true output. Read more
Source§

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

Initiates or attempts to shut down the inner writer. Read more
Source§

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

Source§

async unsafe fn encode_record_ref_ts_out( &mut self, record_ref: RecordRef<'_>, _ts_out: bool, ) -> Result<()>

Encodes a single DBN record.

§Safety

DBN encoding a RecordRef is safe because no dispatching based on type is required.

§Errors

This function will return an error if it fails to encode record to writer.

Source§

async fn encode_record_ref(&mut self, record_ref: RecordRef<'_>) -> Result<()>

Encodes a single RecordRef. Read more
Source§

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

Source§

fn from(meta_encoder: MetadataEncoder<W>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<W> Freeze for RecordEncoder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for RecordEncoder<W>
where W: RefUnwindSafe,

§

impl<W> Send for RecordEncoder<W>
where W: Send,

§

impl<W> Sync for RecordEncoder<W>
where W: Sync,

§

impl<W> Unpin for RecordEncoder<W>

§

impl<W> UnwindSafe for RecordEncoder<W>
where W: 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, 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,