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
sourceimpl<'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> where
T: Send + Sync,
pub fn par_iter(&self) -> impl ParallelIterator<Item = &T> where
T: Send + Sync,
Returns a parallel iterator over the elements of the memory map.
sourcepub fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut T> where
T: Send + Sync,
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.
sourcepub fn get_data_as_slice(&self) -> &[T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn get_data_as_slice(&self) -> &[T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns a read-only slice of the memory map data.
sourcepub fn get_data_as_slice_mut(&mut self) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn get_data_as_slice_mut(&mut self) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
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
sourceimpl<'a, T> Index<usize> for EasyMmap<'a, T> where
T: Copy,
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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more