Crate capnp_rpc [] [src]

An implementation of the Cap'n Proto remote procedure call protocol. Includes all Level 1 features.

Example

# Cap'n Proto schema
interface Foo {
    identity @0 (x: UInt32) -> (y: UInt32);
}
// Rust server defining an implementation of Foo.
struct FooImpl;
impl foo::Server for FooImpl {
    fn identity(&mut self,
                params: foo::IdentityParams,
                mut results: foo::IdentityResults)
                -> Promise<(), ::capnp::Error>
    {
        let x = pry!(params.get()).get_x();
        results.get().set_y(x);
        Promise::ok(())
    }
}
// Rust client calling a remote implementation of Foo.
let mut request = foo_client.identity_request();
request.get().set_x(123);
let promise = request.send().promise.and_then(|response| {
    println!("results = {}", try!(response.get()).get_y());
    Ok(())
});

For a more complete example, see https://github.com/dwrensha/capnp-rpc-rust/tree/master/examples/calculator

Modules

rpc_capnp

Code generated from rpc.capnp.

rpc_twoparty_capnp

Code generated from rpc-twoparty.capnp.

twoparty

An implementation of VatNetwork for the common case of a client-server connection.

Macros

pry

Like try!(), but for functions that return a Promise<T, E> rather than a Result<T, E>.

Structs

RpcSystem

A portal to objects available on the network.

Server

Hook that allows local implementations of interfaces to be passed to the RPC system so that they can be called remotely.

Traits

Connection
IncomingMessage
OutgoingMessage
VatNetwork

Functions

new_promise_client

Converts a promise for a client into a client that queues up any calls that arrive before the promise resolves.