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§
Provided Methods§
sourcefn estimate_csv_size(&self) -> usize
fn estimate_csv_size(&self) -> usize
Estimate the size of the resulting CSV output to avoid reallocations.
sourcefn to_csv_string(&self, delimiter: u8) -> Result<String, Box<dyn StdError>>
fn to_csv_string(&self, delimiter: u8) -> Result<String, Box<dyn StdError>>
Export model to CSV string.
sourcefn to_csv_file<P: AsRef<Path>>(
&self,
path: P,
delimiter: u8
) -> Result<(), Box<dyn StdError>>
fn to_csv_file<P: AsRef<Path>>(
&self,
path: P,
delimiter: u8
) -> Result<(), Box<dyn StdError>>
Export model to CSV output file.