rustenium_cdp_definitions/browser_protocol/io/
commands.rs1use serde::{Deserialize, Serialize};
2#[doc = "Close the stream, discard any temporary backing storage.\n[close](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-close)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct CloseParams {
5 #[doc = "Handle of the stream to close."]
6 #[serde(rename = "handle")]
7 pub handle: super::types::StreamHandle,
8}
9impl CloseParams {
10 pub fn new(handle: impl Into<super::types::StreamHandle>) -> Self {
11 Self {
12 handle: handle.into(),
13 }
14 }
15}
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
17pub enum CloseMethod {
18 #[serde(rename = "IO.close")]
19 Close,
20}
21#[doc = "Close the stream, discard any temporary backing storage.\n[close](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-close)"]
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
23pub struct Close {
24 pub method: CloseMethod,
25 pub params: CloseParams,
26}
27impl Close {
28 pub const IDENTIFIER: &'static str = "IO.close";
29 pub fn identifier(&self) -> &'static str {
30 Self::IDENTIFIER
31 }
32}
33impl crate::CommandResult for Close {
34 type Result = super::results::CloseResult;
35}
36#[doc = "Read a chunk of the stream\n[read](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-read)"]
37#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
38pub struct ReadParams {
39 #[doc = "Handle of the stream to read."]
40 #[serde(rename = "handle")]
41 pub handle: super::types::StreamHandle,
42 #[doc = "Seek to the specified offset before reading (if not specified, proceed with offset\nfollowing the last read). Some types of streams may only support sequential reads."]
43 #[serde(rename = "offset")]
44 #[serde(skip_serializing_if = "Option::is_none")]
45 #[serde(default)]
46 pub offset: Option<i64>,
47 #[doc = "Maximum number of bytes to read (left upon the agent discretion if not specified)."]
48 #[serde(rename = "size")]
49 #[serde(skip_serializing_if = "Option::is_none")]
50 #[serde(default)]
51 pub size: Option<i64>,
52}
53impl ReadParams {
54 pub fn new(handle: impl Into<super::types::StreamHandle>) -> Self {
55 Self {
56 handle: handle.into(),
57 offset: None,
58 size: None,
59 }
60 }
61}
62#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
63pub enum ReadMethod {
64 #[serde(rename = "IO.read")]
65 Read,
66}
67#[doc = "Read a chunk of the stream\n[read](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-read)"]
68#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
69pub struct Read {
70 pub method: ReadMethod,
71 pub params: ReadParams,
72}
73impl Read {
74 pub const IDENTIFIER: &'static str = "IO.read";
75 pub fn identifier(&self) -> &'static str {
76 Self::IDENTIFIER
77 }
78}
79impl crate::CommandResult for Read {
80 type Result = super::results::ReadResult;
81}
82#[doc = "Return UUID of Blob object specified by a remote object id.\n[resolveBlob](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-resolveBlob)"]
83#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
84pub struct ResolveBlobParams {
85 #[doc = "Object id of a Blob object wrapper."]
86 #[serde(rename = "objectId")]
87 pub object_id: crate::js_protocol::runtime::types::RemoteObjectId,
88}
89impl ResolveBlobParams {
90 pub fn new(object_id: impl Into<crate::js_protocol::runtime::types::RemoteObjectId>) -> Self {
91 Self {
92 object_id: object_id.into(),
93 }
94 }
95}
96#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
97pub enum ResolveBlobMethod {
98 #[serde(rename = "IO.resolveBlob")]
99 ResolveBlob,
100}
101#[doc = "Return UUID of Blob object specified by a remote object id.\n[resolveBlob](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-resolveBlob)"]
102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
103pub struct ResolveBlob {
104 pub method: ResolveBlobMethod,
105 pub params: ResolveBlobParams,
106}
107impl ResolveBlob {
108 pub const IDENTIFIER: &'static str = "IO.resolveBlob";
109 pub fn identifier(&self) -> &'static str {
110 Self::IDENTIFIER
111 }
112}
113impl crate::CommandResult for ResolveBlob {
114 type Result = super::results::ResolveBlobResult;
115}
116group_enum ! (IoCommands { Close (Close) , Read (Read) , ResolveBlob (ResolveBlob) } + identifiable);