[][src]Struct gvariant::MaybeFixedSize

#[repr(transparent)]pub struct MaybeFixedSize<T: Cast> { /* fields omitted */ }

Type with same representation as GVariant "mX" type where X is any fixed size type

This is the type returned by:

gv!("mb").cast(data);
gv!("mi").cast(data);
gv!("m(yi)").cast(data);

Rust's built in Option doesn't have any specified byte representation so we need our own type here.

Maybes are encoded differently depending on if their element type is fixed-sized or not. MaybeNonFixedSize is used when the contained size is non-fixed, but it implements the same interface as this type

You probably just want to call .to_option() on this type.

Implementations

impl<T: Cast> MaybeFixedSize<T>[src]

pub fn to_option(&self) -> Option<&T>[src]

Convert to a rust native Option type.

Note: this doesn't copy the data, it returns an option to a reference to the underlying data.

Trait Implementations

impl<T: Cast> AlignOf for MaybeFixedSize<T>[src]

type AlignOf = T::AlignOf

impl<T: Cast> AllBitPatternsValid for MaybeFixedSize<T>[src]

impl<T: Cast> Cast for MaybeFixedSize<T>[src]

impl<T: Cast + Debug> Debug for MaybeFixedSize<T>[src]

impl<T: Cast + Eq> Eq for MaybeFixedSize<T>[src]

impl<'a, T: Cast> From<&'a MaybeFixedSize<T>> for Option<&'a T>[src]

impl<T: Cast + Hash> Hash for MaybeFixedSize<T>[src]

impl<'a, T: Cast> IntoIterator for &'a MaybeFixedSize<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = IntoIter<&'a T>

Which kind of iterator are we turning this into?

impl<'_, '_, T: Cast + PartialEq> PartialEq<&'_ MaybeFixedSize<T>> for Option<&'_ T>[src]

impl<T: Cast + PartialEq> PartialEq<MaybeFixedSize<T>> for MaybeFixedSize<T>[src]

impl<'_, '_, T: Cast + PartialEq> PartialEq<Option<&'_ T>> for &'_ MaybeFixedSize<T>[src]

impl<T: Cast + PartialOrd> PartialOrd<MaybeFixedSize<T>> for MaybeFixedSize<T>[src]

impl<T: Cast> RefCast for MaybeFixedSize<T>[src]

type From = AlignedSlice<T::AlignOf>

impl<'a, GvT: Cast + SerializeTo<GvT>> SerializeTo<MaybeFixedSize<GvT>> for &'a MaybeFixedSize<GvT> where
    &'a GvT: SerializeTo<GvT>, 
[src]

impl<'_, GvT: Cast, T: SerializeTo<GvT> + Copy> SerializeTo<MaybeFixedSize<GvT>> for &'_ Option<T> where
    T: SerializeTo<GvT>, 
[src]

impl<T: Cast> ToOwned for MaybeFixedSize<T>[src]

type Owned = Box<Self>

The resulting type after obtaining ownership.

Auto Trait Implementations

impl<T> RefUnwindSafe for MaybeFixedSize<T> where
    T: RefUnwindSafe,
    <T as AlignOf>::AlignOf: RefUnwindSafe

impl<T> Send for MaybeFixedSize<T> where
    T: Send,
    <T as AlignOf>::AlignOf: Send

impl<T> Sync for MaybeFixedSize<T> where
    T: Sync,
    <T as AlignOf>::AlignOf: Sync

impl<T> Unpin for MaybeFixedSize<T> where
    T: Unpin,
    <T as AlignOf>::AlignOf: Unpin

impl<T> UnwindSafe for MaybeFixedSize<T> where
    T: UnwindSafe,
    <T as AlignOf>::AlignOf: 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, 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.