diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/internal.rs | 2 | ||||
| -rw-r--r-- | src/protocol.rs | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/internal.rs b/src/internal.rs index a3c203a..7085d84 100644 --- a/src/internal.rs +++ b/src/internal.rs | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | pub use bincode; | 1 | pub use postcard; |
| 2 | pub use bytes; | 2 | pub use bytes; |
diff --git a/src/protocol.rs b/src/protocol.rs index baf886b..d789939 100644 --- a/src/protocol.rs +++ b/src/protocol.rs | |||
| @@ -76,8 +76,7 @@ impl Encoder<RpcMessage> for RpcMessageCodec { | |||
| 76 | item: RpcMessage, | 76 | item: RpcMessage, |
| 77 | dst: &mut bytes::BytesMut, | 77 | dst: &mut bytes::BytesMut, |
| 78 | ) -> std::result::Result<(), Self::Error> { | 78 | ) -> std::result::Result<(), Self::Error> { |
| 79 | let encoded = bincode::serde::encode_to_vec(&item, bincode::config::standard()) | 79 | let encoded = postcard::to_stdvec(&item).map_err(std::io::Error::other)?; |
| 80 | .map_err(std::io::Error::other)?; | ||
| 81 | let encoded = Bytes::from(encoded); | 80 | let encoded = Bytes::from(encoded); |
| 82 | self.0.encode(encoded, dst).map_err(std::io::Error::other)?; | 81 | self.0.encode(encoded, dst).map_err(std::io::Error::other)?; |
| 83 | Ok(()) | 82 | Ok(()) |
| @@ -95,9 +94,7 @@ impl Decoder for RpcMessageCodec { | |||
| 95 | ) -> std::result::Result<Option<Self::Item>, Self::Error> { | 94 | ) -> std::result::Result<Option<Self::Item>, Self::Error> { |
| 96 | match self.0.decode(src) { | 95 | match self.0.decode(src) { |
| 97 | Ok(Some(frame)) => { | 96 | Ok(Some(frame)) => { |
| 98 | let (message, _) = | 97 | let message = postcard::from_bytes(&frame).map_err(std::io::Error::other)?; |
| 99 | bincode::serde::decode_from_slice(&frame, bincode::config::standard()) | ||
| 100 | .map_err(std::io::Error::other)?; | ||
| 101 | Ok(Some(message)) | 98 | Ok(Some(message)) |
| 102 | } | 99 | } |
| 103 | Ok(None) => Ok(None), | 100 | Ok(None) => Ok(None), |
