Skip to main content

Services

Struct Services 

Source
pub struct Services<'a, St> {
    pub store: &'a St,
    pub links: &'a dyn LinkRepository,
    pub collections: &'a dyn CollectionRepository,
    pub query: &'a dyn QueryEngine,
    pub clock: &'a dyn Clock,
    pub ids: &'a dyn IdGenerator,
    pub blobs: &'a dyn BlobStore,
}

Fields§

§store: &'a St§links: &'a dyn LinkRepository§collections: &'a dyn CollectionRepository§query: &'a dyn QueryEngine§clock: &'a dyn Clock§ids: &'a dyn IdGenerator§blobs: &'a dyn BlobStore

Implementations§

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn aggregate(&self, id: &Id) -> Result<Aggregate, Error>

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn import_superproductivity( &self, json: &str, ) -> Result<Vec<TaskSnapshot>, Error>

Import a Super Productivity JSON backup. Returns the created project root tasks (one per SP project, per user decision — not a tag).

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn export(&self, root: &Id) -> Result<Export, Error>

Collect root + its descendant subtree (tasks and the edges among them).

Source

pub async fn export_json(&self, root: &Id) -> Result<String, Error>

Source

pub async fn import_json(&self, json: &str) -> Result<(), Error>

FR-17: ingest an Export (round-trips with Self::export).

Source

pub async fn export_md(&self, root: &Id) -> Result<String, Error>

FR-16: Markdown task list of a branch (DFS over child, position order). Iterative DFS (explicit stack) to avoid boxing an async recursion.

Source

pub async fn import_md(&self, md: &str) -> Result<Vec<TaskSnapshot>, Error>

FR-17: parse a Markdown task list into a tree (indent = depth). Status comes from the checkbox ([x] → done, else todo). Returns the roots.

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn evaluate(&self, q: &Query) -> Vec<QueryHit>

Source

pub async fn what_next(&self) -> Vec<QueryHit>

what-next: status:todo by priority.

Source

pub async fn what_next_for( &self, assignee: Option<Id>, within: Option<Id>, tag: Option<String>, ) -> Vec<QueryHit>

what-next-for: status:todo optionally scoped by assignee/subtree/tag.

Source

pub async fn due_today(&self) -> Vec<QueryHit>

due-today: due:today, sorted by due then priority.

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn resolve_id(&self, typed: &str) -> Result<Id, Error>

Resolve a user-typed id or short prefix (git/jj-style abbreviation, spec-independent — see todoapp_core::resolve_id_prefix) against every id currently in the store. The CLI/TUI entry point for letting a human type a short id instead of the full ULID.

Source

pub async fn snapshot(&self, id: &Id) -> Result<TaskSnapshot, Error>

Assemble a read-only TaskSnapshot from the task’s components.

Source

pub async fn children_of(&self, parent: &Id) -> Vec<Link>

Child links out of parent, ordered by position.

Source

pub async fn parent_of(&self, child: &Id) -> Option<Id>

The structural parent of child, if any (single-parent tree). The virtual-root sentinel maps to None — a root has no visible parent.

Source

pub async fn roots(&self) -> Vec<Id>

Top-level tasks: the invisible root’s children, ordered by position (spec §7). Port-level via outgoing(ROOT, Child) — indexed in Turso, no whole-store scan.

Source

pub async fn is_blocked(&self, id: &Id) -> bool

Derived blocked (spec §8): some incoming blocks edge whose blocker task is not done.

Source

pub async fn descendants(&self, id: &Id) -> HashSet<Id>

All descendants of id via child links (excludes id).

Source

pub async fn run(&self, id: &Id, cmd: Command) -> Result<TaskSnapshot, Error>

Run a task-local command through decide → apply → persist (spec §5a), capability-keyed: decide/apply read and write components via the store.

Source§

impl<'a, St: ComponentStore + TaskEntityStore> Services<'a, St>

Source

pub async fn create( &self, title: impl Into<String>, parent: Option<&Id>, status: Status, tags: impl IntoIterator<Item = String>, ) -> Result<TaskSnapshot, Error>

FR-1/FR-2: create one task, optionally under parent (appended last).

Source

pub async fn batch_create(&self, text: &str) -> Result<Vec<TaskSnapshot>, Error>

FR-1: batch-create from text, indentation (2 spaces or a tab) = depth (spec §13 Q7 default). Returns tasks in document order.

Source

pub async fn set_title( &self, id: &Id, title: impl Into<String>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_notes( &self, id: &Id, notes: Option<String>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_status( &self, id: &Id, status: Status, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_due( &self, id: &Id, due: Option<Due>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_estimate( &self, id: &Id, estimate: Option<Duration>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn add_time_spent( &self, id: &Id, spent: Duration, ) -> Result<TaskSnapshot, Error>

Source

pub async fn add_tag( &self, id: &Id, tag: impl Into<String>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn remove_tag( &self, id: &Id, tag: impl Into<String>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn assign(&self, id: &Id, actor: Id) -> Result<TaskSnapshot, Error>

Source

pub async fn unassign(&self, id: &Id, actor: Id) -> Result<TaskSnapshot, Error>

Source

pub async fn claim(&self, id: &Id, actor: Id) -> Result<TaskSnapshot, Error>

FR-11: claim a todo task (open if unassigned, else assignee-only).

Source

pub async fn set_recurrence( &self, id: &Id, recurrence: Option<Recurrence>, ) -> Result<TaskSnapshot, Error>

A recurring task resets in place on completion instead of staying done (see Event::StatusSet(Status::Done)’s apply arm).

Source

pub async fn set_issue_ref( &self, id: &Id, issue_ref: Option<IssueRef>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_time_log( &self, id: &Id, time_log: BTreeMap<Date, Duration>, ) -> Result<TaskSnapshot, Error>

Source

pub async fn set_archived( &self, id: &Id, archived: bool, ) -> Result<TaskSnapshot, Error>

Source

pub async fn add_attachment_from_bytes( &self, id: &Id, title: impl Into<String>, bytes: Vec<u8>, mime: Option<String>, ) -> Result<TaskSnapshot, Error>

Attach a file’s actual bytes (stored via BlobStore) to a task.

Attach a bare link (no stored bytes) to a task.

Source

pub async fn remove_attachment( &self, id: &Id, attachment_id: Id, ) -> Result<TaskSnapshot, Error>

Source

pub async fn move_task( &self, id: &Id, parent: &Id, anchor: Option<Anchor>, ) -> Result<(), Error>

Re-point id’s single child parent to parent at anchor (FR-8). Rejects a move under the task’s own subtree (cycle).

Source

pub async fn reorder(&self, id: &Id, anchor: Anchor) -> Result<(), Error>

Reorder id among its existing siblings (FR-7).

Source

pub async fn block(&self, blocker: &Id, blocked: &Id) -> Result<(), Error>

FR-6: add a blocks edge blocker → blocked; rejects a new cycle.

Auto Trait Implementations§

§

impl<'a, St> !RefUnwindSafe for Services<'a, St>

§

impl<'a, St> !Send for Services<'a, St>

§

impl<'a, St> !Sync for Services<'a, St>

§

impl<'a, St> !UnwindSafe for Services<'a, St>

§

impl<'a, St> Freeze for Services<'a, St>

§

impl<'a, St> Unpin for Services<'a, St>

§

impl<'a, St> UnsafeUnpin for Services<'a, St>

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<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.