Skip to main content

BelongsTo

Trait BelongsTo 

Source
pub trait BelongsTo<Parent> {
    type ForeignKey: Hash + Eq;
    type ForeignKeyColumn: Column;

    // Required methods
    fn foreign_key(&self) -> Option<&Self::ForeignKey>;
    fn foreign_key_column() -> Self::ForeignKeyColumn;
}
Expand description

Indicates that a type belongs to Parent

Specifically, this means that this struct has fields which correspond to the primary key of Parent. This implies that a foreign key relationship exists on the tables.

This trait is not capable of supporting composite foreign keys

Required Associated Types§

Source

type ForeignKey: Hash + Eq

The foreign key of this struct

Source

type ForeignKeyColumn: Column

The database column representing the foreign key of the table this struct represents

Required Methods§

Source

fn foreign_key(&self) -> Option<&Self::ForeignKey>

Returns the foreign key for self

Source

fn foreign_key_column() -> Self::ForeignKeyColumn

Returns the foreign key column of this struct’s table

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§