pub trait CommunicationBackendReceiver:
Send
+ Sync
+ 'static {
type ReceiveError: Debug + Send + Sync + 'static;
// Required method
fn receive(
&self,
) -> impl Future<Output = Result<IncomingMessage, Self::ReceiveError>> + Send + Sync;
}
Expand description
This trait defines the interface for receiving messages from the communication backend.
The implementation of this trait needs to guarantee that: - The receiver buffers messages from the creation of the receiver until the first call to receive(). - The receiver buffers messages between calls to receive().
Required Associated Types§
type ReceiveError: Debug + Send + Sync + 'static
Required Methods§
Sourcefn receive(
&self,
) -> impl Future<Output = Result<IncomingMessage, Self::ReceiveError>> + Send + Sync
fn receive( &self, ) -> impl Future<Output = Result<IncomingMessage, Self::ReceiveError>> + Send + Sync
Receive a message. This function will block asynchronously until a message is received.
An error should only be returned for fatal and unrecoverable errors. Returning an error will cause the IPC client to stop processing messages.
Do not call this function from multiple threads at the same time. Use the subscribe function to create one receiver per thread.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.