Struct EasyMmap

Source
pub struct EasyMmap<'a, T> { /* private fields */ }
Expand description

The main abstraction over the mmap crate. Owns a memory map and provides simplified and safe access to this memory region. Also provides some additional features such as iterators over the data.

Implementations§

Source§

impl<'a, T> EasyMmap<'a, T>
where T: Copy,

Source

pub fn len(&self) -> usize

How many elements can be stored in the memory map.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns a read-only iterator over the elements of the memory map.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns a mutable iterator over the elements of the memory map.

Source

pub fn par_iter(&self) -> impl ParallelIterator<Item = &T>
where T: Send + Sync,

Returns a parallel iterator over the elements of the memory map.

Source

pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
where T: Send + Sync,

Returns a mutable parallel iterator over the elements of the memory map.

Source

pub fn get_data_as_slice(&self) -> &[T]

Returns a read-only slice of the memory map data.

Source

pub fn get_data_as_slice_mut(&mut self) -> &mut [T]

Returns a mutable slice of the memory map data.

Source

pub fn fill(&mut self, f: impl Fn(usize) -> T)

Convenience method for filling the memory map with a custom function Example:

let mut mmap = easy_mmap::EasyMmapBuilder::new()
                           .readable()
                           .writable()
                           .capacity(5)
                           .build();

mmap.fill(|i| i as u32);
assert_eq!(mmap.get_data_as_slice(), &[0, 1, 2, 3, 4]);

Trait Implementations§

Source§

impl<'a, T> Index<usize> for EasyMmap<'a, T>
where T: Copy,

The structure can be indexed similarly to an array. Example:

let mut mmap = easy_mmap::EasyMmapBuilder::new()
                    .options(&[
                        mmap::MapOption::MapWritable,
                        mmap::MapOption::MapReadable,
                    ])
                    .capacity(10)
                    .build();
mmap[0] = 1;
println!("{}", mmap[0]);
Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IndexMut<usize> for EasyMmap<'a, T>
where T: Copy,

The structure can be indexed an array or slice. See the Index trait for an example.

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for EasyMmap<'a, T>

§

impl<'a, T> RefUnwindSafe for EasyMmap<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for EasyMmap<'a, T>

§

impl<'a, T> !Sync for EasyMmap<'a, T>

§

impl<'a, T> Unpin for EasyMmap<'a, T>

§

impl<'a, T> !UnwindSafe for EasyMmap<'a, T>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.