wow_world_messages/world/wrath/
cmsg_battlefield_mgr_queue_invite_response.rs1use std::io::{Read, Write};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
11pub struct CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {
12 pub battle_id: u32,
13 pub accepted: bool,
14}
15
16impl crate::private::Sealed for CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {}
17impl CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {
18 fn read_inner(mut r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseErrorKind> {
19 if body_size != 5 {
20 return Err(crate::errors::ParseErrorKind::InvalidSize);
21 }
22
23 let battle_id = crate::util::read_u32_le(&mut r)?;
25
26 let accepted = crate::util::read_bool_u8(&mut r)?;
28
29 Ok(Self {
30 battle_id,
31 accepted,
32 })
33 }
34
35}
36
37impl crate::Message for CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {
38 const OPCODE: u32 = 0x04e2;
39
40 #[cfg(feature = "print-testcase")]
41 fn message_name(&self) -> &'static str {
42 "CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE"
43 }
44
45 #[cfg(feature = "print-testcase")]
46 fn to_test_case_string(&self) -> Option<String> {
47 use std::fmt::Write;
48 use crate::traits::Message;
49
50 let mut s = String::new();
51
52 writeln!(s, "test CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {{").unwrap();
53 writeln!(s, " battle_id = {};", self.battle_id).unwrap();
55 writeln!(s, " accepted = {};", if self.accepted { "TRUE" } else { "FALSE" }).unwrap();
56
57 writeln!(s, "}} [").unwrap();
58
59 let [a, b] = 9_u16.to_be_bytes();
60 writeln!(s, " {a:#04X}, {b:#04X}, /* size */").unwrap();
61 let [a, b, c, d] = 1250_u32.to_le_bytes();
62 writeln!(s, " {a:#04X}, {b:#04X}, {c:#04X}, {d:#04X}, /* opcode */").unwrap();
63 let mut bytes: Vec<u8> = Vec::new();
64 self.write_into_vec(&mut bytes).unwrap();
65 let mut bytes = bytes.into_iter();
66
67 crate::util::write_bytes(&mut s, &mut bytes, 4, "battle_id", " ");
68 crate::util::write_bytes(&mut s, &mut bytes, 1, "accepted", " ");
69
70
71 writeln!(s, "] {{").unwrap();
72 writeln!(s, " versions = \"{}\";", std::env::var("WOWM_TEST_CASE_WORLD_VERSION").unwrap_or("3.3.5".to_string())).unwrap();
73 writeln!(s, "}}\n").unwrap();
74
75 Some(s)
76 }
77
78 fn size_without_header(&self) -> u32 {
79 5
80 }
81
82 fn write_into_vec(&self, mut w: impl Write) -> Result<(), std::io::Error> {
83 w.write_all(&self.battle_id.to_le_bytes())?;
85
86 w.write_all(u8::from(self.accepted).to_le_bytes().as_slice())?;
88
89 Ok(())
90 }
91
92 fn read_body<S: crate::private::Sealed>(r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseError> {
93 Self::read_inner(r, body_size).map_err(|a| crate::errors::ParseError::new(1250, "CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE", body_size, a))
94 }
95
96}
97
98#[cfg(feature = "wrath")]
99impl crate::wrath::ClientMessage for CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE {}
100