Crate capnpc

source ·
Expand description

Cap’n Proto Schema Compiler Plugin Library

This library allows you to do [Cap’n Proto code generation] (https://capnproto.org/otherlang.html#how-to-write-compiler-plugins) 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.9"

In your build.rs:

extern crate capnpc;

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

Modules

Code generated from [schema.capnp] (https://github.com/sandstorm-io/capnproto/blob/master/c%2B%2B/src/capnp/schema.capnp).

Structs

A builder object for schema compiler commands.

Enums