Skip to main content

RelationshipDef

Trait RelationshipDef 

Source
pub trait RelationshipDef {
    // Required methods
    fn name(&self) -> &str;
    fn target(&self) -> &str;
    fn is_to_many(&self) -> bool;
}
Expand description

One relationship your resource declares.

Only the arity matters to JSON:API: a to-one relationship serializes as a single linkage object, a to-many as an array. Whatever distinction your data layer draws beyond that — belongs-to versus has-one, join tables — is its business, not the wire format’s.

Rel is a ready-made implementation; write your own only if you already have a relationship type to borrow.

Required Methods§

Source

fn name(&self) -> &str

The member name — owner, comments.

Source

fn target(&self) -> &str

The JSON:API type on the far side: the related resource’s name.

Source

fn is_to_many(&self) -> bool

Whether the far side holds many resources.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl RelationshipDef for RelationshipSchema

Available on crate feature domain only.
Source§

fn name(&self) -> &str

Source§

fn target(&self) -> &str

Source§

fn is_to_many(&self) -> bool

Implementors§