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.
GLib type: Inline allocated boxed type with stack copy semantics.
Implementations§
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 from_static_str(s: &'static GStr) -> Self
pub fn from_static_str(s: &'static GStr) -> Self
Creates a new String-typed Value from a 'static string.
Sourcepub fn from_interned_str(s: &'static GStr) -> Self
Available on crate feature v2_66 only.
pub fn from_interned_str(s: &'static GStr) -> Self
v2_66 only.Creates a new String-typed Value from a 'static string that is also assumed to be
interned.
Sourcepub fn get<'a, T>(
&'a self,
) -> Result<T, <<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>where
T: FromValue<'a>,
pub fn get<'a, T>(
&'a self,
) -> Result<T, <<T as FromValue<'a>>::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.
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
Sourcepub fn try_into_send_value<T: Send + StaticType>(
self,
) -> Result<SendValue, Self>
pub fn try_into_send_value<T: Send + StaticType>( self, ) -> Result<SendValue, Self>
Converts a Value into a SendValue. This fails if self does not store a value of type
T. It is required for T to be Send to call this function.
Sourcepub unsafe fn into_send_value(self) -> SendValue
pub unsafe fn into_send_value(self) -> SendValue
Trait Implementations§
Source§impl Extend<Value> for ValueArray
impl Extend<Value> for ValueArray
Source§fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)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<ControlFlow> for Value
impl From<ControlFlow> for Value
Source§fn from(v: ControlFlow) -> Self
fn from(v: ControlFlow) -> 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<NonZero<i32>> for Value
impl From<NonZero<i32>> for Value
Source§fn from(v: NonZeroI32) -> Self
fn from(v: NonZeroI32) -> Self
Source§impl From<NonZero<i64>> for Value
impl From<NonZero<i64>> for Value
Source§fn from(v: NonZeroI64) -> Self
fn from(v: NonZeroI64) -> Self
Source§impl From<NonZero<u32>> for Value
impl From<NonZero<u32>> for Value
Source§fn from(v: NonZeroU32) -> Self
fn from(v: NonZeroU32) -> Self
Source§impl From<NonZero<u64>> for Value
impl From<NonZero<u64>> for Value
Source§fn from(v: NonZeroU64) -> Self
fn from(v: NonZeroU64) -> Self
Source§impl From<NormalizeMode> for Value
impl From<NormalizeMode> for Value
Source§fn from(v: NormalizeMode) -> Self
fn from(v: NormalizeMode) -> Self
Source§impl From<Propagation> for Value
impl From<Propagation> for Value
Source§fn from(v: Propagation) -> Self
fn from(v: Propagation) -> Self
Source§impl From<UnicodeBreakType> for Value
impl From<UnicodeBreakType> for Value
Source§fn from(v: UnicodeBreakType) -> Self
fn from(v: UnicodeBreakType) -> Self
Source§impl From<UnicodeScript> for Value
impl From<UnicodeScript> for Value
Source§fn from(v: UnicodeScript) -> Self
fn from(v: UnicodeScript) -> Self
Source§impl From<UnicodeType> for Value
impl From<UnicodeType> for Value
Source§fn from(v: UnicodeType) -> Self
fn from(v: UnicodeType) -> 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 FromIterator<Value> for ValueArray
impl FromIterator<Value> for ValueArray
Source§impl<'a> FromValue<'a> for &'a Value
impl<'a> FromValue<'a> for &'a Value
Source§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
Source§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