[][src]Macro gvariant::gv

macro_rules! gv {
    ($typestr:literal) => { ... };
}

Maps from GVariant typestrs to compatible Rust types returning a Marker. This Marker can then be used to cast data into that type by calling Marker::cast.

The signature is essentially fn gv(typestr : &str) -> impl Marker.

This is the main entrypoint to the library.

Given data that you want to interpret as a GVariant of type as you write:

gv!("as").cast(data);

Similarly if you want to interpret some data in a variant as an as you write:

v.get(gv!("as"));

The returned marker has a automatically generated type. Marker::TYPESTR will equal the typestr passed into the gv! invocation. Marker::Type is a type that has the same bit representation as GVariant type passed in.

The types are mapped as follows:

GVariant TypeRust TypeSized
bBoolYes
yu8Yes
ni16Yes
qu16Yes
ii32Yes
uu32Yes
xi64Yes
tu64Yes
df64Yes
sStrNo
oStrNo
gStrNo
vVariantNo
msMaybeNonFixedSize<Str> - and similarly for all non-Sized typesNo
miMaybeFixedSize<i32> - and similarly for all Sized typesNo
asNonFixedWidthArray<Str> - and similarly for all non-Sized typesNo
ai[i32] and similarly for all Sized typesNo
(sv)Custom struct generated by this macro. Implements .to_tuple() methodYes if all children are Sized
{si}Custom struct generated by this Macro. Implements .to_tuple() methodYes if all children are Sized