use crossbeam_channel as channel;
use crate::error::Result;
use crate::protocol::constants;
use crate::timed;
use crate::types::{Button, CatchEvent};
use super::Device;
impl Device {
pub fn enable_catch(&self, button: Button) -> Result<()> {
timed!(
"enable_catch",
self.exec(constants::catch_enable_cmd(button))
)
}
pub fn catch_events(&self) -> channel::Receiver<CatchEvent> {
self.transport().subscribe_catch()
}
}
#[cfg(feature = "async")]
use super::AsyncDevice;
#[cfg(feature = "async")]
impl AsyncDevice {
pub async fn enable_catch(&self, button: Button) -> Result<()> {
timed!(
"enable_catch",
self.exec(constants::catch_enable_cmd(button)).await
)
}
pub fn catch_events(&self) -> channel::Receiver<CatchEvent> {
self.transport().subscribe_catch()
}
}