Trait RpcServer

Source
pub trait RpcServer {
    // Required methods
    fn register_endpoint<'life0, 'life1, 'async_trait>(
        &'life0 self,
        origin_filter: Option<&'life1 UUri>,
        resource_id: u16,
        request_handler: Arc<dyn RequestHandler>,
    ) -> Pin<Box<dyn Future<Output = Result<(), RegistrationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn unregister_endpoint<'life0, 'life1, 'async_trait>(
        &'life0 self,
        origin_filter: Option<&'life1 UUri>,
        resource_id: u16,
        request_handler: Arc<dyn RequestHandler>,
    ) -> Pin<Box<dyn Future<Output = Result<(), RegistrationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A server for exposing Remote Procedure Call (RPC) endpoints.

Please refer to the Communication Layer API specification for details.

Required Methods§

Source

fn register_endpoint<'life0, 'life1, 'async_trait>( &'life0 self, origin_filter: Option<&'life1 UUri>, resource_id: u16, request_handler: Arc<dyn RequestHandler>, ) -> Pin<Box<dyn Future<Output = Result<(), RegistrationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Registers an endpoint for RPC requests.

Note that only a single endpoint can be registered for a given resource ID. However, the same request handler can be registered for multiple endpoints.

§Arguments
  • origin_filter - A pattern defining origin addresses to accept requests from. If None, requests will be accepted from all sources.
  • resource_id - The resource identifier of the (local) method to accept requests for.
  • request_handler - The handler to invoke for each incoming request.
§Errors

Returns an error if the listener cannot be registered or if a listener has already been registered for the given resource ID.

Source

fn unregister_endpoint<'life0, 'life1, 'async_trait>( &'life0 self, origin_filter: Option<&'life1 UUri>, resource_id: u16, request_handler: Arc<dyn RequestHandler>, ) -> Pin<Box<dyn Future<Output = Result<(), RegistrationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deregisters a previously registered endpoint.

§Arguments
  • origin_filter - The origin pattern that the endpoint had been registered for.
  • resource_id - The (local) resource identifier that the endpoint had been registered for.
  • request_handler - The handler to unregister.
§Errors

Returns an error if the listener cannot be unregistered.

Implementors§

Source§

impl RpcServer for InMemoryRpcServer

Source§

impl RpcServer for MockRpcServerImpl

This delegates the invocation of the UTransport functions to the mocked functions of the Transport struct. see https://github.com/asomers/mockall/issues/571