pub struct FileReader { /* private fields */ }
Implementations§
Source§impl FileReader
impl FileReader
Sourcepub fn file_length(&self) -> usize
pub fn file_length(&self) -> usize
Returns the total size of the file
Sourcepub fn remaining(&self) -> usize
pub fn remaining(&self) -> usize
Returns the remaining bytes left based on the current cursor position.
Sourcepub fn seek(&mut self, pos: usize)
pub fn seek(&mut self, pos: usize)
Sets the cursor to the position. Panics if the position is beyond the end of the file
Sourcepub async fn read_buf(&mut self, buf: &mut [u8]) -> Result<usize>
pub async fn read_buf(&mut self, buf: &mut [u8]) -> Result<usize>
Read up to buf.len()
bytes into the provided slice, advancing the internal position in the file.
Returns the number of bytes that were read, or 0 if the end of the file has been reached.
Sourcepub async fn read_range(&self, offset: usize, len: usize) -> Result<Bytes>
pub async fn read_range(&self, offset: usize, len: usize) -> Result<Bytes>
Read up to len
bytes starting at offset
into a new Bytes object. The returned buffer
could be smaller than len
if offset + len
extends beyond the end of the file.
Panics if the requested range is outside of the file
Auto Trait Implementations§
impl Freeze for FileReader
impl !RefUnwindSafe for FileReader
impl Send for FileReader
impl Sync for FileReader
impl Unpin for FileReader
impl !UnwindSafe for FileReader
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