pub struct MappedFile { /* private fields */ }Expand description
Read-only memory map of a file.
Holds the File so the mapping remains valid for the lifetime of this
value. The map borrows no path and therefore remains usable if the directory
entry is renamed after opening.
Consumers should treat mapped files as immutable sealed artifacts. External truncation or mutation while a map is live may produce platform-dependent behavior.
Implementations§
Source§impl MappedFile
impl MappedFile
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open path read-only and map the whole file.
§Errors
Returns I/O errors from open or mmap.
§Mapping contract
Although this method is safe to call, memmap2 cannot prevent another
process from truncating or rewriting the file. The caller must ensure
the path follows an immutable/sealed-file convention while mapped.
Trait Implementations§
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