glib::value

Trait 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 identifier of self.

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

Implementations on Foreign Types§

Source§

impl ToValue for &str

Source§

impl ToValue for &Path

Source§

impl ToValue for &[&str]

Source§

impl ToValue for bool

Source§

impl ToValue for char

Source§

impl ToValue for f32

Source§

impl ToValue for f64

Source§

impl ToValue for i8

Source§

impl ToValue for i32

Source§

impl ToValue for i64

Source§

impl ToValue for str

Source§

impl ToValue for u8

Source§

impl ToValue for u32

Source§

impl ToValue for u64

Source§

impl ToValue for Box<str>

Source§

impl ToValue for String

Source§

impl ToValue for Vec<GString>

Source§

impl ToValue for Vec<String>

Source§

impl ToValue for NonNull<Pointee>

Source§

impl ToValue for Path

Source§

impl ToValue for PathBuf

Source§

impl ToValue for NonZeroI8

Source§

impl ToValue for NonZeroI32

Source§

impl ToValue for NonZeroI64

Source§

impl ToValue for NonZeroU8

Source§

impl ToValue for NonZeroU32

Source§

impl ToValue for NonZeroU64

Source§

impl ToValue for [&str]

Source§

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

Blanket implementation for all references.

Source§

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

Blanket implementation for all optional types.

Implementors§

Source§

impl ToValue for &GStr

Source§

impl ToValue for &SendValue

Source§

impl ToValue for &Value

Source§

impl ToValue for ControlFlow

Source§

impl ToValue for NormalizeMode

Source§

impl ToValue for UnicodeBreakType

Source§

impl ToValue for UnicodeScript

Source§

impl ToValue for UnicodeType

Source§

impl ToValue for Propagation

Source§

impl ToValue for StrV

Source§

impl ToValue for MatchInfo<'static>

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

impl ToValue for Content

impl ToValue for Extend

impl ToValue for FillRule

impl ToValue for Filter

impl ToValue for FontType

impl ToValue for Format

impl ToValue for LineCap

impl ToValue for LineJoin

impl ToValue for Operator

impl ToValue for Context

impl ToValue for Device

impl ToValue for Matrix

impl ToValue for Region

impl ToValue for Surface

impl ToValue for BusType

impl ToValue for FileType

impl ToValue for TlsError

impl ToValue for AttrType

impl ToValue for BidiType

impl ToValue for Gravity

impl ToValue for Overline

impl ToValue for Script

impl ToValue for Stretch

impl ToValue for Style

impl ToValue for TabAlign

impl ToValue for Variant

impl ToValue for Weight

impl ToValue for WrapMode

impl ToValue for FontMask