[][src]Trait essrpc::RPCServer

pub trait RPCServer {
    fn serve_single_call(&mut self) -> Result<(), RPCError>;

    fn serve_until(
        &mut self,
        cond: impl FnMut() -> bool
    ) -> Result<(), RPCError> { ... }
fn serve(&mut self) -> Result<(), RPCError> { ... } }

Trait implemented by all RPC servers generated by the essrpc macro. For a trait named Foo, the macro will generate FooRPCServer which implements RPCServer. An RPCServer generated for a trait 'Foo' will have a new method

This example is not tested
fn new(imp: impl Foo, transport: impl essrpc::ServerTransport)

Unfortunately, new is not specified as part of the RPC trait as traits cannot be type parameters.

Required methods

fn serve_single_call(&mut self) -> Result<(), RPCError>

Serve a single RPC call.

Loading content...

Provided methods

fn serve_until(
    &mut self,
    cond: impl FnMut() -> bool
) -> Result<(), RPCError>

Serve RPC calls until cond() returns false. The condition is checked after serving a single call. It does not provide a mechanism to interrupt a server which is waiting for more data or for a connection to be established. If you need that capability, you must build it into a Transport

fn serve(&mut self) -> Result<(), RPCError>

Serve RPC calls indefinitely. The result will always be an error, as it attempts to serve forever.

Loading content...

Implementors

Loading content...