summaryrefslogtreecommitdiff
path: root/vendored/mpd/src/output.rs
blob: d7815117783d2e0df2322768b08d381c620e3069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! The module describes output


use crate::convert::FromMap;
use crate::error::{Error, ProtoError};
use std::collections::BTreeMap;
use std::convert::From;

/// Sound output
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
pub struct Output {
    /// id
    pub id: u32,
    /// name
    pub name: String,
    /// enabled state
    pub enabled: bool,
}

impl FromMap for Output {
    fn from_map(map: BTreeMap<String, String>) -> Result<Output, Error> {
        Ok(Output {
               id: get_field!(map, "outputid"),
               name: map.get("outputname").map(|v| v.to_owned()).ok_or(Error::Proto(ProtoError::NoField("outputname")))?,
               enabled: get_field!(map, bool "outputenabled"),
           })
    }
}