pub struct StateSubscriber<T: DeltaState> { /* private fields */ }Expand description
Receives and applies DeltaStream packets for one application-state stream.
A subscriber owns the receiving side of a stream. The usual flow is:
serialized bytes -> Subscriber -> validated synchronized state.
It validates schema identity, sequence/base-state relationships, duplicate and stale packets, packet integrity, and decompression limits before committing a new state.
Implementations§
Source§impl<T: DeltaState> StateSubscriber<T>
impl<T: DeltaState> StateSubscriber<T>
Sourcepub fn with_decode_config(decode_config: DecodeConfig) -> Self
pub fn with_decode_config(decode_config: DecodeConfig) -> Self
Creates an empty subscriber with explicit packet decoding limits.
Sourcepub fn receive(
&mut self,
bytes: &[u8],
) -> Result<GenericApplyResult<T>, DeltaError>
pub fn receive( &mut self, bytes: &[u8], ) -> Result<GenericApplyResult<T>, DeltaError>
Receives transport bytes, decodes a packet, and applies it.
This is the high-level receiving path. It parses bytes with
Packet::from_bytes_with_config, validates packet integrity, decompresses within
configured limits when needed, and then applies the packet with the same state-chain
logic as Subscriber::apply. It may apply a new state, report a duplicate, or
request a snapshot when a gap or incompatible base is detected.
Sourcepub fn apply(
&mut self,
packet: Packet,
) -> Result<GenericApplyResult<T>, DeltaError>
pub fn apply( &mut self, packet: Packet, ) -> Result<GenericApplyResult<T>, DeltaError>
Applies a snapshot or delta packet.
Snapshots establish or restore state. Deltas are committed only when the local sequence and base-state hash match the packet metadata. Rejected packets do not mutate the subscriber state.
Sourcepub fn apply_with_migrations(
&mut self,
packet: Packet,
migrations: &MigrationRegistry,
) -> Result<GenericApplyResult<T>, DeltaError>
pub fn apply_with_migrations( &mut self, packet: Packet, migrations: &MigrationRegistry, ) -> Result<GenericApplyResult<T>, DeltaError>
Applies a packet and allows registered snapshot migrations when schemas differ.