pub struct TaskList { /* private fields */ }Expand description
Manages a list of tasks for the ephemeral task manager
This structure provides methods for adding, starting, completing, and listing tasks. Tasks follow a state machine that transitions from Pending through InProgress to Completed.
Implementations§
Source§impl TaskList
impl TaskList
Sourcepub fn append_task(&mut self, description: String) -> Task
pub fn append_task(&mut self, description: String) -> Task
Appends a new task to the end of the list
Returns the newly created task with Pending status
Sourcepub fn prepend_task(&mut self, description: String) -> Task
pub fn prepend_task(&mut self, description: String) -> Task
Prepends a new task to the beginning of the list
Returns the newly created task with Pending status
Sourcepub fn insert_task_after(
&mut self,
existing_task_id: usize,
description: String,
) -> Result<Task>
pub fn insert_task_after( &mut self, existing_task_id: usize, description: String, ) -> Result<Task>
Inserts a new task after an existing task with the given ID
Returns the newly created task or an error if the existing task is not found
Sourcepub fn start_task(&mut self, task_id: usize) -> Result<Task>
pub fn start_task(&mut self, task_id: usize) -> Result<Task>
Starts a task by changing its status from Pending to InProgress
Returns an error if the task is not found or not in Pending status
Sourcepub fn complete_task(&mut self, task_id: usize) -> Result<Task>
pub fn complete_task(&mut self, task_id: usize) -> Result<Task>
Completes a task by changing its status from InProgress to Completed
Returns an error if the task is not found or not in InProgress status
Sourcepub fn list_tasks(&self) -> Vec<Task>
pub fn list_tasks(&self) -> Vec<Task>
Returns all tasks in the list
Sourcepub fn clear_tasks(&mut self) -> usize
pub fn clear_tasks(&mut self) -> usize
Clears all tasks from the list
Returns the number of tasks that were cleared