Skip to content

Commit

Permalink
Change generated functions signatures to remove type parameters (res…
Browse files Browse the repository at this point in the history
…t of ::prost::Message trait)
  • Loading branch information
shizzard committed Apr 30, 2024
1 parent ea05101 commit 943fd96
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions prost/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B>(&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();
Expand All @@ -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<B>(&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();
Expand Down Expand Up @@ -106,19 +104,17 @@ pub trait Message: Debug + Send + Sync {
/// Decodes an instance of the message from a buffer.
///
/// The entire buffer will be consumed.
fn decode<B>(mut buf: B) -> Result<Self, DecodeError>
fn decode(mut buf: impl Buf) -> Result<Self, DecodeError>
where
B: Buf,
Self: Default,
{
let mut message = Self::default();
Self::merge(&mut message, &mut buf).map(|_| message)
}

/// Decodes a length-delimited instance of the message from the buffer.
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where
B: Buf,
Self: Default,
{
let mut message = Self::default();
Expand All @@ -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<B>(&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();
Expand All @@ -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<B>(&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(
Expand Down

0 comments on commit 943fd96

Please sign in to comment.