Skip to content

A pure-rust protobuf compiler, designed for use with prost-build

License

Notifications You must be signed in to change notification settings

protoconf/protox

 
 

Repository files navigation

crates.io docs.rs deps.rs MSRV Continuous integration codecov Apache 2.0 OR MIT licensed

protox

An implementation of the protobuf compiler in rust, intended for use as a library with crates such as prost-build to avoid needing to build protoc.

Usage

Compiling a single source file:

assert_eq!(protox::compile(&["root.proto"], &["."]).unwrap(), FileDescriptorSet {
    file: vec![
        FileDescriptorProto {
            name: Some("root.proto".to_owned()),
            /* ... */
        }
    ],
});

Usage with prost-build:

let file_descriptors = compile(&["root.proto"], &["."]).unwrap();
let file_descriptor_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"))
    .join("file_descriptor_set.bin");
fs::write(&file_descriptor_path, file_descriptors.encode_to_vec()).unwrap();

prost_build::Config::new()
    .file_descriptor_set_path(&file_descriptor_path)
    .skip_protoc_run()
    .compile_protos(&["root.proto"], &["."])
    .unwrap();

Minimum Supported Rust Version

Rust 1.61 or higher.

The minimum supported Rust version may be changed in the future, but it will be done with a minor version bump.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A pure-rust protobuf compiler, designed for use with prost-build

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%