Trait bdb::traits::Csv

source ·
pub trait Csv: Sized {
    fn to_csv<T: Write>(
        &self,
        writer: &mut T,
        delimiter: u8
    ) -> Result<(), Box<dyn StdError>>; fn from_csv<T: Read>(
        reader: &mut T,
        delimiter: u8
    ) -> Result<Self, Box<dyn StdError>>; fn estimate_csv_size(&self) -> usize { ... } fn to_csv_string(&self, delimiter: u8) -> Result<String, Box<dyn StdError>> { ... } fn to_csv_file<P: AsRef<Path>>(
        &self,
        path: P,
        delimiter: u8
    ) -> Result<(), Box<dyn StdError>> { ... } fn from_csv_string(
        text: &str,
        delimiter: u8
    ) -> Result<Self, Box<dyn StdError>> { ... } fn from_csv_file<P: AsRef<Path>>(
        path: P,
        delimiter: u8
    ) -> Result<Self, Box<dyn StdError>> { ... } }
Expand description

Serialize to and from CSV.

The underlying CSV readers and writers (rust-csv) are buffered, so do not wrap out readers and writers in BufReader and BufWriter, respectively.

Required Methods§

Export model to CSV (with headers).

Import model from CSV (with headers).

Works identically to a collection importer, only fetches at max 1 record, since the headers are shared over all records.

Provided Methods§

Estimate the size of the resulting CSV output to avoid reallocations.

Export model to CSV string.

Export model to CSV output file.

Import model from CSV string.

Import model from CSV file.

Implementors§