Trait CommunicationBackend

Source
pub trait CommunicationBackend:
    Send
    + Sync
    + 'static {
    type SendError: Debug + Send + Sync + 'static;
    type Receiver: CommunicationBackendReceiver;

    // Required methods
    fn send(
        &self,
        message: OutgoingMessage,
    ) -> impl Future<Output = Result<(), Self::SendError>> + Send;
    fn subscribe(&self) -> impl Future<Output = Self::Receiver> + Send + Sync;
}
Expand description

This trait defines the interface that will be used to send and receive messages over IPC. It is up to the platform to implement this trait and any necessary thread synchronization and broadcasting.

Required Associated Types§

Required Methods§

Source

fn send( &self, message: OutgoingMessage, ) -> impl Future<Output = Result<(), Self::SendError>> + Send

Send a message to the destination specified in the message. This function may be called from any thread at any time.

An error should only be returned for fatal and unrecoverable errors. Returning an error will cause the IPC client to stop processing messages.

The implementation of this trait needs to guarantee that: - Multiple concurrent receivers and senders can coexist.

Source

fn subscribe(&self) -> impl Future<Output = Self::Receiver> + Send + Sync

Subscribe to receive messages. This function will return a receiver that can be used to receive messages asynchronously.

The implementation of this trait needs to guarantee that: - Multiple concurrent receivers may be created. - All concurrent receivers will receive the same messages. - Multiple concurrent receivers and senders can coexist.

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.

Implementors§