AdminModel

Trait AdminModel 

Source
pub trait AdminModel:
    Any
    + Send
    + 'static {
    // Required methods
    fn get_objects<'life0, 'async_trait>(
        request: &'life0 Request,
        pagination: Pagination,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Self>>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;
    fn get_total_object_counts<'life0, 'async_trait>(
        request: &'life0 Request,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;
    fn get_object_by_id<'life0, 'life1, 'async_trait>(
        request: &'life0 Request,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self>>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn name() -> &'static str
       where Self: Sized;
    fn url_name() -> &'static str
       where Self: Sized;
    fn id(&self) -> String;
    fn display(&self) -> String;
    fn form_context() -> Box<dyn FormContext>
       where Self: Sized;
    fn form_context_from_self<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Box<dyn FormContext>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn save_from_request<'life0, 'life1, 'async_trait>(
        request: &'life0 mut Request,
        object_id: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn FormContext>>>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_by_id<'life0, 'life1, 'async_trait>(
        request: &'life0 mut Request,
        object_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A model that can be managed by the admin panel.

Required Methods§

Source

fn get_objects<'life0, 'async_trait>( request: &'life0 Request, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Vec<Self>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Get the objects of this model.

Source

fn get_total_object_counts<'life0, 'async_trait>( request: &'life0 Request, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Get the total count of objects of this model.

Source

fn get_object_by_id<'life0, 'life1, 'async_trait>( request: &'life0 Request, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Self>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the object with the given ID.

Source

fn name() -> &'static str
where Self: Sized,

Get the display name of this model.

Source

fn url_name() -> &'static str
where Self: Sized,

Get the URL slug for this model.

Source

fn id(&self) -> String

Get the ID of this model instance as a String.

Source

fn display(&self) -> String

Get the display text of this model instance.

Source

fn form_context() -> Box<dyn FormContext>
where Self: Sized,

Get the form context for this model.

Source

fn form_context_from_self<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Box<dyn FormContext>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the form context with the data pre-filled from this model instance.

Source

fn save_from_request<'life0, 'life1, 'async_trait>( request: &'life0 mut Request, object_id: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn FormContext>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save the model instance from the form data in the request.

§Errors

Returns an error if the object could not be saved, for instance due to a database error.

Source

fn remove_by_id<'life0, 'life1, 'async_trait>( request: &'life0 mut Request, object_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove the model instance with the given ID.

§Errors

Returns an error if the object with the given ID does not exist.

Returns an error if the object could not be removed, for instance due to a database error.

Implementors§

Source§

impl AdminModel for DatabaseUser

Available on crate feature db only.