From 4b22c17d4ac365e8f4e16c69f0e906a95731e781 Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Thu, 20 Jun 2024 19:52:40 +0200 Subject: [PATCH] Add get_ref() and get_mut() --- src/reading.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/reading.rs b/src/reading.rs index 07b0f47..7bdf789 100644 --- a/src/reading.rs +++ b/src/reading.rs @@ -736,6 +736,20 @@ impl PacketReader { pub fn into_inner(self) -> T { self.rdr } + /// Returns a reference to the wrapped reader. + pub const fn get_ref(&self) -> &T { + &self.rdr + } + /// Returns a mutable reference to the wrapped reader. + /// + /// # Safety + /// + /// Care should be taken to avoid modifying the internal state of the wrapped reader, + /// as it may corrupt the state of the `PacketReader`. It is the caller's responsibility + /// to ensure that the data remains consistent when using this function. + pub fn get_mut(&mut self) -> &mut T { + &mut self.rdr + } /// Reads a packet, and returns it on success. /// /// Ok(None) is returned if the physical stream has ended.