#[non_exhaustive]pub enum Value {
Show 16 variants
Bool(bool),
U8(u8),
I16(i16),
U16(u16),
I32(i32),
U32(u32),
I64(i64),
U64(u64),
F64(f64),
String(String),
ObjectPath(ObjectPathBuf),
Signature(SignatureBuf),
Array {
element: SignatureBuf,
values: Vec<Value>,
},
Dict {
key: SignatureBuf,
value: SignatureBuf,
entries: Vec<(Value, Value)>,
},
Struct(Vec<Value>),
Variant(Box<Value>),
}Expand description
A D-Bus value whose type is only known at runtime.
This is what a v in a signature is decoded into, and holds the value that
was inside the variant rather than the variant itself. A Value::Variant
is therefore only produced for a variant nested inside another one.
§Examples
use std::collections::HashMap;
use tokio_dbus_runtime::Value;
let mut hints = HashMap::new();
hints.insert(String::from("urgency"), Value::U8(2));
hints.insert(String::from("category"), Value::String("device".into()));
assert_eq!(hints["urgency"].signature()?, "y");
assert_eq!(hints["category"].signature()?, "s");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bool(bool)
A boolean.
U8(u8)
A single byte.
I16(i16)
A signed 16-bit integer.
U16(u16)
An unsigned 16-bit integer.
I32(i32)
A signed 32-bit integer.
U32(u32)
An unsigned 32-bit integer.
I64(i64)
A signed 64-bit integer.
U64(u64)
An unsigned 64-bit integer.
F64(f64)
A 64-bit floating point number.
String(String)
A string.
ObjectPath(ObjectPathBuf)
An object path.
Signature(SignatureBuf)
A signature.
Array
An array.
The signature of the element type is carried along, since it cannot be recovered from the values when the array is empty.
Dict
A dictionary, which on the wire is an array of key and value pairs.
Struct(Vec<Value>)
A struct.
Variant(Box<Value>)
A variant nested inside of another value.
Implementations§
Source§impl Value
impl Value
Sourcepub fn array(element: &str) -> Result<Self>
pub fn array(element: &str) -> Result<Self>
Construct an empty array of the given element type.
§Examples
use tokio_dbus_runtime::Value;
let value = Value::array("(iiay)")?;
assert_eq!(value.signature()?, "a(iiay)");Sourcepub fn signature(&self) -> Result<SignatureBuf>
pub fn signature(&self) -> Result<SignatureBuf>
The signature of this value.
§Examples
use tokio_dbus_runtime::Value;
let value = Value::Struct(vec![Value::I32(1), Value::String("hi".into())]);
assert_eq!(value.signature()?, "(is)");