prost_types/
compiler.rs

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