wow_world_messages/world/wrath/
msg_move_stop_swim.rs

1use std::io::{Read, Write};
2
3use crate::Guid;
4use crate::wrath::{
5    MovementFlags, MovementInfo, TransportInfo, Vector3d,
6};
7
8/// Auto generated from the original `wowm` in file [`wow_message_parser/wowm/world/movement/msg/msg_move_stop_swim.wowm:13`](https://github.com/gtker/wow_messages/tree/main/wow_message_parser/wowm/world/movement/msg/msg_move_stop_swim.wowm#L13):
9/// ```text
10/// msg MSG_MOVE_STOP_SWIM = 0x00CB {
11///     PackedGuid guid;
12///     MovementInfo info;
13/// }
14/// ```
15#[derive(Debug, Clone, PartialEq, PartialOrd, Default)]
16pub struct MSG_MOVE_STOP_SWIM {
17    pub guid: Guid,
18    pub info: MovementInfo,
19}
20
21impl crate::private::Sealed for MSG_MOVE_STOP_SWIM {}
22impl MSG_MOVE_STOP_SWIM {
23    fn read_inner(mut r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseErrorKind> {
24        if !(31..=97).contains(&body_size) {
25            return Err(crate::errors::ParseErrorKind::InvalidSize);
26        }
27
28        // guid: PackedGuid
29        let guid = crate::util::read_packed_guid(&mut r)?;
30
31        // info: MovementInfo
32        let info = MovementInfo::read(&mut r)?;
33
34        Ok(Self {
35            guid,
36            info,
37        })
38    }
39
40}
41
42impl crate::Message for MSG_MOVE_STOP_SWIM {
43    const OPCODE: u32 = 0x00cb;
44
45    #[cfg(feature = "print-testcase")]
46    fn message_name(&self) -> &'static str {
47        "MSG_MOVE_STOP_SWIM"
48    }
49
50    #[cfg(feature = "print-testcase")]
51    fn to_test_case_string(&self) -> Option<String> {
52        panic!("MSG types not supported");
53    }
54
55    fn size_without_header(&self) -> u32 {
56        self.size() as u32
57    }
58
59    fn write_into_vec(&self, mut w: impl Write) -> Result<(), std::io::Error> {
60        // guid: PackedGuid
61        crate::util::write_packed_guid(&self.guid, &mut w)?;
62
63        // info: MovementInfo
64        self.info.write_into_vec(&mut w)?;
65
66        Ok(())
67    }
68
69    fn read_body<S: crate::private::Sealed>(r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseError> {
70        Self::read_inner(r, body_size).map_err(|a| crate::errors::ParseError::new(203, "MSG_MOVE_STOP_SWIM", body_size, a))
71    }
72
73}
74
75#[cfg(feature = "wrath")]
76impl crate::wrath::ClientMessage for MSG_MOVE_STOP_SWIM {}
77
78#[cfg(feature = "wrath")]
79impl crate::wrath::ServerMessage for MSG_MOVE_STOP_SWIM {}
80
81impl MSG_MOVE_STOP_SWIM {
82    pub(crate) const fn size(&self) -> usize {
83        crate::util::packed_guid_size(&self.guid) // guid: PackedGuid
84        + self.info.size() // info: MovementInfo
85    }
86}
87