Repository navigation
Expand file tree
/
Copy pathoutgoing_encode.rs
More file actions
68 lines (58 loc) · 1.48 KB
/
Copy pathoutgoing_encode.rs
File metadata and controls
68 lines (58 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use anyhow::Result;
use packet_core::OutgoingPacket;
use packet_macros::{OutgoingFields, Packet};
use serde::Deserialize;
#[derive(Debug, Packet)]
#[packet(event = "po", allow_extra)]
pub struct Ping {}
#[derive(Debug, Packet)]
#[packet(event = "sb", allow_extra)]
pub struct SB {
pub s1: String,
pub s2: String,
}
#[derive(Debug, Deserialize, OutgoingFields)]
pub struct EnterGameLoadout {
pub class_index: i64,
pub spray_index: i64,
pub hat_index: i64,
pub body_index: i64,
}
#[derive(Debug, Packet)]
#[packet(event = "en", allow_extra)]
pub struct EnterGame {
#[packet(nested)]
pub loadout: EnterGameLoadout,
pub sixteen: i64,
#[packet(coerce(bool_to_num))]
pub has_scene_hook: bool,
}
#[derive(Debug, Packet)]
#[packet(event = "testPacket", allow_extra)]
pub struct TestFlag {
#[packet(coerce(bool_to_num))]
pub flag: bool,
}
fn main() -> Result<()> {
let ping = Ping {};
println!("po -> {:?}", ping.to_values()?);
let sb = SB {
s1: "welc".into(),
s2: "hello".into(),
};
println!("sb -> {:?}", sb.to_values()?);
let enter = EnterGame {
loadout: EnterGameLoadout {
class_index: 0,
spray_index: 0,
hat_index: -1,
body_index: -1,
},
sixteen: 16,
has_scene_hook: false,
};
println!("en -> {:?}", enter.to_values()?);
let test = TestFlag { flag: true };
println!("tp -> {:?}", test.to_values()?);
Ok(())
}