doru/lib.rs
1//! # Doru
2//!
3//! Doru is a simple library providing basic `Todo` functionality. In its heart
4//! is a `TodoManager` that manages a vector of `Todo`s - any interaction with
5//! individual `Todo`s is handled by the Manager.
6//!
7//! Additionally, a `TodoStorage` trait defines the contract for loading and
8//! storing `Todo`s from/ to arbitrary text format. An example JSON storage
9//! implementing the trait is provided.
10//!
11//! In some cases, the operations can fail. The `TodoError` enum defines the
12//! possible errors.
13//!
14//! # Example
15//!
16//! ```
17//! use doru::todo::TodoStatus;
18//! use doru::todo_manager::TodoManager;
19//!
20//! let mut manager = TodoManager::default();
21//!
22//! let id = manager.add_todo("Learn Rust");
23//! manager
24//! .change_todo_status(id, TodoStatus::InProgress)
25//! .unwrap();
26//!
27//! let todos = manager.all_todos();
28//!
29//! for todo in &todos {
30//! println!("{:?}", todo);
31//! }
32//! ```
33
34pub mod storage;
35
36pub mod todo;
37
38pub mod todo_manager;
39
40use thiserror::Error;
41
42/// Possible errors that can occur while managing Todo items.
43#[derive(Error, Debug, PartialEq)]
44pub enum TodoError {
45 /// Error indicating that a Todo item with the specified ID was not found.
46 #[error("Todo with ID {0} not found!")]
47 NotFound(usize),
48}