[][src]Trait gvariant::aligned_bytes::AsAligned

pub trait AsAligned<A: Alignment> {
    fn as_aligned(&self) -> &AlignedSlice<A>;
}

Allows narrowing the alignment of a &AlignedSlice

This can be convenient to accept any AlignedSlice with sufficient alignment as an argument to a function. For example:

fn foo(data : &impl AsAligned<A2>) {
    let data = data.as_aligned();

or if a function requires a specific alignment you can do:

bar(data.as_aligned());

Mostly we convert from AlignedSlice<A8> -> AlignedSlice<A4> -> AlignedSlice<A2> -> AlignedSlice<A1>, but this can also be used to go from &[u8] to AlignedSlice<A1>.

This is intended as a 0 overhead abstraction. In release mode this should compile down to nothing.

Required methods

fn as_aligned(&self) -> &AlignedSlice<A>

Loading content...

Implementations on Foreign Types

impl AsAligned<A1> for [u8][src]

Loading content...

Implementors

impl<FromA: Alignment, ToA: Alignment> AsAligned<ToA> for AlignedSlice<FromA> where
    FromA: AlignedTo<ToA>, 
[src]

impl<T: AsRef<[u8]>> AsAligned<A1> for T[src]

Loading content...