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

Value is a string.

Value is a 16-bit integer.

Value is a 32-bit integer.

Value is a 64-bit integer.

Value is an unsigned 8-bit integer.

Value is an unsigned 16-bit integer.

Value is an unsigned 32-bit integer.

Value is an unsigned 64-bit integer.

Value is a 64-bit float.

Value is a boolean.

Value is an array of other values.

Value is a map of other values.

Unsupported value type.

Methods

impl Value
[src]

Is this Value a String?

Is this Value a I16?

Is this Value a I32?

Is this Value a I64?

Is this Value a U8?

Is this Value a U16?

Is this Value a U32?

Is this Value a U64?

Is this Value a F64?

Is this Value a Bool?

Is this Value a Array?

Is this Value a Map?

Is this Value a Unsupported?

impl Value
[src]

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]

Returns the value as a Some(u8) if it is a MetadataValue::U8, or None otherwise.

Returns the value as a Some(u16) if it is a MetadataValue::U16, or None otherwise.

Returns the value as a Some(u32) if it is a MetadataValue::U32, or None otherwise.

Returns the value as a Some(u64) if it is a MetadataValue::U64, or None otherwise.

Returns the value as a Some(i16) if it is a MetadataValue::I16, or None otherwise.

Returns the value as a Some(i32) if it is a MetadataValue::I32, or None otherwise.

Returns the value as a Some(i64) if it is a MetadataValue::I64, or None otherwise.

Returns the value as a Some(f64) if it is a MetadataValue::F64, or None otherwise.

Returns the value as a Some(bool) if it is a MetadataValue::Bool, or None otherwise.

Returns the value as a Some(&String) if it is a MetadataValue::String, or None otherwise.

Returns the value as a Some(&HashMap<String, Value>) if it is a MetadataValue::Map, or None otherwise.

Returns the value as a Some(&Vec<Value>) if it is a MetadataValue::Array, or None otherwise.

Returns the value as a Some(&str) if it is a MetadataValue::String, or None otherwise.

Consumes self and returns the inner value as a Some(u8) if it is a MetadataValue::U8, or None otherwise.

Consumes self and returns the inner value as a Some(u16) if it is a MetadataValue::U16, or None otherwise.

Consumes self and returns the inner value as a Some(u32) if it is a MetadataValue::U32, or None otherwise.

Consumes self and returns the inner value as a Some(u64) if it is a MetadataValue::U64, or None otherwise.

Consumes self and returns the inner value as a Some(i16) if it is a MetadataValue::I16, or None otherwise.

Consumes self and returns the inner value as a Some(i32) if it is a MetadataValue::I32, or None otherwise.

Consumes self and returns the inner value as a Some(i64) if it is a MetadataValue::I64, or None otherwise.

Consumes self and returns the inner value as a Some(f64) if it is a MetadataValue::F64, or None otherwise.

Consumes self and returns the inner value as a Some(bool) if it is a MetadataValue::Bool, or None otherwise.

Consumes self and returns the inner value as a Some(String) if it is a MetadataValue::String, or None otherwise.

Consumes self and returns the inner value as a Some(HashMap<String, Value>) if it is a MetadataValue::Map, or None otherwise.

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]

Formats the value using the given formatter. Read more

impl PartialEq for Value
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'__enum_kinds1> From<&'__enum_kinds1 Value> for ValueKind
[src]

Performs the conversion.

impl<'__enum_kinds1> From<Value> for ValueKind
[src]

Performs the conversion.

impl From<String> for Value
[src]

Convert into String variant.

Performs the conversion.

impl From<i16> for Value
[src]

Convert into I16 variant.

Performs the conversion.

impl From<i32> for Value
[src]

Convert into I32 variant.

Performs the conversion.

impl From<i64> for Value
[src]

Convert into I64 variant.

Performs the conversion.

impl From<u8> for Value
[src]

Convert into U8 variant.

Performs the conversion.

impl From<u16> for Value
[src]

Convert into U16 variant.

Performs the conversion.

impl From<u32> for Value
[src]

Convert into U32 variant.

Performs the conversion.

impl From<u64> for Value
[src]

Convert into U64 variant.

Performs the conversion.

impl From<f64> for Value
[src]

Convert into F64 variant.

Performs the conversion.

impl From<bool> for Value
[src]

Convert into Bool variant.

Performs the conversion.

impl From<Vec<Value>> for Value
[src]

Convert into Array variant.

Performs the conversion.

impl From<HashMap<String, Value>> for Value
[src]

Convert into Map variant.

Performs the conversion.

impl<'a> From<&'a str> for Value
[src]

Performs the conversion.

impl Arg for Value
[src]

ARG_TYPE: ArgType = dbus::arg::ArgType::Variant

The corresponding D-Bus argument type code.

The corresponding D-Bus type signature for this type.

Deprecated

: 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]

Performs the get operation.

Auto Trait Implementations