Skip to main content

fidl_fuchsia_net_sockets/
fidl_fuchsia_net_sockets.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_sockets_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DiagnosticsGetDestructionWatcherRequest {
16    pub watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DiagnosticsGetDestructionWatcherRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct DiagnosticsIterateIpRequest {
26    /// The `IpIterator` for streaming sockets back to the caller.
27    pub s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
28    /// The types of extended information to request. Information is
29    /// only returned for qualifying sockets. For example, the `TCP_INFO`
30    /// extension has no effect on returned UDP sockets.
31    pub extensions: Extensions,
32    /// Matchers are ANDed together and applied to all sockets on the
33    /// system. Put another way, only sockets matched by all matchers are
34    /// returned through the `IpIterator` protocol.
35    ///
36    /// For example, if you want to match all IPv4 TCP sockets with a local
37    /// port of 22, but not on loopback, you could use the following
38    /// (pseudocode) query:
39    ///
40    /// [
41    ///   {
42    ///     family: Ipv4,
43    ///   },
44    ///   {
45    ///     proto: tcp {
46    ///       src_port: {
47    ///         start:  22,
48    ///         end:    22,
49    ///         invert: false,
50    ///       }
51    ///     },
52    ///   },
53    ///   {
54    ///     src_addr: {
55    ///       range: {
56    ///         start: "127.0.0.1"
57    ///         end:   "127.0.0.1"
58    ///       },
59    ///       invert: true
60    ///     },
61    ///   },
62    /// ]
63    pub matchers: Vec<IpSocketMatcher>,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
67    for DiagnosticsIterateIpRequest
68{
69}
70
71#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
72pub struct ControlMarker;
73
74impl fidl::endpoints::ProtocolMarker for ControlMarker {
75    type Proxy = ControlProxy;
76    type RequestStream = ControlRequestStream;
77    #[cfg(target_os = "fuchsia")]
78    type SynchronousProxy = ControlSynchronousProxy;
79
80    const DEBUG_NAME: &'static str = "fuchsia.net.sockets.Control";
81}
82impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
83
84pub trait ControlProxyInterface: Send + Sync {
85    type DisconnectIpResponseFut: std::future::Future<Output = Result<DisconnectIpResult, fidl::Error>>
86        + Send;
87    fn r#disconnect_ip(
88        &self,
89        payload: &ControlDisconnectIpRequest,
90    ) -> Self::DisconnectIpResponseFut;
91}
92#[derive(Debug)]
93#[cfg(target_os = "fuchsia")]
94pub struct ControlSynchronousProxy {
95    client: fidl::client::sync::Client,
96}
97
98#[cfg(target_os = "fuchsia")]
99impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
100    type Proxy = ControlProxy;
101    type Protocol = ControlMarker;
102
103    fn from_channel(inner: fidl::Channel) -> Self {
104        Self::new(inner)
105    }
106
107    fn into_channel(self) -> fidl::Channel {
108        self.client.into_channel()
109    }
110
111    fn as_channel(&self) -> &fidl::Channel {
112        self.client.as_channel()
113    }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl ControlSynchronousProxy {
118    pub fn new(channel: fidl::Channel) -> Self {
119        Self { client: fidl::client::sync::Client::new(channel) }
120    }
121
122    pub fn into_channel(self) -> fidl::Channel {
123        self.client.into_channel()
124    }
125
126    /// Waits until an event arrives and returns it. It is safe for other
127    /// threads to make concurrent requests while waiting for an event.
128    pub fn wait_for_event(
129        &self,
130        deadline: zx::MonotonicInstant,
131    ) -> Result<ControlEvent, fidl::Error> {
132        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
133    }
134
135    /// Disconnect the socket matched by the provided matchers. See
136    /// `Diagnostics.IterateIp` for matcher semantics.
137    ///
138    /// Disconnecting a socket depends on the transport protocol. In all cases,
139    /// the next read or write operation will see `ECONNABORTED`.
140    ///
141    /// - UDP: the behavior is equivalent to calling
142    ///   `fuchsia.posix.socket/*.Disconnect`. Any destination port and address,
143    ///   and bound device are removed. The socket may be reused.
144    /// - TCP LISTEN state: TCP moves to state CLOSE. All non-accepted sockets
145    ///   are closed and an RST is sent to the peer. The socket may be reused.
146    /// - TCP all other states: The TCP connection is put in state CLOSE and an
147    ///   RST is sent to the remote peer, if required. The socket may not be
148    ///   reused.
149    ///
150    /// If no matchers are specified, or the provided matchers match all sockets,
151    /// an error is returned and no action is taken.
152    ///
153    /// NOTE: This operation is asynchronous. While the internal state of the
154    /// socket is updated before this call returns, propagation of the error to
155    /// an application is unsynchronized. Subsequent operations (such as TCP
156    /// reads and writes) may not immediately see the error.
157    ///
158    /// NOTE: For UDP sockets, the receive buffer is not cleared, so it's
159    /// possible for a socket to be interrupted, but still read pending
160    /// datagrams. This is in order to maintain compatibility with Linux.
161    pub fn r#disconnect_ip(
162        &self,
163        mut payload: &ControlDisconnectIpRequest,
164        ___deadline: zx::MonotonicInstant,
165    ) -> Result<DisconnectIpResult, fidl::Error> {
166        let _response = self
167            .client
168            .send_query::<ControlDisconnectIpRequest, DisconnectIpResult, ControlMarker>(
169                payload,
170                0xbdaa66fbb4241a4,
171                fidl::encoding::DynamicFlags::empty(),
172                ___deadline,
173            )?;
174        Ok(_response)
175    }
176}
177
178#[cfg(target_os = "fuchsia")]
179impl From<ControlSynchronousProxy> for zx::NullableHandle {
180    fn from(value: ControlSynchronousProxy) -> Self {
181        value.into_channel().into()
182    }
183}
184
185#[cfg(target_os = "fuchsia")]
186impl From<fidl::Channel> for ControlSynchronousProxy {
187    fn from(value: fidl::Channel) -> Self {
188        Self::new(value)
189    }
190}
191
192#[cfg(target_os = "fuchsia")]
193impl fidl::endpoints::FromClient for ControlSynchronousProxy {
194    type Protocol = ControlMarker;
195
196    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
197        Self::new(value.into_channel())
198    }
199}
200
201#[derive(Debug, Clone)]
202pub struct ControlProxy {
203    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
204}
205
206impl fidl::endpoints::Proxy for ControlProxy {
207    type Protocol = ControlMarker;
208
209    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
210        Self::new(inner)
211    }
212
213    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
214        self.client.into_channel().map_err(|client| Self { client })
215    }
216
217    fn as_channel(&self) -> &::fidl::AsyncChannel {
218        self.client.as_channel()
219    }
220}
221
222impl ControlProxy {
223    /// Create a new Proxy for fuchsia.net.sockets/Control.
224    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
225        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
226        Self { client: fidl::client::Client::new(channel, protocol_name) }
227    }
228
229    /// Get a Stream of events from the remote end of the protocol.
230    ///
231    /// # Panics
232    ///
233    /// Panics if the event stream was already taken.
234    pub fn take_event_stream(&self) -> ControlEventStream {
235        ControlEventStream { event_receiver: self.client.take_event_receiver() }
236    }
237
238    /// Disconnect the socket matched by the provided matchers. See
239    /// `Diagnostics.IterateIp` for matcher semantics.
240    ///
241    /// Disconnecting a socket depends on the transport protocol. In all cases,
242    /// the next read or write operation will see `ECONNABORTED`.
243    ///
244    /// - UDP: the behavior is equivalent to calling
245    ///   `fuchsia.posix.socket/*.Disconnect`. Any destination port and address,
246    ///   and bound device are removed. The socket may be reused.
247    /// - TCP LISTEN state: TCP moves to state CLOSE. All non-accepted sockets
248    ///   are closed and an RST is sent to the peer. The socket may be reused.
249    /// - TCP all other states: The TCP connection is put in state CLOSE and an
250    ///   RST is sent to the remote peer, if required. The socket may not be
251    ///   reused.
252    ///
253    /// If no matchers are specified, or the provided matchers match all sockets,
254    /// an error is returned and no action is taken.
255    ///
256    /// NOTE: This operation is asynchronous. While the internal state of the
257    /// socket is updated before this call returns, propagation of the error to
258    /// an application is unsynchronized. Subsequent operations (such as TCP
259    /// reads and writes) may not immediately see the error.
260    ///
261    /// NOTE: For UDP sockets, the receive buffer is not cleared, so it's
262    /// possible for a socket to be interrupted, but still read pending
263    /// datagrams. This is in order to maintain compatibility with Linux.
264    pub fn r#disconnect_ip(
265        &self,
266        mut payload: &ControlDisconnectIpRequest,
267    ) -> fidl::client::QueryResponseFut<
268        DisconnectIpResult,
269        fidl::encoding::DefaultFuchsiaResourceDialect,
270    > {
271        ControlProxyInterface::r#disconnect_ip(self, payload)
272    }
273}
274
275impl ControlProxyInterface for ControlProxy {
276    type DisconnectIpResponseFut = fidl::client::QueryResponseFut<
277        DisconnectIpResult,
278        fidl::encoding::DefaultFuchsiaResourceDialect,
279    >;
280    fn r#disconnect_ip(
281        &self,
282        mut payload: &ControlDisconnectIpRequest,
283    ) -> Self::DisconnectIpResponseFut {
284        fn _decode(
285            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
286        ) -> Result<DisconnectIpResult, fidl::Error> {
287            let _response = fidl::client::decode_transaction_body::<
288                DisconnectIpResult,
289                fidl::encoding::DefaultFuchsiaResourceDialect,
290                0xbdaa66fbb4241a4,
291            >(_buf?)?;
292            Ok(_response)
293        }
294        self.client.send_query_and_decode::<ControlDisconnectIpRequest, DisconnectIpResult>(
295            payload,
296            0xbdaa66fbb4241a4,
297            fidl::encoding::DynamicFlags::empty(),
298            _decode,
299        )
300    }
301}
302
303pub struct ControlEventStream {
304    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
305}
306
307impl std::marker::Unpin for ControlEventStream {}
308
309impl futures::stream::FusedStream for ControlEventStream {
310    fn is_terminated(&self) -> bool {
311        self.event_receiver.is_terminated()
312    }
313}
314
315impl futures::Stream for ControlEventStream {
316    type Item = Result<ControlEvent, fidl::Error>;
317
318    fn poll_next(
319        mut self: std::pin::Pin<&mut Self>,
320        cx: &mut std::task::Context<'_>,
321    ) -> std::task::Poll<Option<Self::Item>> {
322        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
323            &mut self.event_receiver,
324            cx
325        )?) {
326            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
327            None => std::task::Poll::Ready(None),
328        }
329    }
330}
331
332#[derive(Debug)]
333pub enum ControlEvent {}
334
335impl ControlEvent {
336    /// Decodes a message buffer as a [`ControlEvent`].
337    fn decode(
338        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
339    ) -> Result<ControlEvent, fidl::Error> {
340        let (bytes, _handles) = buf.split_mut();
341        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
342        debug_assert_eq!(tx_header.tx_id, 0);
343        match tx_header.ordinal {
344            _ => Err(fidl::Error::UnknownOrdinal {
345                ordinal: tx_header.ordinal,
346                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
347            }),
348        }
349    }
350}
351
352/// A Stream of incoming requests for fuchsia.net.sockets/Control.
353pub struct ControlRequestStream {
354    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355    is_terminated: bool,
356}
357
358impl std::marker::Unpin for ControlRequestStream {}
359
360impl futures::stream::FusedStream for ControlRequestStream {
361    fn is_terminated(&self) -> bool {
362        self.is_terminated
363    }
364}
365
366impl fidl::endpoints::RequestStream for ControlRequestStream {
367    type Protocol = ControlMarker;
368    type ControlHandle = ControlControlHandle;
369
370    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
371        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
372    }
373
374    fn control_handle(&self) -> Self::ControlHandle {
375        ControlControlHandle { inner: self.inner.clone() }
376    }
377
378    fn into_inner(
379        self,
380    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
381    {
382        (self.inner, self.is_terminated)
383    }
384
385    fn from_inner(
386        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
387        is_terminated: bool,
388    ) -> Self {
389        Self { inner, is_terminated }
390    }
391}
392
393impl futures::Stream for ControlRequestStream {
394    type Item = Result<ControlRequest, fidl::Error>;
395
396    fn poll_next(
397        mut self: std::pin::Pin<&mut Self>,
398        cx: &mut std::task::Context<'_>,
399    ) -> std::task::Poll<Option<Self::Item>> {
400        let this = &mut *self;
401        if this.inner.check_shutdown(cx) {
402            this.is_terminated = true;
403            return std::task::Poll::Ready(None);
404        }
405        if this.is_terminated {
406            panic!("polled ControlRequestStream after completion");
407        }
408        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
409            |bytes, handles| {
410                match this.inner.channel().read_etc(cx, bytes, handles) {
411                    std::task::Poll::Ready(Ok(())) => {}
412                    std::task::Poll::Pending => return std::task::Poll::Pending,
413                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
414                        this.is_terminated = true;
415                        return std::task::Poll::Ready(None);
416                    }
417                    std::task::Poll::Ready(Err(e)) => {
418                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
419                            e.into(),
420                        ))));
421                    }
422                }
423
424                // A message has been received from the channel
425                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
426
427                std::task::Poll::Ready(Some(match header.ordinal {
428                    0xbdaa66fbb4241a4 => {
429                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
430                        let mut req = fidl::new_empty!(
431                            ControlDisconnectIpRequest,
432                            fidl::encoding::DefaultFuchsiaResourceDialect
433                        );
434                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlDisconnectIpRequest>(&header, _body_bytes, handles, &mut req)?;
435                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
436                        Ok(ControlRequest::DisconnectIp {
437                            payload: req,
438                            responder: ControlDisconnectIpResponder {
439                                control_handle: std::mem::ManuallyDrop::new(control_handle),
440                                tx_id: header.tx_id,
441                            },
442                        })
443                    }
444                    _ => Err(fidl::Error::UnknownOrdinal {
445                        ordinal: header.ordinal,
446                        protocol_name:
447                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
448                    }),
449                }))
450            },
451        )
452    }
453}
454
455/// Provides control operations on sockets.
456#[derive(Debug)]
457pub enum ControlRequest {
458    /// Disconnect the socket matched by the provided matchers. See
459    /// `Diagnostics.IterateIp` for matcher semantics.
460    ///
461    /// Disconnecting a socket depends on the transport protocol. In all cases,
462    /// the next read or write operation will see `ECONNABORTED`.
463    ///
464    /// - UDP: the behavior is equivalent to calling
465    ///   `fuchsia.posix.socket/*.Disconnect`. Any destination port and address,
466    ///   and bound device are removed. The socket may be reused.
467    /// - TCP LISTEN state: TCP moves to state CLOSE. All non-accepted sockets
468    ///   are closed and an RST is sent to the peer. The socket may be reused.
469    /// - TCP all other states: The TCP connection is put in state CLOSE and an
470    ///   RST is sent to the remote peer, if required. The socket may not be
471    ///   reused.
472    ///
473    /// If no matchers are specified, or the provided matchers match all sockets,
474    /// an error is returned and no action is taken.
475    ///
476    /// NOTE: This operation is asynchronous. While the internal state of the
477    /// socket is updated before this call returns, propagation of the error to
478    /// an application is unsynchronized. Subsequent operations (such as TCP
479    /// reads and writes) may not immediately see the error.
480    ///
481    /// NOTE: For UDP sockets, the receive buffer is not cleared, so it's
482    /// possible for a socket to be interrupted, but still read pending
483    /// datagrams. This is in order to maintain compatibility with Linux.
484    DisconnectIp { payload: ControlDisconnectIpRequest, responder: ControlDisconnectIpResponder },
485}
486
487impl ControlRequest {
488    #[allow(irrefutable_let_patterns)]
489    pub fn into_disconnect_ip(
490        self,
491    ) -> Option<(ControlDisconnectIpRequest, ControlDisconnectIpResponder)> {
492        if let ControlRequest::DisconnectIp { payload, responder } = self {
493            Some((payload, responder))
494        } else {
495            None
496        }
497    }
498
499    /// Name of the method defined in FIDL
500    pub fn method_name(&self) -> &'static str {
501        match *self {
502            ControlRequest::DisconnectIp { .. } => "disconnect_ip",
503        }
504    }
505}
506
507#[derive(Debug, Clone)]
508pub struct ControlControlHandle {
509    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
510}
511
512impl fidl::endpoints::ControlHandle for ControlControlHandle {
513    fn shutdown(&self) {
514        self.inner.shutdown()
515    }
516
517    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
518        self.inner.shutdown_with_epitaph(status)
519    }
520
521    fn is_closed(&self) -> bool {
522        self.inner.channel().is_closed()
523    }
524    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
525        self.inner.channel().on_closed()
526    }
527
528    #[cfg(target_os = "fuchsia")]
529    fn signal_peer(
530        &self,
531        clear_mask: zx::Signals,
532        set_mask: zx::Signals,
533    ) -> Result<(), zx_status::Status> {
534        use fidl::Peered;
535        self.inner.channel().signal_peer(clear_mask, set_mask)
536    }
537}
538
539impl ControlControlHandle {}
540
541#[must_use = "FIDL methods require a response to be sent"]
542#[derive(Debug)]
543pub struct ControlDisconnectIpResponder {
544    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
545    tx_id: u32,
546}
547
548/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
549/// if the responder is dropped without sending a response, so that the client
550/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
551impl std::ops::Drop for ControlDisconnectIpResponder {
552    fn drop(&mut self) {
553        self.control_handle.shutdown();
554        // Safety: drops once, never accessed again
555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
556    }
557}
558
559impl fidl::endpoints::Responder for ControlDisconnectIpResponder {
560    type ControlHandle = ControlControlHandle;
561
562    fn control_handle(&self) -> &ControlControlHandle {
563        &self.control_handle
564    }
565
566    fn drop_without_shutdown(mut self) {
567        // Safety: drops once, never accessed again due to mem::forget
568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
569        // Prevent Drop from running (which would shut down the channel)
570        std::mem::forget(self);
571    }
572}
573
574impl ControlDisconnectIpResponder {
575    /// Sends a response to the FIDL transaction.
576    ///
577    /// Sets the channel to shutdown if an error occurs.
578    pub fn send(self, mut payload: &DisconnectIpResult) -> Result<(), fidl::Error> {
579        let _result = self.send_raw(payload);
580        if _result.is_err() {
581            self.control_handle.shutdown();
582        }
583        self.drop_without_shutdown();
584        _result
585    }
586
587    /// Similar to "send" but does not shutdown the channel if an error occurs.
588    pub fn send_no_shutdown_on_err(
589        self,
590        mut payload: &DisconnectIpResult,
591    ) -> Result<(), fidl::Error> {
592        let _result = self.send_raw(payload);
593        self.drop_without_shutdown();
594        _result
595    }
596
597    fn send_raw(&self, mut payload: &DisconnectIpResult) -> Result<(), fidl::Error> {
598        self.control_handle.inner.send::<DisconnectIpResult>(
599            payload,
600            self.tx_id,
601            0xbdaa66fbb4241a4,
602            fidl::encoding::DynamicFlags::empty(),
603        )
604    }
605}
606
607#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
608pub struct DestructionWatcherMarker;
609
610impl fidl::endpoints::ProtocolMarker for DestructionWatcherMarker {
611    type Proxy = DestructionWatcherProxy;
612    type RequestStream = DestructionWatcherRequestStream;
613    #[cfg(target_os = "fuchsia")]
614    type SynchronousProxy = DestructionWatcherSynchronousProxy;
615
616    const DEBUG_NAME: &'static str = "(anonymous) DestructionWatcher";
617}
618
619pub trait DestructionWatcherProxyInterface: Send + Sync {
620    type WatchResponseFut: std::future::Future<Output = Result<Vec<IpSocketState>, fidl::Error>>
621        + Send;
622    fn r#watch(&self) -> Self::WatchResponseFut;
623}
624#[derive(Debug)]
625#[cfg(target_os = "fuchsia")]
626pub struct DestructionWatcherSynchronousProxy {
627    client: fidl::client::sync::Client,
628}
629
630#[cfg(target_os = "fuchsia")]
631impl fidl::endpoints::SynchronousProxy for DestructionWatcherSynchronousProxy {
632    type Proxy = DestructionWatcherProxy;
633    type Protocol = DestructionWatcherMarker;
634
635    fn from_channel(inner: fidl::Channel) -> Self {
636        Self::new(inner)
637    }
638
639    fn into_channel(self) -> fidl::Channel {
640        self.client.into_channel()
641    }
642
643    fn as_channel(&self) -> &fidl::Channel {
644        self.client.as_channel()
645    }
646}
647
648#[cfg(target_os = "fuchsia")]
649impl DestructionWatcherSynchronousProxy {
650    pub fn new(channel: fidl::Channel) -> Self {
651        Self { client: fidl::client::sync::Client::new(channel) }
652    }
653
654    pub fn into_channel(self) -> fidl::Channel {
655        self.client.into_channel()
656    }
657
658    /// Waits until an event arrives and returns it. It is safe for other
659    /// threads to make concurrent requests while waiting for an event.
660    pub fn wait_for_event(
661        &self,
662        deadline: zx::MonotonicInstant,
663    ) -> Result<DestructionWatcherEvent, fidl::Error> {
664        DestructionWatcherEvent::decode(
665            self.client.wait_for_event::<DestructionWatcherMarker>(deadline)?,
666        )
667    }
668
669    /// Hanging get for destroyed sockets.
670    ///
671    /// Returns sockets destroyed since the last call to this method. Blocks
672    /// until at least one event is available.
673    ///
674    /// A "destroyed" socket is one that no longer has any references inside the
675    /// Netstack. Especially for TCP sockets (because of TIME-WAIT), this may
676    /// happen long after `close` has returned.
677    ///
678    /// Sockets destroyed before the watcher was created are not returned.
679    /// Unbound sockets are not returned.
680    ///
681    /// Only one call to `Watch` may be active at a time. Concurrency is not
682    /// allowed and will result in the channel being closed with
683    /// `ALREADY_EXISTS`.
684    ///
685    /// If the client doesn't read events fast enough, the channel is closed
686    /// with `NO_RESOURCES`.
687    pub fn r#watch(
688        &self,
689        ___deadline: zx::MonotonicInstant,
690    ) -> Result<Vec<IpSocketState>, fidl::Error> {
691        let _response = self.client.send_query::<
692            fidl::encoding::EmptyPayload,
693            DestructionWatcherWatchResponse,
694            DestructionWatcherMarker,
695        >(
696            (),
697            0x7ce86d7c39821f10,
698            fidl::encoding::DynamicFlags::empty(),
699            ___deadline,
700        )?;
701        Ok(_response.sockets)
702    }
703}
704
705#[cfg(target_os = "fuchsia")]
706impl From<DestructionWatcherSynchronousProxy> for zx::NullableHandle {
707    fn from(value: DestructionWatcherSynchronousProxy) -> Self {
708        value.into_channel().into()
709    }
710}
711
712#[cfg(target_os = "fuchsia")]
713impl From<fidl::Channel> for DestructionWatcherSynchronousProxy {
714    fn from(value: fidl::Channel) -> Self {
715        Self::new(value)
716    }
717}
718
719#[cfg(target_os = "fuchsia")]
720impl fidl::endpoints::FromClient for DestructionWatcherSynchronousProxy {
721    type Protocol = DestructionWatcherMarker;
722
723    fn from_client(value: fidl::endpoints::ClientEnd<DestructionWatcherMarker>) -> Self {
724        Self::new(value.into_channel())
725    }
726}
727
728#[derive(Debug, Clone)]
729pub struct DestructionWatcherProxy {
730    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
731}
732
733impl fidl::endpoints::Proxy for DestructionWatcherProxy {
734    type Protocol = DestructionWatcherMarker;
735
736    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
737        Self::new(inner)
738    }
739
740    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
741        self.client.into_channel().map_err(|client| Self { client })
742    }
743
744    fn as_channel(&self) -> &::fidl::AsyncChannel {
745        self.client.as_channel()
746    }
747}
748
749impl DestructionWatcherProxy {
750    /// Create a new Proxy for fuchsia.net.sockets/DestructionWatcher.
751    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
752        let protocol_name =
753            <DestructionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
754        Self { client: fidl::client::Client::new(channel, protocol_name) }
755    }
756
757    /// Get a Stream of events from the remote end of the protocol.
758    ///
759    /// # Panics
760    ///
761    /// Panics if the event stream was already taken.
762    pub fn take_event_stream(&self) -> DestructionWatcherEventStream {
763        DestructionWatcherEventStream { event_receiver: self.client.take_event_receiver() }
764    }
765
766    /// Hanging get for destroyed sockets.
767    ///
768    /// Returns sockets destroyed since the last call to this method. Blocks
769    /// until at least one event is available.
770    ///
771    /// A "destroyed" socket is one that no longer has any references inside the
772    /// Netstack. Especially for TCP sockets (because of TIME-WAIT), this may
773    /// happen long after `close` has returned.
774    ///
775    /// Sockets destroyed before the watcher was created are not returned.
776    /// Unbound sockets are not returned.
777    ///
778    /// Only one call to `Watch` may be active at a time. Concurrency is not
779    /// allowed and will result in the channel being closed with
780    /// `ALREADY_EXISTS`.
781    ///
782    /// If the client doesn't read events fast enough, the channel is closed
783    /// with `NO_RESOURCES`.
784    pub fn r#watch(
785        &self,
786    ) -> fidl::client::QueryResponseFut<
787        Vec<IpSocketState>,
788        fidl::encoding::DefaultFuchsiaResourceDialect,
789    > {
790        DestructionWatcherProxyInterface::r#watch(self)
791    }
792}
793
794impl DestructionWatcherProxyInterface for DestructionWatcherProxy {
795    type WatchResponseFut = fidl::client::QueryResponseFut<
796        Vec<IpSocketState>,
797        fidl::encoding::DefaultFuchsiaResourceDialect,
798    >;
799    fn r#watch(&self) -> Self::WatchResponseFut {
800        fn _decode(
801            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
802        ) -> Result<Vec<IpSocketState>, fidl::Error> {
803            let _response = fidl::client::decode_transaction_body::<
804                DestructionWatcherWatchResponse,
805                fidl::encoding::DefaultFuchsiaResourceDialect,
806                0x7ce86d7c39821f10,
807            >(_buf?)?;
808            Ok(_response.sockets)
809        }
810        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<IpSocketState>>(
811            (),
812            0x7ce86d7c39821f10,
813            fidl::encoding::DynamicFlags::empty(),
814            _decode,
815        )
816    }
817}
818
819pub struct DestructionWatcherEventStream {
820    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
821}
822
823impl std::marker::Unpin for DestructionWatcherEventStream {}
824
825impl futures::stream::FusedStream for DestructionWatcherEventStream {
826    fn is_terminated(&self) -> bool {
827        self.event_receiver.is_terminated()
828    }
829}
830
831impl futures::Stream for DestructionWatcherEventStream {
832    type Item = Result<DestructionWatcherEvent, fidl::Error>;
833
834    fn poll_next(
835        mut self: std::pin::Pin<&mut Self>,
836        cx: &mut std::task::Context<'_>,
837    ) -> std::task::Poll<Option<Self::Item>> {
838        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
839            &mut self.event_receiver,
840            cx
841        )?) {
842            Some(buf) => std::task::Poll::Ready(Some(DestructionWatcherEvent::decode(buf))),
843            None => std::task::Poll::Ready(None),
844        }
845    }
846}
847
848#[derive(Debug)]
849pub enum DestructionWatcherEvent {
850    #[non_exhaustive]
851    _UnknownEvent {
852        /// Ordinal of the event that was sent.
853        ordinal: u64,
854    },
855}
856
857impl DestructionWatcherEvent {
858    /// Decodes a message buffer as a [`DestructionWatcherEvent`].
859    fn decode(
860        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
861    ) -> Result<DestructionWatcherEvent, fidl::Error> {
862        let (bytes, _handles) = buf.split_mut();
863        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
864        debug_assert_eq!(tx_header.tx_id, 0);
865        match tx_header.ordinal {
866            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
867                Ok(DestructionWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
868            }
869            _ => Err(fidl::Error::UnknownOrdinal {
870                ordinal: tx_header.ordinal,
871                protocol_name:
872                    <DestructionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
873            }),
874        }
875    }
876}
877
878/// A Stream of incoming requests for fuchsia.net.sockets/DestructionWatcher.
879pub struct DestructionWatcherRequestStream {
880    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
881    is_terminated: bool,
882}
883
884impl std::marker::Unpin for DestructionWatcherRequestStream {}
885
886impl futures::stream::FusedStream for DestructionWatcherRequestStream {
887    fn is_terminated(&self) -> bool {
888        self.is_terminated
889    }
890}
891
892impl fidl::endpoints::RequestStream for DestructionWatcherRequestStream {
893    type Protocol = DestructionWatcherMarker;
894    type ControlHandle = DestructionWatcherControlHandle;
895
896    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
897        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
898    }
899
900    fn control_handle(&self) -> Self::ControlHandle {
901        DestructionWatcherControlHandle { inner: self.inner.clone() }
902    }
903
904    fn into_inner(
905        self,
906    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
907    {
908        (self.inner, self.is_terminated)
909    }
910
911    fn from_inner(
912        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
913        is_terminated: bool,
914    ) -> Self {
915        Self { inner, is_terminated }
916    }
917}
918
919impl futures::Stream for DestructionWatcherRequestStream {
920    type Item = Result<DestructionWatcherRequest, fidl::Error>;
921
922    fn poll_next(
923        mut self: std::pin::Pin<&mut Self>,
924        cx: &mut std::task::Context<'_>,
925    ) -> std::task::Poll<Option<Self::Item>> {
926        let this = &mut *self;
927        if this.inner.check_shutdown(cx) {
928            this.is_terminated = true;
929            return std::task::Poll::Ready(None);
930        }
931        if this.is_terminated {
932            panic!("polled DestructionWatcherRequestStream after completion");
933        }
934        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
935            |bytes, handles| {
936                match this.inner.channel().read_etc(cx, bytes, handles) {
937                    std::task::Poll::Ready(Ok(())) => {}
938                    std::task::Poll::Pending => return std::task::Poll::Pending,
939                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
940                        this.is_terminated = true;
941                        return std::task::Poll::Ready(None);
942                    }
943                    std::task::Poll::Ready(Err(e)) => {
944                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
945                            e.into(),
946                        ))));
947                    }
948                }
949
950                // A message has been received from the channel
951                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
952
953                std::task::Poll::Ready(Some(match header.ordinal {
954                0x7ce86d7c39821f10 => {
955                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
956                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
957                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
958                    let control_handle = DestructionWatcherControlHandle {
959                        inner: this.inner.clone(),
960                    };
961                    Ok(DestructionWatcherRequest::Watch {
962                        responder: DestructionWatcherWatchResponder {
963                            control_handle: std::mem::ManuallyDrop::new(control_handle),
964                            tx_id: header.tx_id,
965                        },
966                    })
967                }
968                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
969                    Ok(DestructionWatcherRequest::_UnknownMethod {
970                        ordinal: header.ordinal,
971                        control_handle: DestructionWatcherControlHandle { inner: this.inner.clone() },
972                        method_type: fidl::MethodType::OneWay,
973                    })
974                }
975                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
976                    this.inner.send_framework_err(
977                        fidl::encoding::FrameworkErr::UnknownMethod,
978                        header.tx_id,
979                        header.ordinal,
980                        header.dynamic_flags(),
981                        (bytes, handles),
982                    )?;
983                    Ok(DestructionWatcherRequest::_UnknownMethod {
984                        ordinal: header.ordinal,
985                        control_handle: DestructionWatcherControlHandle { inner: this.inner.clone() },
986                        method_type: fidl::MethodType::TwoWay,
987                    })
988                }
989                _ => Err(fidl::Error::UnknownOrdinal {
990                    ordinal: header.ordinal,
991                    protocol_name: <DestructionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
992                }),
993            }))
994            },
995        )
996    }
997}
998
999/// Protocol for watching socket destruction events.
1000#[derive(Debug)]
1001pub enum DestructionWatcherRequest {
1002    /// Hanging get for destroyed sockets.
1003    ///
1004    /// Returns sockets destroyed since the last call to this method. Blocks
1005    /// until at least one event is available.
1006    ///
1007    /// A "destroyed" socket is one that no longer has any references inside the
1008    /// Netstack. Especially for TCP sockets (because of TIME-WAIT), this may
1009    /// happen long after `close` has returned.
1010    ///
1011    /// Sockets destroyed before the watcher was created are not returned.
1012    /// Unbound sockets are not returned.
1013    ///
1014    /// Only one call to `Watch` may be active at a time. Concurrency is not
1015    /// allowed and will result in the channel being closed with
1016    /// `ALREADY_EXISTS`.
1017    ///
1018    /// If the client doesn't read events fast enough, the channel is closed
1019    /// with `NO_RESOURCES`.
1020    Watch { responder: DestructionWatcherWatchResponder },
1021    /// An interaction was received which does not match any known method.
1022    #[non_exhaustive]
1023    _UnknownMethod {
1024        /// Ordinal of the method that was called.
1025        ordinal: u64,
1026        control_handle: DestructionWatcherControlHandle,
1027        method_type: fidl::MethodType,
1028    },
1029}
1030
1031impl DestructionWatcherRequest {
1032    #[allow(irrefutable_let_patterns)]
1033    pub fn into_watch(self) -> Option<(DestructionWatcherWatchResponder)> {
1034        if let DestructionWatcherRequest::Watch { responder } = self {
1035            Some((responder))
1036        } else {
1037            None
1038        }
1039    }
1040
1041    /// Name of the method defined in FIDL
1042    pub fn method_name(&self) -> &'static str {
1043        match *self {
1044            DestructionWatcherRequest::Watch { .. } => "watch",
1045            DestructionWatcherRequest::_UnknownMethod {
1046                method_type: fidl::MethodType::OneWay,
1047                ..
1048            } => "unknown one-way method",
1049            DestructionWatcherRequest::_UnknownMethod {
1050                method_type: fidl::MethodType::TwoWay,
1051                ..
1052            } => "unknown two-way method",
1053        }
1054    }
1055}
1056
1057#[derive(Debug, Clone)]
1058pub struct DestructionWatcherControlHandle {
1059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1060}
1061
1062impl fidl::endpoints::ControlHandle for DestructionWatcherControlHandle {
1063    fn shutdown(&self) {
1064        self.inner.shutdown()
1065    }
1066
1067    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1068        self.inner.shutdown_with_epitaph(status)
1069    }
1070
1071    fn is_closed(&self) -> bool {
1072        self.inner.channel().is_closed()
1073    }
1074    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1075        self.inner.channel().on_closed()
1076    }
1077
1078    #[cfg(target_os = "fuchsia")]
1079    fn signal_peer(
1080        &self,
1081        clear_mask: zx::Signals,
1082        set_mask: zx::Signals,
1083    ) -> Result<(), zx_status::Status> {
1084        use fidl::Peered;
1085        self.inner.channel().signal_peer(clear_mask, set_mask)
1086    }
1087}
1088
1089impl DestructionWatcherControlHandle {}
1090
1091#[must_use = "FIDL methods require a response to be sent"]
1092#[derive(Debug)]
1093pub struct DestructionWatcherWatchResponder {
1094    control_handle: std::mem::ManuallyDrop<DestructionWatcherControlHandle>,
1095    tx_id: u32,
1096}
1097
1098/// Set the the channel to be shutdown (see [`DestructionWatcherControlHandle::shutdown`])
1099/// if the responder is dropped without sending a response, so that the client
1100/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1101impl std::ops::Drop for DestructionWatcherWatchResponder {
1102    fn drop(&mut self) {
1103        self.control_handle.shutdown();
1104        // Safety: drops once, never accessed again
1105        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1106    }
1107}
1108
1109impl fidl::endpoints::Responder for DestructionWatcherWatchResponder {
1110    type ControlHandle = DestructionWatcherControlHandle;
1111
1112    fn control_handle(&self) -> &DestructionWatcherControlHandle {
1113        &self.control_handle
1114    }
1115
1116    fn drop_without_shutdown(mut self) {
1117        // Safety: drops once, never accessed again due to mem::forget
1118        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1119        // Prevent Drop from running (which would shut down the channel)
1120        std::mem::forget(self);
1121    }
1122}
1123
1124impl DestructionWatcherWatchResponder {
1125    /// Sends a response to the FIDL transaction.
1126    ///
1127    /// Sets the channel to shutdown if an error occurs.
1128    pub fn send(self, mut sockets: &[IpSocketState]) -> Result<(), fidl::Error> {
1129        let _result = self.send_raw(sockets);
1130        if _result.is_err() {
1131            self.control_handle.shutdown();
1132        }
1133        self.drop_without_shutdown();
1134        _result
1135    }
1136
1137    /// Similar to "send" but does not shutdown the channel if an error occurs.
1138    pub fn send_no_shutdown_on_err(self, mut sockets: &[IpSocketState]) -> Result<(), fidl::Error> {
1139        let _result = self.send_raw(sockets);
1140        self.drop_without_shutdown();
1141        _result
1142    }
1143
1144    fn send_raw(&self, mut sockets: &[IpSocketState]) -> Result<(), fidl::Error> {
1145        self.control_handle.inner.send::<DestructionWatcherWatchResponse>(
1146            (sockets,),
1147            self.tx_id,
1148            0x7ce86d7c39821f10,
1149            fidl::encoding::DynamicFlags::empty(),
1150        )
1151    }
1152}
1153
1154#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1155pub struct DiagnosticsMarker;
1156
1157impl fidl::endpoints::ProtocolMarker for DiagnosticsMarker {
1158    type Proxy = DiagnosticsProxy;
1159    type RequestStream = DiagnosticsRequestStream;
1160    #[cfg(target_os = "fuchsia")]
1161    type SynchronousProxy = DiagnosticsSynchronousProxy;
1162
1163    const DEBUG_NAME: &'static str = "fuchsia.net.sockets.Diagnostics";
1164}
1165impl fidl::endpoints::DiscoverableProtocolMarker for DiagnosticsMarker {}
1166
1167pub trait DiagnosticsProxyInterface: Send + Sync {
1168    type IterateIpResponseFut: std::future::Future<Output = Result<IterateIpResult, fidl::Error>>
1169        + Send;
1170    fn r#iterate_ip(
1171        &self,
1172        s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
1173        extensions: Extensions,
1174        matchers: &[IpSocketMatcher],
1175    ) -> Self::IterateIpResponseFut;
1176    type GetDestructionWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1177        + Send;
1178    fn r#get_destruction_watcher(
1179        &self,
1180        watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1181    ) -> Self::GetDestructionWatcherResponseFut;
1182}
1183#[derive(Debug)]
1184#[cfg(target_os = "fuchsia")]
1185pub struct DiagnosticsSynchronousProxy {
1186    client: fidl::client::sync::Client,
1187}
1188
1189#[cfg(target_os = "fuchsia")]
1190impl fidl::endpoints::SynchronousProxy for DiagnosticsSynchronousProxy {
1191    type Proxy = DiagnosticsProxy;
1192    type Protocol = DiagnosticsMarker;
1193
1194    fn from_channel(inner: fidl::Channel) -> Self {
1195        Self::new(inner)
1196    }
1197
1198    fn into_channel(self) -> fidl::Channel {
1199        self.client.into_channel()
1200    }
1201
1202    fn as_channel(&self) -> &fidl::Channel {
1203        self.client.as_channel()
1204    }
1205}
1206
1207#[cfg(target_os = "fuchsia")]
1208impl DiagnosticsSynchronousProxy {
1209    pub fn new(channel: fidl::Channel) -> Self {
1210        Self { client: fidl::client::sync::Client::new(channel) }
1211    }
1212
1213    pub fn into_channel(self) -> fidl::Channel {
1214        self.client.into_channel()
1215    }
1216
1217    /// Waits until an event arrives and returns it. It is safe for other
1218    /// threads to make concurrent requests while waiting for an event.
1219    pub fn wait_for_event(
1220        &self,
1221        deadline: zx::MonotonicInstant,
1222    ) -> Result<DiagnosticsEvent, fidl::Error> {
1223        DiagnosticsEvent::decode(self.client.wait_for_event::<DiagnosticsMarker>(deadline)?)
1224    }
1225
1226    /// Populates an iterator over all IP sockets that match the provided
1227    /// matchers.
1228    ///
1229    /// Unbound sockets are not returned.
1230    pub fn r#iterate_ip(
1231        &self,
1232        mut s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
1233        mut extensions: Extensions,
1234        mut matchers: &[IpSocketMatcher],
1235        ___deadline: zx::MonotonicInstant,
1236    ) -> Result<IterateIpResult, fidl::Error> {
1237        let _response = self
1238            .client
1239            .send_query::<DiagnosticsIterateIpRequest, IterateIpResult, DiagnosticsMarker>(
1240                (s, extensions, matchers),
1241                0x7b05425e48d07605,
1242                fidl::encoding::DynamicFlags::empty(),
1243                ___deadline,
1244            )?;
1245        Ok(_response)
1246    }
1247
1248    /// Creates a watcher for recently destroyed sockets.
1249    ///
1250    /// The watcher is guaranteed to be registered by the time the call returns.
1251    pub fn r#get_destruction_watcher(
1252        &self,
1253        mut watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1254        ___deadline: zx::MonotonicInstant,
1255    ) -> Result<(), fidl::Error> {
1256        let _response = self.client.send_query::<
1257            DiagnosticsGetDestructionWatcherRequest,
1258            fidl::encoding::EmptyPayload,
1259            DiagnosticsMarker,
1260        >(
1261            (watcher,),
1262            0x4b5d70a35a21964f,
1263            fidl::encoding::DynamicFlags::empty(),
1264            ___deadline,
1265        )?;
1266        Ok(_response)
1267    }
1268}
1269
1270#[cfg(target_os = "fuchsia")]
1271impl From<DiagnosticsSynchronousProxy> for zx::NullableHandle {
1272    fn from(value: DiagnosticsSynchronousProxy) -> Self {
1273        value.into_channel().into()
1274    }
1275}
1276
1277#[cfg(target_os = "fuchsia")]
1278impl From<fidl::Channel> for DiagnosticsSynchronousProxy {
1279    fn from(value: fidl::Channel) -> Self {
1280        Self::new(value)
1281    }
1282}
1283
1284#[cfg(target_os = "fuchsia")]
1285impl fidl::endpoints::FromClient for DiagnosticsSynchronousProxy {
1286    type Protocol = DiagnosticsMarker;
1287
1288    fn from_client(value: fidl::endpoints::ClientEnd<DiagnosticsMarker>) -> Self {
1289        Self::new(value.into_channel())
1290    }
1291}
1292
1293#[derive(Debug, Clone)]
1294pub struct DiagnosticsProxy {
1295    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1296}
1297
1298impl fidl::endpoints::Proxy for DiagnosticsProxy {
1299    type Protocol = DiagnosticsMarker;
1300
1301    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1302        Self::new(inner)
1303    }
1304
1305    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1306        self.client.into_channel().map_err(|client| Self { client })
1307    }
1308
1309    fn as_channel(&self) -> &::fidl::AsyncChannel {
1310        self.client.as_channel()
1311    }
1312}
1313
1314impl DiagnosticsProxy {
1315    /// Create a new Proxy for fuchsia.net.sockets/Diagnostics.
1316    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1317        let protocol_name = <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1318        Self { client: fidl::client::Client::new(channel, protocol_name) }
1319    }
1320
1321    /// Get a Stream of events from the remote end of the protocol.
1322    ///
1323    /// # Panics
1324    ///
1325    /// Panics if the event stream was already taken.
1326    pub fn take_event_stream(&self) -> DiagnosticsEventStream {
1327        DiagnosticsEventStream { event_receiver: self.client.take_event_receiver() }
1328    }
1329
1330    /// Populates an iterator over all IP sockets that match the provided
1331    /// matchers.
1332    ///
1333    /// Unbound sockets are not returned.
1334    pub fn r#iterate_ip(
1335        &self,
1336        mut s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
1337        mut extensions: Extensions,
1338        mut matchers: &[IpSocketMatcher],
1339    ) -> fidl::client::QueryResponseFut<
1340        IterateIpResult,
1341        fidl::encoding::DefaultFuchsiaResourceDialect,
1342    > {
1343        DiagnosticsProxyInterface::r#iterate_ip(self, s, extensions, matchers)
1344    }
1345
1346    /// Creates a watcher for recently destroyed sockets.
1347    ///
1348    /// The watcher is guaranteed to be registered by the time the call returns.
1349    pub fn r#get_destruction_watcher(
1350        &self,
1351        mut watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1352    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1353        DiagnosticsProxyInterface::r#get_destruction_watcher(self, watcher)
1354    }
1355}
1356
1357impl DiagnosticsProxyInterface for DiagnosticsProxy {
1358    type IterateIpResponseFut = fidl::client::QueryResponseFut<
1359        IterateIpResult,
1360        fidl::encoding::DefaultFuchsiaResourceDialect,
1361    >;
1362    fn r#iterate_ip(
1363        &self,
1364        mut s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
1365        mut extensions: Extensions,
1366        mut matchers: &[IpSocketMatcher],
1367    ) -> Self::IterateIpResponseFut {
1368        fn _decode(
1369            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1370        ) -> Result<IterateIpResult, fidl::Error> {
1371            let _response = fidl::client::decode_transaction_body::<
1372                IterateIpResult,
1373                fidl::encoding::DefaultFuchsiaResourceDialect,
1374                0x7b05425e48d07605,
1375            >(_buf?)?;
1376            Ok(_response)
1377        }
1378        self.client.send_query_and_decode::<DiagnosticsIterateIpRequest, IterateIpResult>(
1379            (s, extensions, matchers),
1380            0x7b05425e48d07605,
1381            fidl::encoding::DynamicFlags::empty(),
1382            _decode,
1383        )
1384    }
1385
1386    type GetDestructionWatcherResponseFut =
1387        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1388    fn r#get_destruction_watcher(
1389        &self,
1390        mut watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1391    ) -> Self::GetDestructionWatcherResponseFut {
1392        fn _decode(
1393            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1394        ) -> Result<(), fidl::Error> {
1395            let _response = fidl::client::decode_transaction_body::<
1396                fidl::encoding::EmptyPayload,
1397                fidl::encoding::DefaultFuchsiaResourceDialect,
1398                0x4b5d70a35a21964f,
1399            >(_buf?)?;
1400            Ok(_response)
1401        }
1402        self.client.send_query_and_decode::<DiagnosticsGetDestructionWatcherRequest, ()>(
1403            (watcher,),
1404            0x4b5d70a35a21964f,
1405            fidl::encoding::DynamicFlags::empty(),
1406            _decode,
1407        )
1408    }
1409}
1410
1411pub struct DiagnosticsEventStream {
1412    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1413}
1414
1415impl std::marker::Unpin for DiagnosticsEventStream {}
1416
1417impl futures::stream::FusedStream for DiagnosticsEventStream {
1418    fn is_terminated(&self) -> bool {
1419        self.event_receiver.is_terminated()
1420    }
1421}
1422
1423impl futures::Stream for DiagnosticsEventStream {
1424    type Item = Result<DiagnosticsEvent, fidl::Error>;
1425
1426    fn poll_next(
1427        mut self: std::pin::Pin<&mut Self>,
1428        cx: &mut std::task::Context<'_>,
1429    ) -> std::task::Poll<Option<Self::Item>> {
1430        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1431            &mut self.event_receiver,
1432            cx
1433        )?) {
1434            Some(buf) => std::task::Poll::Ready(Some(DiagnosticsEvent::decode(buf))),
1435            None => std::task::Poll::Ready(None),
1436        }
1437    }
1438}
1439
1440#[derive(Debug)]
1441pub enum DiagnosticsEvent {}
1442
1443impl DiagnosticsEvent {
1444    /// Decodes a message buffer as a [`DiagnosticsEvent`].
1445    fn decode(
1446        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1447    ) -> Result<DiagnosticsEvent, fidl::Error> {
1448        let (bytes, _handles) = buf.split_mut();
1449        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1450        debug_assert_eq!(tx_header.tx_id, 0);
1451        match tx_header.ordinal {
1452            _ => Err(fidl::Error::UnknownOrdinal {
1453                ordinal: tx_header.ordinal,
1454                protocol_name: <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1455            }),
1456        }
1457    }
1458}
1459
1460/// A Stream of incoming requests for fuchsia.net.sockets/Diagnostics.
1461pub struct DiagnosticsRequestStream {
1462    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1463    is_terminated: bool,
1464}
1465
1466impl std::marker::Unpin for DiagnosticsRequestStream {}
1467
1468impl futures::stream::FusedStream for DiagnosticsRequestStream {
1469    fn is_terminated(&self) -> bool {
1470        self.is_terminated
1471    }
1472}
1473
1474impl fidl::endpoints::RequestStream for DiagnosticsRequestStream {
1475    type Protocol = DiagnosticsMarker;
1476    type ControlHandle = DiagnosticsControlHandle;
1477
1478    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1479        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1480    }
1481
1482    fn control_handle(&self) -> Self::ControlHandle {
1483        DiagnosticsControlHandle { inner: self.inner.clone() }
1484    }
1485
1486    fn into_inner(
1487        self,
1488    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1489    {
1490        (self.inner, self.is_terminated)
1491    }
1492
1493    fn from_inner(
1494        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1495        is_terminated: bool,
1496    ) -> Self {
1497        Self { inner, is_terminated }
1498    }
1499}
1500
1501impl futures::Stream for DiagnosticsRequestStream {
1502    type Item = Result<DiagnosticsRequest, fidl::Error>;
1503
1504    fn poll_next(
1505        mut self: std::pin::Pin<&mut Self>,
1506        cx: &mut std::task::Context<'_>,
1507    ) -> std::task::Poll<Option<Self::Item>> {
1508        let this = &mut *self;
1509        if this.inner.check_shutdown(cx) {
1510            this.is_terminated = true;
1511            return std::task::Poll::Ready(None);
1512        }
1513        if this.is_terminated {
1514            panic!("polled DiagnosticsRequestStream after completion");
1515        }
1516        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1517            |bytes, handles| {
1518                match this.inner.channel().read_etc(cx, bytes, handles) {
1519                    std::task::Poll::Ready(Ok(())) => {}
1520                    std::task::Poll::Pending => return std::task::Poll::Pending,
1521                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1522                        this.is_terminated = true;
1523                        return std::task::Poll::Ready(None);
1524                    }
1525                    std::task::Poll::Ready(Err(e)) => {
1526                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1527                            e.into(),
1528                        ))));
1529                    }
1530                }
1531
1532                // A message has been received from the channel
1533                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1534
1535                std::task::Poll::Ready(Some(match header.ordinal {
1536                    0x7b05425e48d07605 => {
1537                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1538                        let mut req = fidl::new_empty!(
1539                            DiagnosticsIterateIpRequest,
1540                            fidl::encoding::DefaultFuchsiaResourceDialect
1541                        );
1542                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticsIterateIpRequest>(&header, _body_bytes, handles, &mut req)?;
1543                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
1544                        Ok(DiagnosticsRequest::IterateIp {
1545                            s: req.s,
1546                            extensions: req.extensions,
1547                            matchers: req.matchers,
1548
1549                            responder: DiagnosticsIterateIpResponder {
1550                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1551                                tx_id: header.tx_id,
1552                            },
1553                        })
1554                    }
1555                    0x4b5d70a35a21964f => {
1556                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1557                        let mut req = fidl::new_empty!(
1558                            DiagnosticsGetDestructionWatcherRequest,
1559                            fidl::encoding::DefaultFuchsiaResourceDialect
1560                        );
1561                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticsGetDestructionWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
1562                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
1563                        Ok(DiagnosticsRequest::GetDestructionWatcher {
1564                            watcher: req.watcher,
1565
1566                            responder: DiagnosticsGetDestructionWatcherResponder {
1567                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1568                                tx_id: header.tx_id,
1569                            },
1570                        })
1571                    }
1572                    _ => Err(fidl::Error::UnknownOrdinal {
1573                        ordinal: header.ordinal,
1574                        protocol_name:
1575                            <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1576                    }),
1577                }))
1578            },
1579        )
1580    }
1581}
1582
1583/// Provides diagnostic information IP sockets.
1584#[derive(Debug)]
1585pub enum DiagnosticsRequest {
1586    /// Populates an iterator over all IP sockets that match the provided
1587    /// matchers.
1588    ///
1589    /// Unbound sockets are not returned.
1590    IterateIp {
1591        s: fidl::endpoints::ServerEnd<IpIteratorMarker>,
1592        extensions: Extensions,
1593        matchers: Vec<IpSocketMatcher>,
1594        responder: DiagnosticsIterateIpResponder,
1595    },
1596    /// Creates a watcher for recently destroyed sockets.
1597    ///
1598    /// The watcher is guaranteed to be registered by the time the call returns.
1599    GetDestructionWatcher {
1600        watcher: fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1601        responder: DiagnosticsGetDestructionWatcherResponder,
1602    },
1603}
1604
1605impl DiagnosticsRequest {
1606    #[allow(irrefutable_let_patterns)]
1607    pub fn into_iterate_ip(
1608        self,
1609    ) -> Option<(
1610        fidl::endpoints::ServerEnd<IpIteratorMarker>,
1611        Extensions,
1612        Vec<IpSocketMatcher>,
1613        DiagnosticsIterateIpResponder,
1614    )> {
1615        if let DiagnosticsRequest::IterateIp { s, extensions, matchers, responder } = self {
1616            Some((s, extensions, matchers, responder))
1617        } else {
1618            None
1619        }
1620    }
1621
1622    #[allow(irrefutable_let_patterns)]
1623    pub fn into_get_destruction_watcher(
1624        self,
1625    ) -> Option<(
1626        fidl::endpoints::ServerEnd<DestructionWatcherMarker>,
1627        DiagnosticsGetDestructionWatcherResponder,
1628    )> {
1629        if let DiagnosticsRequest::GetDestructionWatcher { watcher, responder } = self {
1630            Some((watcher, responder))
1631        } else {
1632            None
1633        }
1634    }
1635
1636    /// Name of the method defined in FIDL
1637    pub fn method_name(&self) -> &'static str {
1638        match *self {
1639            DiagnosticsRequest::IterateIp { .. } => "iterate_ip",
1640            DiagnosticsRequest::GetDestructionWatcher { .. } => "get_destruction_watcher",
1641        }
1642    }
1643}
1644
1645#[derive(Debug, Clone)]
1646pub struct DiagnosticsControlHandle {
1647    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1648}
1649
1650impl fidl::endpoints::ControlHandle for DiagnosticsControlHandle {
1651    fn shutdown(&self) {
1652        self.inner.shutdown()
1653    }
1654
1655    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1656        self.inner.shutdown_with_epitaph(status)
1657    }
1658
1659    fn is_closed(&self) -> bool {
1660        self.inner.channel().is_closed()
1661    }
1662    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1663        self.inner.channel().on_closed()
1664    }
1665
1666    #[cfg(target_os = "fuchsia")]
1667    fn signal_peer(
1668        &self,
1669        clear_mask: zx::Signals,
1670        set_mask: zx::Signals,
1671    ) -> Result<(), zx_status::Status> {
1672        use fidl::Peered;
1673        self.inner.channel().signal_peer(clear_mask, set_mask)
1674    }
1675}
1676
1677impl DiagnosticsControlHandle {}
1678
1679#[must_use = "FIDL methods require a response to be sent"]
1680#[derive(Debug)]
1681pub struct DiagnosticsIterateIpResponder {
1682    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
1683    tx_id: u32,
1684}
1685
1686/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
1687/// if the responder is dropped without sending a response, so that the client
1688/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1689impl std::ops::Drop for DiagnosticsIterateIpResponder {
1690    fn drop(&mut self) {
1691        self.control_handle.shutdown();
1692        // Safety: drops once, never accessed again
1693        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1694    }
1695}
1696
1697impl fidl::endpoints::Responder for DiagnosticsIterateIpResponder {
1698    type ControlHandle = DiagnosticsControlHandle;
1699
1700    fn control_handle(&self) -> &DiagnosticsControlHandle {
1701        &self.control_handle
1702    }
1703
1704    fn drop_without_shutdown(mut self) {
1705        // Safety: drops once, never accessed again due to mem::forget
1706        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1707        // Prevent Drop from running (which would shut down the channel)
1708        std::mem::forget(self);
1709    }
1710}
1711
1712impl DiagnosticsIterateIpResponder {
1713    /// Sends a response to the FIDL transaction.
1714    ///
1715    /// Sets the channel to shutdown if an error occurs.
1716    pub fn send(self, mut payload: &IterateIpResult) -> Result<(), fidl::Error> {
1717        let _result = self.send_raw(payload);
1718        if _result.is_err() {
1719            self.control_handle.shutdown();
1720        }
1721        self.drop_without_shutdown();
1722        _result
1723    }
1724
1725    /// Similar to "send" but does not shutdown the channel if an error occurs.
1726    pub fn send_no_shutdown_on_err(self, mut payload: &IterateIpResult) -> Result<(), fidl::Error> {
1727        let _result = self.send_raw(payload);
1728        self.drop_without_shutdown();
1729        _result
1730    }
1731
1732    fn send_raw(&self, mut payload: &IterateIpResult) -> Result<(), fidl::Error> {
1733        self.control_handle.inner.send::<IterateIpResult>(
1734            payload,
1735            self.tx_id,
1736            0x7b05425e48d07605,
1737            fidl::encoding::DynamicFlags::empty(),
1738        )
1739    }
1740}
1741
1742#[must_use = "FIDL methods require a response to be sent"]
1743#[derive(Debug)]
1744pub struct DiagnosticsGetDestructionWatcherResponder {
1745    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
1746    tx_id: u32,
1747}
1748
1749/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
1750/// if the responder is dropped without sending a response, so that the client
1751/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1752impl std::ops::Drop for DiagnosticsGetDestructionWatcherResponder {
1753    fn drop(&mut self) {
1754        self.control_handle.shutdown();
1755        // Safety: drops once, never accessed again
1756        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1757    }
1758}
1759
1760impl fidl::endpoints::Responder for DiagnosticsGetDestructionWatcherResponder {
1761    type ControlHandle = DiagnosticsControlHandle;
1762
1763    fn control_handle(&self) -> &DiagnosticsControlHandle {
1764        &self.control_handle
1765    }
1766
1767    fn drop_without_shutdown(mut self) {
1768        // Safety: drops once, never accessed again due to mem::forget
1769        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1770        // Prevent Drop from running (which would shut down the channel)
1771        std::mem::forget(self);
1772    }
1773}
1774
1775impl DiagnosticsGetDestructionWatcherResponder {
1776    /// Sends a response to the FIDL transaction.
1777    ///
1778    /// Sets the channel to shutdown if an error occurs.
1779    pub fn send(self) -> Result<(), fidl::Error> {
1780        let _result = self.send_raw();
1781        if _result.is_err() {
1782            self.control_handle.shutdown();
1783        }
1784        self.drop_without_shutdown();
1785        _result
1786    }
1787
1788    /// Similar to "send" but does not shutdown the channel if an error occurs.
1789    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1790        let _result = self.send_raw();
1791        self.drop_without_shutdown();
1792        _result
1793    }
1794
1795    fn send_raw(&self) -> Result<(), fidl::Error> {
1796        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1797            (),
1798            self.tx_id,
1799            0x4b5d70a35a21964f,
1800            fidl::encoding::DynamicFlags::empty(),
1801        )
1802    }
1803}
1804
1805#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1806pub struct IpIteratorMarker;
1807
1808impl fidl::endpoints::ProtocolMarker for IpIteratorMarker {
1809    type Proxy = IpIteratorProxy;
1810    type RequestStream = IpIteratorRequestStream;
1811    #[cfg(target_os = "fuchsia")]
1812    type SynchronousProxy = IpIteratorSynchronousProxy;
1813
1814    const DEBUG_NAME: &'static str = "(anonymous) IpIterator";
1815}
1816
1817pub trait IpIteratorProxyInterface: Send + Sync {
1818    type NextResponseFut: std::future::Future<Output = Result<(Vec<IpSocketState>, bool), fidl::Error>>
1819        + Send;
1820    fn r#next(&self) -> Self::NextResponseFut;
1821}
1822#[derive(Debug)]
1823#[cfg(target_os = "fuchsia")]
1824pub struct IpIteratorSynchronousProxy {
1825    client: fidl::client::sync::Client,
1826}
1827
1828#[cfg(target_os = "fuchsia")]
1829impl fidl::endpoints::SynchronousProxy for IpIteratorSynchronousProxy {
1830    type Proxy = IpIteratorProxy;
1831    type Protocol = IpIteratorMarker;
1832
1833    fn from_channel(inner: fidl::Channel) -> Self {
1834        Self::new(inner)
1835    }
1836
1837    fn into_channel(self) -> fidl::Channel {
1838        self.client.into_channel()
1839    }
1840
1841    fn as_channel(&self) -> &fidl::Channel {
1842        self.client.as_channel()
1843    }
1844}
1845
1846#[cfg(target_os = "fuchsia")]
1847impl IpIteratorSynchronousProxy {
1848    pub fn new(channel: fidl::Channel) -> Self {
1849        Self { client: fidl::client::sync::Client::new(channel) }
1850    }
1851
1852    pub fn into_channel(self) -> fidl::Channel {
1853        self.client.into_channel()
1854    }
1855
1856    /// Waits until an event arrives and returns it. It is safe for other
1857    /// threads to make concurrent requests while waiting for an event.
1858    pub fn wait_for_event(
1859        &self,
1860        deadline: zx::MonotonicInstant,
1861    ) -> Result<IpIteratorEvent, fidl::Error> {
1862        IpIteratorEvent::decode(self.client.wait_for_event::<IpIteratorMarker>(deadline)?)
1863    }
1864
1865    /// Call repeatedly to stream results for a previous request to
1866    /// `Diagnostics.IterateIp`.
1867    ///
1868    /// A caller must make sure to retrieve sockets in a timely manner, or the
1869    /// connection may be closed with `TIMED_OUT`.
1870    ///
1871    /// NOTE: The returned sockets do not provide a consistent snapshot of the
1872    /// system. For example, you should never use the state of one socket to
1873    /// infer what the state of another socket will be, since modifications
1874    /// could have occurred in between results for each socket being
1875    /// materialized.
1876    pub fn r#next(
1877        &self,
1878        ___deadline: zx::MonotonicInstant,
1879    ) -> Result<(Vec<IpSocketState>, bool), fidl::Error> {
1880        let _response = self
1881            .client
1882            .send_query::<fidl::encoding::EmptyPayload, IpIteratorNextResponse, IpIteratorMarker>(
1883                (),
1884                0x3d50aa08ce641a6b,
1885                fidl::encoding::DynamicFlags::empty(),
1886                ___deadline,
1887            )?;
1888        Ok((_response.sockets, _response.has_more))
1889    }
1890}
1891
1892#[cfg(target_os = "fuchsia")]
1893impl From<IpIteratorSynchronousProxy> for zx::NullableHandle {
1894    fn from(value: IpIteratorSynchronousProxy) -> Self {
1895        value.into_channel().into()
1896    }
1897}
1898
1899#[cfg(target_os = "fuchsia")]
1900impl From<fidl::Channel> for IpIteratorSynchronousProxy {
1901    fn from(value: fidl::Channel) -> Self {
1902        Self::new(value)
1903    }
1904}
1905
1906#[cfg(target_os = "fuchsia")]
1907impl fidl::endpoints::FromClient for IpIteratorSynchronousProxy {
1908    type Protocol = IpIteratorMarker;
1909
1910    fn from_client(value: fidl::endpoints::ClientEnd<IpIteratorMarker>) -> Self {
1911        Self::new(value.into_channel())
1912    }
1913}
1914
1915#[derive(Debug, Clone)]
1916pub struct IpIteratorProxy {
1917    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1918}
1919
1920impl fidl::endpoints::Proxy for IpIteratorProxy {
1921    type Protocol = IpIteratorMarker;
1922
1923    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1924        Self::new(inner)
1925    }
1926
1927    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1928        self.client.into_channel().map_err(|client| Self { client })
1929    }
1930
1931    fn as_channel(&self) -> &::fidl::AsyncChannel {
1932        self.client.as_channel()
1933    }
1934}
1935
1936impl IpIteratorProxy {
1937    /// Create a new Proxy for fuchsia.net.sockets/IpIterator.
1938    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1939        let protocol_name = <IpIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1940        Self { client: fidl::client::Client::new(channel, protocol_name) }
1941    }
1942
1943    /// Get a Stream of events from the remote end of the protocol.
1944    ///
1945    /// # Panics
1946    ///
1947    /// Panics if the event stream was already taken.
1948    pub fn take_event_stream(&self) -> IpIteratorEventStream {
1949        IpIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1950    }
1951
1952    /// Call repeatedly to stream results for a previous request to
1953    /// `Diagnostics.IterateIp`.
1954    ///
1955    /// A caller must make sure to retrieve sockets in a timely manner, or the
1956    /// connection may be closed with `TIMED_OUT`.
1957    ///
1958    /// NOTE: The returned sockets do not provide a consistent snapshot of the
1959    /// system. For example, you should never use the state of one socket to
1960    /// infer what the state of another socket will be, since modifications
1961    /// could have occurred in between results for each socket being
1962    /// materialized.
1963    pub fn r#next(
1964        &self,
1965    ) -> fidl::client::QueryResponseFut<
1966        (Vec<IpSocketState>, bool),
1967        fidl::encoding::DefaultFuchsiaResourceDialect,
1968    > {
1969        IpIteratorProxyInterface::r#next(self)
1970    }
1971}
1972
1973impl IpIteratorProxyInterface for IpIteratorProxy {
1974    type NextResponseFut = fidl::client::QueryResponseFut<
1975        (Vec<IpSocketState>, bool),
1976        fidl::encoding::DefaultFuchsiaResourceDialect,
1977    >;
1978    fn r#next(&self) -> Self::NextResponseFut {
1979        fn _decode(
1980            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1981        ) -> Result<(Vec<IpSocketState>, bool), fidl::Error> {
1982            let _response = fidl::client::decode_transaction_body::<
1983                IpIteratorNextResponse,
1984                fidl::encoding::DefaultFuchsiaResourceDialect,
1985                0x3d50aa08ce641a6b,
1986            >(_buf?)?;
1987            Ok((_response.sockets, _response.has_more))
1988        }
1989        self.client
1990            .send_query_and_decode::<fidl::encoding::EmptyPayload, (Vec<IpSocketState>, bool)>(
1991                (),
1992                0x3d50aa08ce641a6b,
1993                fidl::encoding::DynamicFlags::empty(),
1994                _decode,
1995            )
1996    }
1997}
1998
1999pub struct IpIteratorEventStream {
2000    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2001}
2002
2003impl std::marker::Unpin for IpIteratorEventStream {}
2004
2005impl futures::stream::FusedStream for IpIteratorEventStream {
2006    fn is_terminated(&self) -> bool {
2007        self.event_receiver.is_terminated()
2008    }
2009}
2010
2011impl futures::Stream for IpIteratorEventStream {
2012    type Item = Result<IpIteratorEvent, fidl::Error>;
2013
2014    fn poll_next(
2015        mut self: std::pin::Pin<&mut Self>,
2016        cx: &mut std::task::Context<'_>,
2017    ) -> std::task::Poll<Option<Self::Item>> {
2018        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2019            &mut self.event_receiver,
2020            cx
2021        )?) {
2022            Some(buf) => std::task::Poll::Ready(Some(IpIteratorEvent::decode(buf))),
2023            None => std::task::Poll::Ready(None),
2024        }
2025    }
2026}
2027
2028#[derive(Debug)]
2029pub enum IpIteratorEvent {
2030    #[non_exhaustive]
2031    _UnknownEvent {
2032        /// Ordinal of the event that was sent.
2033        ordinal: u64,
2034    },
2035}
2036
2037impl IpIteratorEvent {
2038    /// Decodes a message buffer as a [`IpIteratorEvent`].
2039    fn decode(
2040        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2041    ) -> Result<IpIteratorEvent, fidl::Error> {
2042        let (bytes, _handles) = buf.split_mut();
2043        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2044        debug_assert_eq!(tx_header.tx_id, 0);
2045        match tx_header.ordinal {
2046            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2047                Ok(IpIteratorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2048            }
2049            _ => Err(fidl::Error::UnknownOrdinal {
2050                ordinal: tx_header.ordinal,
2051                protocol_name: <IpIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2052            }),
2053        }
2054    }
2055}
2056
2057/// A Stream of incoming requests for fuchsia.net.sockets/IpIterator.
2058pub struct IpIteratorRequestStream {
2059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2060    is_terminated: bool,
2061}
2062
2063impl std::marker::Unpin for IpIteratorRequestStream {}
2064
2065impl futures::stream::FusedStream for IpIteratorRequestStream {
2066    fn is_terminated(&self) -> bool {
2067        self.is_terminated
2068    }
2069}
2070
2071impl fidl::endpoints::RequestStream for IpIteratorRequestStream {
2072    type Protocol = IpIteratorMarker;
2073    type ControlHandle = IpIteratorControlHandle;
2074
2075    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2076        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2077    }
2078
2079    fn control_handle(&self) -> Self::ControlHandle {
2080        IpIteratorControlHandle { inner: self.inner.clone() }
2081    }
2082
2083    fn into_inner(
2084        self,
2085    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2086    {
2087        (self.inner, self.is_terminated)
2088    }
2089
2090    fn from_inner(
2091        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2092        is_terminated: bool,
2093    ) -> Self {
2094        Self { inner, is_terminated }
2095    }
2096}
2097
2098impl futures::Stream for IpIteratorRequestStream {
2099    type Item = Result<IpIteratorRequest, fidl::Error>;
2100
2101    fn poll_next(
2102        mut self: std::pin::Pin<&mut Self>,
2103        cx: &mut std::task::Context<'_>,
2104    ) -> std::task::Poll<Option<Self::Item>> {
2105        let this = &mut *self;
2106        if this.inner.check_shutdown(cx) {
2107            this.is_terminated = true;
2108            return std::task::Poll::Ready(None);
2109        }
2110        if this.is_terminated {
2111            panic!("polled IpIteratorRequestStream after completion");
2112        }
2113        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2114            |bytes, handles| {
2115                match this.inner.channel().read_etc(cx, bytes, handles) {
2116                    std::task::Poll::Ready(Ok(())) => {}
2117                    std::task::Poll::Pending => return std::task::Poll::Pending,
2118                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2119                        this.is_terminated = true;
2120                        return std::task::Poll::Ready(None);
2121                    }
2122                    std::task::Poll::Ready(Err(e)) => {
2123                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2124                            e.into(),
2125                        ))));
2126                    }
2127                }
2128
2129                // A message has been received from the channel
2130                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2131
2132                std::task::Poll::Ready(Some(match header.ordinal {
2133                    0x3d50aa08ce641a6b => {
2134                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2135                        let mut req = fidl::new_empty!(
2136                            fidl::encoding::EmptyPayload,
2137                            fidl::encoding::DefaultFuchsiaResourceDialect
2138                        );
2139                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2140                        let control_handle = IpIteratorControlHandle { inner: this.inner.clone() };
2141                        Ok(IpIteratorRequest::Next {
2142                            responder: IpIteratorNextResponder {
2143                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2144                                tx_id: header.tx_id,
2145                            },
2146                        })
2147                    }
2148                    _ if header.tx_id == 0
2149                        && header
2150                            .dynamic_flags()
2151                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2152                    {
2153                        Ok(IpIteratorRequest::_UnknownMethod {
2154                            ordinal: header.ordinal,
2155                            control_handle: IpIteratorControlHandle { inner: this.inner.clone() },
2156                            method_type: fidl::MethodType::OneWay,
2157                        })
2158                    }
2159                    _ if header
2160                        .dynamic_flags()
2161                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2162                    {
2163                        this.inner.send_framework_err(
2164                            fidl::encoding::FrameworkErr::UnknownMethod,
2165                            header.tx_id,
2166                            header.ordinal,
2167                            header.dynamic_flags(),
2168                            (bytes, handles),
2169                        )?;
2170                        Ok(IpIteratorRequest::_UnknownMethod {
2171                            ordinal: header.ordinal,
2172                            control_handle: IpIteratorControlHandle { inner: this.inner.clone() },
2173                            method_type: fidl::MethodType::TwoWay,
2174                        })
2175                    }
2176                    _ => Err(fidl::Error::UnknownOrdinal {
2177                        ordinal: header.ordinal,
2178                        protocol_name:
2179                            <IpIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2180                    }),
2181                }))
2182            },
2183        )
2184    }
2185}
2186
2187/// Provides sockets as a response to a call to `Diagnostics.IterateIp`.
2188#[derive(Debug)]
2189pub enum IpIteratorRequest {
2190    /// Call repeatedly to stream results for a previous request to
2191    /// `Diagnostics.IterateIp`.
2192    ///
2193    /// A caller must make sure to retrieve sockets in a timely manner, or the
2194    /// connection may be closed with `TIMED_OUT`.
2195    ///
2196    /// NOTE: The returned sockets do not provide a consistent snapshot of the
2197    /// system. For example, you should never use the state of one socket to
2198    /// infer what the state of another socket will be, since modifications
2199    /// could have occurred in between results for each socket being
2200    /// materialized.
2201    Next { responder: IpIteratorNextResponder },
2202    /// An interaction was received which does not match any known method.
2203    #[non_exhaustive]
2204    _UnknownMethod {
2205        /// Ordinal of the method that was called.
2206        ordinal: u64,
2207        control_handle: IpIteratorControlHandle,
2208        method_type: fidl::MethodType,
2209    },
2210}
2211
2212impl IpIteratorRequest {
2213    #[allow(irrefutable_let_patterns)]
2214    pub fn into_next(self) -> Option<(IpIteratorNextResponder)> {
2215        if let IpIteratorRequest::Next { responder } = self { Some((responder)) } else { None }
2216    }
2217
2218    /// Name of the method defined in FIDL
2219    pub fn method_name(&self) -> &'static str {
2220        match *self {
2221            IpIteratorRequest::Next { .. } => "next",
2222            IpIteratorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2223                "unknown one-way method"
2224            }
2225            IpIteratorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2226                "unknown two-way method"
2227            }
2228        }
2229    }
2230}
2231
2232#[derive(Debug, Clone)]
2233pub struct IpIteratorControlHandle {
2234    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2235}
2236
2237impl fidl::endpoints::ControlHandle for IpIteratorControlHandle {
2238    fn shutdown(&self) {
2239        self.inner.shutdown()
2240    }
2241
2242    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2243        self.inner.shutdown_with_epitaph(status)
2244    }
2245
2246    fn is_closed(&self) -> bool {
2247        self.inner.channel().is_closed()
2248    }
2249    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2250        self.inner.channel().on_closed()
2251    }
2252
2253    #[cfg(target_os = "fuchsia")]
2254    fn signal_peer(
2255        &self,
2256        clear_mask: zx::Signals,
2257        set_mask: zx::Signals,
2258    ) -> Result<(), zx_status::Status> {
2259        use fidl::Peered;
2260        self.inner.channel().signal_peer(clear_mask, set_mask)
2261    }
2262}
2263
2264impl IpIteratorControlHandle {}
2265
2266#[must_use = "FIDL methods require a response to be sent"]
2267#[derive(Debug)]
2268pub struct IpIteratorNextResponder {
2269    control_handle: std::mem::ManuallyDrop<IpIteratorControlHandle>,
2270    tx_id: u32,
2271}
2272
2273/// Set the the channel to be shutdown (see [`IpIteratorControlHandle::shutdown`])
2274/// if the responder is dropped without sending a response, so that the client
2275/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2276impl std::ops::Drop for IpIteratorNextResponder {
2277    fn drop(&mut self) {
2278        self.control_handle.shutdown();
2279        // Safety: drops once, never accessed again
2280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2281    }
2282}
2283
2284impl fidl::endpoints::Responder for IpIteratorNextResponder {
2285    type ControlHandle = IpIteratorControlHandle;
2286
2287    fn control_handle(&self) -> &IpIteratorControlHandle {
2288        &self.control_handle
2289    }
2290
2291    fn drop_without_shutdown(mut self) {
2292        // Safety: drops once, never accessed again due to mem::forget
2293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2294        // Prevent Drop from running (which would shut down the channel)
2295        std::mem::forget(self);
2296    }
2297}
2298
2299impl IpIteratorNextResponder {
2300    /// Sends a response to the FIDL transaction.
2301    ///
2302    /// Sets the channel to shutdown if an error occurs.
2303    pub fn send(
2304        self,
2305        mut sockets: &[IpSocketState],
2306        mut has_more: bool,
2307    ) -> Result<(), fidl::Error> {
2308        let _result = self.send_raw(sockets, has_more);
2309        if _result.is_err() {
2310            self.control_handle.shutdown();
2311        }
2312        self.drop_without_shutdown();
2313        _result
2314    }
2315
2316    /// Similar to "send" but does not shutdown the channel if an error occurs.
2317    pub fn send_no_shutdown_on_err(
2318        self,
2319        mut sockets: &[IpSocketState],
2320        mut has_more: bool,
2321    ) -> Result<(), fidl::Error> {
2322        let _result = self.send_raw(sockets, has_more);
2323        self.drop_without_shutdown();
2324        _result
2325    }
2326
2327    fn send_raw(
2328        &self,
2329        mut sockets: &[IpSocketState],
2330        mut has_more: bool,
2331    ) -> Result<(), fidl::Error> {
2332        self.control_handle.inner.send::<IpIteratorNextResponse>(
2333            (sockets, has_more),
2334            self.tx_id,
2335            0x3d50aa08ce641a6b,
2336            fidl::encoding::DynamicFlags::empty(),
2337        )
2338    }
2339}
2340
2341mod internal {
2342    use super::*;
2343
2344    impl fidl::encoding::ResourceTypeMarker for DiagnosticsGetDestructionWatcherRequest {
2345        type Borrowed<'a> = &'a mut Self;
2346        fn take_or_borrow<'a>(
2347            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2348        ) -> Self::Borrowed<'a> {
2349            value
2350        }
2351    }
2352
2353    unsafe impl fidl::encoding::TypeMarker for DiagnosticsGetDestructionWatcherRequest {
2354        type Owned = Self;
2355
2356        #[inline(always)]
2357        fn inline_align(_context: fidl::encoding::Context) -> usize {
2358            4
2359        }
2360
2361        #[inline(always)]
2362        fn inline_size(_context: fidl::encoding::Context) -> usize {
2363            4
2364        }
2365    }
2366
2367    unsafe impl
2368        fidl::encoding::Encode<
2369            DiagnosticsGetDestructionWatcherRequest,
2370            fidl::encoding::DefaultFuchsiaResourceDialect,
2371        > for &mut DiagnosticsGetDestructionWatcherRequest
2372    {
2373        #[inline]
2374        unsafe fn encode(
2375            self,
2376            encoder: &mut fidl::encoding::Encoder<
2377                '_,
2378                fidl::encoding::DefaultFuchsiaResourceDialect,
2379            >,
2380            offset: usize,
2381            _depth: fidl::encoding::Depth,
2382        ) -> fidl::Result<()> {
2383            encoder.debug_check_bounds::<DiagnosticsGetDestructionWatcherRequest>(offset);
2384            // Delegate to tuple encoding.
2385            fidl::encoding::Encode::<DiagnosticsGetDestructionWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2386                (
2387                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DestructionWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
2388                ),
2389                encoder, offset, _depth
2390            )
2391        }
2392    }
2393    unsafe impl<
2394        T0: fidl::encoding::Encode<
2395                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DestructionWatcherMarker>>,
2396                fidl::encoding::DefaultFuchsiaResourceDialect,
2397            >,
2398    >
2399        fidl::encoding::Encode<
2400            DiagnosticsGetDestructionWatcherRequest,
2401            fidl::encoding::DefaultFuchsiaResourceDialect,
2402        > for (T0,)
2403    {
2404        #[inline]
2405        unsafe fn encode(
2406            self,
2407            encoder: &mut fidl::encoding::Encoder<
2408                '_,
2409                fidl::encoding::DefaultFuchsiaResourceDialect,
2410            >,
2411            offset: usize,
2412            depth: fidl::encoding::Depth,
2413        ) -> fidl::Result<()> {
2414            encoder.debug_check_bounds::<DiagnosticsGetDestructionWatcherRequest>(offset);
2415            // Zero out padding regions. There's no need to apply masks
2416            // because the unmasked parts will be overwritten by fields.
2417            // Write the fields.
2418            self.0.encode(encoder, offset + 0, depth)?;
2419            Ok(())
2420        }
2421    }
2422
2423    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2424        for DiagnosticsGetDestructionWatcherRequest
2425    {
2426        #[inline(always)]
2427        fn new_empty() -> Self {
2428            Self {
2429                watcher: fidl::new_empty!(
2430                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DestructionWatcherMarker>>,
2431                    fidl::encoding::DefaultFuchsiaResourceDialect
2432                ),
2433            }
2434        }
2435
2436        #[inline]
2437        unsafe fn decode(
2438            &mut self,
2439            decoder: &mut fidl::encoding::Decoder<
2440                '_,
2441                fidl::encoding::DefaultFuchsiaResourceDialect,
2442            >,
2443            offset: usize,
2444            _depth: fidl::encoding::Depth,
2445        ) -> fidl::Result<()> {
2446            decoder.debug_check_bounds::<Self>(offset);
2447            // Verify that padding bytes are zero.
2448            fidl::decode!(
2449                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DestructionWatcherMarker>>,
2450                fidl::encoding::DefaultFuchsiaResourceDialect,
2451                &mut self.watcher,
2452                decoder,
2453                offset + 0,
2454                _depth
2455            )?;
2456            Ok(())
2457        }
2458    }
2459
2460    impl fidl::encoding::ResourceTypeMarker for DiagnosticsIterateIpRequest {
2461        type Borrowed<'a> = &'a mut Self;
2462        fn take_or_borrow<'a>(
2463            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2464        ) -> Self::Borrowed<'a> {
2465            value
2466        }
2467    }
2468
2469    unsafe impl fidl::encoding::TypeMarker for DiagnosticsIterateIpRequest {
2470        type Owned = Self;
2471
2472        #[inline(always)]
2473        fn inline_align(_context: fidl::encoding::Context) -> usize {
2474            8
2475        }
2476
2477        #[inline(always)]
2478        fn inline_size(_context: fidl::encoding::Context) -> usize {
2479            24
2480        }
2481    }
2482
2483    unsafe impl
2484        fidl::encoding::Encode<
2485            DiagnosticsIterateIpRequest,
2486            fidl::encoding::DefaultFuchsiaResourceDialect,
2487        > for &mut DiagnosticsIterateIpRequest
2488    {
2489        #[inline]
2490        unsafe fn encode(
2491            self,
2492            encoder: &mut fidl::encoding::Encoder<
2493                '_,
2494                fidl::encoding::DefaultFuchsiaResourceDialect,
2495            >,
2496            offset: usize,
2497            _depth: fidl::encoding::Depth,
2498        ) -> fidl::Result<()> {
2499            encoder.debug_check_bounds::<DiagnosticsIterateIpRequest>(offset);
2500            // Delegate to tuple encoding.
2501            fidl::encoding::Encode::<DiagnosticsIterateIpRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2502                (
2503                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IpIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.s),
2504                    <Extensions as fidl::encoding::ValueTypeMarker>::borrow(&self.extensions),
2505                    <fidl::encoding::Vector<IpSocketMatcher, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.matchers),
2506                ),
2507                encoder, offset, _depth
2508            )
2509        }
2510    }
2511    unsafe impl<
2512        T0: fidl::encoding::Encode<
2513                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IpIteratorMarker>>,
2514                fidl::encoding::DefaultFuchsiaResourceDialect,
2515            >,
2516        T1: fidl::encoding::Encode<Extensions, fidl::encoding::DefaultFuchsiaResourceDialect>,
2517        T2: fidl::encoding::Encode<
2518                fidl::encoding::Vector<IpSocketMatcher, 128>,
2519                fidl::encoding::DefaultFuchsiaResourceDialect,
2520            >,
2521    >
2522        fidl::encoding::Encode<
2523            DiagnosticsIterateIpRequest,
2524            fidl::encoding::DefaultFuchsiaResourceDialect,
2525        > for (T0, T1, T2)
2526    {
2527        #[inline]
2528        unsafe fn encode(
2529            self,
2530            encoder: &mut fidl::encoding::Encoder<
2531                '_,
2532                fidl::encoding::DefaultFuchsiaResourceDialect,
2533            >,
2534            offset: usize,
2535            depth: fidl::encoding::Depth,
2536        ) -> fidl::Result<()> {
2537            encoder.debug_check_bounds::<DiagnosticsIterateIpRequest>(offset);
2538            // Zero out padding regions. There's no need to apply masks
2539            // because the unmasked parts will be overwritten by fields.
2540            // Write the fields.
2541            self.0.encode(encoder, offset + 0, depth)?;
2542            self.1.encode(encoder, offset + 4, depth)?;
2543            self.2.encode(encoder, offset + 8, depth)?;
2544            Ok(())
2545        }
2546    }
2547
2548    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2549        for DiagnosticsIterateIpRequest
2550    {
2551        #[inline(always)]
2552        fn new_empty() -> Self {
2553            Self {
2554                s: fidl::new_empty!(
2555                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IpIteratorMarker>>,
2556                    fidl::encoding::DefaultFuchsiaResourceDialect
2557                ),
2558                extensions: fidl::new_empty!(
2559                    Extensions,
2560                    fidl::encoding::DefaultFuchsiaResourceDialect
2561                ),
2562                matchers: fidl::new_empty!(fidl::encoding::Vector<IpSocketMatcher, 128>, fidl::encoding::DefaultFuchsiaResourceDialect),
2563            }
2564        }
2565
2566        #[inline]
2567        unsafe fn decode(
2568            &mut self,
2569            decoder: &mut fidl::encoding::Decoder<
2570                '_,
2571                fidl::encoding::DefaultFuchsiaResourceDialect,
2572            >,
2573            offset: usize,
2574            _depth: fidl::encoding::Depth,
2575        ) -> fidl::Result<()> {
2576            decoder.debug_check_bounds::<Self>(offset);
2577            // Verify that padding bytes are zero.
2578            fidl::decode!(
2579                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IpIteratorMarker>>,
2580                fidl::encoding::DefaultFuchsiaResourceDialect,
2581                &mut self.s,
2582                decoder,
2583                offset + 0,
2584                _depth
2585            )?;
2586            fidl::decode!(
2587                Extensions,
2588                fidl::encoding::DefaultFuchsiaResourceDialect,
2589                &mut self.extensions,
2590                decoder,
2591                offset + 4,
2592                _depth
2593            )?;
2594            fidl::decode!(fidl::encoding::Vector<IpSocketMatcher, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.matchers, decoder, offset + 8, _depth)?;
2595            Ok(())
2596        }
2597    }
2598}