pub struct LifecycleCapsule { /* private fields */ }Expand description
Every protocol-owned value of one conversation’s lifecycle at a log
position. Built only by LifecycleCapsule::capture or
LifecycleCapsule::decode_canonical.
Implementations§
Source§impl LifecycleCapsule
impl LifecycleCapsule
Sourcepub fn capture(view: &LifecycleView<'_>) -> Result<Self, CapsuleCaptureError>
pub fn capture(view: &LifecycleView<'_>) -> Result<Self, CapsuleCaptureError>
Captures the lent values. Nothing is consumed; generic digests are copied out of the borrowed values.
§Errors
Returns CapsuleCaptureError when the frontiers belong to another
conversation, the participants are not strictly ascending, the live
closure cannot be described, or a count or length does not fit u32.
Sourcepub const fn conversation_id(&self) -> ConversationId
pub const fn conversation_id(&self) -> ConversationId
The conversation these values belong to.
Sourcepub const fn covered_log_sequence(&self) -> u64
pub const fn covered_log_sequence(&self) -> u64
The last log sequence whose effects the capsule includes.
Sourcepub fn encode_canonical(&self) -> Vec<u8> ⓘ
pub fn encode_canonical(&self) -> Vec<u8> ⓘ
Encodes the stable v1 capsule envelope in network byte order.
Sourcepub fn decode_canonical(input: &[u8]) -> Result<Self, CapsuleDecodeError>
pub fn decode_canonical(input: &[u8]) -> Result<Self, CapsuleDecodeError>
Decodes one exact canonical v1 capsule.
§Errors
Returns CapsuleDecodeError for truncation, an invalid magic prefix,
an unsupported codec version, a declared length that differs from the
supplied bytes, a section out of order, missing, unknown or of the wrong
length, a section whose fields break their invariants, participants out
of order, or frontiers that belong to another conversation.
Sourcepub fn restore(self) -> Result<RestoredLifecycle, CapsuleRestoreError>
pub fn restore(self) -> Result<RestoredLifecycle, CapsuleRestoreError>
Validates the capsule as a whole and hands back the live values.
The lifecycle goes through the one joint participant-conversation validation, through its crate-private entry that also checks and installs the fenced-marker issuance latch the capsule carried: a latch naming a take the restored state could not have granted is refused.
§Errors
Returns CapsuleRestoreError when the capsule’s sections are
inconsistent with each other or with their own invariants.
Source§impl LifecycleCapsule
impl LifecycleCapsule
Sourcepub fn capture_with_binding_sources(
view: &LifecycleView<'_>,
sources: &[(ParticipantId, &[u8])],
) -> Result<Self, BindingOriginCaptureError>
pub fn capture_with_binding_sources( view: &LifecycleView<'_>, sources: &[(ParticipantId, &[u8])], ) -> Result<Self, BindingOriginCaptureError>
Captures borrowed participants using their retained canonical origin sources.
§Errors
Refuses missing, malformed, unordered or foreign sources, then propagates the ordinary capsule-capture error. Decoded origins must match the sealed frontier and the exact member and binding before any view borrows them.