[−][src]Enum mpris::MetadataValue
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]
pub fn is_string(&self) -> bool
[src]
Is this Value
a String
?
pub fn is_i16(&self) -> bool
[src]
Is this Value
a I16
?
pub fn is_i32(&self) -> bool
[src]
Is this Value
a I32
?
pub fn is_i64(&self) -> bool
[src]
Is this Value
a I64
?
pub fn is_u8(&self) -> bool
[src]
Is this Value
a U8
?
pub fn is_u16(&self) -> bool
[src]
Is this Value
a U16
?
pub fn is_u32(&self) -> bool
[src]
Is this Value
a U32
?
pub fn is_u64(&self) -> bool
[src]
Is this Value
a U64
?
pub fn is_f64(&self) -> bool
[src]
Is this Value
a F64
?
pub fn is_bool(&self) -> bool
[src]
Is this Value
a Bool
?
pub fn is_array(&self) -> bool
[src]
Is this Value
a Array
?
pub fn is_map(&self) -> bool
[src]
Is this Value
a Map
?
pub fn is_unsupported(&self) -> bool
[src]
Is this Value
a Unsupported
?
impl Value
[src]
pub fn kind(&self) -> ValueKind
[src]
Returns a simple enum representing the type of value that this value holds.
Examples
use mpris::MetadataValueKind; if let Some(value) = metadata.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); }
pub fn as_str_array(&self) -> Option<Vec<&str>>
[src]
Returns the value as a Some(Vec<&str>)
if it is a MetadataValue::Array
. Any elements
that are not MetadataValue::String
values will be ignored.
pub fn as_u8(&self) -> Option<u8>
[src]
Returns the value as a Some(u8)
if it is a MetadataValue::U8
, or None
otherwise.
pub fn as_u16(&self) -> Option<u16>
[src]
Returns the value as a Some(u16)
if it is an unsigned int smaller than or equal to u16,
or None
otherwise.
pub fn as_u32(&self) -> Option<u32>
[src]
Returns the value as a Some(u32)
if it is an unsigned int smaller than or equal to u32,
or None
otherwise.
pub fn as_u64(&self) -> Option<u64>
[src]
Returns the value as a Some(u64)
if it is an unsigned int smaller than or equal to u64,
or None
otherwise.
pub fn as_i16(&self) -> Option<i16>
[src]
Returns the value as a Some(i16)
if it is a signed integer smaller than or equal to i16,
or None
otherwise.
pub fn as_i32(&self) -> Option<i32>
[src]
Returns the value as a Some(i32)
if it is a signed integer smaller than or equal to i32,
or None
otherwise.
pub fn as_i64(&self) -> Option<i64>
[src]
Returns the value as a Some(i64)
if it is a signed integer smaller than or equal to i64,
or None
otherwise.
pub fn as_f64(&self) -> Option<f64>
[src]
Returns the value as a Some(f64)
if it is a MetadataValue::F64
, or None
otherwise.
pub fn as_bool(&self) -> Option<bool>
[src]
Returns the value as a Some(bool)
if it is a MetadataValue::Bool
, or None
otherwise.
pub fn as_str(&self) -> Option<&str>
[src]
Returns the value as a Some(&str)
if it is a MetadataValue::String
, or None
otherwise.
pub fn as_string(&self) -> Option<&String>
[src]
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]
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]
Returns the value as a Some(&Vec<Value>)
if it is a MetadataValue::Array
, or None
otherwise.
pub fn into_u8(self) -> Option<u8>
[src]
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]
Consumes self
and returns the inner value as a Some(u16)
if it is an unsigned integer
smaller than or equal to u16, or None
otherwise.
pub fn into_u32(self) -> Option<u32>
[src]
Consumes self
and returns the inner value as a Some(u32)
if it is an unsigned integer
smaller than or equal to u32, or None
otherwise.
pub fn into_u64(self) -> Option<u64>
[src]
Consumes self
and returns the inner value as a Some(u64)
if it is an unsigned integer
smaller than or equal to u64, or None
otherwise.
pub fn into_i16(self) -> Option<i16>
[src]
Consumes self
and returns the inner value as a Some(i16)
if it is a signed integer
smaller than or equal to i16, or None
otherwise.
pub fn into_i32(self) -> Option<i32>
[src]
Consumes self
and returns the inner value as a Some(i32)
if it is a signed integer
smaller than or equal to i32, or None
otherwise.
pub fn into_i64(self) -> Option<i64>
[src]
Consumes self
and returns the inner value as a Some(i64)
if it is a signed integer
smaller than or equal to i64, or None
otherwise.
pub fn into_f64(self) -> Option<f64>
[src]
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]
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]
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]
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]
Consumes self
and returns the inner value as a Some(Vec<Value>)
if it is a
MetadataValue::Array
, or None
otherwise.
Trait Implementations
impl Clone for Value
[src]
fn clone(&self) -> Value
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<Value> for Value
[src]
impl<'__enum_kinds1> From<&'__enum_kinds1 Value> for ValueKind
[src]
impl<'__enum_kinds1> From<Value> for ValueKind
[src]
impl From<String> for Value
[src]
Convert into String
variant.
impl From<i16> for Value
[src]
Convert into I16
variant.
impl From<i32> for Value
[src]
Convert into I32
variant.
impl From<i64> for Value
[src]
Convert into I64
variant.
impl From<u8> for Value
[src]
Convert into U8
variant.
impl From<u16> for Value
[src]
Convert into U16
variant.
impl From<u32> for Value
[src]
Convert into U32
variant.
impl From<u64> for Value
[src]
Convert into U64
variant.
impl From<f64> for Value
[src]
Convert into F64
variant.
impl From<bool> for Value
[src]
Convert into Bool
variant.
impl From<Vec<Value>> for Value
[src]
Convert into Array
variant.
impl From<HashMap<String, Value, RandomState>> for Value
[src]
Convert into Map
variant.
impl<'a> From<&'a str> for Value
[src]
impl Debug for Value
[src]
impl Arg for Value
[src]
const ARG_TYPE: ArgType
[src]
fn signature() -> Signature<'static>
[src]
fn arg_type() -> ArgType
[src]
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]
Auto Trait Implementations
impl Send for MetadataValue
impl Sync for MetadataValue
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,