Skip to content

Commit

Permalink
Add get_ref() and get_mut()
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Khramtsov authored and est31 committed Jun 24, 2024
1 parent 5ee8316 commit 4b22c17
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/reading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,20 @@ impl<T :io::Read + io::Seek> PacketReader<T> {
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.
Expand Down

0 comments on commit 4b22c17

Please sign in to comment.