pub struct TodoState {
pub items: Vec<TodoItem>,
/* private fields */
}Expand description
Shared TODO state that can be persisted.
Fields§
§items: Vec<TodoItem>The list of TODO items.
Implementations§
Source§impl TodoState
impl TodoState
Sourcepub const fn with_storage(path: PathBuf) -> Self
pub const fn with_storage(path: PathBuf) -> Self
Creates a new TODO state with persistence.
Sourcepub fn set_storage_path(&mut self, path: PathBuf)
pub fn set_storage_path(&mut self, path: PathBuf)
Sets the storage path for persistence.
Sourcepub fn load(&mut self) -> Result<()>
pub fn load(&mut self) -> Result<()>
Loads todos from storage if path is set.
§Errors
Returns an error if the file cannot be read or parsed.
Sourcepub fn count_by_status(&self) -> (usize, usize, usize)
pub fn count_by_status(&self) -> (usize, usize, usize)
Returns the count of items by status.
Sourcepub fn current_task(&self) -> Option<&TodoItem>
pub fn current_task(&self) -> Option<&TodoItem>
Returns the currently in-progress item, if any.
Sourcepub fn format_display(&self) -> String
pub fn format_display(&self) -> String
Formats the TODO list for display.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TodoState
impl RefUnwindSafe for TodoState
impl Send for TodoState
impl Sync for TodoState
impl Unpin for TodoState
impl UnwindSafe for TodoState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more