Trait dbn::encode::EncodeDbn

source ·
pub trait EncodeDbn {
    // Required methods
    fn encode_record<R: DbnEncodable>(&mut self, record: &R) -> Result<()>;
    fn flush(&mut self) -> Result<()>;

    // Provided methods
    fn encode_records<R: DbnEncodable>(&mut self, records: &[R]) -> Result<()> { ... }
    fn encode_stream<R: DbnEncodable>(
        &mut self,
        stream: impl StreamingIterator<Item = R>
    ) -> Result<()> { ... }
    unsafe fn encode_record_ref(
        &mut self,
        record: RecordRef<'_>,
        ts_out: bool
    ) -> Result<()> { ... }
    fn encode_decoded<D: DecodeDbn>(&mut self, decoder: D) -> Result<()> { ... }
    fn encode_decoded_with_limit<D: DecodeDbn>(
        &mut self,
        decoder: D,
        limit: NonZeroU64
    ) -> Result<()> { ... }
}
Expand description

Trait for types that encode DBN records with mixed schemas.

Required Methods§

source

fn encode_record<R: DbnEncodable>(&mut self, record: &R) -> 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 or there’s a serialization error.

source

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

Flushes any buffered content to the true output.

Errors

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

Provided Methods§

source

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 or there’s a serialization error.

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

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

Encodes a single DBN record.

Safety

ts_out must be false if record does not have an appended `ts_out

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<()>

Encodes DBN records directly from a DBN decoder.

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_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.

Errors

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

Implementors§

source§

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

source§

impl<W> EncodeDbn for dbn::encode::csv::Encoder<W>where W: Write,

source§

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

source§

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

source§

impl<W> EncodeDbn for dbn::encode::json::Encoder<W>where W: Write,