1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 18:44:12 +02:00

add serde support for packets

This commit is contained in:
Robin Appelman 2021-07-25 15:09:36 +02:00
commit 03f8b8a424
27 changed files with 556 additions and 490 deletions

View file

@ -58,7 +58,7 @@ impl From<&str> for SendPropName {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RawSendPropDefinition {
pub prop_type: SendPropType,
pub name: SendPropName,
@ -252,7 +252,7 @@ impl BitWrite<LittleEndian> for RawSendPropDefinition {
}
}
#[derive(BitRead, BitWrite, Copy, Clone, PartialEq, Debug, Display)]
#[derive(BitRead, BitWrite, Copy, Clone, PartialEq, Debug, Display, Serialize, Deserialize)]
#[discriminant_bits = 5]
pub enum SendPropType {
Int = 0,
@ -310,7 +310,7 @@ pub enum SendPropFlag {
NormalVarInt = 32,
}
#[derive(Debug, Copy, Clone, PartialEq, Default)]
#[derive(Debug, Copy, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct SendPropFlags(BitFlags<SendPropFlag>);
impl BitOr<SendPropFlag> for SendPropFlags {
@ -356,7 +356,7 @@ impl BitWrite<LittleEndian> for SendPropFlags {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FloatDefinition {
Coord,
CoordMP,
@ -398,7 +398,7 @@ impl FloatDefinition {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendPropDefinition {
pub identifier: SendPropIdentifier,
pub parse_definition: SendPropParseDefinition,
@ -416,7 +416,7 @@ impl TryFrom<&RawSendPropDefinition> for SendPropDefinition {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SendPropParseDefinition {
NormalVarInt {
changes_often: bool,
@ -1068,7 +1068,9 @@ impl<'a> TryFrom<&'a SendPropValue> for &'a [SendPropValue] {
}
}
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash, Display)]
#[derive(
Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash, Display, Serialize, Deserialize,
)]
pub struct SendPropIdentifier(u64);
impl SendPropIdentifier {
@ -1084,7 +1086,7 @@ impl From<u64> for SendPropIdentifier {
}
}
#[derive(Debug, Clone, Display, PartialEq)]
#[derive(Debug, Clone, Display, PartialEq, Serialize, Deserialize)]
#[display("{index} = {value}")]
pub struct SendProp {
pub index: u32,