#[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. An opaque structure used to hold different types of values.

The data within the structure has protected scope: it is accessible only to functions within a GTypeValueTable structure, or implementations of the g_value_*() API. That is, code portions which implement new fundamental types.

Value users cannot make any assumptions about how data is stored within the 2 element data union, and the g_type member should only be accessed through the G_VALUE_TYPE() macro.

Implementations

Creates a new Value that is initialized with type_

Creates a new Value that is initialized for a given ValueType.

Tries to get a value of type T.

Returns Ok if the type is correct.

Tries to get a value of an owned type T.

Returns true if the type of the value corresponds to T or is a sub-type of T.

Returns true if the type of the value corresponds to type_ or is a sub-type of type_.

Returns the type of the value.

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

true if the transformation is possible, false otherwise.

Tries to transform the value into a value of the target type Tries to cast the contents of self into a type appropriate to store in dest_value, e.g. to transform a G_TYPE_INT value into a G_TYPE_FLOAT value. Performing transformations between value types might incur precision lossage. Especially transformations into strings might reveal seemingly arbitrary results and shouldn’t be relied upon for production code (such as rcfile value or object property serialization).

dest_value

Target value.

Returns

Whether a transformation rule was found and could be applied. Upon failing transformations, dest_value is left untouched.

Tries to transform the value into a value of the target type

Consumes Value and returns the corresponding GValue.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Value type checker.

Get the contained value from a Value. Read more

Value type checker.

Get the contained value from a Value. Read more

Convert a value to a Value.

Returns the type identifer of self. Read more

Convert a value to a Value.

Returns the type identifer of self. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.