Coverage Report

Created: 2022-07-04 16:17

src/client/outputs.rs
Line
Count
Source (jump to first uncovered line)
1
use serde::{de::DeserializeOwned, Serialize};
2
3
use super::Client;
4
use crate::{requests::outputs::Request, responses::outputs as responses, Error, Result};
5
6
/// API functions related to outputs.
7
pub struct Outputs<'a> {
8
    pub(super) client: &'a Client,
9
}
10
11
impl<'a> Outputs<'a> {
12
    /// Gets the list of available outputs.
13
1
    pub async fn list(&self) -> Result<Vec<responses::Output>> {
<obws::client::outputs::Outputs>::list
Line
Count
Source
13
1
    pub async fn list(&self) -> Result<Vec<responses::Output>> {
Unexecuted instantiation: <obws::client::outputs::Outputs>::list
14
1
        self.client
15
2
            .send_message::<_, responses::OutputList>(Request::List)
16
2
            .await
17
1
            .map(|ol| ol.outputs)
<obws::client::outputs::Outputs>::list::{closure#0}::{closure#0}
Line
Count
Source
17
1
            .map(|ol| ol.outputs)
Unexecuted instantiation: <obws::client::outputs::Outputs>::list::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::list::{closure#0}::{closure#0}
18
1
    }
<obws::client::outputs::Outputs>::list::{closure#0}
Line
Count
Source
14
1
        self.client
15
2
            .send_message::<_, responses::OutputList>(Request::List)
16
2
            .await
17
1
            .map(|ol| ol.outputs)
18
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::list::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::list::{closure#0}
19
20
    /// Gets the status of an output.
21
1
    pub async fn status(&self, name: &str) -> Result<responses::OutputStatus> {
<obws::client::outputs::Outputs>::status
Line
Count
Source
21
1
    pub async fn status(&self, name: &str) -> Result<responses::OutputStatus> {
Unexecuted instantiation: <obws::client::outputs::Outputs>::status
22
2
        
self.client.send_message(Request::Status { name })1
.await
23
1
    }
<obws::client::outputs::Outputs>::status::{closure#0}
Line
Count
Source
22
2
        
self.client.send_message(Request::Status { name })1
.await
23
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::status::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::status::{closure#0}
24
25
    /// Toggles the status of an output.
26
2
    pub async fn toggle(&self, name: &str) -> Result<bool> {
<obws::client::outputs::Outputs>::toggle
Line
Count
Source
26
2
    pub async fn toggle(&self, name: &str) -> Result<bool> {
Unexecuted instantiation: <obws::client::outputs::Outputs>::toggle
27
2
        self.client
28
4
            .send_message::<_, responses::OutputActive>(Request::Toggle { name })
29
4
            .await
30
2
            .map(|oa| oa.active)
<obws::client::outputs::Outputs>::toggle::{closure#0}::{closure#0}
Line
Count
Source
30
2
            .map(|oa| oa.active)
Unexecuted instantiation: <obws::client::outputs::Outputs>::toggle::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::toggle::{closure#0}::{closure#0}
31
2
    }
<obws::client::outputs::Outputs>::toggle::{closure#0}
Line
Count
Source
27
2
        self.client
28
4
            .send_message::<_, responses::OutputActive>(Request::Toggle { name })
29
4
            .await
30
2
            .map(|oa| oa.active)
31
2
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::toggle::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::toggle::{closure#0}
32
33
    /// Starts an output.
34
1
    pub async fn start(&self, name: &str) -> Result<()> {
<obws::client::outputs::Outputs>::start
Line
Count
Source
34
1
    pub async fn start(&self, name: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::outputs::Outputs>::start
35
2
        
self.client.send_message(Request::Start { name })1
.await
36
1
    }
<obws::client::outputs::Outputs>::start::{closure#0}
Line
Count
Source
35
2
        
self.client.send_message(Request::Start { name })1
.await
36
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::start::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::start::{closure#0}
37
38
    /// Stops an output.
39
1
    pub async fn stop(&self, name: &str) -> Result<()> {
<obws::client::outputs::Outputs>::stop
Line
Count
Source
39
1
    pub async fn stop(&self, name: &str) -> Result<()> {
Unexecuted instantiation: <obws::client::outputs::Outputs>::stop
40
2
        
self.client.send_message(Request::Stop { name })1
.await
41
1
    }
<obws::client::outputs::Outputs>::stop::{closure#0}
Line
Count
Source
40
2
        
self.client.send_message(Request::Stop { name })1
.await
41
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::stop::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::stop::{closure#0}
42
43
    /// Gets the settings of an output.
44
1
    pub async fn settings<T>(&self, name: &str) -> Result<T>
45
1
    where
46
1
        T: DeserializeOwned,
47
1
    {
<obws::client::outputs::Outputs>::settings::<serde_json::value::Value>
Line
Count
Source
44
1
    pub async fn settings<T>(&self, name: &str) -> Result<T>
45
1
    where
46
1
        T: DeserializeOwned,
47
1
    {
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>
48
1
        self.client
49
2
            .send_message::<_, responses::OutputSettings<T>>(Request::Settings { name })
50
2
            .await
51
1
            .map(|os| os.settings)
<obws::client::outputs::Outputs>::settings::<serde_json::value::Value>::{closure#0}::{closure#0}
Line
Count
Source
51
1
            .map(|os| os.settings)
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>::{closure#0}::{closure#0}
52
1
    }
<obws::client::outputs::Outputs>::settings::<serde_json::value::Value>::{closure#0}
Line
Count
Source
48
1
        self.client
49
2
            .send_message::<_, responses::OutputSettings<T>>(Request::Settings { name })
50
2
            .await
51
1
            .map(|os| os.settings)
52
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::settings::<_>::{closure#0}
53
54
    /// Sets the settings of an output.
55
1
    pub async fn set_settings<T>(&self, name: &str, settings: T) -> Result<()>
56
1
    where
57
1
        T: Serialize,
58
1
    {
<obws::client::outputs::Outputs>::set_settings::<&serde_json::value::Value>
Line
Count
Source
55
1
    pub async fn set_settings<T>(&self, name: &str, settings: T) -> Result<()>
56
1
    where
57
1
        T: Serialize,
58
1
    {
Unexecuted instantiation: <obws::client::outputs::Outputs>::set_settings::<_>
Unexecuted instantiation: <obws::client::outputs::Outputs>::set_settings::<_>
59
        self.client
60
            .send_message(Request::SetSettings {
61
1
                name,
62
1
                settings: serde_json::to_value(&settings).map_err(Error::SerializeCustomData)
?0
,
63
2
            })
64
2
            .await
65
1
    }
<obws::client::outputs::Outputs>::set_settings::<&serde_json::value::Value>::{closure#0}
Line
Count
Source
61
1
                name,
62
1
                settings: serde_json::to_value(&settings).map_err(Error::SerializeCustomData)
?0
,
63
2
            })
64
2
            .await
65
1
    }
Unexecuted instantiation: <obws::client::outputs::Outputs>::set_settings::<_>::{closure#0}
Unexecuted instantiation: <obws::client::outputs::Outputs>::set_settings::<_>::{closure#0}
66
}