Skip to main content

RowEncoder

Trait RowEncoder 

Source
pub trait RowEncoder: Send + Sync {
    // Required methods
    fn start_new_row(&mut self) -> Result<()>;
    fn encode_field(&mut self, pos: usize, value: Datum<'_>) -> Result<()>;
    fn finish_row(&mut self) -> Result<Bytes>;
    fn close(&mut self) -> Result<()>;
}
Expand description

An encoder to write binary row data. It’s used to write rows one by one. When writing a new row:

  1. call method RowEncoder::start_new_row() to start the writing.
  2. call method RowEncoder::encode_field() to write the row’s field.
  3. call method RowEncoder::finish_row() to finish the writing and get the written row.

Required Methods§

Source

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

Start to write a new row.

§Returns
  • Ok(()) if successful
Source

fn encode_field(&mut self, pos: usize, value: Datum<'_>) -> Result<()>

Write the row’s field in given pos with given value.

§Arguments
  • pos - the position of the field to write.
  • value - the value of the field to write.
§Returns
  • Ok(()) if successful
Source

fn finish_row(&mut self) -> Result<Bytes>

Finish write the row, returns the written row.

Note that returned row borrows from RowEncoder’s internal buffer which is reused for subsequent rows RowEncoder::start_new_row() should only be called after the returned row goes out of scope.

§Returns
  • the written row
Source

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

Closes the row encoder

§Returns
  • Ok(()) if successful

Implementors§