cdp_driver/protocol/io.rs
1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! Input/Output operations for streams produced by DevTools.
5//!
6//! Types, command parameters and event payloads for the `IO`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// This is either obtained from another method or specified as
13/// `blob:\<uuid\>` where `\<uuid\>` is an UUID of a Blob.
14pub type StreamHandle = String;
15
16/// Close the stream, discard any temporary backing storage.
17///
18/// Parameters of `IO.close`.
19#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
20pub struct CloseParams {
21 /// Handle of the stream to close.
22 pub handle: StreamHandle,
23}
24
25impl crate::typed::Command for CloseParams {
26 const METHOD: &'static str = "IO.close";
27 type Returns = crate::typed::NoReturns;
28}
29
30/// Read a chunk of the stream
31///
32/// Parameters of `IO.read`.
33#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
34pub struct ReadParams {
35 /// Handle of the stream to read.
36 pub handle: StreamHandle,
37 /// Seek to the specified offset before reading (if not specified, proceed
38 /// with offset following the last read). Some types of streams may only
39 /// support sequential reads.
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub offset: Option<i64>,
42 /// Maximum number of bytes to read (left upon the agent discretion if not
43 /// specified).
44 #[serde(default, skip_serializing_if = "Option::is_none")]
45 pub size: Option<i64>,
46}
47
48/// What `IO.read` answers with.
49#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
50pub struct ReadReturns {
51 /// Set if the data is base64-encoded
52 #[serde(
53 rename = "base64Encoded",
54 default,
55 skip_serializing_if = "Option::is_none"
56 )]
57 pub base64_encoded: Option<bool>,
58 /// Data that were read.
59 pub data: String,
60 /// Set if the end-of-file condition occurred while reading.
61 pub eof: bool,
62}
63
64impl crate::typed::Command for ReadParams {
65 const METHOD: &'static str = "IO.read";
66 type Returns = ReadReturns;
67}
68
69/// Return UUID of Blob object specified by a remote object id.
70///
71/// Deprecated in the protocol.
72///
73/// Parameters of `IO.resolveBlob`.
74#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
75pub struct ResolveBlobParams {
76 /// Object id of a Blob object wrapper.
77 #[serde(rename = "objectId")]
78 pub object_id: crate::protocol::runtime::RemoteObjectId,
79}
80
81/// What `IO.resolveBlob` answers with.
82#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
83pub struct ResolveBlobReturns {
84 /// UUID of the specified Blob.
85 pub uuid: String,
86}
87
88impl crate::typed::Command for ResolveBlobParams {
89 const METHOD: &'static str = "IO.resolveBlob";
90 type Returns = ResolveBlobReturns;
91}