Skip to main content

DataSource

Trait DataSource 

Source
pub trait DataSource: Send + Sync {
    // Required methods
    fn list<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
        query: &'life2 DataQuery,
    ) -> Pin<Box<dyn Future<Output = DataPage> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
        id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn count<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
        data: Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, AdminError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
        id: &'life2 str,
        data: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelDefinition,
        id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdminError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Pluggable backing store for admin models.

All methods take the ModelDefinition so a single implementation can serve every registered model.

Required Methods§

Source

fn list<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model: &'life1 ModelDefinition, query: &'life2 DataQuery, ) -> Pin<Box<dyn Future<Output = DataPage> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetch a page of rows for a list view.

§Note

A DataQuery::limit of 0 means “no limit / return all matching rows”, not “return zero rows”. Implementations MUST honor this: a SQL-backed source must omit the LIMIT clause when limit == 0 rather than translate it to LIMIT 0.

Source

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

Fetch a single record by primary-key value.

Source

fn count<'life0, 'life1, 'async_trait>( &'life0 self, model: &'life1 ModelDefinition, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Total number of records for a model (used by the dashboard summaries).

Source

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

Create a record, returning its primary-key value.

Source

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

Update an existing record.

Source

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

Delete a record.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§