Coverage Report

Created: 2022-07-04 16:17

src/requests/config.rs
Line
Count
Source (jump to first uncovered line)
1
//! Requests related to the OBS configuration.
2
3
use serde::Serialize;
4
use serde_with::skip_serializing_none;
5
6
9
#[derive(
S7
eri
aliz2
e)]
<<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
6
1
#[derive(Serialize)]
<<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
6
1
#[derive(Serialize)]
<obws::requests::config::Request as serde::ser::Serialize>::serialize::<serde::__private::ser::FlatMapSerializer<serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter>>>
Line
Count
Source
6
7
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::config::Request as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Unexecuted instantiation: <<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::config::Request as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::config::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::config::Request as serde::ser::Serialize>::serialize::<_>
7
#[serde(tag = "requestType", content = "requestData")]
8
pub(crate) enum Request<'a> {
9
    #[serde(rename = "GetPersistentData")]
10
    GetPersistentData {
11
        /// The data realm to select.
12
        #[serde(rename = "realm")]
13
        realm: Realm,
14
        /// The name of the slot to retrieve data from.
15
        #[serde(rename = "slotName")]
16
        slot_name: &'a str,
17
    },
18
    #[serde(rename = "SetPersistentData")]
19
    SetPersistentData(SetPersistentData<'a>),
20
    #[serde(rename = "GetVideoSettings")]
21
    VideoSettings,
22
    #[serde(rename = "SetVideoSettings")]
23
    SetVideoSettings(SetVideoSettings),
24
    #[serde(rename = "GetStreamServiceSettings")]
25
    StreamServiceSettings,
26
    #[serde(rename = "SetStreamServiceSettings")]
27
    SetStreamServiceSettings {
28
        /// Type of stream service to apply. Example: `rtmp_common` or `rtmp_custom`.
29
        #[serde(rename = "streamServiceType")]
30
        r#type: &'a str,
31
        /// Settings to apply to the service.
32
        #[serde(rename = "streamServiceSettings")]
33
        settings: serde_json::Value,
34
    },
35
    #[serde(rename = "GetRecordDirectory")]
36
    RecordDirectory,
37
}
38
39
impl<'a> From<Request<'a>> for super::RequestType<'a> {
40
7
    fn from(value: Request<'a>) -> Self {
41
7
        super::RequestType::Config(value)
42
7
    }
<obws::requests::RequestType as core::convert::From<obws::requests::config::Request>>::from
Line
Count
Source
40
7
    fn from(value: Request<'a>) -> Self {
41
7
        super::RequestType::Config(value)
42
7
    }
Unexecuted instantiation: <obws::requests::RequestType as core::convert::From<obws::requests::config::Request>>::from
43
}
44
45
/// Request information for [`crate::client::Config::get_persistent_data`] and
46
/// [`crate::client::Config::set_persistent_data`] as part of
47
/// [`SetPersistentData`].
48
2
#[derive(
Clone0
, Copy, Serialize)]
Unexecuted instantiation: <obws::requests::config::Realm as core::clone::Clone>::clone
Unexecuted instantiation: <obws::requests::config::Realm as core::clone::Clone>::clone
<obws::requests::config::Realm as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
48
2
#[derive(Clone, Copy, Serialize)]
Unexecuted instantiation: <obws::requests::config::Realm as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::config::Realm as serde::ser::Serialize>::serialize::<_>
49
pub enum Realm {
50
    /// Data located in the global settings.
51
    #[serde(rename = "OBS_WEBSOCKET_DATA_REALM_GLOBAL")]
52
    Global,
53
    /// Data bound to the current profile.
54
    #[serde(rename = "OBS_WEBSOCKET_DATA_REALM_PROFILE")]
55
    Profile,
56
}
57
58
/// Request information for [`crate::client::Config::set_persistent_data`].
59
1
#[derive(Serialize)]
<obws::requests::config::SetPersistentData as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
59
1
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::config::SetPersistentData as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::config::SetPersistentData as serde::ser::Serialize>::serialize::<_>
60
pub struct SetPersistentData<'a> {
61
    /// The data realm to select.
62
    #[serde(rename = "realm")]
63
    pub realm: Realm,
64
    /// The name of the slot to retrieve data from.
65
    #[serde(rename = "slotName")]
66
    pub slot_name: &'a str,
67
    /// The value to apply to the slot.
68
    #[serde(rename = "slotValue")]
69
    pub slot_value: &'a serde_json::Value,
70
}
71
72
/// Request information for [`crate::client::Config::set_video_settings`].
73
#[skip_serializing_none]
74
1
#[derive(
Default0
, Serialize)]
Unexecuted instantiation: <obws::requests::config::SetVideoSettings as core::default::Default>::default
Unexecuted instantiation: <obws::requests::config::SetVideoSettings as core::default::Default>::default
<obws::requests::config::SetVideoSettings as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
74
1
#[derive(Default, Serialize)]
Unexecuted instantiation: <obws::requests::config::SetVideoSettings as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::config::SetVideoSettings as serde::ser::Serialize>::serialize::<_>
75
pub struct SetVideoSettings {
76
    /// Numerator of the fractional FPS value.
77
    #[serde(rename = "fpsNumerator")]
78
    pub fps_numerator: Option<u32>,
79
    /// Denominator of the fractional FPS value.
80
    #[serde(rename = "fpsDenominator")]
81
    pub fps_denominator: Option<u32>,
82
    /// Width of the base (canvas) resolution in pixels.
83
    #[serde(rename = "baseWidth")]
84
    pub base_width: Option<u32>,
85
    /// Height of the base (canvas) resolution in pixels.
86
    #[serde(rename = "baseHeight")]
87
    pub base_height: Option<u32>,
88
    /// Width of the output resolution in pixels.
89
    #[serde(rename = "outputWidth")]
90
    pub output_width: Option<u32>,
91
    /// Height of the output resolution in pixels.
92
    #[serde(rename = "outputHeight")]
93
    pub output_height: Option<u32>,
94
}
95
96
impl From<crate::responses::config::VideoSettings> for SetVideoSettings {
97
1
    fn from(v: crate::responses::config::VideoSettings) -> Self {
98
1
        Self {
99
1
            fps_numerator: Some(v.fps_numerator),
100
1
            fps_denominator: Some(v.fps_denominator),
101
1
            base_width: Some(v.base_width),
102
1
            base_height: Some(v.base_height),
103
1
            output_width: Some(v.output_width),
104
1
            output_height: Some(v.output_height),
105
1
        }
106
1
    }
<obws::requests::config::SetVideoSettings as core::convert::From<obws::responses::config::VideoSettings>>::from
Line
Count
Source
97
1
    fn from(v: crate::responses::config::VideoSettings) -> Self {
98
1
        Self {
99
1
            fps_numerator: Some(v.fps_numerator),
100
1
            fps_denominator: Some(v.fps_denominator),
101
1
            base_width: Some(v.base_width),
102
1
            base_height: Some(v.base_height),
103
1
            output_width: Some(v.output_width),
104
1
            output_height: Some(v.output_height),
105
1
        }
106
1
    }
Unexecuted instantiation: <obws::requests::config::SetVideoSettings as core::convert::From<obws::responses::config::VideoSettings>>::from
107
}