DataFormat

Trait DataFormat 

Source
pub trait DataFormat {
    // Required methods
    fn read_from<T: Data, R: Read + BufRead>(rdr: R) -> Result<T>;
    fn write_to<T: Serialize, W: Write>(data: &T, wtr: W) -> Result<()>;

    // Provided methods
    fn read_from_file<T: Data>(path: &Path) -> Result<T> { ... }
    fn write_to_file<T: Serialize>(data: &T, path: &Path) -> Result<()> { ... }
}
Expand description

Data format to read and load data from a file

Required Methods§

Source

fn read_from<T: Data, R: Read + BufRead>(rdr: R) -> Result<T>

Read data from a reader

Source

fn write_to<T: Serialize, W: Write>(data: &T, wtr: W) -> Result<()>

Write data to a writer

Provided Methods§

Source

fn read_from_file<T: Data>(path: &Path) -> Result<T>

Read data from a file

Source

fn write_to_file<T: Serialize>(data: &T, path: &Path) -> Result<()>

Write data to a file

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§