pub trait IpcClient: Send + Sync {
// Required methods
fn start<'life0, 'async_trait>(
&'life0 self,
cancellation_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), AlreadyRunningError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_running(&self) -> bool;
fn send<'life0, 'async_trait>(
&'life0 self,
message: OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<(), SendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn broadcast<'life0, 'async_trait>(
&'life0 self,
group: BroadcastGroup,
payload: Vec<u8>,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<EndpointSendResult>, BroadcastError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe<'life0, 'async_trait>(
&'life0 self,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<IpcClientSubscription, SubscribeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Dyn-compatible trait for IPC client operations.
This trait provides the core IPC operations that consumers can use without
being tied to a specific concrete IpcClient implementation. For generic
convenience methods (typed subscriptions, RPC requests), use the
IpcClientExt extension trait which is automatically
implemented for all IpcClient implementors.
Required Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 self,
cancellation_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), AlreadyRunningError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
cancellation_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<(), AlreadyRunningError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the IPC client, which will begin listening for incoming messages and processing them.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Check if the IPC client task is currently running.
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
message: OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<(), SendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
message: OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<(), SendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a message over IPC.
Returning an error means this particular send failed. The client only stops processing
messages when the underlying error is fatal (see
IpcErrorKind); recoverable errors leave the client running, so the
send can be retried and existing subscriptions remain valid.
Payloads are limited to 5 MiB. Payloads larger than one crypto provider message are split
into separately encrypted fragments that the receiving client reassembles. A peer that
predates fragmentation receives the fragments as messages on an unknown topic. Topics
IpcFragment and IpcFragment/<topic> are reserved for fragments, and sending on them
returns an error.
Sourcefn broadcast<'life0, 'async_trait>(
&'life0 self,
group: BroadcastGroup,
payload: Vec<u8>,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<EndpointSendResult>, BroadcastError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn broadcast<'life0, 'async_trait>(
&'life0 self,
group: BroadcastGroup,
payload: Vec<u8>,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<EndpointSendResult>, BroadcastError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a message to every member of group, fire-and-forget.
The communication backend resolves the group into its current members at send time, and
each member then receives the message exactly as if it had been passed to
send: encrypted over that endpoint’s own session.
Returns an error, without sending anything, if the group cannot be resolved. Otherwise
returns one EndpointSendResult per resolved endpoint, in resolution order. A failed send
to one endpoint, including SendError::Unreachable, does not stop delivery to the others.
A fatal error is the exception: it stops the client, as it does for send,
and the endpoints after it are not attempted, so the results end at the failed endpoint.
Sourcefn subscribe<'life0, 'async_trait>(
&'life0 self,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<IpcClientSubscription, SubscribeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 self,
topic: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<IpcClientSubscription, SubscribeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to receive messages, optionally filtered by topic.
Setting the topic to None will receive all messages.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".