From 943fd9604e66d982582fb1fe3ce7a752ce67a7a2 Mon Sep 17 00:00:00 2001 From: Denis Fakhrtdinov Date: Tue, 30 Apr 2024 16:37:37 +0300 Subject: [PATCH] Change generated functions signatures to remove type parameters (rest of ::prost::Message trait) --- prost/src/message.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/prost/src/message.rs b/prost/src/message.rs index fa03e9df1..a38e9f38f 100644 --- a/prost/src/message.rs +++ b/prost/src/message.rs @@ -45,9 +45,8 @@ pub trait Message: Debug + Send + Sync { /// Encodes the message to a buffer. /// /// An error will be returned if the buffer does not have sufficient capacity. - fn encode(&self, buf: &mut B) -> Result<(), EncodeError> + fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError> where - B: BufMut, Self: Sized, { let required = self.encoded_len(); @@ -74,9 +73,8 @@ pub trait Message: Debug + Send + Sync { /// Encodes the message with a length-delimiter to a buffer. /// /// An error will be returned if the buffer does not have sufficient capacity. - fn encode_length_delimited(&self, buf: &mut B) -> Result<(), EncodeError> + fn encode_length_delimited(&self, buf: &mut impl BufMut) -> Result<(), EncodeError> where - B: BufMut, Self: Sized, { let len = self.encoded_len(); @@ -106,9 +104,8 @@ pub trait Message: Debug + Send + Sync { /// Decodes an instance of the message from a buffer. /// /// The entire buffer will be consumed. - fn decode(mut buf: B) -> Result + fn decode(mut buf: impl Buf) -> Result where - B: Buf, Self: Default, { let mut message = Self::default(); @@ -116,9 +113,8 @@ pub trait Message: Debug + Send + Sync { } /// Decodes a length-delimited instance of the message from the buffer. - fn decode_length_delimited(buf: B) -> Result + fn decode_length_delimited(buf: impl Buf) -> Result where - B: Buf, Self: Default, { let mut message = Self::default(); @@ -129,9 +125,8 @@ pub trait Message: Debug + Send + Sync { /// Decodes an instance of the message from a buffer, and merges it into `self`. /// /// The entire buffer will be consumed. - fn merge(&mut self, mut buf: B) -> Result<(), DecodeError> + fn merge(&mut self, mut buf: impl Buf) -> Result<(), DecodeError> where - B: Buf, Self: Sized, { let ctx = DecodeContext::default(); @@ -144,9 +139,8 @@ pub trait Message: Debug + Send + Sync { /// Decodes a length-delimited instance of the message from buffer, and /// merges it into `self`. - fn merge_length_delimited(&mut self, mut buf: B) -> Result<(), DecodeError> + fn merge_length_delimited(&mut self, mut buf: impl Buf) -> Result<(), DecodeError> where - B: Buf, Self: Sized, { message::merge(