mirror of https://github.com/dnaka91/obws
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
Rust
61 lines
1.8 KiB
Rust
use super::Client;
|
|
use crate::{requests::recording::Request, responses::recording as responses, Result};
|
|
|
|
/// API functions related to recording.
|
|
pub struct Recording<'a> {
|
|
pub(super) client: &'a Client,
|
|
}
|
|
|
|
impl<'a> Recording<'a> {
|
|
/// Gets the status of the record output.
|
|
#[doc(alias = "GetRecordStatus")]
|
|
pub async fn status(&self) -> Result<responses::RecordStatus> {
|
|
self.client.send_message(Request::Status).await
|
|
}
|
|
|
|
/// Toggles the status of the record output.
|
|
#[doc(alias = "ToggleRecord")]
|
|
pub async fn toggle(&self) -> Result<bool> {
|
|
self.client
|
|
.send_message::<_, responses::OutputActive>(Request::Toggle)
|
|
.await
|
|
.map(|oa| oa.active)
|
|
}
|
|
|
|
/// Starts the record output.
|
|
#[doc(alias = "StartRecord")]
|
|
pub async fn start(&self) -> Result<()> {
|
|
self.client.send_message(Request::Start).await
|
|
}
|
|
|
|
/// Stops the record output.
|
|
#[doc(alias = "StopRecord")]
|
|
pub async fn stop(&self) -> Result<String> {
|
|
self.client
|
|
.send_message::<_, responses::OutputStopped>(Request::Stop)
|
|
.await
|
|
.map(|os| os.path)
|
|
}
|
|
|
|
/// Toggles pause on the record output.
|
|
#[doc(alias = "ToggleRecordPause")]
|
|
pub async fn toggle_pause(&self) -> Result<bool> {
|
|
self.client
|
|
.send_message::<_, responses::OutputPaused>(Request::TogglePause)
|
|
.await
|
|
.map(|op| op.paused)
|
|
}
|
|
|
|
/// Pauses the record output.
|
|
#[doc(alias = "PauseRecord")]
|
|
pub async fn pause(&self) -> Result<()> {
|
|
self.client.send_message(Request::Pause).await
|
|
}
|
|
|
|
/// Resumes the record output.
|
|
#[doc(alias = "ResumeRecord")]
|
|
pub async fn resume(&self) -> Result<()> {
|
|
self.client.send_message(Request::Resume).await
|
|
}
|
|
}
|