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 { ... } }
Expand description

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

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.

Provided Methods

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.

Implementations on Foreign Types

Implementors