Crate capnpc

source ·
Expand description

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:

capnp = "0.18" # Note this is a different library than capnp*c*

capnpc = "0.18"

In your

fn main() {
        .run().expect("schema compiler command");

In your

mod foo_capnp {
    include!(concat!(env!("OUT_DIR"), "/"));

mod bar_capnp {
    include!(concat!(env!("OUT_DIR"), "/"));

This will be equivalent to executing the shell command

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