From 071fc367df7b10ca91016d870417c6cc0aad02d4 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Tue, 15 Aug 2023 21:36:40 +0300 Subject: [PATCH] [Protocol] Add buffer comment to refactor at some point remaining_bytes --- src/buffer.rs | 5 +++-- src/protocols/quake/client.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 6f19edc..420be8b 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -46,8 +46,9 @@ impl<'a, B: ByteOrder> Buffer<'a, B> { /// Returns the length of the buffer data. pub const fn data_length(&self) -> usize { self.data.len() } - // Added for legacy support just for the refactoring - // Not Tested + // TODO: Look into this to make it take ownership of data, not borrowing it + // There are many instances where we transform this to a vector. + /// Returns the remaining bytes that have not been read. pub fn remaining_bytes(&self) -> &[u8] { &self.data[self.cursor ..] } /// Moves the cursor forward or backward by a specified offset. diff --git a/src/protocols/quake/client.rs b/src/protocols/quake/client.rs index 5af6ab1..3f14c8f 100644 --- a/src/protocols/quake/client.rs +++ b/src/protocols/quake/client.rs @@ -45,7 +45,7 @@ fn get_data(address: &SocketAddr, timeout_settings: Option< bufferer.move_cursor(response_header.len() as isize)?; - Ok(bufferer.remaining_bytes().to_vec()) //TODO: Maybe fix? + Ok(bufferer.remaining_bytes().to_vec()) } fn get_server_values(bufferer: &mut Buffer) -> GDResult> {