113 releases

0.14.9 Jul 13, 2022
0.14.7 Feb 24, 2022
0.14.4 Jun 11, 2021
0.14.2 Dec 30, 2020
0.0.5 Nov 23, 2014

#194 in Encoding

Download history 9021/week @ 2022-06-09 7781/week @ 2022-06-16 9671/week @ 2022-06-23 8385/week @ 2022-06-30 6868/week @ 2022-07-07 8571/week @ 2022-07-14 9533/week @ 2022-07-21 11124/week @ 2022-07-28 12300/week @ 2022-08-04 11674/week @ 2022-08-11 10415/week @ 2022-08-18 10910/week @ 2022-08-25 13053/week @ 2022-09-01 21699/week @ 2022-09-08 19252/week @ 2022-09-15 13777/week @ 2022-09-22

70,060 downloads per month
Used in 44 crates (18 directly)

MIT license

795KB
16K 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