Struct glib::variant::Variant [−][src]
pub struct Variant(_);
Expand description
A generic immutable value capable of carrying various types.
See the module documentation for more details.
Implementations
Returns true
if the type of the value corresponds to T
.
Tries to extract a value of type T
.
Returns Some
if T
matches the variant’s type.
Boxes value.
Unboxes self.
Returns Some
if self contains a Variant
.
Reads a child item out of a container Variant
instance.
Panics
- if
self
is not a container type. - if given
index
is larger than number of children.
Tries to extract a &str
.
Returns Some
if the variant has a string type (s
, o
or g
type
strings).
Creates a new GVariant array from children.
All children must be of type T
.
Creates a new GVariant tuple from children.
Creates a new maybe Variant.
Constructs a new serialised-mode GVariant instance.
Constructs a new serialised-mode GVariant instance.
This is the same as from_bytes
, except that checks on the passed
data are skipped.
You should not use this function on data from external sources.
Safety
Since the data is not validated, this is potentially dangerous if called on bytes which are not guaranteed to have come from serialising another Variant. The caller is responsible for ensuring bad data is not passed in.
Returns the serialised form of a GVariant instance.
Determines the number of children in a container GVariant instance.
pub fn iter(&self) -> VariantIterⓘNotable traits for VariantIter
impl Iterator for VariantIter type Item = Variant;
pub fn iter(&self) -> VariantIterⓘNotable traits for VariantIter
impl Iterator for VariantIter type Item = Variant;
Create an iterator over items in the variant.
Variant has a container type.
Trait Implementations
Tries to extract a value. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Returns the VariantType
corresponding to Self
.
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,