pub struct Proto { /* private fields */ }
Expand description
Main structure representing a complete Protocol Buffer file. Contains all the elements that can be defined in a proto file.
Implementations§
Source§impl Proto
impl Proto
Sourcepub fn parse_file(path: &str) -> Result<String, ParserError>
pub fn parse_file(path: &str) -> Result<String, ParserError>
Parses a proto file from the filesystem and returns its JSON representation.
§Arguments
path
- Path to the proto file to be parsed
§Returns
A Result containing either the JSON string representation of the parsed proto file or a ParserError if any error occurs during parsing or processing.
§Examples
use proto_file_parser::Proto;
let json = Proto::parse_file("example.proto").unwrap();
println!("{}", json);
Sourcepub fn parse(input: &str) -> Result<String, ParserError>
pub fn parse(input: &str) -> Result<String, ParserError>
Parses a proto definition from a string and returns its JSON representation.
§Arguments
input
- String containing the proto definition to be parsed
§Returns
A Result containing either the JSON string representation of the parsed proto definition or a ParserError if any error occurs during parsing or processing.
§Examples
use proto_file_parser::Proto;
let input = r#"
syntax = "proto3";
message Test {
string name = 1;
}
"#;
let json = Proto::parse(input).unwrap();
println!("{}", json);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Proto
impl RefUnwindSafe for Proto
impl Send for Proto
impl Sync for Proto
impl Unpin for Proto
impl UnwindSafe for Proto
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more