prost_types/
compiler.rs

1// This file is @generated by prost-build.
2/// The version number of protocol compiler.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Version {
5    #[prost(int32, optional, tag = "1")]
6    pub major: ::core::option::Option<i32>,
7    #[prost(int32, optional, tag = "2")]
8    pub minor: ::core::option::Option<i32>,
9    #[prost(int32, optional, tag = "3")]
10    pub patch: ::core::option::Option<i32>,
11    /// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
12    /// be empty for mainline stable releases.
13    #[prost(string, optional, tag = "4")]
14    pub suffix: ::core::option::Option<::prost::alloc::string::String>,
15}
16/// An encoded CodeGeneratorRequest is written to the plugin's stdin.
17#[derive(Clone, PartialEq, ::prost::Message)]
18pub struct CodeGeneratorRequest {
19    /// The .proto files that were explicitly listed on the command-line.  The
20    /// code generator should generate code only for these files.  Each file's
21    /// descriptor will be included in proto_file, below.
22    #[prost(string, repeated, tag = "1")]
23    pub file_to_generate: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
24    /// The generator parameter passed on the command-line.
25    #[prost(string, optional, tag = "2")]
26    pub parameter: ::core::option::Option<::prost::alloc::string::String>,
27    /// FileDescriptorProtos for all files in files_to_generate and everything
28    /// they import.  The files will appear in topological order, so each file
29    /// appears before any file that imports it.
30    ///
31    /// protoc guarantees that all proto_files will be written after
32    /// the fields above, even though this is not technically guaranteed by the
33    /// protobuf wire format.  This theoretically could allow a plugin to stream
34    /// in the FileDescriptorProtos and handle them one by one rather than read
35    /// the entire set into memory at once.  However, as of this writing, this
36    /// is not similarly optimized on protoc's end -- it will store all fields in
37    /// memory at once before sending them to the plugin.
38    ///
39    /// Type names of fields and extensions in the FileDescriptorProto are always
40    /// fully qualified.
41    #[prost(message, repeated, tag = "15")]
42    pub proto_file: ::prost::alloc::vec::Vec<super::FileDescriptorProto>,
43    /// The version number of protocol compiler.
44    #[prost(message, optional, tag = "3")]
45    pub compiler_version: ::core::option::Option<Version>,
46}
47/// The plugin writes an encoded CodeGeneratorResponse to stdout.
48#[derive(Clone, PartialEq, ::prost::Message)]
49pub struct CodeGeneratorResponse {
50    /// Error message.  If non-empty, code generation failed.  The plugin process
51    /// should exit with status code zero even if it reports an error in this way.
52    ///
53    /// This should be used to indicate errors in .proto files which prevent the
54    /// code generator from generating correct code.  Errors which indicate a
55    /// problem in protoc itself -- such as the input CodeGeneratorRequest being
56    /// unparseable -- should be reported by writing a message to stderr and
57    /// exiting with a non-zero status code.
58    #[prost(string, optional, tag = "1")]
59    pub error: ::core::option::Option<::prost::alloc::string::String>,
60    /// A bitmask of supported features that the code generator supports.
61    /// This is a bitwise "or" of values from the Feature enum.
62    #[prost(uint64, optional, tag = "2")]
63    pub supported_features: ::core::option::Option<u64>,
64    #[prost(message, repeated, tag = "15")]
65    pub file: ::prost::alloc::vec::Vec<code_generator_response::File>,
66}
67/// Nested message and enum types in `CodeGeneratorResponse`.
68pub mod code_generator_response {
69    /// Represents a single generated file.
70    #[derive(Clone, PartialEq, ::prost::Message)]
71    pub struct File {
72        /// The file name, relative to the output directory.  The name must not
73        /// contain "." or ".." components and must be relative, not be absolute (so,
74        /// the file cannot lie outside the output directory).  "/" must be used as
75        /// the path separator, not "".
76        ///
77        /// If the name is omitted, the content will be appended to the previous
78        /// file.  This allows the generator to break large files into small chunks,
79        /// and allows the generated text to be streamed back to protoc so that large
80        /// files need not reside completely in memory at one time.  Note that as of
81        /// this writing protoc does not optimize for this -- it will read the entire
82        /// CodeGeneratorResponse before writing files to disk.
83        #[prost(string, optional, tag = "1")]
84        pub name: ::core::option::Option<::prost::alloc::string::String>,
85        /// If non-empty, indicates that the named file should already exist, and the
86        /// content here is to be inserted into that file at a defined insertion
87        /// point.  This feature allows a code generator to extend the output
88        /// produced by another code generator.  The original generator may provide
89        /// insertion points by placing special annotations in the file that look
90        /// like:
91        /// @@protoc_insertion_point(NAME)
92        /// The annotation can have arbitrary text before and after it on the line,
93        /// which allows it to be placed in a comment.  NAME should be replaced with
94        /// an identifier naming the point -- this is what other generators will use
95        /// as the insertion_point.  Code inserted at this point will be placed
96        /// immediately above the line containing the insertion point (thus multiple
97        /// insertions to the same point will come out in the order they were added).
98        /// The double-@ is intended to make it unlikely that the generated code
99        /// could contain things that look like insertion points by accident.
100        ///
101        /// For example, the C++ code generator places the following line in the
102        /// .pb.h files that it generates:
103        /// // @@protoc_insertion_point(namespace_scope)
104        /// This line appears within the scope of the file's package namespace, but
105        /// outside of any particular class.  Another plugin can then specify the
106        /// insertion_point "namespace_scope" to generate additional classes or
107        /// other declarations that should be placed in this scope.
108        ///
109        /// Note that if the line containing the insertion point begins with
110        /// whitespace, the same whitespace will be added to every line of the
111        /// inserted text.  This is useful for languages like Python, where
112        /// indentation matters.  In these languages, the insertion point comment
113        /// should be indented the same amount as any inserted code will need to be
114        /// in order to work correctly in that context.
115        ///
116        /// The code generator that generates the initial file and the one which
117        /// inserts into it must both run as part of a single invocation of protoc.
118        /// Code generators are executed in the order in which they appear on the
119        /// command line.
120        ///
121        /// If |insertion_point| is present, |name| must also be present.
122        #[prost(string, optional, tag = "2")]
123        pub insertion_point: ::core::option::Option<::prost::alloc::string::String>,
124        /// The file contents.
125        #[prost(string, optional, tag = "15")]
126        pub content: ::core::option::Option<::prost::alloc::string::String>,
127        /// Information describing the file content being inserted. If an insertion
128        /// point is used, this information will be appropriately offset and inserted
129        /// into the code generation metadata for the generated files.
130        #[prost(message, optional, tag = "16")]
131        pub generated_code_info: ::core::option::Option<super::super::GeneratedCodeInfo>,
132    }
133    /// Sync with code_generator.h.
134    #[derive(
135        Clone,
136        Copy,
137        Debug,
138        PartialEq,
139        Eq,
140        Hash,
141        PartialOrd,
142        Ord,
143        ::prost::Enumeration
144    )]
145    #[repr(i32)]
146    pub enum Feature {
147        None = 0,
148        Proto3Optional = 1,
149    }
150    impl Feature {
151        /// String value of the enum field names used in the ProtoBuf definition.
152        ///
153        /// The values are not transformed in any way and thus are considered stable
154        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
155        pub fn as_str_name(&self) -> &'static str {
156            match self {
157                Self::None => "FEATURE_NONE",
158                Self::Proto3Optional => "FEATURE_PROTO3_OPTIONAL",
159            }
160        }
161        /// Creates an enum from field names used in the ProtoBuf definition.
162        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
163            match value {
164                "FEATURE_NONE" => Some(Self::None),
165                "FEATURE_PROTO3_OPTIONAL" => Some(Self::Proto3Optional),
166                _ => None,
167            }
168        }
169    }
170}