Skip to main content

browser_protocol/io/
mod.rs

1//! Input/Output operations for streams produced by DevTools.
2use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5/// This is either obtained from another method or specified as 'blob:<uuid>' where
6/// '<uuid>' is an UUID of a Blob.
7
8pub type StreamHandle = String;
9
10/// Close the stream, discard any temporary backing storage.
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default)]
13#[serde(rename_all = "camelCase")]
14pub struct CloseParams {
15    /// Handle of the stream to close.
16
17    pub handle: StreamHandle,
18}
19
20impl CloseParams { pub const METHOD: &'static str = "IO.close"; }
21
22impl crate::CdpCommand for CloseParams {
23    const METHOD: &'static str = "IO.close";
24    type Response = crate::EmptyReturns;
25}
26
27/// Read a chunk of the stream
28
29#[derive(Debug, Clone, Serialize, Deserialize, Default)]
30#[serde(rename_all = "camelCase")]
31pub struct ReadParams {
32    /// Handle of the stream to read.
33
34    pub handle: StreamHandle,
35    /// Seek to the specified offset before reading (if not specified, proceed with offset
36    /// following the last read). Some types of streams may only support sequential reads.
37
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub offset: Option<i32>,
40    /// Maximum number of bytes to read (left upon the agent discretion if not specified).
41
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub size: Option<u64>,
44}
45
46/// Read a chunk of the stream
47
48#[derive(Debug, Clone, Serialize, Deserialize, Default)]
49#[serde(rename_all = "camelCase")]
50pub struct ReadReturns {
51    /// Set if the data is base64-encoded
52
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub base64Encoded: Option<bool>,
55    /// Data that were read.
56
57    pub data: String,
58    /// Set if the end-of-file condition occurred while reading.
59
60    pub eof: bool,
61}
62
63impl ReadParams { pub const METHOD: &'static str = "IO.read"; }
64
65impl crate::CdpCommand for ReadParams {
66    const METHOD: &'static str = "IO.read";
67    type Response = ReadReturns;
68}
69
70/// Return UUID of Blob object specified by a remote object id.
71
72#[derive(Debug, Clone, Serialize, Deserialize, Default)]
73#[serde(rename_all = "camelCase")]
74pub struct ResolveBlobParams {
75    /// Object id of a Blob object wrapper.
76
77    pub objectId: crate::runtime::RemoteObjectId,
78}
79
80/// Return UUID of Blob object specified by a remote object id.
81
82#[derive(Debug, Clone, Serialize, Deserialize, Default)]
83#[serde(rename_all = "camelCase")]
84pub struct ResolveBlobReturns {
85    /// UUID of the specified Blob.
86
87    pub uuid: String,
88}
89
90impl ResolveBlobParams { pub const METHOD: &'static str = "IO.resolveBlob"; }
91
92impl crate::CdpCommand for ResolveBlobParams {
93    const METHOD: &'static str = "IO.resolveBlob";
94    type Response = ResolveBlobReturns;
95}