Struct glib::value::BoxedValue

source ·
pub struct BoxedValue(pub Value);
Expand description

A Value containing another Value.

Tuple Fields§

§0: Value

Methods from Deref<Target = Value>§

source

pub fn as_ptr(&self) -> *mut GValue

source

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.

source

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.

source

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.

source

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_.

source

pub fn type_(&self) -> Type

Returns the type of the value.

source

pub fn transform<T: ValueType>(&self) -> Result<Value, BoolError>

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.

source

pub fn transform_with_type(&self, type_: Type) -> Result<Value, BoolError>

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

Trait Implementations§

source§

impl Deref for BoxedValue

§

type Target = Value

The resulting type after dereferencing.
source§

fn deref(&self) -> &Value

Dereferences the value.
source§

impl From<BoxedValue> for Value

source§

fn from(v: BoxedValue) -> Self

Converts to this type from the input type.
source§

impl<'a> FromValue<'a> for BoxedValue

§

type Checker = GenericValueTypeOrNoneChecker<BoxedValue>

Value type checker.
source§

unsafe fn from_value(value: &'a Value) -> Self

Get the contained value from a Value. Read more
source§

impl StaticType for BoxedValue

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl ToValue for BoxedValue

source§

fn to_value(&self) -> Value

Convert a value to a Value.
source§

fn value_type(&self) -> Type

Returns the type identifer of self. Read more
source§

impl ToValueOptional for BoxedValue

source§

fn to_value_optional(s: Option<&Self>) -> Value

Convert an Option to a Value.
source§

impl ValueType for BoxedValue

§

type Type = BoxedValue

Type to get the Type from. Read more
source§

impl ValueTypeOptional for BoxedValue

Auto Trait Implementations§

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> 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> IntoClosureReturnValue for T
where T: Into<Value>,

source§

impl<T> StaticTypeExt for T
where T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

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

§

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> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

source§

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

§

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.
source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,