pub struct Encoder<W>where
W: Write,{ /* private fields */ }Expand description
Type for encoding files and streams of DBN records in CSV or other text-delimited tabular file formats including TSV (tab-separated values).
Note that encoding Metadata in CSV is not supported.
Implementations§
source§impl<W> Encoder<W>where
W: Write,
impl<W> Encoder<W>where
W: Write,
sourcepub fn builder(writer: W) -> EncoderBuilder<W>
pub fn builder(writer: W) -> EncoderBuilder<W>
Creates a builder for configuring an Encoder object.
sourcepub fn new(writer: W, use_pretty_px: bool, use_pretty_ts: bool) -> Self
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.
sourcepub fn encode_header<R: DbnEncodable>(
&mut self,
with_symbol: bool
) -> Result<()>
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”. This should
only be used with Self::encode_record_with_sym() and
Self::encode_ref_with_sym(), otherwise there will be a mismatch between the
number of fields in the header and the body.
§Errors
This function returns an error if there’s an error writing to writer.
sourcepub fn encode_header_for_schema(
&mut self,
schema: Schema,
ts_out: bool,
with_symbol: bool
) -> Result<()>
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, it will add a header field “ts_out”.
If with_symbol is true, it will add a header field for “symbol”. This should
only be used with Self::encode_record_with_sym() and
Self::encode_ref_with_sym(), otherwise there will be a mismatch between the
number of fields in the header and the body.
§Errors
This function returns an error if there’s an error writing to writer.
Trait Implementations§
source§impl<W> EncodeDbn for Encoder<W>where
W: Write,
impl<W> EncodeDbn for Encoder<W>where
W: Write,
source§fn encode_stream<R: DbnEncodable>(
&mut self,
stream: impl FallibleStreamingIterator<Item = R, Error = Error>
) -> Result<()>
fn encode_stream<R: DbnEncodable>( &mut self, stream: impl FallibleStreamingIterator<Item = R, Error = Error> ) -> 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: DecodeRecordRef + DbnMetadata>(
&mut self,
decoder: D
) -> Result<()>
fn encode_decoded<D: DecodeRecordRef + DbnMetadata>( &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_records<R: DbnEncodable>(&mut self, records: &[R]) -> Result<()>
fn encode_records<R: DbnEncodable>(&mut self, records: &[R]) -> Result<()>
source§fn encode_decoded_with_limit<D: DecodeRecordRef + DbnMetadata>(
&mut self,
decoder: D,
limit: NonZeroU64
) -> Result<()>
fn encode_decoded_with_limit<D: DecodeRecordRef + DbnMetadata>( &mut self, decoder: D, limit: NonZeroU64 ) -> Result<()>
limit records. Read more