pub trait Server<H>where
H: Handler,{
type Error;
// Required methods
fn start(&mut self) -> Result<(), Self::Error>;
fn stop(&mut self) -> Result<(), Self::Error>;
fn add_method<F>(&mut self, name: &str, method: F)
where F: RpcMethodSimple;
fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G),
)
where F: SubscribeRpcMethod<H::Metadata>,
G: UnsubscribeRpcMethod<H::Metadata>;
fn describe_api(&self) -> Vec<String>;
}Expand description
Trait defining a JSON-RPC server.
Required Associated Types§
Required Methods§
Sourcefn start(&mut self) -> Result<(), Self::Error>
fn start(&mut self) -> Result<(), Self::Error>
Start the server.
This is expexted to be highly side effected, i.e. this is where sockets and listeners are started.
Sourcefn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
fn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
Add a JSON-RPC method to the server.
Sourcefn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G),
)
fn add_subscription<F, G>( &mut self, notification: &str, subscribe: (&str, F), unsubscribe: (&str, G), )
Add a JSON-RPC subscription so the server.
Sourcefn describe_api(&self) -> Vec<String>
fn describe_api(&self) -> Vec<String>
Get a list of all the supported JSON-RPC methods.
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.