Skip to content

Commit 65d909e

Browse files
krallinLucioFranco
andauthored
tonic-build: support boxing fields (#1252)
This exposes tokio-rs/prost#802 in Tonic, though obviously until that's merged and released this diff does nothing. Co-authored-by: Lucio Franco <[email protected]>
1 parent 9990e6e commit 65d909e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tonic-build/src/prost.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub fn configure() -> Builder {
2727
message_attributes: Vec::new(),
2828
enum_attributes: Vec::new(),
2929
type_attributes: Vec::new(),
30+
boxed: Vec::new(),
3031
server_attributes: Attributes::default(),
3132
client_attributes: Attributes::default(),
3233
proto_path: "super".to_string(),
@@ -231,6 +232,7 @@ pub struct Builder {
231232
pub(crate) type_attributes: Vec<(String, String)>,
232233
pub(crate) message_attributes: Vec<(String, String)>,
233234
pub(crate) enum_attributes: Vec<(String, String)>,
235+
pub(crate) boxed: Vec<String>,
234236
pub(crate) server_attributes: Attributes,
235237
pub(crate) client_attributes: Attributes,
236238
pub(crate) proto_path: String,
@@ -342,6 +344,14 @@ impl Builder {
342344
self
343345
}
344346

347+
/// Add additional boxed fields.
348+
///
349+
/// Passed directly to `prost_build::Config.boxed`.
350+
pub fn boxed<P: AsRef<str>>(mut self, path: P) -> Self {
351+
self.boxed.push(path.as_ref().to_string());
352+
self
353+
}
354+
345355
/// Add additional attribute to matched server `mod`s. Matches on the package name.
346356
pub fn server_mod_attribute<P: AsRef<str>, A: AsRef<str>>(
347357
mut self,
@@ -492,6 +502,9 @@ impl Builder {
492502
for (prost_path, attr) in self.enum_attributes.iter() {
493503
config.enum_attribute(prost_path, attr);
494504
}
505+
for prost_path in self.boxed.iter() {
506+
config.boxed(prost_path);
507+
}
495508
if self.compile_well_known_types {
496509
config.compile_well_known_types();
497510
}

0 commit comments

Comments
 (0)