2022-08-05 23:11:44 +03:00
|
|
|
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 {
|
2022-08-16 15:43:44 +03:00
|
|
|
pub name: String,
|
|
|
|
pub link: Option<String>,
|
2022-08-16 16:36:53 +03:00
|
|
|
pub group: Option<String>,
|
2022-08-16 15:43:44 +03:00
|
|
|
pub index: Option<usize>,
|
2022-08-05 23:11:44 +03:00
|
|
|
}
|
|
|
|
|
2022-08-05 23:40:26 +03:00
|
|
|
pub struct UpdateTaskData {
|
2022-08-16 15:43:44 +03:00
|
|
|
pub name: Option<String>,
|
|
|
|
pub link: Option<Option<String>>,
|
2022-08-16 16:36:53 +03:00
|
|
|
pub group: Option<Option<String>>,
|
2022-08-05 23:40:26 +03:00
|
|
|
}
|
|
|
|
|
2022-08-05 23:11:44 +03:00
|
|
|
pub trait Repository {
|
2022-08-16 15:43:44 +03:00
|
|
|
fn get_current_task_opt(&self) -> Result<Option<domain::CurrentTaskInfo>, Error>;
|
|
|
|
|
|
|
|
fn get_task_opt(&self, id: domain::TaskId) -> Result<Option<domain::Task>, Error>;
|
|
|
|
|
2022-08-05 23:11:44 +03:00
|
|
|
fn get_tasks(&self) -> Result<Vec<domain::Task>, Error>;
|
|
|
|
|
2022-08-16 15:43:44 +03:00
|
|
|
fn remove_task(&self, id: domain::TaskId) -> Result<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>;
|
|
|
|
|
2022-08-05 23:11:44 +03:00
|
|
|
fn insert_task(&self, insert_data: InsertTaskData) -> Result<domain::Task, Error>;
|
2022-08-16 15:43:44 +03:00
|
|
|
|
|
|
|
fn start_task(&self, id: domain::TaskId) -> Result<domain::Task, Error>;
|
|
|
|
|
|
|
|
fn stop_task(&self) -> Result<domain::Task, Error>;
|
|
|
|
|
|
|
|
fn finish_task(&self) -> Result<domain::Task, Error>;
|
2022-08-05 23:11:44 +03:00
|
|
|
}
|