pub struct IoWindow<T: Seek> { /* private fields */ }Expand description
Seekable I/O adapter that limits operations to a byte range.
For more, see the crate documentation.
Implementations§
Source§impl<T: Seek> IoWindow<T>
impl<T: Seek> IoWindow<T>
Sourcepub fn new(inner: T, range: impl RangeBounds<u64>) -> Result<IoWindow<T>>
pub fn new(inner: T, range: impl RangeBounds<u64>) -> Result<IoWindow<T>>
Adapts an object to limit I/O operations within a byte range.
If the current position is earlier than the start of the range, the object is seeked to that start.
A range with an unbounded start (for example, ..1024) is treated as
starting at 0.
A range with an unbounded end (for example, 1024..) means
the window ends at the end of the stream. Writing past the end
of the window is supported if the underlying object can grow
its length (some examples include File and
Cursor<Vec<u8>>).
§Errors
Returns an error if determining the current position or seeking fails.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this adapter, returning the underlying object.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Gets a mutable reference to the underlying object.
It is a logic error to seek the object earlier than the start of the
window. If you’re not absolutely certain that code using this mutable
reference upholds this requirement, call Seek::rewind on this
adapter immediately after using the mutable reference.
Trait Implementations§
Source§impl<T: Read + Seek> Read for IoWindow<T>
impl<T: Read + Seek> Read for IoWindow<T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read more§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read more§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Source§impl<T: Seek> Seek for IoWindow<T>
impl<T: Seek> Seek for IoWindow<T>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)Source§impl<T: Write + Seek> Write for IoWindow<T>
impl<T: Write + Seek> Write for IoWindow<T>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)impl<T: Eq + Seek> Eq for IoWindow<T>
impl<T: Seek> StructuralPartialEq for IoWindow<T>
Auto Trait Implementations§
impl<T> Freeze for IoWindow<T>where
T: Freeze,
impl<T> RefUnwindSafe for IoWindow<T>where
T: RefUnwindSafe,
impl<T> Send for IoWindow<T>where
T: Send,
impl<T> Sync for IoWindow<T>where
T: Sync,
impl<T> Unpin for IoWindow<T>where
T: Unpin,
impl<T> UnwindSafe for IoWindow<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)