Skip to main content

Model

Trait Model 

Source
pub trait Model:
    Register
    + Load<Output = Self>
    + Sized {
    type Query;
    type Create: Default + IntoInsert<Model = Self> + IntoExpr<Self>;
    type Update<'a>;
    type UpdateQuery;
    type Path<Origin>;

    // Required method
    fn new_path<Origin>(path: Path<Origin, Self>) -> Self::Path<Origin>;

    // Provided methods
    fn new_root_path() -> Self::Path<Self> { ... }
    fn new_create() -> Self::Create { ... }
}
Expand description

Trait for root models that map to database tables and can be queried.

Root models have primary keys, can be queried independently, and support full CRUD operations. They extend Register with queryability and deserialization capabilities.

Required Associated Types§

Source

type Query

Query builder type for this model

Source

type Create: Default + IntoInsert<Model = Self> + IntoExpr<Self>

Create builder type for this model

Source

type Update<'a>

Update builder type for this model

Source

type UpdateQuery

Update by query builder type for this model

Source

type Path<Origin>

A typed path from Origin into this model.

Required Methods§

Source

fn new_path<Origin>(path: Path<Origin, Self>) -> Self::Path<Origin>

Construct a model path from a Path targeting this model.

Provided Methods§

Source

fn new_root_path() -> Self::Path<Self>

Construct a path rooted at this model.

Source

fn new_create() -> Self::Create

Return a fresh, default-initialized create builder.

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§