pub trait RemotingService: Send {
// Required methods
async fn start(&self, this: WeakArcMut<Self>);
fn shutdown(&mut self);
fn register_rpc_hook(&mut self, hook: Arc<dyn RPCHook>);
fn clear_rpc_hook(&mut self);
}Expand description
RemotingService trait defines the core functionalities for a remoting service.
This trait outlines the essential operations for starting, shutting down, and managing RPC hooks within a remoting service. Implementors of this trait are expected to provide concrete implementations for these operations, facilitating the management of remote procedure calls.
§Requirements
Implementors must be Send to ensure thread safety, allowing instances to be transferred
across thread boundaries.
Required Methods§
Sourceasync fn start(&self, this: WeakArcMut<Self>)
async fn start(&self, this: WeakArcMut<Self>)
Asynchronously starts the remoting service.
This function should initialize and start the service, making it ready to handle incoming or outgoing remote procedure calls. The exact implementation details, such as opening network connections or preparing internal state, are left to the implementor.
Sourcefn shutdown(&mut self)
fn shutdown(&mut self)
Shuts down the remoting service.
This function is responsible for gracefully shutting down the service. It should ensure that all resources are released, and any ongoing operations are completed or aborted appropriately before the service stops.
Sourcefn register_rpc_hook(&mut self, hook: Arc<dyn RPCHook>)
fn register_rpc_hook(&mut self, hook: Arc<dyn RPCHook>)
Registers an RPC hook.
This function allows for the registration of an RPC hook, which can be used to intercept and modify the behavior of remote procedure calls. Hooks can be used for logging, monitoring, or modifying the requests or responses of RPCs.
§Arguments
hook- An implementation of theRPCHooktrait that will be registered.
Sourcefn clear_rpc_hook(&mut self)
fn clear_rpc_hook(&mut self)
Clears all registered RPC hooks.
This function removes all previously registered RPC hooks, returning the service to its default state without any hooks. This can be useful for cleanup or when changing the configuration of the service.
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.