pub struct FaultStateEnvelope { /* private fields */ }Expand description
The bounded, checksummed fault state of one durable step execution.
Format 1 is canonical JSON containing the prior committed checkpoint digest
and at most Self::MAX_ENTRIES digest-sorted unresolved retry
entries. The empty envelope carries the zero checkpoint digest because no
entry depends on a checkpoint generation.
Implementations§
Source§impl FaultStateEnvelope
impl FaultStateEnvelope
Sourcepub const FORMAT: &'static str = "oxide-batch.fault-state"
pub const FORMAT: &'static str = "oxide-batch.fault-state"
The framework format identifier durable adapters persist.
Sourcepub const FORMAT_VERSION: u16 = 1
pub const FORMAT_VERSION: u16 = 1
The framework format version durable adapters persist.
Sourcepub const SCHEMA_VERSION: u32 = 1
pub const SCHEMA_VERSION: u32 = 1
The framework schema version durable adapters persist.
Sourcepub const MAX_ENTRIES: usize = 256
pub const MAX_ENTRIES: usize = 256
The hard unresolved-key ceiling of format 1.
Sourcepub fn new(
checkpoint_digest: [u8; 32],
entries: impl IntoIterator<Item = FaultStateEntry>,
) -> Result<Self, FaultStateFormatError>
pub fn new( checkpoint_digest: [u8; 32], entries: impl IntoIterator<Item = FaultStateEntry>, ) -> Result<Self, FaultStateFormatError>
Validates a complete envelope, sorting entries by retry-key digest.
§Errors
Returns FaultStateFormatError::TooManyEntries above the format
ceiling, FaultStateFormatError::DuplicateKey for a repeated key, and
FaultStateFormatError::CheckpointMismatch when a non-empty envelope
carries the zero checkpoint digest.
Sourcepub const fn checkpoint_digest(&self) -> &[u8; 32]
pub const fn checkpoint_digest(&self) -> &[u8; 32]
Returns the checkpoint generation the retained entries belong to.
Sourcepub fn entries(&self) -> &[FaultStateEntry]
pub fn entries(&self) -> &[FaultStateEntry]
Borrows the digest-sorted unresolved entries.
Sourcepub fn reserved_ordinal(&self, key: RetryKey) -> Option<RetryOrdinal>
pub fn reserved_ordinal(&self, key: RetryKey) -> Option<RetryOrdinal>
Returns the ordinal already reserved for key, when one exists.
Sourcepub fn entry(&self, key: RetryKey) -> Option<&FaultStateEntry>
pub fn entry(&self, key: RetryKey) -> Option<&FaultStateEntry>
Borrows the retained entry for key, when one exists.
Sourcepub fn reserved(
&self,
entry: FaultStateEntry,
checkpoint_digest: [u8; 32],
limit: RetryStateLimit,
) -> Result<Self, FaultStateError>
pub fn reserved( &self, entry: FaultStateEntry, checkpoint_digest: [u8; 32], limit: RetryStateLimit, ) -> Result<Self, FaultStateError>
Returns the envelope after accepting one reservation.
The ordinal must directly follow the persisted one for the same key, and
a new key must fit within limit unresolved keys.
§Errors
Returns FaultStateError::StaleReservation for a non-consecutive
ordinal, FaultStateError::CapacityExhausted at the configured bound,
and FaultStateError::Corrupt when the entry belongs to a different
checkpoint generation.
Sourcepub fn to_canonical_json(&self) -> Result<Vec<u8>, FaultStateFormatError>
pub fn to_canonical_json(&self) -> Result<Vec<u8>, FaultStateFormatError>
Serializes the canonical bytes the durable checksum covers.
§Errors
Returns FaultStateFormatError::TooLarge above the durable ceiling.
Sourcepub fn checksum(&self) -> Result<[u8; 32], FaultStateFormatError>
pub fn checksum(&self) -> Result<[u8; 32], FaultStateFormatError>
Returns the SHA-256 checksum over the canonical bytes.
§Errors
Returns FaultStateFormatError::TooLarge above the durable ceiling.
Sourcepub fn from_canonical_json(
format_version: u16,
schema: &str,
schema_version: u32,
bytes: &[u8],
checksum: &[u8; 32],
) -> Result<Self, FaultStateFormatError>
pub fn from_canonical_json( format_version: u16, schema: &str, schema_version: u32, bytes: &[u8], checksum: &[u8; 32], ) -> Result<Self, FaultStateFormatError>
Validates canonical bytes and their durable checksum.
Unknown format or schema versions, checksum mismatch, invalid enumerations, an unsorted or duplicated key, and an over-large payload are corruption. No component work may begin after one.
§Errors
Returns the redacted FaultStateFormatError that rejected the bytes.
Sourcepub fn validate_for(
&self,
retry_limit: RetryLimit,
state_limit: RetryStateLimit,
checkpoint_digest: &[u8; 32],
) -> Result<(), FaultStateFormatError>
pub fn validate_for( &self, retry_limit: RetryLimit, state_limit: RetryStateLimit, checkpoint_digest: &[u8; 32], ) -> Result<(), FaultStateFormatError>
Rejects state the current policy and checkpoint cannot own.
§Errors
Returns FaultStateFormatError::OrdinalAboveLimit for an ordinal the
configured retry limit cannot reach, [FaultStateFormatError:: TooManyEntries] above the configured capacity, and
FaultStateFormatError::CheckpointMismatch when the retained entries
belong to a superseded checkpoint.
Trait Implementations§
Source§impl Clone for FaultStateEnvelope
impl Clone for FaultStateEnvelope
Source§fn clone(&self) -> FaultStateEnvelope
fn clone(&self) -> FaultStateEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FaultStateEnvelope
impl Debug for FaultStateEnvelope
Source§impl Default for FaultStateEnvelope
impl Default for FaultStateEnvelope
impl Eq for FaultStateEnvelope
Source§impl PartialEq for FaultStateEnvelope
impl PartialEq for FaultStateEnvelope
impl StructuralPartialEq for FaultStateEnvelope
Auto Trait Implementations§
impl Freeze for FaultStateEnvelope
impl RefUnwindSafe for FaultStateEnvelope
impl Send for FaultStateEnvelope
impl Sync for FaultStateEnvelope
impl Unpin for FaultStateEnvelope
impl UnsafeUnpin for FaultStateEnvelope
impl UnwindSafe for FaultStateEnvelope
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more