Skip to main content

RelationMeta

Trait RelationMeta 

Source
pub trait RelationMeta {
    type Owner: Model;
    type Target: Model;

    const NAME: &'static str;
    const KIND: RelationKind;
    const LOCAL_KEY: &'static str;
    const FOREIGN_KEY: &'static str;
}
Expand description

Each relation emitted by codegen materializes as a zero-sized type implementing this trait. Owner is the model declaring the relation; Target is the related model. LOCAL_KEY is the column on Owner that references Target (for BelongsTo); FOREIGN_KEY is the column on Target that references Owner’s PK (for HasMany / HasOne).

Required Associated Constants§

Source

const NAME: &'static str

Field name on Owner (also the string key of the matching super::IncludeSpec).

Source

const KIND: RelationKind

Classification of this relation (see RelationKind).

Source

const LOCAL_KEY: &'static str

Column on Owner that references Target (used for BelongsTo). For HasMany / HasOne this is conventionally "id".

Source

const FOREIGN_KEY: &'static str

Column on Target that references Owner’s PK (used for HasMany / HasOne). For BelongsTo this is conventionally "id".

Required Associated Types§

Source

type Owner: Model

The model declaring the relation.

Source

type Target: Model

The related model.

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.

Implementors§