Coverage Report

Created: 2022-07-04 16:17

src/client/scenes.rs
Line
Count
Source
1
use super::Client;
2
use crate::{
3
    requests::scenes::{Request, SetTransitionOverride},
4
    responses::scenes as responses,
5
    Result,
6
};
7
8
/// API functions related to scenes.
9
pub struct Scenes<'a> {
10
    pub(super) client: &'a Client,
11
}
12
13
impl<'a> Scenes<'a> {
14
    /// Gets an array of all scenes in OBS.
15
19
    pub async fn list(&self) -> Result<responses::Scenes> {
<obws::client::scenes::Scenes>::list
Line
Count
Source
15
19
    pub async fn list(&self) -> Result<responses::Scenes> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::list
16
38
        
self.client.send_message(Request::List)19
.await
17
19
    }
<obws::client::scenes::Scenes>::list::{closure#0}
Line
Count
Source
16
38
        
self.client.send_message(Request::List)19
.await
17
19
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::list::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::list::{closure#0}
18
19
    /// Gets an array of all groups in OBS.
20
    ///
21
    /// Groups in OBS are actually scenes, but renamed and modified. In obs-websocket, we treat them
22
    /// as scenes where we can.
23
19
    pub async fn list_groups(&self) -> Result<Vec<String>> {
<obws::client::scenes::Scenes>::list_groups
Line
Count
Source
23
19
    pub async fn list_groups(&self) -> Result<Vec<String>> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::list_groups
24
19
        self.client
25
38
            .send_message::<_, responses::Groups>(Request::ListGroups)
26
38
            .await
27
19
            .map(|g| g.groups)
<obws::client::scenes::Scenes>::list_groups::{closure#0}::{closure#0}
Line
Count
Source
27
19
            .map(|g| g.groups)
Unexecuted instantiation: <obws::client::scenes::Scenes>::list_groups::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::list_groups::{closure#0}::{closure#0}
28
19
    }
<obws::client::scenes::Scenes>::list_groups::{closure#0}
Line
Count
Source
24
19
        self.client
25
38
            .send_message::<_, responses::Groups>(Request::ListGroups)
26
38
            .await
27
19
            .map(|g| g.groups)
28
19
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::list_groups::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::list_groups::{closure#0}
29
30
    /// Gets the current program scene.
31
1
    pub async fn current_program_scene(&self) -> Result<String> {
<obws::client::scenes::Scenes>::current_program_scene
Line
Count
Source
31
1
    pub async fn current_program_scene(&self) -> Result<String> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_program_scene
32
1
        self.client
33
2
            .send_message::<_, responses::CurrentProgramScene>(Request::CurrentProgramScene)
34
2
            .await
35
1
            .map(|cps| cps.current_program_scene_name)
<obws::client::scenes::Scenes>::current_program_scene::{closure#0}::{closure#0}
Line
Count
Source
35
1
            .map(|cps| cps.current_program_scene_name)
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_program_scene::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_program_scene::{closure#0}::{closure#0}
36
1
    }
<obws::client::scenes::Scenes>::current_program_scene::{closure#0}
Line
Count
Source
32
1
        self.client
33
2
            .send_message::<_, responses::CurrentProgramScene>(Request::CurrentProgramScene)
34
2
            .await
35
1
            .map(|cps| cps.current_program_scene_name)
36
1
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_program_scene::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_program_scene::{closure#0}
37
38
    /// Sets the current program scene.
39
20
    pub async fn set_current_program_scene(&self, scene: &str) -> Result<()> {
<obws::client::scenes::Scenes>::set_current_program_scene
Line
Count
Source
39
20
    pub async fn set_current_program_scene(&self, scene: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_program_scene
40
20
        self.client
41
40
            .send_message(Request::SetCurrentProgramScene { scene })
42
40
            .await
43
20
    }
<obws::client::scenes::Scenes>::set_current_program_scene::{closure#0}
Line
Count
Source
40
20
        self.client
41
40
            .send_message(Request::SetCurrentProgramScene { scene })
42
40
            .await
43
20
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_program_scene::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_program_scene::{closure#0}
44
45
    /// Gets the current preview scene.
46
    ///
47
    /// Only available when studio mode is enabled.
48
1
    pub async fn current_preview_scene(&self) -> Result<String> {
<obws::client::scenes::Scenes>::current_preview_scene
Line
Count
Source
48
1
    pub async fn current_preview_scene(&self) -> Result<String> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_preview_scene
49
1
        self.client
50
2
            .send_message::<_, responses::CurrentPreviewScene>(Request::CurrentPreviewScene)
51
2
            .await
52
1
            .map(|cps| cps.current_preview_scene_name)
<obws::client::scenes::Scenes>::current_preview_scene::{closure#0}::{closure#0}
Line
Count
Source
52
1
            .map(|cps| cps.current_preview_scene_name)
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_preview_scene::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_preview_scene::{closure#0}::{closure#0}
53
1
    }
<obws::client::scenes::Scenes>::current_preview_scene::{closure#0}
Line
Count
Source
49
1
        self.client
50
2
            .send_message::<_, responses::CurrentPreviewScene>(Request::CurrentPreviewScene)
51
2
            .await
52
1
            .map(|cps| cps.current_preview_scene_name)
53
1
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_preview_scene::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::current_preview_scene::{closure#0}
54
55
    /// Sets the current preview scene.
56
    ///
57
    /// Only available when studio mode is enabled.
58
2
    pub async fn set_current_preview_scene(&self, scene: &str) -> Result<()> {
<obws::client::scenes::Scenes>::set_current_preview_scene
Line
Count
Source
58
2
    pub async fn set_current_preview_scene(&self, scene: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_preview_scene
59
2
        self.client
60
4
            .send_message(Request::SetCurrentPreviewScene { scene })
61
4
            .await
62
2
    }
<obws::client::scenes::Scenes>::set_current_preview_scene::{closure#0}
Line
Count
Source
59
2
        self.client
60
4
            .send_message(Request::SetCurrentPreviewScene { scene })
61
4
            .await
62
2
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_preview_scene::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_current_preview_scene::{closure#0}
63
64
    /// Sets the name of a scene (rename).
65
2
    pub async fn set_name(&self, scene: &str, new_name: &str) -> Result<()> {
<obws::client::scenes::Scenes>::set_name
Line
Count
Source
65
2
    pub async fn set_name(&self, scene: &str, new_name: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_name
66
2
        self.client
67
4
            .send_message(Request::SetName { scene, new_name })
68
4
            .await
69
2
    }
<obws::client::scenes::Scenes>::set_name::{closure#0}
Line
Count
Source
66
2
        self.client
67
4
            .send_message(Request::SetName { scene, new_name })
68
4
            .await
69
2
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_name::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_name::{closure#0}
70
71
    /// Creates a new scene in OBS.
72
1
    pub async fn create(&self, name: &str) -> Result<()> {
<obws::client::scenes::Scenes>::create
Line
Count
Source
72
1
    pub async fn create(&self, name: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::create
73
2
        
self.client.send_message(Request::Create { name })1
.await
74
1
    }
<obws::client::scenes::Scenes>::create::{closure#0}
Line
Count
Source
73
2
        
self.client.send_message(Request::Create { name })1
.await
74
1
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::create::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::create::{closure#0}
75
76
    /// Removes a scene from OBS.
77
1
    pub async fn remove(&self, scene: &str) -> Result<()> {
<obws::client::scenes::Scenes>::remove
Line
Count
Source
77
1
    pub async fn remove(&self, scene: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::remove
78
2
        
self.client.send_message(Request::Remove { scene })1
.await
79
1
    }
<obws::client::scenes::Scenes>::remove::{closure#0}
Line
Count
Source
78
2
        
self.client.send_message(Request::Remove { scene })1
.await
79
1
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::remove::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::remove::{closure#0}
80
81
    /// Gets the scene transition overridden for a scene.
82
1
    pub async fn transition_override(
83
1
        &self,
84
1
        scene: &str,
85
1
    ) -> Result<responses::SceneTransitionOverride> {
<obws::client::scenes::Scenes>::transition_override
Line
Count
Source
82
1
    pub async fn transition_override(
83
1
        &self,
84
1
        scene: &str,
85
1
    ) -> Result<responses::SceneTransitionOverride> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::transition_override
86
1
        self.client
87
2
            .send_message(Request::TransitionOverride { scene })
88
2
            .await
89
1
    }
<obws::client::scenes::Scenes>::transition_override::{closure#0}
Line
Count
Source
86
1
        self.client
87
2
            .send_message(Request::TransitionOverride { scene })
88
2
            .await
89
1
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::transition_override::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::transition_override::{closure#0}
90
91
    /// Sets the scene transition overridden for a scene.
92
2
    pub async fn set_transition_override(
93
2
        &self,
94
2
        transition_override: SetTransitionOverride<'_>,
95
2
    ) -> Result<()> {
<obws::client::scenes::Scenes>::set_transition_override
Line
Count
Source
92
2
    pub async fn set_transition_override(
93
2
        &self,
94
2
        transition_override: SetTransitionOverride<'_>,
95
2
    ) -> Result<()> {
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_transition_override
96
2
        self.client
97
4
            .send_message(Request::SetTransitionOverride(transition_override))
98
4
            .await
99
2
    }
<obws::client::scenes::Scenes>::set_transition_override::{closure#0}
Line
Count
Source
96
2
        self.client
97
4
            .send_message(Request::SetTransitionOverride(transition_override))
98
4
            .await
99
2
    }
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_transition_override::{closure#0}
Unexecuted instantiation: <obws::client::scenes::Scenes>::set_transition_override::{closure#0}
100
}