Skip to main content

CommunicationBackendReceiver

Trait CommunicationBackendReceiver 

Source
pub trait CommunicationBackendReceiver:
    Send
    + Sync
    + 'static {
    type ReceiveError: Debug + Send + Sync + 'static + IpcErrorKind;

    // 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§

Required Methods§

Source

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.

Both recoverable and fatal errors may be returned, classified via IpcErrorKind::is_fatal(). A recoverable error (e.g. the receiver lagging) is logged and the IPC client’s processing loop continues; a fatal error (e.g. the channel being closed) stops the loop. Ambiguous cases should be classified as recoverable.

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.

Implementations on Foreign Types§

Source§

impl CommunicationBackendReceiver for RwLock<Receiver<IncomingMessage>>

Implementors§