aligned_array

Struct Aligned

Source
#[repr(C)]
pub struct Aligned<A, T>
where T: ?Sized,
{ /* private fields */ }
Expand description

A newtype with alignment of at least A bytes

Trait Implementations§

Source§

impl<A, A2, N, M> AsAlignedChunks<A2, M> for Aligned<A, GenericArray<u8, N>>
where A: Alignment, A2: Alignment, A2::Num: IsLessOrEqual<A::Num, Output = B1>, N: ArrayLength<u8>, M: ArrayLength<u8> + PartialDiv<A2::Num>,

Source§

fn as_aligned_chunks(&self) -> &[Aligned<A2, GenericArray<u8, M>>]

Break self into aligned chunks of size M. This is not required to cover all the bytes of Self, trailing bytes that don’t fit may be left off.
Source§

fn as_mut_aligned_chunks(&mut self) -> &mut [Aligned<A2, GenericArray<u8, M>>]

Break self into mutable aligned chunks of size M. This is not required to cover all the bytes of Self, but must agree with as_aligned_chunks.
Source§

impl<'a, A, A2, T> AsMut<Aligned<A, T>> for &'a mut Aligned<A2, T>
where A: Alignment, A2: Alignment, A::Num: IsLessOrEqual<A2::Num, Output = B1>,

Source§

fn as_mut(&mut self) -> &mut Aligned<A, T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<A, N> AsNeSlice for Aligned<A, GenericArray<u8, N>>
where A: Alignment, A::Num: IsGreaterOrEqual<U8, Output = B1>, N: ArrayLength<u8> + PartialDiv<U8>,

Source§

fn as_ne_u16_slice(&self) -> &[u16]

Represent the value as native-endian u16’s
Source§

fn as_mut_ne_u16_slice(&mut self) -> &mut [u16]

Represent the value as mutable native-endian u16’s
Source§

fn as_ne_u32_slice(&self) -> &[u32]

Represent the value as native-endian u32’s
Source§

fn as_mut_ne_u32_slice(&mut self) -> &mut [u32]

Represent the value as mutable native-endian u32’s
Source§

fn as_ne_u64_slice(&self) -> &[u64]

Represent the value as native-endian u64’s
Source§

fn as_mut_ne_u64_slice(&mut self) -> &mut [u64]

Represent the value as mutable native-endian u64’s
Source§

impl<'a, A, A2, T> AsRef<Aligned<A, T>> for &'a Aligned<A2, T>
where A: Alignment, A2: Alignment, A::Num: IsLessOrEqual<A2::Num, Output = B1>,

Source§

fn as_ref(&self) -> &Aligned<A, T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<A, T> Clone for Aligned<A, T>
where A: Alignment, T: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A, T> Debug for Aligned<A, T>
where A: Alignment, T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, T> Default for Aligned<A, T>
where A: Alignment, T: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A, T> Deref for Aligned<A, T>
where A: Alignment, T: ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<A, T> DerefMut for Aligned<A, T>
where A: Alignment, T: ?Sized,

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
Source§

impl<A, T> Display for Aligned<A, T>
where A: Alignment, T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, T, V> FromIterator<V> for Aligned<A, T>
where A: Alignment, T: FromIterator<V>,

Source§

fn from_iter<U: IntoIterator<Item = V>>(iter: U) -> Self

Creates a value from an iterator. Read more
Source§

impl<A, T, N> GenericSequence<T> for Aligned<A, GenericArray<T, N>>
where N: ArrayLength<T>, A: Alignment,

Implement generic_array::GenericSequence for Aligned sequences

Source§

type Length = N

GenericArray associated length
Source§

type Sequence = Aligned<A, GenericArray<T, N>>

Concrete sequence type used in conjuction with reference implementations of GenericSequence
Source§

fn generate<F>(f: F) -> Self::Sequence
where F: FnMut(usize) -> T,

Initializes a new sequence instance using the given function. Read more
Source§

impl<A, T> Hash for Aligned<A, T>
where A: Alignment, T: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A, T> Index<RangeTo<usize>> for Aligned<A, [T]>
where A: Alignment,

Source§

type Output = Aligned<A, [T]>

The returned type after indexing.
Source§

fn index(&self, range: RangeTo<usize>) -> &Aligned<A, [T]>

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

impl<'a, A, T> IntoIterator for &'a Aligned<A, T>
where A: Alignment, &'a T: IntoIterator,

Source§

type Item = <&'a T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'a T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, A, T> IntoIterator for &'a mut Aligned<A, T>
where A: Alignment, &'a mut T: IntoIterator,

Source§

type Item = <&'a mut T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'a mut T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<A, T> IntoIterator for Aligned<A, T>
where A: Alignment, T: IntoIterator,

Source§

type Item = <T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<A, T> Ord for Aligned<A, T>
where A: Alignment, T: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<A, T> PartialEq for Aligned<A, T>
where A: Alignment, T: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A, T> PartialOrd for Aligned<A, T>
where A: Alignment, T: PartialOrd,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, A, N, K> Split<u8, K> for &'a Aligned<A, GenericArray<u8, N>>
where A: Alignment, N: ArrayLength<u8> + Sub<K>, K: ArrayLength<u8> + PartialDiv<A::Num> + 'static, Diff<N, K>: ArrayLength<u8>,

Implement generic_array::Split api for aligned bytes in a way that preserves aligment info TODO: This could be more generic, but we didn’t need it yet. Instead of u8, a generic value T?

Source§

type First = &'a Aligned<A, GenericArray<u8, K>>

First part of the resulting split array
Source§

type Second = &'a Aligned<A, GenericArray<u8, <N as Sub<K>>::Output>>

Second part of the resulting split array
Source§

fn split(self) -> (Self::First, Self::Second)

Splits an array at the given index, returning the separate parts of the array.
Source§

impl<'a, A, N, K> Split<u8, K> for &'a mut Aligned<A, GenericArray<u8, N>>
where A: Alignment, N: ArrayLength<u8> + Sub<K>, K: ArrayLength<u8> + PartialDiv<A::Num> + 'static, Diff<N, K>: ArrayLength<u8>,

Implement generic_array::Split API for aligned bytes in a way that preserves aligment info TODO: This could be more generic, but we didn’t need it yet. Instead of u8, a generic value T?

Source§

type First = &'a mut Aligned<A, GenericArray<u8, K>>

First part of the resulting split array
Source§

type Second = &'a mut Aligned<A, GenericArray<u8, <N as Sub<K>>::Output>>

Second part of the resulting split array
Source§

fn split(self) -> (Self::First, Self::Second)

Splits an array at the given index, returning the separate parts of the array.
Source§

impl<A, T> Eq for Aligned<A, T>
where A: Alignment, T: Eq,

Auto Trait Implementations§

§

impl<A, T> Freeze for Aligned<A, T>
where T: Freeze + ?Sized, A: Freeze,

§

impl<A, T> RefUnwindSafe for Aligned<A, T>

§

impl<A, T> Send for Aligned<A, T>
where T: Send + ?Sized, A: Send,

§

impl<A, T> Sync for Aligned<A, T>
where T: Sync + ?Sized, A: Sync,

§

impl<A, T> Unpin for Aligned<A, T>
where T: Unpin + ?Sized, A: Unpin,

§

impl<A, T> UnwindSafe for Aligned<A, T>
where T: UnwindSafe + ?Sized, A: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.