Skip to main content

Model

Trait Model 

Source
pub trait Model: ModelHooks {
    type Pk: PrimaryKey;

    // Required methods
    fn table_name() -> &'static str;
    fn schema() -> TableSchema;
}
Expand description

Core trait implemented by #[derive(Model)]. Every model must be able to describe its own schema. ModelHooks is a supertrait: the derive emits an empty impl unless #[model(hooks)] is set.

Required Associated Types§

Source

type Pk: PrimaryKey

The Rust type of the primary key value (Uuid, i32, i64). ForeignKey<Self> and ManyToMany<Self> columns follow it.

Required Methods§

Source

fn table_name() -> &'static str

The table name in the database.

Source

fn schema() -> TableSchema

The full schema description for this model.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§