[−][src]Macro gvariant::gv
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 Type | Rust Type | Sized |
---|---|---|
b | Bool | Yes |
y | u8 | Yes |
n | i16 | Yes |
q | u16 | Yes |
i | i32 | Yes |
u | u32 | Yes |
x | i64 | Yes |
t | u64 | Yes |
d | f64 | Yes |
s | Str | No |
o | Str | No |
g | Str | No |
v | Variant | No |
ms | MaybeNonFixedSize<Str> - and similarly for all non-Sized types | No |
mi | MaybeFixedSize<i32> - and similarly for all Sized types | No |
as | NonFixedWidthArray<Str> - and similarly for all non-Sized types | No |
ai | [i32] and similarly for all Sized types | No |
(sv) | Custom struct generated by this macro. Implements .to_tuple() method | Yes if all children are Sized |
{si} | Custom struct generated by this Macro. Implements .to_tuple() method | Yes if all children are Sized |