diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-08-07 20:47:54 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-08-07 20:47:54 -0400 |
| commit | ea77a8cf9c012fcd877d842fec85b0b5a442952c (patch) | |
| tree | 7f209c030b97a957497f152d161a9d7035311132 /vendored/mpd/src/output.rs | |
| parent | 0de7e9ac43f88aae3750ecfe25b5454fdd1ad015 (diff) | |
Diffstat (limited to 'vendored/mpd/src/output.rs')
| -rw-r--r-- | vendored/mpd/src/output.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendored/mpd/src/output.rs b/vendored/mpd/src/output.rs new file mode 100644 index 0000000..d781511 --- /dev/null +++ b/vendored/mpd/src/output.rs @@ -0,0 +1,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"), + }) + } +} |