diff --git a/tonic-build/src/prost.rs b/tonic-build/src/prost.rs index 623705b72..6c89dc8fa 100644 --- a/tonic-build/src/prost.rs +++ b/tonic-build/src/prost.rs @@ -26,6 +26,7 @@ pub fn configure() -> Builder { message_attributes: Vec::new(), enum_attributes: Vec::new(), type_attributes: Vec::new(), + boxed: Vec::new(), server_attributes: Attributes::default(), client_attributes: Attributes::default(), proto_path: "super".to_string(), @@ -229,6 +230,7 @@ pub struct Builder { pub(crate) type_attributes: Vec<(String, String)>, pub(crate) message_attributes: Vec<(String, String)>, pub(crate) enum_attributes: Vec<(String, String)>, + pub(crate) boxed: Vec, pub(crate) server_attributes: Attributes, pub(crate) client_attributes: Attributes, pub(crate) proto_path: String, @@ -332,6 +334,15 @@ impl Builder { self } + /// Add additional boxed fields. + /// + /// Passed directly to `prost_build::Config.boxed`. + pub fn boxed>(mut self, path: P) -> Self { + self.boxed + .push(path.as_ref().to_string()); + self + } + /// Add additional attribute to matched server `mod`s. Matches on the package name. pub fn server_mod_attribute, A: AsRef>( mut self, @@ -479,6 +490,9 @@ impl Builder { for (prost_path, attr) in self.enum_attributes.iter() { config.enum_attribute(prost_path, attr); } + for prost_path in self.boxed.iter() { + config.boxed(prost_path); + } if self.compile_well_known_types { config.compile_well_known_types(); }