Skip to main content

CmsAdminOverrides

Trait CmsAdminOverrides 

Source
pub trait CmsAdminOverrides: Send + Sync {
    // Provided methods
    fn read_only_fields<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
    ) -> Pin<Box<dyn Future<Output = Vec<&'static str>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn can_create<'life0, 'async_trait>(
        _pool: &'life0 Pool,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait { ... }
    fn can_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn validate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
    ) -> Pin<Box<dyn Future<Output = Vec<FieldError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn field_options<'life0, 'life1, 'async_trait>(
        _pool: &'life0 Pool,
        _field: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Option<Vec<(String, String)>>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn extra_widgets<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
    ) -> Pin<Box<dyn Future<Output = Vec<Widget>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn save_extra<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
        _form: &'life2 AdminForm,
    ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn after_save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _pool: &'life1 Pool,
        _created: bool,
    ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_delete<'life0, 'life1, 'async_trait>(
        &'life0 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 list_column<'life0, 'life1, 'life2, 'async_trait>(
        _pool: &'life0 Pool,
        _rows: &'life1 [Self],
        _column: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Option<Vec<String>>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Hooks for a model’s editor. Every method has a default, so impl CmsAdminOverrides for MyModel {} is enough to start.

Provided Methods§

Source

fn read_only_fields<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 Pool, ) -> Pin<Box<dyn Future<Output = Vec<&'static str>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fields shown but not editable on self. For a new record self is the blank row.

Source

fn can_create<'life0, 'async_trait>( _pool: &'life0 Pool, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Whether editors may add records. false hides “Add” and refuses the form.

Source

fn can_delete<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 Pool, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Whether editors may delete self.

Source

fn validate<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 Pool, ) -> Pin<Box<dyn Future<Output = Vec<FieldError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checks beyond “does each value parse”, run before saving. Return one FieldError per problem; any error stops the save and re-shows the form.

Source

fn field_options<'life0, 'life1, 'async_trait>( _pool: &'life0 Pool, _field: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<Vec<(String, String)>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Options for a Select, Radio, Checkboxes or MultiSelect field, as (value, label), replacing any declared in #[field(options(...))]. Use it for a foreign key: list the target table’s rows. None keeps the declared options.

Source

fn extra_widgets<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 Pool, ) -> Pin<Box<dyn Future<Output = Vec<Widget>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Widgets for data that is not a column of this struct, such as a many-to-many relation. They render after the #[field] widgets; Self::save_extra stores what they post.

Source

fn save_extra<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _pool: &'life1 Pool, _form: &'life2 AdminForm, ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store the values Self::extra_widgets posted. Runs after the record is saved, so self has its primary key.

Source

fn after_save<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 Pool, _created: bool, ) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs after every successful save; created is true for an add.

Source

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

Runs before the delete; an error cancels it. Remove dependent rows here.

Source

fn list_column<'life0, 'life1, 'life2, 'async_trait>( _pool: &'life0 Pool, _rows: &'life1 [Self], _column: &'life2 str, ) -> Pin<Box<dyn Future<Output = Option<Vec<String>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The cells of list column column for rows, one per row in order, overriding the field’s own value. Lets a column show something computed, such as a count from another table (one query for the page, not one per row), or name a column that is not a field at all. None keeps the default.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§