Skip to main content

AdminModel

Trait AdminModel 

Source
pub trait AdminModel:
    Send
    + Sync
    + 'static {
    const ADMIN_NAME: &'static str;
    const DISPLAY_NAME: &'static str;
    const SINGULAR_NAME: &'static str;
    const FIELDS: &'static [AdminField];

    // Required methods
    fn display_values(&self) -> Vec<(String, String)>;
    fn from_form(form: &FormData) -> Result<Self, Vec<String>>
       where Self: Sized;
    fn object_label(&self) -> String;
    fn id(&self) -> i64;
    fn values_to_update(&self) -> Vec<(&'static str, Value)>;
}
Expand description

What the #[derive(RustioAdmin)] macro produces for each struct.

Required Associated Constants§

Source

const ADMIN_NAME: &'static str

Source

const DISPLAY_NAME: &'static str

Source

const SINGULAR_NAME: &'static str

Source

const FIELDS: &'static [AdminField]

Required Methods§

Source

fn display_values(&self) -> Vec<(String, String)>

Render one row for the list page (column → display string).

Source

fn from_form(form: &FormData) -> Result<Self, Vec<String>>
where Self: Sized,

Populate a new instance from an HTTP form. Returns a list of validation errors if anything was wrong.

Source

fn object_label(&self) -> String

A stable label for one instance (used on the delete confirm page).

Source

fn id(&self) -> i64

Source

fn values_to_update(&self) -> Vec<(&'static str, Value)>

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§