miniweb/src/admin_examples/file_repository.rs

65 lines
1.5 KiB
Rust

use crate::admin::domain::*;
use async_trait::async_trait;
use serde_json::Value;
struct Repository {}
impl Repository {}
#[async_trait]
impl AdminRepository for Repository {
async fn info(&self, _: &RepositoryContext) -> RepositoryInfo {
RepoInfo {
name: "My Empty Repository",
lookup_key: "id",
display_list: &["id"],
fields: &[],
}
.into()
}
// GET on item collection.
async fn list(&self, model: &RepositoryContext) -> RepositoryList {
RepositoryList::Empty
}
// POST on item collection.
async fn create(
&mut self,
model: &RepositoryContext,
mut data: Value,
) -> Option<RepositoryItem> {
None
}
// GET single item.
async fn get(&self, model: &RepositoryContext, id: LookupKey) -> Option<RepositoryItem> {
None
}
// PATCH single item.
async fn update(
&mut self,
model: &RepositoryContext,
id: LookupKey,
data: Value,
) -> Option<RepositoryItem> {
None
}
// PUT single item.
async fn replace(
&mut self,
model: &RepositoryContext,
id: LookupKey,
data: Value,
) -> Option<RepositoryItem> {
None
}
// DELETE single item.
async fn delete(&mut self, _: &RepositoryContext, id: LookupKey) -> Option<Value> {
None
}
}