Skip to main content

FaultStateEnvelope

Struct FaultStateEnvelope 

Source
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

Source

pub const FORMAT: &'static str = "oxide-batch.fault-state"

The framework format identifier durable adapters persist.

Source

pub const FORMAT_VERSION: u16 = 1

The framework format version durable adapters persist.

Source

pub const SCHEMA_VERSION: u32 = 1

The framework schema version durable adapters persist.

Source

pub const MAX_BYTES: usize

The canonical byte ceiling accepted by the durable metadata model.

Source

pub const MAX_ENTRIES: usize = 256

The hard unresolved-key ceiling of format 1.

Source

pub const fn empty() -> Self

Returns the envelope every step execution starts from.

Source

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.

Source

pub const fn checkpoint_digest(&self) -> &[u8; 32]

Returns the checkpoint generation the retained entries belong to.

Source

pub fn entries(&self) -> &[FaultStateEntry]

Borrows the digest-sorted unresolved entries.

Source

pub fn is_empty(&self) -> bool

Returns whether the envelope retains no unresolved key.

Source

pub fn len(&self) -> usize

Returns the number of retained unresolved keys.

Source

pub fn reserved_ordinal(&self, key: RetryKey) -> Option<RetryOrdinal>

Returns the ordinal already reserved for key, when one exists.

Source

pub fn entry(&self, key: RetryKey) -> Option<&FaultStateEntry>

Borrows the retained entry for key, when one exists.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> FaultStateEnvelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FaultStateEnvelope

Source§

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

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

impl Default for FaultStateEnvelope

Source§

fn default() -> Self

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

impl Eq for FaultStateEnvelope

Source§

impl PartialEq for FaultStateEnvelope

Source§

fn eq(&self, other: &FaultStateEnvelope) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FaultStateEnvelope

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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