From 44e291ee09239f899506b5d764cbca225e3d1bcb Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Fri, 12 Jun 2026 20:59:32 +0800 Subject: [PATCH] prost: relax codec Default bounds Manually implement Default for ProstEncoder and ProstDecoder so their message types do not need to implement Default. Fixes: #2458 --- tonic-prost/src/codec.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tonic-prost/src/codec.rs b/tonic-prost/src/codec.rs index f25bb6d43..8418fe5ae 100644 --- a/tonic-prost/src/codec.rs +++ b/tonic-prost/src/codec.rs @@ -74,7 +74,7 @@ where } /// A [`Encoder`] that knows how to encode `T`. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct ProstEncoder { _pd: PhantomData, buffer_settings: BufferSettings, @@ -90,6 +90,12 @@ impl ProstEncoder { } } +impl Default for ProstEncoder { + fn default() -> Self { + Self::new(Default::default()) + } +} + impl Encoder for ProstEncoder { type Item = T; type Error = Status; @@ -107,7 +113,7 @@ impl Encoder for ProstEncoder { } /// A [`Decoder`] that knows how to decode `U`. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct ProstDecoder { _pd: PhantomData, buffer_settings: BufferSettings, @@ -123,6 +129,12 @@ impl ProstDecoder { } } +impl Default for ProstDecoder { + fn default() -> Self { + Self::new(Default::default()) + } +} + impl Decoder for ProstDecoder { type Item = U; type Error = Status;