Skip to main content

AdminResource

Trait AdminResource 

Source
pub trait AdminResource:
    Send
    + Sync
    + 'static {
Show 16 methods // Required methods fn name(&self) -> &str; fn plural_name(&self) -> &str; fn slug(&self) -> &str; fn list_columns(&self) -> Vec<Column>; fn form_fields(&self) -> Vec<FormField>; fn list<'life0, 'async_trait>( &'life0 self, query: ListQuery, ) -> Pin<Box<dyn Future<Output = Result<ListResult, AdminError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create<'life0, 'async_trait>( &'life0 self, data: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, data: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn icon(&self) -> &str { ... } fn searchable_fields(&self) -> Vec<&str> { ... } fn can_create(&self) -> bool { ... } fn can_delete(&self) -> bool { ... } fn validate<'life0, 'life1, 'async_trait>( &'life0 self, _data: &'life1 HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<(), HashMap<String, String>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn info(&self, prefix: &str) -> ResourceInfo { ... }
}
Expand description

Trait to be implemented by any resource that should be managed by the admin backoffice.

Required Methods§

Source

fn name(&self) -> &str

Display name of the resource.

Source

fn plural_name(&self) -> &str

Plural display name of the resource.

Source

fn slug(&self) -> &str

URL slug for the resource.

Source

fn list_columns(&self) -> Vec<Column>

Columns to show in the list view.

Source

fn form_fields(&self) -> Vec<FormField>

Fields to show in the create/edit form.

Source

fn list<'life0, 'async_trait>( &'life0 self, query: ListQuery, ) -> Pin<Box<dyn Future<Output = Result<ListResult, AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List records based on the provided query.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a single record by its ID.

Source

fn create<'life0, 'async_trait>( &'life0 self, data: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new record.

Source

fn update<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, data: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<Value, AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update an existing record.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a record.

Provided Methods§

Source

fn icon(&self) -> &str

Icon for the resource in the dashboard (default: “box”).

Source

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

Fields that should be used for the global search.

Source

fn can_create(&self) -> bool

Whether the resource can be created.

Source

fn can_delete(&self) -> bool

Whether the resource can be deleted.

Source

fn validate<'life0, 'life1, 'async_trait>( &'life0 self, _data: &'life1 HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<(), HashMap<String, String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Optional hook to validate data before saving.

Source

fn info(&self, prefix: &str) -> ResourceInfo

Return a serializable summary of the resource.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§