Trait glib::value::ToValue

source ·
pub trait ToValue {
    // Required methods
    fn to_value(&self) -> Value;
    fn value_type(&self) -> Type;
}
Expand description

Trait to convert a value to a Value.

Similar to other common conversion traits, the following invariants are guaranteed:

  • Invertibility: x.to_value().get().unwrap() == x. In words, FromValue is the inverse of ToValue.
  • Idempotence: x.to_value() == x.to_value().to_value(). In words, applying ToValue multiple times yields the same result as applying it once. Idempotence also applies the other way around: value.get::<Value>() is a no-op.

There is also the possibility to wrap values within values, see BoxedValue. All (un-)boxing needs to be done manually, and will be preserved under the conversion methods.

The conversion methods may cause values to be cloned, which may result in reference counter changes or heap allocations depending on the source and target type.

Required Methods§

source

fn to_value(&self) -> Value

Convert a value to a Value.

source

fn value_type(&self) -> Type

Returns the type identifer of self.

This is the type of the value to be returned by to_value.

Implementations on Foreign Types§

source§

impl ToValue for u32

source§

impl ToValue for Vec<String>

source§

impl ToValue for u64

source§

impl ToValue for NonNull<Pointee>

source§

impl ToValue for i64

source§

impl ToValue for i32

source§

impl<'a> ToValue for &'a [&'a str]

source§

impl ToValue for &str

source§

impl ToValue for i8

source§

impl<T: ToValue + StaticType> ToValue for &T

Blanket implementation for all references.

source§

impl ToValue for f64

source§

impl ToValue for String

source§

impl ToValue for u8

source§

impl<'a> ToValue for [&'a str]

source§

impl ToValue for Vec<GString>

source§

impl ToValue for str

source§

impl<T: ToValueOptional + StaticType> ToValue for Option<T>

Blanket implementation for all optional types.

source§

impl ToValue for f32

source§

impl ToValue for bool

source§

impl ToValue for char

Implementors§

source§

impl ToValue for &GStr

source§

impl ToValue for Inhibit

source§

impl ToValue for BindingFlags

source§

impl ToValue for GStr

source§

impl ToValue for GString

source§

impl ToValue for IOCondition

source§

impl ToValue for ILong

source§

impl ToValue for ULong

source§

impl ToValue for BoxedValue

source§

impl ToValue for SendValue

source§

impl ToValue for Value

source§

impl ToValue for Pointer

source§

impl<'a> ToValue for &'a SendValue

source§

impl<'a> ToValue for &'a Value

impl ToValue for Operator

impl ToValue for Format

impl ToValue for Filter

impl ToValue for Device

impl ToValue for Surface

impl ToValue for FontType

impl ToValue for LineJoin

impl ToValue for Region

impl ToValue for Context

impl ToValue for LineCap

impl ToValue for FillRule

impl ToValue for Content

impl ToValue for Matrix

impl ToValue for Extend

impl ToValue for BusType

impl ToValue for TlsError

impl ToValue for FileType

impl ToValue for Script

impl ToValue for Weight

impl ToValue for Variant

impl ToValue for Gravity

impl ToValue for BidiType

impl ToValue for Style

impl ToValue for WrapMode

impl ToValue for Stretch

impl ToValue for TabAlign

impl ToValue for AttrType

impl ToValue for Overline

impl ToValue for FontMask