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 {
async fn identity(
self: Rc<Self>,
params: foo::IdentityParams,
mut results: foo::IdentityResults
) -> Result<(), ::capnp::Error> {
let x = params.get()?.get_x();
results.get().set_y(x);
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§
- rpc_
capnp - Code generated from rpc.capnp.
- rpc_
twoparty_ capnp - Code generated from rpc-twoparty.capnp.
- twoparty
- An implementation of
VatNetworkfor the common case of a client-server connection.
Macros§
- pry
- Like
try!(), but for functions that return aPromise<T, E>rather than aResult<T, E>.
Structs§
- Capability
Server Set - Collection of unwrappable capabilities.
- Disconnector
- A
Futurethat can be run to disconnect anRpcSystem’s ConnectionState and wait for it to be closed. - Imbued
Message Builder - RpcSystem
- A portal to objects available on the network.
Traits§
- Connection
- A two-way RPC connection.
- Flow
Controller - Tracks a particular RPC stream in order to implement a flow control algorithm.
- Incoming
Message - A message received from a
VatNetwork. - Outgoing
Message - A message to be sent by a
VatNetwork. - SetTarget
- Trait implemented by the reconnecting client to set new connection out-of-band.
- VatNetwork
- Network facility between vats, it determines how to form connections between vats.
Functions§
- auto_
reconnect - Creates a new client that reconnects when getting
ErrorKind::Disconnectederrors. - lazy_
auto_ reconnect - Creates a new client that lazily connect and also reconnects when getting
ErrorKind::Disconnectederrors. - new_
client - Creates a new local RPC client of type
Cout of an object that implements a server traitS. - new_
client_ from_ rc - Variant of
new_clientthat works on anRc<S>. - new_
future_ client - Creates a
Clientfrom a future that resolves to aClient.