Coverage Report

Created: 2022-07-04 16:17

src/client/config.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::config::{Realm, Request, SetPersistentData, SetVideoSettings},
6
    responses::config as responses,
7
    Error, Result,
8
};
9
10
/// API functions related to OBS configuration.
11
pub struct Config<'a> {
12
    pub(super) client: &'a Client,
13
}
14
15
impl<'a> Config<'a> {
16
    /// Gets the value of a "slot" from the selected persistent data realm.
17
1
    pub async fn get_persistent_data(
18
1
        &self,
19
1
        realm: Realm,
20
1
        slot_name: &str,
21
1
    ) -> Result<serde_json::Value> {
<obws::client::config::Config>::get_persistent_data
Line
Count
Source
17
1
    pub async fn get_persistent_data(
18
1
        &self,
19
1
        realm: Realm,
20
1
        slot_name: &str,
21
1
    ) -> Result<serde_json::Value> {
Unexecuted instantiation: <obws::client::config::Config>::get_persistent_data
22
1
        self.client
23
2
            .send_message(Request::GetPersistentData { realm, slot_name })
24
2
            .await
25
1
    }
<obws::client::config::Config>::get_persistent_data::{closure#0}
Line
Count
Source
22
1
        self.client
23
2
            .send_message(Request::GetPersistentData { realm, slot_name })
24
2
            .await
25
1
    }
Unexecuted instantiation: <obws::client::config::Config>::get_persistent_data::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::get_persistent_data::{closure#0}
26
27
    /// Sets the value of a "slot" from the selected persistent data realm.
28
1
    pub async fn set_persistent_data(&self, data: SetPersistentData<'_>) -> Result<()> {
<obws::client::config::Config>::set_persistent_data
Line
Count
Source
28
1
    pub async fn set_persistent_data(&self, data: SetPersistentData<'_>) -> Result<()> {
Unexecuted instantiation: <obws::client::config::Config>::set_persistent_data
29
1
        self.client
30
2
            .send_message(Request::SetPersistentData(data))
31
2
            .await
32
1
    }
<obws::client::config::Config>::set_persistent_data::{closure#0}
Line
Count
Source
29
1
        self.client
30
2
            .send_message(Request::SetPersistentData(data))
31
2
            .await
32
1
    }
Unexecuted instantiation: <obws::client::config::Config>::set_persistent_data::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::set_persistent_data::{closure#0}
33
34
    /// Gets the current video settings.
35
    ///
36
    /// **Note:** To get the true FPS value, divide the FPS numerator by the FPS denominator.
37
    /// Example: `60000/1001`.
38
1
    pub async fn video_settings(&self) -> Result<responses::VideoSettings> {
<obws::client::config::Config>::video_settings
Line
Count
Source
38
1
    pub async fn video_settings(&self) -> Result<responses::VideoSettings> {
Unexecuted instantiation: <obws::client::config::Config>::video_settings
39
2
        
self.client.send_message(Request::VideoSettings)1
.await
40
1
    }
<obws::client::config::Config>::video_settings::{closure#0}
Line
Count
Source
39
2
        
self.client.send_message(Request::VideoSettings)1
.await
40
1
    }
Unexecuted instantiation: <obws::client::config::Config>::video_settings::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::video_settings::{closure#0}
41
42
    /// Sets the current video settings.
43
    ///
44
    /// **Note:** Fields must be specified in pairs. For example, you cannot set only
45
    /// [`SetVideoSettings::base_width`] without needing to specify
46
    /// [`SetVideoSettings::base_height`].
47
1
    pub async fn set_video_settings(&self, settings: SetVideoSettings) -> Result<()> {
<obws::client::config::Config>::set_video_settings
Line
Count
Source
47
1
    pub async fn set_video_settings(&self, settings: SetVideoSettings) -> Result<()> {
Unexecuted instantiation: <obws::client::config::Config>::set_video_settings
48
1
        self.client
49
2
            .send_message(Request::SetVideoSettings(settings))
50
2
            .await
51
1
    }
<obws::client::config::Config>::set_video_settings::{closure#0}
Line
Count
Source
48
1
        self.client
49
2
            .send_message(Request::SetVideoSettings(settings))
50
2
            .await
51
1
    }
Unexecuted instantiation: <obws::client::config::Config>::set_video_settings::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::set_video_settings::{closure#0}
52
53
    /// Gets the current stream service settings (stream destination).
54
1
    pub async fn stream_service_settings<T>(&self) -> Result<responses::StreamServiceSettings<T>>
55
1
    where
56
1
        T: DeserializeOwned,
57
1
    {
<obws::client::config::Config>::stream_service_settings::<serde_json::value::Value>
Line
Count
Source
54
1
    pub async fn stream_service_settings<T>(&self) -> Result<responses::StreamServiceSettings<T>>
55
1
    where
56
1
        T: DeserializeOwned,
57
1
    {
Unexecuted instantiation: <obws::client::config::Config>::stream_service_settings::<_>
Unexecuted instantiation: <obws::client::config::Config>::stream_service_settings::<_>
58
1
        self.client
59
2
            .send_message(Request::StreamServiceSettings)
60
2
            .await
61
1
    }
<obws::client::config::Config>::stream_service_settings::<serde_json::value::Value>::{closure#0}
Line
Count
Source
58
1
        self.client
59
2
            .send_message(Request::StreamServiceSettings)
60
2
            .await
61
1
    }
Unexecuted instantiation: <obws::client::config::Config>::stream_service_settings::<_>::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::stream_service_settings::<_>::{closure#0}
62
63
    /// Sets the current stream service settings (stream destination).
64
    ///
65
    /// **Note:** Simple RTMP settings can be set with type `rtmp_custom` and the settings fields
66
    /// `server` and `key`.
67
1
    pub async fn set_stream_service_settings<T>(&self, r#type: &'a str, settings: &T) -> Result<()>
68
1
    where
69
1
        T: Serialize,
70
1
    {
<obws::client::config::Config>::set_stream_service_settings::<serde_json::value::Value>
Line
Count
Source
67
1
    pub async fn set_stream_service_settings<T>(&self, r#type: &'a str, settings: &T) -> Result<()>
68
1
    where
69
1
        T: Serialize,
70
1
    {
Unexecuted instantiation: <obws::client::config::Config>::set_stream_service_settings::<_>
Unexecuted instantiation: <obws::client::config::Config>::set_stream_service_settings::<_>
71
        self.client
72
            .send_message(Request::SetStreamServiceSettings {
73
1
                r#type,
74
1
                settings: serde_json::to_value(settings).map_err(Error::SerializeCustomData)
?0
,
75
2
            })
76
2
            .await
77
1
    }
<obws::client::config::Config>::set_stream_service_settings::<serde_json::value::Value>::{closure#0}
Line
Count
Source
73
1
                r#type,
74
1
                settings: serde_json::to_value(settings).map_err(Error::SerializeCustomData)
?0
,
75
2
            })
76
2
            .await
77
1
    }
Unexecuted instantiation: <obws::client::config::Config>::set_stream_service_settings::<_>::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::set_stream_service_settings::<_>::{closure#0}
78
79
    /// Gets the current directory that the record output is set to.
80
1
    pub async fn record_directory(&self) -> Result<String> {
<obws::client::config::Config>::record_directory
Line
Count
Source
80
1
    pub async fn record_directory(&self) -> Result<String> {
Unexecuted instantiation: <obws::client::config::Config>::record_directory
81
1
        self.client
82
2
            .send_message::<_, responses::RecordDirectory>(Request::RecordDirectory)
83
2
            .await
84
1
            .map(|rd| rd.record_directory)
<obws::client::config::Config>::record_directory::{closure#0}::{closure#0}
Line
Count
Source
84
1
            .map(|rd| rd.record_directory)
Unexecuted instantiation: <obws::client::config::Config>::record_directory::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::record_directory::{closure#0}::{closure#0}
85
1
    }
<obws::client::config::Config>::record_directory::{closure#0}
Line
Count
Source
81
1
        self.client
82
2
            .send_message::<_, responses::RecordDirectory>(Request::RecordDirectory)
83
2
            .await
84
1
            .map(|rd| rd.record_directory)
85
1
    }
Unexecuted instantiation: <obws::client::config::Config>::record_directory::{closure#0}
Unexecuted instantiation: <obws::client::config::Config>::record_directory::{closure#0}
86
}