Crate capnp_rpc

source ·
Expand description

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 = {}", response.get()?.get_y());
    Ok(())
});

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

Modules

Macros

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

Structs

  • Allows a server to recognize its own capabilities when passed back to it, and obtain the underlying Server objects associated with them. Note that CapabilityServerSet holds references to every Server passed to it, and the only way to drop them is to drop the entire CapabilityServerSet. The WeakCapabilityServerSet struct below is a (better) alternative that only holds weak references. Its semantics match the capnproto-c++ version of CapabilityServerSet.
  • A Future that can be run to disconnect an RpcSystem’s ConnectionState and wait for it to be closed.
  • A portal to objects available on the network.
  • Allows a server to recognize its own capabilities when passed back to it, and obtain the underlying Server objects associated with them. Holds only weak references to Server objects allowing Server objects to be dropped when dropped by the remote client. Call the gc method to reclaim memory used for Server objects that have been dropped.

Traits

Functions