Created
February 23, 2021 16:28
-
-
Save mkmik/bde76e12ed891e290dc492a2d9eb7071 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
use std::io::Result; | |
fn main() -> Result<()> { | |
prost_build::compile_protos(&["src/tutorial.proto"], &["src/"])?; | |
Ok(()) | |
} |
This file contains hidden or 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
[package] | |
name = "prostdemo" | |
version = "0.1.0" | |
authors = ["Marko Mikulicic <[email protected]>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
prost = "0.7" | |
bytes = "1.0" | |
[build-dependencies] | |
prost-build = { version = "0.7" } |
This file contains hidden or 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
pub mod tut { | |
include!(concat!(env!("OUT_DIR"), "/tutorial.rs")); | |
} | |
fn main() { | |
let x = tut::Person { | |
phone_type: tut::person::PhoneType::Home.into(), | |
..Default::default() | |
}; | |
println!("the fields itself is an i32: {:?}", x.phone_type); | |
let e = tut::person::PhoneType::from_i32(x.phone_type).unwrap(); | |
println!("You can turn it into an enum with from_i32: {:?}", e); | |
} |
This file contains hidden or 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
pub mod tut { | |
include!(concat!(env!("OUT_DIR"), "/tutorial.rs")); | |
} | |
fn main() { | |
let x = tut::Person { | |
phone_type: tut::person::PhoneType::Home.into(), | |
..Default::default() | |
}; | |
println!("the fields itself is an i32: {:?}", x.phone_type); | |
let e = tut::person::PhoneType::from_i32(x.phone_type).unwrap(); | |
println!("You can turn it into an enum with from_i32: {:?}", e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment