Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 21e3f73

Browse files
committed
feat: add missing canvas UUID fields
1 parent b28aaa0 commit 21e3f73

20 files changed

Lines changed: 429 additions & 145 deletions

File tree

examples/screenshot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async fn main() -> Result<()> {
1616
.sources()
1717
.take_screenshot(TakeScreenshot {
1818
source: "OBWS-TEST-Scene".into(),
19+
canvas: None,
1920
width: None,
2021
height: None,
2122
compression_quality: None,

src/client/filters.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use serde::{Serialize, de::DeserializeOwned};
2+
use uuid::Uuid;
23

34
use super::Client;
45
use crate::{
56
error::Result,
67
requests::{
78
filters::{
8-
Create, CreateInternal, Request, SetEnabled, SetIndex, SetName, SetSettings,
9-
SetSettingsInternal,
9+
Create, CreateInternal, Get, Remove, Request, SetEnabled, SetIndex, SetName,
10+
SetSettings, SetSettingsInternal,
1011
},
1112
sources::SourceId,
1213
},
@@ -30,9 +31,13 @@ impl Filters<'_> {
3031

3132
/// Gets an array of all of a source's filters.
3233
#[doc(alias = "GetSourceFilterList")]
33-
pub async fn list(&self, source: SourceId<'_>) -> Result<Vec<responses::SourceFilter>> {
34+
pub async fn list(
35+
&self,
36+
canvas: Option<Uuid>,
37+
source: SourceId<'_>,
38+
) -> Result<Vec<responses::SourceFilter>> {
3439
self.client
35-
.send_message::<_, responses::Filters>(Request::List { source })
40+
.send_message::<_, responses::Filters>(Request::List { canvas, source })
3641
.await
3742
.map(|f| f.filters)
3843
}
@@ -60,6 +65,7 @@ impl Filters<'_> {
6065
self.client
6166
.send_message(Request::Create(CreateInternal {
6267
source: filter.source,
68+
canvas: filter.canvas,
6369
filter: filter.filter,
6470
kind: filter.kind,
6571
settings: filter
@@ -73,10 +79,8 @@ impl Filters<'_> {
7379

7480
/// Removes a filter from a source.
7581
#[doc(alias = "RemoveSourceFilter")]
76-
pub async fn remove(&self, source: SourceId<'_>, filter: &str) -> Result<()> {
77-
self.client
78-
.send_message(Request::Remove { source, filter })
79-
.await
82+
pub async fn remove(&self, filter: Remove<'_>) -> Result<()> {
83+
self.client.send_message(Request::Remove(filter)).await
8084
}
8185

8286
/// Sets the name of a source filter (rename).
@@ -87,10 +91,8 @@ impl Filters<'_> {
8791

8892
/// Gets the info for a specific source filter.
8993
#[doc(alias = "GetSourceFilter")]
90-
pub async fn get(&self, source: SourceId<'_>, filter: &str) -> Result<responses::SourceFilter> {
91-
self.client
92-
.send_message(Request::Get { source, filter })
93-
.await
94+
pub async fn get(&self, filter: Get<'_>) -> Result<responses::SourceFilter> {
95+
self.client.send_message(Request::Get(filter)).await
9496
}
9597

9698
/// Sets the index position of a filter on a source.
@@ -108,6 +110,7 @@ impl Filters<'_> {
108110
self.client
109111
.send_message(Request::SetSettings(SetSettingsInternal {
110112
source: settings.source,
113+
canvas: settings.canvas,
111114
filter: settings.filter,
112115
settings: serde_json::to_value(&settings.settings)
113116
.map_err(crate::error::SerializeCustomDataError)?,

src/client/inputs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl Inputs<'_> {
139139
{
140140
self.client
141141
.send_message(Request::Create(CreateInputInternal {
142+
canvas: input.canvas,
142143
scene: input.scene,
143144
input: input.input,
144145
kind: input.kind,

src/client/scene_items.rs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use serde::{Serialize, de::DeserializeOwned};
2+
use uuid::Uuid;
23

34
use super::Client;
45
use crate::{
5-
common::BlendMode,
6+
common,
67
error::Result,
78
requests::{
89
scene_items::{
9-
CreateSceneItem, Duplicate, Id, Request, SetBlendMode, SetEnabled, SetIndex, SetLocked,
10-
SetPrivateSettings, SetPrivateSettingsInternal, SetTransform, Source,
10+
BlendMode, CreateSceneItem, Duplicate, Enabled, Id, Index, Locked, Remove, Request,
11+
SetBlendMode, SetEnabled, SetIndex, SetLocked, SetPrivateSettings,
12+
SetPrivateSettingsInternal, SetTransform, Source, Transform,
1113
},
1214
scenes::SceneId,
1315
},
@@ -22,9 +24,13 @@ pub struct SceneItems<'a> {
2224
impl<'a> SceneItems<'a> {
2325
/// Gets a list of all scene items in a scene.
2426
#[doc(alias = "GetSceneItemList")]
25-
pub async fn list(&self, scene: SceneId<'_>) -> Result<Vec<responses::SceneItem>> {
27+
pub async fn list(
28+
&self,
29+
canvas: Option<Uuid>,
30+
scene: SceneId<'_>,
31+
) -> Result<Vec<responses::SceneItem>> {
2632
self.client
27-
.send_message::<_, responses::SceneItemList>(Request::List { scene })
33+
.send_message::<_, responses::SceneItemList>(Request::List { canvas, scene })
2834
.await
2935
.map(|sil| sil.scene_items)
3036
}
@@ -33,9 +39,13 @@ impl<'a> SceneItems<'a> {
3339
///
3440
/// Using groups at all in OBS is discouraged, as they are very broken under the hood.
3541
#[doc(alias = "GetGroupSceneItemList")]
36-
pub async fn list_group(&self, scene: SceneId<'_>) -> Result<Vec<responses::SceneItem>> {
42+
pub async fn list_group(
43+
&self,
44+
canvas: Option<Uuid>,
45+
scene: SceneId<'_>,
46+
) -> Result<Vec<responses::SceneItem>> {
3747
self.client
38-
.send_message::<_, responses::SceneItemList>(Request::ListGroup { scene })
48+
.send_message::<_, responses::SceneItemList>(Request::ListGroup { canvas, scene })
3949
.await
4050
.map(|sil| sil.scene_items)
4151
}
@@ -66,10 +76,8 @@ impl<'a> SceneItems<'a> {
6676

6777
/// Removes a scene item from a scene.
6878
#[doc(alias = "RemoveSceneItem")]
69-
pub async fn remove(&self, scene: SceneId<'_>, item_id: i64) -> Result<()> {
70-
self.client
71-
.send_message(Request::Remove { scene, item_id })
72-
.await
79+
pub async fn remove(&self, remove: Remove<'_>) -> Result<()> {
80+
self.client.send_message(Request::Remove(remove)).await
7381
}
7482

7583
/// Duplicates a scene item, copying all transform and crop info.
@@ -85,14 +93,10 @@ impl<'a> SceneItems<'a> {
8593
#[doc(alias = "GetSceneItemTransform")]
8694
pub async fn transform(
8795
&self,
88-
scene: SceneId<'_>,
89-
item_id: i64,
96+
transform: Transform<'_>,
9097
) -> Result<responses::SceneItemTransform> {
9198
self.client
92-
.send_message::<_, responses::GetSceneItemTransform>(Request::Transform {
93-
scene,
94-
item_id,
95-
})
99+
.send_message::<_, responses::GetSceneItemTransform>(Request::Transform(transform))
96100
.await
97101
.map(|gsit| gsit.transform)
98102
}
@@ -107,9 +111,9 @@ impl<'a> SceneItems<'a> {
107111

108112
/// Gets the enable state of a scene item.
109113
#[doc(alias = "GetSceneItemEnabled")]
110-
pub async fn enabled(&self, scene: SceneId<'_>, item_id: i64) -> Result<bool> {
114+
pub async fn enabled(&self, enabled: Enabled<'a>) -> Result<bool> {
111115
self.client
112-
.send_message::<_, responses::SceneItemEnabled>(Request::Enabled { scene, item_id })
116+
.send_message::<_, responses::SceneItemEnabled>(Request::Enabled(enabled))
113117
.await
114118
.map(|sie| sie.enabled)
115119
}
@@ -122,9 +126,9 @@ impl<'a> SceneItems<'a> {
122126

123127
/// Gets the lock state of a scene item.
124128
#[doc(alias = "GetSceneItemLocked")]
125-
pub async fn locked(&self, scene: SceneId<'_>, item_id: i64) -> Result<bool> {
129+
pub async fn locked(&self, locked: Locked<'a>) -> Result<bool> {
126130
self.client
127-
.send_message::<_, responses::SceneItemLocked>(Request::Locked { scene, item_id })
131+
.send_message::<_, responses::SceneItemLocked>(Request::Locked(locked))
128132
.await
129133
.map(|sil| sil.locked)
130134
}
@@ -139,9 +143,9 @@ impl<'a> SceneItems<'a> {
139143
///
140144
/// An index of 0 is at the bottom of the source list in the UI.
141145
#[doc(alias = "GetSceneItemIndex")]
142-
pub async fn index(&self, scene: SceneId<'_>, item_id: i64) -> Result<u32> {
146+
pub async fn index(&self, index: Index<'a>) -> Result<u32> {
143147
self.client
144-
.send_message::<_, responses::SceneItemIndex>(Request::Index { scene, item_id })
148+
.send_message::<_, responses::SceneItemIndex>(Request::Index(index))
145149
.await
146150
.map(|sii| sii.index)
147151
}
@@ -154,9 +158,9 @@ impl<'a> SceneItems<'a> {
154158

155159
/// Gets the blend mode of a scene item.
156160
#[doc(alias = "GetSceneItemBlendMode")]
157-
pub async fn blend_mode(&self, scene: SceneId<'_>, item_id: i64) -> Result<BlendMode> {
161+
pub async fn blend_mode(&self, mode: BlendMode<'_>) -> Result<common::BlendMode> {
158162
self.client
159-
.send_message::<_, responses::SceneItemBlendMode>(Request::BlendMode { scene, item_id })
163+
.send_message::<_, responses::SceneItemBlendMode>(Request::BlendMode(mode))
160164
.await
161165
.map(|sibm| sibm.blend_mode)
162166
}

src/client/scenes.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use uuid::Uuid;
33
use super::Client;
44
use crate::{
55
error::Result,
6-
requests::scenes::{Request, SceneId, SetTransitionOverride},
6+
requests::scenes::{Request, SceneId, SetName, SetTransitionOverride},
77
responses::scenes as responses,
88
};
99

@@ -32,6 +32,9 @@ impl Scenes<'_> {
3232
}
3333

3434
/// Gets the current program scene.
35+
///
36+
/// **Note:** Canvases do not have any concept of a program or preview scene, so this request
37+
/// does not support canvases.
3538
#[doc(alias = "GetCurrentProgramScene")]
3639
pub async fn current_program_scene(&self) -> Result<responses::CurrentProgramScene> {
3740
self.client.send_message(Request::CurrentProgramScene).await
@@ -69,35 +72,36 @@ impl Scenes<'_> {
6972

7073
/// Sets the name of a scene (rename).
7174
#[doc(alias = "SetSceneName")]
72-
pub async fn set_name(&self, scene: SceneId<'_>, new_name: &str) -> Result<()> {
73-
self.client
74-
.send_message(Request::SetName { scene, new_name })
75-
.await
75+
pub async fn set_name(&self, name: SetName<'_>) -> Result<()> {
76+
self.client.send_message(Request::SetName(name)).await
7677
}
7778

7879
/// Creates a new scene in OBS.
7980
#[doc(alias = "CreateScene")]
80-
pub async fn create(&self, name: &str) -> Result<Uuid> {
81+
pub async fn create(&self, canvas: Option<Uuid>, name: &str) -> Result<Uuid> {
8182
self.client
82-
.send_message::<_, responses::CreateScene>(Request::Create { name })
83+
.send_message::<_, responses::CreateScene>(Request::Create { canvas, name })
8384
.await
8485
.map(|cs| cs.uuid)
8586
}
8687

8788
/// Removes a scene from OBS.
8889
#[doc(alias = "RemoveScene")]
89-
pub async fn remove(&self, scene: SceneId<'_>) -> Result<()> {
90-
self.client.send_message(Request::Remove { scene }).await
90+
pub async fn remove(&self, canvas: Option<Uuid>, scene: SceneId<'_>) -> Result<()> {
91+
self.client
92+
.send_message(Request::Remove { canvas, scene })
93+
.await
9194
}
9295

9396
/// Gets the scene transition overridden for a scene.
9497
#[doc(alias = "GetSceneSceneTransitionOverride")]
9598
pub async fn transition_override(
9699
&self,
100+
canvas: Option<Uuid>,
97101
scene: SceneId<'_>,
98102
) -> Result<responses::SceneTransitionOverride> {
99103
self.client
100-
.send_message(Request::TransitionOverride { scene })
104+
.send_message(Request::TransitionOverride { canvas, scene })
101105
.await
102106
}
103107

src/client/sources.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use uuid::Uuid;
2+
13
use super::Client;
24
use crate::{
35
error::Result,
@@ -13,8 +15,14 @@ pub struct Sources<'a> {
1315
impl Sources<'_> {
1416
/// Gets the active and show state of a source.
1517
#[doc(alias = "GetSourceActive")]
16-
pub async fn active(&self, source: SourceId<'_>) -> Result<responses::SourceActive> {
17-
self.client.send_message(Request::Active { source }).await
18+
pub async fn active(
19+
&self,
20+
canvas: Option<Uuid>,
21+
source: SourceId<'_>,
22+
) -> Result<responses::SourceActive> {
23+
self.client
24+
.send_message(Request::Active { canvas, source })
25+
.await
1826
}
1927

2028
/// Gets a Base64-encoded screenshot of a source.

src/client/ui.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl<'a> Ui<'a> {
8787
pub async fn open_source_projector(&self, open: OpenSourceProjector<'a>) -> Result<()> {
8888
self.client
8989
.send_message(Request::OpenSourceProjector(OpenSourceProjectorInternal {
90+
canvas: open.canvas,
9091
source: open.source,
9192
location: open.location.map(Into::into),
9293
}))

0 commit comments

Comments
 (0)