JsonIO

Trait JsonIO 

Source
pub trait JsonIO {
    // Required methods
    fn from_json(json: &str) -> Self;
    fn to_json(&self) -> String;
    fn read_json(path: &str) -> Self;
    fn write_json(&self, path: &str);
}
Expand description

A trait for reading and writing JSON files.

Required Methods§

Source

fn from_json(json: &str) -> Self

Create an instance of the type from a JSON string.

§Arguments
  • json - The JSON string to parse.
§Returns

An instance of the type.

Source

fn to_json(&self) -> String

Convert the instance to a JSON string.

§Returns

A JSON string representation of the instance.

Source

fn read_json(path: &str) -> Self

Create an instance of the type from a JSON file.

§Arguments
  • path - The path to the JSON file.
§Returns

An instance of the type.

Source

fn write_json(&self, path: &str)

Write the instance to a JSON file.

§Arguments
  • path - The path to the JSON 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§