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
impl StreamStateContract
Sourcepub fn new<T, C>(codec: C) -> Self
pub fn new<T, C>(codec: C) -> Self
Captures codec’s schema/codec identity, versions, and
restartability declaration as a type-erased contract.
Sourcepub fn schema_id(&self) -> &StateSchemaId
pub fn schema_id(&self) -> &StateSchemaId
Borrows the expected application schema identifier.
Sourcepub fn restartability(&self) -> RestartabilityDeclaration
pub fn restartability(&self) -> RestartabilityDeclaration
Returns the declared restartability of the stream this contract belongs to.
Sourcepub fn validate_for_open(
&self,
envelope: &ComponentStateEnvelope,
) -> Result<ComponentStateEnvelope, ComponentStateError>
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.