//! Copyright (C) 2022, Dmitriy Pleshevskiy //! //! tas is free software: you can redistribute it and/or modify //! it under the terms of the GNU General Public License as published by //! the Free Software Foundation, either version 3 of the License, or //! (at your option) any later version. //! //! tas is distributed in the hope that it will be useful, //! but WITHOUT ANY WARRANTY; without even the implied warranty of //! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //! GNU General Public License for more details. //! //! You should have received a copy of the GNU General Public License //! along with tas. If not, see . //! pub mod fs; use std::path::PathBuf; 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 { pub name: String, pub project: Option, pub link: Option, pub dir_path: Option, pub index: Option, } pub struct UpdateTaskData { pub name: Option, pub project: Option>, pub link: Option>, pub dir_path: Option>, } pub trait Repository { fn get_current_task_opt(&self) -> Result, Error>; fn get_task_opt(&self, id: domain::TaskId) -> Result, Error>; fn get_tasks(&self) -> Result, Error>; fn remove_task(&self, id: domain::TaskId) -> Result; fn update_task( &self, id: domain::TaskId, update_data: UpdateTaskData, ) -> Result; fn insert_task(&self, insert_data: InsertTaskData) -> Result; fn start_task(&self, id: domain::TaskId) -> Result; fn stop_task(&self) -> Result; fn finish_task(&self) -> Result; }