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.

//! Provides access to log entries.
//!
//! Types, command parameters and event payloads for the `Log`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].

use serde::{Deserialize, Serialize};

/// Log entry.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LogEntry {
    /// Log entry source.
    pub source: LogEntrySource,
    /// Log entry severity.
    pub level: LogEntryLevel,
    /// Logged text.
    pub text: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub category: Option<LogEntryCategory>,
    /// Timestamp when this entry was added.
    pub timestamp: crate::protocol::runtime::Timestamp,
    /// URL of the resource if known.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// Line number in the resource.
    #[serde(
        rename = "lineNumber",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub line_number: Option<i64>,
    /// JavaScript stack trace.
    #[serde(
        rename = "stackTrace",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stack_trace: Option<crate::protocol::runtime::StackTrace>,
    /// Identifier of the network request associated with this entry.
    #[serde(
        rename = "networkRequestId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub network_request_id: Option<crate::protocol::network::RequestId>,
    /// Identifier of the worker associated with this entry.
    #[serde(rename = "workerId", default, skip_serializing_if = "Option::is_none")]
    pub worker_id: Option<String>,
    /// Call arguments.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub args: Option<Vec<crate::protocol::runtime::RemoteObject>>,
}

/// The values `source` accepts on `LogEntry`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum LogEntrySource {
    /// `xml`
    #[serde(rename = "xml")]
    Xml,
    /// `javascript`
    #[serde(rename = "javascript")]
    Javascript,
    /// `network`
    #[serde(rename = "network")]
    Network,
    /// `storage`
    #[serde(rename = "storage")]
    Storage,
    /// `appcache`
    #[serde(rename = "appcache")]
    Appcache,
    /// `rendering`
    #[serde(rename = "rendering")]
    Rendering,
    /// `security`
    #[serde(rename = "security")]
    Security,
    /// `deprecation`
    #[serde(rename = "deprecation")]
    Deprecation,
    /// `worker`
    #[serde(rename = "worker")]
    Worker,
    /// `violation`
    #[serde(rename = "violation")]
    Violation,
    /// `intervention`
    #[serde(rename = "intervention")]
    Intervention,
    /// `recommendation`
    #[serde(rename = "recommendation")]
    Recommendation,
    /// `other`
    #[serde(rename = "other")]
    Other,
    /// 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 `LogEntry`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum LogEntryLevel {
    /// `verbose`
    #[serde(rename = "verbose")]
    Verbose,
    /// `info`
    #[serde(rename = "info")]
    Info,
    /// `warning`
    #[serde(rename = "warning")]
    Warning,
    /// `error`
    #[serde(rename = "error")]
    Error,
    /// 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 `category` accepts on `LogEntry`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum LogEntryCategory {
    /// `cors`
    #[serde(rename = "cors")]
    Cors,
    /// 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),
}

/// Violation configuration setting.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ViolationSetting {
    /// Violation type.
    pub name: ViolationSettingName,
    /// Time threshold to trigger upon.
    pub threshold: f64,
}

/// The values `name` accepts on `ViolationSetting`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ViolationSettingName {
    /// `longTask`
    #[serde(rename = "longTask")]
    LongTask,
    /// `longLayout`
    #[serde(rename = "longLayout")]
    LongLayout,
    /// `blockedEvent`
    #[serde(rename = "blockedEvent")]
    BlockedEvent,
    /// `blockedParser`
    #[serde(rename = "blockedParser")]
    BlockedParser,
    /// `discouragedAPIUse`
    #[serde(rename = "discouragedAPIUse")]
    DiscouragedApiUse,
    /// `handler`
    #[serde(rename = "handler")]
    Handler,
    /// `recurringHandler`
    #[serde(rename = "recurringHandler")]
    RecurringHandler,
    /// 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),
}

/// Clears the log.
///
/// Parameters of `Log.clear`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ClearParams {}

impl crate::typed::Command for ClearParams {
    const METHOD: &'static str = "Log.clear";
    type Returns = crate::typed::NoReturns;
}

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

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

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

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

/// start violation reporting.
///
/// Parameters of `Log.startViolationsReport`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StartViolationsReportParams {
    /// Configuration for violations.
    pub config: Vec<ViolationSetting>,
}

impl crate::typed::Command for StartViolationsReportParams {
    const METHOD: &'static str = "Log.startViolationsReport";
    type Returns = crate::typed::NoReturns;
}

/// Stop violation reporting.
///
/// Parameters of `Log.stopViolationsReport`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct StopViolationsReportParams {}

impl crate::typed::Command for StopViolationsReportParams {
    const METHOD: &'static str = "Log.stopViolationsReport";
    type Returns = crate::typed::NoReturns;
}

/// Issued when new message was logged.
///
/// Payload of the `Log.entryAdded` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EntryAddedEvent {
    /// The entry.
    pub entry: LogEntry,
}

impl crate::typed::Event for EntryAddedEvent {
    const METHOD: &'static str = "Log.entryAdded";
}