#[repr(transparent)]pub struct Value { /* private fields */ }Expand description
A generic value capable of carrying various types.
Once created the type of the value can’t be changed.
Some types (e.g. String and objects) support None values while others
(e.g. numeric types) don’t.
Value does not implement the Send trait, but SendValue can be
used instead.
See the module documentation for more details.
Implementations§
source§impl Value
impl Value
pub fn as_ptr(&self) -> *mut GValue
sourcepub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GValue) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GValue) -> &'a Self
Borrows the underlying C value.
sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(ptr: *mut GValue) -> &'a mut Self
pub unsafe fn from_glib_ptr_borrow_mut<'a>(ptr: *mut GValue) -> &'a mut Self
Borrows the underlying C value mutably.
source§impl Value
impl Value
sourcepub fn from_type(type_: Type) -> Self
pub fn from_type(type_: Type) -> Self
Creates a new Value that is initialized with type_.
Panics
If type_ can’t be stored in a Value this function panics.
sourcepub unsafe fn from_type_unchecked(type_: Type) -> Self
pub unsafe fn from_type_unchecked(type_: Type) -> Self
Creates a new Value that is initialized with type_.
SAFETY
This must be called with a valid type_ that can be stored in Values.
sourcepub fn for_value_type<T: ValueType>() -> Self
pub fn for_value_type<T: ValueType>() -> Self
Creates a new Value that is initialized for a given ValueType.
sourcepub fn get<'a, T>(
&'a self
) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where
T: FromValue<'a>,
pub fn get<'a, T>( &'a self ) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where T: FromValue<'a>,
Tries to get a value of type T.
Returns Ok if the type is correct.
sourcepub fn get_owned<T>(
&self
) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where
T: for<'b> FromValue<'b> + 'static,
pub fn get_owned<T>( &self ) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where T: for<'b> FromValue<'b> + 'static,
Tries to get a value of an owned type T.
sourcepub fn is<T: StaticType>(&self) -> bool
pub fn is<T: StaticType>(&self) -> bool
Returns true if the type of the value corresponds to T
or is a sub-type of T.
sourcepub fn is_type(&self, type_: Type) -> bool
pub fn is_type(&self, type_: Type) -> bool
Returns true if the type of the value corresponds to type_
or is a sub-type of type_.
sourcepub fn type_transformable(src: Type, dst: Type) -> bool
pub fn type_transformable(src: Type, dst: Type) -> bool
Returns whether Values of type src can be transformed to type dst.
Check whether transform() is able to transform values
of type src_type into values of type dest_type. Note that for
the types to be transformable, they must be compatible or a
transformation function must be registered.
src_type
Source type.
dest_type
Target type.
Returns
sourcepub fn transform<T: ValueType>(&self) -> Result<Value, BoolError>
pub fn transform<T: ValueType>(&self) -> Result<Value, BoolError>
Tries to transform the value into a value of the target type
sourcepub fn transform_with_type(&self, type_: Type) -> Result<Value, BoolError>
pub fn transform_with_type(&self, type_: Type) -> Result<Value, BoolError>
Tries to transform the value into a value of the target type
pub fn try_into_send_value<T: Send + StaticType>( self ) -> Result<SendValue, Self>
Trait Implementations§
source§impl From<BindingFlags> for Value
impl From<BindingFlags> for Value
source§fn from(v: BindingFlags) -> Self
fn from(v: BindingFlags) -> Self
source§impl From<BoxedValue> for Value
impl From<BoxedValue> for Value
source§fn from(v: BoxedValue) -> Self
fn from(v: BoxedValue) -> Self
source§impl From<IOCondition> for Value
impl From<IOCondition> for Value
source§fn from(v: IOCondition) -> Self
fn from(v: IOCondition) -> Self
source§impl From<MainContext> for Value
impl From<MainContext> for Value
source§fn from(s: MainContext) -> Self
fn from(s: MainContext) -> Self
source§impl From<MarkupParseContext> for Value
impl From<MarkupParseContext> for Value
source§fn from(s: MarkupParseContext) -> Self
fn from(s: MarkupParseContext) -> Self
source§impl From<ValueArray> for Value
impl From<ValueArray> for Value
source§fn from(o: ValueArray) -> Self
fn from(o: ValueArray) -> Self
source§impl From<VariantDict> for Value
impl From<VariantDict> for Value
source§fn from(s: VariantDict) -> Self
fn from(s: VariantDict) -> Self
source§impl<'a> FromValue<'a> for &'a Value
impl<'a> FromValue<'a> for &'a Value
§type Checker = NopChecker
type Checker = NopChecker
source§unsafe fn from_value(value: &'a Value) -> Self
unsafe fn from_value(value: &'a Value) -> Self
Value. Read moresource§impl<'a> FromValue<'a> for Value
impl<'a> FromValue<'a> for Value
§type Checker = NopChecker
type Checker = NopChecker
source§unsafe fn from_value(value: &'a Value) -> Self
unsafe fn from_value(value: &'a Value) -> Self
Value. Read more