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,
impl<'a, T> EasyMmap<'a, T>where
T: Copy,
Sourcepub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
Returns a read-only iterator over the elements of the memory map.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns a mutable iterator over the elements of the memory map.
Sourcepub fn par_iter(&self) -> impl ParallelIterator<Item = &T>
pub fn par_iter(&self) -> impl ParallelIterator<Item = &T>
Returns a parallel iterator over the elements of the memory map.
Sourcepub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
pub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
Returns a mutable parallel iterator over the elements of the memory map.
Sourcepub fn get_data_as_slice(&self) -> &[T]
pub fn get_data_as_slice(&self) -> &[T]
Returns a read-only slice of the memory map data.
Sourcepub fn get_data_as_slice_mut(&mut self) -> &mut [T]
pub fn get_data_as_slice_mut(&mut self) -> &mut [T]
Returns a mutable slice of the memory map data.
Sourcepub fn fill(&mut self, f: impl Fn(usize) -> T)
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:
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]);
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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