Skip to main content

browser_protocol/cast/
mod.rs

1//! A domain for interacting with Cast, Presentation API, and Remote Playback API
2//! functionalities.
3use serde::{Serialize, Deserialize};
4use serde_json::Value as JsonValue;
5
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct Sink {
10
11    pub name: String,
12
13    pub id: String,
14    /// Text describing the current session. Present only if there is an active
15    /// session on the sink.
16
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub session: Option<String>,
19}
20
21/// Starts observing for sinks that can be used for tab mirroring, and if set,
22/// sinks compatible with |presentationUrl| as well. When sinks are found, a
23/// |sinksUpdated| event is fired.
24/// Also starts observing for issue messages. When an issue is added or removed,
25/// an |issueUpdated| event is fired.
26
27#[derive(Debug, Clone, Serialize, Deserialize, Default)]
28#[serde(rename_all = "camelCase")]
29pub struct EnableParams {
30
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub presentationUrl: Option<String>,
33}
34
35impl EnableParams { pub const METHOD: &'static str = "Cast.enable"; }
36
37impl crate::CdpCommand for EnableParams {
38    const METHOD: &'static str = "Cast.enable";
39    type Response = crate::EmptyReturns;
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize, Default)]
43pub struct DisableParams {}
44
45impl DisableParams { pub const METHOD: &'static str = "Cast.disable"; }
46
47impl crate::CdpCommand for DisableParams {
48    const METHOD: &'static str = "Cast.disable";
49    type Response = crate::EmptyReturns;
50}
51
52/// Sets a sink to be used when the web page requests the browser to choose a
53/// sink via Presentation API, Remote Playback API, or Cast SDK.
54
55#[derive(Debug, Clone, Serialize, Deserialize, Default)]
56#[serde(rename_all = "camelCase")]
57pub struct SetSinkToUseParams {
58
59    pub sinkName: String,
60}
61
62impl SetSinkToUseParams { pub const METHOD: &'static str = "Cast.setSinkToUse"; }
63
64impl crate::CdpCommand for SetSinkToUseParams {
65    const METHOD: &'static str = "Cast.setSinkToUse";
66    type Response = crate::EmptyReturns;
67}
68
69/// Starts mirroring the desktop to the sink.
70
71#[derive(Debug, Clone, Serialize, Deserialize, Default)]
72#[serde(rename_all = "camelCase")]
73pub struct StartDesktopMirroringParams {
74
75    pub sinkName: String,
76}
77
78impl StartDesktopMirroringParams { pub const METHOD: &'static str = "Cast.startDesktopMirroring"; }
79
80impl crate::CdpCommand for StartDesktopMirroringParams {
81    const METHOD: &'static str = "Cast.startDesktopMirroring";
82    type Response = crate::EmptyReturns;
83}
84
85/// Starts mirroring the tab to the sink.
86
87#[derive(Debug, Clone, Serialize, Deserialize, Default)]
88#[serde(rename_all = "camelCase")]
89pub struct StartTabMirroringParams {
90
91    pub sinkName: String,
92}
93
94impl StartTabMirroringParams { pub const METHOD: &'static str = "Cast.startTabMirroring"; }
95
96impl crate::CdpCommand for StartTabMirroringParams {
97    const METHOD: &'static str = "Cast.startTabMirroring";
98    type Response = crate::EmptyReturns;
99}
100
101/// Stops the active Cast session on the sink.
102
103#[derive(Debug, Clone, Serialize, Deserialize, Default)]
104#[serde(rename_all = "camelCase")]
105pub struct StopCastingParams {
106
107    pub sinkName: String,
108}
109
110impl StopCastingParams { pub const METHOD: &'static str = "Cast.stopCasting"; }
111
112impl crate::CdpCommand for StopCastingParams {
113    const METHOD: &'static str = "Cast.stopCasting";
114    type Response = crate::EmptyReturns;
115}