Struct mini_io_queue::Region
source · [−]pub struct Region<'a, T>(_, _);
Expand description
A region of two separate slices that represent continuous data.
Ring
implements a “ring-buffer”, meaning the left and right regions can overlap the ends of
the underlying buffer, causing them to be split into two contiguous slices (chunks). Region
represents these two chunks, allowing their data to be accessed mostly like one continuous slice
without allocations or copies.
Implementations
sourceimpl<'a, T> Region<'a, T>
impl<'a, T> Region<'a, T>
sourcepub fn new(slice_0: &'a [T], slice_1: &'a [T]) -> Self
pub fn new(slice_0: &'a [T], slice_1: &'a [T]) -> Self
Creates a region with two slices.
The slices should represent continuous data, where slice_0
goes before slice_1
.
sourcepub fn iter(&self) -> impl Iterator<Item = &'a T> + 'a
pub fn iter(&self) -> impl Iterator<Item = &'a T> + 'a
Returns an iterator over the region.
The iterator yields all items from start to end.
sourcepub fn contiguous(&self) -> &'a [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn contiguous(&self) -> &'a [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns the first contiguous slice in the region.
The slice will not necessarily contain all data in the region. If the region is not empty, the slice is guaranteed to contain some data.
sourcepub fn slice<R>(&self, range: R) -> Self where
R: RangeBounds<usize>,
pub fn slice<R>(&self, range: R) -> Self where
R: RangeBounds<usize>,
Slices the region, returning a new region containing a part of the original.
Panics
Panics if the start
or end
of the range is >= region.len()
.
sourceimpl<'a, T> Region<'a, T> where
T: Copy,
impl<'a, T> Region<'a, T> where
T: Copy,
sourcepub fn copy_to_slice(&self, dest: &mut [T])
pub fn copy_to_slice(&self, dest: &mut [T])
Copies all elements in the region into dest
, using a memcpy.
The length of dest
must be the same as self
.
If T
does not implement Copy
, use clone_to_slice
.
Panics
This function will panic if dest
has a different length to self
.
Trait Implementations
sourceimpl<'a, T: PartialEq> PartialEq<Region<'a, T>> for Region<'a, T>
impl<'a, T: PartialEq> PartialEq<Region<'a, T>> for Region<'a, T>
impl<'a, T: Copy> Copy for Region<'a, T>
impl<'a, T: Eq> Eq for Region<'a, T>
impl<'a, T> StructuralEq for Region<'a, T>
impl<'a, T> StructuralPartialEq for Region<'a, T>
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Region<'a, T> where
T: RefUnwindSafe,
impl<'a, T> Send for Region<'a, T> where
T: Sync,
impl<'a, T> Sync for Region<'a, T> where
T: Sync,
impl<'a, T> Unpin for Region<'a, T>
impl<'a, T> UnwindSafe for Region<'a, T> where
T: RefUnwindSafe,
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