Skip to main content

WorkItemState

Struct WorkItemState 

Source
pub struct WorkItemState {
Show 15 fields pub title: LwwRegister<String>, pub description: LwwRegister<String>, pub kind: LwwRegister<Kind>, pub state: EpochPhaseState, pub size: LwwRegister<Option<Size>>, pub urgency: LwwRegister<Urgency>, pub parent: LwwRegister<String>, pub assignees: OrSet<String>, pub labels: OrSet<String>, pub blocked_by: OrSet<String>, pub related_to: OrSet<String>, pub comments: GSet<String>, pub deleted: LwwRegister<bool>, pub created_at: u64, pub updated_at: u64,
}
Expand description

Composite CRDT representing the full state of a work item.

All fields are individually mergeable CRDTs. The aggregate merge delegates to each field, preserving semilattice laws.

Fields§

§title: LwwRegister<String>

Item title (LWW register).

§description: LwwRegister<String>

Item description (LWW register, empty string = no description).

§kind: LwwRegister<Kind>

Work item kind (LWW register).

§state: EpochPhaseState

Lifecycle state (epoch+phase CRDT).

§size: LwwRegister<Option<Size>>

T-shirt size estimate (LWW register, None encoded as Size::M default).

§urgency: LwwRegister<Urgency>

Priority/urgency override (LWW register).

§parent: LwwRegister<String>

Parent item ID (LWW register, empty string = no parent).

§assignees: OrSet<String>

Assigned agents (OR-Set, add-wins).

§labels: OrSet<String>

Labels (OR-Set, add-wins).

§blocked_by: OrSet<String>

Blocked-by item IDs (OR-Set, add-wins).

§related_to: OrSet<String>

Related-to item IDs (OR-Set, add-wins).

§comments: GSet<String>

Comment event hashes (G-Set, grow-only).

§deleted: LwwRegister<bool>

Soft-delete flag (LWW register).

§created_at: u64

Wall-clock timestamp of the earliest event (for created_at).

§updated_at: u64

Wall-clock timestamp of the latest applied event (for updated_at).

Implementations§

Source§

impl WorkItemState

Source

pub fn to_snapshot_payload( &self, item_id: &str, compacted_from: usize, earliest_ts: i64, latest_ts: i64, ) -> SnapshotPayload

Serialize the full CRDT aggregate to a SnapshotPayload.

This captures per-field clock metadata needed for correct lattice merge when the snapshot is applied on another replica.

Source

pub fn from_snapshot_payload(payload: &SnapshotPayload) -> Self

Reconstruct a WorkItemState from a SnapshotPayload.

The resulting state can be merged with other states via the normal WorkItemState::merge — this is how snapshots participate in the lattice.

Source§

impl WorkItemState

Source

pub fn new() -> Self

Create a new empty WorkItemState with default values.

All LWW registers start with a zero stamp (epoch 0, no identity). All sets start empty. State starts at epoch 0, phase Open.

Source

pub fn merge(&mut self, other: &WorkItemState)

Merge another WorkItemState into this one.

Each field delegates to its own CRDT merge. The aggregate merge preserves semilattice properties because the product of semilattices is a semilattice.

Source

pub fn apply_event(&mut self, event: &Event)

Apply an event to this aggregate, updating the appropriate field CRDT.

The event’s metadata (wall_ts, agent, event_hash) is used to construct the LWW timestamp or OR-Set tag for the update.

Unknown event types and unrecognized update fields are silently ignored (no-op), following the principle that invalid events are skipped during replay.

Source

pub const fn is_deleted(&self) -> bool

Check if this item is soft-deleted.

Source

pub const fn phase(&self) -> Phase

Return the current lifecycle phase.

Source

pub const fn epoch(&self) -> u64

Return the current epoch.

Source

pub fn assignee_names(&self) -> HashSet<&String>

Return the set of current assignee names.

Source

pub fn label_names(&self) -> HashSet<&String>

Return the set of current label strings.

Source

pub fn blocked_by_ids(&self) -> HashSet<&String>

Return the set of items blocking this one.

Source

pub fn related_to_ids(&self) -> HashSet<&String>

Return the set of related item IDs.

Source

pub const fn comment_hashes(&self) -> &HashSet<String>

Return comment event hashes.

Trait Implementations§

Source§

impl Clone for WorkItemState

Source§

fn clone(&self) -> WorkItemState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkItemState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WorkItemState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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