como/como_core/src/items/mod.rs

30 lines
710 B
Rust
Raw Normal View History

2022-10-03 23:00:31 +02:00
use std::sync::Arc;
use async_trait::async_trait;
use como_domain::{
item::{
queries::{GetItemQuery, GetItemsQuery},
requests::CreateItemDto,
responses::CreatedItemDto,
ItemDto,
},
Context,
2022-10-04 22:39:57 +02:00
};
2022-10-03 23:00:31 +02:00
pub type DynItemService = Arc<dyn ItemService + Send + Sync>;
#[async_trait]
2022-10-04 11:06:48 +02:00
pub trait ItemService {
async fn add_item(
&self,
context: &Context,
item: CreateItemDto,
) -> anyhow::Result<CreatedItemDto>;
async fn get_item(&self, context: &Context, query: GetItemQuery) -> anyhow::Result<ItemDto>;
async fn get_items(
&self,
context: &Context,
query: GetItemsQuery,
) -> anyhow::Result<Vec<ItemDto>>;
2022-10-04 11:06:48 +02:00
}