diff --git a/protocol/src/main/resources/rust/byte_buffer.rs b/protocol/src/main/resources/rust/byte_buffer.rs index 607d02d4a..638a0f9f6 100644 --- a/protocol/src/main/resources/rust/byte_buffer.rs +++ b/protocol/src/main/resources/rust/byte_buffer.rs @@ -4,8 +4,8 @@ #![allow(non_camel_case_types)] use std::any::Any; use crate::${protocol_root_path}::i_byte_buffer::IByteBuffer; -use crate::${protocol_root_path}::protocol_manager::write; -use crate::${protocol_root_path}::protocol_manager::readByProtocolId; +use crate::${protocol_root_path}::protocol_manager::writeNoProtocolId; +use crate::${protocol_root_path}::protocol_manager::readNoProtocolId; #[allow(non_snake_case)] pub struct ByteBuffer { @@ -443,10 +443,10 @@ impl IByteBuffer for ByteBuffer { } fn writePacket(&mut self, packet: &dyn Any, protocolId: i16) { - write(self, packet, protocolId); + writeNoProtocolId(self, packet, protocolId); } fn readPacket(&mut self, protocolId: i16) -> Box { - return readByProtocolId(self, protocolId); + return readNoProtocolId(self, protocolId); } } diff --git a/protocol/src/main/resources/rust/protocol_manager_template.rs b/protocol/src/main/resources/rust/protocol_manager_template.rs index 4d8172d39..281e62b91 100644 --- a/protocol/src/main/resources/rust/protocol_manager_template.rs +++ b/protocol/src/main/resources/rust/protocol_manager_template.rs @@ -6,7 +6,13 @@ use std::any::Any; use crate::${protocol_root_path}::i_byte_buffer::IByteBuffer; ${protocol_imports} + pub fn write(buffer: &mut dyn IByteBuffer, packet: &dyn Any, protocolId: i16) { + buffer.writeShort(protocolId); + writeNoProtocolId(buffer, packet, protocolId); +} + +pub fn writeNoProtocolId(buffer: &mut dyn IByteBuffer, packet: &dyn Any, protocolId: i16) { match protocolId { ${protocol_write_serialization} _ => println!("protocolId:[{}] not found", protocolId) @@ -15,10 +21,10 @@ pub fn write(buffer: &mut dyn IByteBuffer, packet: &dyn Any, protocolId: i16) { pub fn read(buffer: &mut dyn IByteBuffer) -> Box { let protocolId = buffer.readShort(); - return readByProtocolId(buffer, protocolId); + return readNoProtocolId(buffer, protocolId); } -pub fn readByProtocolId(buffer: &mut dyn IByteBuffer, protocolId: i16) -> Box { +pub fn readNoProtocolId(buffer: &mut dyn IByteBuffer, protocolId: i16) -> Box { let packet = match protocolId { ${protocol_read_deserialization} _ => Box::new(String::from("protocolId not found"))