[][src]Struct mpd_protocol::response::Frame

pub struct Frame {
    pub values: Vec<(String, String)>,
    pub binary: Option<Bytes>,
}

Data in a succesful response.

Fields

values: Vec<(String, String)>

Key-value pairs. Keys can repeat arbitrarily often.

binary: Option<Bytes>

Binary frame.

Methods

impl Frame[src]

pub fn values_as_map(&self) -> HashMap<&str, Vec<&str>>[src]

Collect the key-value pairs in this resposne into a HashMap.

Beware that this loses the order relationship between different keys. Values for a given key are ordered like they appear in the response.

use mpd_protocol::response::Frame;

let f = Frame {
    values: vec![
        (String::from("foo"), String::from("bar")),
        (String::from("hello"), String::from("world")),
        (String::from("foo"), String::from("baz")),
    ],
    ..Default::default()
};

let map = f.values_as_map();

assert_eq!(map.get("foo"), Some(&vec!["bar", "baz"]));
assert_eq!(map.get("hello"), Some(&vec!["world"]));

Trait Implementations

impl Default for Frame[src]

impl Eq for Frame[src]

impl PartialEq<Frame> for Frame[src]

impl Debug for Frame[src]

impl StructuralPartialEq for Frame[src]

impl StructuralEq for Frame[src]

Auto Trait Implementations

impl Send for Frame

impl Sync for Frame

impl Unpin for Frame

impl UnwindSafe for Frame

impl RefUnwindSafe for Frame

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]