1use serde::{Deserialize, Serialize};
2#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3pub struct CapabilitiesRequest {
4 #[serde(rename = "alwaysMatch")]
5 #[serde(skip_serializing_if = "Option::is_none")]
6 #[serde(default)]
7 pub always_match: Option<CapabilityRequest>,
8 #[serde(rename = "firstMatch")]
9 #[serde(skip_serializing_if = "Option::is_none")]
10 #[serde(default)]
11 pub first_match: Option<Vec<CapabilityRequest>>,
12}
13impl CapabilitiesRequest {
14 pub const IDENTIFIER: &'static str = "session.CapabilitiesRequest";
15 pub const DOMAIN_DIRECTION: &'static str = "all";
16 pub fn identifier(&self) -> &'static str {
17 Self::IDENTIFIER
18 }
19}
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21pub struct CapabilityRequest {
22 #[serde(rename = "acceptInsecureCerts")]
23 #[serde(skip_serializing_if = "Option::is_none")]
24 #[serde(default)]
25 pub accept_insecure_certs: Option<bool>,
26 #[serde(rename = "browserName")]
27 #[serde(skip_serializing_if = "Option::is_none")]
28 #[serde(default)]
29 pub browser_name: Option<String>,
30 #[serde(rename = "browserVersion")]
31 #[serde(skip_serializing_if = "Option::is_none")]
32 #[serde(default)]
33 pub browser_version: Option<String>,
34 #[serde(rename = "platformName")]
35 #[serde(skip_serializing_if = "Option::is_none")]
36 #[serde(default)]
37 pub platform_name: Option<String>,
38 #[serde(rename = "proxy")]
39 #[serde(skip_serializing_if = "Option::is_none")]
40 #[serde(default)]
41 pub proxy: Option<ProxyConfiguration>,
42 #[serde(rename = "unhandledPromptBehavior")]
43 #[serde(skip_serializing_if = "Option::is_none")]
44 #[serde(default)]
45 pub unhandled_prompt_behavior: Option<UnhandledPromptBehavior>,
46 #[serde(flatten)]
47 #[serde(default)]
48 pub extensible: std::collections::HashMap<String, serde_json::Value>,
49}
50impl CapabilityRequest {
51 pub fn new(
52 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
53 ) -> Self {
54 Self {
55 extensible: extensible.into(),
56 accept_insecure_certs: None,
57 browser_name: None,
58 browser_version: None,
59 platform_name: None,
60 proxy: None,
61 unhandled_prompt_behavior: None,
62 }
63 }
64}
65impl CapabilityRequest {
66 pub const IDENTIFIER: &'static str = "session.CapabilityRequest";
67 pub const DOMAIN_DIRECTION: &'static str = "all";
68 pub fn identifier(&self) -> &'static str {
69 Self::IDENTIFIER
70 }
71}
72#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum ProxyConfiguration {
75 AutodetectProxyConfiguration(AutodetectProxyConfiguration),
76 DirectProxyConfiguration(DirectProxyConfiguration),
77 ManualProxyConfiguration(ManualProxyConfiguration),
78 PacProxyConfiguration(PacProxyConfiguration),
79 SystemProxyConfiguration(SystemProxyConfiguration),
80 SocksProxyConfiguration(SocksProxyConfiguration),
81 EmptyProxyConfiguration {},
82}
83impl From<AutodetectProxyConfiguration> for ProxyConfiguration {
84 fn from(v: AutodetectProxyConfiguration) -> Self {
85 ProxyConfiguration::AutodetectProxyConfiguration(v)
86 }
87}
88impl TryFrom<ProxyConfiguration> for AutodetectProxyConfiguration {
89 type Error = ProxyConfiguration;
90 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
91 match e {
92 ProxyConfiguration::AutodetectProxyConfiguration(inner) => Ok(inner),
93 other => Err(other),
94 }
95 }
96}
97impl From<DirectProxyConfiguration> for ProxyConfiguration {
98 fn from(v: DirectProxyConfiguration) -> Self {
99 ProxyConfiguration::DirectProxyConfiguration(v)
100 }
101}
102impl TryFrom<ProxyConfiguration> for DirectProxyConfiguration {
103 type Error = ProxyConfiguration;
104 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
105 match e {
106 ProxyConfiguration::DirectProxyConfiguration(inner) => Ok(inner),
107 other => Err(other),
108 }
109 }
110}
111impl From<ManualProxyConfiguration> for ProxyConfiguration {
112 fn from(v: ManualProxyConfiguration) -> Self {
113 ProxyConfiguration::ManualProxyConfiguration(v)
114 }
115}
116impl TryFrom<ProxyConfiguration> for ManualProxyConfiguration {
117 type Error = ProxyConfiguration;
118 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
119 match e {
120 ProxyConfiguration::ManualProxyConfiguration(inner) => Ok(inner),
121 other => Err(other),
122 }
123 }
124}
125impl From<PacProxyConfiguration> for ProxyConfiguration {
126 fn from(v: PacProxyConfiguration) -> Self {
127 ProxyConfiguration::PacProxyConfiguration(v)
128 }
129}
130impl TryFrom<ProxyConfiguration> for PacProxyConfiguration {
131 type Error = ProxyConfiguration;
132 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
133 match e {
134 ProxyConfiguration::PacProxyConfiguration(inner) => Ok(inner),
135 other => Err(other),
136 }
137 }
138}
139impl From<SystemProxyConfiguration> for ProxyConfiguration {
140 fn from(v: SystemProxyConfiguration) -> Self {
141 ProxyConfiguration::SystemProxyConfiguration(v)
142 }
143}
144impl TryFrom<ProxyConfiguration> for SystemProxyConfiguration {
145 type Error = ProxyConfiguration;
146 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
147 match e {
148 ProxyConfiguration::SystemProxyConfiguration(inner) => Ok(inner),
149 other => Err(other),
150 }
151 }
152}
153impl From<SocksProxyConfiguration> for ProxyConfiguration {
154 fn from(v: SocksProxyConfiguration) -> Self {
155 ProxyConfiguration::SocksProxyConfiguration(v)
156 }
157}
158impl TryFrom<ProxyConfiguration> for SocksProxyConfiguration {
159 type Error = ProxyConfiguration;
160 fn try_from(e: ProxyConfiguration) -> Result<Self, Self::Error> {
161 match e {
162 ProxyConfiguration::SocksProxyConfiguration(inner) => Ok(inner),
163 other => Err(other),
164 }
165 }
166}
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
168pub struct AutodetectProxyConfiguration {
169 #[serde(rename = "proxyType")]
170 pub proxy_type: AutodetectProxyConfigurationProxyType,
171 #[serde(flatten)]
172 #[serde(default)]
173 pub extensible: std::collections::HashMap<String, serde_json::Value>,
174}
175#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
176pub enum AutodetectProxyConfigurationProxyType {
177 #[serde(rename = "autodetect")]
178 Autodetect,
179}
180impl AutodetectProxyConfiguration {
181 pub fn new(
182 proxy_type: impl Into<AutodetectProxyConfigurationProxyType>,
183 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
184 ) -> Self {
185 Self {
186 proxy_type: proxy_type.into(),
187 extensible: extensible.into(),
188 }
189 }
190}
191impl AutodetectProxyConfiguration {
192 pub const IDENTIFIER: &'static str = "session.AutodetectProxyConfiguration";
193 pub const DOMAIN_DIRECTION: &'static str = "all";
194 pub fn identifier(&self) -> &'static str {
195 Self::IDENTIFIER
196 }
197}
198#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
199pub struct DirectProxyConfiguration {
200 #[serde(rename = "proxyType")]
201 pub proxy_type: DirectProxyConfigurationProxyType,
202 #[serde(flatten)]
203 #[serde(default)]
204 pub extensible: std::collections::HashMap<String, serde_json::Value>,
205}
206#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
207pub enum DirectProxyConfigurationProxyType {
208 #[serde(rename = "direct")]
209 Direct,
210}
211impl DirectProxyConfiguration {
212 pub fn new(
213 proxy_type: impl Into<DirectProxyConfigurationProxyType>,
214 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
215 ) -> Self {
216 Self {
217 proxy_type: proxy_type.into(),
218 extensible: extensible.into(),
219 }
220 }
221}
222impl DirectProxyConfiguration {
223 pub const IDENTIFIER: &'static str = "session.DirectProxyConfiguration";
224 pub const DOMAIN_DIRECTION: &'static str = "all";
225 pub fn identifier(&self) -> &'static str {
226 Self::IDENTIFIER
227 }
228}
229#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
230pub struct ManualProxyConfiguration {
231 #[serde(rename = "proxyType")]
232 pub proxy_type: ManualProxyConfigurationProxyType,
233 #[serde(rename = "httpProxy")]
234 #[serde(skip_serializing_if = "Option::is_none")]
235 #[serde(default)]
236 pub http_proxy: Option<String>,
237 #[serde(rename = "sslProxy")]
238 #[serde(skip_serializing_if = "Option::is_none")]
239 #[serde(default)]
240 pub ssl_proxy: Option<String>,
241 #[serde(rename = "noProxy")]
242 #[serde(skip_serializing_if = "Option::is_none")]
243 #[serde(default)]
244 pub no_proxy: Option<Vec<String>>,
245 #[serde(flatten)]
246 #[serde(default)]
247 pub extensible: std::collections::HashMap<String, serde_json::Value>,
248}
249#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
250pub enum ManualProxyConfigurationProxyType {
251 #[serde(rename = "manual")]
252 Manual,
253}
254impl ManualProxyConfiguration {
255 pub fn new(
256 proxy_type: impl Into<ManualProxyConfigurationProxyType>,
257 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
258 ) -> Self {
259 Self {
260 proxy_type: proxy_type.into(),
261 extensible: extensible.into(),
262 http_proxy: None,
263 ssl_proxy: None,
264 no_proxy: None,
265 }
266 }
267}
268impl ManualProxyConfiguration {
269 pub const IDENTIFIER: &'static str = "session.ManualProxyConfiguration";
270 pub const DOMAIN_DIRECTION: &'static str = "all";
271 pub fn identifier(&self) -> &'static str {
272 Self::IDENTIFIER
273 }
274}
275#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
276pub struct SocksProxyConfiguration {
277 #[serde(rename = "socksProxy")]
278 pub socks_proxy: String,
279 #[serde(rename = "socksVersion")]
280 pub socks_version: u64,
281}
282impl SocksProxyConfiguration {
283 pub fn new(socks_proxy: impl Into<String>, socks_version: impl Into<u64>) -> Self {
284 Self {
285 socks_proxy: socks_proxy.into(),
286 socks_version: socks_version.into(),
287 }
288 }
289}
290impl SocksProxyConfiguration {
291 pub const IDENTIFIER: &'static str = "session.SocksProxyConfiguration";
292 pub const DOMAIN_DIRECTION: &'static str = "all";
293 pub fn identifier(&self) -> &'static str {
294 Self::IDENTIFIER
295 }
296}
297#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
298pub struct PacProxyConfiguration {
299 #[serde(rename = "proxyType")]
300 pub proxy_type: PacProxyConfigurationProxyType,
301 #[serde(rename = "proxyAutoconfigUrl")]
302 pub proxy_autoconfig_url: String,
303 #[serde(flatten)]
304 #[serde(default)]
305 pub extensible: std::collections::HashMap<String, serde_json::Value>,
306}
307#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
308pub enum PacProxyConfigurationProxyType {
309 #[serde(rename = "pac")]
310 Pac,
311}
312impl PacProxyConfiguration {
313 pub fn new(
314 proxy_type: impl Into<PacProxyConfigurationProxyType>,
315 proxy_autoconfig_url: impl Into<String>,
316 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
317 ) -> Self {
318 Self {
319 proxy_type: proxy_type.into(),
320 proxy_autoconfig_url: proxy_autoconfig_url.into(),
321 extensible: extensible.into(),
322 }
323 }
324}
325impl PacProxyConfiguration {
326 pub const IDENTIFIER: &'static str = "session.PacProxyConfiguration";
327 pub const DOMAIN_DIRECTION: &'static str = "all";
328 pub fn identifier(&self) -> &'static str {
329 Self::IDENTIFIER
330 }
331}
332#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
333pub struct SystemProxyConfiguration {
334 #[serde(rename = "proxyType")]
335 pub proxy_type: SystemProxyConfigurationProxyType,
336 #[serde(flatten)]
337 #[serde(default)]
338 pub extensible: std::collections::HashMap<String, serde_json::Value>,
339}
340#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
341pub enum SystemProxyConfigurationProxyType {
342 #[serde(rename = "system")]
343 System,
344}
345impl SystemProxyConfiguration {
346 pub fn new(
347 proxy_type: impl Into<SystemProxyConfigurationProxyType>,
348 extensible: impl Into<std::collections::HashMap<String, serde_json::Value>>,
349 ) -> Self {
350 Self {
351 proxy_type: proxy_type.into(),
352 extensible: extensible.into(),
353 }
354 }
355}
356impl SystemProxyConfiguration {
357 pub const IDENTIFIER: &'static str = "session.SystemProxyConfiguration";
358 pub const DOMAIN_DIRECTION: &'static str = "all";
359 pub fn identifier(&self) -> &'static str {
360 Self::IDENTIFIER
361 }
362}
363#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
364pub struct UserPromptHandler {
365 #[serde(rename = "alert")]
366 #[serde(skip_serializing_if = "Option::is_none")]
367 #[serde(default)]
368 pub alert: Option<UserPromptHandlerType>,
369 #[serde(rename = "beforeUnload")]
370 #[serde(skip_serializing_if = "Option::is_none")]
371 #[serde(default)]
372 pub before_unload: Option<UserPromptHandlerType>,
373 #[serde(rename = "confirm")]
374 #[serde(skip_serializing_if = "Option::is_none")]
375 #[serde(default)]
376 pub confirm: Option<UserPromptHandlerType>,
377 #[serde(rename = "default")]
378 #[serde(skip_serializing_if = "Option::is_none")]
379 #[serde(default)]
380 pub r#default: Option<UserPromptHandlerType>,
381 #[serde(rename = "file")]
382 #[serde(skip_serializing_if = "Option::is_none")]
383 #[serde(default)]
384 pub file: Option<UserPromptHandlerType>,
385 #[serde(rename = "prompt")]
386 #[serde(skip_serializing_if = "Option::is_none")]
387 #[serde(default)]
388 pub prompt: Option<UserPromptHandlerType>,
389}
390impl UserPromptHandler {
391 pub const IDENTIFIER: &'static str = "session.UserPromptHandler";
392 pub const DOMAIN_DIRECTION: &'static str = "all";
393 pub fn identifier(&self) -> &'static str {
394 Self::IDENTIFIER
395 }
396}
397#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
398pub enum UserPromptHandlerType {
399 #[serde(rename = "accept")]
400 Accept,
401 #[serde(rename = "dismiss")]
402 Dismiss,
403 #[serde(rename = "ignore")]
404 Ignore,
405 #[serde(rename = "dismiss and notify")]
406 DismissAndNotify,
407}
408#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, Eq, Hash)]
409pub struct Subscription(String);
410impl Subscription {
411 pub fn new(val: impl Into<String>) -> Self {
412 Subscription(val.into())
413 }
414 pub fn inner(&self) -> &String {
415 &self.0
416 }
417}
418impl AsRef<str> for Subscription {
419 fn as_ref(&self) -> &str {
420 self.0.as_str()
421 }
422}
423impl From<Subscription> for String {
424 fn from(el: Subscription) -> String {
425 el.0
426 }
427}
428impl From<String> for Subscription {
429 fn from(expr: String) -> Self {
430 Subscription(expr)
431 }
432}
433impl Subscription {
434 pub const IDENTIFIER: &'static str = "session.Subscription";
435 pub const DOMAIN_DIRECTION: &'static str = "all";
436 pub fn identifier(&self) -> &'static str {
437 Self::IDENTIFIER
438 }
439}
440#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
441pub struct UnsubscribeByIdRequest {
442 #[serde(rename = "subscriptions")]
443 #[serde(skip_serializing_if = "Vec::is_empty")]
444 pub subscriptions: Vec<Subscription>,
445}
446impl UnsubscribeByIdRequest {
447 pub fn new(subscriptions: Vec<Subscription>) -> Self {
448 Self { subscriptions }
449 }
450}
451impl UnsubscribeByIdRequest {
452 pub const IDENTIFIER: &'static str = "session.UnsubscribeByIDRequest";
453 pub const DOMAIN_DIRECTION: &'static str = "remote";
454 pub fn identifier(&self) -> &'static str {
455 Self::IDENTIFIER
456 }
457}
458#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
459pub struct UnsubscribeByAttributesRequest {
460 #[serde(rename = "events")]
461 #[serde(skip_serializing_if = "Vec::is_empty")]
462 pub events: Vec<String>,
463}
464impl UnsubscribeByAttributesRequest {
465 pub fn new(events: Vec<String>) -> Self {
466 Self { events }
467 }
468}
469impl UnsubscribeByAttributesRequest {
470 pub const IDENTIFIER: &'static str = "session.UnsubscribeByAttributesRequest";
471 pub const DOMAIN_DIRECTION: &'static str = "remote";
472 pub fn identifier(&self) -> &'static str {
473 Self::IDENTIFIER
474 }
475}
476#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
477#[serde(untagged)]
478pub enum UnsubscribeParameters {
479 UnsubscribeByAttributesRequest(UnsubscribeByAttributesRequest),
480 UnsubscribeByIdRequest(UnsubscribeByIdRequest),
481}
482impl From<UnsubscribeByAttributesRequest> for UnsubscribeParameters {
483 fn from(v: UnsubscribeByAttributesRequest) -> Self {
484 UnsubscribeParameters::UnsubscribeByAttributesRequest(v)
485 }
486}
487impl TryFrom<UnsubscribeParameters> for UnsubscribeByAttributesRequest {
488 type Error = UnsubscribeParameters;
489 fn try_from(e: UnsubscribeParameters) -> Result<Self, Self::Error> {
490 match e {
491 UnsubscribeParameters::UnsubscribeByAttributesRequest(inner) => Ok(inner),
492 other => Err(other),
493 }
494 }
495}
496impl From<UnsubscribeByIdRequest> for UnsubscribeParameters {
497 fn from(v: UnsubscribeByIdRequest) -> Self {
498 UnsubscribeParameters::UnsubscribeByIdRequest(v)
499 }
500}
501impl TryFrom<UnsubscribeParameters> for UnsubscribeByIdRequest {
502 type Error = UnsubscribeParameters;
503 fn try_from(e: UnsubscribeParameters) -> Result<Self, Self::Error> {
504 match e {
505 UnsubscribeParameters::UnsubscribeByIdRequest(inner) => Ok(inner),
506 other => Err(other),
507 }
508 }
509}
510#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
511pub struct NewResultCapabilities {
512 #[serde(rename = "acceptInsecureCerts")]
513 pub accept_insecure_certs: bool,
514 #[serde(rename = "browserName")]
515 pub browser_name: String,
516 #[serde(rename = "browserVersion")]
517 pub browser_version: String,
518 #[serde(rename = "platformName")]
519 pub platform_name: String,
520 #[serde(rename = "setWindowRect")]
521 pub set_window_rect: bool,
522 #[serde(rename = "userAgent")]
523 #[serde(skip_serializing_if = "Option::is_none")]
524 #[serde(default)]
525 pub user_agent: Option<String>,
526 #[serde(rename = "proxy")]
527 #[serde(skip_serializing_if = "Option::is_none")]
528 #[serde(default)]
529 pub proxy: Option<ProxyConfiguration>,
530 #[serde(rename = "unhandledPromptBehavior")]
531 #[serde(skip_serializing_if = "Option::is_none")]
532 #[serde(default)]
533 pub unhandled_prompt_behavior: Option<UnhandledPromptBehavior>,
534 #[serde(rename = "webSocketUrl")]
535 #[serde(skip_serializing_if = "Option::is_none")]
536 #[serde(default)]
537 pub web_socket_url: Option<String>,
538 #[serde(flatten)]
539 #[serde(default)]
540 pub extensible: std::collections::HashMap<String, serde_json::Value>,
541}
542impl NewResultCapabilities {
543 pub const IDENTIFIER: &'static str = "";
544 pub fn identifier(&self) -> &'static str {
545 Self::IDENTIFIER
546 }
547}
548#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
549#[serde(untagged)]
550pub enum UnhandledPromptBehavior {
551 UserPromptHandler(UserPromptHandler),
552 UserPromptHandlerType(UserPromptHandlerType),
553}
554impl From<UserPromptHandler> for UnhandledPromptBehavior {
555 fn from(v: UserPromptHandler) -> Self {
556 UnhandledPromptBehavior::UserPromptHandler(v)
557 }
558}
559impl TryFrom<UnhandledPromptBehavior> for UserPromptHandler {
560 type Error = UnhandledPromptBehavior;
561 fn try_from(e: UnhandledPromptBehavior) -> Result<Self, Self::Error> {
562 match e {
563 UnhandledPromptBehavior::UserPromptHandler(inner) => Ok(inner),
564 other => Err(other),
565 }
566 }
567}
568impl From<UserPromptHandlerType> for UnhandledPromptBehavior {
569 fn from(v: UserPromptHandlerType) -> Self {
570 UnhandledPromptBehavior::UserPromptHandlerType(v)
571 }
572}
573impl TryFrom<UnhandledPromptBehavior> for UserPromptHandlerType {
574 type Error = UnhandledPromptBehavior;
575 fn try_from(e: UnhandledPromptBehavior) -> Result<Self, Self::Error> {
576 match e {
577 UnhandledPromptBehavior::UserPromptHandlerType(inner) => Ok(inner),
578 other => Err(other),
579 }
580 }
581}