Skip to main content

cdp_driver/protocol/
cast.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! A domain for interacting with Cast, Presentation API, and Remote Playback
5//! API functionalities.
6//!
7//! Types, command parameters and event payloads for the `Cast`
8//! domain. The method-name constants for the same domain are in
9//! [`crate::methods`].
10//!
11//! This domain is experimental and may change without notice.
12
13use serde::{Deserialize, Serialize};
14
15#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
16pub struct Sink {
17    pub name: String,
18    pub id: String,
19    /// Text describing the current session. Present only if there is an active
20    /// session on the sink.
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub session: Option<String>,
23}
24
25/// Starts observing for sinks that can be used for tab mirroring, and if set,
26/// sinks compatible with |presentationUrl| as well. When sinks are found, a
27/// |sinksUpdated| event is fired. Also starts observing for issue messages.
28/// When an issue is added or removed, an |issueUpdated| event is fired.
29///
30/// Parameters of `Cast.enable`.
31#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
32pub struct EnableParams {
33    #[serde(
34        rename = "presentationUrl",
35        default,
36        skip_serializing_if = "Option::is_none"
37    )]
38    pub presentation_url: Option<String>,
39}
40
41impl crate::typed::Command for EnableParams {
42    const METHOD: &'static str = "Cast.enable";
43    type Returns = crate::typed::NoReturns;
44}
45
46/// Stops observing for sinks and issues.
47///
48/// Parameters of `Cast.disable`.
49#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
50pub struct DisableParams {}
51
52impl crate::typed::Command for DisableParams {
53    const METHOD: &'static str = "Cast.disable";
54    type Returns = crate::typed::NoReturns;
55}
56
57/// Sets a sink to be used when the web page requests the browser to choose a
58/// sink via Presentation API, Remote Playback API, or Cast SDK.
59///
60/// Parameters of `Cast.setSinkToUse`.
61#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
62pub struct SetSinkToUseParams {
63    #[serde(rename = "sinkName")]
64    pub sink_name: String,
65}
66
67impl crate::typed::Command for SetSinkToUseParams {
68    const METHOD: &'static str = "Cast.setSinkToUse";
69    type Returns = crate::typed::NoReturns;
70}
71
72/// Starts mirroring the desktop to the sink.
73///
74/// Parameters of `Cast.startDesktopMirroring`.
75#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
76pub struct StartDesktopMirroringParams {
77    #[serde(rename = "sinkName")]
78    pub sink_name: String,
79}
80
81impl crate::typed::Command for StartDesktopMirroringParams {
82    const METHOD: &'static str = "Cast.startDesktopMirroring";
83    type Returns = crate::typed::NoReturns;
84}
85
86/// Starts mirroring the tab to the sink.
87///
88/// Parameters of `Cast.startTabMirroring`.
89#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
90pub struct StartTabMirroringParams {
91    #[serde(rename = "sinkName")]
92    pub sink_name: String,
93}
94
95impl crate::typed::Command for StartTabMirroringParams {
96    const METHOD: &'static str = "Cast.startTabMirroring";
97    type Returns = crate::typed::NoReturns;
98}
99
100/// Stops the active Cast session on the sink.
101///
102/// Parameters of `Cast.stopCasting`.
103#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
104pub struct StopCastingParams {
105    #[serde(rename = "sinkName")]
106    pub sink_name: String,
107}
108
109impl crate::typed::Command for StopCastingParams {
110    const METHOD: &'static str = "Cast.stopCasting";
111    type Returns = crate::typed::NoReturns;
112}
113
114/// This is fired whenever the list of available sinks changes. A sink is a
115/// device or a software surface that you can cast to.
116///
117/// Payload of the `Cast.sinksUpdated` event.
118#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
119pub struct SinksUpdatedEvent {
120    pub sinks: Vec<Sink>,
121}
122
123impl crate::typed::Event for SinksUpdatedEvent {
124    const METHOD: &'static str = "Cast.sinksUpdated";
125}
126
127/// This is fired whenever the outstanding issue/error message changes.
128/// |issueMessage| is empty if there is no issue.
129///
130/// Payload of the `Cast.issueUpdated` event.
131#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
132pub struct IssueUpdatedEvent {
133    #[serde(rename = "issueMessage")]
134    pub issue_message: String,
135}
136
137impl crate::typed::Event for IssueUpdatedEvent {
138    const METHOD: &'static str = "Cast.issueUpdated";
139}