Skip to main content

ModelColumns

Trait ModelColumns 

Source
pub trait ModelColumns:
    Model
    + IntoExpr<Self>
    + Sized {
    const TENANT_COLUMNS: &'static [&'static str];

    // Provided methods
    fn table() -> Table<Self> { ... }
    fn detail() -> Detail<Self> { ... }
    fn version(&self) -> Option<u64> { ... }
}
Expand description

The table and detail page a model reads as when its resource declares none: what a ResourceDef without a table lists and without a detail shows.

Derive it with ModelColumns, which gives a column to each field a person reads, whether a form or Toasty writes it. An impl by hand names the model’s tenant columns; one that keeps the defaults here lists no column and turns the detail page off, for a resource that declares both.

Required Associated Constants§

Source

const TENANT_COLUMNS: &'static [&'static str]

The model’s TenantId fields, by name: the derive lists each field typed TenantId or Option<TenantId>. Mounting a panel refuses a resource over a model that lists one and declares no tenancy, which would serve every tenant’s rows. It has no default, so an impl by hand states it.

Provided Methods§

Source

fn table() -> Table<Self>

The default table, which lists no column here.

Source

fn detail() -> Detail<Self>

The default detail page, which is off here.

Source

fn version(&self) -> Option<u64>

The record’s #[version] counter, or None for a model without one.

The edit form carries it, so a save refuses a record another save changed since the form opened. The derive reads the model’s #[version] field; an impl written by hand keeps this default unless it returns the counter itself.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl ModelColumns for AdminUser

Source§

const TENANT_COLUMNS: &'static [&'static str]