Trait packed::Aligned [] [src]

pub unsafe trait Aligned: Sized {
    type Unaligned: Unaligned + Sized + Copy;
    fn is_aligned(unaligned: &Self::Unaligned) -> bool { ... }
    fn as_unaligned(&self) -> &Self::Unaligned { ... }
    unsafe fn as_unaligned_mut(&mut self) -> &mut Self::Unaligned { ... }
    fn from_unaligned_ref(unaligned: &Self::Unaligned) -> Option<&Self> { ... }
    unsafe fn from_unaligned_mut(unaligned: &mut Self::Unaligned) -> Option<&mut Self> { ... }
    unsafe fn from_unaligned_unchecked(unaligned: &Self::Unaligned) -> &Self { ... }
    unsafe fn from_unaligned_mut_unchecked(unaligned: &mut Self::Unaligned) -> &mut Self { ... }
    fn into_unaligned(self) -> Self::Unaligned { ... }
    unsafe fn from_unaligned(u: Self::Unaligned) -> Self { ... }
}

A trait for converting types with alignments greater than 1 into their unaligned equivalent.

Associated Types

type Unaligned: Unaligned + Sized + Copy

An unaligned representation of this type. Usually a u8 array of the same size.

Provided Methods

fn is_aligned(unaligned: &Self::Unaligned) -> bool

Determines whether an unaligned representation of this type is aligned.

fn as_unaligned(&self) -> &Self::Unaligned

Borrows the value as unaligned.

unsafe fn as_unaligned_mut(&mut self) -> &mut Self::Unaligned

Mutably borrows the value as unaligned.

fn from_unaligned_ref(unaligned: &Self::Unaligned) -> Option<&Self>

Borrows an unaligned type as an aligned value.

Returns None if unaligned is not aligned.

unsafe fn from_unaligned_mut(unaligned: &mut Self::Unaligned) -> Option<&mut Self>

Mutably borrows an unaligned type as an aligned value.

Returns None if unaligned is not aligned.

unsafe fn from_unaligned_unchecked(unaligned: &Self::Unaligned) -> &Self

Borrows an unaligned type as an aligned value, without first checking the alignment.

Causes undefined behaviour if used improprly!

unsafe fn from_unaligned_mut_unchecked(unaligned: &mut Self::Unaligned) -> &mut Self

Mutably borrows an unaligned type as an aligned value, without first checking the alignment.

Causes undefined behaviour if used improprly!

fn into_unaligned(self) -> Self::Unaligned

Converts a value to its unaligned representation without dropping self.

unsafe fn from_unaligned(u: Self::Unaligned) -> Self

Creates a value from its unaligned representation.

Implementors