Struct zvariant::OwnedValue [−][src]
pub struct OwnedValue(_);
Expand description
Owned Value
Methods from Deref<Target = Value<'static>>
Get the signature of the enclosed value.
Try to get a reference to the underlying type T
.
Same as downcast
except it doesn’t consume self
and get a reference to the underlying
value.
Examples
use std::convert::TryFrom; use zvariant::{Result, Value}; fn value_vec_to_type_vec<'a, T>(values: &'a Vec<Value<'a>>) -> Result<Vec<&'a T>> where &'a T: TryFrom<&'a Value<'a>>, { let mut res = vec![]; for value in values.into_iter() { res.push(value.downcast_ref().unwrap()); } Ok(res) } // Let's try u32 values first let v = vec![Value::U32(42), Value::U32(43)]; let v = value_vec_to_type_vec::<u32>(&v).unwrap(); assert_eq!(*v[0], 42); assert_eq!(*v[1], 43); // Now try Value values let v = vec![Value::new(Value::U32(42)), Value::new(Value::U32(43))]; let v = value_vec_to_type_vec::<Value>(&v).unwrap(); assert_eq!(*v[0], Value::U32(42)); assert_eq!(*v[1], Value::U32(43));
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for OwnedValue
impl Send for OwnedValue
impl Sync for OwnedValue
impl Unpin for OwnedValue
impl UnwindSafe for OwnedValue
Blanket Implementations
Mutably borrows from an owned value. Read more