Skip to content

Commit 4b22c17

Browse files
Evgeny Khramtsovest31
authored andcommitted
Add get_ref() and get_mut()
1 parent 5ee8316 commit 4b22c17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/reading.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,20 @@ impl<T :io::Read + io::Seek> PacketReader<T> {
736736
pub fn into_inner(self) -> T {
737737
self.rdr
738738
}
739+
/// Returns a reference to the wrapped reader.
740+
pub const fn get_ref(&self) -> &T {
741+
&self.rdr
742+
}
743+
/// Returns a mutable reference to the wrapped reader.
744+
///
745+
/// # Safety
746+
///
747+
/// Care should be taken to avoid modifying the internal state of the wrapped reader,
748+
/// as it may corrupt the state of the `PacketReader`. It is the caller's responsibility
749+
/// to ensure that the data remains consistent when using this function.
750+
pub fn get_mut(&mut self) -> &mut T {
751+
&mut self.rdr
752+
}
739753
/// Reads a packet, and returns it on success.
740754
///
741755
/// Ok(None) is returned if the physical stream has ended.

0 commit comments

Comments
 (0)