pub struct MappedFile { /* private fields */ }Expand description
A memory-buffered view of a file, providing mmap-like random-access semantics.
Implementations§
Source§impl MappedFile
impl MappedFile
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, StreamingError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, StreamingError>
Opens path and loads its entire contents into memory.
§Errors
Returns StreamingError on any I/O failure.
Sourcepub fn read_range(
&self,
start: u64,
len: usize,
) -> Result<&[u8], StreamingError>
pub fn read_range( &self, start: u64, len: usize, ) -> Result<&[u8], StreamingError>
Returns a slice covering bytes [start, start + len).
§Errors
Returns an error if the requested range falls outside the file.
Sourcepub fn read_ranges(
&self,
ranges: &[(u64, usize)],
) -> Vec<Result<&[u8], StreamingError>>
pub fn read_ranges( &self, ranges: &[(u64, usize)], ) -> Vec<Result<&[u8], StreamingError>>
Reads multiple (start, len) ranges simultaneously.
The returned Vec preserves the order of the input slice.
Auto Trait Implementations§
impl Freeze for MappedFile
impl RefUnwindSafe for MappedFile
impl Send for MappedFile
impl Sync for MappedFile
impl Unpin for MappedFile
impl UnsafeUnpin for MappedFile
impl UnwindSafe for MappedFile
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