[][src]Trait gvariant::Cast

pub trait Cast: AlignOf + AllBitPatternsValid + 'static + PartialEq + Debug + ToOwned {
    fn default_ref() -> &'static Self;
fn try_from_aligned_slice(
        slice: &AlignedSlice<Self::AlignOf>
    ) -> Result<&Self, WrongSize>;
fn try_from_aligned_slice_mut(
        slice: &mut AlignedSlice<Self::AlignOf>
    ) -> Result<&mut Self, WrongSize>; fn from_aligned_slice(slice: &AlignedSlice<Self::AlignOf>) -> &Self { ... } }

Trait implemented by all our types that have the same representation as the GVariant type

This allows casting appropriately aligned AlignedSlices to rust types.

Don't implement this class for your own types. It's already implemented for all appropriate types. It's automatically implemented for Structure types generated by the gv! macro.

Required methods

fn default_ref() -> &'static Self

Get a static reference to the default value for this type.

In GVariant every type has a default value which is used in certian circumstances in-lieu of returning errors during deserialisation. We're always dealing with references so std::default::Default isn't appropriate.

fn try_from_aligned_slice(
    slice: &AlignedSlice<Self::AlignOf>
) -> Result<&Self, WrongSize>

fn try_from_aligned_slice_mut(
    slice: &mut AlignedSlice<Self::AlignOf>
) -> Result<&mut Self, WrongSize>

Loading content...

Provided methods

fn from_aligned_slice(slice: &AlignedSlice<Self::AlignOf>) -> &Self

Cast slice to type Self.

This always succeeds. If the slice is the wrong size a defualt value is returned in accordance with the GVariant spec.

Loading content...

Implementations on Foreign Types

impl Cast for u8[src]

impl Cast for u16[src]

impl Cast for i16[src]

impl Cast for u32[src]

impl Cast for i32[src]

impl Cast for u64[src]

impl Cast for i64[src]

impl Cast for f64[src]

impl<'a, T: Cast + 'static + Copy> Cast for [T][src]

Loading content...

Implementors

impl Cast for Bool[src]

impl Cast for Str[src]

impl Cast for Variant[src]

impl<T: Cast + ?Sized> Cast for MaybeNonFixedSize<T>[src]

impl<T: Cast + ?Sized> Cast for NonFixedWidthArray<T>[src]

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

Loading content...