Skip to main content

CmsAdmin

Trait CmsAdmin 

Source
pub trait CmsAdmin:
    CmsAdminOverrides
    + Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn admin_meta() -> &'static CmsAdminMeta;
    fn admin_new() -> Self;
    fn admin_id(&self) -> Option<i64>;
    fn admin_title(&self) -> String;
    fn admin_cell(&self, field: &str) -> String;
    fn admin_widgets(&self) -> Vec<Widget>;
    fn admin_apply(
        &mut self,
        form: &AdminForm,
        skip: &[&str],
    ) -> Vec<FieldError>;
    fn admin_list<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool,
        search: &'life1 str,
        limit: i64,
        offset: i64,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<Self>, i64), ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn admin_get<'life0, 'async_trait>(
        pool: &'life0 Pool,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn admin_save<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        pool: &'life1 Pool,
    ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn admin_delete<'life0, 'async_trait>(
        self,
        pool: &'life0 Pool,
    ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

What #[derive(CmsAdmin)] implements. Host code rarely calls these directly; CmsAdminPage does.

Required Methods§

Source

fn admin_meta() -> &'static CmsAdminMeta

The editor’s static description.

Source

fn admin_new() -> Self

A blank record for the add form (Default::default()).

Source

fn admin_id(&self) -> Option<i64>

The primary key, once saved.

Source

fn admin_title(&self) -> String

How a record names itself in headings and messages.

Source

fn admin_cell(&self, field: &str) -> String

The text for list column field.

Source

fn admin_widgets(&self) -> Vec<Widget>

One widget per #[field], filled from self.

Source

fn admin_apply(&mut self, form: &AdminForm, skip: &[&str]) -> Vec<FieldError>

Copy the posted values into self, leaving the fields in skip alone. Returns a message for each value that does not parse and each required field left empty.

Source

fn admin_list<'life0, 'life1, 'async_trait>( pool: &'life0 Pool, search: &'life1 str, limit: i64, offset: i64, ) -> Pin<Box<dyn Future<Output = Result<(Vec<Self>, i64), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

One page of records matching search, and the total match count.

Source

fn admin_get<'life0, 'async_trait>( pool: &'life0 Pool, id: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The record with primary key id.

Source

fn admin_save<'life0, 'life1, 'async_trait>( &'life0 mut self, pool: &'life1 Pool, ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert or update.

Source

fn admin_delete<'life0, 'async_trait>( self, pool: &'life0 Pool, ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§