Struct tdo_core::tdo::Tdo
[−]
[src]
pub struct Tdo { pub lists: Vec<TodoList>, // some fields omitted }
Basic container structure for a set of todo lists.
This data structure acts as a conatiner for all todo lists and its associated todos.
The whole tdo
microcosm settles around this structure
which is also used for (de-)serialization.
When instanciated, it comes with an empty default list.
Fields
lists: Vec<TodoList>
A vector of all todo lists.
Methods
impl Tdo
[src]
fn new() -> Tdo
Create a new Tdo
container.
Each new container is instanciated with a default TodoList
.
Example
let tdo = Tdo::new();
fn load(path: &str) -> TdoResult<Tdo>
Load a saved Tdo
container from a JSON file.
This function returns a ResultType
which will yield the
deserialized JSON or a serde_json::Error
.
Example
let mut tdo = Tdo::load("foo.json");
fn save(&self, path: &str) -> TdoResult<()>
Dump the Tdo
container to a JSON file.
This function returns a ResultType
yielding a StorageError::SaveFailure
if the JSON file could not be opened/saved.
Example
let res = tdo.save("foo.json"); assert_eq!(res.unwrap(), ());
fn set_gh_token(&mut self, token: Option<&str>)
Sets the GitHub access token.
fn get_gh_token(&self) -> Option<String>
Returns an Option
fn add_list(&mut self, list: TodoList) -> TdoResult<()>
Add a todo list to the container.
fn remove_list(&mut self, list_name: &str) -> TdoResult<()>
Removes a list from the container.
fn add_todo(&mut self, list_name: Option<&str>, todo: Todo) -> TdoResult<()>
Add a todo to the todo list, identified by its name.
This function returns a ResultType
with a TodoError::NoSuchList
if there is no matching list found.
fn find_id(&self, id: u32) -> TdoResult<usize>
Cycle through all todo lists and find the list which contains the todo with the given ID
This function retuns a ResultType
with a TodoError::NotInList
if there is no list found or a usize with the postition of the list in lists.
fn done_id(&mut self, id: u32) -> TdoResult<()>
Cycle through all todo lists and mark a todo with the given ID as done. This function has no return value and thus won't indicate whether there was a matching todo found.
fn remove_id(&mut self, id: u32) -> TdoResult<()>
Cycle through all todo lists and remove a todo with the given id. This function has no return value and thus won't indicate whether there was a matching todo found.
fn clean_lists(&mut self)
Remove all todos that have been marked as done from all todo lists.
fn clean_list(&mut self, list: &str) -> TdoResult<()>
Remove all todos that have been marked as done from a given todo list.
fn get_highest_id(&self) -> u32
Get the highest ID used in the tdo container.
fn move_todo(&mut self, id: u32, target_list: &str) -> TdoResult<()>
Move a todo
between two lists.
Trait Implementations
impl Debug for Tdo
[src]
impl Clone for Tdo
[src]
fn clone(&self) -> Tdo
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more