Trait sea_streamer_types::Producer

source ·
pub trait Producer: Clone + Send + Sync {
    type Error: Error;
    type SendFuture: Future<Output = StreamResult<Receipt, Self::Error>>;

    // Required methods
    fn send_to<S: Buffer>(
        &self,
        stream: &StreamKey,
        payload: S
    ) -> StreamResult<Self::SendFuture, Self::Error>;
    fn end(self) -> impl Future<Output = StreamResult<(), Self::Error>> + Send;
    fn flush(
        &mut self
    ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send;
    fn anchor(&mut self, stream: StreamKey) -> StreamResult<(), Self::Error>;
    fn anchored(&self) -> StreamResult<&StreamKey, Self::Error>;

    // Provided method
    fn send<S: Buffer>(
        &self,
        payload: S
    ) -> StreamResult<Self::SendFuture, Self::Error> { ... }
}
Expand description

Common interface of producers, to be implemented by all backends.

Required Associated Types§

Required Methods§

source

fn send_to<S: Buffer>( &self, stream: &StreamKey, payload: S ) -> StreamResult<Self::SendFuture, Self::Error>

Send a message to a particular stream. This function is non-blocking. You don’t have to await the future if you are not interested in the Receipt.

source

fn end(self) -> impl Future<Output = StreamResult<(), Self::Error>> + Send

End this producer, only after flushing all it’s pending messages.

source

fn flush( &mut self ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send

Flush all pending messages.

source

fn anchor(&mut self, stream: StreamKey) -> StreamResult<(), Self::Error>

Lock this producer to a particular stream. This function can only be called once. Subsequent calls should return StreamErr::AlreadyAnchored error.

source

fn anchored(&self) -> StreamResult<&StreamKey, Self::Error>

If the producer is already anchored, return a reference to the StreamKey. If the producer is not anchored, this will return StreamErr::NotAnchored error.

Provided Methods§

source

fn send<S: Buffer>( &self, payload: S ) -> StreamResult<Self::SendFuture, Self::Error>

Send a message to the already anchored stream. This function is non-blocking. You don’t have to await the future if you are not interested in the Receipt.

If the producer is not anchored, this will return StreamErr::NotAnchored error.

Object Safety§

This trait is not object safe.

Implementors§