use serde::{Deserialize, Serialize};
use crate::SonosClient;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct GroupRenderingControlState {
pub group_volume: Option<u16>,
pub group_mute: Option<bool>,
pub group_volume_changeable: Option<bool>,
}
pub fn poll(client: &SonosClient, ip: &str) -> crate::Result<GroupRenderingControlState> {
let volume = client.execute_enhanced(
ip,
super::get_group_volume_operation()
.build()
.map_err(|e| crate::ApiError::ParseError(e.to_string()))?,
)?;
let mute = super::get_group_mute_operation()
.build()
.ok()
.and_then(|op| client.execute_enhanced(ip, op).ok());
Ok(GroupRenderingControlState {
group_volume: Some(volume.current_volume),
group_mute: mute.map(|m| m.current_mute),
group_volume_changeable: None,
})
}