GithubHelp home page GithubHelp logo

Comments (6)

davechallis avatar davechallis commented on July 30, 2024 2

@JohnDoneth many thanks for posting those, that's very helpful.

from tonic.

LucioFranco avatar LucioFranco commented on July 30, 2024

@davechallis Hi! I'm not exactly sure how this is actually handled, I would assume prost builds two structs. I'm not sure if the docs proprely belong in tonic or with prost. I think what might be good would to build out a set of guides around the full stack version of tonic.

from tonic.

JohnDoneth avatar JohnDoneth commented on July 30, 2024

For prost the nested types are put into their own module and the outermost items themselves are generated outside of that new module.

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,
        }
    }
}

from tonic.

LucioFranco avatar LucioFranco commented on July 30, 2024

@davechallis hopefully this answered your question, I think we can close this issue now?

from tonic.

davechallis avatar davechallis commented on July 30, 2024

@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.

from tonic.

LucioFranco avatar LucioFranco commented on July 30, 2024

@davechallis that would be great!

from tonic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.