-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add protoc-gen-prost crate, a protoc codegen plugin
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "protoc-gen-prost" | ||
version = "0.7.0" | ||
authors = ["Tokio Contributors <[email protected]>"] | ||
license = "Apache-2.0" | ||
repository = "https://github.com/tokio-rs/prost" | ||
documentation = "https://docs.rs/prost-build" | ||
readme = "README.md" | ||
description = "A Protocol Buffers implementation for the Rust Language." | ||
edition = "2018" | ||
|
||
[dependencies] | ||
prost = { version = "0.7.0", path = "..", default-features = false } | ||
prost-build = { version = "0.7.0", path = "../prost-build", default-features = false } | ||
prost-types = { version = "0.7.0", path = "../prost-types", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::io::{Read, Result, Write}; | ||
|
||
use prost::Message; | ||
use prost_build::Config; | ||
use prost_types::compiler::CodeGeneratorRequest; | ||
|
||
fn main() { | ||
if let Err(e) = faillible_main() { | ||
eprintln!("{}", e); | ||
std::process::exit(1); | ||
} | ||
} | ||
|
||
fn faillible_main() -> Result<()> { | ||
let mut buf = Vec::new(); | ||
std::io::stdin().read_to_end(&mut buf)?; | ||
|
||
let req = CodeGeneratorRequest::decode(buf.as_slice()).unwrap(); | ||
let res = Config::new_from_opts(req.parameter(), true).compile_request(req); | ||
|
||
buf.clear(); | ||
res.encode(&mut buf).unwrap(); | ||
std::io::stdout().write_all(&buf)?; | ||
|
||
Ok(()) | ||
} |