pub struct File<'a, C>(/* private fields */)
where
C: Debug + Sync + Send;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>(file: File, path: P) -> Result<File<'a, ()>, Error>
pub fn new<P>(file: File, path: P) -> Result<File<'a, ()>, Error>
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> File<'a, C>
impl<'a, C> 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> BufferedReader<C> for File<'a, C>
impl<'a, C> BufferedReader<C> for File<'a, C>
Source§fn data(&mut self, amount: usize) -> Result<&[u8], Error>
fn data(&mut self, amount: usize) -> Result<&[u8], Error>
amount bytes
of data, and returns it. Read moreSource§fn data_hard(&mut self, amount: usize) -> Result<&[u8], Error>
fn data_hard(&mut self, amount: usize) -> Result<&[u8], Error>
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], Error>
fn data_consume_hard(&mut self, amount: usize) -> Result<&[u8], Error>
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<File<'a, C>>,
) -> Option<Box<dyn BufferedReader<C> + 'b>>where
File<'a, C>: 'b,
fn into_inner<'b>(
self: Box<File<'a, C>>,
) -> Option<Box<dyn BufferedReader<C> + 'b>>where
File<'a, C>: '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, Error>
fn copy(&mut self, sink: &mut dyn Write) -> Result<u64, Error>
Source§fn dump(&self, sink: &mut dyn Write) -> Result<(), Error>where
Self: Sized,
fn dump(&self, sink: &mut dyn Write) -> Result<(), Error>where
Self: Sized,
Source§fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: Sized + 'a,
fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: Sized + 'a,
Source§impl<'a, C> Read for File<'a, C>
impl<'a, C> Read for File<'a, C>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> 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 more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)Auto Trait Implementations§
impl<'a, C> !RefUnwindSafe for File<'a, C>
impl<'a, C> !UnwindSafe for File<'a, C>
impl<'a, C> Freeze for File<'a, C>where
Imp<'a, C>: Freeze,
impl<'a, C> Send for File<'a, C>where
Imp<'a, C>: Send,
impl<'a, C> Sync for File<'a, C>where
Imp<'a, C>: Sync,
impl<'a, C> Unpin for File<'a, C>where
Imp<'a, C>: Unpin,
impl<'a, C> UnsafeUnpin for File<'a, C>where
Imp<'a, C>: UnsafeUnpin,
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
Source§impl<R> ElfRead for R
impl<R> ElfRead for R
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<R> LittleEndianReadExt for Rwhere
R: Read,
impl<R> LittleEndianReadExt for Rwhere
R: Read,
impl<T> MaybeSend for T
impl<T> MaybeSync for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more