[][src]Struct gvariant::aligned_bytes::AlignedOffset

pub struct AlignedOffset<A: Alignment>(_, _)
where
    Self: BitOr,
    Self::Output: Into<Self>
;

Represents a usize that is some multiple of Alignment::ALIGNMENT.

AlignedOffset<A2> is essentially a usize that is multiple of 2. This is useful because you can slice a AlignedSlice<A2> and be statically guaranteed that the slice will still be aligned.

Use .try_new(), <usize>.try_into() or align_offset() to construct values of this type.

Implementations

impl<A: Alignment> AlignedOffset<A>[src]

pub fn to_usize(&self) -> usize[src]

Convert to usize

pub fn try_new(value: usize) -> Result<Self, Misaligned>[src]

Construct an AlignedOffset from a usize.

Result will be Err(Misaligned) if the passed value is not a multiple of the alignment of this type. This is provided in addition to the TryInto impl because there is less scope for type ambiguity with this function.

Trait Implementations

impl<A: Alignment> BitOr<AlignedOffset<A>> for AlignedOffset<A>[src]

type Output = AlignedOffset<A>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A1>> for AlignedOffset<A2>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A1>> for AlignedOffset<A4>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A1>> for AlignedOffset<A8>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A2>> for AlignedOffset<A1>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A2>> for AlignedOffset<A4>[src]

type Output = AlignedOffset<A2>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A2>> for AlignedOffset<A8>[src]

type Output = AlignedOffset<A2>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A4>> for AlignedOffset<A1>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A4>> for AlignedOffset<A2>[src]

type Output = AlignedOffset<A2>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A4>> for AlignedOffset<A8>[src]

type Output = AlignedOffset<A4>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A8>> for AlignedOffset<A1>[src]

type Output = AlignedOffset<A1>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A8>> for AlignedOffset<A2>[src]

type Output = AlignedOffset<A2>

The resulting type after applying the | operator.

impl BitOr<AlignedOffset<A8>> for AlignedOffset<A4>[src]

type Output = AlignedOffset<A4>

The resulting type after applying the | operator.

impl<A: Alignment> Borrow<usize> for AlignedOffset<A>[src]

impl<A: Clone + Alignment> Clone for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Copy + Alignment> Copy for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Debug + Alignment> Debug for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> Display for AlignedOffset<A>[src]

impl<A: Eq + Alignment> Eq for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> From<AlignedOffset<A>> for usize[src]

impl From<AlignedOffset<A2>> for AlignedOffset<A1>[src]

impl From<AlignedOffset<A4>> for AlignedOffset<A1>[src]

impl From<AlignedOffset<A4>> for AlignedOffset<A2>[src]

impl From<AlignedOffset<A8>> for AlignedOffset<A1>[src]

impl From<AlignedOffset<A8>> for AlignedOffset<A2>[src]

impl From<AlignedOffset<A8>> for AlignedOffset<A4>[src]

impl<A: Ord + Alignment> Ord for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: PartialEq + Alignment> PartialEq<AlignedOffset<A>> for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> PartialEq<AlignedOffset<A>> for usize[src]

impl<A: Alignment> PartialEq<usize> for AlignedOffset<A>[src]

impl<A: PartialOrd + Alignment> PartialOrd<AlignedOffset<A>> for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> PartialOrd<AlignedOffset<A>> for usize[src]

impl<A: Alignment> PartialOrd<usize> for AlignedOffset<A>[src]

impl<A: Alignment> StructuralEq for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> StructuralPartialEq for AlignedOffset<A> where
    Self: BitOr,
    Self::Output: Into<Self>, 
[src]

impl<A: Alignment> TryFrom<usize> for AlignedOffset<A>[src]

type Error = Misaligned

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<A> RefUnwindSafe for AlignedOffset<A> where
    A: RefUnwindSafe

impl<A> Send for AlignedOffset<A> where
    A: Send

impl<A> Sync for AlignedOffset<A> where
    A: Sync

impl<A> Unpin for AlignedOffset<A> where
    A: Unpin

impl<A> UnwindSafe for AlignedOffset<A> where
    A: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.