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
.
Examples
Compiling a single source file:
assert_eq!;
Usage with prost-build
:
let file_descriptors = compile.unwrap;
compile_fds.unwrap;
Usage with tonic-build
:
let file_descriptors = compile.unwrap;
let file_descriptor_path = from
.join;
write.unwrap;
configure
.build_server
.file_descriptor_set_path
.skip_protoc_run
.compile
.unwrap;
Error messages
This crate uses miette
to add additional details to errors. For nice error messages, add miette
as a dependency with the fancy
feature enabled and return a miette::Result
from your build script.
Example error message:
Error:
× name 'Bar' is not defined
╭─[root.proto:3:1]
3 │ message Foo {
4 │ Bar bar = 1;
· ─┬─
· ╰── found here
5 │ }
╰────
Minimum Supported Rust Version
Rust 1.64 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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
This project includes code imported from the Protocol Buffers project, which is included under its original (BSD) license.
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.