Skip to main content

StepStreamExt

Trait StepStreamExt 

Source
pub trait StepStreamExt<I, R>: Stream<Item = Result<Step<I>, R>> + Sized
where I: RawItem,
{ // Provided methods fn events(self) -> impl Stream<Item = Result<I, R>> + Send where Self: Send, I: Send, R: Send { ... } fn decoded<E, C>( self, codec: C, ) -> impl Stream<Item = Result<Step<I::Typed<E>>, DecodeStreamError<R, C::Error>>> + Send where C: OwningCodec<E>, E: Send + 'static, I: Send + 'static, R: Send + 'static, Self: Send { ... } }
Expand description

Adds phase-aware views over a Step-tagged stream — what Subscription::subscribe / subscribe_all yield.

The Step phase marker (the catch-up→live boundary) is intrinsic to a subscription (a finite read has no such boundary), so it rides on the raw stream. This trait lets a consumer either keep the phase and decode (.decoded()), or drop it (.events()) and fall back to the plain DecodedStreamExt surface a finite read uses.

Step<I> is deliberately not a RawItem (the CaughtUp marker carries no envelope), so .decoded() here and .decoded() on DecodedStreamExt are two non-overlapping impls sharing one name.

Provided Methods§

Source

fn events(self) -> impl Stream<Item = Result<I, R>> + Send
where Self: Send, I: Send, R: Send,

Drop the phase: yield bare I items (CaughtUp removed, Event unwrapped). The result is a plain raw stream, so the full DecodedStreamExt surface (.decoded(), .for_each_decoded()) applies to it — the path for a consumer that does not care whether it is replaying or live.

Source

fn decoded<E, C>( self, codec: C, ) -> impl Stream<Item = Result<Step<I::Typed<E>>, DecodeStreamError<R, C::Error>>> + Send
where C: OwningCodec<E>, E: Send + 'static, I: Send + 'static, R: Send + 'static, Self: Send,

Decode each event with codec, preserving the phase marker: the result is a stream of Step<I::Typed<E>> — replay events, then exactly one CaughtUp, then live events. Owning codecs only (same for<'a> Output<'a> = E steer as DecodedStreamExt::decoded).

This is the projection consumption path: it tells catch-up from live and hands you typed events, reusing the codec — no magic count, no hand-rolled timeout, mnesis-owned error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<St, I, R> StepStreamExt<I, R> for St
where St: Stream<Item = Result<Step<I>, R>>, I: RawItem,