Struct Value
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§
§impl Value
impl Value
pub fn from_type(type_: Type) -> Value
pub fn from_type(type_: Type) -> Value
Creates a new Value that is initialized with type_.
§Panics
If type_ can’t be stored in a Value this function panics.
pub unsafe fn from_type_unchecked(type_: Type) -> Value
pub unsafe fn from_type_unchecked(type_: Type) -> Value
Creates a new Value that is initialized with type_.
§SAFETY
This must be called with a valid type_ that can be stored in Values.
pub fn for_value_type<T>() -> Valuewhere
T: ValueType,
pub fn for_value_type<T>() -> Valuewhere
T: ValueType,
Creates a new Value that is initialized for a given ValueType.
pub fn from_static_str(s: &'static GStr) -> Value
pub fn from_static_str(s: &'static GStr) -> Value
Creates a new String-typed Value from a 'static string.
pub fn from_interned_str(s: &'static GStr) -> Value
pub fn from_interned_str(s: &'static GStr) -> Value
Creates a new String-typed Value from a 'static string that is also assumed to be
interned.
pub 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.
pub 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.
pub fn is<T>(&self) -> boolwhere
T: StaticType,
pub fn is<T>(&self) -> boolwhere
T: StaticType,
Returns true if the type of the value corresponds to T
or is a sub-type of T.
pub 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_.
pub 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.
pub fn transform<T>(&self) -> Result<Value, BoolError>where
T: ValueType,
pub fn transform<T>(&self) -> Result<Value, BoolError>where
T: ValueType,
Tries to transform the value into a value of the target type
pub 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>(self) -> Result<SendValue, Value>where
T: Send + StaticType,
pub fn try_into_send_value<T>(self) -> Result<SendValue, Value>where
T: Send + StaticType,
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.
pub unsafe fn into_send_value(self) -> SendValue
pub unsafe fn into_send_value(self) -> SendValue
Trait Implementations§
§impl Extend<Value> for ValueArray
impl Extend<Value> for ValueArray
§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Value>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Value>,
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)§impl From<BindingFlags> for Value
impl From<BindingFlags> for Value
§fn from(v: BindingFlags) -> Value
fn from(v: BindingFlags) -> Value
§impl From<BoxedValue> for Value
impl From<BoxedValue> for Value
§fn from(v: BoxedValue) -> Value
fn from(v: BoxedValue) -> Value
§impl From<ControlFlow> for Value
impl From<ControlFlow> for Value
§fn from(v: ControlFlow) -> Value
fn from(v: ControlFlow) -> Value
§impl From<IOCondition> for Value
impl From<IOCondition> for Value
§fn from(v: IOCondition) -> Value
fn from(v: IOCondition) -> Value
§impl From<MainContext> for Value
impl From<MainContext> for Value
§fn from(s: MainContext) -> Value
fn from(s: MainContext) -> Value
§impl From<MarkupParseContext> for Value
impl From<MarkupParseContext> for Value
§fn from(s: MarkupParseContext) -> Value
fn from(s: MarkupParseContext) -> Value
§impl From<NormalizeMode> for Value
impl From<NormalizeMode> for Value
§fn from(v: NormalizeMode) -> Value
fn from(v: NormalizeMode) -> Value
§impl From<Propagation> for Value
impl From<Propagation> for Value
§fn from(v: Propagation) -> Value
fn from(v: Propagation) -> Value
§impl From<UnicodeBreakType> for Value
impl From<UnicodeBreakType> for Value
§fn from(v: UnicodeBreakType) -> Value
fn from(v: UnicodeBreakType) -> Value
§impl From<UnicodeScript> for Value
impl From<UnicodeScript> for Value
§fn from(v: UnicodeScript) -> Value
fn from(v: UnicodeScript) -> Value
§impl From<UnicodeType> for Value
impl From<UnicodeType> for Value
§fn from(v: UnicodeType) -> Value
fn from(v: UnicodeType) -> Value
§impl From<ValueArray> for Value
impl From<ValueArray> for Value
§fn from(o: ValueArray) -> Value
fn from(o: ValueArray) -> Value
§impl From<VariantDict> for Value
impl From<VariantDict> for Value
§fn from(s: VariantDict) -> Value
fn from(s: VariantDict) -> Value
§impl FromIterator<Value> for ValueArray
impl FromIterator<Value> for ValueArray
§fn from_iter<T>(iter: T) -> ValueArraywhere
T: IntoIterator<Item = Value>,
fn from_iter<T>(iter: T) -> ValueArraywhere
T: IntoIterator<Item = Value>,
§impl<'a> FromValue<'a> for &'a Value
impl<'a> FromValue<'a> for &'a Value
§type Checker = NopChecker
type Checker = NopChecker
§unsafe fn from_value(value: &'a Value) -> &'a Value
unsafe fn from_value(value: &'a Value) -> &'a Value
Value. Read more§impl<'a> FromValue<'a> for Value
impl<'a> FromValue<'a> for Value
§type Checker = NopChecker
type Checker = NopChecker
§unsafe fn from_value(value: &'a Value) -> Value
unsafe fn from_value(value: &'a Value) -> Value
Value. Read moreAuto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more