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::NullableHandle {
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
307 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
308 self.inner.shutdown_with_epitaph(status)
309 }
310
311 fn is_closed(&self) -> bool {
312 self.inner.channel().is_closed()
313 }
314 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
315 self.inner.channel().on_closed()
316 }
317
318 #[cfg(target_os = "fuchsia")]
319 fn signal_peer(
320 &self,
321 clear_mask: zx::Signals,
322 set_mask: zx::Signals,
323 ) -> Result<(), zx_status::Status> {
324 use fidl::Peered;
325 self.inner.channel().signal_peer(clear_mask, set_mask)
326 }
327}
328
329impl TcpProxy_ControlHandle {}
330
331#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
332pub struct TcpProxyControlMarker;
333
334impl fidl::endpoints::ProtocolMarker for TcpProxyControlMarker {
335 type Proxy = TcpProxyControlProxy;
336 type RequestStream = TcpProxyControlRequestStream;
337 #[cfg(target_os = "fuchsia")]
338 type SynchronousProxy = TcpProxyControlSynchronousProxy;
339
340 const DEBUG_NAME: &'static str = "fuchsia.testing.proxy.TcpProxyControl";
341}
342impl fidl::endpoints::DiscoverableProtocolMarker for TcpProxyControlMarker {}
343
344pub trait TcpProxyControlProxyInterface: Send + Sync {
345 type OpenProxy_ResponseFut: std::future::Future<Output = Result<u16, fidl::Error>> + Send;
346 fn r#open_proxy_(
347 &self,
348 target_port: u16,
349 proxy_port: u16,
350 tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
351 ) -> Self::OpenProxy_ResponseFut;
352}
353#[derive(Debug)]
354#[cfg(target_os = "fuchsia")]
355pub struct TcpProxyControlSynchronousProxy {
356 client: fidl::client::sync::Client,
357}
358
359#[cfg(target_os = "fuchsia")]
360impl fidl::endpoints::SynchronousProxy for TcpProxyControlSynchronousProxy {
361 type Proxy = TcpProxyControlProxy;
362 type Protocol = TcpProxyControlMarker;
363
364 fn from_channel(inner: fidl::Channel) -> Self {
365 Self::new(inner)
366 }
367
368 fn into_channel(self) -> fidl::Channel {
369 self.client.into_channel()
370 }
371
372 fn as_channel(&self) -> &fidl::Channel {
373 self.client.as_channel()
374 }
375}
376
377#[cfg(target_os = "fuchsia")]
378impl TcpProxyControlSynchronousProxy {
379 pub fn new(channel: fidl::Channel) -> Self {
380 let protocol_name = <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
381 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
382 }
383
384 pub fn into_channel(self) -> fidl::Channel {
385 self.client.into_channel()
386 }
387
388 pub fn wait_for_event(
391 &self,
392 deadline: zx::MonotonicInstant,
393 ) -> Result<TcpProxyControlEvent, fidl::Error> {
394 TcpProxyControlEvent::decode(self.client.wait_for_event(deadline)?)
395 }
396
397 pub fn r#open_proxy_(
407 &self,
408 mut target_port: u16,
409 mut proxy_port: u16,
410 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
411 ___deadline: zx::MonotonicInstant,
412 ) -> Result<u16, fidl::Error> {
413 let _response = self
414 .client
415 .send_query::<TcpProxyControlOpenProxyRequest, TcpProxyControlOpenProxyResponse>(
416 (target_port, proxy_port, tcp_proxy),
417 0x6e2c348c371061e2,
418 fidl::encoding::DynamicFlags::empty(),
419 ___deadline,
420 )?;
421 Ok(_response.open_port)
422 }
423}
424
425#[cfg(target_os = "fuchsia")]
426impl From<TcpProxyControlSynchronousProxy> for zx::NullableHandle {
427 fn from(value: TcpProxyControlSynchronousProxy) -> Self {
428 value.into_channel().into()
429 }
430}
431
432#[cfg(target_os = "fuchsia")]
433impl From<fidl::Channel> for TcpProxyControlSynchronousProxy {
434 fn from(value: fidl::Channel) -> Self {
435 Self::new(value)
436 }
437}
438
439#[cfg(target_os = "fuchsia")]
440impl fidl::endpoints::FromClient for TcpProxyControlSynchronousProxy {
441 type Protocol = TcpProxyControlMarker;
442
443 fn from_client(value: fidl::endpoints::ClientEnd<TcpProxyControlMarker>) -> Self {
444 Self::new(value.into_channel())
445 }
446}
447
448#[derive(Debug, Clone)]
449pub struct TcpProxyControlProxy {
450 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
451}
452
453impl fidl::endpoints::Proxy for TcpProxyControlProxy {
454 type Protocol = TcpProxyControlMarker;
455
456 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
457 Self::new(inner)
458 }
459
460 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
461 self.client.into_channel().map_err(|client| Self { client })
462 }
463
464 fn as_channel(&self) -> &::fidl::AsyncChannel {
465 self.client.as_channel()
466 }
467}
468
469impl TcpProxyControlProxy {
470 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
472 let protocol_name = <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
473 Self { client: fidl::client::Client::new(channel, protocol_name) }
474 }
475
476 pub fn take_event_stream(&self) -> TcpProxyControlEventStream {
482 TcpProxyControlEventStream { event_receiver: self.client.take_event_receiver() }
483 }
484
485 pub fn r#open_proxy_(
495 &self,
496 mut target_port: u16,
497 mut proxy_port: u16,
498 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
499 ) -> fidl::client::QueryResponseFut<u16, fidl::encoding::DefaultFuchsiaResourceDialect> {
500 TcpProxyControlProxyInterface::r#open_proxy_(self, target_port, proxy_port, tcp_proxy)
501 }
502}
503
504impl TcpProxyControlProxyInterface for TcpProxyControlProxy {
505 type OpenProxy_ResponseFut =
506 fidl::client::QueryResponseFut<u16, fidl::encoding::DefaultFuchsiaResourceDialect>;
507 fn r#open_proxy_(
508 &self,
509 mut target_port: u16,
510 mut proxy_port: u16,
511 mut tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
512 ) -> Self::OpenProxy_ResponseFut {
513 fn _decode(
514 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
515 ) -> Result<u16, fidl::Error> {
516 let _response = fidl::client::decode_transaction_body::<
517 TcpProxyControlOpenProxyResponse,
518 fidl::encoding::DefaultFuchsiaResourceDialect,
519 0x6e2c348c371061e2,
520 >(_buf?)?;
521 Ok(_response.open_port)
522 }
523 self.client.send_query_and_decode::<TcpProxyControlOpenProxyRequest, u16>(
524 (target_port, proxy_port, tcp_proxy),
525 0x6e2c348c371061e2,
526 fidl::encoding::DynamicFlags::empty(),
527 _decode,
528 )
529 }
530}
531
532pub struct TcpProxyControlEventStream {
533 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
534}
535
536impl std::marker::Unpin for TcpProxyControlEventStream {}
537
538impl futures::stream::FusedStream for TcpProxyControlEventStream {
539 fn is_terminated(&self) -> bool {
540 self.event_receiver.is_terminated()
541 }
542}
543
544impl futures::Stream for TcpProxyControlEventStream {
545 type Item = Result<TcpProxyControlEvent, fidl::Error>;
546
547 fn poll_next(
548 mut self: std::pin::Pin<&mut Self>,
549 cx: &mut std::task::Context<'_>,
550 ) -> std::task::Poll<Option<Self::Item>> {
551 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
552 &mut self.event_receiver,
553 cx
554 )?) {
555 Some(buf) => std::task::Poll::Ready(Some(TcpProxyControlEvent::decode(buf))),
556 None => std::task::Poll::Ready(None),
557 }
558 }
559}
560
561#[derive(Debug)]
562pub enum TcpProxyControlEvent {}
563
564impl TcpProxyControlEvent {
565 fn decode(
567 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
568 ) -> Result<TcpProxyControlEvent, fidl::Error> {
569 let (bytes, _handles) = buf.split_mut();
570 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
571 debug_assert_eq!(tx_header.tx_id, 0);
572 match tx_header.ordinal {
573 _ => Err(fidl::Error::UnknownOrdinal {
574 ordinal: tx_header.ordinal,
575 protocol_name:
576 <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
577 }),
578 }
579 }
580}
581
582pub struct TcpProxyControlRequestStream {
584 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
585 is_terminated: bool,
586}
587
588impl std::marker::Unpin for TcpProxyControlRequestStream {}
589
590impl futures::stream::FusedStream for TcpProxyControlRequestStream {
591 fn is_terminated(&self) -> bool {
592 self.is_terminated
593 }
594}
595
596impl fidl::endpoints::RequestStream for TcpProxyControlRequestStream {
597 type Protocol = TcpProxyControlMarker;
598 type ControlHandle = TcpProxyControlControlHandle;
599
600 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
601 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
602 }
603
604 fn control_handle(&self) -> Self::ControlHandle {
605 TcpProxyControlControlHandle { inner: self.inner.clone() }
606 }
607
608 fn into_inner(
609 self,
610 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
611 {
612 (self.inner, self.is_terminated)
613 }
614
615 fn from_inner(
616 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
617 is_terminated: bool,
618 ) -> Self {
619 Self { inner, is_terminated }
620 }
621}
622
623impl futures::Stream for TcpProxyControlRequestStream {
624 type Item = Result<TcpProxyControlRequest, fidl::Error>;
625
626 fn poll_next(
627 mut self: std::pin::Pin<&mut Self>,
628 cx: &mut std::task::Context<'_>,
629 ) -> std::task::Poll<Option<Self::Item>> {
630 let this = &mut *self;
631 if this.inner.check_shutdown(cx) {
632 this.is_terminated = true;
633 return std::task::Poll::Ready(None);
634 }
635 if this.is_terminated {
636 panic!("polled TcpProxyControlRequestStream after completion");
637 }
638 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
639 |bytes, handles| {
640 match this.inner.channel().read_etc(cx, bytes, handles) {
641 std::task::Poll::Ready(Ok(())) => {}
642 std::task::Poll::Pending => return std::task::Poll::Pending,
643 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
644 this.is_terminated = true;
645 return std::task::Poll::Ready(None);
646 }
647 std::task::Poll::Ready(Err(e)) => {
648 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
649 e.into(),
650 ))));
651 }
652 }
653
654 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
656
657 std::task::Poll::Ready(Some(match header.ordinal {
658 0x6e2c348c371061e2 => {
659 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
660 let mut req = fidl::new_empty!(
661 TcpProxyControlOpenProxyRequest,
662 fidl::encoding::DefaultFuchsiaResourceDialect
663 );
664 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TcpProxyControlOpenProxyRequest>(&header, _body_bytes, handles, &mut req)?;
665 let control_handle =
666 TcpProxyControlControlHandle { inner: this.inner.clone() };
667 Ok(TcpProxyControlRequest::OpenProxy_ {
668 target_port: req.target_port,
669 proxy_port: req.proxy_port,
670 tcp_proxy: req.tcp_proxy,
671
672 responder: TcpProxyControlOpenProxy_Responder {
673 control_handle: std::mem::ManuallyDrop::new(control_handle),
674 tx_id: header.tx_id,
675 },
676 })
677 }
678 _ => Err(fidl::Error::UnknownOrdinal {
679 ordinal: header.ordinal,
680 protocol_name:
681 <TcpProxyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
682 }),
683 }))
684 },
685 )
686 }
687}
688
689#[derive(Debug)]
697pub enum TcpProxyControlRequest {
698 OpenProxy_ {
708 target_port: u16,
709 proxy_port: u16,
710 tcp_proxy: fidl::endpoints::ServerEnd<TcpProxy_Marker>,
711 responder: TcpProxyControlOpenProxy_Responder,
712 },
713}
714
715impl TcpProxyControlRequest {
716 #[allow(irrefutable_let_patterns)]
717 pub fn into_open_proxy_(
718 self,
719 ) -> Option<(
720 u16,
721 u16,
722 fidl::endpoints::ServerEnd<TcpProxy_Marker>,
723 TcpProxyControlOpenProxy_Responder,
724 )> {
725 if let TcpProxyControlRequest::OpenProxy_ {
726 target_port,
727 proxy_port,
728 tcp_proxy,
729 responder,
730 } = self
731 {
732 Some((target_port, proxy_port, tcp_proxy, responder))
733 } else {
734 None
735 }
736 }
737
738 pub fn method_name(&self) -> &'static str {
740 match *self {
741 TcpProxyControlRequest::OpenProxy_ { .. } => "open_proxy_",
742 }
743 }
744}
745
746#[derive(Debug, Clone)]
747pub struct TcpProxyControlControlHandle {
748 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
749}
750
751impl fidl::endpoints::ControlHandle for TcpProxyControlControlHandle {
752 fn shutdown(&self) {
753 self.inner.shutdown()
754 }
755
756 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
757 self.inner.shutdown_with_epitaph(status)
758 }
759
760 fn is_closed(&self) -> bool {
761 self.inner.channel().is_closed()
762 }
763 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
764 self.inner.channel().on_closed()
765 }
766
767 #[cfg(target_os = "fuchsia")]
768 fn signal_peer(
769 &self,
770 clear_mask: zx::Signals,
771 set_mask: zx::Signals,
772 ) -> Result<(), zx_status::Status> {
773 use fidl::Peered;
774 self.inner.channel().signal_peer(clear_mask, set_mask)
775 }
776}
777
778impl TcpProxyControlControlHandle {}
779
780#[must_use = "FIDL methods require a response to be sent"]
781#[derive(Debug)]
782pub struct TcpProxyControlOpenProxy_Responder {
783 control_handle: std::mem::ManuallyDrop<TcpProxyControlControlHandle>,
784 tx_id: u32,
785}
786
787impl std::ops::Drop for TcpProxyControlOpenProxy_Responder {
791 fn drop(&mut self) {
792 self.control_handle.shutdown();
793 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
795 }
796}
797
798impl fidl::endpoints::Responder for TcpProxyControlOpenProxy_Responder {
799 type ControlHandle = TcpProxyControlControlHandle;
800
801 fn control_handle(&self) -> &TcpProxyControlControlHandle {
802 &self.control_handle
803 }
804
805 fn drop_without_shutdown(mut self) {
806 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
808 std::mem::forget(self);
810 }
811}
812
813impl TcpProxyControlOpenProxy_Responder {
814 pub fn send(self, mut open_port: u16) -> Result<(), fidl::Error> {
818 let _result = self.send_raw(open_port);
819 if _result.is_err() {
820 self.control_handle.shutdown();
821 }
822 self.drop_without_shutdown();
823 _result
824 }
825
826 pub fn send_no_shutdown_on_err(self, mut open_port: u16) -> Result<(), fidl::Error> {
828 let _result = self.send_raw(open_port);
829 self.drop_without_shutdown();
830 _result
831 }
832
833 fn send_raw(&self, mut open_port: u16) -> Result<(), fidl::Error> {
834 self.control_handle.inner.send::<TcpProxyControlOpenProxyResponse>(
835 (open_port,),
836 self.tx_id,
837 0x6e2c348c371061e2,
838 fidl::encoding::DynamicFlags::empty(),
839 )
840 }
841}
842
843mod internal {
844 use super::*;
845
846 impl fidl::encoding::ResourceTypeMarker for TcpProxyControlOpenProxyRequest {
847 type Borrowed<'a> = &'a mut Self;
848 fn take_or_borrow<'a>(
849 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
850 ) -> Self::Borrowed<'a> {
851 value
852 }
853 }
854
855 unsafe impl fidl::encoding::TypeMarker for TcpProxyControlOpenProxyRequest {
856 type Owned = Self;
857
858 #[inline(always)]
859 fn inline_align(_context: fidl::encoding::Context) -> usize {
860 4
861 }
862
863 #[inline(always)]
864 fn inline_size(_context: fidl::encoding::Context) -> usize {
865 8
866 }
867 }
868
869 unsafe impl
870 fidl::encoding::Encode<
871 TcpProxyControlOpenProxyRequest,
872 fidl::encoding::DefaultFuchsiaResourceDialect,
873 > for &mut TcpProxyControlOpenProxyRequest
874 {
875 #[inline]
876 unsafe fn encode(
877 self,
878 encoder: &mut fidl::encoding::Encoder<
879 '_,
880 fidl::encoding::DefaultFuchsiaResourceDialect,
881 >,
882 offset: usize,
883 _depth: fidl::encoding::Depth,
884 ) -> fidl::Result<()> {
885 encoder.debug_check_bounds::<TcpProxyControlOpenProxyRequest>(offset);
886 fidl::encoding::Encode::<TcpProxyControlOpenProxyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
888 (
889 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.target_port),
890 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.proxy_port),
891 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.tcp_proxy),
892 ),
893 encoder, offset, _depth
894 )
895 }
896 }
897 unsafe impl<
898 T0: fidl::encoding::Encode<u16, fidl::encoding::DefaultFuchsiaResourceDialect>,
899 T1: fidl::encoding::Encode<u16, fidl::encoding::DefaultFuchsiaResourceDialect>,
900 T2: fidl::encoding::Encode<
901 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
902 fidl::encoding::DefaultFuchsiaResourceDialect,
903 >,
904 >
905 fidl::encoding::Encode<
906 TcpProxyControlOpenProxyRequest,
907 fidl::encoding::DefaultFuchsiaResourceDialect,
908 > for (T0, T1, T2)
909 {
910 #[inline]
911 unsafe fn encode(
912 self,
913 encoder: &mut fidl::encoding::Encoder<
914 '_,
915 fidl::encoding::DefaultFuchsiaResourceDialect,
916 >,
917 offset: usize,
918 depth: fidl::encoding::Depth,
919 ) -> fidl::Result<()> {
920 encoder.debug_check_bounds::<TcpProxyControlOpenProxyRequest>(offset);
921 self.0.encode(encoder, offset + 0, depth)?;
925 self.1.encode(encoder, offset + 2, depth)?;
926 self.2.encode(encoder, offset + 4, depth)?;
927 Ok(())
928 }
929 }
930
931 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
932 for TcpProxyControlOpenProxyRequest
933 {
934 #[inline(always)]
935 fn new_empty() -> Self {
936 Self {
937 target_port: fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect),
938 proxy_port: fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect),
939 tcp_proxy: fidl::new_empty!(
940 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
941 fidl::encoding::DefaultFuchsiaResourceDialect
942 ),
943 }
944 }
945
946 #[inline]
947 unsafe fn decode(
948 &mut self,
949 decoder: &mut fidl::encoding::Decoder<
950 '_,
951 fidl::encoding::DefaultFuchsiaResourceDialect,
952 >,
953 offset: usize,
954 _depth: fidl::encoding::Depth,
955 ) -> fidl::Result<()> {
956 decoder.debug_check_bounds::<Self>(offset);
957 fidl::decode!(
959 u16,
960 fidl::encoding::DefaultFuchsiaResourceDialect,
961 &mut self.target_port,
962 decoder,
963 offset + 0,
964 _depth
965 )?;
966 fidl::decode!(
967 u16,
968 fidl::encoding::DefaultFuchsiaResourceDialect,
969 &mut self.proxy_port,
970 decoder,
971 offset + 2,
972 _depth
973 )?;
974 fidl::decode!(
975 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TcpProxy_Marker>>,
976 fidl::encoding::DefaultFuchsiaResourceDialect,
977 &mut self.tcp_proxy,
978 decoder,
979 offset + 4,
980 _depth
981 )?;
982 Ok(())
983 }
984 }
985}