Coverage Report

Created: 2022-07-04 16:17

src/requests/inputs.rs
Line
Count
Source (jump to first uncovered line)
1
//! Requests related to inputs.
2
3
use serde::Serialize;
4
use serde_with::skip_serializing_none;
5
use time::Duration;
6
7
use crate::common::MonitorType;
8
9
75
#[derive(
S57
eri
aliz18
e)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::inputs::Request as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
<<obws::requests::inputs::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
9
2
#[derive(Serialize)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
2
#[derive(Serialize)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
9
2
#[derive(Serialize)]
<<obws::requests::inputs::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
9
2
#[derive(Serialize)]
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
2
#[derive(Serialize)]
<<obws::requests::inputs::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
9
2
#[derive(Serialize)]
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
<<obws::requests::inputs::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
9
1
#[derive(Serialize)]
<<obws::requests::inputs::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
9
19
#[derive(Serialize)]
<obws::requests::inputs::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
9
38
#[derive(Serialize)]
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::inputs::Request as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::inputs::Request as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <<obws::requests::inputs::Request as serde::ser::Serialize>::serialize::__AdjacentlyTagged as serde::ser::Serialize>::serialize::<_>
10
#[serde(tag = "requestType", content = "requestData")]
11
pub(crate) enum Request<'a> {
12
    #[serde(rename = "GetInputList")]
13
    List {
14
        /// Restrict the array to only inputs of the specified kind.
15
        #[serde(rename = "inputKind", skip_serializing_if = "Option::is_none")]
16
        kind: Option<&'a str>,
17
    },
18
    #[serde(rename = "GetInputKindList")]
19
    ListKinds {
20
        /// Return all kinds as unversioned or with version suffixes (if available).
21
        #[serde(rename = "unversioned")]
22
        unversioned: bool,
23
    },
24
    #[serde(rename = "GetInputDefaultSettings")]
25
    DefaultSettings {
26
        /// Input kind to get the default settings for.
27
        #[serde(rename = "inputKind")]
28
        kind: &'a str,
29
    },
30
    #[serde(rename = "GetInputSettings")]
31
    Settings {
32
        /// Name of the input to get the settings of.
33
        #[serde(rename = "inputName")]
34
        name: &'a str,
35
    },
36
    #[serde(rename = "SetInputSettings")]
37
    SetSettings(SetSettingsInternal<'a>),
38
    #[serde(rename = "GetInputMute")]
39
    Muted {
40
        /// Name of input to get the mute state of.
41
        #[serde(rename = "inputName")]
42
        name: &'a str,
43
    },
44
    #[serde(rename = "SetInputMute")]
45
    SetMuted {
46
        /// Name of the input to set the mute state of.
47
        #[serde(rename = "inputName")]
48
        name: &'a str,
49
        /// Whether to mute the input.
50
        #[serde(rename = "inputMuted")]
51
        muted: bool,
52
    },
53
    #[serde(rename = "ToggleInputMute")]
54
    ToggleMute {
55
        /// Name of the input to toggle the mute state of.
56
        #[serde(rename = "inputName")]
57
        name: &'a str,
58
    },
59
    #[serde(rename = "GetInputVolume")]
60
    Volume {
61
        /// Name of the input to get the volume of.
62
        #[serde(rename = "inputName")]
63
        name: &'a str,
64
    },
65
    #[serde(rename = "SetInputVolume")]
66
    SetVolume {
67
        /// Name of the input to set the volume of.
68
        #[serde(rename = "inputName")]
69
        name: &'a str,
70
        /// Volume settings in either mul or dB.
71
        #[serde(rename = "volume", flatten)]
72
        volume: Volume,
73
    },
74
    #[serde(rename = "SetInputName")]
75
    SetName {
76
        /// Current input name.
77
        #[serde(rename = "inputName")]
78
        name: &'a str,
79
        /// New name for the input.
80
        #[serde(rename = "newInputName")]
81
        new: &'a str,
82
    },
83
    #[serde(rename = "CreateInput")]
84
    Create(CreateInputInternal<'a>),
85
    #[serde(rename = "RemoveInput")]
86
    Remove {
87
        /// Name of the input to remove.
88
        #[serde(rename = "inputName")]
89
        name: &'a str,
90
    },
91
    #[serde(rename = "GetInputAudioSyncOffset")]
92
    AudioSyncOffset {
93
        /// Name of the input to get the audio sync offset of.
94
        #[serde(rename = "inputName")]
95
        name: &'a str,
96
    },
97
    #[serde(rename = "SetInputAudioSyncOffset")]
98
    SetAudioSyncOffset {
99
        /// Name of the input to set the audio sync offset of.
100
        #[serde(rename = "inputName")]
101
        name: &'a str,
102
        /// New audio sync offset in milliseconds.
103
        #[serde(
104
            rename = "inputAudioSyncOffset",
105
            with = "crate::serde::duration_millis"
106
        )]
107
        offset: Duration,
108
    },
109
    #[serde(rename = "GetInputAudioMonitorType")]
110
    AudioMonitorType {
111
        /// Name of the input to get the audio monitor type of.
112
        #[serde(rename = "inputName")]
113
        name: &'a str,
114
    },
115
    #[serde(rename = "SetInputAudioMonitorType")]
116
    SetAudioMonitorType {
117
        /// Name of the input to set the audio monitor type of.
118
        #[serde(rename = "inputName")]
119
        name: &'a str,
120
        /// Audio monitor type.
121
        #[serde(rename = "monitorType")]
122
        monitor_type: MonitorType,
123
    },
124
    #[serde(rename = "GetInputPropertiesListPropertyItems")]
125
    PropertiesListPropertyItems {
126
        /// Name of the input.
127
        #[serde(rename = "inputName")]
128
        input: &'a str,
129
        /// Name of the list property to get the items of.
130
        #[serde(rename = "propertyName")]
131
        property: &'a str,
132
    },
133
    #[serde(rename = "PressInputPropertiesButton")]
134
    PressPropertiesButton {
135
        /// Name of the input.
136
        #[serde(rename = "inputName")]
137
        input: &'a str,
138
        /// Name of the button property to press.
139
        #[serde(rename = "propertyName")]
140
        property: &'a str,
141
    },
142
}
143
144
impl<'a> From<Request<'a>> for super::RequestType<'a> {
145
38
    fn from(value: Request<'a>) -> Self {
146
38
        super::RequestType::Inputs(value)
147
38
    }
<obws::requests::RequestType as core::convert::From<obws::requests::inputs::Request>>::from
Line
Count
Source
145
38
    fn from(value: Request<'a>) -> Self {
146
38
        super::RequestType::Inputs(value)
147
38
    }
Unexecuted instantiation: <obws::requests::RequestType as core::convert::From<obws::requests::inputs::Request>>::from
148
}
149
150
/// Request information for [`crate::client::Inputs::set_settings`].
151
pub struct SetSettings<'a, T> {
152
    /// Name of the input to set the settings of.
153
    pub input: &'a str,
154
    /// Object of settings to apply.
155
    pub settings: &'a T,
156
    /// Apply settings on top of existing ones or reset the input to its defaults, then apply
157
    /// settings.
158
    pub overlay: Option<bool>,
159
}
160
161
/// Request information for [`crate::client::Inputs::set_input_settings`].
162
#[skip_serializing_none]
163
1
#[derive(
Default0
, Serialize)]
Unexecuted instantiation: <obws::requests::inputs::SetSettingsInternal as core::default::Default>::default
Unexecuted instantiation: <obws::requests::inputs::SetSettingsInternal as core::default::Default>::default
<obws::requests::inputs::SetSettingsInternal as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
163
1
#[derive(Default, Serialize)]
Unexecuted instantiation: <obws::requests::inputs::SetSettingsInternal as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::inputs::SetSettingsInternal as serde::ser::Serialize>::serialize::<_>
164
pub(crate) struct SetSettingsInternal<'a> {
165
    /// Name of the input to set the settings of.
166
    #[serde(rename = "inputName")]
167
    pub input: &'a str,
168
    /// Object of settings to apply.
169
    #[serde(rename = "inputSettings")]
170
    pub settings: serde_json::Value,
171
    /// Apply settings on top of existing ones or reset the input to its defaults, then apply
172
    /// settings.
173
    #[serde(rename = "overlay")]
174
    pub overlay: Option<bool>,
175
}
176
177
/// Request information for [`crate::client::Inputs::set_volume`].
178
1
#[derive(Serialize)]
<obws::requests::inputs::Volume 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
178
1
#[derive(Serialize)]
Unexecuted instantiation: <obws::requests::inputs::Volume as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::inputs::Volume as serde::ser::Serialize>::serialize::<_>
179
pub enum Volume {
180
    /// Volume setting in mul.
181
    #[serde(rename = "inputVolumeMul")]
182
    Mul(f32),
183
    /// Volume setting in dB.
184
    #[serde(rename = "inputVolumeDb")]
185
    Db(f32),
186
}
187
188
/// Request information for [`crate::client::Inputs::create`].
189
pub struct Create<'a, T> {
190
    /// Name of the scene to add the input to as a scene item.
191
    pub scene: &'a str,
192
    /// Name of the new input to created.
193
    pub input: &'a str,
194
    /// The kind of input to be created.
195
    pub kind: &'a str,
196
    /// Settings object to initialize the input with.
197
    pub settings: Option<T>,
198
    /// Whether to set the created scene item to enabled or disabled.
199
    pub enabled: Option<bool>,
200
}
201
202
/// Request information for [`crate::client::Inputs::create_input`].
203
#[skip_serializing_none]
204
0
#[derive(Default, Serialize)]
Unexecuted instantiation: <obws::requests::inputs::CreateInputInternal as core::default::Default>::default
Unexecuted instantiation: <obws::requests::inputs::CreateInputInternal as core::default::Default>::default
Unexecuted instantiation: <obws::requests::inputs::CreateInputInternal as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Unexecuted instantiation: <obws::requests::inputs::CreateInputInternal as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <obws::requests::inputs::CreateInputInternal as serde::ser::Serialize>::serialize::<_>
205
pub(crate) struct CreateInputInternal<'a> {
206
    #[serde(rename = "sceneName")]
207
    pub scene: &'a str,
208
    #[serde(rename = "inputName")]
209
    pub input: &'a str,
210
    #[serde(rename = "inputKind")]
211
    pub kind: &'a str,
212
    #[serde(rename = "inputSettings")]
213
    pub settings: Option<serde_json::Value>,
214
    #[serde(rename = "sceneItemEnabled")]
215
    pub enabled: Option<bool>,
216
}