pub trait CommunicationBackend:
Send
+ Sync
+ 'static {
type SendError: Debug + Send + Sync + 'static + IpcErrorKind;
type Receiver: CommunicationBackendReceiver;
// Required methods
fn send(
&self,
message: OutgoingMessage,
) -> impl Future<Output = Result<(), Self::SendError>> + Send + Sync;
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§
type SendError: Debug + Send + Sync + 'static + IpcErrorKind
type Receiver: CommunicationBackendReceiver
Required Methods§
Sourcefn send(
&self,
message: OutgoingMessage,
) -> impl Future<Output = Result<(), Self::SendError>> + Send + Sync
fn send( &self, message: OutgoingMessage, ) -> impl Future<Output = Result<(), Self::SendError>> + Send + Sync
Send a message to the destination specified in the message. This function may be called from any thread at any time.
Both recoverable and fatal errors may be returned, classified via
IpcErrorKind::is_fatal(). A recoverable error (e.g. a transient transport failure) is
logged and the IPC client keeps running; a fatal error stops the client from processing any
further messages. Ambiguous cases should be classified as recoverable.
The implementation of this trait needs to guarantee that: - Multiple concurrent receivers and senders can coexist.
Sourcefn subscribe(&self) -> impl Future<Output = Self::Receiver> + Send + Sync
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.