1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
///命令 marker、完整参数与成功响应。
pub mod commands;
///事件 marker 和拥有型事件参数。
pub mod events;
///命名协议类型;不包含连接状态。
pub mod types;
///薄 Domain 视图,仅借用 Session;创建不发送数据。协议来源:Fetch。
///
///协议原文:
///
///<pre>A domain for letting clients substitute browser's network layer with client code.</pre>
///
///
pub struct Domain<'a> {
///借用的通信路由,生命周期不超过 Session。
pub(super) session: &'a ydp_core::Session,
}
impl<'a> Domain<'a> {
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.continueRequest。
///
///协议原文:
///
///<pre>Continues the request, optionally modifying some of its parameters.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::ContinueRequestParams) -> ydp_core::Result<()> {
///let response = session.fetch().continue_request(params).await?;
///# Ok(())
///# }
///```
pub fn continue_request(
&self,
params: commands::ContinueRequestParams,
) -> ydp_core::Request<commands::ContinueRequest> {
self.session.send::<commands::ContinueRequest>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.continueResponse。
///
///协议原文:
///
///<pre>Continues loading of the paused response, optionally modifying the
///response headers. If either responseCode or headers are modified, all of them
///must be present.</pre>
///
///此项为 experimental,端点可能不支持。
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::ContinueResponseParams) -> ydp_core::Result<()> {
///let response = session.fetch().continue_response(params).await?;
///# Ok(())
///# }
///```
pub fn continue_response(
&self,
params: commands::ContinueResponseParams,
) -> ydp_core::Request<commands::ContinueResponse> {
self.session.send::<commands::ContinueResponse>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.continueWithAuth。
///
///协议原文:
///
///<pre>Continues a request supplying authChallengeResponse following authRequired event.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::ContinueWithAuthParams) -> ydp_core::Result<()> {
///let response = session.fetch().continue_with_auth(params).await?;
///# Ok(())
///# }
///```
pub fn continue_with_auth(
&self,
params: commands::ContinueWithAuthParams,
) -> ydp_core::Request<commands::ContinueWithAuth> {
self.session.send::<commands::ContinueWithAuth>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.disable。
///
///协议原文:
///
///<pre>Disables the fetch domain.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::DisableParams) -> ydp_core::Result<()> {
///let response = session.fetch().disable(params).await?;
///# Ok(())
///# }
///```
pub fn disable(&self, params: commands::DisableParams) -> ydp_core::Request<commands::Disable> {
self.session.send::<commands::Disable>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.enable。
///
///协议原文:
///
///<pre>Enables issuing of requestPaused events. A request will be paused until client
///calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::EnableParams) -> ydp_core::Result<()> {
///let response = session.fetch().enable(params).await?;
///# Ok(())
///# }
///```
pub fn enable(&self, params: commands::EnableParams) -> ydp_core::Request<commands::Enable> {
self.session.send::<commands::Enable>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.failRequest。
///
///协议原文:
///
///<pre>Causes the request to fail with specified reason.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::FailRequestParams) -> ydp_core::Result<()> {
///let response = session.fetch().fail_request(params).await?;
///# Ok(())
///# }
///```
pub fn fail_request(
&self,
params: commands::FailRequestParams,
) -> ydp_core::Request<commands::FailRequest> {
self.session.send::<commands::FailRequest>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.fulfillRequest。
///
///协议原文:
///
///<pre>Provides response to the request.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::FulfillRequestParams) -> ydp_core::Result<()> {
///let response = session.fetch().fulfill_request(params).await?;
///# Ok(())
///# }
///```
pub fn fulfill_request(
&self,
params: commands::FulfillRequestParams,
) -> ydp_core::Request<commands::FulfillRequest> {
self.session.send::<commands::FulfillRequest>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.getResponseBody。
///
///协议原文:
///
///<pre>Causes the body of the response to be received from the server and
///returned as a single string. May only be issued for a request that
///is paused in the Response stage and is mutually exclusive with
///takeResponseBodyForInterceptionAsStream. Calling other methods that
///affect the request or disabling fetch domain before body is received
///results in an undefined behavior.
///Note that the response body is not available for redirects. Requests
///paused in the _redirect received_ state may be differentiated by
///`responseCode` and presence of `location` response header, see
///comments to `requestPaused` for details.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::GetResponseBodyParams) -> ydp_core::Result<()> {
///let response = session.fetch().get_response_body(params).await?;
///# Ok(())
///# }
///```
pub fn get_response_body(
&self,
params: commands::GetResponseBodyParams,
) -> ydp_core::Request<commands::GetResponseBody> {
self.session.send::<commands::GetResponseBody>(params)
}
///拥有参数并返回冷 Request;首次 poll 才提交,Drop 仅结束本地等待,发布后远端可能继续执行。协议来源:Fetch.command.takeResponseBodyAsStream。
///
///协议原文:
///
///<pre>Returns a handle to the stream representing the response body.
///The request must be paused in the HeadersReceived stage.
///Note that after this command the request can't be continued
///as is -- client either needs to cancel it or to provide the
///response body.
///The stream only supports sequential read, IO.read will fail if the position
///is specified.
///This method is mutually exclusive with getResponseBody.
///Calling other methods that affect the request or disabling fetch
///domain before body is received results in an undefined behavior.</pre>
///
///
///
///```no_run
///use ydp::SessionDomains as _;
///# async fn call(session: &ydp_core::Session, params: ydp::fetch::commands::TakeResponseBodyAsStreamParams) -> ydp_core::Result<()> {
///let response = session.fetch().take_response_body_as_stream(params).await?;
///# Ok(())
///# }
///```
pub fn take_response_body_as_stream(
&self,
params: commands::TakeResponseBodyAsStreamParams,
) -> ydp_core::Request<commands::TakeResponseBodyAsStream> {
self.session
.send::<commands::TakeResponseBodyAsStream>(params)
}
}