Struct Value

Source
#[repr(C)]
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

Source

pub fn from_type(type_: Type) -> Self

Creates a new Value that is initialized with type_

Source

pub fn downcast<'a, T: FromValueOptional<'a> + SetValue>( self, ) -> Result<TypedValue<T>, Self>

Tries to downcast to a TypedValue.

Returns Ok(TypedValue<T>) if the value carries a type corresponding to T and Err(self) otherwise.

Source

pub fn downcast_ref<'a, T: FromValueOptional<'a> + SetValue>( &self, ) -> Option<&TypedValue<T>>

Tries to downcast to a &TypedValue.

Returns Some(&TypedValue<T>) if the value carries a type corresponding to T and None otherwise.

Source

pub fn get<'a, T: FromValueOptional<'a>>(&'a self) -> Option<T>

Tries to get a value of type T.

Returns Some if the type is correct and the value is not None.

This function doesn’t distinguish between type mismatches and correctly typed None values. Use downcast or is for that.

Source

pub fn is<'a, T: FromValueOptional<'a> + SetValue>(&self) -> bool

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

Source

pub fn type_(&self) -> Type

Returns the type of the value.

Source

pub fn type_transformable(src: Type, dst: Type) -> bool

Returns whether Values of type src can be transformed to type dst.

Source

pub fn try_into_send_value<'a, T: Send + FromValueOptional<'a> + SetValue>( self, ) -> Result<SendValue, Self>

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for Value

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, T: ?Sized + SetValue> From<&'a T> for Value

Source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized + SetValueOptional> From<Option<&'a T>> for Value

Source§

fn from(value: Option<&'a T>) -> Self

Converts to this type from the input type.
Source§

impl From<SendValue> for Value

Source§

fn from(value: SendValue) -> Self

Converts to this type from the input type.
Source§

impl<T> From<TypedValue<T>> for Value

Source§

fn from(value: TypedValue<T>) -> Self

Converts to this type from the input type.
Source§

impl FromGlibContainerAsVec<*mut GValue, *const *mut GValue> for Value

Source§

impl FromGlibContainerAsVec<*mut GValue, *mut *mut GValue> for Value

Source§

impl FromGlibPtrArrayContainerAsVec<*mut GValue, *const *mut GValue> for Value

Source§

impl FromGlibPtrArrayContainerAsVec<*mut GValue, *mut *mut GValue> for Value

Source§

impl FromGlibPtrFull<*mut GValue> for Value

Source§

unsafe fn from_glib_full(ptr: *mut GValue) -> Self

Source§

impl FromGlibPtrNone<*const GValue> for Value

Source§

unsafe fn from_glib_none(ptr: *const GValue) -> Self

Source§

impl FromGlibPtrNone<*mut GValue> for Value

Source§

unsafe fn from_glib_none(ptr: *mut GValue) -> Self

Source§

impl ToValue for Value

Source§

fn to_value(&self) -> Value

Returns a Value clone of self.
Source§

fn to_value_type(&self) -> Type

Returns the type identifer of self. Read more
Source§

impl Uninitialized for Value

Source§

unsafe fn uninitialized() -> Value

Returns an uninitialized value.

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.