Struct dbn::encode::DynEncoder

source ·
pub struct DynEncoder<'a, W>(/* private fields */)
where
    W: Write;
Expand description

An encoder whose Encoding and Compression can be set at runtime.

Implementations§

source§

impl<'a, W> DynEncoder<'a, W>
where W: Write,

source

pub fn new( writer: W, encoding: Encoding, compression: Compression, metadata: &Metadata, should_pretty_print: bool, use_pretty_px: bool, use_pretty_ts: bool, ) -> Result<Self>

Constructs a new instance of DynEncoder.

Note: should_pretty_print, use_pretty_px, and use_pretty_ts are ignored if encoding is Dbn.

§Errors

This function returns an error if it fails to encode the DBN metadata or it fails to initialize the Zstd compression.

source

pub fn builder( writer: W, encoding: Encoding, compression: Compression, metadata: &Metadata, ) -> DynEncoderBuilder<'_, W>

Creates a builder for configuring a DynEncoder object.

source

pub fn encode_header<R: DbnEncodable>( &mut self, with_symbol: bool, ) -> Result<()>

Encodes the CSV header for the record type R, i.e. the names of each of the fields to the output.

If with_symbol is true, will add a header field for “symbol”.

§Errors

This function returns an error if there’s an error writing to writer.

source

pub fn encode_header_for_schema( &mut self, schema: Schema, ts_out: bool, with_symbol: bool, ) -> Result<()>

Encodes the CSV header for schema, i.e. the names of each of the fields to the output.

If ts_out is true, will add a header field “ts_out”. If with_symbol is true, will add a header field “symbol”.

§Errors

This function returns an error if there’s an error writing to writer.

Trait Implementations§

source§

impl<'a, W> EncodeDbn for DynEncoder<'a, W>
where W: Write,

source§

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

Encodes a slice of DBN records. Read more
source§

fn encode_stream<R: DbnEncodable>( &mut self, stream: impl FallibleStreamingIterator<Item = R, Error = Error>, ) -> Result<()>

Encodes a stream of DBN records. Read more
source§

fn encode_decoded<D: DecodeRecordRef + DbnMetadata>( &mut self, decoder: D, ) -> Result<()>

Encodes DBN records directly from a DBN decoder. Read more
source§

fn encode_decoded_with_limit<D: DecodeRecordRef + DbnMetadata>( &mut self, decoder: D, limit: NonZeroU64, ) -> Result<()>

Encodes DBN records directly from a DBN decoder, outputting no more than limit records. Read more
source§

impl<'a, W> EncodeRecord for DynEncoder<'a, W>
where W: Write,

source§

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

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

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

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

impl<'a, W> EncodeRecordRef for DynEncoder<'a, W>
where W: Write,

source§

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

Encodes a single DBN RecordRef. Read more
source§

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

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

impl<'a, W> EncodeRecordTextExt for DynEncoder<'a, W>
where W: Write,

source§

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§

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§

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<'a, W> Freeze for DynEncoder<'a, W>
where W: Freeze,

§

impl<'a, W> !RefUnwindSafe for DynEncoder<'a, W>

§

impl<'a, W> Send for DynEncoder<'a, W>
where W: Send,

§

impl<'a, W> !Sync for DynEncoder<'a, W>

§

impl<'a, W> Unpin for DynEncoder<'a, W>
where W: Unpin,

§

impl<'a, W> !UnwindSafe for DynEncoder<'a, W>

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,