task

Per-entity sync adapter for tasks and their notes.

struct TaskFile

source

struct TaskFile

On-disk wrapper for .gest/task/<id>.yaml.

Field Type Description
deleted_at Option<DateTime<Utc>> When the task was deleted; a set value makes the file a tombstone, and import deletes the row.
id Id The task’s id, which also names the file.
title String The task’s title.
status String The task’s status, as the text stored in the status column.
priority Option<u8> The task’s priority number, if it has one.
assigned_to Option<Id> The id of the author the task is assigned to, if any.
description String The task’s description; left out of the file when empty.
tags Vec<String> The labels of the task’s tags; left out of the file when empty.
metadata Value The task’s JSON metadata; left out of the file when null.
created_at DateTime<Utc> When the task was created.
updated_at DateTime<Utc> When the task was last changed.
resolved_at Option<DateTime<Utc>> When the task reached a terminal status, or None while it is not done or cancelled.

Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.

struct TaskNoteFile

source

struct TaskNoteFile

On-disk wrapper for .gest/task/notes/<note_id>.yaml.

Field Type Description
deleted_at Option<DateTime<Utc>> When the note was deleted; a set value makes the file a tombstone, and import deletes the row.
id Id The note’s id, which also names the file.
entity_id Id The id of the task that the note belongs to.
author_id Option<Id> The author who wrote the note, if one is recorded.
body String The note’s text.
created_at DateTime<Utc> When the note was created.
updated_at DateTime<Utc> When the note was last changed.

Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.

fn read_all

source

pub async fn read_all(conn: &Connection, project_id: &Id, gest_dir: &Path) -> Result<(), Error>

Import every task/*.yaml (and task/notes/*.yaml) file into SQLite.

A tombstoned file deletes its row; any other file inserts or updates its row. A task’s tags are replaced by the labels in its file.

Parameter Type Description
conn &Connection the database connection
project_id &Id the project that imported tasks belong to
gest_dir &Path the project’s .gest/ directory
returns Result<(), Error> Ok(()) when every file is imported, or an error when a file cannot be read or parsed or a query fails.

fn write_all

source

pub async fn write_all(conn: &Connection, project_id: &Id, gest_dir: &Path) -> Result<(), Error>

Export every task and task note row to per-entity files.

Afterwards it removes the files of tasks and notes that are no longer in the database, and their digests. Tombstoned task and note files stay, because clones read them as the delete signal.

Parameter Type Description
conn &Connection the database connection
project_id &Id the project whose tasks to export
gest_dir &Path the project’s .gest/ directory
returns Result<(), Error> Ok(()) when every row is written, or an error when a query, an id, a timestamp or a file write fails.

fn load_task_tag_labels

source

async fn load_task_tag_labels(conn: &Connection, task_id: &Id) -> Result<Vec<String>, Error>

Read the labels of the tags attached to a task.

Parameter Type Description
conn &Connection the database connection
task_id &Id the task whose tags to read
returns Result<Vec<String>, Error> The labels in alphabetical order, or an error when the query fails.

fn parse_dt

source

fn parse_dt(s: &str) -> Result<DateTime<Utc>, Error>

Parse an RFC 3339 timestamp from the database into UTC.

Parameter Type Description
s &str the timestamp text
returns Result<DateTime<Utc>, Error> The time in UTC, or an Error::Io that holds the parse error.

fn sync_task_tags

source

async fn sync_task_tags(conn: &Connection, file: &TaskFile) -> Result<(), Error>

Replace a task’s tags with the labels in its file.

A label with no tag row gets a new tag.

Parameter Type Description
conn &Connection the database connection
file &TaskFile the task file that holds the task’s id and tag labels
returns Result<(), Error> Ok(()) when the tags are stored, or an error when a query fails.

fn upsert_note

source

async fn upsert_note(conn: &Connection, file: &TaskNoteFile) -> Result<(), Error>

Insert a task note row from its file, or update the body and updated_at of the row that has its id.

Parameter Type Description
conn &Connection the database connection
file &TaskNoteFile the parsed note file
returns Result<(), Error> Ok(()) when the row is written, or an error when the query fails.

fn upsert_task

source

async fn upsert_task(conn: &Connection, project_id: &Id, file: &TaskFile) -> Result<(), Error>

Insert a task row from its file, or update the row that has its id.

An update changes every column from the file except the project and created_at.

Parameter Type Description
conn &Connection the database connection
project_id &Id the project that a new row belongs to
file &TaskFile the parsed task file
returns Result<(), Error> Ok(()) when the row is written, or an error when the query fails.