From d4bd4758dd80135f89d3e559c5d7f42ccbbab504 Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Thu, 31 Mar 2022 20:52:38 +0200 Subject: [PATCH] feat(build): Expose Prost generation plugin (#947) --- tonic-build/src/prost.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tonic-build/src/prost.rs b/tonic-build/src/prost.rs index 2c74ed5cf..750bcd677 100644 --- a/tonic-build/src/prost.rs +++ b/tonic-build/src/prost.rs @@ -412,10 +412,16 @@ impl Builder { config.protoc_arg(arg); } - config.service_generator(Box::new(ServiceGenerator::new(self))); + config.service_generator(self.service_generator()); config.compile_protos(protos, includes)?; Ok(()) } + + /// Turn the builder into a `ServiceGenerator` ready to be passed to `prost-build`s + /// `Config::service_generator`. + pub fn service_generator(self) -> Box { + Box::new(ServiceGenerator::new(self)) + } }