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§
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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).
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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".