Struct memmap2::MmapRaw

source ·
pub struct MmapRaw { /* private fields */ }
Expand description

A handle to a raw memory mapped buffer.

This struct never hands out references to its interior, only raw pointers. This can be helpful when creating shared memory maps between untrusted processes.

Implementations§

source§

impl MmapRaw

source

pub fn map_raw<T: MmapAsRawDesc>(file: T) -> Result<MmapRaw>

Creates a writeable memory map backed by a file.

This is equivalent to calling MmapOptions::new().map_raw(file).

Errors

This method returns an error when the underlying system call fails, which can happen for a variety of reasons, such as when the file is not open with read and write permissions.

source

pub fn as_ptr(&self) -> *const u8

Returns a raw pointer to the memory mapped file.

Before dereferencing this pointer, you have to make sure that the file has not been truncated since the memory map was created. Avoiding this will not introduce memory safety issues in Rust terms, but will cause SIGBUS (or equivalent) signal.

source

pub fn as_mut_ptr(&self) -> *mut u8

Returns an unsafe mutable pointer to the memory mapped file.

Before dereferencing this pointer, you have to make sure that the file has not been truncated since the memory map was created. Avoiding this will not introduce memory safety issues in Rust terms, but will cause SIGBUS (or equivalent) signal.

source

pub fn len(&self) -> usize

Returns the length in bytes of the memory map.

Note that truncating the file can cause the length to change (and render this value unusable).

Trait Implementations§

source§

impl Debug for MmapRaw

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.