Line | Count | Source (jump to first uncovered line) |
1 | | use serde::{de::DeserializeOwned, Serialize}; |
2 | | |
3 | | use super::Client; |
4 | | use crate::{ |
5 | | requests::filters::{ |
6 | | Create, CreateInternal, Request, SetEnabled, SetIndex, SetName, SetSettings, |
7 | | SetSettingsInternal, |
8 | | }, |
9 | | responses::filters as responses, |
10 | | Error, Result, |
11 | | }; |
12 | | |
13 | | /// API functions related to filters. |
14 | | pub struct Filters<'a> { |
15 | | pub(super) client: &'a Client, |
16 | | } |
17 | | |
18 | | impl<'a> Filters<'a> { |
19 | | /// Gets an array of all of a source's filters. |
20 | 19 | pub async fn list(&self, source: &str) -> Result<Vec<responses::SourceFilter>> { <obws::client::filters::Filters>::list Line | Count | Source | 20 | 19 | pub async fn list(&self, source: &str) -> Result<Vec<responses::SourceFilter>> { |
Unexecuted instantiation: <obws::client::filters::Filters>::list |
21 | 19 | self.client |
22 | 38 | .send_message::<_, responses::Filters>(Request::List { source }) |
23 | 38 | .await |
24 | 19 | .map(|f| f.filters) <obws::client::filters::Filters>::list::{closure#0}::{closure#0} Line | Count | Source | 24 | 19 | .map(|f| f.filters) |
Unexecuted instantiation: <obws::client::filters::Filters>::list::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::list::{closure#0}::{closure#0} |
25 | 19 | } <obws::client::filters::Filters>::list::{closure#0} Line | Count | Source | 21 | 19 | self.client | 22 | 38 | .send_message::<_, responses::Filters>(Request::List { source }) | 23 | 38 | .await | 24 | 19 | .map(|f| f.filters) | 25 | 19 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::list::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::list::{closure#0} |
26 | | |
27 | | /// Gets the default settings for a filter kind. |
28 | 1 | pub async fn default_settings<T>(&self, kind: &str) -> Result<T> |
29 | 1 | where |
30 | 1 | T: DeserializeOwned, |
31 | 1 | { <obws::client::filters::Filters>::default_settings::<serde_json::value::Value> Line | Count | Source | 28 | 1 | pub async fn default_settings<T>(&self, kind: &str) -> Result<T> | 29 | 1 | where | 30 | 1 | T: DeserializeOwned, | 31 | 1 | { |
Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_> Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_> |
32 | 1 | self.client |
33 | 1 | .send_message::<_, responses::DefaultFilterSettings<T>>(Request::DefaultSettings { |
34 | 1 | kind, |
35 | 2 | }) |
36 | 2 | .await |
37 | 1 | .map(|dfs| dfs.default_filter_settings) <obws::client::filters::Filters>::default_settings::<serde_json::value::Value>::{closure#0}::{closure#0} Line | Count | Source | 37 | 1 | .map(|dfs| dfs.default_filter_settings) |
Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_>::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_>::{closure#0}::{closure#0} |
38 | 1 | } <obws::client::filters::Filters>::default_settings::<serde_json::value::Value>::{closure#0} Line | Count | Source | 32 | 1 | self.client | 33 | 1 | .send_message::<_, responses::DefaultFilterSettings<T>>(Request::DefaultSettings { | 34 | 1 | kind, | 35 | 2 | }) | 36 | 2 | .await | 37 | 1 | .map(|dfs| dfs.default_filter_settings) | 38 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_>::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::default_settings::<_>::{closure#0} |
39 | | |
40 | | /// Creates a new filter, adding it to the specified source. |
41 | 1 | pub async fn create<T>(&self, filter: Create<'_, T>) -> Result<()> |
42 | 1 | where |
43 | 1 | T: Serialize, |
44 | 1 | { <obws::client::filters::Filters>::create::<serde_json::map::Map<alloc::string::String, serde_json::value::Value>> Line | Count | Source | 41 | 1 | pub async fn create<T>(&self, filter: Create<'_, T>) -> Result<()> | 42 | 1 | where | 43 | 1 | T: Serialize, | 44 | 1 | { |
Unexecuted instantiation: <obws::client::filters::Filters>::create::<_> Unexecuted instantiation: <obws::client::filters::Filters>::create::<_> |
45 | | self.client |
46 | | .send_message(Request::Create(CreateInternal { |
47 | 1 | source: filter.source, |
48 | 1 | filter: filter.filter, |
49 | 1 | kind: filter.kind, |
50 | 1 | settings: filter |
51 | 1 | .settings |
52 | 1 | .map(|settings| serde_json::to_value(&settings)) <obws::client::filters::Filters>::create::<serde_json::map::Map<alloc::string::String, serde_json::value::Value>>::{closure#0}::{closure#0} Line | Count | Source | 52 | 1 | .map(|settings| serde_json::to_value(&settings)) |
Unexecuted instantiation: <obws::client::filters::Filters>::create::<_>::{closure#0}::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::create::<_>::{closure#0}::{closure#0} |
53 | 1 | .transpose() |
54 | 1 | .map_err(Error::SerializeCustomData)?0 , |
55 | 2 | })) |
56 | 2 | .await |
57 | 1 | } <obws::client::filters::Filters>::create::<serde_json::map::Map<alloc::string::String, serde_json::value::Value>>::{closure#0} Line | Count | Source | 47 | 1 | source: filter.source, | 48 | 1 | filter: filter.filter, | 49 | 1 | kind: filter.kind, | 50 | 1 | settings: filter | 51 | 1 | .settings | 52 | 1 | .map(|settings| serde_json::to_value(&settings)) | 53 | 1 | .transpose() | 54 | 1 | .map_err(Error::SerializeCustomData)?0 , | 55 | 2 | })) | 56 | 2 | .await | 57 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::create::<_>::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::create::<_>::{closure#0} |
58 | | |
59 | | /// Removes a filter from a source. |
60 | 1 | pub async fn remove(&self, source: &str, filter: &str) -> Result<()> { <obws::client::filters::Filters>::remove Line | Count | Source | 60 | 1 | pub async fn remove(&self, source: &str, filter: &str) -> Result<()> { |
Unexecuted instantiation: <obws::client::filters::Filters>::remove |
61 | 1 | self.client |
62 | 2 | .send_message(Request::Remove { source, filter }) |
63 | 2 | .await |
64 | 1 | } <obws::client::filters::Filters>::remove::{closure#0} Line | Count | Source | 61 | 1 | self.client | 62 | 2 | .send_message(Request::Remove { source, filter }) | 63 | 2 | .await | 64 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::remove::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::remove::{closure#0} |
65 | | |
66 | | /// Sets the name of a source filter (rename). |
67 | 2 | pub async fn set_name(&self, name: SetName<'_>) -> Result<()> { <obws::client::filters::Filters>::set_name Line | Count | Source | 67 | 2 | pub async fn set_name(&self, name: SetName<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::filters::Filters>::set_name |
68 | 4 | self.client.send_message(Request::SetName(name))2 .await |
69 | 2 | } <obws::client::filters::Filters>::set_name::{closure#0} Line | Count | Source | 68 | 4 | self.client.send_message(Request::SetName(name))2 .await | 69 | 2 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::set_name::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::set_name::{closure#0} |
70 | | |
71 | | /// Gets the info for a specific source filter. |
72 | 1 | pub async fn get(&self, source: &str, filter: &str) -> Result<responses::SourceFilter> { <obws::client::filters::Filters>::get Line | Count | Source | 72 | 1 | pub async fn get(&self, source: &str, filter: &str) -> Result<responses::SourceFilter> { |
Unexecuted instantiation: <obws::client::filters::Filters>::get |
73 | 1 | self.client |
74 | 2 | .send_message(Request::Get { source, filter }) |
75 | 2 | .await |
76 | 1 | } <obws::client::filters::Filters>::get::{closure#0} Line | Count | Source | 73 | 1 | self.client | 74 | 2 | .send_message(Request::Get { source, filter }) | 75 | 2 | .await | 76 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::get::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::get::{closure#0} |
77 | | |
78 | | /// Sets the index position of a filter on a source. |
79 | 1 | pub async fn set_index(&self, index: SetIndex<'_>) -> Result<()> { <obws::client::filters::Filters>::set_index Line | Count | Source | 79 | 1 | pub async fn set_index(&self, index: SetIndex<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::filters::Filters>::set_index |
80 | 2 | self.client.send_message(Request::SetIndex(index))1 .await |
81 | 1 | } <obws::client::filters::Filters>::set_index::{closure#0} Line | Count | Source | 80 | 2 | self.client.send_message(Request::SetIndex(index))1 .await | 81 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::set_index::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::set_index::{closure#0} |
82 | | |
83 | | /// Sets the settings of a source filter. |
84 | 1 | pub async fn set_settings<T>(&self, settings: SetSettings<'_, T>) -> Result<()> |
85 | 1 | where |
86 | 1 | T: Serialize, |
87 | 1 | { <obws::client::filters::Filters>::set_settings::<serde_json::map::Map<alloc::string::String, serde_json::value::Value>> Line | Count | Source | 84 | 1 | pub async fn set_settings<T>(&self, settings: SetSettings<'_, T>) -> Result<()> | 85 | 1 | where | 86 | 1 | T: Serialize, | 87 | 1 | { |
Unexecuted instantiation: <obws::client::filters::Filters>::set_settings::<_> Unexecuted instantiation: <obws::client::filters::Filters>::set_settings::<_> |
88 | | self.client |
89 | | .send_message(Request::SetSettings(SetSettingsInternal { |
90 | 1 | source: settings.source, |
91 | 1 | filter: settings.filter, |
92 | 1 | settings: serde_json::to_value(&settings.settings) |
93 | 1 | .map_err(Error::SerializeCustomData)?0 , |
94 | 1 | overlay: settings.overlay, |
95 | 2 | })) |
96 | 2 | .await |
97 | 1 | } <obws::client::filters::Filters>::set_settings::<serde_json::map::Map<alloc::string::String, serde_json::value::Value>>::{closure#0} Line | Count | Source | 90 | 1 | source: settings.source, | 91 | 1 | filter: settings.filter, | 92 | 1 | settings: serde_json::to_value(&settings.settings) | 93 | 1 | .map_err(Error::SerializeCustomData)?0 , | 94 | 1 | overlay: settings.overlay, | 95 | 2 | })) | 96 | 2 | .await | 97 | 1 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::set_settings::<_>::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::set_settings::<_>::{closure#0} |
98 | | |
99 | | /// Sets the enable state of a source filter. |
100 | 2 | pub async fn set_enabled(&self, enabled: SetEnabled<'_>) -> Result<()> { <obws::client::filters::Filters>::set_enabled Line | Count | Source | 100 | 2 | pub async fn set_enabled(&self, enabled: SetEnabled<'_>) -> Result<()> { |
Unexecuted instantiation: <obws::client::filters::Filters>::set_enabled |
101 | 4 | self.client.send_message(Request::SetEnabled(enabled))2 .await |
102 | 2 | } <obws::client::filters::Filters>::set_enabled::{closure#0} Line | Count | Source | 101 | 4 | self.client.send_message(Request::SetEnabled(enabled))2 .await | 102 | 2 | } |
Unexecuted instantiation: <obws::client::filters::Filters>::set_enabled::{closure#0} Unexecuted instantiation: <obws::client::filters::Filters>::set_enabled::{closure#0} |
103 | | } |