Struct MemoryFlags

Source
#[repr(transparent)]
pub struct MemoryFlags(pub u32);

Tuple Fields§

§0: u32

Implementations§

Source§

impl MemoryFlags

Source

pub const NONE: u32 = 0u32

No flags

Source

pub const ACCESS_READ: u32 = 1u32

Memory is readable.

Source

pub const ACCESS_WRITE: u32 = 2u32

Memory is writable.

Source

pub const ACCESS_EXECUTE: u32 = 4u32

Memory is executable.

Source

pub const ACCESS_RW: u32 = 3u32

Memory is readable and writable.

Source

pub const ACCESS_RX: u32 = 5u32

Memory is readable and executable.

Source

pub const ACCESS_RWX: u32 = 7u32

Memory is readable, writable and executable.

Source

pub const MMAP_ENABLE_JIT: u32 = 16u32

Use a MAP_JIT flag available on Apple platforms (introduced by Mojave), which allows JIT code to be executed in a MAC bundle.

This flag may be turned on by the allocator if there is no other way of allocating executable memory.

§Note

This flag can only be used with [alloc], MAP_JIT only works on OSX and not on iOS. When a process uses fork() the child process has no access to the pages mapped with MAP_JIT.

Source

pub const MMAP_MAX_ACCESS_READ: u32 = 32u32

Pass PROT_MAX(PROT_READ) or PROT_MPROTECT(PROT_READ) to mmap() on platforms that support it.

This flag allows to set a “maximum access” that the memory page can get during its lifetime. Use protect to change the access flags.

§Note

This flag can only be used with [alloc] and alloc_dual_mapping. However alloc_dual_mapping may automatically use this if AccessRead is used.

Source

pub const MMAP_MAX_ACCESS_WRITE: u32 = 64u32

Pass PROT_MAX(PROT_WRITE) or PROT_MPROTECT(PROT_WRITE) to mmap() on platforms that support it.

This flag allows to set a “maximum access” that the memory page can get during its lifetime. Use protect to change the access flags.

§Note

This flag can only be used with [alloc] and alloc_dual_mapping. However alloc_dual_mapping may automatically use this if AccessWrite is used.

Source

pub const MMAP_MAX_ACCESS_EXECUTE: u32 = 128u32

Pass PROT_MAX(PROT_EXEC) or PROT_MPROTECT(PROT_EXEC) to mmap() on platforms that support it.

This flag allows to set a “maximum access” that the memory page can get during its lifetime. Use protect to change the access flags.

§Note

This flag can only be used with [alloc] and alloc_dual_mapping. However alloc_dual_mapping may automatically use this if AccessExecute is used.

Source

pub const MMAP_MAX_ACCESS_RW: u32 = 96u32

Source

pub const MMAP_MAX_ACCESS_RX: u32 = 160u32

Source

pub const MMAP_MAX_ACCESS_RWX: u32 = 224u32

Source

pub const MAP_SHARED: u32 = 256u32

Use MAP_SHARED when calling mmap().

§Note

In some cases MAP_SHARED may be set automatically. For example, some dual mapping implementations must use MAP_SHARED instead of MAP_PRIVATE to ensure that the OS would not apply copy on write on RW page, which would cause RX page not having the updated content.

Source

pub const MAPPING_PREFER_TMP: u32 = 2_147_483_648u32

Not an access flag, only used by alloc_dual_mapping() to override the default allocation strategy to always use a ‘tmp’ directory instead of “/dev/shm” (on POSIX platforms). Please note that this flag will be ignored if the operating system allows to allocate an executable memory by a different API than open() or shm_open(). For example on Linux memfd_create() is preferred and on BSDs shm_open(SHM_ANON, ...) is used if SHM_ANON is defined.

§Note

This flag can only be used with [alloc].

Source§

impl MemoryFlags

Source

pub fn contains(self, other: u32) -> bool

Trait Implementations§

Source§

impl BitAnd<u32> for MemoryFlags

Source§

type Output = MemoryFlags

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: u32) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd for MemoryFlags

Source§

type Output = MemoryFlags

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign<u32> for MemoryFlags

Source§

fn bitand_assign(&mut self, rhs: u32)

Performs the &= operation. Read more
Source§

impl BitAndAssign for MemoryFlags

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr<u32> for MemoryFlags

Source§

type Output = MemoryFlags

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: u32) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for MemoryFlags

Source§

type Output = MemoryFlags

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign<u32> for MemoryFlags

Source§

fn bitor_assign(&mut self, rhs: u32)

Performs the |= operation. Read more
Source§

impl BitOrAssign for MemoryFlags

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl Clone for MemoryFlags

Source§

fn clone(&self) -> MemoryFlags

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryFlags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<MemoryFlags> for u32

Source§

fn from(val: MemoryFlags) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for MemoryFlags

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for MemoryFlags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for MemoryFlags

Source§

fn cmp(&self, other: &MemoryFlags) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<u32> for MemoryFlags

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for MemoryFlags

Source§

fn eq(&self, other: &MemoryFlags) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for MemoryFlags

Source§

fn partial_cmp(&self, other: &MemoryFlags) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for MemoryFlags

Source§

impl Eq for MemoryFlags

Source§

impl StructuralPartialEq for MemoryFlags

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.