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