Skip to main content

Schema

Trait Schema 

Source
pub trait Schema {
    type Relationship: RelationshipDef;

    // Required methods
    fn name(&self) -> &str;
    fn relationships(&self) -> &[Self::Relationship];
    fn base_path(&self) -> &str;
}
Expand description

What serialization needs to know about one resource.

Three methods. Implement it on whatever already describes your resource — a marker struct, a config value, or a schema type you own.

Required Associated Types§

Required Methods§

Source

fn name(&self) -> &str

ResourceSchema::name → the JSON:API type.

Source

fn relationships(&self) -> &[Self::Relationship]

Every declared relationship.

Source

fn base_path(&self) -> &str

Where the resource is mounted, e.g. /api/v1/todos.

Used to build self and related links, so it should match the path the router actually serves.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Schema for Mounted<'_>

Available on crate feature domain only.