src/client/transitions.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use serde::Serialize; |
2 | | use time::Duration; |
3 | | |
4 | | use super::Client; |
5 | | use crate::{requests::transitions::Request, responses::transitions as responses, Error, Result}; |
6 | | |
7 | | /// API functions related to transitions. |
8 | | pub struct Transitions<'a> { |
9 | | pub(super) client: &'a Client, |
10 | | } |
11 | | |
12 | | impl<'a> Transitions<'a> { |
13 | | /// Gets an array of all available transition kinds. |
14 | 1 | pub async fn list_kinds(&self) -> Result<Vec<String>> { <obws::client::transitions::Transitions>::list_kinds Line | Count | Source | 14 | 1 | pub async fn list_kinds(&self) -> Result<Vec<String>> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::list_kinds |
15 | 1 | self.client |
16 | 2 | .send_message::<_, responses::TransitionKinds>(Request::GetTransitionKindList) |
17 | 2 | .await |
18 | 1 | .map(|tk| tk.transition_kinds) <obws::client::transitions::Transitions>::list_kinds::{closure#0}::{closure#0} Line | Count | Source | 18 | 1 | .map(|tk| tk.transition_kinds) |
Unexecuted instantiation: <obws::client::transitions::Transitions>::list_kinds::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::list_kinds::{closure#0}::{closure#0} |
19 | 1 | } <obws::client::transitions::Transitions>::list_kinds::{closure#0} Line | Count | Source | 15 | 1 | self.client | 16 | 2 | .send_message::<_, responses::TransitionKinds>(Request::GetTransitionKindList) | 17 | 2 | .await | 18 | 1 | .map(|tk| tk.transition_kinds) | 19 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::list_kinds::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::list_kinds::{closure#0} |
20 | | |
21 | | /// Gets an array of all scene transitions in OBS. |
22 | 1 | pub async fn list(&self) -> Result<responses::SceneTransitionList> { <obws::client::transitions::Transitions>::list Line | Count | Source | 22 | 1 | pub async fn list(&self) -> Result<responses::SceneTransitionList> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::list |
23 | 1 | self.client |
24 | 2 | .send_message(Request::GetSceneTransitionList) |
25 | 2 | .await |
26 | 1 | } <obws::client::transitions::Transitions>::list::{closure#0} Line | Count | Source | 23 | 1 | self.client | 24 | 2 | .send_message(Request::GetSceneTransitionList) | 25 | 2 | .await | 26 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::list::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::list::{closure#0} |
27 | | |
28 | | /// Gets information about the current scene transition. |
29 | 1 | pub async fn current(&self) -> Result<responses::CurrentSceneTransition> { <obws::client::transitions::Transitions>::current Line | Count | Source | 29 | 1 | pub async fn current(&self) -> Result<responses::CurrentSceneTransition> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::current |
30 | 1 | self.client |
31 | 2 | .send_message(Request::GetCurrentSceneTransition) |
32 | 2 | .await |
33 | 1 | } <obws::client::transitions::Transitions>::current::{closure#0} Line | Count | Source | 30 | 1 | self.client | 31 | 2 | .send_message(Request::GetCurrentSceneTransition) | 32 | 2 | .await | 33 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::current::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::current::{closure#0} |
34 | | |
35 | | /// Sets the current scene transition. |
36 | | /// |
37 | | /// **Small note:** While the namespace of scene transitions is generally unique, that |
38 | | /// uniqueness is not a guarantee as it is with other resources like inputs. |
39 | 1 | pub async fn set_current(&self, name: &str) -> Result<()> { <obws::client::transitions::Transitions>::set_current Line | Count | Source | 39 | 1 | pub async fn set_current(&self, name: &str) -> Result<()> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current |
40 | 1 | self.client |
41 | 2 | .send_message(Request::SetCurrentSceneTransition { name }) |
42 | 2 | .await |
43 | 1 | } <obws::client::transitions::Transitions>::set_current::{closure#0} Line | Count | Source | 40 | 1 | self.client | 41 | 2 | .send_message(Request::SetCurrentSceneTransition { name }) | 42 | 2 | .await | 43 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current::{closure#0} |
44 | | |
45 | | /// Sets the duration of the current scene transition, if it is not fixed. |
46 | 1 | pub async fn set_current_duration(&self, duration: Duration) -> Result<()> { <obws::client::transitions::Transitions>::set_current_duration Line | Count | Source | 46 | 1 | pub async fn set_current_duration(&self, duration: Duration) -> Result<()> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_duration |
47 | 1 | self.client |
48 | 2 | .send_message(Request::SetCurrentSceneTransitionDuration { duration }) |
49 | 2 | .await |
50 | 1 | } <obws::client::transitions::Transitions>::set_current_duration::{closure#0} Line | Count | Source | 47 | 1 | self.client | 48 | 2 | .send_message(Request::SetCurrentSceneTransitionDuration { duration }) | 49 | 2 | .await | 50 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_duration::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_duration::{closure#0} |
51 | | |
52 | | /// Sets the settings of the current scene transition. |
53 | 1 | pub async fn set_current_settings<T>(&self, settings: T, overlay: Option<bool>) -> Result<()> |
54 | 1 | where |
55 | 1 | T: Serialize, |
56 | 1 | { <obws::client::transitions::Transitions>::set_current_settings::<serde_json::value::Value> Line | Count | Source | 53 | 1 | pub async fn set_current_settings<T>(&self, settings: T, overlay: Option<bool>) -> Result<()> | 54 | 1 | where | 55 | 1 | T: Serialize, | 56 | 1 | { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_settings::<_> Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_settings::<_> |
57 | | self.client |
58 | | .send_message(Request::SetCurrentSceneTransitionSettings { |
59 | 1 | settings: serde_json::to_value(&settings).map_err(Error::SerializeCustomData)?0 , |
60 | 1 | overlay, |
61 | 2 | }) |
62 | 2 | .await |
63 | 1 | } <obws::client::transitions::Transitions>::set_current_settings::<serde_json::value::Value>::{closure#0} Line | Count | Source | 59 | 1 | settings: serde_json::to_value(&settings).map_err(Error::SerializeCustomData)?0 , | 60 | 1 | overlay, | 61 | 2 | }) | 62 | 2 | .await | 63 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_settings::<_>::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::set_current_settings::<_>::{closure#0} |
64 | | |
65 | | /// Gets the cursor position of the current scene transition. |
66 | | /// |
67 | | /// **Note:** `transitionCursor` will return `1.0` when the transition is inactive. |
68 | 1 | pub async fn current_cursor(&self) -> Result<f32> { <obws::client::transitions::Transitions>::current_cursor Line | Count | Source | 68 | 1 | pub async fn current_cursor(&self) -> Result<f32> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::current_cursor |
69 | 1 | self.client |
70 | 1 | .send_message::<_, responses::TransitionCursor>( |
71 | 1 | Request::GetCurrentSceneTransitionCursor, |
72 | 2 | ) |
73 | 2 | .await |
74 | 1 | .map(|tc| tc.transition_cursor) <obws::client::transitions::Transitions>::current_cursor::{closure#0}::{closure#0} Line | Count | Source | 74 | 1 | .map(|tc| tc.transition_cursor) |
Unexecuted instantiation: <obws::client::transitions::Transitions>::current_cursor::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::current_cursor::{closure#0}::{closure#0} |
75 | 1 | } <obws::client::transitions::Transitions>::current_cursor::{closure#0} Line | Count | Source | 69 | 1 | self.client | 70 | 1 | .send_message::<_, responses::TransitionCursor>( | 71 | 1 | Request::GetCurrentSceneTransitionCursor, | 72 | 2 | ) | 73 | 2 | .await | 74 | 1 | .map(|tc| tc.transition_cursor) | 75 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::current_cursor::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::current_cursor::{closure#0} |
76 | | |
77 | | /// Triggers the current scene transition. Same functionality as the `Transition` button in |
78 | | /// studio mode. |
79 | 1 | pub async fn trigger(&self) -> Result<()> { <obws::client::transitions::Transitions>::trigger Line | Count | Source | 79 | 1 | pub async fn trigger(&self) -> Result<()> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::trigger |
80 | 1 | self.client |
81 | 2 | .send_message(Request::TriggerStudioModeTransition) |
82 | 2 | .await |
83 | 1 | } <obws::client::transitions::Transitions>::trigger::{closure#0} Line | Count | Source | 80 | 1 | self.client | 81 | 2 | .send_message(Request::TriggerStudioModeTransition) | 82 | 2 | .await | 83 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::trigger::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::trigger::{closure#0} |
84 | | |
85 | | /// Sets the position of the T-Bar. |
86 | | /// |
87 | | /// **Very important note:** This will be deprecated and replaced in a future version of |
88 | | /// `obs-websocket`. |
89 | 1 | pub async fn set_tbar_position(&self, position: f32, release: Option<bool>) -> Result<()> { <obws::client::transitions::Transitions>::set_tbar_position Line | Count | Source | 89 | 1 | pub async fn set_tbar_position(&self, position: f32, release: Option<bool>) -> Result<()> { |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_tbar_position |
90 | 1 | self.client |
91 | 2 | .send_message(Request::SetTbarPosition { position, release }) |
92 | 2 | .await |
93 | 1 | } <obws::client::transitions::Transitions>::set_tbar_position::{closure#0} Line | Count | Source | 90 | 1 | self.client | 91 | 2 | .send_message(Request::SetTbarPosition { position, release }) | 92 | 2 | .await | 93 | 1 | } |
Unexecuted instantiation: <obws::client::transitions::Transitions>::set_tbar_position::{closure#0} Unexecuted instantiation: <obws::client::transitions::Transitions>::set_tbar_position::{closure#0} |
94 | | } |