pub struct BoxedValue(pub Value);
Tuple Fields§
§0: Value
Methods from Deref<Target = Value>§
pub fn as_ptr(&self) -> *mut GValue
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 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
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.
Trait Implementations§
Source§impl Deref for BoxedValue
impl Deref for BoxedValue
Source§impl From<BoxedValue> for Value
impl From<BoxedValue> for Value
Source§fn from(v: BoxedValue) -> Self
fn from(v: BoxedValue) -> Self
Source§impl<'a> FromValue<'a> for BoxedValue
impl<'a> FromValue<'a> for BoxedValue
Source§type Checker = GenericValueTypeOrNoneChecker<BoxedValue>
type Checker = GenericValueTypeOrNoneChecker<BoxedValue>
Source§unsafe fn from_value(value: &'a Value) -> Self
unsafe fn from_value(value: &'a Value) -> Self
Value
. Read moreSource§impl StaticType for BoxedValue
impl StaticType for BoxedValue
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.Source§impl ToValue for BoxedValue
impl ToValue for BoxedValue
Source§impl ToValueOptional for BoxedValue
impl ToValueOptional for BoxedValue
Source§fn to_value_optional(s: Option<&Self>) -> Value
fn to_value_optional(s: Option<&Self>) -> Value
Option
to a Value
.Source§impl ValueType for BoxedValue
impl ValueType for BoxedValue
Source§type Type = BoxedValue
type Type = BoxedValue
Type
from. Read more