Model

Trait Model 

Source
pub trait Model {
    // Required methods
    fn parse(json: &str) -> Result<Self>
       where Self: Sized;
    fn parse_bytes(bytes: &[u8]) -> Result<Self>
       where Self: Sized;
    fn json(&self, ensure_ascii: bool) -> String;
    fn schema() -> String;
}
Expand description

A trait defines the format to handle a model.

This trait is efficiently handled data corresponding to an implemented struct.

Required Methods§

Source

fn parse(json: &str) -> Result<Self>
where Self: Sized,

Convert a JSON string to a struct that implemented this trait. If the JSON string is invalid, the return is Err. Also, if valid, the return is Ok that contains an instance.

Source

fn parse_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Convert bytes to a struct that implemented this trait. If the JSON string is invalid, the return is Err. Also, if valid, the return is Ok that contains an instance.

Source

fn json(&self, ensure_ascii: bool) -> String

Dump a JSON string from the instance.

Source

fn schema() -> String

Export a JSON Schema with a model.

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§