Skip to main content

ModelSerializer

Trait ModelSerializer 

Source
pub trait ModelSerializer: Serialize + Sized {
    type Model: Model;
    type Input;

    // Required method
    fn from_input(input: Self::Input) -> Self;

    // Provided methods
    fn to_json(input: Self::Input) -> Result<Value, Error> { ... }
    fn fields() -> &'static [SerializerField] { ... }
}
Expand description

Converts a materialized ORM model into an API representation.

Required Associated Types§

Required Methods§

Source

fn from_input(input: Self::Input) -> Self

Provided Methods§

Source

fn to_json(input: Self::Input) -> Result<Value, Error>

Source

fn fields() -> &'static [SerializerField]

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§