PagedSegment

Struct PagedSegment 

Source
pub struct PagedSegment<'a> { /* private fields */ }
Expand description

Memory segment that allows customized page fault handling in user space.

Implementations§

Source§

impl<'a> PagedSegment<'a>

Source

pub unsafe fn from_raw<S: PageStore + Send + 'static>( base: *mut u8, size: usize, store: S, page_size: Option<usize>, ) -> Result<PagedSegment<'static>, Error>

Make the user-space paged segement at an existing memory location.

Note that the range of addresses should be valid throughout the lifetime of PagedSegment and no access should be made to the memory unless it is wrapped in [PagedSegment::run].

Source

pub fn new<S: PageStore + Send + 'static>( length: usize, store: S, page_size: Option<usize>, ) -> Result<PagedSegment<'static>, Error>

Allocate new memory to be user-space paged.

Source

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

Source

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

Source

pub fn as_raw_parts(&self) -> (*mut u8, usize)

Source

pub fn page_size(&self) -> usize

Return the page size in use.

Source

pub fn reset_write_detection( &self, offset: usize, size: usize, ) -> Result<(), Error>

Mark the entire PagedSegment to be aware of all subsequent writes, this will trigger write-access page faults again when write operation is made in the future, even though the location was previously written.

Source

pub fn release_page(&self, page_offset: usize) -> Result<(), Error>

Release the page content loaded from PageStore. The next access to an address within this page will trigger a page fault. page_offset must be one of the offset that may pass to page fault handler in PageStore (thus it has to be aligned to the beginning of a page).

Source

pub fn release_all_pages(&self) -> Result<(), Error>

Source

pub fn make_shared( &self, offset: usize, shm: &SharedMemory, ) -> 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<'a> Drop for PagedSegment<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PagedSegment<'a>

§

impl<'a> !RefUnwindSafe for PagedSegment<'a>

§

impl<'a> Send for PagedSegment<'a>

§

impl<'a> Sync for PagedSegment<'a>

§

impl<'a> Unpin for PagedSegment<'a>

§

impl<'a> !UnwindSafe for PagedSegment<'a>

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.