[](https://crates.io/crates/protox/)
[](https://docs.rs/protox/)
[](https://deps.rs/crate/protox)

[](https://github.com/andrewhickman/protox/actions/workflows/ci.yml)
[](https://codecov.io/gh/andrewhickman/protox)

# protox
An implementation of the protobuf compiler in rust, intended for use as a library with crates such as [`prost-build`](https://crates.io/crates/prost-build) to avoid needing to build `protoc`.
## Usage
Compiling a single source file:
```rust
assert_eq!(protox::compile(["root.proto"], ["."]).unwrap(), FileDescriptorSet {
file: vec![
FileDescriptorProto {
name: Some("root.proto".to_owned()),
/* ... */
}
],
});
```
Usage with `prost-build`:
```rust
let file_descriptors = protox::compile(["root.proto"], ["."]).unwrap();
prost_build::compile_fds(file_descriptors).unwrap();
```
For better error messages, enable the `fancy` feature of `miette` and return a [`miette::Result`](https://docs.rs/miette/latest/miette/type.Result.html) from your `main()` function.
## Minimum Supported Rust Version
Rust **1.60** 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](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](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][2]) license.
[2]: https://github.com/protocolbuffers/protobuf/blob/master/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.