tas/src/repo.rs

45 lines
983 B
Rust
Raw Normal View History

pub mod fs;
use crate::domain;
#[derive(Debug)]
pub enum Error {
NotFound,
InvalidData,
InsertData,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::NotFound => f.write_str("Cannot find data"),
Error::InvalidData => f.write_str("Invalid data format"),
Error::InsertData => f.write_str("Cannot insert data"),
}
}
}
impl std::error::Error for Error {}
pub struct InsertTaskData {
name: String,
link: Option<String>,
}
2022-08-05 23:40:26 +03:00
pub struct UpdateTaskData {
name: Option<String>,
link: Option<Option<String>>,
}
pub trait Repository {
fn get_tasks(&self) -> Result<Vec<domain::Task>, Error>;
2022-08-05 23:40:26 +03:00
fn update_task(
&self,
id: domain::TaskId,
update_data: UpdateTaskData,
) -> Result<domain::Task, Error>;
fn insert_task(&self, insert_data: InsertTaskData) -> Result<domain::Task, Error>;
}