Struct dbn::encode::csv::Encoder

source ·
pub struct Encoder<W>where
    W: Write,{ /* private fields */ }
Expand description

Type for encoding files and streams of DBN records in CSV.

Note that encoding Metadata in CSV is not supported.

Implementations§

source§

impl<W> Encoder<W>where W: Write,

source

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

Creates a new Encoder that will write to writer. If use_pretty_px is true, price fields will be serialized as a decimal. If pretty_ts is true, timestamp fields will be serialized in a ISO8601 datetime string.

Trait Implementations§

source§

impl<W> EncodeDbn for Encoder<W>where W: Write,

source§

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

Encodes a stream 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.

source§

fn encode_decoded<D: DecodeDbn>(&mut self, decoder: D) -> Result<()>

Encode DBN records directly from a DBN decoder. This implemented outside EncodeDbn because the CSV encoder has the additional constraint of only being able to encode a single schema in a stream.

Errors

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

source§

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

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

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

Encodes a slice of DBN records. Read more
source§

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

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

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

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

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

Encodes a single DBN record. Read more

Auto Trait Implementations§

§

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>where W: Unpin,

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.