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.

//! Input/Output operations for streams produced by DevTools.
//!
//! Types, command parameters and event payloads for the `IO`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].

use serde::{Deserialize, Serialize};

/// This is either obtained from another method or specified as
/// `blob:\<uuid\>` where `\<uuid\>` is an UUID of a Blob.
pub type StreamHandle = String;

/// Close the stream, discard any temporary backing storage.
///
/// Parameters of `IO.close`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CloseParams {
    /// Handle of the stream to close.
    pub handle: StreamHandle,
}

impl crate::typed::Command for CloseParams {
    const METHOD: &'static str = "IO.close";
    type Returns = crate::typed::NoReturns;
}

/// Read a chunk of the stream
///
/// Parameters of `IO.read`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReadParams {
    /// Handle of the stream to read.
    pub handle: StreamHandle,
    /// Seek to the specified offset before reading (if not specified, proceed
    /// with offset following the last read). Some types of streams may only
    /// support sequential reads.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub offset: Option<i64>,
    /// Maximum number of bytes to read (left upon the agent discretion if not
    /// specified).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
}

/// What `IO.read` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ReadReturns {
    /// Set if the data is base64-encoded
    #[serde(
        rename = "base64Encoded",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub base64_encoded: Option<bool>,
    /// Data that were read.
    pub data: String,
    /// Set if the end-of-file condition occurred while reading.
    pub eof: bool,
}

impl crate::typed::Command for ReadParams {
    const METHOD: &'static str = "IO.read";
    type Returns = ReadReturns;
}

/// Return UUID of Blob object specified by a remote object id.
///
/// Deprecated in the protocol.
///
/// Parameters of `IO.resolveBlob`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ResolveBlobParams {
    /// Object id of a Blob object wrapper.
    #[serde(rename = "objectId")]
    pub object_id: crate::protocol::runtime::RemoteObjectId,
}

/// What `IO.resolveBlob` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ResolveBlobReturns {
    /// UUID of the specified Blob.
    pub uuid: String,
}

impl crate::typed::Command for ResolveBlobParams {
    const METHOD: &'static str = "IO.resolveBlob";
    type Returns = ResolveBlobReturns;
}