[−][src]Struct head::HeaderSlice
A dynamically-sized view into a contiguous header and trailing sequence.
Implementations
impl<H, T> HeaderSlice<H, T>
[src]
pub fn with_header<F, R>(header: H, f: F) -> R where
F: for<'a> FnOnce(&'a Self) -> R,
[src]
F: for<'a> FnOnce(&'a Self) -> R,
Returns the result of calling f
on a shared header-slice starting with
header
.
pub fn with_header_mut<F, R>(header: H, f: F) -> R where
F: for<'a> FnOnce(&'a mut Self) -> R,
[src]
F: for<'a> FnOnce(&'a mut Self) -> R,
Returns the result of calling f
on a mutable header-slice starting
with header
.
pub fn from_header(header: &H) -> Option<&Self>
[src]
Attempts to create a shared header-slice from just header
.
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
If T
has equal or greater alignment than H
, unwrapping the returned
value is a no-op.
pub fn from_header_mut(header: &mut H) -> Option<&mut Self>
[src]
Attempts to create a mutable header-slice from just header
.
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
If T
has equal or greater alignment than H
, unwrapping the returned
value is a no-op.
pub fn from_boxed_header(header: Box<H>) -> Result<Box<Self>, Box<H>>
[src]
Attempts to create a boxed header-slice from just header
.
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
If T
has equal or greater alignment than H
, unwrapping the returned
value is a no-op.
pub unsafe fn from_header_unchecked(header: &H) -> &Self
[src]
Create a shared header-slice from just header
, without checking its
alignment.
Safety
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
pub unsafe fn from_header_unchecked_mut(header: &mut H) -> &mut Self
[src]
Create a mutable header-slice from just header
, without checking its
alignment.
Safety
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
pub unsafe fn from_boxed_header_unchecked(header: Box<H>) -> Box<Self>
[src]
Create a boxed header-slice from just header
, without checking its
alignment.
Safety
The address of header
must be at least aligned to T
because the
empty slice component must be properly aligned.
pub unsafe fn from_raw_parts<'a>(header: *const H, len: usize) -> &'a Self
[src]
Forms a shared header-slice from a pointer and a length.
Safety
Behavior is undefined if any of the following conditions are violated:
-
header
and any slice following it must be valid.-
header
must be non-null and aligned to the greater alignment betweenH
andT
. -
If
len
is non-zero, the slice followingheader
must be aligned toT
. -
The entire memory range of spanning from the start of
header
to the end of the trailing slice must be contained within a single allocated object! Header-slices can never span across multiple allocated objects.
-
-
The memory referenced by the returned header-slice must not be mutated for the duration of lifetime
'a
, except inside anUnsafeCell
. -
The total size of the resulting header-slice must be no larger than
isize::MAX
.
Caveat
The lifetime for the returned slice is inferred from its usage. To prevent accidental misuse, it's suggested to tie the lifetime to whichever source lifetime is safe in the context, such as by providing a helper function taking the lifetime of a host value for the slice, or by explicit annotation.
pub unsafe fn from_raw_parts_mut<'a>(header: *mut H, len: usize) -> &'a mut Self
[src]
Forms a mutable header-slice from a pointer and a length.
Safety
Behavior is undefined if any of the following conditions are violated:
-
header
and any slice following it must be valid.-
header
must be non-null and aligned to the greater alignment betweenH
andT
. -
If
len
is non-zero, the slice followingheader
must be aligned toT
. -
The entire memory range of spanning from the start of
header
to the end of the trailing slice must be contained within a single allocated object! Header-slices can never span across multiple allocated objects.
-
-
The memory referenced by the returned header-slice must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime
'a
. Both read and write accesses are forbidden. -
The total size of the resulting header-slice must be no larger than
isize::MAX
.
Caveat
The lifetime for the returned slice is inferred from its usage. To prevent accidental misuse, it's suggested to tie the lifetime to whichever source lifetime is safe in the context, such as by providing a helper function taking the lifetime of a host value for the slice, or by explicit annotation.
pub unsafe fn boxed_from_raw_parts(header: *mut H, len: usize) -> Box<Self>
[src]
Forms a boxed header-slice from a pointer and a length.
Safety
header
must point to a header-slice with a slice of len
items that
has been allocated by the global allocator.
Improper use can lead to:
-
A double-free if the function is called twice on the same raw pointer.
-
Mutable aliasing, which causes undefined behavior.
pub fn as_header(&self) -> &H
[src]
Returns a shared reference to the value preceding a slice of T
in
memory.
pub fn as_header_mut(&mut self) -> &mut H
[src]
Returns a mutable reference to the value preceding a slice of T
in
memory.
pub fn as_slice(&self) -> &[T]
[src]
Returns a shared reference to the trailing contiguous sequence of values.
pub fn as_slice_mut(&mut self) -> &mut [T]
[src]
Returns a mutable reference to the trailing contiguous sequence of values.
pub fn as_header_and_slice(&self) -> (&H, &[T])
[src]
Returns shared references to the header and its proceeded slice of T
.
pub fn as_header_and_slice_mut(&mut self) -> (&mut H, &mut [T])
[src]
Returns mutable references to the header and its proceeded slice of T
.
impl<H> HeaderSlice<H, H>
[src]
pub fn from_full_slice(slice: &[H]) -> Option<&Self>
[src]
Attempts to create a shared header-slice from slice
, using the first
element as the header.
Returns None
if slice
is empty.
pub fn from_full_slice_mut(slice: &mut [H]) -> Option<&mut Self>
[src]
Attempts to create a mutable header-slice from slice
, using the first
element as the header.
Returns None
if slice
is empty.
pub fn from_full_boxed_slice(slice: Box<[H]>) -> Option<Box<Self>>
[src]
Attempts to create a boxed header-slice from slice
, using the first
element as the header.
Returns None
if slice
is empty.
pub unsafe fn from_full_slice_unchecked(slice: &[H]) -> &Self
[src]
Creates a shared header-slice from slice
, using the first element as
the header without checking if it exists.
Safety
slice
must be non-empty.
pub unsafe fn from_full_slice_unchecked_mut(slice: &mut [H]) -> &mut Self
[src]
Creates a mutable header-slice from slice
, using the first element as
the header without checking if it exists.
Safety
slice
must be non-empty.
pub unsafe fn from_full_boxed_slice_unchecked(slice: Box<[H]>) -> Box<Self>
[src]
Creates a boxed header-slice from slice
, using the first element as
the header without checking if it exists.
Safety
slice
must be non-empty.
pub fn as_full_slice(&self) -> &[H]
[src]
Returns the full range of self
as a single shared slice.
pub fn as_full_slice_mut(&mut self) -> &mut [H]
[src]
Returns the full range of self
as a single mutable slice.
pub fn into_full_boxed_slice(self: Box<Self>) -> Box<[H]>
[src]
Returns the full range of self
as a single boxed slice.
Trait Implementations
impl<H: Debug, T: Debug> Debug for HeaderSlice<H, T>
[src]
impl<H: Eq, T: Eq> Eq for HeaderSlice<H, T>
[src]
impl<'a, H> From<&'a H> for &'a HeaderSlice<H, H>
[src]
impl<'a, H> From<&'a mut H> for &'a mut HeaderSlice<H, H>
[src]
impl<H: Hash, T: Hash> Hash for HeaderSlice<H, T>
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<H: Ord, T: Ord> Ord for HeaderSlice<H, T>
[src]
pub fn cmp(&self, other: &HeaderSlice<H, T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<H: PartialEq, T: PartialEq> PartialEq<HeaderSlice<H, T>> for HeaderSlice<H, T>
[src]
pub fn eq(&self, other: &HeaderSlice<H, T>) -> bool
[src]
pub fn ne(&self, other: &HeaderSlice<H, T>) -> bool
[src]
impl<H: PartialOrd, T: PartialOrd> PartialOrd<HeaderSlice<H, T>> for HeaderSlice<H, T>
[src]
pub fn partial_cmp(&self, other: &HeaderSlice<H, T>) -> Option<Ordering>
[src]
pub fn lt(&self, other: &HeaderSlice<H, T>) -> bool
[src]
pub fn le(&self, other: &HeaderSlice<H, T>) -> bool
[src]
pub fn gt(&self, other: &HeaderSlice<H, T>) -> bool
[src]
pub fn ge(&self, other: &HeaderSlice<H, T>) -> bool
[src]
impl<H, T> StructuralEq for HeaderSlice<H, T>
[src]
impl<H, T> StructuralPartialEq for HeaderSlice<H, T>
[src]
Auto Trait Implementations
impl<H, T> RefUnwindSafe for HeaderSlice<H, T> where
H: RefUnwindSafe,
T: RefUnwindSafe,
H: RefUnwindSafe,
T: RefUnwindSafe,
impl<H, T> Send for HeaderSlice<H, T> where
H: Send,
T: Send,
H: Send,
T: Send,
impl<H, T> Sync for HeaderSlice<H, T> where
H: Sync,
T: Sync,
H: Sync,
T: Sync,
impl<H, T> Unpin for HeaderSlice<H, T> where
H: Unpin,
T: Unpin,
H: Unpin,
T: Unpin,
impl<H, T> UnwindSafe for HeaderSlice<H, T> where
H: UnwindSafe,
T: UnwindSafe,
H: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,