Skip to content

Commit

Permalink
fix(codec): Enforce encoders/decoders are Sync
Browse files Browse the repository at this point in the history
Closes #81
  • Loading branch information
LucioFranco committed Oct 21, 2019
1 parent 5d0a795 commit 8317a8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions tonic/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BUFFER_SIZE: usize = 8 * 1024;
/// This will wrap some inner [`Body`] and [`Decoder`] and provide an interface
/// to fetch the message stream and trailing metadata
pub struct Streaming<T> {
decoder: Box<dyn Decoder<Item = T, Error = Status> + Send + 'static>,
decoder: Box<dyn Decoder<Item = T, Error = Status> + Sync + Send + 'static>,
body: BoxBody,
state: State,
direction: Direction,
Expand Down Expand Up @@ -48,7 +48,7 @@ impl<T> Streaming<T> {
B: Body + Send + 'static,
B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
D: Decoder<Item = T, Error = Status> + Sync + Send + 'static,
{
Self::new(decoder, body, Direction::Response(status_code))
}
Expand All @@ -58,7 +58,7 @@ impl<T> Streaming<T> {
B: Body + Send + 'static,
B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
D: Decoder<Item = T, Error = Status> + Sync + Send + 'static,
{
Self::new(decoder, body, Direction::EmptyResponse)
}
Expand All @@ -68,7 +68,7 @@ impl<T> Streaming<T> {
B: Body + Send + 'static,
B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
D: Decoder<Item = T, Error = Status> + Sync + Send + 'static,
{
Self::new(decoder, body, Direction::Request)
}
Expand All @@ -78,7 +78,7 @@ impl<T> Streaming<T> {
B: Body + Send + 'static,
B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + 'static,
D: Decoder<Item = T, Error = Status> + Sync + Send + 'static,
{
Self {
decoder: Box::new(decoder),
Expand Down
4 changes: 2 additions & 2 deletions tonic/src/codec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ pub trait Codec {
type Decode: Send + 'static;

/// The encoder that can encode a message.
type Encoder: Encoder<Item = Self::Encode, Error = Status> + Send + 'static;
type Encoder: Encoder<Item = Self::Encode, Error = Status> + Sync + Send + 'static;
/// The encoder that can decode a message.
type Decoder: Decoder<Item = Self::Decode, Error = Status> + Send + 'static;
type Decoder: Decoder<Item = Self::Decode, Error = Status> + Sync + Send + 'static;

/// The content type of this codec.
///
Expand Down

0 comments on commit 8317a8c

Please sign in to comment.