Trait kernel::Read[][src]

pub trait Read {
    fn len(&self) -> usize;
fn ptr(&self) -> *const u8;
fn map_or<F, R>(&self, default: R, fun: F) -> R
    where
        F: FnOnce(&[u8]) -> R
; }

A readable region of userspace memory.

This trait can be used to gain read-only access to memory regions wrapped in an AppSlice type.

Required methods

fn len(&self) -> usize[src]

Length of the memory region.

If the process is no longer alive and the memory has been reclaimed, this method must return 0.

Default AppSlice

A default instance of an AppSlice must return 0.

fn ptr(&self) -> *const u8[src]

Pointer to the first byte of the userspace memory region.

If the length of the initially shared memory region (irrespective of the return value of len) is 0, this function returns a pointer to address 0x0. This is because processes may allow buffers with length 0 to share no no memory with the kernel. Because these buffers have zero length, they may have any pointer value. However, these dummy addresses should not be leaked, so this method returns 0 for zero-length slices.

Default AppSlice

A default instance of an AppSlice must return a pointer to address 0x0.

fn map_or<F, R>(&self, default: R, fun: F) -> R where
    F: FnOnce(&[u8]) -> R, 
[src]

Applies a function to the (read only) slice reference pointed to by the AppSlice.

If the process is no longer alive and the memory has been reclaimed, this method must return the default value.

Default AppSlice

A default instance of an AppSlice must return the passed default value without executing the closure.

Loading content...

Implementors

impl Read for ReadOnlyAppSlice[src]

impl Read for ReadWriteAppSlice[src]

Loading content...