Segment

Struct Segment 

Source
pub struct Segment { /* private fields */ }
Expand description

A segment of OS memory.

Implementations§

Source§

impl Segment

Source

pub fn new( base: Option<*mut u8>, size: usize, page_size: usize, flags: ProtFlags, ) -> Result<Self, Error>

Create a segment of OS memory.

When base is None, new memory will be allocated. Otherwise, the given pointer will be used, and Segment will not assume ownership of the underlying memory segment. page_size must be a power of 2.

Source

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

Base pointer to the segment.

Source

pub fn as_slice(&self) -> &mut [u8]

Access the segment as a byte slice.

Source

pub fn make_shared( &self, offset: usize, shm: &SharedMemory, flags: ProtFlags, ) -> Result<(), Error>

Patch a SharedMemory to a part of this memory segment. The given shm will start with an offset from the beginning of Segment, and cannot overrun the end of the segment. The given SharedMemory outlives this object once patched (even if it is over-shadowed by subsequent patching).

Trait Implementations§

Source§

impl Drop for Segment

Source§

fn drop(&mut self)

Executes the destructor for this type. 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>,

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.