MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / read_task_by_id

Function read_task_by_id

src/context/task_storage.rs:115–129  ·  view source on GitHub ↗

Read a single task by ID from the database, returning an error if not found.

(
    conn: &Connection,
    id: &str,
)

Source from the content-addressed store, hash-verified

113
114/// Read a single task by ID from the database, returning an error if not found.
115fn read_task_by_id(
116 conn: &Connection,
117 id: &str,
118) -> Result<Task, Box<dyn std::error::Error + Send + Sync>> {
119 let mut stmt = conn.prepare("SELECT * FROM tasks WHERE id = ?1")?;
120 let task = stmt
121 .query_row(rusqlite::params![id], row_to_task)
122 .map_err(|e| match e {
123 rusqlite::Error::QueryReturnedNoRows => {
124 Box::<dyn std::error::Error + Send + Sync>::from("Task not found")
125 }
126 other => Box::<dyn std::error::Error + Send + Sync>::from(other),
127 })?;
128 Ok(task)
129}
130
131fn insert_task(
132 conn: &Connection,

Callers 6

mark_runningMethod · 0.85
mark_completeMethod · 0.85
mark_failedMethod · 0.85
mark_cancelledMethod · 0.85
reset_to_queuedMethod · 0.85
prepare_child_taskMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected