Skip to main content

browser_protocol/io/
mod.rs

1//! Input/Output operations for streams produced by DevTools.
2
3use serde::{Serialize, Deserialize};
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
20/// Read a chunk of the stream
21
22#[derive(Debug, Clone, Serialize, Deserialize, Default)]
23#[serde(rename_all = "camelCase")]
24pub struct ReadParams {
25    /// Handle of the stream to read.
26
27    pub handle: StreamHandle,
28    /// Seek to the specified offset before reading (if not specified, proceed with offset
29    /// following the last read). Some types of streams may only support sequential reads.
30
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub offset: Option<i32>,
33    /// Maximum number of bytes to read (left upon the agent discretion if not specified).
34
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub size: Option<u64>,
37}
38
39/// Read a chunk of the stream
40
41#[derive(Debug, Clone, Serialize, Deserialize, Default)]
42#[serde(rename_all = "camelCase")]
43pub struct ReadReturns {
44    /// Set if the data is base64-encoded
45
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub base64Encoded: Option<bool>,
48    /// Data that were read.
49
50    pub data: String,
51    /// Set if the end-of-file condition occurred while reading.
52
53    pub eof: bool,
54}
55
56/// Return UUID of Blob object specified by a remote object id.
57
58#[derive(Debug, Clone, Serialize, Deserialize, Default)]
59#[serde(rename_all = "camelCase")]
60pub struct ResolveBlobParams {
61    /// Object id of a Blob object wrapper.
62
63    pub objectId: crate::runtime::RemoteObjectId,
64}
65
66/// Return UUID of Blob object specified by a remote object id.
67
68#[derive(Debug, Clone, Serialize, Deserialize, Default)]
69#[serde(rename_all = "camelCase")]
70pub struct ResolveBlobReturns {
71    /// UUID of the specified Blob.
72
73    pub uuid: String,
74}