diff --git a/io/src/lib.rs b/io/src/lib.rs index 581d73289..8de9f28d9 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -202,11 +202,28 @@ impl> Cursor { #[inline] pub fn position(&self) -> u64 { self.pos } + /// Sets the internal position. + /// + /// This method allows seeking within the wrapped memory by setting the position. + /// + /// Note that setting a position that is larger than the buffer length will cause reads to + /// return no bytes (EOF). + #[inline] + pub fn set_position(&mut self, position: u64) { + self.pos = position; + } + /// Returns the inner buffer. /// /// This is the whole wrapped buffer, including the bytes already read. #[inline] pub fn into_inner(self) -> T { self.inner } + + /// Returns a reference to the inner buffer. + /// + /// This is the whole wrapped buffer, including the bytes already read. + #[inline] + pub fn inner(&self) -> &T { &self.inner } } impl> Read for Cursor {