transition
Concrete commands (e.g. task cancel, iteration complete) resolve an
entity ID and delegate here. The generic absorbs the six repeated steps:
resolve → load before-snapshot → begin transaction → patch → record event
→ emit envelope. Entity-specific details are provided through the
HasStatus trait.
trait HasStatus
pub trait HasStatus: Findable + HasMetadata + PrefixableAn entity whose lifecycle is tracked by a status enum that can be patched
atomically via HasMetadata::update.
Implemented for Iteration, Task.
type HasStatus::Status
type Status: Copy + Display + Send;The lifecycle status enum (e.g. TaskStatus, IterationStatus).
HasStatus::status
fn status(model: &Self::Model) -> Self::Status;Read the current status off the domain model.
| Parameter | Type | Description |
|---|---|---|
model |
&Self::Model | the entity to read |
| returns | Self::Status | The entity’s status. |
HasStatus::status_patch
fn status_patch(status: Self::Status) -> Self::Patch;Produce a patch that sets only the status field to status.
| Parameter | Type | Description |
|---|---|---|
status |
Self::Status | the new status |
| returns | Self::Patch | A patch with every other field left unset. |
HasStatus::title
fn title(model: &Self::Model) -> &str;Read the human-readable title off the domain model, used by success messages.
| Parameter | Type | Description |
|---|---|---|
model |
&Self::Model | the entity to read |
| returns | &str | The entity’s title. |
fn transition_status
pub async fn transition_status<E: HasStatus>(
context: &AppContext,
raw_id: &str,
new_status: <E as >::Status,
action: &str,
semantic_type: &str,
success_label: &str,
output: &json::Flags,
) -> Result<(), Error>Transition raw_id to new_status inside a recorded transaction.
Returns after printing either a JSON envelope or a SuccessMessage
(based on output). action is the transaction description
(e.g. "task cancel"), semantic_type is the timeline label
(e.g. "cancelled", "status-change"), and success_label is the
imperative past-tense phrase shown to the user (e.g. "cancelled task").
| Parameter | Type | Description |
|---|---|---|
context |
&AppContext | the application context: settings, store and current project |
raw_id |
&str | the entity’s ID or a unique prefix of it |
new_status |
<E as >::Status | the status to move to |
action |
&str | the transaction description, such as "task cancel" |
semantic_type |
&str | the timeline label, such as "cancelled" |
success_label |
&str | the phrase shown on success, such as "cancelled task" |
output |
&json::Flags | the output mode: normal, --json, --quiet or --raw |
| returns | Result<(), Error> | Ok(()) once the status is saved and printed, or the error that stopped it. |