Skip to main content

JsonResource

Trait JsonResource 

Source
pub trait JsonResource {
    // Required method
    fn to_json(&self) -> Value;

    // Provided method
    fn to_response(&self) -> Response<Body> { ... }
}
Expand description

Trait untuk mentransformasi data menjadi format JSON API yang terstandarisasi.

Required Methods§

Source

fn to_json(&self) -> Value

Provided Methods§

Source

fn to_response(&self) -> Response<Body>

Membungkus hasil transformasi ke dalam object “data” (standar Laravel/JSON:API).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§