kanban-core 0.3.1

Core traits, errors, and result types for the kanban project management tool
Documentation
use crate::KanbanResult;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};

#[async_trait]
pub trait Repository<T, Id> {
    async fn find_by_id(&self, id: Id) -> KanbanResult<Option<T>>;
    async fn find_all(&self) -> KanbanResult<Vec<T>>;
    async fn save(&self, entity: &T) -> KanbanResult<T>;
    async fn delete(&self, id: Id) -> KanbanResult<()>;
}

#[async_trait]
pub trait Service<T, Id> {
    async fn get(&self, id: Id) -> KanbanResult<T>;
    async fn list(&self) -> KanbanResult<Vec<T>>;
    async fn create(&self, entity: T) -> KanbanResult<T>;
    async fn update(&self, id: Id, entity: T) -> KanbanResult<T>;
    async fn delete(&self, id: Id) -> KanbanResult<()>;
}

pub trait Editable<T>: Serialize + for<'de> Deserialize<'de> + Sized {
    fn from_entity(entity: &T) -> Self;
    fn apply_to(self, entity: &mut T);
}