Skip to main content

Identifiable

Trait Identifiable 

Source
pub trait Identifiable {
    type Key;

    const ID_COLUMN: &'static str;

    // Required method
    fn id(&self) -> Option<Self::Key>;
}
Expand description

Trait for entities that have an identifiable key. This trait exposes the key type and column name so macros can introspect it.

Required Associated Constants§

Source

const ID_COLUMN: &'static str

The name of the primary key column in the database.

Required Associated Types§

Source

type Key

The type of the primary key (e.g., i64, Uuid).

Required Methods§

Source

fn id(&self) -> Option<Self::Key>

Returns a copy of the entity’s ID, if it has one.

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§