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;
// Provided method
fn resolve(
&self,
_group: &BroadcastGroup,
) -> impl Future<Output = BroadcastResolution> + 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§
Sourcetype SendError: Debug + Send + Sync + 'static + IpcErrorKind
type SendError: Debug + Send + Sync + 'static + IpcErrorKind
Error returned by send, classified via IpcErrorKind.
Sourcetype Receiver: CommunicationBackendReceiver
type Receiver: CommunicationBackendReceiver
Receiver type returned by subscribe.
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::kind(). 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.
Provided Methods§
Sourcefn resolve(
&self,
_group: &BroadcastGroup,
) -> impl Future<Output = BroadcastResolution> + Send + Sync
fn resolve( &self, _group: &BroadcastGroup, ) -> impl Future<Output = BroadcastResolution> + Send + Sync
Resolve a BroadcastGroup into the endpoints that are currently its members. Called by
IpcClient::broadcast, which rejects any resolved endpoint
that falls outside the group.
The default implementation returns BroadcastResolution::Unsupported, so a backend has
to opt in to broadcasting explicitly. Backends that track the connected members of a group
should override this.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".