Trait sea_streamer::Producer
source · pub trait Producer: Clone + Send + Sync {
type Error: Error;
type SendFuture: Future<Output = Result<MessageHeader, StreamErr<Self::Error>>>;
// Required methods
fn send_to<S>(
&self,
stream: &StreamKey,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>
where S: Buffer;
fn end(
self
) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send;
fn flush(
&mut self
) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send;
fn anchor(
&mut self,
stream: StreamKey
) -> Result<(), StreamErr<Self::Error>>;
fn anchored(&self) -> Result<&StreamKey, StreamErr<Self::Error>>;
// Provided method
fn send<S>(
&self,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>
where S: Buffer { ... }
}
Expand description
Common interface of producers, to be implemented by all backends.
Required Associated Types§
type Error: Error
type SendFuture: Future<Output = Result<MessageHeader, StreamErr<Self::Error>>>
Required Methods§
sourcefn send_to<S>(
&self,
stream: &StreamKey,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>where
S: Buffer,
fn send_to<S>(
&self,
stream: &StreamKey,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>where
S: Buffer,
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 = Result<(), StreamErr<Self::Error>>> + Send
fn end(self) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send
End this producer, only after flushing all it’s pending messages.
sourcefn flush(
&mut self
) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send
fn flush( &mut self ) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send
Flush all pending messages.
Provided Methods§
sourcefn send<S>(
&self,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>where
S: Buffer,
fn send<S>(
&self,
payload: S
) -> Result<Self::SendFuture, StreamErr<Self::Error>>where
S: Buffer,
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.