tonic-build: support boxing fields (#1252)
This exposes https://github.com/tokio-rs/prost/pull/802 in Tonic, though obviously until that's merged and released this diff does nothing. Co-authored-by: Lucio Franco <[email protected]>
This commit is contained in:
co-authored by
Lucio Franco
parent
9990e6ef9d
commit
65d909e850
@@ -27,6 +27,7 @@ pub fn configure() -> Builder {
|
|||||||
message_attributes: Vec::new(),
|
message_attributes: Vec::new(),
|
||||||
enum_attributes: Vec::new(),
|
enum_attributes: Vec::new(),
|
||||||
type_attributes: Vec::new(),
|
type_attributes: Vec::new(),
|
||||||
|
boxed: Vec::new(),
|
||||||
server_attributes: Attributes::default(),
|
server_attributes: Attributes::default(),
|
||||||
client_attributes: Attributes::default(),
|
client_attributes: Attributes::default(),
|
||||||
proto_path: "super".to_string(),
|
proto_path: "super".to_string(),
|
||||||
@@ -231,6 +232,7 @@ pub struct Builder {
|
|||||||
pub(crate) type_attributes: Vec<(String, String)>,
|
pub(crate) type_attributes: Vec<(String, String)>,
|
||||||
pub(crate) message_attributes: Vec<(String, String)>,
|
pub(crate) message_attributes: Vec<(String, String)>,
|
||||||
pub(crate) enum_attributes: Vec<(String, String)>,
|
pub(crate) enum_attributes: Vec<(String, String)>,
|
||||||
|
pub(crate) boxed: Vec<String>,
|
||||||
pub(crate) server_attributes: Attributes,
|
pub(crate) server_attributes: Attributes,
|
||||||
pub(crate) client_attributes: Attributes,
|
pub(crate) client_attributes: Attributes,
|
||||||
pub(crate) proto_path: String,
|
pub(crate) proto_path: String,
|
||||||
@@ -342,6 +344,14 @@ impl Builder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add additional boxed fields.
|
||||||
|
///
|
||||||
|
/// Passed directly to `prost_build::Config.boxed`.
|
||||||
|
pub fn boxed<P: AsRef<str>>(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.
|
/// Add additional attribute to matched server `mod`s. Matches on the package name.
|
||||||
pub fn server_mod_attribute<P: AsRef<str>, A: AsRef<str>>(
|
pub fn server_mod_attribute<P: AsRef<str>, A: AsRef<str>>(
|
||||||
mut self,
|
mut self,
|
||||||
@@ -492,6 +502,9 @@ impl Builder {
|
|||||||
for (prost_path, attr) in self.enum_attributes.iter() {
|
for (prost_path, attr) in self.enum_attributes.iter() {
|
||||||
config.enum_attribute(prost_path, attr);
|
config.enum_attribute(prost_path, attr);
|
||||||
}
|
}
|
||||||
|
for prost_path in self.boxed.iter() {
|
||||||
|
config.boxed(prost_path);
|
||||||
|
}
|
||||||
if self.compile_well_known_types {
|
if self.compile_well_known_types {
|
||||||
config.compile_well_known_types();
|
config.compile_well_known_types();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user