|
|
@ -12,9 +12,12 @@ use std::io::{Read, Seek}; |
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum PacketParseError {
|
|
|
|
NotEnoughBytes,
|
|
|
|
WrongPacketCommand,
|
|
|
|
WrongPacketCommand {expected: u16, got: u16},
|
|
|
|
WrongPacketForServerType(u16, Vec<u8>),
|
|
|
|
UnknownPacket(u16, Vec<u8>),
|
|
|
|
WrongPacketSize(u16, usize),
|
|
|
|
WrongMessageCommand {expected: u8, got: u8},
|
|
|
|
UnknownMessage(u8, Vec<u8>),
|
|
|
|
DataStructNotLargeEnough(u64, usize),
|
|
|
|
InvalidValue,
|
|
|
|
ReadError,
|
|
|
@ -336,7 +339,7 @@ mod test { |
|
|
|
let mut bytes = test.as_bytes();
|
|
|
|
bytes[2] = 17;
|
|
|
|
let test2 = Test::from_bytes(&bytes);
|
|
|
|
assert!(test2 == Err(PacketParseError::WrongPacketCommand));
|
|
|
|
assert!(test2 == Err(PacketParseError::WrongPacketCommand { expected: 0x23, got: 17}));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|