wdc/wdcmd/session/
w3c.rs

1// Copyright (C) 2023  Michael Lee
2//
3// This file is part of Wdc.
4//
5// Wdc is free software: you can redistribute it and/or modify it under the
6// terms of the GNU General Public License as published by the Free Software
7// Foundation, either version 3 of the License, or (at your option) any later
8// version.
9//
10// Wdc is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12// A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License along with
15// Wdc. If not, see <https://www.gnu.org/licenses/>.
16
17///
18/// Setters for standard-compliance capabilities request.
19///
20/// This is the request for which any standard-compliance WebDriver session
21/// would ask.
22pub trait W3cCapRequSetter<'c1, 'c2> {
23    fn mandate_as_w3c(&mut self, other: &'c1 impl W3cCapaGetter);
24    fn allow_as_w3c(&mut self, other: &'c2 impl W3cCapaGetter) -> &mut Self;
25}
26
27///
28/// Getters for standard-compliance capabilities.
29///
30/// Note that each capability has a specicial property of _significance_,
31/// by which the maximum flexibility of seriazlization can achieve.
32pub trait W3cCapaGetter {
33    // getter
34    fn browser_name(&self) -> Option<&str> {
35        None
36    }
37    fn browser_version(&self) -> Option<&str> {
38        None
39    }
40    fn platform_name(&self) -> Option<&str> {
41        None
42    }
43    fn accept_insecure_certs(&self) -> Option<bool> {
44        None
45    }
46    fn page_load_strategy(&self) -> Option<&str> {
47        None
48    }
49    //
50    fn proxy_type(&self) -> Option<&str> {
51        None
52    }
53    fn proxy_autoconfig_url(&self) -> Option<&str> {
54        None
55    }
56    fn ftp_proxy(&self) -> Option<&str> {
57        None
58    }
59    fn http_proxy(&self) -> Option<&str> {
60        None
61    }
62    fn no_proxy(&self) -> Option<Vec<&str>> {
63        None
64    }
65    fn ssl_proxy(&self) -> Option<&str> {
66        None
67    }
68    fn socks_proxy(&self) -> Option<&str> {
69        None
70    }
71    fn socks_version(&self) -> Option<u8> {
72        None
73    }
74    //
75    fn window_rect(&self) -> Option<bool> {
76        None
77    }
78    //
79    fn timeouts_script(&self) -> Option<u32> {
80        None
81    }
82    fn timeouts_page_load(&self) -> Option<u32> {
83        None
84    }
85    fn timeouts_implicit(&self) -> Option<u32> {
86        None
87    }
88    //
89    fn strict_file_interactability(&self) -> Option<bool> {
90        None
91    }
92    fn unhandled_prompt_behavior(&self) -> Option<&str> {
93        None
94    }
95    fn wsurl(&self) -> Option<&str> {
96        None
97    }
98
99    ///
100    /// Check whether all fields are insignificant, i.e. no need to
101    /// be serialized.
102    fn is_insig_as_w3c(&self) -> bool;
103}
104
105///
106/// Setters for standard-compliance capabilities.
107///
108/// These are the capabilities that any standard-compliance WebDriver session
109/// would have. They have effect on eventual new session. By this, user can tune
110/// the behavior the WebDriver has.
111///
112/// There are totally three types of "capabilities", as per W3C standard:
113/// 1. [Standard Capabilities](https://w3c.github.io/webdriver/#dfn-table-of-standard-capabilities)
114/// 2. [Extension Capabilities](https://w3c.github.io/webdriver/#dfn-extension-capability)
115/// 3. [Additional Capabilities](https://w3c.github.io/webdriver/#dfn-additional-webdriver-capability)
116///
117/// This specifies the __standard__ ones.
118pub trait W3cCapaSetter<'c> {
119    ///
120    /// Set a browser name.
121    fn set_browser_name(&mut self, arg: &'c str);
122    fn set_browser_name_take(&mut self, arg: String);
123    fn set_browser_name_owned(&mut self, arg: &str);
124    ///
125    /// Set a browser name, copy needed.
126    fn set_browser_version(&mut self, arg: &'c str);
127    fn set_browser_version_take(&mut self, arg: String);
128    fn set_browser_version_owned(&mut self, arg: &str);
129    fn set_platform_name(&mut self, arg: &'c str);
130    fn set_platform_name_take(&mut self, arg: String);
131    fn set_platform_name_owned(&mut self, arg: &str);
132    fn set_accept_insecure_certs(&mut self, arg: bool);
133    fn set_page_load_strategy(&mut self, arg: &'c str);
134    fn set_page_load_strategy_take(&mut self, arg: String);
135    fn set_page_load_strategy_owned(&mut self, arg: &str);
136    //
137    fn set_proxy_type(&mut self, arg: &'c str);
138    fn set_proxy_autoconfig_url(&mut self, arg: &'c str);
139    fn set_ftp_proxy(&mut self, arg: &'c str);
140    fn set_http_proxy(&mut self, arg: &'c str);
141    fn set_no_proxy(&mut self, arg: Vec<&'c str>);
142    fn add_no_proxy(&mut self, arg: &'c str);
143    fn set_ssl_proxy(&mut self, arg: &'c str);
144    fn set_socks_proxy(&mut self, arg: &'c str);
145    fn set_socks_proxy_owned(&mut self, arg: &str);
146    fn set_socks_proxy_take(&mut self, arg: String);
147    fn set_socks_version(&mut self, arg: u8);
148    //
149    fn set_window_rect(&mut self, arg: bool);
150    //
151    ///
152    /// Set timeout for script evaluation, in milliseconds.
153    ///
154    /// The script evaluation is typically fired by _ExecuteSync_
155    /// or _ExecuteAsync_ command.
156    fn set_timeouts_script(&mut self, arg: u32);
157    ///
158    /// Set timeout for page loading, in milliseconds.
159    fn set_timeouts_page_load(&mut self, arg: u32);
160    ///
161    /// Set timeout for ???, in milliseconds.
162    fn set_timeouts_implicit(&mut self, arg: u32);
163    //
164    fn set_strict_file_interactability(&mut self, arg: bool);
165    fn set_unhandled_prompt_behavior(&mut self, arg: &'c str);
166    fn set_unhandled_prompt_behavior_take(&mut self, arg: String);
167    fn set_unhandled_prompt_behavior_owned(&mut self, arg: &str);
168    fn set_wsurl(&mut self, arg: &'c str);
169    fn set_wsurl_take(&mut self, arg: String);
170    fn enable_bidi(&mut self);
171}
172
173///
174/// Getters for standard-compliance session result.
175///
176/// This is result that any standard-compliance WebDriver server would send back
177/// to client after creating a session.
178pub trait W3cSessResultGetter {
179    ///
180    /// The [session ID](https://w3c.github.io/webdriver/#dfn-session-id)
181    /// of binding session.
182    fn session_id(&self) -> &str;
183    fn wsurl(&self) -> Option<&str>;
184}