cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! A domain for interacting with Cast, Presentation API, and Remote Playback
//! API functionalities.
//!
//! Types, command parameters and event payloads for the `Cast`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Sink {
    pub name: String,
    pub id: String,
    /// Text describing the current session. Present only if there is an active
    /// session on the sink.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub session: Option<String>,
}

/// Starts observing for sinks that can be used for tab mirroring, and if set,
/// sinks compatible with |presentationUrl| as well. When sinks are found, a
/// |sinksUpdated| event is fired. Also starts observing for issue messages.
/// When an issue is added or removed, an |issueUpdated| event is fired.
///
/// Parameters of `Cast.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {
    #[serde(
        rename = "presentationUrl",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub presentation_url: Option<String>,
}

impl crate::typed::Command for EnableParams {
    const METHOD: &'static str = "Cast.enable";
    type Returns = crate::typed::NoReturns;
}

/// Stops observing for sinks and issues.
///
/// Parameters of `Cast.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

impl crate::typed::Command for DisableParams {
    const METHOD: &'static str = "Cast.disable";
    type Returns = crate::typed::NoReturns;
}

/// Sets a sink to be used when the web page requests the browser to choose a
/// sink via Presentation API, Remote Playback API, or Cast SDK.
///
/// Parameters of `Cast.setSinkToUse`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetSinkToUseParams {
    #[serde(rename = "sinkName")]
    pub sink_name: String,
}

impl crate::typed::Command for SetSinkToUseParams {
    const METHOD: &'static str = "Cast.setSinkToUse";
    type Returns = crate::typed::NoReturns;
}

/// Starts mirroring the desktop to the sink.
///
/// Parameters of `Cast.startDesktopMirroring`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StartDesktopMirroringParams {
    #[serde(rename = "sinkName")]
    pub sink_name: String,
}

impl crate::typed::Command for StartDesktopMirroringParams {
    const METHOD: &'static str = "Cast.startDesktopMirroring";
    type Returns = crate::typed::NoReturns;
}

/// Starts mirroring the tab to the sink.
///
/// Parameters of `Cast.startTabMirroring`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StartTabMirroringParams {
    #[serde(rename = "sinkName")]
    pub sink_name: String,
}

impl crate::typed::Command for StartTabMirroringParams {
    const METHOD: &'static str = "Cast.startTabMirroring";
    type Returns = crate::typed::NoReturns;
}

/// Stops the active Cast session on the sink.
///
/// Parameters of `Cast.stopCasting`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StopCastingParams {
    #[serde(rename = "sinkName")]
    pub sink_name: String,
}

impl crate::typed::Command for StopCastingParams {
    const METHOD: &'static str = "Cast.stopCasting";
    type Returns = crate::typed::NoReturns;
}

/// This is fired whenever the list of available sinks changes. A sink is a
/// device or a software surface that you can cast to.
///
/// Payload of the `Cast.sinksUpdated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SinksUpdatedEvent {
    pub sinks: Vec<Sink>,
}

impl crate::typed::Event for SinksUpdatedEvent {
    const METHOD: &'static str = "Cast.sinksUpdated";
}

/// This is fired whenever the outstanding issue/error message changes.
/// |issueMessage| is empty if there is no issue.
///
/// Payload of the `Cast.issueUpdated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct IssueUpdatedEvent {
    #[serde(rename = "issueMessage")]
    pub issue_message: String,
}

impl crate::typed::Event for IssueUpdatedEvent {
    const METHOD: &'static str = "Cast.issueUpdated";
}