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