107 releases

0.14.3 Apr 9, 2021
0.14.2 Dec 30, 2020
0.13.1 Jul 7, 2020
0.12.1 Feb 13, 2020
0.0.5 Nov 23, 2014

#39 in Network programming

Download history 2211/week @ 2021-01-17 2120/week @ 2021-01-24 2483/week @ 2021-01-31 2216/week @ 2021-02-07 2520/week @ 2021-02-14 2946/week @ 2021-02-21 2797/week @ 2021-02-28 2805/week @ 2021-03-07 2236/week @ 2021-03-14 2967/week @ 2021-03-21 2795/week @ 2021-03-28 2341/week @ 2021-04-04 3399/week @ 2021-04-11 3753/week @ 2021-04-18 4818/week @ 2021-04-25 2287/week @ 2021-05-02

11,013 downloads per month
Used in 41 crates (19 directly)

MIT license

745KB
15K SLoC

Cap'n Proto code generation for Rust

crates.io

documentation

The generated code depends on the capnproto-rust runtime library.

Code generation can be customized through the annotations defined in rust.capnp.


lib.rs:

Cap'n Proto Schema Compiler Plugin Library

This library allows you to do Cap'n Proto code generation within a Cargo build. You still need the capnp binary (implemented in C++). (If you use a package manager, try looking for a package called capnproto.)

In your Cargo.toml:

[package]
build = "build.rs"

[build-dependencies]
capnpc = "0.14"

In your build.rs:

fn main() {
    capnpc::CompilerCommand::new()
        .src_prefix("schema")
        .file("schema/foo.capnp")
        .file("schema/bar.capnp")
        .run().expect("schema compiler command");
}

This will be equivalent to executing the shell command

  capnp compile -orust:$OUT_DIR --src-prefix=schema schema/foo.capnp schema/bar.capnp

Dependencies