Skip to main content

IpcClientExt

Trait IpcClientExt 

Source
pub trait IpcClientExt: IpcClient {
    // Provided methods
    fn register_rpc_handler<H>(
        &self,
        handler: H,
    ) -> impl Future<Output = ()> + Send
       where H: RpcHandler + Send + Sync + 'static { ... }
    fn send_typed<Payload>(
        &self,
        payload: Payload,
        destination: Endpoint,
    ) -> impl Future<Output = Result<(), RequestError>> + Send
       where Payload: Serialize + PayloadTypeName + Send { ... }
    fn subscribe_typed<Payload>(
        &self,
    ) -> impl Future<Output = Result<IpcClientTypedSubscription<Payload>, SubscribeError>> + Send
       where Payload: DeserializeOwned + PayloadTypeName { ... }
    fn request<Request>(
        &self,
        request: Request,
        destination: Endpoint,
        cancellation_token: Option<CancellationToken>,
    ) -> impl Future<Output = Result<Request::Response, RequestError>> + Send
       where Request: RpcRequest + Send,
             Request::Response: Send { ... }
}
Expand description

Extension trait providing generic convenience methods on any IpcClient.

This trait is automatically implemented for all types that implement IpcClient, including dyn IpcClient. It provides typed subscriptions, handler registration, and RPC request functionality with full static type safety.

Provided Methods§

Source

fn register_rpc_handler<H>(&self, handler: H) -> impl Future<Output = ()> + Send
where H: RpcHandler + Send + Sync + 'static,

Register a new RPC handler for processing incoming RPC requests. The handler will be executed by the IPC client when an RPC request is received and the response will be sent back over IPC.

Source

fn send_typed<Payload>( &self, payload: Payload, destination: Endpoint, ) -> impl Future<Output = Result<(), RequestError>> + Send
where Payload: Serialize + PayloadTypeName + Send,

Send a message with a payload of any serializable type to the specified destination.

Source

fn subscribe_typed<Payload>( &self, ) -> impl Future<Output = Result<IpcClientTypedSubscription<Payload>, SubscribeError>> + Send

Create a subscription to receive messages that can be deserialized into the provided payload type.

Source

fn request<Request>( &self, request: Request, destination: Endpoint, cancellation_token: Option<CancellationToken>, ) -> impl Future<Output = Result<Request::Response, RequestError>> + Send
where Request: RpcRequest + Send, Request::Response: Send,

Send a request to the specified destination and wait for a response. The destination must have a registered RPC handler for the request type, otherwise an error will be returned by the remote endpoint.

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§

Source§

impl<T: IpcClient + ?Sized> IpcClientExt for T

Blanket implementation: every IpcClient gets the extension methods for free.