Struct glib::VariantType
source · [−]pub struct VariantType { /* private fields */ }
Expand description
Describes Variant
types.
The Variant
type system (based on the D-Bus one) describes types with
“type strings”. VariantType
is an owned immutable type string (you can
think of it as a Box<str>
statically guaranteed to be a valid type
string), &VariantTy
is a borrowed one (like &str
).
Implementations
sourceimpl VariantType
impl VariantType
sourcepub fn new(type_string: &str) -> Result<VariantType, BoolError>
pub fn new(type_string: &str) -> Result<VariantType, BoolError>
Tries to create a VariantType
from a string slice.
Returns Ok
if the string is a valid type string, Err
otherwise.
sourcepub fn new_dict_entry(
key_type: &VariantTy,
value_type: &VariantTy
) -> VariantType
pub fn new_dict_entry(
key_type: &VariantTy,
value_type: &VariantTy
) -> VariantType
Creates a VariantType
from a key and value type.
sourcepub fn new_array(elem_type: &VariantTy) -> VariantType
pub fn new_array(elem_type: &VariantTy) -> VariantType
Creates a VariantType
from an array element type.
sourcepub fn new_maybe(child_type: &VariantTy) -> VariantType
pub fn new_maybe(child_type: &VariantTy) -> VariantType
Creates a VariantType
from a maybe element type.
sourcepub fn new_tuple<T: AsRef<VariantTy>, I: IntoIterator<Item = T>>(
items: I
) -> VariantType
pub fn new_tuple<T: AsRef<VariantTy>, I: IntoIterator<Item = T>>(
items: I
) -> VariantType
Creates a VariantType
from a maybe element type.
sourcepub fn from_string(
type_string: impl Into<GString>
) -> Result<VariantType, BoolError>
pub fn from_string(
type_string: impl Into<GString>
) -> Result<VariantType, BoolError>
Tries to create a VariantType
from an owned string.
Returns Ok
if the string is a valid type string, Err
otherwise.
Methods from Deref<Target = VariantTy>
pub const BOOLEAN: &'static VariantTy = _
pub const BYTE: &'static VariantTy = _
pub const INT16: &'static VariantTy = _
pub const UINT16: &'static VariantTy = _
pub const INT32: &'static VariantTy = _
pub const UINT32: &'static VariantTy = _
pub const INT64: &'static VariantTy = _
pub const UINT64: &'static VariantTy = _
pub const DOUBLE: &'static VariantTy = _
pub const STRING: &'static VariantTy = _
pub const OBJECT_PATH: &'static VariantTy = _
pub const SIGNATURE: &'static VariantTy = _
pub const VARIANT: &'static VariantTy = _
pub const HANDLE: &'static VariantTy = _
pub const UNIT: &'static VariantTy = _
pub const ANY: &'static VariantTy = _
pub const BASIC: &'static VariantTy = _
pub const MAYBE: &'static VariantTy = _
pub const ARRAY: &'static VariantTy = _
pub const TUPLE: &'static VariantTy = _
pub const DICT_ENTRY: &'static VariantTy = _
pub const DICTIONARY: &'static VariantTy = _
pub const STRING_ARRAY: &'static VariantTy = _
pub const OBJECT_PATH_ARRAY: &'static VariantTy = _
pub const BYTE_STRING: &'static VariantTy = _
pub const BYTE_STRING_ARRAY: &'static VariantTy = _
pub const VARDICT: &'static VariantTy = _
sourcepub fn is_definite(&self) -> bool
pub fn is_definite(&self) -> bool
Check if this variant type is a definite type.
sourcepub fn is_container(&self) -> bool
pub fn is_container(&self) -> bool
Check if this variant type is a container type.
sourcepub fn is_dict_entry(&self) -> bool
pub fn is_dict_entry(&self) -> bool
Check if this variant type is a dict entry type.
sourcepub fn is_variant(&self) -> bool
pub fn is_variant(&self) -> bool
Check if this variant type is a variant.
sourcepub fn is_subtype_of(&self, supertype: &Self) -> bool
pub fn is_subtype_of(&self, supertype: &Self) -> bool
Check if this variant type is a subtype of another.
sourcepub fn element(&self) -> &VariantTy
pub fn element(&self) -> &VariantTy
Return the element type of this variant type.
Panics
This function panics if not called with an array or maybe type.
sourcepub fn tuple_types(&self) -> VariantTyIterator<'_>ⓘNotable traits for VariantTyIterator<'a>impl<'a> Iterator for VariantTyIterator<'a> type Item = &'a VariantTy;
pub fn tuple_types(&self) -> VariantTyIterator<'_>ⓘNotable traits for VariantTyIterator<'a>impl<'a> Iterator for VariantTyIterator<'a> type Item = &'a VariantTy;
Iterate over the types of this variant type.
Panics
This function panics if not called with a tuple or dictionary entry type.
sourcepub fn first(&self) -> Option<&VariantTy>
pub fn first(&self) -> Option<&VariantTy>
Return the first type of this variant type.
Panics
This function panics if not called with a tuple or dictionary entry type.
Trait Implementations
sourceimpl AsRef<VariantTy> for VariantType
impl AsRef<VariantTy> for VariantType
sourceimpl Borrow<VariantTy> for VariantType
impl Borrow<VariantTy> for VariantType
sourceimpl Clone for VariantType
impl Clone for VariantType
sourcefn clone(&self) -> VariantType
fn clone(&self) -> VariantType
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VariantType
impl Debug for VariantType
sourceimpl Deref for VariantType
impl Deref for VariantType
sourceimpl Display for VariantType
impl Display for VariantType
sourceimpl Drop for VariantType
impl Drop for VariantType
sourceimpl<'a> From<VariantType> for Cow<'a, VariantTy>
impl<'a> From<VariantType> for Cow<'a, VariantTy>
sourcefn from(ty: VariantType) -> Cow<'a, VariantTy>
fn from(ty: VariantType) -> Cow<'a, VariantTy>
Converts to this type from the input type.
sourceimpl FromStr for VariantType
impl FromStr for VariantType
sourceimpl Hash for VariantType
impl Hash for VariantType
sourceimpl<'a, 'b> PartialEq<&'a VariantTy> for VariantType
impl<'a, 'b> PartialEq<&'a VariantTy> for VariantType
sourceimpl<'a, 'b> PartialEq<&'a str> for VariantType
impl<'a, 'b> PartialEq<&'a str> for VariantType
sourceimpl<'a, 'b> PartialEq<Cow<'a, VariantTy>> for VariantType
impl<'a, 'b> PartialEq<Cow<'a, VariantTy>> for VariantType
sourceimpl<'a, 'b> PartialEq<String> for VariantType
impl<'a, 'b> PartialEq<String> for VariantType
sourceimpl<'a, 'b> PartialEq<VariantTy> for VariantType
impl<'a, 'b> PartialEq<VariantTy> for VariantType
sourceimpl<'a, 'b> PartialEq<VariantType> for &'a VariantTy
impl<'a, 'b> PartialEq<VariantType> for &'a VariantTy
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a, 'b> PartialEq<VariantType> for &'a str
impl<'a, 'b> PartialEq<VariantType> for &'a str
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a, 'b> PartialEq<VariantType> for Cow<'a, VariantTy>
impl<'a, 'b> PartialEq<VariantType> for Cow<'a, VariantTy>
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a, 'b> PartialEq<VariantType> for String
impl<'a, 'b> PartialEq<VariantType> for String
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a, 'b> PartialEq<VariantType> for VariantTy
impl<'a, 'b> PartialEq<VariantType> for VariantTy
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<VariantType> for VariantType
impl PartialEq<VariantType> for VariantType
sourceimpl<'a, 'b> PartialEq<VariantType> for str
impl<'a, 'b> PartialEq<VariantType> for str
sourcefn eq(&self, other: &VariantType) -> bool
fn eq(&self, other: &VariantType) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a, 'b> PartialEq<str> for VariantType
impl<'a, 'b> PartialEq<str> for VariantType
sourceimpl StaticType for VariantType
impl StaticType for VariantType
sourcefn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl Eq for VariantType
impl Send for VariantType
impl Sync for VariantType
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> StaticTypeExt for T where
T: StaticType,
impl<T> StaticTypeExt for T where
T: StaticType,
sourcefn ensure_type()
fn ensure_type()
Ensures that the type has been registered with the type system.
sourceimpl<T> ToClosureReturnValue for T where
T: ToValue,
impl<T> ToClosureReturnValue for T where
T: ToValue,
fn to_closure_return_value(&self) -> Option<Value>
sourceimpl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
impl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
sourcefn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
Returns a SendValue
clone of self
.