aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.rs')
-rw-r--r--src/protocol.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/protocol.rs b/src/protocol.rs
index 816d20b..7355ed0 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -199,21 +199,20 @@ macro_rules! define_protocol {
use self::$statet::*;
use self::$directiont::*;
use crate::protocol::PacketErr::*;
- use crate::Deserialize;
+ use crate::{Deserialize, Deserialized};
let id = raw.id;
let data = raw.data;
match (id.id, id.state, id.direction) {
- $(($id, $state, $direction) => Ok($nam({
- let deserialized = $body::mc_deserialize(data).map_err(DeserializeFailed)?;
- let rest = deserialized.data;
+ $(($id, $state, $direction) => {
+ let Deserialized { value: body, data: rest } = $body::mc_deserialize(data).map_err(DeserializeFailed)?;
if !rest.is_empty() {
- return Err(ExtraData(rest.to_vec()))
+ Err(ExtraData(rest.to_vec()))
+ } else {
+ Ok($nam(body))
}
-
- deserialized.value
- }))),*,
+ }),*,
other => Err(UnknownId(other.0)),
}
}