pub trait AlignedBytes:
Pod
+ Zeroable
+ Copy
+ Default
+ Eq {
type Unaligned: AsRef<[u8]> + AsMut<[u8]> + Index<usize, Output = u8> + IndexMut<usize, Output = u8> + for<'a> TryFrom<&'a [u8]> + Debug + Default + IntoIterator<Item = u8> + Pod;
const ALIGNMENT: usize;
const SIZE: usize;
// Required methods
fn to_unaligned(&self) -> Self::Unaligned;
fn from_unaligned(unaligned: Self::Unaligned) -> Self;
// Provided method
fn cast_vec_ref_mut<T: AlignedBytesCast<Self>>(
vec: &mut Vec<T>,
) -> &mut Vec<Self> { ... }
}
Expand description
A representation of a type as raw bytes with the same alignment as the original type.
Required Associated Constants§
Required Associated Types§
type Unaligned: AsRef<[u8]> + AsMut<[u8]> + Index<usize, Output = u8> + IndexMut<usize, Output = u8> + for<'a> TryFrom<&'a [u8]> + Debug + Default + IntoIterator<Item = u8> + Pod
Required Methods§
fn to_unaligned(&self) -> Self::Unaligned
fn from_unaligned(unaligned: Self::Unaligned) -> Self
Provided Methods§
Sourcefn cast_vec_ref_mut<T: AlignedBytesCast<Self>>(
vec: &mut Vec<T>,
) -> &mut Vec<Self>
fn cast_vec_ref_mut<T: AlignedBytesCast<Self>>( vec: &mut Vec<T>, ) -> &mut Vec<Self>
Safely cast a mutable reference to a Vec
of T
to a mutable reference of Self
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.