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.

//! This domain is deprecated - use Runtime or Log instead.
//!
//! Types, command parameters and event payloads for the `Console`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is deprecated in the protocol.

use serde::{Deserialize, Serialize};

/// Console message.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConsoleMessage {
    /// Message source.
    pub source: ConsoleMessageSource,
    /// Message severity.
    pub level: ConsoleMessageLevel,
    /// Message text.
    pub text: String,
    /// URL of the message origin.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// Line number in the resource that generated this message (1-based).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub line: Option<i64>,
    /// Column number in the resource that generated this message (1-based).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
}

/// The values `source` accepts on `ConsoleMessage`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConsoleMessageSource {
    /// `xml`
    #[serde(rename = "xml")]
    Xml,
    /// `javascript`
    #[serde(rename = "javascript")]
    Javascript,
    /// `network`
    #[serde(rename = "network")]
    Network,
    /// `console-api`
    #[serde(rename = "console-api")]
    ConsoleApi,
    /// `storage`
    #[serde(rename = "storage")]
    Storage,
    /// `appcache`
    #[serde(rename = "appcache")]
    Appcache,
    /// `rendering`
    #[serde(rename = "rendering")]
    Rendering,
    /// `security`
    #[serde(rename = "security")]
    Security,
    /// `other`
    #[serde(rename = "other")]
    Other,
    /// `deprecation`
    #[serde(rename = "deprecation")]
    Deprecation,
    /// `worker`
    #[serde(rename = "worker")]
    Worker,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// The values `level` accepts on `ConsoleMessage`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConsoleMessageLevel {
    /// `log`
    #[serde(rename = "log")]
    Log,
    /// `warning`
    #[serde(rename = "warning")]
    Warning,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// `debug`
    #[serde(rename = "debug")]
    Debug,
    /// `info`
    #[serde(rename = "info")]
    Info,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Does nothing.
///
/// Parameters of `Console.clearMessages`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ClearMessagesParams {}

impl crate::typed::Command for ClearMessagesParams {
    const METHOD: &'static str = "Console.clearMessages";
    type Returns = crate::typed::NoReturns;
}

/// Disables console domain, prevents further console messages from being
/// reported to the client.
///
/// Parameters of `Console.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

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

/// Enables console domain, sends the messages collected so far to the client
/// by means of the `messageAdded` notification.
///
/// Parameters of `Console.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

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

/// Issued when new console message is added.
///
/// Payload of the `Console.messageAdded` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MessageAddedEvent {
    /// Console message that has been added.
    pub message: ConsoleMessage,
}

impl crate::typed::Event for MessageAddedEvent {
    const METHOD: &'static str = "Console.messageAdded";
}