@@ -23,6 +23,8 @@ pub fn configure() -> Builder {
23
23
out_dir : None ,
24
24
extern_path : Vec :: new ( ) ,
25
25
field_attributes : Vec :: new ( ) ,
26
+ message_attributes : Vec :: new ( ) ,
27
+ enum_attributes : Vec :: new ( ) ,
26
28
type_attributes : Vec :: new ( ) ,
27
29
server_attributes : Attributes :: default ( ) ,
28
30
client_attributes : Attributes :: default ( ) ,
@@ -225,6 +227,8 @@ pub struct Builder {
225
227
pub ( crate ) extern_path : Vec < ( String , String ) > ,
226
228
pub ( crate ) field_attributes : Vec < ( String , String ) > ,
227
229
pub ( crate ) type_attributes : Vec < ( String , String ) > ,
230
+ pub ( crate ) message_attributes : Vec < ( String , String ) > ,
231
+ pub ( crate ) enum_attributes : Vec < ( String , String ) > ,
228
232
pub ( crate ) server_attributes : Attributes ,
229
233
pub ( crate ) client_attributes : Attributes ,
230
234
pub ( crate ) proto_path : String ,
@@ -306,6 +310,28 @@ impl Builder {
306
310
self
307
311
}
308
312
313
+ /// Add additional attribute to matched messages.
314
+ ///
315
+ /// Passed directly to `prost_build::Config.message_attribute`.
316
+ pub fn message_attribute < P : AsRef < str > , A : AsRef < str > > (
317
+ mut self ,
318
+ path : P ,
319
+ attribute : A ,
320
+ ) -> Self {
321
+ self . message_attributes
322
+ . push ( ( path. as_ref ( ) . to_string ( ) , attribute. as_ref ( ) . to_string ( ) ) ) ;
323
+ self
324
+ }
325
+
326
+ /// Add additional attribute to matched enums.
327
+ ///
328
+ /// Passed directly to `prost_build::Config.enum_attribute`.
329
+ pub fn enum_attribute < P : AsRef < str > , A : AsRef < str > > ( mut self , path : P , attribute : A ) -> Self {
330
+ self . enum_attributes
331
+ . push ( ( path. as_ref ( ) . to_string ( ) , attribute. as_ref ( ) . to_string ( ) ) ) ;
332
+ self
333
+ }
334
+
309
335
/// Add additional attribute to matched server `mod`s. Matches on the package name.
310
336
pub fn server_mod_attribute < P : AsRef < str > , A : AsRef < str > > (
311
337
mut self ,
@@ -447,6 +473,12 @@ impl Builder {
447
473
for ( prost_path, attr) in self . type_attributes . iter ( ) {
448
474
config. type_attribute ( prost_path, attr) ;
449
475
}
476
+ for ( prost_path, attr) in self . message_attributes . iter ( ) {
477
+ config. message_attribute ( prost_path, attr) ;
478
+ }
479
+ for ( prost_path, attr) in self . enum_attributes . iter ( ) {
480
+ config. enum_attribute ( prost_path, attr) ;
481
+ }
450
482
if self . compile_well_known_types {
451
483
config. compile_well_known_types ( ) ;
452
484
}
0 commit comments