Struct buffered_reader::File
source · pub struct File<'a, C: Debug + Sync + Send>(/* private fields */);
Expand description
Wraps files using mmap
().
This implementation tries to mmap the file, falling back to just using a generic reader.
Implementations§
source§impl<'a> File<'a, ()>
impl<'a> File<'a, ()>
sourcepub fn new<P: AsRef<Path>>(file: File, path: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(file: File, path: P) -> Result<Self>
Wraps a fs::File
.
The given path
should be the path that has been used to
obtain file
from. It is used in error messages to provide
context to the user.
While this is slightly less convenient than Self::open
, it
allows one to inspect or manipulate the fs::File
object
before handing it off. For example, one can inspect the
metadata.
source§impl<'a, C: Debug + Sync + Send> File<'a, C>
impl<'a, C: Debug + Sync + Send> File<'a, C>
Like Self::new
, but sets a cookie.
The given path
should be the path that has been used to
obtain file
from. It is used in error messages to provide
context to the user.
While this is slightly less convenient than
Self::with_cookie
, it allows one to inspect or manipulate
the fs::File
object before handing it off. For example,
one can inspect the metadata.
Like Self::open
, but sets a cookie.
Trait Implementations§
source§impl<'a, C: Debug + Sync + Send> BufferedReader<C> for File<'a, C>
impl<'a, C: Debug + Sync + Send> BufferedReader<C> for File<'a, C>
source§fn data(&mut self, amount: usize) -> Result<&[u8]>
fn data(&mut self, amount: usize) -> Result<&[u8]>
amount
bytes
of data, and returns it. Read moresource§fn data_hard(&mut self, amount: usize) -> Result<&[u8]>
fn data_hard(&mut self, amount: usize) -> Result<&[u8]>
BufferedReader::data
, but returns an error if there is not at least
amount
bytes available. Read moresource§fn data_consume_hard(&mut self, amount: usize) -> Result<&[u8]>
fn data_consume_hard(&mut self, amount: usize) -> Result<&[u8]>
BufferedReader::data_hard
and BufferedReader::consume
. Read moresource§fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>>
fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>>
BufferedReader
, if
any. Read moresource§fn get_ref(&self) -> Option<&dyn BufferedReader<C>>
fn get_ref(&self) -> Option<&dyn BufferedReader<C>>
BufferedReader
, if any.source§fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>>where
Self: 'b,
fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>>where
Self: 'b,
BufferedReader
’s cookie and returns the old value.BufferedReader
’s cookie.BufferedReader
’s cookie.source§fn data_eof(&mut self) -> Result<&[u8], Error>
fn data_eof(&mut self) -> Result<&[u8], Error>
BufferedReader::data
, this does not
actually consume the data that is read. Read moresource§fn consummated(&mut self) -> bool
fn consummated(&mut self) -> bool
source§fn read_be_u16(&mut self) -> Result<u16, Error>
fn read_be_u16(&mut self) -> Result<u16, Error>
source§fn read_be_u32(&mut self) -> Result<u32, Error>
fn read_be_u32(&mut self) -> Result<u32, Error>
source§fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
terminal
is encountered or EOF. Read moresource§fn drop_until(&mut self, terminals: &[u8]) -> Result<usize, Error>
fn drop_until(&mut self, terminals: &[u8]) -> Result<usize, Error>
source§fn drop_through(
&mut self,
terminals: &[u8],
match_eof: bool
) -> Result<(Option<u8>, usize), Error>
fn drop_through( &mut self, terminals: &[u8], match_eof: bool ) -> Result<(Option<u8>, usize), Error>
terminals
is
encountered. Read moresource§fn steal(&mut self, amount: usize) -> Result<Vec<u8>, Error>
fn steal(&mut self, amount: usize) -> Result<Vec<u8>, Error>
BufferedReader::data_consume_hard
, but returns the data in a
caller-owned buffer. Read moresource§fn steal_eof(&mut self) -> Result<Vec<u8>, Error>
fn steal_eof(&mut self) -> Result<Vec<u8>, Error>
BufferedReader::steal
, but instead of stealing a fixed number of
bytes, steals all of the data until the end of file.source§fn drop_eof(&mut self) -> Result<bool, Error>
fn drop_eof(&mut self) -> Result<bool, Error>
BufferedReader::steal_eof
, but instead of returning the data, the
data is discarded. Read moresource§fn copy(&mut self, sink: &mut dyn Write) -> Result<u64>
fn copy(&mut self, sink: &mut dyn Write) -> Result<u64>
source§fn dump(&self, sink: &mut dyn Write) -> Result<()>where
Self: Sized,
fn dump(&self, sink: &mut dyn Write) -> Result<()>where
Self: Sized,
source§fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: 'a + Sized,
fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: 'a + Sized,
source§impl<'a, C: Debug + Sync + Send> Read for File<'a, C>
impl<'a, C: Debug + Sync + Send> Read for File<'a, C>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§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 moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§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 · source§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 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§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 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read more