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§
Sourcefn plural_name(&self) -> &str
fn plural_name(&self) -> &str
Plural display name of the resource.
Sourcefn list_columns(&self) -> Vec<Column>
fn list_columns(&self) -> Vec<Column>
Columns to show in the list view.
Sourcefn form_fields(&self) -> Vec<FormField>
fn form_fields(&self) -> Vec<FormField>
Fields to show in the create/edit form.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Provided Methods§
Sourcefn searchable_fields(&self) -> Vec<&str>
fn searchable_fields(&self) -> Vec<&str>
Fields that should be used for the global search.
Sourcefn can_create(&self) -> bool
fn can_create(&self) -> bool
Whether the resource can be created.
Sourcefn can_delete(&self) -> bool
fn can_delete(&self) -> bool
Whether the resource can be deleted.
Sourcefn 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 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.
Sourcefn info(&self, prefix: &str) -> ResourceInfo
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".