Skip to main content

StreamStateContract

Struct StreamStateContract 

Source
pub struct StreamStateContract(/* private fields */);
Expand description

The codec/schema/restartability contract a registered ItemStream carries, bound to the runtime at registration time.

Gate C requires the runtime to validate a registered stream’s expected schema and codec identity/version, apply declared migrations, and reject unknown-newer versions – all before the application’s open runs – without introspecting the stream’s opaque internal state. This is the small, explicit descriptor that makes that possible: it preserves the existing separation between the stream’s logical identity (crate::definition::ComponentStreamIdentity), its runtime implementation (ItemStream/BoxedStream), and its state contract (this type), which the stream’s own ComponentStateCodec already declares.

Implementations§

Source§

impl StreamStateContract

Source

pub fn new<T, C>(codec: C) -> Self
where C: ComponentStateCodec<T> + Send + Sync + 'static, T: 'static,

Captures codec’s schema/codec identity, versions, and restartability declaration as a type-erased contract.

Source

pub fn schema_id(&self) -> &StateSchemaId

Borrows the expected application schema identifier.

Source

pub fn codec_id(&self) -> &CodecId

Borrows the expected codec identifier.

Source

pub fn restartability(&self) -> RestartabilityDeclaration

Returns the declared restartability of the stream this contract belongs to.

Source

pub fn validate_for_open( &self, envelope: &ComponentStateEnvelope, ) -> Result<ComponentStateEnvelope, ComponentStateError>

Validates and migrates envelope to this contract’s current schema and codec versions before the runtime may call open with it.

§Errors

Returns the redacted identity, compatibility, or migration failure ComponentStateEnvelope::validated_for_open would.

Trait Implementations§

Source§

impl Debug for StreamStateContract

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.