@@ -29,6 +29,10 @@ pub struct Customize {
29
29
/// Used internally to generate protos bundled in protobuf crate
30
30
/// like `descriptor.proto`
31
31
pub inside_protobuf : Option < bool > ,
32
+ /// Generate code suitable for compiling as a root module
33
+ pub root_module : Option < bool > ,
34
+ /// Wrap output file in the named module
35
+ pub wrap_in_module : Option < String > ,
32
36
33
37
// When adding more options please keep in sync with `parse_from_parameter` below.
34
38
/// Make sure `Customize` is always used with `..Default::default()`
@@ -78,6 +82,12 @@ impl Customize {
78
82
if let Some ( v) = that. inside_protobuf {
79
83
self . inside_protobuf = Some ( v) ;
80
84
}
85
+ if let Some ( v) = that. root_module {
86
+ self . root_module = Some ( v) ;
87
+ }
88
+ if let Some ( ref v) = that. wrap_in_module {
89
+ self . wrap_in_module = Some ( v. clone ( ) ) ;
90
+ }
81
91
}
82
92
83
93
/// Update unset fields of self with fields from other customize
@@ -124,6 +134,10 @@ impl Customize {
124
134
r. lite_runtime = Some ( parse_bool ( v) ?) ;
125
135
} else if n == "inside_protobuf" {
126
136
r. inside_protobuf = Some ( parse_bool ( v) ?) ;
137
+ } else if n == "root_module" {
138
+ r. root_module = Some ( parse_bool ( v) ?) ;
139
+ } else if n == "wrap_in_module" {
140
+ r. wrap_in_module = Some ( v. to_owned ( ) ) ;
127
141
} else {
128
142
return Err ( CustomizeParseParameterError :: UnknownOptionName (
129
143
n. to_owned ( ) ,
@@ -145,6 +159,8 @@ pub fn customize_from_rustproto_for_message(source: &MessageOptions) -> Customiz
145
159
let serde_derive_cfg = rustproto:: exts:: serde_derive_cfg. get ( source) ;
146
160
let lite_runtime = None ;
147
161
let inside_protobuf = None ;
162
+ let root_module = None ;
163
+ let wrap_in_module = None ;
148
164
Customize {
149
165
expose_oneof,
150
166
expose_fields,
@@ -156,6 +172,8 @@ pub fn customize_from_rustproto_for_message(source: &MessageOptions) -> Customiz
156
172
serde_derive_cfg,
157
173
lite_runtime,
158
174
inside_protobuf,
175
+ root_module,
176
+ wrap_in_module,
159
177
_future_options : ( ) ,
160
178
}
161
179
}
@@ -172,6 +190,8 @@ pub fn customize_from_rustproto_for_field(source: &FieldOptions) -> Customize {
172
190
let serde_derive_cfg = None ;
173
191
let lite_runtime = None ;
174
192
let inside_protobuf = None ;
193
+ let root_module = None ;
194
+ let wrap_in_module = None ;
175
195
Customize {
176
196
expose_oneof,
177
197
expose_fields,
@@ -183,6 +203,8 @@ pub fn customize_from_rustproto_for_field(source: &FieldOptions) -> Customize {
183
203
serde_derive_cfg,
184
204
lite_runtime,
185
205
inside_protobuf,
206
+ root_module,
207
+ wrap_in_module,
186
208
_future_options : ( ) ,
187
209
}
188
210
}
@@ -198,6 +220,8 @@ pub fn customize_from_rustproto_for_file(source: &FileOptions) -> Customize {
198
220
let serde_derive_cfg = rustproto:: exts:: serde_derive_cfg_all. get ( source) ;
199
221
let lite_runtime = rustproto:: exts:: lite_runtime_all. get ( source) ;
200
222
let inside_protobuf = None ;
223
+ let root_module = None ;
224
+ let wrap_in_module = None ;
201
225
Customize {
202
226
expose_oneof,
203
227
expose_fields,
@@ -209,6 +233,8 @@ pub fn customize_from_rustproto_for_file(source: &FileOptions) -> Customize {
209
233
serde_derive_cfg,
210
234
lite_runtime,
211
235
inside_protobuf,
236
+ root_module,
237
+ wrap_in_module,
212
238
_future_options : ( ) ,
213
239
}
214
240
}
0 commit comments