pub trait Document: Send + Sync + DocumentClone + Debug {
    // Required methods
    fn read(&self, buffer: &[u8]) -> Result<DataSet>;
    fn write(&self, dataset: &DataSet) -> Result<Vec<u8>>;

    // Provided methods
    fn metadata(&self) -> Metadata { ... }
    fn has_data(&self, buffer: &[u8]) -> Result<bool> { ... }
    fn can_append(&self) -> bool { ... }
    fn header(&self, _dataset: &DataSet) -> Result<Vec<u8>> { ... }
    fn footer(&self, _dataset: &DataSet) -> Result<Vec<u8>> { ... }
    fn terminator(&self) -> Result<Vec<u8>> { ... }
    fn set_entry_path(&mut self, _entry_point: String) { ... }
}
Expand description

Every document_builder that implement this trait can get/write json_value through a connector.

Required Methods§

source

fn read(&self, buffer: &[u8]) -> Result<DataSet>

Read buffer of bytes and transform it into dataset

source

fn write(&self, dataset: &DataSet) -> Result<Vec<u8>>

Write dataset into a buffer of bytes

Provided Methods§

source

fn metadata(&self) -> Metadata

source

fn has_data(&self, buffer: &[u8]) -> Result<bool>

Check if the buffer has data

source

fn can_append(&self) -> bool

Check if it’s possible to append new data into the end of the document

True: Append the data to the end of the document False: Replace the document

source

fn header(&self, _dataset: &DataSet) -> Result<Vec<u8>>

Return the header data used to identify when the data start |––––|——|––––| document => | header | data | footer | |––––|——|––––|

source

fn footer(&self, _dataset: &DataSet) -> Result<Vec<u8>>

Return the footer data used to identify when the data end |––––|——|––––| document => | header | data | footer | |––––|——|––––|

source

fn terminator(&self) -> Result<Vec<u8>>

Return the terminator to seperate lines of data

source

fn set_entry_path(&mut self, _entry_point: String)

Set the entry path. The entry path is the path to reach the data into the document.

For example, in json, the entry path for {"field1":{"sub_field1":10}} will be /field1/sub_field1

Trait Implementations§

source§

impl Clone for Box<dyn Document>

source§

fn clone(&self) -> Box<dyn Document>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§