pub struct Operation {
pub kind: OperationKind,
pub parents: Vec<OpId>,
pub intent_id: Option<IntentId>,
}Expand description
The operation as a whole — its kind and the causal predecessors
it assumes. The OpId is computed from this plus a sorted view
of parents.
Operations without parents are valid and represent “applies to
the empty repository” or “applies to the synthetic genesis
state.” lex store migrate v1→v2 will produce parentless ops
for stages it can’t trace back to a clear predecessor.
Fields§
§kind: OperationKind§parents: Vec<OpId>Operations whose produces this op assumes. Sorted before
hashing for canonical form. Empty for ops against the empty
repo.
intent_id: Option<IntentId>The intent that caused this op, if known. Optional because
operations produced outside an agent harness (e.g. a human
running lex publish directly) don’t have one.
Including the intent in the canonical hash means the same
logical change made under different intents produces
different OpIds — causally distinct events should hash
distinctly. Ops with intent_id: None keep their existing
hashes (the field is omitted from the canonical JSON via
skip_serializing_if), so this is backwards-compatible
for stores written before #131.
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn new(kind: OperationKind, parents: impl IntoIterator<Item = OpId>) -> Self
pub fn new(kind: OperationKind, parents: impl IntoIterator<Item = OpId>) -> Self
Construct an operation against zero or more parents. Caller supplies parents in any order; canonicalization sorts them before hashing.
Sourcepub fn with_intent(self, intent_id: impl Into<IntentId>) -> Self
pub fn with_intent(self, intent_id: impl Into<IntentId>) -> Self
Tag this operation with the intent that produced it. The builder shape keeps existing call sites untouched; agent harnesses that record intent call this once before applying the op.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Operation
impl<'de> Deserialize<'de> for Operation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Operation
impl StructuralPartialEq for Operation
Auto Trait Implementations§
impl Freeze for Operation
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnsafeUnpin for Operation
impl UnwindSafe for Operation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.