[−][src]Struct glib::VariantDict
VariantDict
is a mutable key/value store where the keys are always
strings and the values are Variant
s.
Variant dictionaries can easily be converted to/from Variant
s 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
impl VariantDict
[src]
pub fn new(from_asv: Option<&Variant>) -> Self
[src]
Create a new VariantDict
optionally populating it with the given Variant
Since Variant
s 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.
pub fn contains(&self, key: &str) -> bool
[src]
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
.
pub fn lookup_value(
&self,
key: &str,
expected_type: Option<&VariantTy>
) -> Option<Variant>
[src]
&self,
key: &str,
expected_type: Option<&VariantTy>
) -> Option<Variant>
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
.
pub fn insert_value(&self, key: &str, value: &Variant)
[src]
Insert a variant into the dictionary.
The given key
/value
pair is inserted into self
. If a value
was previously associated with key
then it is overwritten.
For convenience, you may use the insert()
if
you have a value which implements ToVariant
.
pub fn insert<T: ToVariant>(&self, key: &str, value: &T)
[src]
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.
pub fn remove(&self, key: &str) -> bool
[src]
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.
pub unsafe fn end_unsafe(&self) -> Variant
[src]
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
pub fn end(&self) -> Variant
[src]
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
impl Clone for VariantDict
[src]
fn clone(&self) -> VariantDict
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for VariantDict
[src]
impl From<Variant> for VariantDict
[src]
impl FromVariant for VariantDict
[src]
fn from_variant(variant: &Variant) -> Option<Self>
[src]
impl StaticType for VariantDict
[src]
fn static_type() -> Type
[src]
impl StaticVariantType for VariantDict
[src]
fn static_variant_type() -> Cow<'static, VariantTy>
[src]
impl ToVariant for VariantDict
[src]
fn to_variant(&self) -> Variant
[src]
Auto Trait Implementations
impl RefUnwindSafe for VariantDict
impl !Send for VariantDict
impl !Sync for VariantDict
impl Unpin for VariantDict
impl UnwindSafe for VariantDict
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)
fn to_glib_none_from_slice(
&'a [T]
) -> (*const GList, <T as ToGlibContainerFromSlice<'a, *const GList>>::Storage)
[src]
&'a [T]
) -> (*const GList, <T as ToGlibContainerFromSlice<'a, *const GList>>::Storage)
fn to_glib_container_from_slice(
&'a [T]
) -> (*const GList, <T as ToGlibContainerFromSlice<'a, *const GList>>::Storage)
[src]
&'a [T]
) -> (*const GList, <T as ToGlibContainerFromSlice<'a, *const GList>>::Storage)
fn to_glib_full_from_slice(&[T]) -> *const GList
[src]
impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)
fn to_glib_none_from_slice(
&'a [T]
) -> (*const GPtrArray, <T as ToGlibContainerFromSlice<'a, *const GPtrArray>>::Storage)
[src]
&'a [T]
) -> (*const GPtrArray, <T as ToGlibContainerFromSlice<'a, *const GPtrArray>>::Storage)
fn to_glib_container_from_slice(
&'a [T]
) -> (*const GPtrArray, <T as ToGlibContainerFromSlice<'a, *const GPtrArray>>::Storage)
[src]
&'a [T]
) -> (*const GPtrArray, <T as ToGlibContainerFromSlice<'a, *const GPtrArray>>::Storage)
fn to_glib_full_from_slice(&[T]) -> *const GPtrArray
[src]
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)
fn to_glib_none_from_slice(
&'a [T]
) -> (*mut GArray, <T as ToGlibContainerFromSlice<'a, *mut GArray>>::Storage)
[src]
&'a [T]
) -> (*mut GArray, <T as ToGlibContainerFromSlice<'a, *mut GArray>>::Storage)
fn to_glib_container_from_slice(
&'a [T]
) -> (*mut GArray, <T as ToGlibContainerFromSlice<'a, *mut GArray>>::Storage)
[src]
&'a [T]
) -> (*mut GArray, <T as ToGlibContainerFromSlice<'a, *mut GArray>>::Storage)
fn to_glib_full_from_slice(&[T]) -> *mut GArray
[src]
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)
fn to_glib_none_from_slice(
&'a [T]
) -> (*mut GList, <T as ToGlibContainerFromSlice<'a, *mut GList>>::Storage)
[src]
&'a [T]
) -> (*mut GList, <T as ToGlibContainerFromSlice<'a, *mut GList>>::Storage)
fn to_glib_container_from_slice(
&'a [T]
) -> (*mut GList, <T as ToGlibContainerFromSlice<'a, *mut GList>>::Storage)
[src]
&'a [T]
) -> (*mut GList, <T as ToGlibContainerFromSlice<'a, *mut GList>>::Storage)
fn to_glib_full_from_slice(&[T]) -> *mut GList
[src]
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)
fn to_glib_none_from_slice(
&'a [T]
) -> (*mut GPtrArray, <T as ToGlibContainerFromSlice<'a, *mut GPtrArray>>::Storage)
[src]
&'a [T]
) -> (*mut GPtrArray, <T as ToGlibContainerFromSlice<'a, *mut GPtrArray>>::Storage)
fn to_glib_container_from_slice(
&'a [T]
) -> (*mut GPtrArray, <T as ToGlibContainerFromSlice<'a, *mut GPtrArray>>::Storage)
[src]
&'a [T]
) -> (*mut GPtrArray, <T as ToGlibContainerFromSlice<'a, *mut GPtrArray>>::Storage)
fn to_glib_full_from_slice(&[T]) -> *mut GPtrArray
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToSendValue for T where
T: ToValue + SetValue + Send + ?Sized,
[src]
T: ToValue + SetValue + Send + ?Sized,
fn to_send_value(&Self) -> SendValue
[src]
impl<T> ToValue for T where
T: SetValue + ?Sized,
[src]
T: SetValue + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,