Added packets folder for the packet-service until I automate generation at build time
This commit is contained in:
34
packet-service/src/packets/cli_messenger_chat.rs
Normal file
34
packet-service/src/packets/cli_messenger_chat.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
/* This file is @generated with IDL v0.2.2 */
|
||||
|
||||
use crate::dataconsts::*;
|
||||
use crate::enums::*;
|
||||
use crate::packet::PacketPayload;
|
||||
use crate::types::*;
|
||||
use bincode::de::read::Reader;
|
||||
use bincode::enc::write::Writer;
|
||||
use bincode::{de::Decoder, enc::Encoder, error::DecodeError, Decode, Encode};
|
||||
use utils::null_string::NullTerminatedString;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CliMessengerChat {
|
||||
pub(crate) tag: u16,
|
||||
pub(crate) message: NullTerminatedString,
|
||||
}
|
||||
|
||||
impl PacketPayload for CliMessengerChat {}
|
||||
|
||||
impl Encode for CliMessengerChat {
|
||||
fn encode<E: Encoder>(&self, encoder: &mut E) -> std::result::Result<(), bincode::error::EncodeError> {
|
||||
self.tag.encode(encoder)?;
|
||||
self.message.encode(encoder)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<Context> Decode<Context> for CliMessengerChat {
|
||||
fn decode<D: Decoder>(decoder: &mut D) -> std::result::Result<Self, bincode::error::DecodeError> {
|
||||
let tag = u16::decode(decoder)?;
|
||||
let message = NullTerminatedString::decode(decoder)?;
|
||||
Ok(Self { tag, message })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user