sonos_api/services/group_rendering_control/
state.rs1use serde::{Deserialize, Serialize};
6
7use crate::SonosClient;
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
14pub struct GroupRenderingControlState {
15 pub group_volume: Option<u16>,
17
18 pub group_mute: Option<bool>,
20
21 pub group_volume_changeable: Option<bool>,
23}
24
25pub fn poll(client: &SonosClient, ip: &str) -> crate::Result<GroupRenderingControlState> {
30 let volume = client.execute_enhanced(
31 ip,
32 super::get_group_volume_operation()
33 .build()
34 .map_err(|e| crate::ApiError::ParseError(e.to_string()))?,
35 )?;
36
37 let mute = super::get_group_mute_operation()
38 .build()
39 .ok()
40 .and_then(|op| client.execute_enhanced(ip, op).ok());
41
42 Ok(GroupRenderingControlState {
43 group_volume: Some(volume.current_volume),
44 group_mute: mute.map(|m| m.current_mute),
45 group_volume_changeable: None,
46 })
47}