Skip to main content

Positioned

Trait Positioned 

Source
pub trait Positioned: IncomingMessage {
    type Position: Send;

    // Required method
    fn position(&self) -> Self::Position;
}
Expand description

A delivered message that knows its own position in the broker’s replayable log.

The captured half of the seek capability, next to broker-constructed positions: position returns a value Seeker::seek accepts, with pinned semantics - seeking to it redelivers this exact message. Generic replay code and the conformance suite rely on that contract; positions built by broker constructors keep broker-documented semantics instead.

§Examples

use ruststream::{Positioned, Seekable, Seeker};

async fn replay_from<S>(
    subscriber: &S,
    msg: &S::Message,
) -> Result<(), <S::Seeker as Seeker>::Error>
where
    S: Seekable,
    S::Message: Positioned<Position = <S::Seeker as Seeker>::Position>,
{
    subscriber.seeker().seek(msg.position()).await
}

Required Associated Types§

Source

type Position: Send

The position type, matching the subscription’s Seeker::Position.

Required Methods§

Source

fn position(&self) -> Self::Position

Returns the position of this delivery; seeking to it redelivers this message.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Positioned for RedisMessage

The position of a delivery is the group cursor that redelivers it.

The cursor is exclusive (a group resumes after the id it holds), so the pinned position is the id immediately below this entry’s - seeking to it delivers this message again, followed by the entries after it. Repositioning is group-wide; see RedisGroupSeeker.