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§
Sourcetype ForeignKey: Hash + Eq
type ForeignKey: Hash + Eq
The foreign key of this struct
Sourcetype ForeignKeyColumn: Column
type ForeignKeyColumn: Column
The database column representing the foreign key of the table this struct represents
Required Methods§
Sourcefn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for self
Sourcefn foreign_key_column() -> Self::ForeignKeyColumn
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", so this trait is not object safe.