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