|
@@ -1590,22 +1590,25 @@ fn protocol_macro(
|
|
|
let decls = clientstate_fields.field_decls();
|
|
|
quote! {
|
|
|
#[serde_as]
|
|
|
- #[derive(Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
+ #[derive(bincode::Encode, bincode::Decode, Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
pub struct ClientState {
|
|
|
#decls
|
|
|
}
|
|
|
|
|
|
impl TryFrom<&[u8]> for ClientState {
|
|
|
- type Error = bincode::error::Error;
|
|
|
+ type Error = bincode::error::DecodeError;
|
|
|
|
|
|
- fn try_from(bytes: &[u8]) -> bincode::Result<ClientState> {
|
|
|
- bincode::decode_from_slice::<ClientState>(bytes)
|
|
|
+ fn try_from(bytes: &[u8]) -> Result<ClientState, bincode::error::DecodeError> {
|
|
|
+ match bincode::serde::decode_from_slice::<ClientState, bincode::config::Configuration>(bytes, bincode::config::legacy()) {
|
|
|
+ Ok(result) => Ok(result.0),
|
|
|
+ Err(_) => bincode::error::DecodeError,
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
impl From<&ClientState> for Vec<u8> {
|
|
|
fn from(req: &ClientState) -> Vec<u8> {
|
|
|
- bincode::encode_to_vec(req).unwrap();
|
|
|
+ bincode::serde::encode_to_vec(req,bincode::config::legacy()).unwrap();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1623,22 +1626,25 @@ fn protocol_macro(
|
|
|
let repdecls = reply_fields.field_decls();
|
|
|
quote! {
|
|
|
#[serde_as]
|
|
|
- #[derive(Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
+ #[derive(bincode::Encode, bincode::Decode, Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
pub struct Request {
|
|
|
#reqdecls
|
|
|
}
|
|
|
|
|
|
impl TryFrom<&[u8]> for Request {
|
|
|
- type Error = bincode::error::Error;
|
|
|
+ type Error = bincode::error::DecodeError;
|
|
|
|
|
|
- fn try_from(bytes: &[u8]) -> bincode::Result<Request> {
|
|
|
- bincode::deserialize::<Request>(bytes)
|
|
|
+ fn try_from(bytes: &[u8]) -> Result<Request, bincode::error::DecodeError> {
|
|
|
+ match bincode::serde::decode_from_slice::<Request, bincode::config::Configuration>(bytes, bincode::config::legacy()) {
|
|
|
+ Ok(result) => Ok(result.0),
|
|
|
+ Err(e) => bincode::error::DecodeError,
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
impl From<&Request> for Vec<u8> {
|
|
|
fn from(req: &Request) -> Vec<u8> {
|
|
|
- bincode::encode_to_vec(req).unwrap()
|
|
|
+ bincode::serde::encode_to_vec(req, bincode::config::legacy()).unwrap()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1649,22 +1655,26 @@ fn protocol_macro(
|
|
|
}
|
|
|
|
|
|
#[serde_as]
|
|
|
- #[derive(Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
+ #[derive(bincode::Encode, bincode::Decode, Clone,Debug,serde::Serialize,serde::Deserialize)]
|
|
|
pub struct Reply {
|
|
|
#repdecls
|
|
|
}
|
|
|
|
|
|
impl TryFrom<&[u8]> for Reply {
|
|
|
- type Error = bincode::error::Error;
|
|
|
+ type Error = bincode::error::DecodeError;
|
|
|
|
|
|
- fn try_from(bytes: &[u8]) -> bincode::Result<Reply> {
|
|
|
- bincode::deserialize::<Reply>(bytes)
|
|
|
+ fn try_from(bytes: &[u8]) -> Result<(Reply, bincode::error::DecodeError>) {
|
|
|
+ match bincode::serde::decode_from_slice::<Reply, bincode::config::Configuration>(bytes, bincode::config::legacy()) {
|
|
|
+ Ok(result) => Ok(result.0),
|
|
|
+ Err(e) => bincode::error::DecodeError,
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
impl From<&Reply> for Vec<u8> {
|
|
|
fn from(rep: &Reply) -> Vec<u8> {
|
|
|
- bincode::encode_to_vec(rep).unwrap()
|
|
|
+ bincode::serde::encode_to_vec(rep, bincode::config::legacy()).unwrap()
|
|
|
}
|
|
|
}
|
|
|
|