fidl_fuchsia_net_policy_testing/
fidl_fuchsia_net_policy_testing.rs1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_policy_testing__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct FakeSocketProxy_Marker;
16
17impl fidl::endpoints::ProtocolMarker for FakeSocketProxy_Marker {
18 type Proxy = FakeSocketProxy_Proxy;
19 type RequestStream = FakeSocketProxy_RequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = FakeSocketProxy_SynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.net.policy.testing.FakeSocketProxy";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for FakeSocketProxy_Marker {}
26
27pub trait FakeSocketProxy_ProxyInterface: Send + Sync {
28 type UpdateDefaultNetworkResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
29 + Send;
30 fn r#update_default_network(
31 &self,
32 update: &fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
33 ) -> Self::UpdateDefaultNetworkResponseFut;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct FakeSocketProxy_SynchronousProxy {
38 client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for FakeSocketProxy_SynchronousProxy {
43 type Proxy = FakeSocketProxy_Proxy;
44 type Protocol = FakeSocketProxy_Marker;
45
46 fn from_channel(inner: fidl::Channel) -> Self {
47 Self::new(inner)
48 }
49
50 fn into_channel(self) -> fidl::Channel {
51 self.client.into_channel()
52 }
53
54 fn as_channel(&self) -> &fidl::Channel {
55 self.client.as_channel()
56 }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl FakeSocketProxy_SynchronousProxy {
61 pub fn new(channel: fidl::Channel) -> Self {
62 let protocol_name = <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64 }
65
66 pub fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 pub fn wait_for_event(
73 &self,
74 deadline: zx::MonotonicInstant,
75 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
76 FakeSocketProxy_Event::decode(self.client.wait_for_event(deadline)?)
77 }
78
79 pub fn r#update_default_network(
80 &self,
81 mut update: &fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
82 ___deadline: zx::MonotonicInstant,
83 ) -> Result<(), fidl::Error> {
84 let _response = self
85 .client
86 .send_query::<FakeSocketProxyUpdateDefaultNetworkRequest, fidl::encoding::EmptyPayload>(
87 (update,),
88 0x5cc5f84f1d4ef11b,
89 fidl::encoding::DynamicFlags::empty(),
90 ___deadline,
91 )?;
92 Ok(_response)
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl From<FakeSocketProxy_SynchronousProxy> for zx::Handle {
98 fn from(value: FakeSocketProxy_SynchronousProxy) -> Self {
99 value.into_channel().into()
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<fidl::Channel> for FakeSocketProxy_SynchronousProxy {
105 fn from(value: fidl::Channel) -> Self {
106 Self::new(value)
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl fidl::endpoints::FromClient for FakeSocketProxy_SynchronousProxy {
112 type Protocol = FakeSocketProxy_Marker;
113
114 fn from_client(value: fidl::endpoints::ClientEnd<FakeSocketProxy_Marker>) -> Self {
115 Self::new(value.into_channel())
116 }
117}
118
119#[derive(Debug, Clone)]
120pub struct FakeSocketProxy_Proxy {
121 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
122}
123
124impl fidl::endpoints::Proxy for FakeSocketProxy_Proxy {
125 type Protocol = FakeSocketProxy_Marker;
126
127 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
128 Self::new(inner)
129 }
130
131 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
132 self.client.into_channel().map_err(|client| Self { client })
133 }
134
135 fn as_channel(&self) -> &::fidl::AsyncChannel {
136 self.client.as_channel()
137 }
138}
139
140impl FakeSocketProxy_Proxy {
141 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
143 let protocol_name = <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144 Self { client: fidl::client::Client::new(channel, protocol_name) }
145 }
146
147 pub fn take_event_stream(&self) -> FakeSocketProxy_EventStream {
153 FakeSocketProxy_EventStream { event_receiver: self.client.take_event_receiver() }
154 }
155
156 pub fn r#update_default_network(
157 &self,
158 mut update: &fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
159 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
160 FakeSocketProxy_ProxyInterface::r#update_default_network(self, update)
161 }
162}
163
164impl FakeSocketProxy_ProxyInterface for FakeSocketProxy_Proxy {
165 type UpdateDefaultNetworkResponseFut =
166 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
167 fn r#update_default_network(
168 &self,
169 mut update: &fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
170 ) -> Self::UpdateDefaultNetworkResponseFut {
171 fn _decode(
172 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
173 ) -> Result<(), fidl::Error> {
174 let _response = fidl::client::decode_transaction_body::<
175 fidl::encoding::EmptyPayload,
176 fidl::encoding::DefaultFuchsiaResourceDialect,
177 0x5cc5f84f1d4ef11b,
178 >(_buf?)?;
179 Ok(_response)
180 }
181 self.client.send_query_and_decode::<FakeSocketProxyUpdateDefaultNetworkRequest, ()>(
182 (update,),
183 0x5cc5f84f1d4ef11b,
184 fidl::encoding::DynamicFlags::empty(),
185 _decode,
186 )
187 }
188}
189
190pub struct FakeSocketProxy_EventStream {
191 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
192}
193
194impl std::marker::Unpin for FakeSocketProxy_EventStream {}
195
196impl futures::stream::FusedStream for FakeSocketProxy_EventStream {
197 fn is_terminated(&self) -> bool {
198 self.event_receiver.is_terminated()
199 }
200}
201
202impl futures::Stream for FakeSocketProxy_EventStream {
203 type Item = Result<FakeSocketProxy_Event, fidl::Error>;
204
205 fn poll_next(
206 mut self: std::pin::Pin<&mut Self>,
207 cx: &mut std::task::Context<'_>,
208 ) -> std::task::Poll<Option<Self::Item>> {
209 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
210 &mut self.event_receiver,
211 cx
212 )?) {
213 Some(buf) => std::task::Poll::Ready(Some(FakeSocketProxy_Event::decode(buf))),
214 None => std::task::Poll::Ready(None),
215 }
216 }
217}
218
219#[derive(Debug)]
220pub enum FakeSocketProxy_Event {}
221
222impl FakeSocketProxy_Event {
223 fn decode(
225 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
226 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
227 let (bytes, _handles) = buf.split_mut();
228 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
229 debug_assert_eq!(tx_header.tx_id, 0);
230 match tx_header.ordinal {
231 _ => Err(fidl::Error::UnknownOrdinal {
232 ordinal: tx_header.ordinal,
233 protocol_name:
234 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
235 }),
236 }
237 }
238}
239
240pub struct FakeSocketProxy_RequestStream {
242 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
243 is_terminated: bool,
244}
245
246impl std::marker::Unpin for FakeSocketProxy_RequestStream {}
247
248impl futures::stream::FusedStream for FakeSocketProxy_RequestStream {
249 fn is_terminated(&self) -> bool {
250 self.is_terminated
251 }
252}
253
254impl fidl::endpoints::RequestStream for FakeSocketProxy_RequestStream {
255 type Protocol = FakeSocketProxy_Marker;
256 type ControlHandle = FakeSocketProxy_ControlHandle;
257
258 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
259 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
260 }
261
262 fn control_handle(&self) -> Self::ControlHandle {
263 FakeSocketProxy_ControlHandle { inner: self.inner.clone() }
264 }
265
266 fn into_inner(
267 self,
268 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
269 {
270 (self.inner, self.is_terminated)
271 }
272
273 fn from_inner(
274 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
275 is_terminated: bool,
276 ) -> Self {
277 Self { inner, is_terminated }
278 }
279}
280
281impl futures::Stream for FakeSocketProxy_RequestStream {
282 type Item = Result<FakeSocketProxy_Request, fidl::Error>;
283
284 fn poll_next(
285 mut self: std::pin::Pin<&mut Self>,
286 cx: &mut std::task::Context<'_>,
287 ) -> std::task::Poll<Option<Self::Item>> {
288 let this = &mut *self;
289 if this.inner.check_shutdown(cx) {
290 this.is_terminated = true;
291 return std::task::Poll::Ready(None);
292 }
293 if this.is_terminated {
294 panic!("polled FakeSocketProxy_RequestStream after completion");
295 }
296 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
297 |bytes, handles| {
298 match this.inner.channel().read_etc(cx, bytes, handles) {
299 std::task::Poll::Ready(Ok(())) => {}
300 std::task::Poll::Pending => return std::task::Poll::Pending,
301 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
302 this.is_terminated = true;
303 return std::task::Poll::Ready(None);
304 }
305 std::task::Poll::Ready(Err(e)) => {
306 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
307 e.into(),
308 ))));
309 }
310 }
311
312 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
314
315 std::task::Poll::Ready(Some(match header.ordinal {
316 0x5cc5f84f1d4ef11b => {
317 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
318 let mut req = fidl::new_empty!(
319 FakeSocketProxyUpdateDefaultNetworkRequest,
320 fidl::encoding::DefaultFuchsiaResourceDialect
321 );
322 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeSocketProxyUpdateDefaultNetworkRequest>(&header, _body_bytes, handles, &mut req)?;
323 let control_handle =
324 FakeSocketProxy_ControlHandle { inner: this.inner.clone() };
325 Ok(FakeSocketProxy_Request::UpdateDefaultNetwork {
326 update: req.update,
327
328 responder: FakeSocketProxy_UpdateDefaultNetworkResponder {
329 control_handle: std::mem::ManuallyDrop::new(control_handle),
330 tx_id: header.tx_id,
331 },
332 })
333 }
334 _ => Err(fidl::Error::UnknownOrdinal {
335 ordinal: header.ordinal,
336 protocol_name:
337 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
338 }),
339 }))
340 },
341 )
342 }
343}
344
345#[derive(Debug)]
346pub enum FakeSocketProxy_Request {
347 UpdateDefaultNetwork {
348 update: fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
349 responder: FakeSocketProxy_UpdateDefaultNetworkResponder,
350 },
351}
352
353impl FakeSocketProxy_Request {
354 #[allow(irrefutable_let_patterns)]
355 pub fn into_update_default_network(
356 self,
357 ) -> Option<(
358 fidl_fuchsia_net_policy_properties::DefaultNetworkUpdate,
359 FakeSocketProxy_UpdateDefaultNetworkResponder,
360 )> {
361 if let FakeSocketProxy_Request::UpdateDefaultNetwork { update, responder } = self {
362 Some((update, responder))
363 } else {
364 None
365 }
366 }
367
368 pub fn method_name(&self) -> &'static str {
370 match *self {
371 FakeSocketProxy_Request::UpdateDefaultNetwork { .. } => "update_default_network",
372 }
373 }
374}
375
376#[derive(Debug, Clone)]
377pub struct FakeSocketProxy_ControlHandle {
378 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
379}
380
381impl fidl::endpoints::ControlHandle for FakeSocketProxy_ControlHandle {
382 fn shutdown(&self) {
383 self.inner.shutdown()
384 }
385 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
386 self.inner.shutdown_with_epitaph(status)
387 }
388
389 fn is_closed(&self) -> bool {
390 self.inner.channel().is_closed()
391 }
392 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
393 self.inner.channel().on_closed()
394 }
395
396 #[cfg(target_os = "fuchsia")]
397 fn signal_peer(
398 &self,
399 clear_mask: zx::Signals,
400 set_mask: zx::Signals,
401 ) -> Result<(), zx_status::Status> {
402 use fidl::Peered;
403 self.inner.channel().signal_peer(clear_mask, set_mask)
404 }
405}
406
407impl FakeSocketProxy_ControlHandle {}
408
409#[must_use = "FIDL methods require a response to be sent"]
410#[derive(Debug)]
411pub struct FakeSocketProxy_UpdateDefaultNetworkResponder {
412 control_handle: std::mem::ManuallyDrop<FakeSocketProxy_ControlHandle>,
413 tx_id: u32,
414}
415
416impl std::ops::Drop for FakeSocketProxy_UpdateDefaultNetworkResponder {
420 fn drop(&mut self) {
421 self.control_handle.shutdown();
422 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
424 }
425}
426
427impl fidl::endpoints::Responder for FakeSocketProxy_UpdateDefaultNetworkResponder {
428 type ControlHandle = FakeSocketProxy_ControlHandle;
429
430 fn control_handle(&self) -> &FakeSocketProxy_ControlHandle {
431 &self.control_handle
432 }
433
434 fn drop_without_shutdown(mut self) {
435 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
437 std::mem::forget(self);
439 }
440}
441
442impl FakeSocketProxy_UpdateDefaultNetworkResponder {
443 pub fn send(self) -> Result<(), fidl::Error> {
447 let _result = self.send_raw();
448 if _result.is_err() {
449 self.control_handle.shutdown();
450 }
451 self.drop_without_shutdown();
452 _result
453 }
454
455 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
457 let _result = self.send_raw();
458 self.drop_without_shutdown();
459 _result
460 }
461
462 fn send_raw(&self) -> Result<(), fidl::Error> {
463 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
464 (),
465 self.tx_id,
466 0x5cc5f84f1d4ef11b,
467 fidl::encoding::DynamicFlags::empty(),
468 )
469 }
470}
471
472mod internal {
473 use super::*;
474}