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§
type Error: Error
type SendFuture: Future<Output = StreamResult<Receipt, Self::Error>>
Required Methods§
sourcefn send_to<S: Buffer>(
&self,
stream: &StreamKey,
payload: S
) -> StreamResult<Self::SendFuture, Self::Error>
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.
sourcefn end(self) -> impl Future<Output = StreamResult<(), Self::Error>> + Send
fn end(self) -> impl Future<Output = StreamResult<(), Self::Error>> + Send
End this producer, only after flushing all it’s pending messages.
sourcefn flush(
&mut self
) -> impl Future<Output = StreamResult<(), Self::Error>> + Send
fn flush( &mut self ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send
Flush all pending messages.
sourcefn anchor(&mut self, stream: StreamKey) -> StreamResult<(), Self::Error>
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.
sourcefn anchored(&self) -> StreamResult<&StreamKey, Self::Error>
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§
sourcefn send<S: Buffer>(
&self,
payload: S
) -> StreamResult<Self::SendFuture, Self::Error>
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.