/home/runner/work/obws/obws/src/client/replay_buffer.rs
Line | Count | Source |
1 | | use super::Client; |
2 | | use crate::{ |
3 | | error::Result, requests::replay_buffer::Request, responses::replay_buffer as responses, |
4 | | }; |
5 | | |
6 | | /// API functions related to the replay buffer. |
7 | | pub struct ReplayBuffer<'a> { |
8 | | pub(super) client: &'a Client, |
9 | | } |
10 | | |
11 | | impl ReplayBuffer<'_> { |
12 | | /// Gets the status of the replay buffer output. |
13 | | #[doc(alias = "GetReplayBufferStatus")] |
14 | 1 | pub async fn status(&self) -> Result<bool> { |
15 | 1 | self.client |
16 | 1 | .send_message::<_, responses::OutputActive>(Request::Status) |
17 | 1 | .await |
18 | 1 | .map(|oa| oa.active) |
19 | 1 | } |
20 | | |
21 | | /// Toggles the state of the replay buffer output. |
22 | | #[doc(alias = "ToggleReplayBuffer")] |
23 | 1 | pub async fn toggle(&self) -> Result<bool> { |
24 | 1 | self.client |
25 | 1 | .send_message::<_, responses::OutputActive>(Request::Toggle) |
26 | 1 | .await |
27 | 1 | .map(|oa| oa.active) |
28 | 1 | } |
29 | | |
30 | | /// Starts the replay buffer output. |
31 | | #[doc(alias = "StartReplayBuffer")] |
32 | 1 | pub async fn start(&self) -> Result<()> { |
33 | 1 | self.client.send_message(Request::Start).await |
34 | 1 | } |
35 | | |
36 | | /// Stops the replay buffer output. |
37 | | #[doc(alias = "StopReplayBuffer")] |
38 | 1 | pub async fn stop(&self) -> Result<()> { |
39 | 1 | self.client.send_message(Request::Stop).await |
40 | 1 | } |
41 | | |
42 | | /// Saves the contents of the replay buffer output. |
43 | | #[doc(alias = "SaveReplayBuffer")] |
44 | 1 | pub async fn save(&self) -> Result<()> { |
45 | 1 | self.client.send_message(Request::Save).await |
46 | 1 | } |
47 | | |
48 | | /// Gets the file name of the last replay buffer save file. |
49 | | #[doc(alias = "GetLastReplayBufferReplay")] |
50 | 1 | pub async fn last_replay(&self) -> Result<String> { |
51 | 1 | self.client |
52 | 1 | .send_message::<_, responses::SavedReplayPath>(Request::LastReplay) |
53 | 1 | .await |
54 | 1 | .map(|srp| srp.saved_replay_path) |
55 | 1 | } |
56 | | } |