mirror of
https://codeberg.org/demostf/parser.git
synced 2026-11-30 02:30:46 +01:00
make Message::encode write the message type instead of requiring to do so manually
This commit is contained in:
parent
9b0e19a7e7
commit
2bb0a60171
4 changed files with 16 additions and 8 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ impl Encode for MessagePacket<'_> {
|
|||
self.meta.write(stream)?;
|
||||
stream.reserve_byte_length(32, |stream| {
|
||||
for message in self.messages.iter() {
|
||||
message.get_message_type().write(stream)?;
|
||||
message.encode(stream, state)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue