1#![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_testing_proxy_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct TcpProxyControlOpenProxyRequest {
16 pub target_port: u16,
17 pub proxy_port: u16,
18 pub tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22 for TcpProxyControlOpenProxyRequest
23{
24}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct TcpProxy_Marker;
28
29impl fidl::endpoints::ProtocolMarker for TcpProxy_Marker {
30 type Proxy = TcpProxy_Proxy;
31 type RequestStream = TcpProxy_RequestStream;
32 #[cfg(target_os = "fuchsia")]
33 type SynchronousProxy = TcpProxy_SynchronousProxy;
34
35 const DEBUG_NAME: &'static str = "(anonymous) TcpProxy_";
36}
37
38pub trait TcpProxy_ProxyInterface: Send + Sync {}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct TcpProxy_SynchronousProxy {
42 client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for TcpProxy_SynchronousProxy {
47 type Proxy = TcpProxy_Proxy;
48 type Protocol = TcpProxy_Marker;
49
50 fn from_channel(inner: fidl::Channel) -> Self {
51 Self::new(inner)
52 }
53
54 fn into_channel(self) -> fidl::Channel {
55 self.client.into_channel()
56 }
57
58 fn as_channel(&self) -> &fidl::Channel {
59 self.client.as_channel()
60 }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl TcpProxy_SynchronousProxy {
65 pub fn new(channel: fidl::Channel) -> Self {
66 let protocol_name = <TcpProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
67 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<TcpProxy_Event, fidl::Error> {
80 TcpProxy_Event::decode(self.client.wait_for_event(deadline)?)
81 }
82}
83
84#[cfg(target_os = "fuchsia")]
85impl From<TcpProxy_SynchronousProxy> for zx::Handle {
86 fn from(value: TcpProxy_SynchronousProxy) -> Self {
87 value.into_channel().into()
88 }
89}
90
91#[cfg(target_os = "fuchsia")]
92impl From<fidl::Channel> for TcpProxy_SynchronousProxy {
93 fn from(value: fidl::Channel) -> Self {
94 Self::new(value)
95 }
96}
97
98#[derive(Debug, Clone)]
99pub struct TcpProxy_Proxy {
100 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
101}
102
103impl fidl::endpoints::Proxy for TcpProxy_Proxy {
104 type Protocol = TcpProxy_Marker;
105
106 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
107 Self::new(inner)
108 }
109
110 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
111 self.client.into_channel().map_err(|client| Self { client })
112 }
113
114 fn as_channel(&self) -> &::fidl::AsyncChannel {
115 self.client.as_channel()
116 }
117}
118
119impl TcpProxy_Proxy {
120 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
122 let protocol_name = <TcpProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
123 Self { client: fidl::client::Client::new(channel, protocol_name) }
124 }
125
126 pub fn take_event_stream(&self) -> TcpProxy_EventStream {
132 TcpProxy_EventStream { event_receiver: self.client.take_event_receiver() }
133 }
134}
135
136impl TcpProxy_ProxyInterface for TcpProxy_Proxy {}
137
138pub struct TcpProxy_EventStream {
139 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
140}
141
142impl std::marker::Unpin for TcpProxy_EventStream {}
143
144impl futures::stream::FusedStream for TcpProxy_EventStream {
145 fn is_terminated(&self) -> bool {
146 self.event_receiver.is_terminated()
147 }
148}
149
150impl futures::Stream for TcpProxy_EventStream {
151 type Item = Result<TcpProxy_Event, fidl::Error>;
152
153 fn poll_next(
154 mut self: std::pin::Pin<&mut Self>,
155 cx: &mut std::task::Context<'_>,
156 ) -> std::task::Poll<Option<Self::Item>> {
157 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
158 &mut self.event_receiver,
159 cx
160 )?) {
161 Some(buf) => std::task::Poll::Ready(Some(TcpProxy_Event::decode(buf))),
162 None => std::task::Poll::Ready(None),
163 }
164 }
165}
166
167#[derive(Debug)]
168pub enum TcpProxy_Event {}
169
170impl TcpProxy_Event {
171 fn decode(
173 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
174 ) -> Result<TcpProxy_Event, fidl::Error> {
175 let (bytes, _handles) = buf.split_mut();
176 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
177 debug_assert_eq!(tx_header.tx_id, 0);
178 match tx_header.ordinal {
179 _ => Err(fidl::Error::UnknownOrdinal {
180 ordinal: tx_header.ordinal,
181 protocol_name: <TcpProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
182 }),
183 }
184 }
185}
186
187pub struct TcpProxy_RequestStream {
189 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
190 is_terminated: bool,
191}
192
193impl std::marker::Unpin for TcpProxy_RequestStream {}
194
195impl futures::stream::FusedStream for TcpProxy_RequestStream {
196 fn is_terminated(&self) -> bool {
197 self.is_terminated
198 }
199}
200
201impl fidl::endpoints::RequestStream for TcpProxy_RequestStream {
202 type Protocol = TcpProxy_Marker;
203 type ControlHandle = TcpProxy_ControlHandle;
204
205 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
206 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
207 }
208
209 fn control_handle(&self) -> Self::ControlHandle {
210 TcpProxy_ControlHandle { inner: self.inner.clone() }
211 }
212
213 fn into_inner(
214 self,
215 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
216 {
217 (self.inner, self.is_terminated)
218 }
219
220 fn from_inner(
221 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
222 is_terminated: bool,
223 ) -> Self {
224 Self { inner, is_terminated }
225 }
226}
227
228impl futures::Stream for TcpProxy_RequestStream {
229 type Item = Result<TcpProxy_Request, fidl::Error>;
230
231 fn poll_next(
232 mut self: std::pin::Pin<&mut Self>,
233 cx: &mut std::task::Context<'_>,
234 ) -> std::task::Poll<Option<Self::Item>> {
235 let this = &mut *self;
236 if this.inner.check_shutdown(cx) {
237 this.is_terminated = true;
238 return std::task::Poll::Ready(None);
239 }
240 if this.is_terminated {
241 panic!("polled TcpProxy_RequestStream after completion");
242 }
243 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
244 |bytes, handles| {
245 match this.inner.channel().read_etc(cx, bytes, handles) {
246 std::task::Poll::Ready(Ok(())) => {}
247 std::task::Poll::Pending => return std::task::Poll::Pending,
248 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
249 this.is_terminated = true;
250 return std::task::Poll::Ready(None);
251 }
252 std::task::Poll::Ready(Err(e)) => {
253 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
254 e.into(),
255 ))))
256 }
257 }
258
259 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
261
262 std::task::Poll::Ready(Some(match header.ordinal {
263 _ => Err(fidl::Error::UnknownOrdinal {
264 ordinal: header.ordinal,
265 protocol_name:
266 <TcpProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
267 }),
268 }))
269 },
270 )
271 }
272}
273
274#[derive(Debug)]
279pub enum TcpProxy_Request {}
280
281impl TcpProxy_Request {
282 pub fn method_name(&self) -> &'static str {
284 match *self {}
285 }
286}
287
288#[derive(Debug, Clone)]
289pub struct TcpProxy_ControlHandle {
290 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
291}
292
293impl fidl::endpoints::ControlHandle for TcpProxy_ControlHandle {
294 fn shutdown(&self) {
295 self.inner.shutdown()
296 }
297 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
298 self.inner.shutdown_with_epitaph(status)
299 }
300
301 fn is_closed(&self) -> bool {
302 self.inner.channel().is_closed()
303 }
304 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
305 self.inner.channel().on_closed()
306 }
307
308 #[cfg(target_os = "fuchsia")]
309 fn signal_peer(
310 &self,
311 clear_mask: zx::Signals,
312 set_mask: zx::Signals,
313 ) -> Result<(), zx_status::Status> {
314 use fidl::Peered;
315 self.inner.channel().signal_peer(clear_mask, set_mask)
316 }
317}
318
319impl TcpProxy_ControlHandle {}
320
321#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
322pub struct TcpProxyControlMarker;
323
324impl fidl::endpoints::ProtocolMarker for TcpProxyControlMarker {
325 type Proxy = TcpProxyControlProxy;
326 type RequestStream = TcpProxyControlRequestStream;
327 #[cfg(target_os = "fuchsia")]
328 type SynchronousProxy = TcpProxyControlSynchronousProxy;
329
330 const DEBUG_NAME: &'static str = "fuchsia.testing.proxy.TcpProxyControl";
331}
332impl fidl::endpoints::DiscoverableProtocolMarker for TcpProxyControlMarker {}
333
334pub trait TcpProxyControlProxyInterface: Send + Sync {
335 type OpenProxy_ResponseFut: std::future::Future<Output = Result<u16, fidl::Error>> + Send;
336 fn r#open_proxy_(
337 &self,
338 target_port: u16,
339 proxy_port: u16,
340 tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
341 ) -> Self::OpenProxy_ResponseFut;
342}
343#[derive(Debug)]
344#[cfg(target_os = "fuchsia")]
345pub struct TcpProxyControlSynchronousProxy {
346 client: fidl::client::sync::Client,
347}
348
349#[cfg(target_os = "fuchsia")]
350impl fidl::endpoints::SynchronousProxy for TcpProxyControlSynchronousProxy {
351 type Proxy = TcpProxyControlProxy;
352 type Protocol = TcpProxyControlMarker;
353
354 fn from_channel(inner: fidl::Channel) -> Self {
355 Self::new(inner)
356 }
357
358 fn into_channel(self) -> fidl::Channel {
359 self.client.into_channel()
360 }
361
362 fn as_channel(&self) -> &fidl::Channel {
363 self.client.as_channel()
364 }
365}
366
367#[cfg(target_os = "fuchsia")]
368impl TcpProxyControlSynchronousProxy {
369 pub fn new(channel: fidl::Channel) -> Self {
370 let protocol_name = <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
371 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
372 }
373
374 pub fn into_channel(self) -> fidl::Channel {
375 self.client.into_channel()
376 }
377
378 pub fn wait_for_event(
381 &self,
382 deadline: zx::MonotonicInstant,
383 ) -> Result<TcpProxyControlEvent, fidl::Error> {
384 TcpProxyControlEvent::decode(self.client.wait_for_event(deadline)?)
385 }
386
387 pub fn r#open_proxy_(
397 &self,
398 mut target_port: u16,
399 mut proxy_port: u16,
400 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
401 ___deadline: zx::MonotonicInstant,
402 ) -> Result<u16, fidl::Error> {
403 let _response = self
404 .client
405 .send_query::<TcpProxyControlOpenProxyRequest, TcpProxyControlOpenProxyResponse>(
406 (target_port, proxy_port, tcp_proxy),
407 0x6e2c348c371061e2,
408 fidl::encoding::DynamicFlags::empty(),
409 ___deadline,
410 )?;
411 Ok(_response.open_port)
412 }
413}
414
415#[cfg(target_os = "fuchsia")]
416impl From<TcpProxyControlSynchronousProxy> for zx::Handle {
417 fn from(value: TcpProxyControlSynchronousProxy) -> Self {
418 value.into_channel().into()
419 }
420}
421
422#[cfg(target_os = "fuchsia")]
423impl From<fidl::Channel> for TcpProxyControlSynchronousProxy {
424 fn from(value: fidl::Channel) -> Self {
425 Self::new(value)
426 }
427}
428
429#[derive(Debug, Clone)]
430pub struct TcpProxyControlProxy {
431 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
432}
433
434impl fidl::endpoints::Proxy for TcpProxyControlProxy {
435 type Protocol = TcpProxyControlMarker;
436
437 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
438 Self::new(inner)
439 }
440
441 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
442 self.client.into_channel().map_err(|client| Self { client })
443 }
444
445 fn as_channel(&self) -> &::fidl::AsyncChannel {
446 self.client.as_channel()
447 }
448}
449
450impl TcpProxyControlProxy {
451 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
453 let protocol_name = <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
454 Self { client: fidl::client::Client::new(channel, protocol_name) }
455 }
456
457 pub fn take_event_stream(&self) -> TcpProxyControlEventStream {
463 TcpProxyControlEventStream { event_receiver: self.client.take_event_receiver() }
464 }
465
466 pub fn r#open_proxy_(
476 &self,
477 mut target_port: u16,
478 mut proxy_port: u16,
479 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
480 ) -> fidl::client::QueryResponseFut<u16, fidl::encoding::DefaultFuchsiaResourceDialect> {
481 TcpProxyControlProxyInterface::r#open_proxy_(self, target_port, proxy_port, tcp_proxy)
482 }
483}
484
485impl TcpProxyControlProxyInterface for TcpProxyControlProxy {
486 type OpenProxy_ResponseFut =
487 fidl::client::QueryResponseFut<u16, fidl::encoding::DefaultFuchsiaResourceDialect>;
488 fn r#open_proxy_(
489 &self,
490 mut target_port: u16,
491 mut proxy_port: u16,
492 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
493 ) -> Self::OpenProxy_ResponseFut {
494 fn _decode(
495 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
496 ) -> Result<u16, fidl::Error> {
497 let _response = fidl::client::decode_transaction_body::<
498 TcpProxyControlOpenProxyResponse,
499 fidl::encoding::DefaultFuchsiaResourceDialect,
500 0x6e2c348c371061e2,
501 >(_buf?)?;
502 Ok(_response.open_port)
503 }
504 self.client.send_query_and_decode::<TcpProxyControlOpenProxyRequest, u16>(
505 (target_port, proxy_port, tcp_proxy),
506 0x6e2c348c371061e2,
507 fidl::encoding::DynamicFlags::empty(),
508 _decode,
509 )
510 }
511}
512
513pub struct TcpProxyControlEventStream {
514 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
515}
516
517impl std::marker::Unpin for TcpProxyControlEventStream {}
518
519impl futures::stream::FusedStream for TcpProxyControlEventStream {
520 fn is_terminated(&self) -> bool {
521 self.event_receiver.is_terminated()
522 }
523}
524
525impl futures::Stream for TcpProxyControlEventStream {
526 type Item = Result<TcpProxyControlEvent, fidl::Error>;
527
528 fn poll_next(
529 mut self: std::pin::Pin<&mut Self>,
530 cx: &mut std::task::Context<'_>,
531 ) -> std::task::Poll<Option<Self::Item>> {
532 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
533 &mut self.event_receiver,
534 cx
535 )?) {
536 Some(buf) => std::task::Poll::Ready(Some(TcpProxyControlEvent::decode(buf))),
537 None => std::task::Poll::Ready(None),
538 }
539 }
540}
541
542#[derive(Debug)]
543pub enum TcpProxyControlEvent {}
544
545impl TcpProxyControlEvent {
546 fn decode(
548 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
549 ) -> Result<TcpProxyControlEvent, fidl::Error> {
550 let (bytes, _handles) = buf.split_mut();
551 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
552 debug_assert_eq!(tx_header.tx_id, 0);
553 match tx_header.ordinal {
554 _ => Err(fidl::Error::UnknownOrdinal {
555 ordinal: tx_header.ordinal,
556 protocol_name:
557 <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
558 }),
559 }
560 }
561}
562
563pub struct TcpProxyControlRequestStream {
565 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
566 is_terminated: bool,
567}
568
569impl std::marker::Unpin for TcpProxyControlRequestStream {}
570
571impl futures::stream::FusedStream for TcpProxyControlRequestStream {
572 fn is_terminated(&self) -> bool {
573 self.is_terminated
574 }
575}
576
577impl fidl::endpoints::RequestStream for TcpProxyControlRequestStream {
578 type Protocol = TcpProxyControlMarker;
579 type ControlHandle = TcpProxyControlControlHandle;
580
581 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
582 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
583 }
584
585 fn control_handle(&self) -> Self::ControlHandle {
586 TcpProxyControlControlHandle { inner: self.inner.clone() }
587 }
588
589 fn into_inner(
590 self,
591 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
592 {
593 (self.inner, self.is_terminated)
594 }
595
596 fn from_inner(
597 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
598 is_terminated: bool,
599 ) -> Self {
600 Self { inner, is_terminated }
601 }
602}
603
604impl futures::Stream for TcpProxyControlRequestStream {
605 type Item = Result<TcpProxyControlRequest, fidl::Error>;
606
607 fn poll_next(
608 mut self: std::pin::Pin<&mut Self>,
609 cx: &mut std::task::Context<'_>,
610 ) -> std::task::Poll<Option<Self::Item>> {
611 let this = &mut *self;
612 if this.inner.check_shutdown(cx) {
613 this.is_terminated = true;
614 return std::task::Poll::Ready(None);
615 }
616 if this.is_terminated {
617 panic!("polled TcpProxyControlRequestStream after completion");
618 }
619 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
620 |bytes, handles| {
621 match this.inner.channel().read_etc(cx, bytes, handles) {
622 std::task::Poll::Ready(Ok(())) => {}
623 std::task::Poll::Pending => return std::task::Poll::Pending,
624 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
625 this.is_terminated = true;
626 return std::task::Poll::Ready(None);
627 }
628 std::task::Poll::Ready(Err(e)) => {
629 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
630 e.into(),
631 ))))
632 }
633 }
634
635 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
637
638 std::task::Poll::Ready(Some(match header.ordinal {
639 0x6e2c348c371061e2 => {
640 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
641 let mut req = fidl::new_empty!(
642 TcpProxyControlOpenProxyRequest,
643 fidl::encoding::DefaultFuchsiaResourceDialect
644 );
645 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TcpProxyControlOpenProxyRequest>(&header, _body_bytes, handles, &mut req)?;
646 let control_handle =
647 TcpProxyControlControlHandle { inner: this.inner.clone() };
648 Ok(TcpProxyControlRequest::OpenProxy_ {
649 target_port: req.target_port,
650 proxy_port: req.proxy_port,
651 tcp_proxy: req.tcp_proxy,
652
653 responder: TcpProxyControlOpenProxy_Responder {
654 control_handle: std::mem::ManuallyDrop::new(control_handle),
655 tx_id: header.tx_id,
656 },
657 })
658 }
659 _ => Err(fidl::Error::UnknownOrdinal {
660 ordinal: header.ordinal,
661 protocol_name:
662 <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
663 }),
664 }))
665 },
666 )
667 }
668}
669
670#[derive(Debug)]
678pub enum TcpProxyControlRequest {
679 OpenProxy_ {
689 target_port: u16,
690 proxy_port: u16,
691 tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
692 responder: TcpProxyControlOpenProxy_Responder,
693 },
694}
695
696impl TcpProxyControlRequest {
697 #[allow(irrefutable_let_patterns)]
698 pub fn into_open_proxy_(
699 self,
700 ) -> Option<(
701 u16,
702 u16,
703 fidl::endpoints::ServerEnd<TcpProxy_Marker>,
704 TcpProxyControlOpenProxy_Responder,
705 )> {
706 if let TcpProxyControlRequest::OpenProxy_ {
707 target_port,
708 proxy_port,
709 tcp_proxy,
710 responder,
711 } = self
712 {
713 Some((target_port, proxy_port, tcp_proxy, responder))
714 } else {
715 None
716 }
717 }
718
719 pub fn method_name(&self) -> &'static str {
721 match *self {
722 TcpProxyControlRequest::OpenProxy_ { .. } => "open_proxy_",
723 }
724 }
725}
726
727#[derive(Debug, Clone)]
728pub struct TcpProxyControlControlHandle {
729 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
730}
731
732impl fidl::endpoints::ControlHandle for TcpProxyControlControlHandle {
733 fn shutdown(&self) {
734 self.inner.shutdown()
735 }
736 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
737 self.inner.shutdown_with_epitaph(status)
738 }
739
740 fn is_closed(&self) -> bool {
741 self.inner.channel().is_closed()
742 }
743 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
744 self.inner.channel().on_closed()
745 }
746
747 #[cfg(target_os = "fuchsia")]
748 fn signal_peer(
749 &self,
750 clear_mask: zx::Signals,
751 set_mask: zx::Signals,
752 ) -> Result<(), zx_status::Status> {
753 use fidl::Peered;
754 self.inner.channel().signal_peer(clear_mask, set_mask)
755 }
756}
757
758impl TcpProxyControlControlHandle {}
759
760#[must_use = "FIDL methods require a response to be sent"]
761#[derive(Debug)]
762pub struct TcpProxyControlOpenProxy_Responder {
763 control_handle: std::mem::ManuallyDrop<TcpProxyControlControlHandle>,
764 tx_id: u32,
765}
766
767impl std::ops::Drop for TcpProxyControlOpenProxy_Responder {
771 fn drop(&mut self) {
772 self.control_handle.shutdown();
773 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
775 }
776}
777
778impl fidl::endpoints::Responder for TcpProxyControlOpenProxy_Responder {
779 type ControlHandle = TcpProxyControlControlHandle;
780
781 fn control_handle(&self) -> &TcpProxyControlControlHandle {
782 &self.control_handle
783 }
784
785 fn drop_without_shutdown(mut self) {
786 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788 std::mem::forget(self);
790 }
791}
792
793impl TcpProxyControlOpenProxy_Responder {
794 pub fn send(self, mut open_port: u16) -> Result<(), fidl::Error> {
798 let _result = self.send_raw(open_port);
799 if _result.is_err() {
800 self.control_handle.shutdown();
801 }
802 self.drop_without_shutdown();
803 _result
804 }
805
806 pub fn send_no_shutdown_on_err(self, mut open_port: u16) -> Result<(), fidl::Error> {
808 let _result = self.send_raw(open_port);
809 self.drop_without_shutdown();
810 _result
811 }
812
813 fn send_raw(&self, mut open_port: u16) -> Result<(), fidl::Error> {
814 self.control_handle.inner.send::<TcpProxyControlOpenProxyResponse>(
815 (open_port,),
816 self.tx_id,
817 0x6e2c348c371061e2,
818 fidl::encoding::DynamicFlags::empty(),
819 )
820 }
821}
822
823mod internal {
824 use super::*;
825
826 impl fidl::encoding::ResourceTypeMarker for TcpProxyControlOpenProxyRequest {
827 type Borrowed<'a> = &'a mut Self;
828 fn take_or_borrow<'a>(
829 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
830 ) -> Self::Borrowed<'a> {
831 value
832 }
833 }
834
835 unsafe impl fidl::encoding::TypeMarker for TcpProxyControlOpenProxyRequest {
836 type Owned = Self;
837
838 #[inline(always)]
839 fn inline_align(_context: fidl::encoding::Context) -> usize {
840 4
841 }
842
843 #[inline(always)]
844 fn inline_size(_context: fidl::encoding::Context) -> usize {
845 8
846 }
847 }
848
849 unsafe impl
850 fidl::encoding::Encode<
851 TcpProxyControlOpenProxyRequest,
852 fidl::encoding::DefaultFuchsiaResourceDialect,
853 > for &mut TcpProxyControlOpenProxyRequest
854 {
855 #[inline]
856 unsafe fn encode(
857 self,
858 encoder: &mut fidl::encoding::Encoder<
859 '_,
860 fidl::encoding::DefaultFuchsiaResourceDialect,
861 >,
862 offset: usize,
863 _depth: fidl::encoding::Depth,
864 ) -> fidl::Result<()> {
865 encoder.debug_check_bounds::<TcpProxyControlOpenProxyRequest>(offset);
866 fidl::encoding::Encode::<TcpProxyControlOpenProxyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
868 (
869 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.target_port),
870 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.proxy_port),
871 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.tcp_proxy),
872 ),
873 encoder, offset, _depth
874 )
875 }
876 }
877 unsafe impl<
878 T0: fidl::encoding::Encode<u16, fidl::encoding::DefaultFuchsiaResourceDialect>,
879 T1: fidl::encoding::Encode<u16, fidl::encoding::DefaultFuchsiaResourceDialect>,
880 T2: fidl::encoding::Encode<
881 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
882 fidl::encoding::DefaultFuchsiaResourceDialect,
883 >,
884 >
885 fidl::encoding::Encode<
886 TcpProxyControlOpenProxyRequest,
887 fidl::encoding::DefaultFuchsiaResourceDialect,
888 > for (T0, T1, T2)
889 {
890 #[inline]
891 unsafe fn encode(
892 self,
893 encoder: &mut fidl::encoding::Encoder<
894 '_,
895 fidl::encoding::DefaultFuchsiaResourceDialect,
896 >,
897 offset: usize,
898 depth: fidl::encoding::Depth,
899 ) -> fidl::Result<()> {
900 encoder.debug_check_bounds::<TcpProxyControlOpenProxyRequest>(offset);
901 self.0.encode(encoder, offset + 0, depth)?;
905 self.1.encode(encoder, offset + 2, depth)?;
906 self.2.encode(encoder, offset + 4, depth)?;
907 Ok(())
908 }
909 }
910
911 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
912 for TcpProxyControlOpenProxyRequest
913 {
914 #[inline(always)]
915 fn new_empty() -> Self {
916 Self {
917 target_port: fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect),
918 proxy_port: fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect),
919 tcp_proxy: fidl::new_empty!(
920 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
921 fidl::encoding::DefaultFuchsiaResourceDialect
922 ),
923 }
924 }
925
926 #[inline]
927 unsafe fn decode(
928 &mut self,
929 decoder: &mut fidl::encoding::Decoder<
930 '_,
931 fidl::encoding::DefaultFuchsiaResourceDialect,
932 >,
933 offset: usize,
934 _depth: fidl::encoding::Depth,
935 ) -> fidl::Result<()> {
936 decoder.debug_check_bounds::<Self>(offset);
937 fidl::decode!(
939 u16,
940 fidl::encoding::DefaultFuchsiaResourceDialect,
941 &mut self.target_port,
942 decoder,
943 offset + 0,
944 _depth
945 )?;
946 fidl::decode!(
947 u16,
948 fidl::encoding::DefaultFuchsiaResourceDialect,
949 &mut self.proxy_port,
950 decoder,
951 offset + 2,
952 _depth
953 )?;
954 fidl::decode!(
955 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
956 fidl::encoding::DefaultFuchsiaResourceDialect,
957 &mut self.tcp_proxy,
958 decoder,
959 offset + 4,
960 _depth
961 )?;
962 Ok(())
963 }
964 }
965}