use super::Client;
use crate::{error::Result, requests::recording::Request, responses::recording as responses};
pub struct Recording<'a> {
pub(super) client: &'a Client,
}
impl Recording<'_> {
#[doc(alias = "GetRecordStatus")]
pub async fn status(&self) -> Result<responses::RecordStatus> {
self.client.send_message(Request::Status).await
}
#[doc(alias = "ToggleRecord")]
pub async fn toggle(&self) -> Result<bool> {
self.client
.send_message::<_, responses::OutputActive>(Request::Toggle)
.await
.map(|oa| oa.active)
}
#[doc(alias = "StartRecord")]
pub async fn start(&self) -> Result<()> {
self.client.send_message(Request::Start).await
}
#[doc(alias = "StopRecord")]
pub async fn stop(&self) -> Result<String> {
self.client
.send_message::<_, responses::OutputStopped>(Request::Stop)
.await
.map(|os| os.path)
}
#[doc(alias = "ToggleRecordPause")]
pub async fn toggle_pause(&self) -> Result<bool> {
self.client
.send_message::<_, responses::OutputPaused>(Request::TogglePause)
.await
.map(|op| op.paused)
}
#[doc(alias = "PauseRecord")]
pub async fn pause(&self) -> Result<()> {
self.client.send_message(Request::Pause).await
}
#[doc(alias = "ResumeRecord")]
pub async fn resume(&self) -> Result<()> {
self.client.send_message(Request::Resume).await
}
#[doc(alias = "SplitRecordFile")]
pub async fn split_file(&self) -> Result<()> {
self.client.send_message(Request::SplitFile).await
}
#[doc(alias = "CreateRecordChapter")]
pub async fn create_chapter(&self, name: Option<&str>) -> Result<()> {
self.client
.send_message(Request::CreateChapter { name })
.await
}
}