Skip to main content

TaskService

Struct TaskService 

Source
pub struct TaskService<'a> { /* private fields */ }
Expand description

Service for managing development tasks.

TaskService provides operations for creating, retrieving, updating, and archiving tasks. It handles task lifecycle management, ticket linking, and task switching.

Implementations§

Source§

impl<'a> TaskService<'a>

Source

pub fn new(db: &'a Database) -> Self

Creates a new TaskService instance.

§Arguments
  • db - Reference to the database connection
Source

pub fn create_task( &self, name: &str, description: Option<&str>, ticket_id: Option<&str>, ticket_url: Option<&str>, ) -> Result<Task>

Creates a new task and sets it as the current task.

§Arguments
  • name - Name of the task (cannot be empty)
  • description - Optional task description
  • ticket_id - Optional ticket ID (e.g., “PROJ-123” or “owner/repo/456”)
  • ticket_url - Optional URL to the ticket
§Errors

Returns an error if:

  • The task name is empty
  • The ticket ID format is invalid
  • A task with the same ticket ID already exists
Source

pub fn get_task(&self, task_id: i64) -> Result<Task>

Retrieves a task by its ID.

§Arguments
  • task_id - The ID of the task to retrieve
§Errors

Returns TrackError::TaskNotFound if the task does not exist.

Source

pub fn list_tasks(&self, include_archived: bool) -> Result<Vec<Task>>

Lists all tasks, optionally including archived tasks.

§Arguments
  • include_archived - If true, includes archived tasks in the results
§Returns

A vector of tasks ordered by creation date (newest first).

Source

pub fn switch_task(&self, task_id: i64) -> Result<Task>

Switches to a different task, making it the current active task.

§Arguments
  • task_id - The ID of the task to switch to
§Errors

Returns an error if:

  • The task does not exist
  • The task is archived
Source

pub fn archive_task(&self, task_id: i64) -> Result<()>

Archives a task, marking it as completed or abandoned.

If the archived task is the current task, the current task is cleared.

§Arguments
  • task_id - The ID of the task to archive

Links a ticket to an existing task.

§Arguments
  • task_id - The ID of the task to link the ticket to
  • ticket_id - The ticket ID (e.g., “PROJ-123” or “owner/repo/456”)
  • url - The URL to the ticket
§Errors

Returns an error if:

  • The ticket ID format is invalid
  • Another task is already linked to this ticket
Source

pub fn set_description(&self, task_id: i64, description: &str) -> Result<()>

Sets or updates the description of a task.

§Arguments
  • task_id - The ID of the task to update
  • description - The new description text
§Errors

Returns an error if:

  • The task does not exist
  • The task is archived
Source

pub fn resolve_task_id(&self, reference: &str) -> Result<i64>

Resolves a task reference to a task ID.

Accepts a numeric task ID, a ticket reference prefixed with “t:”, or an alias.

§Arguments
  • reference - Either a task ID (e.g., “1”), ticket reference (e.g., “t:PROJ-123”), or alias (e.g., “daily-work”)
§Returns

The resolved task ID.

§Errors

Returns an error if the reference is invalid or no matching task is found.

Source

pub fn set_alias(&self, task_id: i64, alias: &str, force: bool) -> Result<()>

Sets an alias for a task.

§Arguments
  • task_id - The ID of the task to set the alias for
  • alias - The alias to set (must be unique and valid)
  • force - If true, removes the alias from any existing task before setting it
§Errors

Returns an error if:

  • The alias format is invalid
  • The alias is already in use by another task (when force is false)
  • The task does not exist
Source

pub fn remove_alias(&self, task_id: i64) -> Result<()>

Removes the alias from a task.

§Arguments
  • task_id - The ID of the task to remove the alias from

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TaskService<'a>

§

impl<'a> !Send for TaskService<'a>

§

impl<'a> !Sync for TaskService<'a>

§

impl<'a> !UnwindSafe for TaskService<'a>

§

impl<'a> Freeze for TaskService<'a>

§

impl<'a> Unpin for TaskService<'a>

§

impl<'a> UnsafeUnpin for TaskService<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more