Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tonic-prost/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
}

/// A [`Encoder`] that knows how to encode `T`.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct ProstEncoder<T> {
_pd: PhantomData<T>,
buffer_settings: BufferSettings,
Expand All @@ -90,6 +90,12 @@ impl<T> ProstEncoder<T> {
}
}

impl<T> Default for ProstEncoder<T> {
fn default() -> Self {
Self::new(Default::default())
}
}

impl<T: Message> Encoder for ProstEncoder<T> {
type Item = T;
type Error = Status;
Expand All @@ -107,7 +113,7 @@ impl<T: Message> Encoder for ProstEncoder<T> {
}

/// A [`Decoder`] that knows how to decode `U`.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct ProstDecoder<U> {
_pd: PhantomData<U>,
buffer_settings: BufferSettings,
Expand All @@ -123,6 +129,12 @@ impl<U> ProstDecoder<U> {
}
}

impl<U> Default for ProstDecoder<U> {
fn default() -> Self {
Self::new(Default::default())
}
}

impl<U: Message + Default> Decoder for ProstDecoder<U> {
type Item = U;
type Error = Status;
Expand Down
Loading