-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc/example request: using nested messages #56
Comments
@davechallis Hi! I'm not exactly sure how this is actually handled, I would assume |
For Example: message MyOuterMessage {
string message = 1;
enum MyInnerEnum {
FOO = 0;
BAR = 1;
}
} Generated: #[derive(Clone, PartialEq, ::prost::Message)]
pub struct MyOuterMessage {
#[prost(string, tag = "1")]
pub message: std::string::String,
}
pub mod my_outer_message {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MyInnerEnum {
Foo = 0,
Bar = 1,
}
} Nesting further puts the items deeper in the generated modules. message Level1 {
message Level2 {
message Level3 {
string foo = 1;
}
}
} #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Level1 {}
pub mod level1 {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Level2 {}
pub mod level2 {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Level3 {
#[prost(string, tag = "1")]
pub foo: std::string::String,
}
}
} |
@JohnDoneth many thanks for posting those, that's very helpful. |
@davechallis hopefully this answered your question, I think we can close this issue now? |
@LucioFranco yes, please go ahead and close, I've made a note to try and work these into an example when I get the chance. |
@davechallis that would be great! |
Feature Request
Documentation or examples on how to use nested message types from Rust, e.g. for something like:
Motivation
Just to make getting started with using Tonic a bit easier, since it's not as obvious how nested data structures might be handled in Rust.
The text was updated successfully, but these errors were encountered: