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§
Sourcefn parse(json: &str) -> Result<Self>where
Self: Sized,
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.
Sourcefn parse_bytes(bytes: &[u8]) -> Result<Self>where
Self: Sized,
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.
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.