src/client/scene_items.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use serde::{de::DeserializeOwned, Serialize}; |
2 | | |
3 | | use super::Client; |
4 | | use crate::{ |
5 | | requests::scene_items::{ |
6 | | CreateSceneItem, Duplicate, Id, Request, SetEnabled, SetIndex, SetLocked, |
7 | | SetPrivateSettings, SetPrivateSettingsInternal, SetTransform, |
8 | | }, |
9 | | responses::scene_items as responses, |
10 | | Error, Result, |
11 | | }; |
12 | | |
13 | | /// API functions related to scene items. |
14 | | pub struct SceneItems<'a> { |
15 | | pub(super) client: &'a Client, |
16 | | } |
17 | | |
18 | | impl<'a> SceneItems<'a> { |
19 | | /// Gets a list of all scene items in a scene. |
20 | 1 | pub async fn list(&self, scene: &str) -> Result<Vec<responses::SceneItem>> { <obws::client::scene_items::SceneItems>::list Line | Count | Source | 20 | 1 | pub async fn list(&self, scene: &str) -> Result<Vec<responses::SceneItem>> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list |
21 | 1 | self.client |
22 | 2 | .send_message::<_, responses::SceneItemList>(Request::List { scene }) |
23 | 2 | .await |
24 | 1 | .map(|sil| sil.scene_items) <obws::client::scene_items::SceneItems>::list::{closure#0}::{closure#0} Line | Count | Source | 24 | 1 | .map(|sil| sil.scene_items) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list::{closure#0}::{closure#0} |
25 | 1 | } <obws::client::scene_items::SceneItems>::list::{closure#0} Line | Count | Source | 21 | 1 | self.client | 22 | 2 | .send_message::<_, responses::SceneItemList>(Request::List { scene }) | 23 | 2 | .await | 24 | 1 | .map(|sil| sil.scene_items) | 25 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list::{closure#0} |
26 | | |
27 | | /// Basically [`Self::list`], but for groups. |
28 | | /// |
29 | | /// Using groups at all in OBS is discouraged, as they are very broken under the hood. |
30 | 1 | pub async fn list_group(&self, scene: &str) -> Result<Vec<responses::SceneItem>> { <obws::client::scene_items::SceneItems>::list_group Line | Count | Source | 30 | 1 | pub async fn list_group(&self, scene: &str) -> Result<Vec<responses::SceneItem>> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list_group |
31 | 1 | self.client |
32 | 2 | .send_message::<_, responses::SceneItemList>(Request::ListGroup { scene }) |
33 | 2 | .await |
34 | 1 | .map(|sil| sil.scene_items) <obws::client::scene_items::SceneItems>::list_group::{closure#0}::{closure#0} Line | Count | Source | 34 | 1 | .map(|sil| sil.scene_items) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list_group::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list_group::{closure#0}::{closure#0} |
35 | 1 | } <obws::client::scene_items::SceneItems>::list_group::{closure#0} Line | Count | Source | 31 | 1 | self.client | 32 | 2 | .send_message::<_, responses::SceneItemList>(Request::ListGroup { scene }) | 33 | 2 | .await | 34 | 1 | .map(|sil| sil.scene_items) | 35 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list_group::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::list_group::{closure#0} |
36 | | |
37 | | /// Searches a scene for a source, and returns its id. |
38 | 1 | pub async fn id(&self, get: Id<'_>) -> Result<i64> { <obws::client::scene_items::SceneItems>::id Line | Count | Source | 38 | 1 | pub async fn id(&self, get: Id<'_>) -> Result<i64> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::id |
39 | 1 | self.client |
40 | 2 | .send_message::<_, responses::SceneItemId>(Request::Id(get)) |
41 | 2 | .await |
42 | 1 | .map(|sii| sii.id) <obws::client::scene_items::SceneItems>::id::{closure#0}::{closure#0} Line | Count | Source | 42 | 1 | .map(|sii| sii.id) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::id::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::id::{closure#0}::{closure#0} |
43 | 1 | } <obws::client::scene_items::SceneItems>::id::{closure#0} Line | Count | Source | 39 | 1 | self.client | 40 | 2 | .send_message::<_, responses::SceneItemId>(Request::Id(get)) | 41 | 2 | .await | 42 | 1 | .map(|sii| sii.id) | 43 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::id::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::id::{closure#0} |
44 | | |
45 | | /// Creates a new scene item using a source. |
46 | 1 | pub async fn create(&self, create: CreateSceneItem<'_>) -> Result<i64> { <obws::client::scene_items::SceneItems>::create Line | Count | Source | 46 | 1 | pub async fn create(&self, create: CreateSceneItem<'_>) -> Result<i64> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::create |
47 | 1 | self.client |
48 | 2 | .send_message::<_, responses::SceneItemId>(Request::Create(create)) |
49 | 2 | .await |
50 | 1 | .map(|sii| sii.id) <obws::client::scene_items::SceneItems>::create::{closure#0}::{closure#0} Line | Count | Source | 50 | 1 | .map(|sii| sii.id) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::create::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::create::{closure#0}::{closure#0} |
51 | 1 | } <obws::client::scene_items::SceneItems>::create::{closure#0} Line | Count | Source | 47 | 1 | self.client | 48 | 2 | .send_message::<_, responses::SceneItemId>(Request::Create(create)) | 49 | 2 | .await | 50 | 1 | .map(|sii| sii.id) | 51 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::create::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::create::{closure#0} |
52 | | |
53 | | /// Removes a scene item from a scene. |
54 | 2 | pub async fn remove(&self, scene: &str, item_id: i64) -> Result<()> { <obws::client::scene_items::SceneItems>::remove Line | Count | Source | 54 | 2 | pub async fn remove(&self, scene: &str, item_id: i64) -> Result<()> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::remove |
55 | 2 | self.client |
56 | 4 | .send_message(Request::Remove { scene, item_id }) |
57 | 4 | .await |
58 | 2 | } <obws::client::scene_items::SceneItems>::remove::{closure#0} Line | Count | Source | 55 | 2 | self.client | 56 | 4 | .send_message(Request::Remove { scene, item_id }) | 57 | 4 | .await | 58 | 2 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::remove::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::remove::{closure#0} |
59 | | |
60 | | /// Duplicates a scene item, copying all transform and crop info. |
61 | 1 | pub async fn duplicate(&self, duplicate: Duplicate<'_>) -> Result<i64> { <obws::client::scene_items::SceneItems>::duplicate Line | Count | Source | 61 | 1 | pub async fn duplicate(&self, duplicate: Duplicate<'_>) -> Result<i64> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::duplicate |
62 | 1 | self.client |
63 | 2 | .send_message::<_, responses::SceneItemId>(Request::Duplicate(duplicate)) |
64 | 2 | .await |
65 | 1 | .map(|sii| sii.id) <obws::client::scene_items::SceneItems>::duplicate::{closure#0}::{closure#0} Line | Count | Source | 65 | 1 | .map(|sii| sii.id) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::duplicate::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::duplicate::{closure#0}::{closure#0} |
66 | 1 | } <obws::client::scene_items::SceneItems>::duplicate::{closure#0} Line | Count | Source | 62 | 1 | self.client | 63 | 2 | .send_message::<_, responses::SceneItemId>(Request::Duplicate(duplicate)) | 64 | 2 | .await | 65 | 1 | .map(|sii| sii.id) | 66 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::duplicate::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::duplicate::{closure#0} |
67 | | |
68 | | /// Gets the transform and crop info of a scene item. |
69 | 1 | pub async fn transform( |
70 | 1 | &self, |
71 | 1 | scene: &str, |
72 | 1 | item_id: i64, |
73 | 1 | ) -> Result<responses::SceneItemTransform> { <obws::client::scene_items::SceneItems>::transform Line | Count | Source | 69 | 1 | pub async fn transform( | 70 | 1 | &self, | 71 | 1 | scene: &str, | 72 | 1 | item_id: i64, | 73 | 1 | ) -> Result<responses::SceneItemTransform> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::transform |
74 | 1 | self.client |
75 | 1 | .send_message::<_, responses::GetSceneItemTransform>(Request::Transform { |
76 | 1 | scene, |
77 | 1 | item_id, |
78 | 2 | }) |
79 | 2 | .await |
80 | 1 | .map(|gsit| gsit.transform) <obws::client::scene_items::SceneItems>::transform::{closure#0}::{closure#0} Line | Count | Source | 80 | 1 | .map(|gsit| gsit.transform) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::transform::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::transform::{closure#0}::{closure#0} |
81 | 1 | } <obws::client::scene_items::SceneItems>::transform::{closure#0} Line | Count | Source | 74 | 1 | self.client | 75 | 1 | .send_message::<_, responses::GetSceneItemTransform>(Request::Transform { | 76 | 1 | scene, | 77 | 1 | item_id, | 78 | 2 | }) | 79 | 2 | .await | 80 | 1 | .map(|gsit| gsit.transform) | 81 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::transform::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::transform::{closure#0} |
82 | | |
83 | | /// Sets the transform and crop info of a scene item. |
84 | 2 | pub async fn set_transform(&self, transform: SetTransform<'_>) -> Result<()> { <obws::client::scene_items::SceneItems>::set_transform Line | Count | Source | 84 | 2 | pub async fn set_transform(&self, transform: SetTransform<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_transform |
85 | 2 | self.client |
86 | 4 | .send_message(Request::SetTransform(transform)) |
87 | 4 | .await |
88 | 2 | } <obws::client::scene_items::SceneItems>::set_transform::{closure#0} Line | Count | Source | 85 | 2 | self.client | 86 | 4 | .send_message(Request::SetTransform(transform)) | 87 | 4 | .await | 88 | 2 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_transform::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_transform::{closure#0} |
89 | | |
90 | | /// Gets the enable state of a scene item. |
91 | 1 | pub async fn enabled(&self, scene: &str, item_id: i64) -> Result<bool> { <obws::client::scene_items::SceneItems>::enabled Line | Count | Source | 91 | 1 | pub async fn enabled(&self, scene: &str, item_id: i64) -> Result<bool> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::enabled |
92 | 1 | self.client |
93 | 2 | .send_message::<_, responses::SceneItemEnabled>(Request::Enabled { scene, item_id }) |
94 | 2 | .await |
95 | 1 | .map(|sie| sie.enabled) <obws::client::scene_items::SceneItems>::enabled::{closure#0}::{closure#0} Line | Count | Source | 95 | 1 | .map(|sie| sie.enabled) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::enabled::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::enabled::{closure#0}::{closure#0} |
96 | 1 | } <obws::client::scene_items::SceneItems>::enabled::{closure#0} Line | Count | Source | 92 | 1 | self.client | 93 | 2 | .send_message::<_, responses::SceneItemEnabled>(Request::Enabled { scene, item_id }) | 94 | 2 | .await | 95 | 1 | .map(|sie| sie.enabled) | 96 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::enabled::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::enabled::{closure#0} |
97 | | |
98 | | /// Sets the enable state of a scene item. |
99 | 2 | pub async fn set_enabled(&self, enabled: SetEnabled<'a>) -> Result<()> { <obws::client::scene_items::SceneItems>::set_enabled Line | Count | Source | 99 | 2 | pub async fn set_enabled(&self, enabled: SetEnabled<'a>) -> Result<()> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_enabled |
100 | 4 | self.client.send_message(Request::SetEnabled(enabled))2 .await |
101 | 2 | } <obws::client::scene_items::SceneItems>::set_enabled::{closure#0} Line | Count | Source | 100 | 4 | self.client.send_message(Request::SetEnabled(enabled))2 .await | 101 | 2 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_enabled::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_enabled::{closure#0} |
102 | | |
103 | | /// Gets the lock state of a scene item. |
104 | 1 | pub async fn locked(&self, scene: &str, item_id: i64) -> Result<bool> { <obws::client::scene_items::SceneItems>::locked Line | Count | Source | 104 | 1 | pub async fn locked(&self, scene: &str, item_id: i64) -> Result<bool> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::locked |
105 | 1 | self.client |
106 | 2 | .send_message::<_, responses::SceneItemLocked>(Request::Locked { scene, item_id }) |
107 | 2 | .await |
108 | 1 | .map(|sil| sil.locked) <obws::client::scene_items::SceneItems>::locked::{closure#0}::{closure#0} Line | Count | Source | 108 | 1 | .map(|sil| sil.locked) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::locked::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::locked::{closure#0}::{closure#0} |
109 | 1 | } <obws::client::scene_items::SceneItems>::locked::{closure#0} Line | Count | Source | 105 | 1 | self.client | 106 | 2 | .send_message::<_, responses::SceneItemLocked>(Request::Locked { scene, item_id }) | 107 | 2 | .await | 108 | 1 | .map(|sil| sil.locked) | 109 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::locked::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::locked::{closure#0} |
110 | | |
111 | | /// Sets the lock state of a scene item. |
112 | 2 | pub async fn set_locked(&self, locked: SetLocked<'_>) -> Result<()> { <obws::client::scene_items::SceneItems>::set_locked Line | Count | Source | 112 | 2 | pub async fn set_locked(&self, locked: SetLocked<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_locked |
113 | 4 | self.client.send_message(Request::SetLocked(locked))2 .await |
114 | 2 | } <obws::client::scene_items::SceneItems>::set_locked::{closure#0} Line | Count | Source | 113 | 4 | self.client.send_message(Request::SetLocked(locked))2 .await | 114 | 2 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_locked::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_locked::{closure#0} |
115 | | |
116 | | /// Gets the index position of a scene item in a scene. |
117 | | /// |
118 | | /// An index of 0 is at the bottom of the source list in the UI. |
119 | 1 | pub async fn index(&self, scene: &str, item_id: i64) -> Result<u32> { <obws::client::scene_items::SceneItems>::index Line | Count | Source | 119 | 1 | pub async fn index(&self, scene: &str, item_id: i64) -> Result<u32> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::index |
120 | 1 | self.client |
121 | 2 | .send_message::<_, responses::SceneItemIndex>(Request::Index { scene, item_id }) |
122 | 2 | .await |
123 | 1 | .map(|sii| sii.index) <obws::client::scene_items::SceneItems>::index::{closure#0}::{closure#0} Line | Count | Source | 123 | 1 | .map(|sii| sii.index) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::index::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::index::{closure#0}::{closure#0} |
124 | 1 | } <obws::client::scene_items::SceneItems>::index::{closure#0} Line | Count | Source | 120 | 1 | self.client | 121 | 2 | .send_message::<_, responses::SceneItemIndex>(Request::Index { scene, item_id }) | 122 | 2 | .await | 123 | 1 | .map(|sii| sii.index) | 124 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::index::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::index::{closure#0} |
125 | | |
126 | | /// Sets the index position of a scene item in a scene. |
127 | 2 | pub async fn set_index(&self, index: SetIndex<'_>) -> Result<()> { <obws::client::scene_items::SceneItems>::set_index Line | Count | Source | 127 | 2 | pub async fn set_index(&self, index: SetIndex<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_index |
128 | 4 | self.client.send_message(Request::SetIndex(index))2 .await |
129 | 2 | } <obws::client::scene_items::SceneItems>::set_index::{closure#0} Line | Count | Source | 128 | 4 | self.client.send_message(Request::SetIndex(index))2 .await | 129 | 2 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_index::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_index::{closure#0} |
130 | | |
131 | | /// Gets private scene item settings. |
132 | 1 | pub async fn private_settings<T>(&self, scene: &str, item_id: i64) -> Result<T> |
133 | 1 | where |
134 | 1 | T: DeserializeOwned, |
135 | 1 | { <obws::client::scene_items::SceneItems>::private_settings::<serde_json::value::Value> Line | Count | Source | 132 | 1 | pub async fn private_settings<T>(&self, scene: &str, item_id: i64) -> Result<T> | 133 | 1 | where | 134 | 1 | T: DeserializeOwned, | 135 | 1 | { |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_> Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_> |
136 | 1 | self.client |
137 | 1 | .send_message::<_, responses::SceneItemSettings<T>>(Request::PrivateSettings { |
138 | 1 | scene, |
139 | 1 | item_id, |
140 | 2 | }) |
141 | 2 | .await |
142 | 1 | .map(|sis| sis.settings) <obws::client::scene_items::SceneItems>::private_settings::<serde_json::value::Value>::{closure#0}::{closure#0} Line | Count | Source | 142 | 1 | .map(|sis| sis.settings) |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_>::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_>::{closure#0}::{closure#0} |
143 | 1 | } <obws::client::scene_items::SceneItems>::private_settings::<serde_json::value::Value>::{closure#0} Line | Count | Source | 136 | 1 | self.client | 137 | 1 | .send_message::<_, responses::SceneItemSettings<T>>(Request::PrivateSettings { | 138 | 1 | scene, | 139 | 1 | item_id, | 140 | 2 | }) | 141 | 2 | .await | 142 | 1 | .map(|sis| sis.settings) | 143 | 1 | } |
Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_>::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::private_settings::<_>::{closure#0} |
144 | | |
145 | | /// Sets private scene item settings. |
146 | 0 | pub async fn set_private_settings<T>(&self, settings: SetPrivateSettings<'_, T>) -> Result<()> |
147 | 0 | where |
148 | 0 | T: Serialize, |
149 | 0 | { Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_private_settings::<_> Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_private_settings::<_> |
150 | | self.client |
151 | | .send_message(Request::SetPrivateSettings(SetPrivateSettingsInternal { |
152 | 0 | scene: settings.scene, |
153 | 0 | item_id: settings.item_id, |
154 | 0 | settings: serde_json::to_value(&settings.settings) |
155 | 0 | .map_err(Error::SerializeCustomData)?, |
156 | 0 | })) |
157 | 0 | .await |
158 | 0 | } Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_private_settings::<_>::{closure#0} Unexecuted instantiation: <obws::client::scene_items::SceneItems>::set_private_settings::<_>::{closure#0} |
159 | | } |