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§
Provided Methods§
fn metadata(&self) -> Metadata
sourcefn can_append(&self) -> bool
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
sourcefn header(&self, _dataset: &DataSet) -> Result<Vec<u8>>
fn header(&self, _dataset: &DataSet) -> Result<Vec<u8>>
Return the header data used to identify when the data start |––––|——|––––| document => | header | data | footer | |––––|——|––––|
Return the footer data used to identify when the data end |––––|——|––––| document => | header | data | footer | |––––|——|––––|
sourcefn terminator(&self) -> Result<Vec<u8>>
fn terminator(&self) -> Result<Vec<u8>>
Return the terminator to seperate lines of data
sourcefn set_entry_path(&mut self, _entry_point: String)
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