Struct glib::VariantDict [−][src]
pub struct VariantDict(_);
Expand description
VariantDict is a mutable key/value store where the keys are always
strings and the values are Variants.
Variant dictionaries can easily be converted to/from Variants of the
appropriate type. In glib terms, this is a variant of the form "a{sv}".
Panics
Note, pretty much all methods on this struct will panic if the
end_unsafe() method was called on the instance.
Implementations
Create a new VariantDict optionally populating it with the given Variant
Since Variants are immutable, this does not couple the VariantDict with
the input Variant, instead the contents are copied into the VariantDict.
Panics
This function will panic if the given Variant is not of the correct type.
Check if this VariantDict contains the given key.
Look up whether or not the given key is present, returning true if it
is present in self.
Look up and return a value from this VariantDict.
The given key is looked up in self. If expected_type is not
None then it will be matched against the type of any found value.
This will return None if the key is not present in the dictionary
or if it is present but the type of the value does not match a given
expected_type. Otherwise Some(value) will be returned where
the value is an instance of Variant.
Insert a value into the dictionary
The given key/value pair is inserted into self. If a value
was previously associated with key then it is overwritten.
This is a convenience method which automatically calls
to_variant() for you
on the given value.
If, on the other hand, you have a Variant
instance already, you should use the insert_value()
method instead.
Remove the given key from the dictionary.
This removes the given key from the dictionary, releasing the reference
on the associated value if one is present.
If a key/value pair was removed from the dictionary, true is
returned. If key was not present then false is returned instead.
Convert this dictionary to a Variant
This method converts self into an instance of Variant
but in doing so renders it very unsafe to use.
Safety
After calling this, the underlying GVariantDict is in a state where
the only valid operations to perform as reference ones. As such
any attempt to read/update the dictionary will fail and emit warnings
of such.
You should only use this function if the extra cost of the safe function is too much for your performance critical codepaths
Convert this dictionary to a Variant
This method converts self into an instance of Variant
and then reinitialises itself in order to be safe for further use.
If you are certain that nothing other than disposing of references will
be done subsequent to ending the instance, you can call the
end_unsafe() method instead to avoid the unnecessary
reinitialisation of the dictionary.
Trait Implementations
Tries to extract a value. Read more
Returns the type identifier of Self.
Returns the VariantType corresponding to Self.
Returns a Variant clone of self.
Auto Trait Implementations
impl RefUnwindSafe for VariantDictimpl !Send for VariantDictimpl !Sync for VariantDictimpl Unpin for VariantDictimpl UnwindSafe for VariantDictBlanket Implementations
Mutably borrows from an owned value. Read more
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,