Enum mpris::MetadataValue [−][src]
pub enum MetadataValue { String(String), I16(i16), I32(i32), I64(i64), U8(u8), U16(u16), U32(u32), U64(u64), F64(f64), Bool(bool), Array(Vec<Value>), Map(HashMap<String, Value>), Unsupported, }
Holds a dynamically-typed metadata value.
You will need to type-check this at runtime in order to use the value.
Variants
String(String)
Value is a string.
I16(i16)
Value is a 16-bit integer.
I32(i32)
Value is a 32-bit integer.
I64(i64)
Value is a 64-bit integer.
U8(u8)
Value is an unsigned 8-bit integer.
U16(u16)
Value is an unsigned 16-bit integer.
U32(u32)
Value is an unsigned 32-bit integer.
U64(u64)
Value is an unsigned 64-bit integer.
F64(f64)
Value is a 64-bit float.
Bool(bool)
Value is a boolean.
Array(Vec<Value>)
Value is an array of other values.
Map(HashMap<String, Value>)
Value is a map of other values.
Unsupported
Unsupported value type.
Methods
impl Value
[src]
impl Value
pub fn is_string(&self) -> bool
[src]
pub fn is_string(&self) -> bool
Is this Value
a String
?
pub fn is_i16(&self) -> bool
[src]
pub fn is_i16(&self) -> bool
Is this Value
a I16
?
pub fn is_i32(&self) -> bool
[src]
pub fn is_i32(&self) -> bool
Is this Value
a I32
?
pub fn is_i64(&self) -> bool
[src]
pub fn is_i64(&self) -> bool
Is this Value
a I64
?
pub fn is_u8(&self) -> bool
[src]
pub fn is_u8(&self) -> bool
Is this Value
a U8
?
pub fn is_u16(&self) -> bool
[src]
pub fn is_u16(&self) -> bool
Is this Value
a U16
?
pub fn is_u32(&self) -> bool
[src]
pub fn is_u32(&self) -> bool
Is this Value
a U32
?
pub fn is_u64(&self) -> bool
[src]
pub fn is_u64(&self) -> bool
Is this Value
a U64
?
pub fn is_f64(&self) -> bool
[src]
pub fn is_f64(&self) -> bool
Is this Value
a F64
?
pub fn is_bool(&self) -> bool
[src]
pub fn is_bool(&self) -> bool
Is this Value
a Bool
?
pub fn is_array(&self) -> bool
[src]
pub fn is_array(&self) -> bool
Is this Value
a Array
?
pub fn is_map(&self) -> bool
[src]
pub fn is_map(&self) -> bool
Is this Value
a Map
?
pub fn is_unsupported(&self) -> bool
[src]
pub fn is_unsupported(&self) -> bool
Is this Value
a Unsupported
?
impl Value
[src]
impl Value
pub fn kind(&self) -> ValueKind
[src]
pub fn kind(&self) -> ValueKind
Returns a simple enum representing the type of value that this value holds.
Examples
use mpris::MetadataValueKind; let rest_hash = metadata.rest_hash(); if let Some(value) = rest_hash.get(key_name) { match value.kind() { MetadataValueKind::String => println!("{} is a string", key_name), MetadataValueKind::I16 | MetadataValueKind::I32 | MetadataValueKind::I64 | MetadataValueKind::U8 | MetadataValueKind::U16 | MetadataValueKind::U32 | MetadataValueKind::U64 => println!("{} is an integer", key_name), MetadataValueKind::F64 => println!("{} is a float", key_name), MetadataValueKind::Bool => println!("{} is a boolean", key_name), MetadataValueKind::Array => println!("{} is an array", key_name), MetadataValueKind::Map => println!("{} is a map", key_name), MetadataValueKind::Unsupported => println!("{} is not a supported type", key_name), } } else { println!("Metadata does not have a {} key", key_name); }
impl Value
[src]
impl Value
pub fn as_u8(&self) -> Option<u8>
[src]
pub fn as_u8(&self) -> Option<u8>
Returns the value as a Some(u8)
if it is a MetadataValue::U8
, or None
otherwise.
pub fn as_u16(&self) -> Option<u16>
[src]
pub fn as_u16(&self) -> Option<u16>
Returns the value as a Some(u16)
if it is a MetadataValue::U16
, or None
otherwise.
pub fn as_u32(&self) -> Option<u32>
[src]
pub fn as_u32(&self) -> Option<u32>
Returns the value as a Some(u32)
if it is a MetadataValue::U32
, or None
otherwise.
pub fn as_u64(&self) -> Option<u64>
[src]
pub fn as_u64(&self) -> Option<u64>
Returns the value as a Some(u64)
if it is a MetadataValue::U64
, or None
otherwise.
pub fn as_i16(&self) -> Option<i16>
[src]
pub fn as_i16(&self) -> Option<i16>
Returns the value as a Some(i16)
if it is a MetadataValue::I16
, or None
otherwise.
pub fn as_i32(&self) -> Option<i32>
[src]
pub fn as_i32(&self) -> Option<i32>
Returns the value as a Some(i32)
if it is a MetadataValue::I32
, or None
otherwise.
pub fn as_i64(&self) -> Option<i64>
[src]
pub fn as_i64(&self) -> Option<i64>
Returns the value as a Some(i64)
if it is a MetadataValue::I64
, or None
otherwise.
pub fn as_f64(&self) -> Option<f64>
[src]
pub fn as_f64(&self) -> Option<f64>
Returns the value as a Some(f64)
if it is a MetadataValue::F64
, or None
otherwise.
pub fn as_bool(&self) -> Option<bool>
[src]
pub fn as_bool(&self) -> Option<bool>
Returns the value as a Some(bool)
if it is a MetadataValue::Bool
, or None
otherwise.
pub fn as_string(&self) -> Option<&String>
[src]
pub fn as_string(&self) -> Option<&String>
Returns the value as a Some(&String)
if it is a MetadataValue::String
, or None
otherwise.
pub fn as_map(&self) -> Option<&HashMap<String, Value>>
[src]
pub fn as_map(&self) -> Option<&HashMap<String, Value>>
Returns the value as a Some(&HashMap<String, Value>)
if it is a MetadataValue::Map
, or None
otherwise.
pub fn as_array(&self) -> Option<&Vec<Value>>
[src]
pub fn as_array(&self) -> Option<&Vec<Value>>
Returns the value as a Some(&Vec<Value>)
if it is a MetadataValue::Array
, or None
otherwise.
pub fn as_str(&self) -> Option<&str>
[src]
pub fn as_str(&self) -> Option<&str>
Returns the value as a Some(&str)
if it is a MetadataValue::String
, or None
otherwise.
pub fn into_u8(self) -> Option<u8>
[src]
pub fn into_u8(self) -> Option<u8>
Consumes self
and returns the inner value as a Some(u8)
if it is a MetadataValue::U8
, or None
otherwise.
pub fn into_u16(self) -> Option<u16>
[src]
pub fn into_u16(self) -> Option<u16>
Consumes self
and returns the inner value as a Some(u16)
if it is a MetadataValue::U16
, or None
otherwise.
pub fn into_u32(self) -> Option<u32>
[src]
pub fn into_u32(self) -> Option<u32>
Consumes self
and returns the inner value as a Some(u32)
if it is a MetadataValue::U32
, or None
otherwise.
pub fn into_u64(self) -> Option<u64>
[src]
pub fn into_u64(self) -> Option<u64>
Consumes self
and returns the inner value as a Some(u64)
if it is a MetadataValue::U64
, or None
otherwise.
pub fn into_i16(self) -> Option<i16>
[src]
pub fn into_i16(self) -> Option<i16>
Consumes self
and returns the inner value as a Some(i16)
if it is a MetadataValue::I16
, or None
otherwise.
pub fn into_i32(self) -> Option<i32>
[src]
pub fn into_i32(self) -> Option<i32>
Consumes self
and returns the inner value as a Some(i32)
if it is a MetadataValue::I32
, or None
otherwise.
pub fn into_i64(self) -> Option<i64>
[src]
pub fn into_i64(self) -> Option<i64>
Consumes self
and returns the inner value as a Some(i64)
if it is a MetadataValue::I64
, or None
otherwise.
pub fn into_f64(self) -> Option<f64>
[src]
pub fn into_f64(self) -> Option<f64>
Consumes self
and returns the inner value as a Some(f64)
if it is a MetadataValue::F64
, or None
otherwise.
pub fn into_bool(self) -> Option<bool>
[src]
pub fn into_bool(self) -> Option<bool>
Consumes self
and returns the inner value as a Some(bool)
if it is a MetadataValue::Bool
, or None
otherwise.
pub fn into_string(self) -> Option<String>
[src]
pub fn into_string(self) -> Option<String>
Consumes self
and returns the inner value as a Some(String)
if it is a MetadataValue::String
, or None
otherwise.
pub fn into_map(self) -> Option<HashMap<String, Value>>
[src]
pub fn into_map(self) -> Option<HashMap<String, Value>>
Consumes self
and returns the inner value as a Some(HashMap<String, Value>)
if it is a MetadataValue::Map
, or None
otherwise.
pub fn into_array(self) -> Option<Vec<Value>>
[src]
pub fn into_array(self) -> Option<Vec<Value>>
Consumes self
and returns the inner value as a Some(Vec<Value>)
if it is a MetadataValue::Array
, or None
otherwise.
Trait Implementations
impl Debug for Value
[src]
impl Debug for Value
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for Value
[src]
impl PartialEq for Value
fn eq(&self, other: &Value) -> bool
[src]
fn eq(&self, other: &Value) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Value) -> bool
[src]
fn ne(&self, other: &Value) -> bool
This method tests for !=
.
impl<'__enum_kinds1> From<&'__enum_kinds1 Value> for ValueKind
[src]
impl<'__enum_kinds1> From<&'__enum_kinds1 Value> for ValueKind
impl<'__enum_kinds1> From<Value> for ValueKind
[src]
impl<'__enum_kinds1> From<Value> for ValueKind
impl From<String> for Value
[src]
impl From<String> for Value
Convert into String
variant.
impl From<i16> for Value
[src]
impl From<i16> for Value
Convert into I16
variant.
impl From<i32> for Value
[src]
impl From<i32> for Value
Convert into I32
variant.
impl From<i64> for Value
[src]
impl From<i64> for Value
Convert into I64
variant.
impl From<u8> for Value
[src]
impl From<u8> for Value
Convert into U8
variant.
impl From<u16> for Value
[src]
impl From<u16> for Value
Convert into U16
variant.
impl From<u32> for Value
[src]
impl From<u32> for Value
Convert into U32
variant.
impl From<u64> for Value
[src]
impl From<u64> for Value
Convert into U64
variant.
impl From<f64> for Value
[src]
impl From<f64> for Value
Convert into F64
variant.
impl From<bool> for Value
[src]
impl From<bool> for Value
Convert into Bool
variant.
impl From<Vec<Value>> for Value
[src]
impl From<Vec<Value>> for Value
Convert into Array
variant.
impl From<HashMap<String, Value>> for Value
[src]
impl From<HashMap<String, Value>> for Value
Convert into Map
variant.
impl<'a> From<&'a str> for Value
[src]
impl<'a> From<&'a str> for Value
impl Arg for Value
[src]
impl Arg for Value
const ARG_TYPE: ArgType
ARG_TYPE: ArgType = dbus::arg::ArgType::Variant
The corresponding D-Bus argument type code.
fn signature() -> Signature<'static>
[src]
fn signature() -> Signature<'static>
The corresponding D-Bus type signature for this type.
fn arg_type() -> ArgType
[src]
fn arg_type() -> ArgType
: Use associated constant ARG_TYPE instead
The corresponding D-Bus argument type code; just returns ARG_TYPE. Read more
impl<'a> Get<'a> for Value
[src]
impl<'a> Get<'a> for Value
Auto Trait Implementations
impl Send for MetadataValue
impl Send for MetadataValue
impl Sync for MetadataValue
impl Sync for MetadataValue