Coverage Report

Created: 2022-07-04 16:17

src/client/sources.rs
Line
Count
Source
1
use super::Client;
2
use crate::{
3
    requests::sources::{Request, SaveScreenshot, TakeScreenshot},
4
    responses::sources as responses,
5
    Result,
6
};
7
8
/// API functions related to sources.
9
pub struct Sources<'a> {
10
    pub(super) client: &'a Client,
11
}
12
13
impl<'a> Sources<'a> {
14
    /// Gets the active and show state of a source.
15
1
    pub async fn active(&self, name: &str) -> Result<responses::SourceActive> {
<obws::client::sources::Sources>::active
Line
Count
Source
15
1
    pub async fn active(&self, name: &str) -> Result<responses::SourceActive> {
Unexecuted instantiation: <obws::client::sources::Sources>::active
16
2
        
self.client.send_message(Request::Active { name })1
.await
17
1
    }
<obws::client::sources::Sources>::active::{closure#0}
Line
Count
Source
16
2
        
self.client.send_message(Request::Active { name })1
.await
17
1
    }
Unexecuted instantiation: <obws::client::sources::Sources>::active::{closure#0}
Unexecuted instantiation: <obws::client::sources::Sources>::active::{closure#0}
18
19
    /// Gets a Base64-encoded screenshot of a source.
20
    ///
21
    /// The [`TakeScreenshot::width`] and [`TakeScreenshot::height`] parameters are treated as
22
    /// "scale to inner", meaning the smallest ratio will be used and the aspect ratio of the
23
    /// original resolution is kept. If [`TakeScreenshot::width`] and [`TakeScreenshot::height`] are
24
    /// not specified, the compressed image will use the full resolution of the source.
25
1
    pub async fn take_screenshot(&self, settings: TakeScreenshot<'_>) -> Result<String> {
<obws::client::sources::Sources>::take_screenshot
Line
Count
Source
25
1
    pub async fn take_screenshot(&self, settings: TakeScreenshot<'_>) -> Result<String> {
Unexecuted instantiation: <obws::client::sources::Sources>::take_screenshot
26
1
        self.client
27
2
            .send_message::<_, responses::ImageData>(Request::TakeScreenshot(settings))
28
2
            .await
29
1
            .map(|id| id.image_data)
<obws::client::sources::Sources>::take_screenshot::{closure#0}::{closure#0}
Line
Count
Source
29
1
            .map(|id| id.image_data)
Unexecuted instantiation: <obws::client::sources::Sources>::take_screenshot::{closure#0}::{closure#0}
Unexecuted instantiation: <obws::client::sources::Sources>::take_screenshot::{closure#0}::{closure#0}
30
1
    }
<obws::client::sources::Sources>::take_screenshot::{closure#0}
Line
Count
Source
26
1
        self.client
27
2
            .send_message::<_, responses::ImageData>(Request::TakeScreenshot(settings))
28
2
            .await
29
1
            .map(|id| id.image_data)
30
1
    }
Unexecuted instantiation: <obws::client::sources::Sources>::take_screenshot::{closure#0}
Unexecuted instantiation: <obws::client::sources::Sources>::take_screenshot::{closure#0}
31
32
    /// Saves a screenshot of a source to the file system.
33
    ///
34
    /// The [`SaveScreenshot::width`] and [`SaveScreenshot::height`] parameters are treated as
35
    /// "scale to inner", meaning the smallest ratio will be used and the aspect ratio of the
36
    /// original resolution is kept. If [`SaveScreenshot::width`] and [`SaveScreenshot::height`] are
37
    /// not specified, the compressed image will use the full resolution of the source.
38
1
    pub async fn save_screenshot(&self, settings: SaveScreenshot<'_>) -> Result<()> {
<obws::client::sources::Sources>::save_screenshot
Line
Count
Source
38
1
    pub async fn save_screenshot(&self, settings: SaveScreenshot<'_>) -> Result<()> {
Unexecuted instantiation: <obws::client::sources::Sources>::save_screenshot
39
1
        self.client
40
2
            .send_message(Request::SaveScreenshot(settings))
41
2
            .await
42
1
    }
<obws::client::sources::Sources>::save_screenshot::{closure#0}
Line
Count
Source
39
1
        self.client
40
2
            .send_message(Request::SaveScreenshot(settings))
41
2
            .await
42
1
    }
Unexecuted instantiation: <obws::client::sources::Sources>::save_screenshot::{closure#0}
Unexecuted instantiation: <obws::client::sources::Sources>::save_screenshot::{closure#0}
43
}