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
//! Core traits that pair a CDP command's request type with its response
//! type, and an event type with its method name.
//!
//! Implement [`CdpCommand`] for any command not in the curated set under
//! [`crate::cdp::domains`]; the same `Cdp::send` and `CdpSession::send` paths
//! will pick it up. [`CdpEvent`] is the same idea for events delivered over
//! a WebSocket session.
use ;
/// A typed CDP command.
///
/// `Self` is the request params type (must be [`Serialize`]); [`Returns`] is
/// the response type returned by `Cdp::send` / `CdpSession::send`. `METHOD`
/// is the wire name, e.g. `"Page.navigate"`.
///
/// [`Returns`]: CdpCommand::Returns
///
/// # Example
/// ```
/// use serde::{Deserialize, Serialize};
/// use thirtyfour::cdp::CdpCommand;
///
/// #[derive(Serialize)]
/// struct GetTitleParams;
///
/// #[derive(Deserialize)]
/// struct GetTitleReturns {
/// title: String,
/// }
///
/// impl CdpCommand for GetTitleParams {
/// const METHOD: &'static str = "Page.getTitle";
/// type Returns = GetTitleReturns;
/// }
/// ```
/// A typed CDP event delivered over a [`CdpSession`].
///
/// CDP events only fire after the owning domain is enabled
/// (`Network.enable`, `Page.enable`, `Runtime.enable`, …). Implementors
/// should set [`Self::ENABLE`] to the wire method name of the relevant
/// `*.enable` command so that
/// [`CdpSession::subscribe`](crate::cdp::CdpSession::subscribe) can call
/// it idempotently the first time the domain is needed in a session.
/// Set to `None` for events whose domain has no `enable` command (e.g.
/// `Target.attachedToTarget` — the user must call
/// `Target.setDiscoverTargets` themselves).
///
/// [`CdpSession`]: crate::cdp::CdpSession
/// Marker type for CDP commands whose response body is `{}`.
///
/// Many commands (`Network.enable`, `Page.reload`,
/// `Emulation.clearDeviceMetricsOverride`, etc.) return an empty object
/// on success. Use this as the [`CdpCommand::Returns`] type for those.
/// A raw event delivered by [`crate::cdp::CdpSession::subscribe_all`].
// `CdpCommand` and `CdpEvent` are trait shells with no runtime behaviour;
// the only thing worth verifying is "does this command actually round-trip
// through a real browser", which is what the integration tests in
// `thirtyfour/tests/cdp_typed.rs` and `cdp_events.rs` cover.