1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-11-30 10:40:50 +01:00

make Message::encode write the message type instead of requiring to do so manually

This commit is contained in:
Robin Appelman 2026-11-07 16:54:25 +01:00
commit 2bb0a60171
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE
4 changed files with 16 additions and 8 deletions

View file

@ -255,6 +255,7 @@ impl<'a> Message<'a> {
#[cfg(feature = "write")]
impl Encode for Message<'_> {
fn encode(&self, stream: &mut BitWriteStream<LittleEndian>, state: &ParserState) -> Result<()> {
self.get_message_type().write(stream)?;
match self {
Message::Empty => Ok(()),
Message::Disconnect(reason) => reason.encode(stream, state),