mpris 1.1.2

Idiomatic MPRIS D-Bus interface library
Documentation
// This file was generated by ./script/generate_metadata_value_conversions.rb.
impl Value {
    /// Returns the value as a `Some(u8)` if it is a `MetadataValue::U8`, or `None` otherwise.
    pub fn as_u8(&self) -> Option<u8> {
        match *self {
            Value::U8(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(u16)` if it is a `MetadataValue::U16`, or `None` otherwise.
    pub fn as_u16(&self) -> Option<u16> {
        match *self {
            Value::U16(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(u32)` if it is a `MetadataValue::U32`, or `None` otherwise.
    pub fn as_u32(&self) -> Option<u32> {
        match *self {
            Value::U32(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(u64)` if it is a `MetadataValue::U64`, or `None` otherwise.
    pub fn as_u64(&self) -> Option<u64> {
        match *self {
            Value::U64(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(i16)` if it is a `MetadataValue::I16`, or `None` otherwise.
    pub fn as_i16(&self) -> Option<i16> {
        match *self {
            Value::I16(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(i32)` if it is a `MetadataValue::I32`, or `None` otherwise.
    pub fn as_i32(&self) -> Option<i32> {
        match *self {
            Value::I32(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(i64)` if it is a `MetadataValue::I64`, or `None` otherwise.
    pub fn as_i64(&self) -> Option<i64> {
        match *self {
            Value::I64(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(f64)` if it is a `MetadataValue::F64`, or `None` otherwise.
    pub fn as_f64(&self) -> Option<f64> {
        match *self {
            Value::F64(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(bool)` if it is a `MetadataValue::Bool`, or `None` otherwise.
    pub fn as_bool(&self) -> Option<bool> {
        match *self {
            Value::Bool(val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(&String)` if it is a `MetadataValue::String`, or `None` otherwise.
    pub fn as_string(&self) -> Option<&String> {
        match *self {
            Value::String(ref val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(&HashMap<String, Value>)` if it is a `MetadataValue::Map`, or `None` otherwise.
    pub fn as_map(&self) -> Option<&HashMap<String, Value>> {
        match *self {
            Value::Map(ref val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(&Vec<Value>)` if it is a `MetadataValue::Array`, or `None` otherwise.
    pub fn as_array(&self) -> Option<&Vec<Value>> {
        match *self {
            Value::Array(ref val) => Some(val),
            _ => None,
        }
    }

    /// Returns the value as a `Some(&str)` if it is a `MetadataValue::String`, or `None` otherwise.
    pub fn as_str(&self) -> Option<&str> {
        match *self {
            Value::String(ref val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(u8)` if it is a `MetadataValue::U8`, or `None` otherwise.
    pub fn into_u8(self) -> Option<u8> {
        match self {
            Value::U8(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(u16)` if it is a `MetadataValue::U16`, or `None` otherwise.
    pub fn into_u16(self) -> Option<u16> {
        match self {
            Value::U16(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(u32)` if it is a `MetadataValue::U32`, or `None` otherwise.
    pub fn into_u32(self) -> Option<u32> {
        match self {
            Value::U32(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(u64)` if it is a `MetadataValue::U64`, or `None` otherwise.
    pub fn into_u64(self) -> Option<u64> {
        match self {
            Value::U64(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(i16)` if it is a `MetadataValue::I16`, or `None` otherwise.
    pub fn into_i16(self) -> Option<i16> {
        match self {
            Value::I16(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(i32)` if it is a `MetadataValue::I32`, or `None` otherwise.
    pub fn into_i32(self) -> Option<i32> {
        match self {
            Value::I32(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(i64)` if it is a `MetadataValue::I64`, or `None` otherwise.
    pub fn into_i64(self) -> Option<i64> {
        match self {
            Value::I64(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(f64)` if it is a `MetadataValue::F64`, or `None` otherwise.
    pub fn into_f64(self) -> Option<f64> {
        match self {
            Value::F64(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(bool)` if it is a `MetadataValue::Bool`, or `None` otherwise.
    pub fn into_bool(self) -> Option<bool> {
        match self {
            Value::Bool(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(String)` if it is a `MetadataValue::String`, or `None` otherwise.
    pub fn into_string(self) -> Option<String> {
        match self {
            Value::String(val) => Some(val),
            _ => None,
        }
    }

    /// 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_map(self) -> Option<HashMap<String, Value>> {
        match self {
            Value::Map(val) => Some(val),
            _ => None,
        }
    }

    /// Consumes `self` and returns the inner value as a `Some(Vec<Value>)` if it is a `MetadataValue::Array`, or `None` otherwise.
    pub fn into_array(self) -> Option<Vec<Value>> {
        match self {
            Value::Array(val) => Some(val),
            _ => None,
        }
    }
}