Skip to main content

AdminUiModel

Trait AdminUiModel 

Source
pub trait AdminUiModel:
    Send
    + Sync
    + 'static {
    // Required methods
    fn slug(&self) -> &'static str;
    fn model_name(&self) -> &'static str;
    fn table_name(&self) -> &'static str;
    fn primary_key(&self) -> &'static str;
    fn fields(&self) -> Vec<AdminUiField>;
    fn searchable_fields(&self) -> Vec<&'static str>;
    fn primary_status_field(&self) -> Option<&'static str>;
    fn ensure_table_sql(&self) -> Option<&'static str>;
}
Expand description

A model that can describe its admin-UI shape (display name + table mapping + column list + searchable / sortable / filterable / status semantics).

Object-safe (&self methods + Send + Sync + 'static) so implementations can be stored as Box<dyn AdminUiModel> in AdminRegistry for dynamic-by-URL-slug dispatch.

Required Methods§

Source

fn slug(&self) -> &'static str

URL slug used as the :model path segment, e.g. "users"/admin/users. Must be unique within a registry.

Source

fn model_name(&self) -> &'static str

Human-readable display name shown in subtitles / banners, e.g. "User". Used in format!("{} · {} records", …).

Source

fn table_name(&self) -> &'static str

SQL table name. quote_ident is applied by the persistence layer, so callers can safely pass a static identifier.

Source

fn primary_key(&self) -> &'static str

Primary-key column name. Used by the persistence layer for WHERE pk = ? lookups and by the form engine to skip the PK from auto-generated INSERT / UPDATE column maps.

Source

fn fields(&self) -> Vec<AdminUiField>

Source

fn searchable_fields(&self) -> Vec<&'static str>

Field names participating in free-text search (?q=…). Persistence emits a single OR-clause across these columns with LOWER(col) LIKE ?.

Source

fn primary_status_field(&self) -> Option<&'static str>

Boolean column the bulk Activate/Deactivate actions flip (typically is_active). None disables those bulk actions for the model — Delete still works since it doesn’t depend on a status column.

Source

fn ensure_table_sql(&self) -> Option<&'static str>

Optional CREATE TABLE IF NOT EXISTS … statement run on every request. Returning None skips auto-creation (caller is responsible for migrations). Idempotent SQL is required.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§