Skip to content

Instantly share code, notes, and snippets.

@codedjinn
Created June 25, 2022 09:08
Show Gist options
  • Select an option

  • Save codedjinn/0bcd7dd133dcbfd602dee6139a9d3280 to your computer and use it in GitHub Desktop.

Select an option

Save codedjinn/0bcd7dd133dcbfd602dee6139a9d3280 to your computer and use it in GitHub Desktop.
use std::{path::Path, fmt::DebugSet};
fn main() {
let mut parser = protobuf_parse::Parser::new();
parser.pure();
let file = Path::new("D:/protos/hello.proto");
parser.include("D:/protos");
parser.input(file);
let result = parser.parse_and_typecheck();
if result.is_err() {
println!("DAMN! {:?}", result.as_ref().err());
}
let parsed = result.ok().unwrap();
for descriptor in parsed.file_descriptors {
println!("name {}", descriptor.name());
for service in descriptor.service {
println!("\tservice {}", service.name());
for method in service.method {
println!("\t\tmethod {}", method.name());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment