pub trait PrimaryKey {
type PrimaryKey: OwnedKeyType;
// Required method
fn primary_key(&self) -> Self::PrimaryKey;
}Expand description
Something which has a distinct primary key which can uniquely identify it.
Required Associated Types§
Sourcetype PrimaryKey: OwnedKeyType
type PrimaryKey: OwnedKeyType
Each distinct PrimaryKey uniquely identifies either 0 or 1 instance.
This constraint should be enforced at the DB level.
Required Methods§
Sourcefn primary_key(&self) -> Self::PrimaryKey
fn primary_key(&self) -> Self::PrimaryKey
Get this entity’s primary key.
This must return an owned type, because there are some entities for which only owned primary keys are possible.
However, entities which have primary keys owned within the entity itself should consider also implementing
BorrowPrimaryKey for greater efficiency.