pub struct FileMapState { /* private fields */ }Expand description
Struct to manage memory range mapped from file objects.
It maps a region from a file into current process by using libc::mmap(). Then it provides safe interfaces to access the memory mapped region.
Implementations§
Source§impl FileMapState
impl FileMapState
Sourcepub fn new(
file: File,
offset: off_t,
size: usize,
writable: bool,
) -> Result<Self>
pub fn new( file: File, offset: off_t, size: usize, writable: bool, ) -> Result<Self>
Memory map a region of the file object into current process.
It takes ownership of the file object and will close it when the returned object is dropped.
Sourcepub fn get_ref<T>(&self, offset: usize) -> Result<&T>
pub fn get_ref<T>(&self, offset: usize) -> Result<&T>
Cast a subregion of the mapped area to an object reference.
Sourcepub fn get_mut<T>(&mut self, offset: usize) -> Result<&mut T>
pub fn get_mut<T>(&mut self, offset: usize) -> Result<&mut T>
Cast a subregion of the mapped area to an mutable object reference.
Sourcepub fn get_slice<T>(&self, offset: usize, count: usize) -> Result<&[T]>
pub fn get_slice<T>(&self, offset: usize, count: usize) -> Result<&[T]>
Get an immutable slice of ‘T’ at ‘offset’ with ‘count’ entries.
Sourcepub fn get_slice_mut<T>(
&mut self,
offset: usize,
count: usize,
) -> Result<&mut [T]>
pub fn get_slice_mut<T>( &mut self, offset: usize, count: usize, ) -> Result<&mut [T]>
Get a mutable slice of ‘T’ at ‘offset’ with ‘count’ entries.
Sourcepub fn validate_range(&self, offset: usize, size: usize) -> Result<*const u8>
pub fn validate_range(&self, offset: usize, size: usize) -> Result<*const u8>
Check whether the range [offset, offset + size) is valid and return the start address.
Trait Implementations§
Source§impl Default for FileMapState
impl Default for FileMapState
Source§impl Drop for FileMapState
impl Drop for FileMapState
impl Send for FileMapState
impl Sync for FileMapState
Auto Trait Implementations§
impl Freeze for FileMapState
impl RefUnwindSafe for FileMapState
impl Unpin for FileMapState
impl UnwindSafe for FileMapState
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