1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Core traits and marker types for BiDi commands and events.
//!
//! Every typed command implements [`BidiCommand`], pairing the request
//! type with its response type and the wire method name. Every typed
//! event implements [`BidiEvent`].
//!
//! Implement these traits for any command or event not in the curated
//! set under [`crate::bidi::modules`] — the framework picks them up
//! automatically via [`BiDi::send`](crate::bidi::BiDi::send) and
//! [`BiDi::subscribe`](crate::bidi::BiDi::subscribe). There is no
//! second-class API.
use ;
/// A typed BiDi command.
///
/// `Self` is the request `params` type (must be [`Serialize`]).
/// [`Returns`](BidiCommand::Returns) is the deserialised `result` type
/// returned by [`BiDi::send`](crate::bidi::BiDi::send).
/// [`METHOD`](BidiCommand::METHOD) is the spec-defined wire name
/// (e.g. `"browsingContext.navigate"`).
///
/// # Example
///
/// ```
/// use serde::{Deserialize, Serialize};
/// use thirtyfour::bidi::BidiCommand;
///
/// #[derive(Serialize)]
/// struct NavigateParams {
/// context: String,
/// url: String,
/// }
///
/// #[derive(Deserialize)]
/// struct NavigateResult {
/// navigation: Option<String>,
/// url: String,
/// }
///
/// impl BidiCommand for NavigateParams {
/// const METHOD: &'static str = "browsingContext.navigate";
/// type Returns = NavigateResult;
/// }
/// ```
/// A typed BiDi event.
///
/// Implementations are deserialised into the `Self` type and delivered
/// through [`BiDi::subscribe::<E>()`](crate::bidi::BiDi::subscribe).
/// `METHOD` is the spec-defined wire name
/// (e.g. `"browsingContext.load"`).
/// Marker type for BiDi commands whose response body is the empty
/// object `{}`.
///
/// Many commands (`session.subscribe`, `browsingContext.close`,
/// `script.removePreloadScript`, every `emulation.*` setter, …)
/// return `{}` on success. Implement [`BidiCommand`] with
/// `type Returns = Empty;` to model that.
///
/// `Empty` is `Deserialize` with `deny_unknown_fields`, so a non-empty
/// response body would be a deserialise error — useful as a defensive
/// check that the spec hasn't started returning meaningful data.
/// A raw event delivered by
/// [`BiDi::subscribe_raw`](crate::bidi::BiDi::subscribe_raw).
///
/// No filtering or deserialisation is performed — every event the
/// driver pushes is surfaced as-is. Useful for debugging, dump
/// recording, or implementing a typed event that hasn't been added to
/// the curated set yet.