pub struct Take<T> { /* private fields */ }Expand description
Reader adapter which limits the bytes read from an underlying reader.
This struct is generally created by calling take on a reader.
Please see the documentation of take for more details.
See std::io::Take for more details.
Implementations§
Source§impl<T> Take<T>
impl<T> Take<T>
Sourcepub fn limit(&self) -> u64
pub fn limit(&self) -> u64
Returns the number of bytes that can be read before this instance will return EOF.
Sourcepub fn set_limit(&mut self, limit: u64)
pub fn set_limit(&mut self, limit: u64)
Sets the number of bytes that can be read before this instance will
return EOF. This is the same as constructing a new Take instance, so
the amount of bytes read and the previous limit value don’t matter when
calling this method.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the Take, returning the wrapped reader.
Trait Implementations§
Source§impl<T: BufRead> BufRead for Take<T>
impl<T: BufRead> BufRead for Take<T>
Source§fn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data, via
Read methods,
if empty.Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
Marks the given
amount of additional bytes from the internal buffer as having been read.
Subsequent calls to read only return bytes that have not been marked as read.Source§fn has_data_left(&mut self) -> Result<bool>
fn has_data_left(&mut self) -> Result<bool>
Checks if there is any data left to be
read.Source§impl<T: Read> Read for Take<T>
impl<T: Read> Read for Take<T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read.
Source§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<()>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<()>
Pull some bytes from this source into the specified buffer. Read more
Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Read the exact number of bytes required to fill
buf.Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<()>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<()>
Reads the exact number of bytes required to fill
cursor. Read moreSource§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adapter for this instance of
Read. Read moreSource§impl<T: Seek> Seek for Take<T>
impl<T: Seek> Seek for Take<T>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
Source§fn stream_len(&mut self) -> Result<u64>
fn stream_len(&mut self) -> Result<u64>
Returns the length of this stream (in bytes).
Source§fn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
Returns the current seek position from the start of the stream. Read more
Auto Trait Implementations§
impl<T> Freeze for Take<T>where
T: Freeze,
impl<T> RefUnwindSafe for Take<T>where
T: RefUnwindSafe,
impl<T> Send for Take<T>where
T: Send,
impl<T> Sync for Take<T>where
T: Sync,
impl<T> Unpin for Take<T>where
T: Unpin,
impl<T> UnsafeUnpin for Take<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Take<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more