Skip to content

Commit d44492e

Browse files
committed
Implemented HeosCommandHandler
1 parent b854022 commit d44492e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

heos-lib/src/heos_group.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
/// See the file LICENSE for details.
1010
///
1111
12+
use crate::heos_command::{HeosCommand, HeosCommandHandler};
13+
use crate::{HeosDevice, HeosReply};
14+
use anyhow::{anyhow, Result};
1215
use std::fmt::{Display, Formatter};
13-
use crate::HeosDevice;
1416

1517
#[derive(Debug)]
1618
pub struct HeosGroup {
@@ -31,6 +33,17 @@ impl HeosGroup {
3133
}
3234
}
3335

36+
impl HeosCommandHandler for HeosGroup {
37+
async fn send_command<'a>(&mut self, cmd: &HeosCommand<'a>) -> Result<HeosReply> {
38+
match self.leader {
39+
Some(ref mut leader) => {
40+
Ok(leader.send_command(cmd).await?)
41+
},
42+
None => Err(anyhow!("No leader found")),
43+
}
44+
}
45+
}
46+
3447
impl Clone for HeosGroup {
3548
fn clone(&self) -> Self {
3649
Self {

0 commit comments

Comments
 (0)