Skip to main content

AsyncEncoder

Struct AsyncEncoder 

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

Type for encoding files and streams of DBN records in JSON lines.

Implementations§

Source§

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

Source

pub fn new( writer: W, should_pretty_print: bool, use_pretty_px: bool, use_pretty_ts: bool, ) -> Self

Creates a new instance of Encoder. If should_pretty_print is true, each JSON object will be nicely formatted and indented, instead of the default compact output with no whitespace between key-value pairs.

Source

pub async fn encode_metadata(&mut self, metadata: &Metadata) -> Result<()>

Encodes metadata into JSON.

§Errors

This function returns an error if there’s an error writing to 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 metadata JSON may have been partially written, but future calls will begin writing the metadata JSON 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.

Trait Implementations§

Source§

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

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.

§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 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 Encoder<W>
where W: AsyncWriteExt + Unpin,

Source§

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

Encodes a single RecordRef. Read more
Source§

async fn encode_record_refs( &mut self, record_refs: &[RecordRef<'_>], ) -> Result<()>

Encodes a slice of RecordRefs. Read more
Source§

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

Encodes a single DBN RecordRef with an optional ts_out (see record::WithTsOut). Read more
Source§

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

Encodes a single DBN RecordRef with an appended ts_out timestamp. Read more
Source§

async fn encode_record_refs_with_ts_out( &mut self, record_refs: &[RecordRef<'_>], ts_out: u64, ) -> Result<()>

Encodes a slice of RecordRefs, each with the same appended ts_out timestamp. Read more
Source§

impl<W> AsyncEncodeRecordTextExt for Encoder<W>
where W: AsyncWriteExt + Unpin,

Source§

async fn encode_record_with_sym<R: DbnEncodable>( &mut self, record: &R, symbol: Option<&str>, ) -> Result<()>

Encodes a single DBN record of type R along with the record’s text symbol. Read more
Source§

async fn encode_ref_with_sym( &mut self, record: RecordRef<'_>, symbol: Option<&str>, ) -> Result<()>

Encodes a single DBN RecordRef along with the record’s text symbol. Read more
Source§

async unsafe fn encode_ref_ts_out_with_sym( &mut self, record: RecordRef<'_>, ts_out: bool, symbol: Option<&str>, ) -> Result<()>

Encodes a single DBN RecordRef with an optional ts_out (see record::WithTsOut) along with the record’s text symbol. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<W> Unpin for Encoder<W>

§

impl<W> UnsafeUnpin for Encoder<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for Encoder<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,