Skip to main content

fidl_fuchsia_net_debug/
fidl_fuchsia_net_debug.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_debug__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DiagnosticsGetProcessHandleForInspectionResponse {
16    pub process: fidl::Process,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DiagnosticsGetProcessHandleForInspectionResponse
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct InterfacesGetPortRequest {
26    pub id: u64,
27    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InterfacesGetPortRequest {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct PacketCaptureProviderReconnectRollingRequest {
34    /// A name previously passed to [`RollingPacketCapture/Detach`]
35    /// that identifies this packet capture.
36    pub name: String,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for PacketCaptureProviderReconnectRollingRequest
41{
42}
43
44#[derive(Debug, PartialEq)]
45pub struct PacketCaptureProviderStartRollingRequest {
46    pub common_params: CommonPacketCaptureParams,
47    pub params: RollingPacketCaptureParams,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
51    for PacketCaptureProviderStartRollingRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct PacketCaptureProviderReconnectRollingResponse {
57    pub channel: fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61    for PacketCaptureProviderReconnectRollingResponse
62{
63}
64
65#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66pub struct PacketCaptureProviderStartRollingResponse {
67    pub channel: fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
71    for PacketCaptureProviderStartRollingResponse
72{
73}
74
75#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
76pub struct RollingPacketCaptureStopAndDownloadRequest {
77    /// Channel over which the client can download the packet capture. The
78    /// file is always read-only.
79    pub channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
80}
81
82impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
83    for RollingPacketCaptureStopAndDownloadRequest
84{
85}
86
87/// Parameters common to all packet capturing modes.
88#[derive(Debug, Default, PartialEq)]
89pub struct CommonPacketCaptureParams {
90    /// Which interface(s) to capture on.
91    ///
92    /// Required.
93    pub interfaces: Option<InterfaceSpecifier>,
94    /// eBPF program for deciding which packets are included in
95    /// the capture. The program must not make use of any eBPF-only
96    /// features not present in cBPF. The program must be of type
97    /// BPF_PROG_TYPE_SOCKET_FILTER and have been verified as such.
98    ///
99    /// Optional.
100    pub bpf_program: Option<fidl_fuchsia_ebpf::VerifiedProgram>,
101    /// Number of bytes from the start of each packet to save in the capture.
102    /// Truncation only happens at the end of the packet, no headers are skipped.
103    ///
104    /// Optional, [`DEFAULT_SNAP_LEN`] is used if absent or 0 is passed.
105    pub snap_len: Option<u32>,
106    #[doc(hidden)]
107    pub __source_breaking: fidl::marker::SourceBreaking,
108}
109
110impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommonPacketCaptureParams {}
111
112#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
113pub struct DiagnosticsMarker;
114
115impl fidl::endpoints::ProtocolMarker for DiagnosticsMarker {
116    type Proxy = DiagnosticsProxy;
117    type RequestStream = DiagnosticsRequestStream;
118    #[cfg(target_os = "fuchsia")]
119    type SynchronousProxy = DiagnosticsSynchronousProxy;
120
121    const DEBUG_NAME: &'static str = "fuchsia.net.debug.Diagnostics";
122}
123impl fidl::endpoints::DiscoverableProtocolMarker for DiagnosticsMarker {}
124
125pub trait DiagnosticsProxyInterface: Send + Sync {
126    type LogDebugInfoToSyslogResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
127        + Send;
128    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut;
129    type GetProcessHandleForInspectionResponseFut: std::future::Future<Output = Result<fidl::Process, fidl::Error>>
130        + Send;
131    fn r#get_process_handle_for_inspection(&self)
132    -> Self::GetProcessHandleForInspectionResponseFut;
133}
134#[derive(Debug)]
135#[cfg(target_os = "fuchsia")]
136pub struct DiagnosticsSynchronousProxy {
137    client: fidl::client::sync::Client,
138}
139
140#[cfg(target_os = "fuchsia")]
141impl fidl::endpoints::SynchronousProxy for DiagnosticsSynchronousProxy {
142    type Proxy = DiagnosticsProxy;
143    type Protocol = DiagnosticsMarker;
144
145    fn from_channel(inner: fidl::Channel) -> Self {
146        Self::new(inner)
147    }
148
149    fn into_channel(self) -> fidl::Channel {
150        self.client.into_channel()
151    }
152
153    fn as_channel(&self) -> &fidl::Channel {
154        self.client.as_channel()
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl DiagnosticsSynchronousProxy {
160    pub fn new(channel: fidl::Channel) -> Self {
161        Self { client: fidl::client::sync::Client::new(channel) }
162    }
163
164    pub fn into_channel(self) -> fidl::Channel {
165        self.client.into_channel()
166    }
167
168    /// Waits until an event arrives and returns it. It is safe for other
169    /// threads to make concurrent requests while waiting for an event.
170    pub fn wait_for_event(
171        &self,
172        deadline: zx::MonotonicInstant,
173    ) -> Result<DiagnosticsEvent, fidl::Error> {
174        DiagnosticsEvent::decode(self.client.wait_for_event::<DiagnosticsMarker>(deadline)?)
175    }
176
177    /// Requests that the network stack produces debugging information in the
178    /// system logs.
179    ///
180    /// The call returns once debug information has been produced.
181    pub fn r#log_debug_info_to_syslog(
182        &self,
183        ___deadline: zx::MonotonicInstant,
184    ) -> Result<(), fidl::Error> {
185        let _response = self.client.send_query::<
186            fidl::encoding::EmptyPayload,
187            fidl::encoding::EmptyPayload,
188            DiagnosticsMarker,
189        >(
190            (),
191            0x336c39330bd8e1ac,
192            fidl::encoding::DynamicFlags::empty(),
193            ___deadline,
194        )?;
195        Ok(_response)
196    }
197
198    /// Requests a handle to the netstack's process.
199    ///
200    /// This handle is not meant to be used for anything other than diagnostics,
201    /// so only the `INSPECT` right is provided to the caller.
202    pub fn r#get_process_handle_for_inspection(
203        &self,
204        ___deadline: zx::MonotonicInstant,
205    ) -> Result<fidl::Process, fidl::Error> {
206        let _response = self.client.send_query::<
207            fidl::encoding::EmptyPayload,
208            DiagnosticsGetProcessHandleForInspectionResponse,
209            DiagnosticsMarker,
210        >(
211            (),
212            0x563e5df030f2f4d5,
213            fidl::encoding::DynamicFlags::empty(),
214            ___deadline,
215        )?;
216        Ok(_response.process)
217    }
218}
219
220#[cfg(target_os = "fuchsia")]
221impl From<DiagnosticsSynchronousProxy> for zx::NullableHandle {
222    fn from(value: DiagnosticsSynchronousProxy) -> Self {
223        value.into_channel().into()
224    }
225}
226
227#[cfg(target_os = "fuchsia")]
228impl From<fidl::Channel> for DiagnosticsSynchronousProxy {
229    fn from(value: fidl::Channel) -> Self {
230        Self::new(value)
231    }
232}
233
234#[cfg(target_os = "fuchsia")]
235impl fidl::endpoints::FromClient for DiagnosticsSynchronousProxy {
236    type Protocol = DiagnosticsMarker;
237
238    fn from_client(value: fidl::endpoints::ClientEnd<DiagnosticsMarker>) -> Self {
239        Self::new(value.into_channel())
240    }
241}
242
243#[derive(Debug, Clone)]
244pub struct DiagnosticsProxy {
245    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
246}
247
248impl fidl::endpoints::Proxy for DiagnosticsProxy {
249    type Protocol = DiagnosticsMarker;
250
251    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
252        Self::new(inner)
253    }
254
255    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
256        self.client.into_channel().map_err(|client| Self { client })
257    }
258
259    fn as_channel(&self) -> &::fidl::AsyncChannel {
260        self.client.as_channel()
261    }
262}
263
264impl DiagnosticsProxy {
265    /// Create a new Proxy for fuchsia.net.debug/Diagnostics.
266    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
267        let protocol_name = <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
268        Self { client: fidl::client::Client::new(channel, protocol_name) }
269    }
270
271    /// Get a Stream of events from the remote end of the protocol.
272    ///
273    /// # Panics
274    ///
275    /// Panics if the event stream was already taken.
276    pub fn take_event_stream(&self) -> DiagnosticsEventStream {
277        DiagnosticsEventStream { event_receiver: self.client.take_event_receiver() }
278    }
279
280    /// Requests that the network stack produces debugging information in the
281    /// system logs.
282    ///
283    /// The call returns once debug information has been produced.
284    pub fn r#log_debug_info_to_syslog(
285        &self,
286    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
287        DiagnosticsProxyInterface::r#log_debug_info_to_syslog(self)
288    }
289
290    /// Requests a handle to the netstack's process.
291    ///
292    /// This handle is not meant to be used for anything other than diagnostics,
293    /// so only the `INSPECT` right is provided to the caller.
294    pub fn r#get_process_handle_for_inspection(
295        &self,
296    ) -> fidl::client::QueryResponseFut<fidl::Process, fidl::encoding::DefaultFuchsiaResourceDialect>
297    {
298        DiagnosticsProxyInterface::r#get_process_handle_for_inspection(self)
299    }
300}
301
302impl DiagnosticsProxyInterface for DiagnosticsProxy {
303    type LogDebugInfoToSyslogResponseFut =
304        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
305    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut {
306        fn _decode(
307            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
308        ) -> Result<(), fidl::Error> {
309            let _response = fidl::client::decode_transaction_body::<
310                fidl::encoding::EmptyPayload,
311                fidl::encoding::DefaultFuchsiaResourceDialect,
312                0x336c39330bd8e1ac,
313            >(_buf?)?;
314            Ok(_response)
315        }
316        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
317            (),
318            0x336c39330bd8e1ac,
319            fidl::encoding::DynamicFlags::empty(),
320            _decode,
321        )
322    }
323
324    type GetProcessHandleForInspectionResponseFut = fidl::client::QueryResponseFut<
325        fidl::Process,
326        fidl::encoding::DefaultFuchsiaResourceDialect,
327    >;
328    fn r#get_process_handle_for_inspection(
329        &self,
330    ) -> Self::GetProcessHandleForInspectionResponseFut {
331        fn _decode(
332            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
333        ) -> Result<fidl::Process, fidl::Error> {
334            let _response = fidl::client::decode_transaction_body::<
335                DiagnosticsGetProcessHandleForInspectionResponse,
336                fidl::encoding::DefaultFuchsiaResourceDialect,
337                0x563e5df030f2f4d5,
338            >(_buf?)?;
339            Ok(_response.process)
340        }
341        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Process>(
342            (),
343            0x563e5df030f2f4d5,
344            fidl::encoding::DynamicFlags::empty(),
345            _decode,
346        )
347    }
348}
349
350pub struct DiagnosticsEventStream {
351    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
352}
353
354impl std::marker::Unpin for DiagnosticsEventStream {}
355
356impl futures::stream::FusedStream for DiagnosticsEventStream {
357    fn is_terminated(&self) -> bool {
358        self.event_receiver.is_terminated()
359    }
360}
361
362impl futures::Stream for DiagnosticsEventStream {
363    type Item = Result<DiagnosticsEvent, fidl::Error>;
364
365    fn poll_next(
366        mut self: std::pin::Pin<&mut Self>,
367        cx: &mut std::task::Context<'_>,
368    ) -> std::task::Poll<Option<Self::Item>> {
369        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
370            &mut self.event_receiver,
371            cx
372        )?) {
373            Some(buf) => std::task::Poll::Ready(Some(DiagnosticsEvent::decode(buf))),
374            None => std::task::Poll::Ready(None),
375        }
376    }
377}
378
379#[derive(Debug)]
380pub enum DiagnosticsEvent {}
381
382impl DiagnosticsEvent {
383    /// Decodes a message buffer as a [`DiagnosticsEvent`].
384    fn decode(
385        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
386    ) -> Result<DiagnosticsEvent, fidl::Error> {
387        let (bytes, _handles) = buf.split_mut();
388        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
389        debug_assert_eq!(tx_header.tx_id, 0);
390        match tx_header.ordinal {
391            _ => Err(fidl::Error::UnknownOrdinal {
392                ordinal: tx_header.ordinal,
393                protocol_name: <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
394            }),
395        }
396    }
397}
398
399/// A Stream of incoming requests for fuchsia.net.debug/Diagnostics.
400pub struct DiagnosticsRequestStream {
401    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
402    is_terminated: bool,
403}
404
405impl std::marker::Unpin for DiagnosticsRequestStream {}
406
407impl futures::stream::FusedStream for DiagnosticsRequestStream {
408    fn is_terminated(&self) -> bool {
409        self.is_terminated
410    }
411}
412
413impl fidl::endpoints::RequestStream for DiagnosticsRequestStream {
414    type Protocol = DiagnosticsMarker;
415    type ControlHandle = DiagnosticsControlHandle;
416
417    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
418        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
419    }
420
421    fn control_handle(&self) -> Self::ControlHandle {
422        DiagnosticsControlHandle { inner: self.inner.clone() }
423    }
424
425    fn into_inner(
426        self,
427    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
428    {
429        (self.inner, self.is_terminated)
430    }
431
432    fn from_inner(
433        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
434        is_terminated: bool,
435    ) -> Self {
436        Self { inner, is_terminated }
437    }
438}
439
440impl futures::Stream for DiagnosticsRequestStream {
441    type Item = Result<DiagnosticsRequest, fidl::Error>;
442
443    fn poll_next(
444        mut self: std::pin::Pin<&mut Self>,
445        cx: &mut std::task::Context<'_>,
446    ) -> std::task::Poll<Option<Self::Item>> {
447        let this = &mut *self;
448        if this.inner.check_shutdown(cx) {
449            this.is_terminated = true;
450            return std::task::Poll::Ready(None);
451        }
452        if this.is_terminated {
453            panic!("polled DiagnosticsRequestStream after completion");
454        }
455        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
456            |bytes, handles| {
457                match this.inner.channel().read_etc(cx, bytes, handles) {
458                    std::task::Poll::Ready(Ok(())) => {}
459                    std::task::Poll::Pending => return std::task::Poll::Pending,
460                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
461                        this.is_terminated = true;
462                        return std::task::Poll::Ready(None);
463                    }
464                    std::task::Poll::Ready(Err(e)) => {
465                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
466                            e.into(),
467                        ))));
468                    }
469                }
470
471                // A message has been received from the channel
472                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
473
474                std::task::Poll::Ready(Some(match header.ordinal {
475                    0x336c39330bd8e1ac => {
476                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
477                        let mut req = fidl::new_empty!(
478                            fidl::encoding::EmptyPayload,
479                            fidl::encoding::DefaultFuchsiaResourceDialect
480                        );
481                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
482                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
483                        Ok(DiagnosticsRequest::LogDebugInfoToSyslog {
484                            responder: DiagnosticsLogDebugInfoToSyslogResponder {
485                                control_handle: std::mem::ManuallyDrop::new(control_handle),
486                                tx_id: header.tx_id,
487                            },
488                        })
489                    }
490                    0x563e5df030f2f4d5 => {
491                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
492                        let mut req = fidl::new_empty!(
493                            fidl::encoding::EmptyPayload,
494                            fidl::encoding::DefaultFuchsiaResourceDialect
495                        );
496                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
497                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
498                        Ok(DiagnosticsRequest::GetProcessHandleForInspection {
499                            responder: DiagnosticsGetProcessHandleForInspectionResponder {
500                                control_handle: std::mem::ManuallyDrop::new(control_handle),
501                                tx_id: header.tx_id,
502                            },
503                        })
504                    }
505                    _ => Err(fidl::Error::UnknownOrdinal {
506                        ordinal: header.ordinal,
507                        protocol_name:
508                            <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
509                    }),
510                }))
511            },
512        )
513    }
514}
515
516/// Provides access to Network stack diagnostics information.
517#[derive(Debug)]
518pub enum DiagnosticsRequest {
519    /// Requests that the network stack produces debugging information in the
520    /// system logs.
521    ///
522    /// The call returns once debug information has been produced.
523    LogDebugInfoToSyslog { responder: DiagnosticsLogDebugInfoToSyslogResponder },
524    /// Requests a handle to the netstack's process.
525    ///
526    /// This handle is not meant to be used for anything other than diagnostics,
527    /// so only the `INSPECT` right is provided to the caller.
528    GetProcessHandleForInspection { responder: DiagnosticsGetProcessHandleForInspectionResponder },
529}
530
531impl DiagnosticsRequest {
532    #[allow(irrefutable_let_patterns)]
533    pub fn into_log_debug_info_to_syslog(
534        self,
535    ) -> Option<(DiagnosticsLogDebugInfoToSyslogResponder)> {
536        if let DiagnosticsRequest::LogDebugInfoToSyslog { responder } = self {
537            Some((responder))
538        } else {
539            None
540        }
541    }
542
543    #[allow(irrefutable_let_patterns)]
544    pub fn into_get_process_handle_for_inspection(
545        self,
546    ) -> Option<(DiagnosticsGetProcessHandleForInspectionResponder)> {
547        if let DiagnosticsRequest::GetProcessHandleForInspection { responder } = self {
548            Some((responder))
549        } else {
550            None
551        }
552    }
553
554    /// Name of the method defined in FIDL
555    pub fn method_name(&self) -> &'static str {
556        match *self {
557            DiagnosticsRequest::LogDebugInfoToSyslog { .. } => "log_debug_info_to_syslog",
558            DiagnosticsRequest::GetProcessHandleForInspection { .. } => {
559                "get_process_handle_for_inspection"
560            }
561        }
562    }
563}
564
565#[derive(Debug, Clone)]
566pub struct DiagnosticsControlHandle {
567    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
568}
569
570impl fidl::endpoints::ControlHandle for DiagnosticsControlHandle {
571    fn shutdown(&self) {
572        self.inner.shutdown()
573    }
574
575    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
576        self.inner.shutdown_with_epitaph(status)
577    }
578
579    fn is_closed(&self) -> bool {
580        self.inner.channel().is_closed()
581    }
582    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
583        self.inner.channel().on_closed()
584    }
585
586    #[cfg(target_os = "fuchsia")]
587    fn signal_peer(
588        &self,
589        clear_mask: zx::Signals,
590        set_mask: zx::Signals,
591    ) -> Result<(), zx_status::Status> {
592        use fidl::Peered;
593        self.inner.channel().signal_peer(clear_mask, set_mask)
594    }
595}
596
597impl DiagnosticsControlHandle {}
598
599#[must_use = "FIDL methods require a response to be sent"]
600#[derive(Debug)]
601pub struct DiagnosticsLogDebugInfoToSyslogResponder {
602    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
603    tx_id: u32,
604}
605
606/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
607/// if the responder is dropped without sending a response, so that the client
608/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
609impl std::ops::Drop for DiagnosticsLogDebugInfoToSyslogResponder {
610    fn drop(&mut self) {
611        self.control_handle.shutdown();
612        // Safety: drops once, never accessed again
613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
614    }
615}
616
617impl fidl::endpoints::Responder for DiagnosticsLogDebugInfoToSyslogResponder {
618    type ControlHandle = DiagnosticsControlHandle;
619
620    fn control_handle(&self) -> &DiagnosticsControlHandle {
621        &self.control_handle
622    }
623
624    fn drop_without_shutdown(mut self) {
625        // Safety: drops once, never accessed again due to mem::forget
626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
627        // Prevent Drop from running (which would shut down the channel)
628        std::mem::forget(self);
629    }
630}
631
632impl DiagnosticsLogDebugInfoToSyslogResponder {
633    /// Sends a response to the FIDL transaction.
634    ///
635    /// Sets the channel to shutdown if an error occurs.
636    pub fn send(self) -> Result<(), fidl::Error> {
637        let _result = self.send_raw();
638        if _result.is_err() {
639            self.control_handle.shutdown();
640        }
641        self.drop_without_shutdown();
642        _result
643    }
644
645    /// Similar to "send" but does not shutdown the channel if an error occurs.
646    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
647        let _result = self.send_raw();
648        self.drop_without_shutdown();
649        _result
650    }
651
652    fn send_raw(&self) -> Result<(), fidl::Error> {
653        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
654            (),
655            self.tx_id,
656            0x336c39330bd8e1ac,
657            fidl::encoding::DynamicFlags::empty(),
658        )
659    }
660}
661
662#[must_use = "FIDL methods require a response to be sent"]
663#[derive(Debug)]
664pub struct DiagnosticsGetProcessHandleForInspectionResponder {
665    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
666    tx_id: u32,
667}
668
669/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
670/// if the responder is dropped without sending a response, so that the client
671/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
672impl std::ops::Drop for DiagnosticsGetProcessHandleForInspectionResponder {
673    fn drop(&mut self) {
674        self.control_handle.shutdown();
675        // Safety: drops once, never accessed again
676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
677    }
678}
679
680impl fidl::endpoints::Responder for DiagnosticsGetProcessHandleForInspectionResponder {
681    type ControlHandle = DiagnosticsControlHandle;
682
683    fn control_handle(&self) -> &DiagnosticsControlHandle {
684        &self.control_handle
685    }
686
687    fn drop_without_shutdown(mut self) {
688        // Safety: drops once, never accessed again due to mem::forget
689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
690        // Prevent Drop from running (which would shut down the channel)
691        std::mem::forget(self);
692    }
693}
694
695impl DiagnosticsGetProcessHandleForInspectionResponder {
696    /// Sends a response to the FIDL transaction.
697    ///
698    /// Sets the channel to shutdown if an error occurs.
699    pub fn send(self, mut process: fidl::Process) -> Result<(), fidl::Error> {
700        let _result = self.send_raw(process);
701        if _result.is_err() {
702            self.control_handle.shutdown();
703        }
704        self.drop_without_shutdown();
705        _result
706    }
707
708    /// Similar to "send" but does not shutdown the channel if an error occurs.
709    pub fn send_no_shutdown_on_err(self, mut process: fidl::Process) -> Result<(), fidl::Error> {
710        let _result = self.send_raw(process);
711        self.drop_without_shutdown();
712        _result
713    }
714
715    fn send_raw(&self, mut process: fidl::Process) -> Result<(), fidl::Error> {
716        self.control_handle.inner.send::<DiagnosticsGetProcessHandleForInspectionResponse>(
717            (process,),
718            self.tx_id,
719            0x563e5df030f2f4d5,
720            fidl::encoding::DynamicFlags::empty(),
721        )
722    }
723}
724
725#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
726pub struct InterfacesMarker;
727
728impl fidl::endpoints::ProtocolMarker for InterfacesMarker {
729    type Proxy = InterfacesProxy;
730    type RequestStream = InterfacesRequestStream;
731    #[cfg(target_os = "fuchsia")]
732    type SynchronousProxy = InterfacesSynchronousProxy;
733
734    const DEBUG_NAME: &'static str = "fuchsia.net.debug.Interfaces";
735}
736impl fidl::endpoints::DiscoverableProtocolMarker for InterfacesMarker {}
737pub type InterfacesCloseBackingSessionResult = Result<(), CloseSessionError>;
738
739pub trait InterfacesProxyInterface: Send + Sync {
740    fn r#get_port(
741        &self,
742        id: u64,
743        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
744    ) -> Result<(), fidl::Error>;
745    type CloseBackingSessionResponseFut: std::future::Future<Output = Result<InterfacesCloseBackingSessionResult, fidl::Error>>
746        + Send;
747    fn r#close_backing_session(&self, id: u64) -> Self::CloseBackingSessionResponseFut;
748}
749#[derive(Debug)]
750#[cfg(target_os = "fuchsia")]
751pub struct InterfacesSynchronousProxy {
752    client: fidl::client::sync::Client,
753}
754
755#[cfg(target_os = "fuchsia")]
756impl fidl::endpoints::SynchronousProxy for InterfacesSynchronousProxy {
757    type Proxy = InterfacesProxy;
758    type Protocol = InterfacesMarker;
759
760    fn from_channel(inner: fidl::Channel) -> Self {
761        Self::new(inner)
762    }
763
764    fn into_channel(self) -> fidl::Channel {
765        self.client.into_channel()
766    }
767
768    fn as_channel(&self) -> &fidl::Channel {
769        self.client.as_channel()
770    }
771}
772
773#[cfg(target_os = "fuchsia")]
774impl InterfacesSynchronousProxy {
775    pub fn new(channel: fidl::Channel) -> Self {
776        Self { client: fidl::client::sync::Client::new(channel) }
777    }
778
779    pub fn into_channel(self) -> fidl::Channel {
780        self.client.into_channel()
781    }
782
783    /// Waits until an event arrives and returns it. It is safe for other
784    /// threads to make concurrent requests while waiting for an event.
785    pub fn wait_for_event(
786        &self,
787        deadline: zx::MonotonicInstant,
788    ) -> Result<InterfacesEvent, fidl::Error> {
789        InterfacesEvent::decode(self.client.wait_for_event::<InterfacesMarker>(deadline)?)
790    }
791
792    /// Provides access to the port backing an interface.
793    ///
794    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
795    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
796    /// [`fuchsia.hardware.network/Port`].
797    ///
798    /// + request `id` identifies the interface whose port is granted.
799    /// + request `port` grants access to the interface's device port.
800    pub fn r#get_port(
801        &self,
802        mut id: u64,
803        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
804    ) -> Result<(), fidl::Error> {
805        self.client.send::<InterfacesGetPortRequest>(
806            (id, port),
807            0xdd15c4df17fb148,
808            fidl::encoding::DynamicFlags::empty(),
809        )
810    }
811
812    /// Closes the session with the network device that backs the interface.
813    ///
814    /// This method will wait for the backing session to be closed, which will
815    /// result in the removal of the interface(s) using that session from the
816    /// netstack. This is different from the traditional interface removal with
817    /// `fuchsia.net.interfaces.admin.Control` in the sense that the latter
818    /// does not close the session.
819    ///
820    /// + request `id` identifies the interface.
821    ///
822    /// - error `INTERFACE_NOT_FOUND` if the given `id` is not found.
823    /// - error `NOT_SUPPORTED` if the interface is not backed by a network-device
824    ///   or if the operation is not supported.
825    pub fn r#close_backing_session(
826        &self,
827        mut id: u64,
828        ___deadline: zx::MonotonicInstant,
829    ) -> Result<InterfacesCloseBackingSessionResult, fidl::Error> {
830        let _response = self.client.send_query::<
831            InterfacesCloseBackingSessionRequest,
832            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CloseSessionError>,
833            InterfacesMarker,
834        >(
835            (id,),
836            0x57da4d8a53ac6d0c,
837            fidl::encoding::DynamicFlags::empty(),
838            ___deadline,
839        )?;
840        Ok(_response.map(|x| x))
841    }
842}
843
844#[cfg(target_os = "fuchsia")]
845impl From<InterfacesSynchronousProxy> for zx::NullableHandle {
846    fn from(value: InterfacesSynchronousProxy) -> Self {
847        value.into_channel().into()
848    }
849}
850
851#[cfg(target_os = "fuchsia")]
852impl From<fidl::Channel> for InterfacesSynchronousProxy {
853    fn from(value: fidl::Channel) -> Self {
854        Self::new(value)
855    }
856}
857
858#[cfg(target_os = "fuchsia")]
859impl fidl::endpoints::FromClient for InterfacesSynchronousProxy {
860    type Protocol = InterfacesMarker;
861
862    fn from_client(value: fidl::endpoints::ClientEnd<InterfacesMarker>) -> Self {
863        Self::new(value.into_channel())
864    }
865}
866
867#[derive(Debug, Clone)]
868pub struct InterfacesProxy {
869    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
870}
871
872impl fidl::endpoints::Proxy for InterfacesProxy {
873    type Protocol = InterfacesMarker;
874
875    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
876        Self::new(inner)
877    }
878
879    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
880        self.client.into_channel().map_err(|client| Self { client })
881    }
882
883    fn as_channel(&self) -> &::fidl::AsyncChannel {
884        self.client.as_channel()
885    }
886}
887
888impl InterfacesProxy {
889    /// Create a new Proxy for fuchsia.net.debug/Interfaces.
890    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
891        let protocol_name = <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
892        Self { client: fidl::client::Client::new(channel, protocol_name) }
893    }
894
895    /// Get a Stream of events from the remote end of the protocol.
896    ///
897    /// # Panics
898    ///
899    /// Panics if the event stream was already taken.
900    pub fn take_event_stream(&self) -> InterfacesEventStream {
901        InterfacesEventStream { event_receiver: self.client.take_event_receiver() }
902    }
903
904    /// Provides access to the port backing an interface.
905    ///
906    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
907    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
908    /// [`fuchsia.hardware.network/Port`].
909    ///
910    /// + request `id` identifies the interface whose port is granted.
911    /// + request `port` grants access to the interface's device port.
912    pub fn r#get_port(
913        &self,
914        mut id: u64,
915        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
916    ) -> Result<(), fidl::Error> {
917        InterfacesProxyInterface::r#get_port(self, id, port)
918    }
919
920    /// Closes the session with the network device that backs the interface.
921    ///
922    /// This method will wait for the backing session to be closed, which will
923    /// result in the removal of the interface(s) using that session from the
924    /// netstack. This is different from the traditional interface removal with
925    /// `fuchsia.net.interfaces.admin.Control` in the sense that the latter
926    /// does not close the session.
927    ///
928    /// + request `id` identifies the interface.
929    ///
930    /// - error `INTERFACE_NOT_FOUND` if the given `id` is not found.
931    /// - error `NOT_SUPPORTED` if the interface is not backed by a network-device
932    ///   or if the operation is not supported.
933    pub fn r#close_backing_session(
934        &self,
935        mut id: u64,
936    ) -> fidl::client::QueryResponseFut<
937        InterfacesCloseBackingSessionResult,
938        fidl::encoding::DefaultFuchsiaResourceDialect,
939    > {
940        InterfacesProxyInterface::r#close_backing_session(self, id)
941    }
942}
943
944impl InterfacesProxyInterface for InterfacesProxy {
945    fn r#get_port(
946        &self,
947        mut id: u64,
948        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
949    ) -> Result<(), fidl::Error> {
950        self.client.send::<InterfacesGetPortRequest>(
951            (id, port),
952            0xdd15c4df17fb148,
953            fidl::encoding::DynamicFlags::empty(),
954        )
955    }
956
957    type CloseBackingSessionResponseFut = fidl::client::QueryResponseFut<
958        InterfacesCloseBackingSessionResult,
959        fidl::encoding::DefaultFuchsiaResourceDialect,
960    >;
961    fn r#close_backing_session(&self, mut id: u64) -> Self::CloseBackingSessionResponseFut {
962        fn _decode(
963            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
964        ) -> Result<InterfacesCloseBackingSessionResult, fidl::Error> {
965            let _response = fidl::client::decode_transaction_body::<
966                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CloseSessionError>,
967                fidl::encoding::DefaultFuchsiaResourceDialect,
968                0x57da4d8a53ac6d0c,
969            >(_buf?)?;
970            Ok(_response.map(|x| x))
971        }
972        self.client.send_query_and_decode::<
973            InterfacesCloseBackingSessionRequest,
974            InterfacesCloseBackingSessionResult,
975        >(
976            (id,),
977            0x57da4d8a53ac6d0c,
978            fidl::encoding::DynamicFlags::empty(),
979            _decode,
980        )
981    }
982}
983
984pub struct InterfacesEventStream {
985    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
986}
987
988impl std::marker::Unpin for InterfacesEventStream {}
989
990impl futures::stream::FusedStream for InterfacesEventStream {
991    fn is_terminated(&self) -> bool {
992        self.event_receiver.is_terminated()
993    }
994}
995
996impl futures::Stream for InterfacesEventStream {
997    type Item = Result<InterfacesEvent, fidl::Error>;
998
999    fn poll_next(
1000        mut self: std::pin::Pin<&mut Self>,
1001        cx: &mut std::task::Context<'_>,
1002    ) -> std::task::Poll<Option<Self::Item>> {
1003        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1004            &mut self.event_receiver,
1005            cx
1006        )?) {
1007            Some(buf) => std::task::Poll::Ready(Some(InterfacesEvent::decode(buf))),
1008            None => std::task::Poll::Ready(None),
1009        }
1010    }
1011}
1012
1013#[derive(Debug)]
1014pub enum InterfacesEvent {}
1015
1016impl InterfacesEvent {
1017    /// Decodes a message buffer as a [`InterfacesEvent`].
1018    fn decode(
1019        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1020    ) -> Result<InterfacesEvent, fidl::Error> {
1021        let (bytes, _handles) = buf.split_mut();
1022        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1023        debug_assert_eq!(tx_header.tx_id, 0);
1024        match tx_header.ordinal {
1025            _ => Err(fidl::Error::UnknownOrdinal {
1026                ordinal: tx_header.ordinal,
1027                protocol_name: <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1028            }),
1029        }
1030    }
1031}
1032
1033/// A Stream of incoming requests for fuchsia.net.debug/Interfaces.
1034pub struct InterfacesRequestStream {
1035    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1036    is_terminated: bool,
1037}
1038
1039impl std::marker::Unpin for InterfacesRequestStream {}
1040
1041impl futures::stream::FusedStream for InterfacesRequestStream {
1042    fn is_terminated(&self) -> bool {
1043        self.is_terminated
1044    }
1045}
1046
1047impl fidl::endpoints::RequestStream for InterfacesRequestStream {
1048    type Protocol = InterfacesMarker;
1049    type ControlHandle = InterfacesControlHandle;
1050
1051    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1052        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1053    }
1054
1055    fn control_handle(&self) -> Self::ControlHandle {
1056        InterfacesControlHandle { inner: self.inner.clone() }
1057    }
1058
1059    fn into_inner(
1060        self,
1061    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1062    {
1063        (self.inner, self.is_terminated)
1064    }
1065
1066    fn from_inner(
1067        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1068        is_terminated: bool,
1069    ) -> Self {
1070        Self { inner, is_terminated }
1071    }
1072}
1073
1074impl futures::Stream for InterfacesRequestStream {
1075    type Item = Result<InterfacesRequest, fidl::Error>;
1076
1077    fn poll_next(
1078        mut self: std::pin::Pin<&mut Self>,
1079        cx: &mut std::task::Context<'_>,
1080    ) -> std::task::Poll<Option<Self::Item>> {
1081        let this = &mut *self;
1082        if this.inner.check_shutdown(cx) {
1083            this.is_terminated = true;
1084            return std::task::Poll::Ready(None);
1085        }
1086        if this.is_terminated {
1087            panic!("polled InterfacesRequestStream after completion");
1088        }
1089        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1090            |bytes, handles| {
1091                match this.inner.channel().read_etc(cx, bytes, handles) {
1092                    std::task::Poll::Ready(Ok(())) => {}
1093                    std::task::Poll::Pending => return std::task::Poll::Pending,
1094                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1095                        this.is_terminated = true;
1096                        return std::task::Poll::Ready(None);
1097                    }
1098                    std::task::Poll::Ready(Err(e)) => {
1099                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1100                            e.into(),
1101                        ))));
1102                    }
1103                }
1104
1105                // A message has been received from the channel
1106                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1107
1108                std::task::Poll::Ready(Some(match header.ordinal {
1109                    0xdd15c4df17fb148 => {
1110                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1111                        let mut req = fidl::new_empty!(
1112                            InterfacesGetPortRequest,
1113                            fidl::encoding::DefaultFuchsiaResourceDialect
1114                        );
1115                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterfacesGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
1116                        let control_handle = InterfacesControlHandle { inner: this.inner.clone() };
1117                        Ok(InterfacesRequest::GetPort {
1118                            id: req.id,
1119                            port: req.port,
1120
1121                            control_handle,
1122                        })
1123                    }
1124                    0x57da4d8a53ac6d0c => {
1125                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1126                        let mut req = fidl::new_empty!(
1127                            InterfacesCloseBackingSessionRequest,
1128                            fidl::encoding::DefaultFuchsiaResourceDialect
1129                        );
1130                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterfacesCloseBackingSessionRequest>(&header, _body_bytes, handles, &mut req)?;
1131                        let control_handle = InterfacesControlHandle { inner: this.inner.clone() };
1132                        Ok(InterfacesRequest::CloseBackingSession {
1133                            id: req.id,
1134
1135                            responder: InterfacesCloseBackingSessionResponder {
1136                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1137                                tx_id: header.tx_id,
1138                            },
1139                        })
1140                    }
1141                    _ => Err(fidl::Error::UnknownOrdinal {
1142                        ordinal: header.ordinal,
1143                        protocol_name:
1144                            <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1145                    }),
1146                }))
1147            },
1148        )
1149    }
1150}
1151
1152/// Network interface debugging functionality.
1153///
1154/// This protocol is intended for debugging and testing only; and not meant for
1155/// load-bearing code.
1156#[derive(Debug)]
1157pub enum InterfacesRequest {
1158    /// Provides access to the port backing an interface.
1159    ///
1160    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
1161    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
1162    /// [`fuchsia.hardware.network/Port`].
1163    ///
1164    /// + request `id` identifies the interface whose port is granted.
1165    /// + request `port` grants access to the interface's device port.
1166    GetPort {
1167        id: u64,
1168        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1169        control_handle: InterfacesControlHandle,
1170    },
1171    /// Closes the session with the network device that backs the interface.
1172    ///
1173    /// This method will wait for the backing session to be closed, which will
1174    /// result in the removal of the interface(s) using that session from the
1175    /// netstack. This is different from the traditional interface removal with
1176    /// `fuchsia.net.interfaces.admin.Control` in the sense that the latter
1177    /// does not close the session.
1178    ///
1179    /// + request `id` identifies the interface.
1180    ///
1181    /// - error `INTERFACE_NOT_FOUND` if the given `id` is not found.
1182    /// - error `NOT_SUPPORTED` if the interface is not backed by a network-device
1183    ///   or if the operation is not supported.
1184    CloseBackingSession { id: u64, responder: InterfacesCloseBackingSessionResponder },
1185}
1186
1187impl InterfacesRequest {
1188    #[allow(irrefutable_let_patterns)]
1189    pub fn into_get_port(
1190        self,
1191    ) -> Option<(
1192        u64,
1193        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1194        InterfacesControlHandle,
1195    )> {
1196        if let InterfacesRequest::GetPort { id, port, control_handle } = self {
1197            Some((id, port, control_handle))
1198        } else {
1199            None
1200        }
1201    }
1202
1203    #[allow(irrefutable_let_patterns)]
1204    pub fn into_close_backing_session(
1205        self,
1206    ) -> Option<(u64, InterfacesCloseBackingSessionResponder)> {
1207        if let InterfacesRequest::CloseBackingSession { id, responder } = self {
1208            Some((id, responder))
1209        } else {
1210            None
1211        }
1212    }
1213
1214    /// Name of the method defined in FIDL
1215    pub fn method_name(&self) -> &'static str {
1216        match *self {
1217            InterfacesRequest::GetPort { .. } => "get_port",
1218            InterfacesRequest::CloseBackingSession { .. } => "close_backing_session",
1219        }
1220    }
1221}
1222
1223#[derive(Debug, Clone)]
1224pub struct InterfacesControlHandle {
1225    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1226}
1227
1228impl fidl::endpoints::ControlHandle for InterfacesControlHandle {
1229    fn shutdown(&self) {
1230        self.inner.shutdown()
1231    }
1232
1233    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1234        self.inner.shutdown_with_epitaph(status)
1235    }
1236
1237    fn is_closed(&self) -> bool {
1238        self.inner.channel().is_closed()
1239    }
1240    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1241        self.inner.channel().on_closed()
1242    }
1243
1244    #[cfg(target_os = "fuchsia")]
1245    fn signal_peer(
1246        &self,
1247        clear_mask: zx::Signals,
1248        set_mask: zx::Signals,
1249    ) -> Result<(), zx_status::Status> {
1250        use fidl::Peered;
1251        self.inner.channel().signal_peer(clear_mask, set_mask)
1252    }
1253}
1254
1255impl InterfacesControlHandle {}
1256
1257#[must_use = "FIDL methods require a response to be sent"]
1258#[derive(Debug)]
1259pub struct InterfacesCloseBackingSessionResponder {
1260    control_handle: std::mem::ManuallyDrop<InterfacesControlHandle>,
1261    tx_id: u32,
1262}
1263
1264/// Set the the channel to be shutdown (see [`InterfacesControlHandle::shutdown`])
1265/// if the responder is dropped without sending a response, so that the client
1266/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1267impl std::ops::Drop for InterfacesCloseBackingSessionResponder {
1268    fn drop(&mut self) {
1269        self.control_handle.shutdown();
1270        // Safety: drops once, never accessed again
1271        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1272    }
1273}
1274
1275impl fidl::endpoints::Responder for InterfacesCloseBackingSessionResponder {
1276    type ControlHandle = InterfacesControlHandle;
1277
1278    fn control_handle(&self) -> &InterfacesControlHandle {
1279        &self.control_handle
1280    }
1281
1282    fn drop_without_shutdown(mut self) {
1283        // Safety: drops once, never accessed again due to mem::forget
1284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1285        // Prevent Drop from running (which would shut down the channel)
1286        std::mem::forget(self);
1287    }
1288}
1289
1290impl InterfacesCloseBackingSessionResponder {
1291    /// Sends a response to the FIDL transaction.
1292    ///
1293    /// Sets the channel to shutdown if an error occurs.
1294    pub fn send(self, mut result: Result<(), CloseSessionError>) -> Result<(), fidl::Error> {
1295        let _result = self.send_raw(result);
1296        if _result.is_err() {
1297            self.control_handle.shutdown();
1298        }
1299        self.drop_without_shutdown();
1300        _result
1301    }
1302
1303    /// Similar to "send" but does not shutdown the channel if an error occurs.
1304    pub fn send_no_shutdown_on_err(
1305        self,
1306        mut result: Result<(), CloseSessionError>,
1307    ) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw(result);
1309        self.drop_without_shutdown();
1310        _result
1311    }
1312
1313    fn send_raw(&self, mut result: Result<(), CloseSessionError>) -> Result<(), fidl::Error> {
1314        self.control_handle.inner.send::<fidl::encoding::ResultType<
1315            fidl::encoding::EmptyStruct,
1316            CloseSessionError,
1317        >>(
1318            result,
1319            self.tx_id,
1320            0x57da4d8a53ac6d0c,
1321            fidl::encoding::DynamicFlags::empty(),
1322        )
1323    }
1324}
1325
1326#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1327pub struct PacketCaptureProviderMarker;
1328
1329impl fidl::endpoints::ProtocolMarker for PacketCaptureProviderMarker {
1330    type Proxy = PacketCaptureProviderProxy;
1331    type RequestStream = PacketCaptureProviderRequestStream;
1332    #[cfg(target_os = "fuchsia")]
1333    type SynchronousProxy = PacketCaptureProviderSynchronousProxy;
1334
1335    const DEBUG_NAME: &'static str = "fuchsia.net.debug.PacketCaptureProvider";
1336}
1337impl fidl::endpoints::DiscoverableProtocolMarker for PacketCaptureProviderMarker {}
1338pub type PacketCaptureProviderStartRollingResult =
1339    Result<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>, PacketCaptureStartError>;
1340pub type PacketCaptureProviderReconnectRollingResult =
1341    Result<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>, PacketCaptureReconnectError>;
1342
1343pub trait PacketCaptureProviderProxyInterface: Send + Sync {
1344    type StartRollingResponseFut: std::future::Future<Output = Result<PacketCaptureProviderStartRollingResult, fidl::Error>>
1345        + Send;
1346    fn r#start_rolling(
1347        &self,
1348        common_params: CommonPacketCaptureParams,
1349        params: &RollingPacketCaptureParams,
1350    ) -> Self::StartRollingResponseFut;
1351    type ReconnectRollingResponseFut: std::future::Future<
1352            Output = Result<PacketCaptureProviderReconnectRollingResult, fidl::Error>,
1353        > + Send;
1354    fn r#reconnect_rolling(&self, name: &str) -> Self::ReconnectRollingResponseFut;
1355}
1356#[derive(Debug)]
1357#[cfg(target_os = "fuchsia")]
1358pub struct PacketCaptureProviderSynchronousProxy {
1359    client: fidl::client::sync::Client,
1360}
1361
1362#[cfg(target_os = "fuchsia")]
1363impl fidl::endpoints::SynchronousProxy for PacketCaptureProviderSynchronousProxy {
1364    type Proxy = PacketCaptureProviderProxy;
1365    type Protocol = PacketCaptureProviderMarker;
1366
1367    fn from_channel(inner: fidl::Channel) -> Self {
1368        Self::new(inner)
1369    }
1370
1371    fn into_channel(self) -> fidl::Channel {
1372        self.client.into_channel()
1373    }
1374
1375    fn as_channel(&self) -> &fidl::Channel {
1376        self.client.as_channel()
1377    }
1378}
1379
1380#[cfg(target_os = "fuchsia")]
1381impl PacketCaptureProviderSynchronousProxy {
1382    pub fn new(channel: fidl::Channel) -> Self {
1383        Self { client: fidl::client::sync::Client::new(channel) }
1384    }
1385
1386    pub fn into_channel(self) -> fidl::Channel {
1387        self.client.into_channel()
1388    }
1389
1390    /// Waits until an event arrives and returns it. It is safe for other
1391    /// threads to make concurrent requests while waiting for an event.
1392    pub fn wait_for_event(
1393        &self,
1394        deadline: zx::MonotonicInstant,
1395    ) -> Result<PacketCaptureProviderEvent, fidl::Error> {
1396        PacketCaptureProviderEvent::decode(
1397            self.client.wait_for_event::<PacketCaptureProviderMarker>(deadline)?,
1398        )
1399    }
1400
1401    /// Start a rolling packet capture.
1402    ///
1403    /// Lifetime of the packet capture is tied to the pipelined `channel` unless
1404    /// [`RollingPacketCapture.Detach`] has been called.
1405    ///
1406    /// ## Error
1407    ///
1408    /// All variants of [`PacketCaptureStartError`] may be returned by this
1409    /// method.
1410    pub fn r#start_rolling(
1411        &self,
1412        mut common_params: CommonPacketCaptureParams,
1413        mut params: &RollingPacketCaptureParams,
1414        ___deadline: zx::MonotonicInstant,
1415    ) -> Result<PacketCaptureProviderStartRollingResult, fidl::Error> {
1416        let _response = self
1417            .client
1418            .send_query::<PacketCaptureProviderStartRollingRequest, fidl::encoding::ResultType<
1419                PacketCaptureProviderStartRollingResponse,
1420                PacketCaptureStartError,
1421            >, PacketCaptureProviderMarker>(
1422                (&mut common_params, params),
1423                0x4a5b2305ea27e845,
1424                fidl::encoding::DynamicFlags::empty(),
1425                ___deadline,
1426            )?;
1427        Ok(_response.map(|x| x.channel))
1428    }
1429
1430    /// Reconnects to a packet capture previously started with
1431    /// [`PacketCaptureProvider/StartRolling`].
1432    ///
1433    /// Note reconnecting does not reattach the lifetime of the packet capture to
1434    /// `channel`.
1435    pub fn r#reconnect_rolling(
1436        &self,
1437        mut name: &str,
1438        ___deadline: zx::MonotonicInstant,
1439    ) -> Result<PacketCaptureProviderReconnectRollingResult, fidl::Error> {
1440        let _response = self
1441            .client
1442            .send_query::<PacketCaptureProviderReconnectRollingRequest, fidl::encoding::ResultType<
1443                PacketCaptureProviderReconnectRollingResponse,
1444                PacketCaptureReconnectError,
1445            >, PacketCaptureProviderMarker>(
1446                (name,),
1447                0x57828e9ed034a522,
1448                fidl::encoding::DynamicFlags::empty(),
1449                ___deadline,
1450            )?;
1451        Ok(_response.map(|x| x.channel))
1452    }
1453}
1454
1455#[cfg(target_os = "fuchsia")]
1456impl From<PacketCaptureProviderSynchronousProxy> for zx::NullableHandle {
1457    fn from(value: PacketCaptureProviderSynchronousProxy) -> Self {
1458        value.into_channel().into()
1459    }
1460}
1461
1462#[cfg(target_os = "fuchsia")]
1463impl From<fidl::Channel> for PacketCaptureProviderSynchronousProxy {
1464    fn from(value: fidl::Channel) -> Self {
1465        Self::new(value)
1466    }
1467}
1468
1469#[cfg(target_os = "fuchsia")]
1470impl fidl::endpoints::FromClient for PacketCaptureProviderSynchronousProxy {
1471    type Protocol = PacketCaptureProviderMarker;
1472
1473    fn from_client(value: fidl::endpoints::ClientEnd<PacketCaptureProviderMarker>) -> Self {
1474        Self::new(value.into_channel())
1475    }
1476}
1477
1478#[derive(Debug, Clone)]
1479pub struct PacketCaptureProviderProxy {
1480    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1481}
1482
1483impl fidl::endpoints::Proxy for PacketCaptureProviderProxy {
1484    type Protocol = PacketCaptureProviderMarker;
1485
1486    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1487        Self::new(inner)
1488    }
1489
1490    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1491        self.client.into_channel().map_err(|client| Self { client })
1492    }
1493
1494    fn as_channel(&self) -> &::fidl::AsyncChannel {
1495        self.client.as_channel()
1496    }
1497}
1498
1499impl PacketCaptureProviderProxy {
1500    /// Create a new Proxy for fuchsia.net.debug/PacketCaptureProvider.
1501    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1502        let protocol_name =
1503            <PacketCaptureProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1504        Self { client: fidl::client::Client::new(channel, protocol_name) }
1505    }
1506
1507    /// Get a Stream of events from the remote end of the protocol.
1508    ///
1509    /// # Panics
1510    ///
1511    /// Panics if the event stream was already taken.
1512    pub fn take_event_stream(&self) -> PacketCaptureProviderEventStream {
1513        PacketCaptureProviderEventStream { event_receiver: self.client.take_event_receiver() }
1514    }
1515
1516    /// Start a rolling packet capture.
1517    ///
1518    /// Lifetime of the packet capture is tied to the pipelined `channel` unless
1519    /// [`RollingPacketCapture.Detach`] has been called.
1520    ///
1521    /// ## Error
1522    ///
1523    /// All variants of [`PacketCaptureStartError`] may be returned by this
1524    /// method.
1525    pub fn r#start_rolling(
1526        &self,
1527        mut common_params: CommonPacketCaptureParams,
1528        mut params: &RollingPacketCaptureParams,
1529    ) -> fidl::client::QueryResponseFut<
1530        PacketCaptureProviderStartRollingResult,
1531        fidl::encoding::DefaultFuchsiaResourceDialect,
1532    > {
1533        PacketCaptureProviderProxyInterface::r#start_rolling(self, common_params, params)
1534    }
1535
1536    /// Reconnects to a packet capture previously started with
1537    /// [`PacketCaptureProvider/StartRolling`].
1538    ///
1539    /// Note reconnecting does not reattach the lifetime of the packet capture to
1540    /// `channel`.
1541    pub fn r#reconnect_rolling(
1542        &self,
1543        mut name: &str,
1544    ) -> fidl::client::QueryResponseFut<
1545        PacketCaptureProviderReconnectRollingResult,
1546        fidl::encoding::DefaultFuchsiaResourceDialect,
1547    > {
1548        PacketCaptureProviderProxyInterface::r#reconnect_rolling(self, name)
1549    }
1550}
1551
1552impl PacketCaptureProviderProxyInterface for PacketCaptureProviderProxy {
1553    type StartRollingResponseFut = fidl::client::QueryResponseFut<
1554        PacketCaptureProviderStartRollingResult,
1555        fidl::encoding::DefaultFuchsiaResourceDialect,
1556    >;
1557    fn r#start_rolling(
1558        &self,
1559        mut common_params: CommonPacketCaptureParams,
1560        mut params: &RollingPacketCaptureParams,
1561    ) -> Self::StartRollingResponseFut {
1562        fn _decode(
1563            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1564        ) -> Result<PacketCaptureProviderStartRollingResult, fidl::Error> {
1565            let _response = fidl::client::decode_transaction_body::<
1566                fidl::encoding::ResultType<
1567                    PacketCaptureProviderStartRollingResponse,
1568                    PacketCaptureStartError,
1569                >,
1570                fidl::encoding::DefaultFuchsiaResourceDialect,
1571                0x4a5b2305ea27e845,
1572            >(_buf?)?;
1573            Ok(_response.map(|x| x.channel))
1574        }
1575        self.client.send_query_and_decode::<
1576            PacketCaptureProviderStartRollingRequest,
1577            PacketCaptureProviderStartRollingResult,
1578        >(
1579            (&mut common_params, params,),
1580            0x4a5b2305ea27e845,
1581            fidl::encoding::DynamicFlags::empty(),
1582            _decode,
1583        )
1584    }
1585
1586    type ReconnectRollingResponseFut = fidl::client::QueryResponseFut<
1587        PacketCaptureProviderReconnectRollingResult,
1588        fidl::encoding::DefaultFuchsiaResourceDialect,
1589    >;
1590    fn r#reconnect_rolling(&self, mut name: &str) -> Self::ReconnectRollingResponseFut {
1591        fn _decode(
1592            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1593        ) -> Result<PacketCaptureProviderReconnectRollingResult, fidl::Error> {
1594            let _response = fidl::client::decode_transaction_body::<
1595                fidl::encoding::ResultType<
1596                    PacketCaptureProviderReconnectRollingResponse,
1597                    PacketCaptureReconnectError,
1598                >,
1599                fidl::encoding::DefaultFuchsiaResourceDialect,
1600                0x57828e9ed034a522,
1601            >(_buf?)?;
1602            Ok(_response.map(|x| x.channel))
1603        }
1604        self.client.send_query_and_decode::<
1605            PacketCaptureProviderReconnectRollingRequest,
1606            PacketCaptureProviderReconnectRollingResult,
1607        >(
1608            (name,),
1609            0x57828e9ed034a522,
1610            fidl::encoding::DynamicFlags::empty(),
1611            _decode,
1612        )
1613    }
1614}
1615
1616pub struct PacketCaptureProviderEventStream {
1617    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1618}
1619
1620impl std::marker::Unpin for PacketCaptureProviderEventStream {}
1621
1622impl futures::stream::FusedStream for PacketCaptureProviderEventStream {
1623    fn is_terminated(&self) -> bool {
1624        self.event_receiver.is_terminated()
1625    }
1626}
1627
1628impl futures::Stream for PacketCaptureProviderEventStream {
1629    type Item = Result<PacketCaptureProviderEvent, fidl::Error>;
1630
1631    fn poll_next(
1632        mut self: std::pin::Pin<&mut Self>,
1633        cx: &mut std::task::Context<'_>,
1634    ) -> std::task::Poll<Option<Self::Item>> {
1635        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1636            &mut self.event_receiver,
1637            cx
1638        )?) {
1639            Some(buf) => std::task::Poll::Ready(Some(PacketCaptureProviderEvent::decode(buf))),
1640            None => std::task::Poll::Ready(None),
1641        }
1642    }
1643}
1644
1645#[derive(Debug)]
1646pub enum PacketCaptureProviderEvent {}
1647
1648impl PacketCaptureProviderEvent {
1649    /// Decodes a message buffer as a [`PacketCaptureProviderEvent`].
1650    fn decode(
1651        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1652    ) -> Result<PacketCaptureProviderEvent, fidl::Error> {
1653        let (bytes, _handles) = buf.split_mut();
1654        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1655        debug_assert_eq!(tx_header.tx_id, 0);
1656        match tx_header.ordinal {
1657            _ => Err(fidl::Error::UnknownOrdinal {
1658                ordinal: tx_header.ordinal,
1659                protocol_name:
1660                    <PacketCaptureProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1661            }),
1662        }
1663    }
1664}
1665
1666/// A Stream of incoming requests for fuchsia.net.debug/PacketCaptureProvider.
1667pub struct PacketCaptureProviderRequestStream {
1668    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1669    is_terminated: bool,
1670}
1671
1672impl std::marker::Unpin for PacketCaptureProviderRequestStream {}
1673
1674impl futures::stream::FusedStream for PacketCaptureProviderRequestStream {
1675    fn is_terminated(&self) -> bool {
1676        self.is_terminated
1677    }
1678}
1679
1680impl fidl::endpoints::RequestStream for PacketCaptureProviderRequestStream {
1681    type Protocol = PacketCaptureProviderMarker;
1682    type ControlHandle = PacketCaptureProviderControlHandle;
1683
1684    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1685        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1686    }
1687
1688    fn control_handle(&self) -> Self::ControlHandle {
1689        PacketCaptureProviderControlHandle { inner: self.inner.clone() }
1690    }
1691
1692    fn into_inner(
1693        self,
1694    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1695    {
1696        (self.inner, self.is_terminated)
1697    }
1698
1699    fn from_inner(
1700        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1701        is_terminated: bool,
1702    ) -> Self {
1703        Self { inner, is_terminated }
1704    }
1705}
1706
1707impl futures::Stream for PacketCaptureProviderRequestStream {
1708    type Item = Result<PacketCaptureProviderRequest, fidl::Error>;
1709
1710    fn poll_next(
1711        mut self: std::pin::Pin<&mut Self>,
1712        cx: &mut std::task::Context<'_>,
1713    ) -> std::task::Poll<Option<Self::Item>> {
1714        let this = &mut *self;
1715        if this.inner.check_shutdown(cx) {
1716            this.is_terminated = true;
1717            return std::task::Poll::Ready(None);
1718        }
1719        if this.is_terminated {
1720            panic!("polled PacketCaptureProviderRequestStream after completion");
1721        }
1722        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1723            |bytes, handles| {
1724                match this.inner.channel().read_etc(cx, bytes, handles) {
1725                    std::task::Poll::Ready(Ok(())) => {}
1726                    std::task::Poll::Pending => return std::task::Poll::Pending,
1727                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1728                        this.is_terminated = true;
1729                        return std::task::Poll::Ready(None);
1730                    }
1731                    std::task::Poll::Ready(Err(e)) => {
1732                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1733                            e.into(),
1734                        ))));
1735                    }
1736                }
1737
1738                // A message has been received from the channel
1739                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1740
1741                std::task::Poll::Ready(Some(match header.ordinal {
1742                0x4a5b2305ea27e845 => {
1743                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1744                    let mut req = fidl::new_empty!(PacketCaptureProviderStartRollingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1745                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketCaptureProviderStartRollingRequest>(&header, _body_bytes, handles, &mut req)?;
1746                    let control_handle = PacketCaptureProviderControlHandle {
1747                        inner: this.inner.clone(),
1748                    };
1749                    Ok(PacketCaptureProviderRequest::StartRolling {common_params: req.common_params,
1750params: req.params,
1751
1752                        responder: PacketCaptureProviderStartRollingResponder {
1753                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1754                            tx_id: header.tx_id,
1755                        },
1756                    })
1757                }
1758                0x57828e9ed034a522 => {
1759                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1760                    let mut req = fidl::new_empty!(PacketCaptureProviderReconnectRollingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1761                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketCaptureProviderReconnectRollingRequest>(&header, _body_bytes, handles, &mut req)?;
1762                    let control_handle = PacketCaptureProviderControlHandle {
1763                        inner: this.inner.clone(),
1764                    };
1765                    Ok(PacketCaptureProviderRequest::ReconnectRolling {name: req.name,
1766
1767                        responder: PacketCaptureProviderReconnectRollingResponder {
1768                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1769                            tx_id: header.tx_id,
1770                        },
1771                    })
1772                }
1773                _ => Err(fidl::Error::UnknownOrdinal {
1774                    ordinal: header.ordinal,
1775                    protocol_name: <PacketCaptureProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1776                }),
1777            }))
1778            },
1779        )
1780    }
1781}
1782
1783/// Provides packet captures.
1784///
1785/// [`PacketCaptureProvider.StartRolling`] is recommended if:
1786/// 1. You need resilience against network interruptions closing the channel
1787///    tied to the packet capture’s lifetime.
1788/// 2. You know when the packets of interest get captured, e.g. when a specific
1789///    networking event you’re looking for occurs.
1790/// 3. Not having to continuously read packet capture data from the Netstack
1791///    is a benefit.
1792///
1793/// Note that in order to conserve memory, the server maintains a limit on the
1794/// number of concurrent packet captures, and starting another packet capture
1795/// when the quota has been met fails.
1796///
1797/// In all cases, the server sends the packet captures in [pcapng format],
1798/// i.e. there is a Section Header Block at the start of each packet capture
1799/// followed by one or more Interface Description Blocks, followed by Enhanced
1800/// Packet Blocks containing packet data. Other blocks defined by the pcapng
1801/// file standard may appear as well.
1802///
1803/// [pcapng format]: https://www.ietf.org/archive/id/draft-ietf-opsawg-pcapng-05.html
1804#[derive(Debug)]
1805pub enum PacketCaptureProviderRequest {
1806    /// Start a rolling packet capture.
1807    ///
1808    /// Lifetime of the packet capture is tied to the pipelined `channel` unless
1809    /// [`RollingPacketCapture.Detach`] has been called.
1810    ///
1811    /// ## Error
1812    ///
1813    /// All variants of [`PacketCaptureStartError`] may be returned by this
1814    /// method.
1815    StartRolling {
1816        common_params: CommonPacketCaptureParams,
1817        params: RollingPacketCaptureParams,
1818        responder: PacketCaptureProviderStartRollingResponder,
1819    },
1820    /// Reconnects to a packet capture previously started with
1821    /// [`PacketCaptureProvider/StartRolling`].
1822    ///
1823    /// Note reconnecting does not reattach the lifetime of the packet capture to
1824    /// `channel`.
1825    ReconnectRolling { name: String, responder: PacketCaptureProviderReconnectRollingResponder },
1826}
1827
1828impl PacketCaptureProviderRequest {
1829    #[allow(irrefutable_let_patterns)]
1830    pub fn into_start_rolling(
1831        self,
1832    ) -> Option<(
1833        CommonPacketCaptureParams,
1834        RollingPacketCaptureParams,
1835        PacketCaptureProviderStartRollingResponder,
1836    )> {
1837        if let PacketCaptureProviderRequest::StartRolling { common_params, params, responder } =
1838            self
1839        {
1840            Some((common_params, params, responder))
1841        } else {
1842            None
1843        }
1844    }
1845
1846    #[allow(irrefutable_let_patterns)]
1847    pub fn into_reconnect_rolling(
1848        self,
1849    ) -> Option<(String, PacketCaptureProviderReconnectRollingResponder)> {
1850        if let PacketCaptureProviderRequest::ReconnectRolling { name, responder } = self {
1851            Some((name, responder))
1852        } else {
1853            None
1854        }
1855    }
1856
1857    /// Name of the method defined in FIDL
1858    pub fn method_name(&self) -> &'static str {
1859        match *self {
1860            PacketCaptureProviderRequest::StartRolling { .. } => "start_rolling",
1861            PacketCaptureProviderRequest::ReconnectRolling { .. } => "reconnect_rolling",
1862        }
1863    }
1864}
1865
1866#[derive(Debug, Clone)]
1867pub struct PacketCaptureProviderControlHandle {
1868    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1869}
1870
1871impl fidl::endpoints::ControlHandle for PacketCaptureProviderControlHandle {
1872    fn shutdown(&self) {
1873        self.inner.shutdown()
1874    }
1875
1876    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1877        self.inner.shutdown_with_epitaph(status)
1878    }
1879
1880    fn is_closed(&self) -> bool {
1881        self.inner.channel().is_closed()
1882    }
1883    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1884        self.inner.channel().on_closed()
1885    }
1886
1887    #[cfg(target_os = "fuchsia")]
1888    fn signal_peer(
1889        &self,
1890        clear_mask: zx::Signals,
1891        set_mask: zx::Signals,
1892    ) -> Result<(), zx_status::Status> {
1893        use fidl::Peered;
1894        self.inner.channel().signal_peer(clear_mask, set_mask)
1895    }
1896}
1897
1898impl PacketCaptureProviderControlHandle {}
1899
1900#[must_use = "FIDL methods require a response to be sent"]
1901#[derive(Debug)]
1902pub struct PacketCaptureProviderStartRollingResponder {
1903    control_handle: std::mem::ManuallyDrop<PacketCaptureProviderControlHandle>,
1904    tx_id: u32,
1905}
1906
1907/// Set the the channel to be shutdown (see [`PacketCaptureProviderControlHandle::shutdown`])
1908/// if the responder is dropped without sending a response, so that the client
1909/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1910impl std::ops::Drop for PacketCaptureProviderStartRollingResponder {
1911    fn drop(&mut self) {
1912        self.control_handle.shutdown();
1913        // Safety: drops once, never accessed again
1914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1915    }
1916}
1917
1918impl fidl::endpoints::Responder for PacketCaptureProviderStartRollingResponder {
1919    type ControlHandle = PacketCaptureProviderControlHandle;
1920
1921    fn control_handle(&self) -> &PacketCaptureProviderControlHandle {
1922        &self.control_handle
1923    }
1924
1925    fn drop_without_shutdown(mut self) {
1926        // Safety: drops once, never accessed again due to mem::forget
1927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1928        // Prevent Drop from running (which would shut down the channel)
1929        std::mem::forget(self);
1930    }
1931}
1932
1933impl PacketCaptureProviderStartRollingResponder {
1934    /// Sends a response to the FIDL transaction.
1935    ///
1936    /// Sets the channel to shutdown if an error occurs.
1937    pub fn send(
1938        self,
1939        mut result: Result<
1940            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
1941            PacketCaptureStartError,
1942        >,
1943    ) -> Result<(), fidl::Error> {
1944        let _result = self.send_raw(result);
1945        if _result.is_err() {
1946            self.control_handle.shutdown();
1947        }
1948        self.drop_without_shutdown();
1949        _result
1950    }
1951
1952    /// Similar to "send" but does not shutdown the channel if an error occurs.
1953    pub fn send_no_shutdown_on_err(
1954        self,
1955        mut result: Result<
1956            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
1957            PacketCaptureStartError,
1958        >,
1959    ) -> Result<(), fidl::Error> {
1960        let _result = self.send_raw(result);
1961        self.drop_without_shutdown();
1962        _result
1963    }
1964
1965    fn send_raw(
1966        &self,
1967        mut result: Result<
1968            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
1969            PacketCaptureStartError,
1970        >,
1971    ) -> Result<(), fidl::Error> {
1972        self.control_handle.inner.send::<fidl::encoding::ResultType<
1973            PacketCaptureProviderStartRollingResponse,
1974            PacketCaptureStartError,
1975        >>(
1976            result.map(|channel| (channel,)),
1977            self.tx_id,
1978            0x4a5b2305ea27e845,
1979            fidl::encoding::DynamicFlags::empty(),
1980        )
1981    }
1982}
1983
1984#[must_use = "FIDL methods require a response to be sent"]
1985#[derive(Debug)]
1986pub struct PacketCaptureProviderReconnectRollingResponder {
1987    control_handle: std::mem::ManuallyDrop<PacketCaptureProviderControlHandle>,
1988    tx_id: u32,
1989}
1990
1991/// Set the the channel to be shutdown (see [`PacketCaptureProviderControlHandle::shutdown`])
1992/// if the responder is dropped without sending a response, so that the client
1993/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1994impl std::ops::Drop for PacketCaptureProviderReconnectRollingResponder {
1995    fn drop(&mut self) {
1996        self.control_handle.shutdown();
1997        // Safety: drops once, never accessed again
1998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1999    }
2000}
2001
2002impl fidl::endpoints::Responder for PacketCaptureProviderReconnectRollingResponder {
2003    type ControlHandle = PacketCaptureProviderControlHandle;
2004
2005    fn control_handle(&self) -> &PacketCaptureProviderControlHandle {
2006        &self.control_handle
2007    }
2008
2009    fn drop_without_shutdown(mut self) {
2010        // Safety: drops once, never accessed again due to mem::forget
2011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2012        // Prevent Drop from running (which would shut down the channel)
2013        std::mem::forget(self);
2014    }
2015}
2016
2017impl PacketCaptureProviderReconnectRollingResponder {
2018    /// Sends a response to the FIDL transaction.
2019    ///
2020    /// Sets the channel to shutdown if an error occurs.
2021    pub fn send(
2022        self,
2023        mut result: Result<
2024            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
2025            PacketCaptureReconnectError,
2026        >,
2027    ) -> Result<(), fidl::Error> {
2028        let _result = self.send_raw(result);
2029        if _result.is_err() {
2030            self.control_handle.shutdown();
2031        }
2032        self.drop_without_shutdown();
2033        _result
2034    }
2035
2036    /// Similar to "send" but does not shutdown the channel if an error occurs.
2037    pub fn send_no_shutdown_on_err(
2038        self,
2039        mut result: Result<
2040            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
2041            PacketCaptureReconnectError,
2042        >,
2043    ) -> Result<(), fidl::Error> {
2044        let _result = self.send_raw(result);
2045        self.drop_without_shutdown();
2046        _result
2047    }
2048
2049    fn send_raw(
2050        &self,
2051        mut result: Result<
2052            fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
2053            PacketCaptureReconnectError,
2054        >,
2055    ) -> Result<(), fidl::Error> {
2056        self.control_handle.inner.send::<fidl::encoding::ResultType<
2057            PacketCaptureProviderReconnectRollingResponse,
2058            PacketCaptureReconnectError,
2059        >>(
2060            result.map(|channel| (channel,)),
2061            self.tx_id,
2062            0x57828e9ed034a522,
2063            fidl::encoding::DynamicFlags::empty(),
2064        )
2065    }
2066}
2067
2068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2069pub struct RollingPacketCaptureMarker;
2070
2071impl fidl::endpoints::ProtocolMarker for RollingPacketCaptureMarker {
2072    type Proxy = RollingPacketCaptureProxy;
2073    type RequestStream = RollingPacketCaptureRequestStream;
2074    #[cfg(target_os = "fuchsia")]
2075    type SynchronousProxy = RollingPacketCaptureSynchronousProxy;
2076
2077    const DEBUG_NAME: &'static str = "(anonymous) RollingPacketCapture";
2078}
2079
2080pub trait RollingPacketCaptureProxyInterface: Send + Sync {
2081    fn r#detach(&self, name: &str) -> Result<(), fidl::Error>;
2082    fn r#stop_and_download(
2083        &self,
2084        channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2085    ) -> Result<(), fidl::Error>;
2086    fn r#discard(&self) -> Result<(), fidl::Error>;
2087}
2088#[derive(Debug)]
2089#[cfg(target_os = "fuchsia")]
2090pub struct RollingPacketCaptureSynchronousProxy {
2091    client: fidl::client::sync::Client,
2092}
2093
2094#[cfg(target_os = "fuchsia")]
2095impl fidl::endpoints::SynchronousProxy for RollingPacketCaptureSynchronousProxy {
2096    type Proxy = RollingPacketCaptureProxy;
2097    type Protocol = RollingPacketCaptureMarker;
2098
2099    fn from_channel(inner: fidl::Channel) -> Self {
2100        Self::new(inner)
2101    }
2102
2103    fn into_channel(self) -> fidl::Channel {
2104        self.client.into_channel()
2105    }
2106
2107    fn as_channel(&self) -> &fidl::Channel {
2108        self.client.as_channel()
2109    }
2110}
2111
2112#[cfg(target_os = "fuchsia")]
2113impl RollingPacketCaptureSynchronousProxy {
2114    pub fn new(channel: fidl::Channel) -> Self {
2115        Self { client: fidl::client::sync::Client::new(channel) }
2116    }
2117
2118    pub fn into_channel(self) -> fidl::Channel {
2119        self.client.into_channel()
2120    }
2121
2122    /// Waits until an event arrives and returns it. It is safe for other
2123    /// threads to make concurrent requests while waiting for an event.
2124    pub fn wait_for_event(
2125        &self,
2126        deadline: zx::MonotonicInstant,
2127    ) -> Result<RollingPacketCaptureEvent, fidl::Error> {
2128        RollingPacketCaptureEvent::decode(
2129            self.client.wait_for_event::<RollingPacketCaptureMarker>(deadline)?,
2130        )
2131    }
2132
2133    /// Detaches the lifetime of this protocol from the underlying packet
2134    /// capture.
2135    ///
2136    /// After calling `Detach`, closing the client end no longer results in
2137    /// the packet capture from being terminated. The passed string names this
2138    /// packet capture and can be used *once* to reconnect via
2139    /// [`PacketCaptureProvider.ReconnectRolling`]. This gives the client the
2140    /// option of ensuring the packet capture is resilient against
2141    /// disconnections.
2142    ///
2143    /// `Detach` can be called multiple times, but only the name passed in the
2144    /// most recent call is valid and previously passed names are invalidated.
2145    pub fn r#detach(&self, mut name: &str) -> Result<(), fidl::Error> {
2146        self.client.send::<RollingPacketCaptureDetachRequest>(
2147            (name,),
2148            0xb3d28b9518e7db0,
2149            fidl::encoding::DynamicFlags::empty(),
2150        )
2151    }
2152
2153    /// Stop and make this rolling packet capture downloadable.
2154    ///
2155    /// It is implicit by calling this method that the packet capture is stopped
2156    /// due to user request, so the [`RollingPacketCapture.OnEnded`] event is
2157    /// not emitted.
2158    ///
2159    /// This method can be called multiple times, including across disconnects:
2160    /// a client can call this method, disconnect, reconnect, and call this
2161    /// method again.
2162    ///
2163    /// The server discards the contents of the packet capture once this
2164    /// method has been called and there is no client connected to this protocol
2165    /// for some time.
2166    pub fn r#stop_and_download(
2167        &self,
2168        mut channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2169    ) -> Result<(), fidl::Error> {
2170        self.client.send::<RollingPacketCaptureStopAndDownloadRequest>(
2171            (channel,),
2172            0x268270260a49e2ea,
2173            fidl::encoding::DynamicFlags::empty(),
2174        )
2175    }
2176
2177    /// Discard this rolling packet capture.
2178    ///
2179    /// Clients should call this method when they have successfully downloaded
2180    /// the packet capture, or if they no longer need it for any reason.
2181    ///
2182    /// When this method is called, the server closes all readers initialized
2183    /// via [`StopAndDownload`] and all future interactions on this protocol
2184    /// are invalid.
2185    pub fn r#discard(&self) -> Result<(), fidl::Error> {
2186        self.client.send::<fidl::encoding::EmptyPayload>(
2187            (),
2188            0x89e60c428d47a1,
2189            fidl::encoding::DynamicFlags::empty(),
2190        )
2191    }
2192}
2193
2194#[cfg(target_os = "fuchsia")]
2195impl From<RollingPacketCaptureSynchronousProxy> for zx::NullableHandle {
2196    fn from(value: RollingPacketCaptureSynchronousProxy) -> Self {
2197        value.into_channel().into()
2198    }
2199}
2200
2201#[cfg(target_os = "fuchsia")]
2202impl From<fidl::Channel> for RollingPacketCaptureSynchronousProxy {
2203    fn from(value: fidl::Channel) -> Self {
2204        Self::new(value)
2205    }
2206}
2207
2208#[cfg(target_os = "fuchsia")]
2209impl fidl::endpoints::FromClient for RollingPacketCaptureSynchronousProxy {
2210    type Protocol = RollingPacketCaptureMarker;
2211
2212    fn from_client(value: fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>) -> Self {
2213        Self::new(value.into_channel())
2214    }
2215}
2216
2217#[derive(Debug, Clone)]
2218pub struct RollingPacketCaptureProxy {
2219    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2220}
2221
2222impl fidl::endpoints::Proxy for RollingPacketCaptureProxy {
2223    type Protocol = RollingPacketCaptureMarker;
2224
2225    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2226        Self::new(inner)
2227    }
2228
2229    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2230        self.client.into_channel().map_err(|client| Self { client })
2231    }
2232
2233    fn as_channel(&self) -> &::fidl::AsyncChannel {
2234        self.client.as_channel()
2235    }
2236}
2237
2238impl RollingPacketCaptureProxy {
2239    /// Create a new Proxy for fuchsia.net.debug/RollingPacketCapture.
2240    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2241        let protocol_name =
2242            <RollingPacketCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2243        Self { client: fidl::client::Client::new(channel, protocol_name) }
2244    }
2245
2246    /// Get a Stream of events from the remote end of the protocol.
2247    ///
2248    /// # Panics
2249    ///
2250    /// Panics if the event stream was already taken.
2251    pub fn take_event_stream(&self) -> RollingPacketCaptureEventStream {
2252        RollingPacketCaptureEventStream { event_receiver: self.client.take_event_receiver() }
2253    }
2254
2255    /// Detaches the lifetime of this protocol from the underlying packet
2256    /// capture.
2257    ///
2258    /// After calling `Detach`, closing the client end no longer results in
2259    /// the packet capture from being terminated. The passed string names this
2260    /// packet capture and can be used *once* to reconnect via
2261    /// [`PacketCaptureProvider.ReconnectRolling`]. This gives the client the
2262    /// option of ensuring the packet capture is resilient against
2263    /// disconnections.
2264    ///
2265    /// `Detach` can be called multiple times, but only the name passed in the
2266    /// most recent call is valid and previously passed names are invalidated.
2267    pub fn r#detach(&self, mut name: &str) -> Result<(), fidl::Error> {
2268        RollingPacketCaptureProxyInterface::r#detach(self, name)
2269    }
2270
2271    /// Stop and make this rolling packet capture downloadable.
2272    ///
2273    /// It is implicit by calling this method that the packet capture is stopped
2274    /// due to user request, so the [`RollingPacketCapture.OnEnded`] event is
2275    /// not emitted.
2276    ///
2277    /// This method can be called multiple times, including across disconnects:
2278    /// a client can call this method, disconnect, reconnect, and call this
2279    /// method again.
2280    ///
2281    /// The server discards the contents of the packet capture once this
2282    /// method has been called and there is no client connected to this protocol
2283    /// for some time.
2284    pub fn r#stop_and_download(
2285        &self,
2286        mut channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2287    ) -> Result<(), fidl::Error> {
2288        RollingPacketCaptureProxyInterface::r#stop_and_download(self, channel)
2289    }
2290
2291    /// Discard this rolling packet capture.
2292    ///
2293    /// Clients should call this method when they have successfully downloaded
2294    /// the packet capture, or if they no longer need it for any reason.
2295    ///
2296    /// When this method is called, the server closes all readers initialized
2297    /// via [`StopAndDownload`] and all future interactions on this protocol
2298    /// are invalid.
2299    pub fn r#discard(&self) -> Result<(), fidl::Error> {
2300        RollingPacketCaptureProxyInterface::r#discard(self)
2301    }
2302}
2303
2304impl RollingPacketCaptureProxyInterface for RollingPacketCaptureProxy {
2305    fn r#detach(&self, mut name: &str) -> Result<(), fidl::Error> {
2306        self.client.send::<RollingPacketCaptureDetachRequest>(
2307            (name,),
2308            0xb3d28b9518e7db0,
2309            fidl::encoding::DynamicFlags::empty(),
2310        )
2311    }
2312
2313    fn r#stop_and_download(
2314        &self,
2315        mut channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2316    ) -> Result<(), fidl::Error> {
2317        self.client.send::<RollingPacketCaptureStopAndDownloadRequest>(
2318            (channel,),
2319            0x268270260a49e2ea,
2320            fidl::encoding::DynamicFlags::empty(),
2321        )
2322    }
2323
2324    fn r#discard(&self) -> Result<(), fidl::Error> {
2325        self.client.send::<fidl::encoding::EmptyPayload>(
2326            (),
2327            0x89e60c428d47a1,
2328            fidl::encoding::DynamicFlags::empty(),
2329        )
2330    }
2331}
2332
2333pub struct RollingPacketCaptureEventStream {
2334    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2335}
2336
2337impl std::marker::Unpin for RollingPacketCaptureEventStream {}
2338
2339impl futures::stream::FusedStream for RollingPacketCaptureEventStream {
2340    fn is_terminated(&self) -> bool {
2341        self.event_receiver.is_terminated()
2342    }
2343}
2344
2345impl futures::Stream for RollingPacketCaptureEventStream {
2346    type Item = Result<RollingPacketCaptureEvent, fidl::Error>;
2347
2348    fn poll_next(
2349        mut self: std::pin::Pin<&mut Self>,
2350        cx: &mut std::task::Context<'_>,
2351    ) -> std::task::Poll<Option<Self::Item>> {
2352        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2353            &mut self.event_receiver,
2354            cx
2355        )?) {
2356            Some(buf) => std::task::Poll::Ready(Some(RollingPacketCaptureEvent::decode(buf))),
2357            None => std::task::Poll::Ready(None),
2358        }
2359    }
2360}
2361
2362#[derive(Debug)]
2363pub enum RollingPacketCaptureEvent {
2364    OnEnded { reason: PacketCaptureEndReason },
2365}
2366
2367impl RollingPacketCaptureEvent {
2368    #[allow(irrefutable_let_patterns)]
2369    pub fn into_on_ended(self) -> Option<PacketCaptureEndReason> {
2370        if let RollingPacketCaptureEvent::OnEnded { reason } = self { Some((reason)) } else { None }
2371    }
2372
2373    /// Decodes a message buffer as a [`RollingPacketCaptureEvent`].
2374    fn decode(
2375        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2376    ) -> Result<RollingPacketCaptureEvent, fidl::Error> {
2377        let (bytes, _handles) = buf.split_mut();
2378        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2379        debug_assert_eq!(tx_header.tx_id, 0);
2380        match tx_header.ordinal {
2381            0x74690c9d4f59f506 => {
2382                let mut out = fidl::new_empty!(
2383                    RollingPacketCaptureOnEndedRequest,
2384                    fidl::encoding::DefaultFuchsiaResourceDialect
2385                );
2386                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RollingPacketCaptureOnEndedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2387                Ok((RollingPacketCaptureEvent::OnEnded { reason: out.reason }))
2388            }
2389            _ => Err(fidl::Error::UnknownOrdinal {
2390                ordinal: tx_header.ordinal,
2391                protocol_name:
2392                    <RollingPacketCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2393            }),
2394        }
2395    }
2396}
2397
2398/// A Stream of incoming requests for fuchsia.net.debug/RollingPacketCapture.
2399pub struct RollingPacketCaptureRequestStream {
2400    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2401    is_terminated: bool,
2402}
2403
2404impl std::marker::Unpin for RollingPacketCaptureRequestStream {}
2405
2406impl futures::stream::FusedStream for RollingPacketCaptureRequestStream {
2407    fn is_terminated(&self) -> bool {
2408        self.is_terminated
2409    }
2410}
2411
2412impl fidl::endpoints::RequestStream for RollingPacketCaptureRequestStream {
2413    type Protocol = RollingPacketCaptureMarker;
2414    type ControlHandle = RollingPacketCaptureControlHandle;
2415
2416    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2417        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2418    }
2419
2420    fn control_handle(&self) -> Self::ControlHandle {
2421        RollingPacketCaptureControlHandle { inner: self.inner.clone() }
2422    }
2423
2424    fn into_inner(
2425        self,
2426    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2427    {
2428        (self.inner, self.is_terminated)
2429    }
2430
2431    fn from_inner(
2432        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2433        is_terminated: bool,
2434    ) -> Self {
2435        Self { inner, is_terminated }
2436    }
2437}
2438
2439impl futures::Stream for RollingPacketCaptureRequestStream {
2440    type Item = Result<RollingPacketCaptureRequest, fidl::Error>;
2441
2442    fn poll_next(
2443        mut self: std::pin::Pin<&mut Self>,
2444        cx: &mut std::task::Context<'_>,
2445    ) -> std::task::Poll<Option<Self::Item>> {
2446        let this = &mut *self;
2447        if this.inner.check_shutdown(cx) {
2448            this.is_terminated = true;
2449            return std::task::Poll::Ready(None);
2450        }
2451        if this.is_terminated {
2452            panic!("polled RollingPacketCaptureRequestStream after completion");
2453        }
2454        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2455            |bytes, handles| {
2456                match this.inner.channel().read_etc(cx, bytes, handles) {
2457                    std::task::Poll::Ready(Ok(())) => {}
2458                    std::task::Poll::Pending => return std::task::Poll::Pending,
2459                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2460                        this.is_terminated = true;
2461                        return std::task::Poll::Ready(None);
2462                    }
2463                    std::task::Poll::Ready(Err(e)) => {
2464                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2465                            e.into(),
2466                        ))));
2467                    }
2468                }
2469
2470                // A message has been received from the channel
2471                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2472
2473                std::task::Poll::Ready(Some(match header.ordinal {
2474                0xb3d28b9518e7db0 => {
2475                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2476                    let mut req = fidl::new_empty!(RollingPacketCaptureDetachRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2477                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RollingPacketCaptureDetachRequest>(&header, _body_bytes, handles, &mut req)?;
2478                    let control_handle = RollingPacketCaptureControlHandle {
2479                        inner: this.inner.clone(),
2480                    };
2481                    Ok(RollingPacketCaptureRequest::Detach {name: req.name,
2482
2483                        control_handle,
2484                    })
2485                }
2486                0x268270260a49e2ea => {
2487                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2488                    let mut req = fidl::new_empty!(RollingPacketCaptureStopAndDownloadRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2489                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RollingPacketCaptureStopAndDownloadRequest>(&header, _body_bytes, handles, &mut req)?;
2490                    let control_handle = RollingPacketCaptureControlHandle {
2491                        inner: this.inner.clone(),
2492                    };
2493                    Ok(RollingPacketCaptureRequest::StopAndDownload {channel: req.channel,
2494
2495                        control_handle,
2496                    })
2497                }
2498                0x89e60c428d47a1 => {
2499                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2500                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2501                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2502                    let control_handle = RollingPacketCaptureControlHandle {
2503                        inner: this.inner.clone(),
2504                    };
2505                    Ok(RollingPacketCaptureRequest::Discard {
2506                        control_handle,
2507                    })
2508                }
2509                _ => Err(fidl::Error::UnknownOrdinal {
2510                    ordinal: header.ordinal,
2511                    protocol_name: <RollingPacketCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2512                }),
2513            }))
2514            },
2515        )
2516    }
2517}
2518
2519/// Rolling packet capture.
2520///
2521/// Once a rolling packet capture has stopped either because [`StopAndDownload`]
2522/// has been called or the capture stopped for some other reason and the server
2523/// has emitted [`OnEnded`], and there is no client connected to this protocol
2524/// for some time, the server discards the contents of the packet capture.
2525/// This timeout resets every time a client reconnects to this protocol, and
2526/// exists to provide resilience against disconnections.
2527#[derive(Debug)]
2528pub enum RollingPacketCaptureRequest {
2529    /// Detaches the lifetime of this protocol from the underlying packet
2530    /// capture.
2531    ///
2532    /// After calling `Detach`, closing the client end no longer results in
2533    /// the packet capture from being terminated. The passed string names this
2534    /// packet capture and can be used *once* to reconnect via
2535    /// [`PacketCaptureProvider.ReconnectRolling`]. This gives the client the
2536    /// option of ensuring the packet capture is resilient against
2537    /// disconnections.
2538    ///
2539    /// `Detach` can be called multiple times, but only the name passed in the
2540    /// most recent call is valid and previously passed names are invalidated.
2541    Detach { name: String, control_handle: RollingPacketCaptureControlHandle },
2542    /// Stop and make this rolling packet capture downloadable.
2543    ///
2544    /// It is implicit by calling this method that the packet capture is stopped
2545    /// due to user request, so the [`RollingPacketCapture.OnEnded`] event is
2546    /// not emitted.
2547    ///
2548    /// This method can be called multiple times, including across disconnects:
2549    /// a client can call this method, disconnect, reconnect, and call this
2550    /// method again.
2551    ///
2552    /// The server discards the contents of the packet capture once this
2553    /// method has been called and there is no client connected to this protocol
2554    /// for some time.
2555    StopAndDownload {
2556        channel: fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2557        control_handle: RollingPacketCaptureControlHandle,
2558    },
2559    /// Discard this rolling packet capture.
2560    ///
2561    /// Clients should call this method when they have successfully downloaded
2562    /// the packet capture, or if they no longer need it for any reason.
2563    ///
2564    /// When this method is called, the server closes all readers initialized
2565    /// via [`StopAndDownload`] and all future interactions on this protocol
2566    /// are invalid.
2567    Discard { control_handle: RollingPacketCaptureControlHandle },
2568}
2569
2570impl RollingPacketCaptureRequest {
2571    #[allow(irrefutable_let_patterns)]
2572    pub fn into_detach(self) -> Option<(String, RollingPacketCaptureControlHandle)> {
2573        if let RollingPacketCaptureRequest::Detach { name, control_handle } = self {
2574            Some((name, control_handle))
2575        } else {
2576            None
2577        }
2578    }
2579
2580    #[allow(irrefutable_let_patterns)]
2581    pub fn into_stop_and_download(
2582        self,
2583    ) -> Option<(
2584        fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
2585        RollingPacketCaptureControlHandle,
2586    )> {
2587        if let RollingPacketCaptureRequest::StopAndDownload { channel, control_handle } = self {
2588            Some((channel, control_handle))
2589        } else {
2590            None
2591        }
2592    }
2593
2594    #[allow(irrefutable_let_patterns)]
2595    pub fn into_discard(self) -> Option<(RollingPacketCaptureControlHandle)> {
2596        if let RollingPacketCaptureRequest::Discard { control_handle } = self {
2597            Some((control_handle))
2598        } else {
2599            None
2600        }
2601    }
2602
2603    /// Name of the method defined in FIDL
2604    pub fn method_name(&self) -> &'static str {
2605        match *self {
2606            RollingPacketCaptureRequest::Detach { .. } => "detach",
2607            RollingPacketCaptureRequest::StopAndDownload { .. } => "stop_and_download",
2608            RollingPacketCaptureRequest::Discard { .. } => "discard",
2609        }
2610    }
2611}
2612
2613#[derive(Debug, Clone)]
2614pub struct RollingPacketCaptureControlHandle {
2615    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2616}
2617
2618impl fidl::endpoints::ControlHandle for RollingPacketCaptureControlHandle {
2619    fn shutdown(&self) {
2620        self.inner.shutdown()
2621    }
2622
2623    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2624        self.inner.shutdown_with_epitaph(status)
2625    }
2626
2627    fn is_closed(&self) -> bool {
2628        self.inner.channel().is_closed()
2629    }
2630    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2631        self.inner.channel().on_closed()
2632    }
2633
2634    #[cfg(target_os = "fuchsia")]
2635    fn signal_peer(
2636        &self,
2637        clear_mask: zx::Signals,
2638        set_mask: zx::Signals,
2639    ) -> Result<(), zx_status::Status> {
2640        use fidl::Peered;
2641        self.inner.channel().signal_peer(clear_mask, set_mask)
2642    }
2643}
2644
2645impl RollingPacketCaptureControlHandle {
2646    pub fn send_on_ended(&self, mut reason: PacketCaptureEndReason) -> Result<(), fidl::Error> {
2647        self.inner.send::<RollingPacketCaptureOnEndedRequest>(
2648            (reason,),
2649            0,
2650            0x74690c9d4f59f506,
2651            fidl::encoding::DynamicFlags::empty(),
2652        )
2653    }
2654}
2655
2656mod internal {
2657    use super::*;
2658
2659    impl fidl::encoding::ResourceTypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
2660        type Borrowed<'a> = &'a mut Self;
2661        fn take_or_borrow<'a>(
2662            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2663        ) -> Self::Borrowed<'a> {
2664            value
2665        }
2666    }
2667
2668    unsafe impl fidl::encoding::TypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
2669        type Owned = Self;
2670
2671        #[inline(always)]
2672        fn inline_align(_context: fidl::encoding::Context) -> usize {
2673            4
2674        }
2675
2676        #[inline(always)]
2677        fn inline_size(_context: fidl::encoding::Context) -> usize {
2678            4
2679        }
2680    }
2681
2682    unsafe impl
2683        fidl::encoding::Encode<
2684            DiagnosticsGetProcessHandleForInspectionResponse,
2685            fidl::encoding::DefaultFuchsiaResourceDialect,
2686        > for &mut DiagnosticsGetProcessHandleForInspectionResponse
2687    {
2688        #[inline]
2689        unsafe fn encode(
2690            self,
2691            encoder: &mut fidl::encoding::Encoder<
2692                '_,
2693                fidl::encoding::DefaultFuchsiaResourceDialect,
2694            >,
2695            offset: usize,
2696            _depth: fidl::encoding::Depth,
2697        ) -> fidl::Result<()> {
2698            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
2699            // Delegate to tuple encoding.
2700            fidl::encoding::Encode::<
2701                DiagnosticsGetProcessHandleForInspectionResponse,
2702                fidl::encoding::DefaultFuchsiaResourceDialect,
2703            >::encode(
2704                (<fidl::encoding::HandleType<
2705                    fidl::Process,
2706                    { fidl::ObjectType::PROCESS.into_raw() },
2707                    32768,
2708                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2709                    &mut self.process
2710                ),),
2711                encoder,
2712                offset,
2713                _depth,
2714            )
2715        }
2716    }
2717    unsafe impl<
2718        T0: fidl::encoding::Encode<
2719                fidl::encoding::HandleType<
2720                    fidl::Process,
2721                    { fidl::ObjectType::PROCESS.into_raw() },
2722                    32768,
2723                >,
2724                fidl::encoding::DefaultFuchsiaResourceDialect,
2725            >,
2726    >
2727        fidl::encoding::Encode<
2728            DiagnosticsGetProcessHandleForInspectionResponse,
2729            fidl::encoding::DefaultFuchsiaResourceDialect,
2730        > for (T0,)
2731    {
2732        #[inline]
2733        unsafe fn encode(
2734            self,
2735            encoder: &mut fidl::encoding::Encoder<
2736                '_,
2737                fidl::encoding::DefaultFuchsiaResourceDialect,
2738            >,
2739            offset: usize,
2740            depth: fidl::encoding::Depth,
2741        ) -> fidl::Result<()> {
2742            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
2743            // Zero out padding regions. There's no need to apply masks
2744            // because the unmasked parts will be overwritten by fields.
2745            // Write the fields.
2746            self.0.encode(encoder, offset + 0, depth)?;
2747            Ok(())
2748        }
2749    }
2750
2751    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2752        for DiagnosticsGetProcessHandleForInspectionResponse
2753    {
2754        #[inline(always)]
2755        fn new_empty() -> Self {
2756            Self {
2757                process: fidl::new_empty!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect),
2758            }
2759        }
2760
2761        #[inline]
2762        unsafe fn decode(
2763            &mut self,
2764            decoder: &mut fidl::encoding::Decoder<
2765                '_,
2766                fidl::encoding::DefaultFuchsiaResourceDialect,
2767            >,
2768            offset: usize,
2769            _depth: fidl::encoding::Depth,
2770        ) -> fidl::Result<()> {
2771            decoder.debug_check_bounds::<Self>(offset);
2772            // Verify that padding bytes are zero.
2773            fidl::decode!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.process, decoder, offset + 0, _depth)?;
2774            Ok(())
2775        }
2776    }
2777
2778    impl fidl::encoding::ResourceTypeMarker for InterfacesGetPortRequest {
2779        type Borrowed<'a> = &'a mut Self;
2780        fn take_or_borrow<'a>(
2781            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2782        ) -> Self::Borrowed<'a> {
2783            value
2784        }
2785    }
2786
2787    unsafe impl fidl::encoding::TypeMarker for InterfacesGetPortRequest {
2788        type Owned = Self;
2789
2790        #[inline(always)]
2791        fn inline_align(_context: fidl::encoding::Context) -> usize {
2792            8
2793        }
2794
2795        #[inline(always)]
2796        fn inline_size(_context: fidl::encoding::Context) -> usize {
2797            16
2798        }
2799    }
2800
2801    unsafe impl
2802        fidl::encoding::Encode<
2803            InterfacesGetPortRequest,
2804            fidl::encoding::DefaultFuchsiaResourceDialect,
2805        > for &mut InterfacesGetPortRequest
2806    {
2807        #[inline]
2808        unsafe fn encode(
2809            self,
2810            encoder: &mut fidl::encoding::Encoder<
2811                '_,
2812                fidl::encoding::DefaultFuchsiaResourceDialect,
2813            >,
2814            offset: usize,
2815            _depth: fidl::encoding::Depth,
2816        ) -> fidl::Result<()> {
2817            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
2818            // Delegate to tuple encoding.
2819            fidl::encoding::Encode::<
2820                InterfacesGetPortRequest,
2821                fidl::encoding::DefaultFuchsiaResourceDialect,
2822            >::encode(
2823                (
2824                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2825                    <fidl::encoding::Endpoint<
2826                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2827                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2828                        &mut self.port
2829                    ),
2830                ),
2831                encoder,
2832                offset,
2833                _depth,
2834            )
2835        }
2836    }
2837    unsafe impl<
2838        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2839        T1: fidl::encoding::Encode<
2840                fidl::encoding::Endpoint<
2841                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2842                >,
2843                fidl::encoding::DefaultFuchsiaResourceDialect,
2844            >,
2845    >
2846        fidl::encoding::Encode<
2847            InterfacesGetPortRequest,
2848            fidl::encoding::DefaultFuchsiaResourceDialect,
2849        > for (T0, T1)
2850    {
2851        #[inline]
2852        unsafe fn encode(
2853            self,
2854            encoder: &mut fidl::encoding::Encoder<
2855                '_,
2856                fidl::encoding::DefaultFuchsiaResourceDialect,
2857            >,
2858            offset: usize,
2859            depth: fidl::encoding::Depth,
2860        ) -> fidl::Result<()> {
2861            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
2862            // Zero out padding regions. There's no need to apply masks
2863            // because the unmasked parts will be overwritten by fields.
2864            unsafe {
2865                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2866                (ptr as *mut u64).write_unaligned(0);
2867            }
2868            // Write the fields.
2869            self.0.encode(encoder, offset + 0, depth)?;
2870            self.1.encode(encoder, offset + 8, depth)?;
2871            Ok(())
2872        }
2873    }
2874
2875    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2876        for InterfacesGetPortRequest
2877    {
2878        #[inline(always)]
2879        fn new_empty() -> Self {
2880            Self {
2881                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2882                port: fidl::new_empty!(
2883                    fidl::encoding::Endpoint<
2884                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2885                    >,
2886                    fidl::encoding::DefaultFuchsiaResourceDialect
2887                ),
2888            }
2889        }
2890
2891        #[inline]
2892        unsafe fn decode(
2893            &mut self,
2894            decoder: &mut fidl::encoding::Decoder<
2895                '_,
2896                fidl::encoding::DefaultFuchsiaResourceDialect,
2897            >,
2898            offset: usize,
2899            _depth: fidl::encoding::Depth,
2900        ) -> fidl::Result<()> {
2901            decoder.debug_check_bounds::<Self>(offset);
2902            // Verify that padding bytes are zero.
2903            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2904            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2905            let mask = 0xffffffff00000000u64;
2906            let maskedval = padval & mask;
2907            if maskedval != 0 {
2908                return Err(fidl::Error::NonZeroPadding {
2909                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2910                });
2911            }
2912            fidl::decode!(
2913                u64,
2914                fidl::encoding::DefaultFuchsiaResourceDialect,
2915                &mut self.id,
2916                decoder,
2917                offset + 0,
2918                _depth
2919            )?;
2920            fidl::decode!(
2921                fidl::encoding::Endpoint<
2922                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2923                >,
2924                fidl::encoding::DefaultFuchsiaResourceDialect,
2925                &mut self.port,
2926                decoder,
2927                offset + 8,
2928                _depth
2929            )?;
2930            Ok(())
2931        }
2932    }
2933
2934    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderReconnectRollingRequest {
2935        type Borrowed<'a> = &'a mut Self;
2936        fn take_or_borrow<'a>(
2937            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2938        ) -> Self::Borrowed<'a> {
2939            value
2940        }
2941    }
2942
2943    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderReconnectRollingRequest {
2944        type Owned = Self;
2945
2946        #[inline(always)]
2947        fn inline_align(_context: fidl::encoding::Context) -> usize {
2948            8
2949        }
2950
2951        #[inline(always)]
2952        fn inline_size(_context: fidl::encoding::Context) -> usize {
2953            16
2954        }
2955    }
2956
2957    unsafe impl
2958        fidl::encoding::Encode<
2959            PacketCaptureProviderReconnectRollingRequest,
2960            fidl::encoding::DefaultFuchsiaResourceDialect,
2961        > for &mut PacketCaptureProviderReconnectRollingRequest
2962    {
2963        #[inline]
2964        unsafe fn encode(
2965            self,
2966            encoder: &mut fidl::encoding::Encoder<
2967                '_,
2968                fidl::encoding::DefaultFuchsiaResourceDialect,
2969            >,
2970            offset: usize,
2971            _depth: fidl::encoding::Depth,
2972        ) -> fidl::Result<()> {
2973            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingRequest>(offset);
2974            // Delegate to tuple encoding.
2975            fidl::encoding::Encode::<
2976                PacketCaptureProviderReconnectRollingRequest,
2977                fidl::encoding::DefaultFuchsiaResourceDialect,
2978            >::encode(
2979                (<fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
2980                    &self.name,
2981                ),),
2982                encoder,
2983                offset,
2984                _depth,
2985            )
2986        }
2987    }
2988    unsafe impl<
2989        T0: fidl::encoding::Encode<
2990                fidl::encoding::BoundedString<64>,
2991                fidl::encoding::DefaultFuchsiaResourceDialect,
2992            >,
2993    >
2994        fidl::encoding::Encode<
2995            PacketCaptureProviderReconnectRollingRequest,
2996            fidl::encoding::DefaultFuchsiaResourceDialect,
2997        > for (T0,)
2998    {
2999        #[inline]
3000        unsafe fn encode(
3001            self,
3002            encoder: &mut fidl::encoding::Encoder<
3003                '_,
3004                fidl::encoding::DefaultFuchsiaResourceDialect,
3005            >,
3006            offset: usize,
3007            depth: fidl::encoding::Depth,
3008        ) -> fidl::Result<()> {
3009            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingRequest>(offset);
3010            // Zero out padding regions. There's no need to apply masks
3011            // because the unmasked parts will be overwritten by fields.
3012            // Write the fields.
3013            self.0.encode(encoder, offset + 0, depth)?;
3014            Ok(())
3015        }
3016    }
3017
3018    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3019        for PacketCaptureProviderReconnectRollingRequest
3020    {
3021        #[inline(always)]
3022        fn new_empty() -> Self {
3023            Self {
3024                name: fidl::new_empty!(
3025                    fidl::encoding::BoundedString<64>,
3026                    fidl::encoding::DefaultFuchsiaResourceDialect
3027                ),
3028            }
3029        }
3030
3031        #[inline]
3032        unsafe fn decode(
3033            &mut self,
3034            decoder: &mut fidl::encoding::Decoder<
3035                '_,
3036                fidl::encoding::DefaultFuchsiaResourceDialect,
3037            >,
3038            offset: usize,
3039            _depth: fidl::encoding::Depth,
3040        ) -> fidl::Result<()> {
3041            decoder.debug_check_bounds::<Self>(offset);
3042            // Verify that padding bytes are zero.
3043            fidl::decode!(
3044                fidl::encoding::BoundedString<64>,
3045                fidl::encoding::DefaultFuchsiaResourceDialect,
3046                &mut self.name,
3047                decoder,
3048                offset + 0,
3049                _depth
3050            )?;
3051            Ok(())
3052        }
3053    }
3054
3055    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderStartRollingRequest {
3056        type Borrowed<'a> = &'a mut Self;
3057        fn take_or_borrow<'a>(
3058            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3059        ) -> Self::Borrowed<'a> {
3060            value
3061        }
3062    }
3063
3064    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderStartRollingRequest {
3065        type Owned = Self;
3066
3067        #[inline(always)]
3068        fn inline_align(_context: fidl::encoding::Context) -> usize {
3069            8
3070        }
3071
3072        #[inline(always)]
3073        fn inline_size(_context: fidl::encoding::Context) -> usize {
3074            32
3075        }
3076    }
3077
3078    unsafe impl
3079        fidl::encoding::Encode<
3080            PacketCaptureProviderStartRollingRequest,
3081            fidl::encoding::DefaultFuchsiaResourceDialect,
3082        > for &mut PacketCaptureProviderStartRollingRequest
3083    {
3084        #[inline]
3085        unsafe fn encode(
3086            self,
3087            encoder: &mut fidl::encoding::Encoder<
3088                '_,
3089                fidl::encoding::DefaultFuchsiaResourceDialect,
3090            >,
3091            offset: usize,
3092            _depth: fidl::encoding::Depth,
3093        ) -> fidl::Result<()> {
3094            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingRequest>(offset);
3095            // Delegate to tuple encoding.
3096            fidl::encoding::Encode::<PacketCaptureProviderStartRollingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3097                (
3098                    <CommonPacketCaptureParams as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.common_params),
3099                    <RollingPacketCaptureParams as fidl::encoding::ValueTypeMarker>::borrow(&self.params),
3100                ),
3101                encoder, offset, _depth
3102            )
3103        }
3104    }
3105    unsafe impl<
3106        T0: fidl::encoding::Encode<
3107                CommonPacketCaptureParams,
3108                fidl::encoding::DefaultFuchsiaResourceDialect,
3109            >,
3110        T1: fidl::encoding::Encode<
3111                RollingPacketCaptureParams,
3112                fidl::encoding::DefaultFuchsiaResourceDialect,
3113            >,
3114    >
3115        fidl::encoding::Encode<
3116            PacketCaptureProviderStartRollingRequest,
3117            fidl::encoding::DefaultFuchsiaResourceDialect,
3118        > for (T0, T1)
3119    {
3120        #[inline]
3121        unsafe fn encode(
3122            self,
3123            encoder: &mut fidl::encoding::Encoder<
3124                '_,
3125                fidl::encoding::DefaultFuchsiaResourceDialect,
3126            >,
3127            offset: usize,
3128            depth: fidl::encoding::Depth,
3129        ) -> fidl::Result<()> {
3130            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingRequest>(offset);
3131            // Zero out padding regions. There's no need to apply masks
3132            // because the unmasked parts will be overwritten by fields.
3133            // Write the fields.
3134            self.0.encode(encoder, offset + 0, depth)?;
3135            self.1.encode(encoder, offset + 16, depth)?;
3136            Ok(())
3137        }
3138    }
3139
3140    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3141        for PacketCaptureProviderStartRollingRequest
3142    {
3143        #[inline(always)]
3144        fn new_empty() -> Self {
3145            Self {
3146                common_params: fidl::new_empty!(
3147                    CommonPacketCaptureParams,
3148                    fidl::encoding::DefaultFuchsiaResourceDialect
3149                ),
3150                params: fidl::new_empty!(
3151                    RollingPacketCaptureParams,
3152                    fidl::encoding::DefaultFuchsiaResourceDialect
3153                ),
3154            }
3155        }
3156
3157        #[inline]
3158        unsafe fn decode(
3159            &mut self,
3160            decoder: &mut fidl::encoding::Decoder<
3161                '_,
3162                fidl::encoding::DefaultFuchsiaResourceDialect,
3163            >,
3164            offset: usize,
3165            _depth: fidl::encoding::Depth,
3166        ) -> fidl::Result<()> {
3167            decoder.debug_check_bounds::<Self>(offset);
3168            // Verify that padding bytes are zero.
3169            fidl::decode!(
3170                CommonPacketCaptureParams,
3171                fidl::encoding::DefaultFuchsiaResourceDialect,
3172                &mut self.common_params,
3173                decoder,
3174                offset + 0,
3175                _depth
3176            )?;
3177            fidl::decode!(
3178                RollingPacketCaptureParams,
3179                fidl::encoding::DefaultFuchsiaResourceDialect,
3180                &mut self.params,
3181                decoder,
3182                offset + 16,
3183                _depth
3184            )?;
3185            Ok(())
3186        }
3187    }
3188
3189    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderReconnectRollingResponse {
3190        type Borrowed<'a> = &'a mut Self;
3191        fn take_or_borrow<'a>(
3192            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3193        ) -> Self::Borrowed<'a> {
3194            value
3195        }
3196    }
3197
3198    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderReconnectRollingResponse {
3199        type Owned = Self;
3200
3201        #[inline(always)]
3202        fn inline_align(_context: fidl::encoding::Context) -> usize {
3203            4
3204        }
3205
3206        #[inline(always)]
3207        fn inline_size(_context: fidl::encoding::Context) -> usize {
3208            4
3209        }
3210    }
3211
3212    unsafe impl
3213        fidl::encoding::Encode<
3214            PacketCaptureProviderReconnectRollingResponse,
3215            fidl::encoding::DefaultFuchsiaResourceDialect,
3216        > for &mut PacketCaptureProviderReconnectRollingResponse
3217    {
3218        #[inline]
3219        unsafe fn encode(
3220            self,
3221            encoder: &mut fidl::encoding::Encoder<
3222                '_,
3223                fidl::encoding::DefaultFuchsiaResourceDialect,
3224            >,
3225            offset: usize,
3226            _depth: fidl::encoding::Depth,
3227        ) -> fidl::Result<()> {
3228            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingResponse>(offset);
3229            // Delegate to tuple encoding.
3230            fidl::encoding::Encode::<
3231                PacketCaptureProviderReconnectRollingResponse,
3232                fidl::encoding::DefaultFuchsiaResourceDialect,
3233            >::encode(
3234                (
3235                    <fidl::encoding::Endpoint<
3236                        fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
3237                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3238                        &mut self.channel
3239                    ),
3240                ),
3241                encoder,
3242                offset,
3243                _depth,
3244            )
3245        }
3246    }
3247    unsafe impl<
3248        T0: fidl::encoding::Encode<
3249                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>>,
3250                fidl::encoding::DefaultFuchsiaResourceDialect,
3251            >,
3252    >
3253        fidl::encoding::Encode<
3254            PacketCaptureProviderReconnectRollingResponse,
3255            fidl::encoding::DefaultFuchsiaResourceDialect,
3256        > for (T0,)
3257    {
3258        #[inline]
3259        unsafe fn encode(
3260            self,
3261            encoder: &mut fidl::encoding::Encoder<
3262                '_,
3263                fidl::encoding::DefaultFuchsiaResourceDialect,
3264            >,
3265            offset: usize,
3266            depth: fidl::encoding::Depth,
3267        ) -> fidl::Result<()> {
3268            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingResponse>(offset);
3269            // Zero out padding regions. There's no need to apply masks
3270            // because the unmasked parts will be overwritten by fields.
3271            // Write the fields.
3272            self.0.encode(encoder, offset + 0, depth)?;
3273            Ok(())
3274        }
3275    }
3276
3277    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3278        for PacketCaptureProviderReconnectRollingResponse
3279    {
3280        #[inline(always)]
3281        fn new_empty() -> Self {
3282            Self {
3283                channel: fidl::new_empty!(
3284                    fidl::encoding::Endpoint<
3285                        fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
3286                    >,
3287                    fidl::encoding::DefaultFuchsiaResourceDialect
3288                ),
3289            }
3290        }
3291
3292        #[inline]
3293        unsafe fn decode(
3294            &mut self,
3295            decoder: &mut fidl::encoding::Decoder<
3296                '_,
3297                fidl::encoding::DefaultFuchsiaResourceDialect,
3298            >,
3299            offset: usize,
3300            _depth: fidl::encoding::Depth,
3301        ) -> fidl::Result<()> {
3302            decoder.debug_check_bounds::<Self>(offset);
3303            // Verify that padding bytes are zero.
3304            fidl::decode!(
3305                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>>,
3306                fidl::encoding::DefaultFuchsiaResourceDialect,
3307                &mut self.channel,
3308                decoder,
3309                offset + 0,
3310                _depth
3311            )?;
3312            Ok(())
3313        }
3314    }
3315
3316    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderStartRollingResponse {
3317        type Borrowed<'a> = &'a mut Self;
3318        fn take_or_borrow<'a>(
3319            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3320        ) -> Self::Borrowed<'a> {
3321            value
3322        }
3323    }
3324
3325    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderStartRollingResponse {
3326        type Owned = Self;
3327
3328        #[inline(always)]
3329        fn inline_align(_context: fidl::encoding::Context) -> usize {
3330            4
3331        }
3332
3333        #[inline(always)]
3334        fn inline_size(_context: fidl::encoding::Context) -> usize {
3335            4
3336        }
3337    }
3338
3339    unsafe impl
3340        fidl::encoding::Encode<
3341            PacketCaptureProviderStartRollingResponse,
3342            fidl::encoding::DefaultFuchsiaResourceDialect,
3343        > for &mut PacketCaptureProviderStartRollingResponse
3344    {
3345        #[inline]
3346        unsafe fn encode(
3347            self,
3348            encoder: &mut fidl::encoding::Encoder<
3349                '_,
3350                fidl::encoding::DefaultFuchsiaResourceDialect,
3351            >,
3352            offset: usize,
3353            _depth: fidl::encoding::Depth,
3354        ) -> fidl::Result<()> {
3355            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingResponse>(offset);
3356            // Delegate to tuple encoding.
3357            fidl::encoding::Encode::<
3358                PacketCaptureProviderStartRollingResponse,
3359                fidl::encoding::DefaultFuchsiaResourceDialect,
3360            >::encode(
3361                (
3362                    <fidl::encoding::Endpoint<
3363                        fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
3364                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3365                        &mut self.channel
3366                    ),
3367                ),
3368                encoder,
3369                offset,
3370                _depth,
3371            )
3372        }
3373    }
3374    unsafe impl<
3375        T0: fidl::encoding::Encode<
3376                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>>,
3377                fidl::encoding::DefaultFuchsiaResourceDialect,
3378            >,
3379    >
3380        fidl::encoding::Encode<
3381            PacketCaptureProviderStartRollingResponse,
3382            fidl::encoding::DefaultFuchsiaResourceDialect,
3383        > for (T0,)
3384    {
3385        #[inline]
3386        unsafe fn encode(
3387            self,
3388            encoder: &mut fidl::encoding::Encoder<
3389                '_,
3390                fidl::encoding::DefaultFuchsiaResourceDialect,
3391            >,
3392            offset: usize,
3393            depth: fidl::encoding::Depth,
3394        ) -> fidl::Result<()> {
3395            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingResponse>(offset);
3396            // Zero out padding regions. There's no need to apply masks
3397            // because the unmasked parts will be overwritten by fields.
3398            // Write the fields.
3399            self.0.encode(encoder, offset + 0, depth)?;
3400            Ok(())
3401        }
3402    }
3403
3404    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3405        for PacketCaptureProviderStartRollingResponse
3406    {
3407        #[inline(always)]
3408        fn new_empty() -> Self {
3409            Self {
3410                channel: fidl::new_empty!(
3411                    fidl::encoding::Endpoint<
3412                        fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>,
3413                    >,
3414                    fidl::encoding::DefaultFuchsiaResourceDialect
3415                ),
3416            }
3417        }
3418
3419        #[inline]
3420        unsafe fn decode(
3421            &mut self,
3422            decoder: &mut fidl::encoding::Decoder<
3423                '_,
3424                fidl::encoding::DefaultFuchsiaResourceDialect,
3425            >,
3426            offset: usize,
3427            _depth: fidl::encoding::Depth,
3428        ) -> fidl::Result<()> {
3429            decoder.debug_check_bounds::<Self>(offset);
3430            // Verify that padding bytes are zero.
3431            fidl::decode!(
3432                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RollingPacketCaptureMarker>>,
3433                fidl::encoding::DefaultFuchsiaResourceDialect,
3434                &mut self.channel,
3435                decoder,
3436                offset + 0,
3437                _depth
3438            )?;
3439            Ok(())
3440        }
3441    }
3442
3443    impl fidl::encoding::ResourceTypeMarker for RollingPacketCaptureStopAndDownloadRequest {
3444        type Borrowed<'a> = &'a mut Self;
3445        fn take_or_borrow<'a>(
3446            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3447        ) -> Self::Borrowed<'a> {
3448            value
3449        }
3450    }
3451
3452    unsafe impl fidl::encoding::TypeMarker for RollingPacketCaptureStopAndDownloadRequest {
3453        type Owned = Self;
3454
3455        #[inline(always)]
3456        fn inline_align(_context: fidl::encoding::Context) -> usize {
3457            4
3458        }
3459
3460        #[inline(always)]
3461        fn inline_size(_context: fidl::encoding::Context) -> usize {
3462            4
3463        }
3464    }
3465
3466    unsafe impl
3467        fidl::encoding::Encode<
3468            RollingPacketCaptureStopAndDownloadRequest,
3469            fidl::encoding::DefaultFuchsiaResourceDialect,
3470        > for &mut RollingPacketCaptureStopAndDownloadRequest
3471    {
3472        #[inline]
3473        unsafe fn encode(
3474            self,
3475            encoder: &mut fidl::encoding::Encoder<
3476                '_,
3477                fidl::encoding::DefaultFuchsiaResourceDialect,
3478            >,
3479            offset: usize,
3480            _depth: fidl::encoding::Depth,
3481        ) -> fidl::Result<()> {
3482            encoder.debug_check_bounds::<RollingPacketCaptureStopAndDownloadRequest>(offset);
3483            // Delegate to tuple encoding.
3484            fidl::encoding::Encode::<
3485                RollingPacketCaptureStopAndDownloadRequest,
3486                fidl::encoding::DefaultFuchsiaResourceDialect,
3487            >::encode(
3488                (
3489                    <fidl::encoding::Endpoint<
3490                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
3491                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3492                        &mut self.channel
3493                    ),
3494                ),
3495                encoder,
3496                offset,
3497                _depth,
3498            )
3499        }
3500    }
3501    unsafe impl<
3502        T0: fidl::encoding::Encode<
3503                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>>,
3504                fidl::encoding::DefaultFuchsiaResourceDialect,
3505            >,
3506    >
3507        fidl::encoding::Encode<
3508            RollingPacketCaptureStopAndDownloadRequest,
3509            fidl::encoding::DefaultFuchsiaResourceDialect,
3510        > for (T0,)
3511    {
3512        #[inline]
3513        unsafe fn encode(
3514            self,
3515            encoder: &mut fidl::encoding::Encoder<
3516                '_,
3517                fidl::encoding::DefaultFuchsiaResourceDialect,
3518            >,
3519            offset: usize,
3520            depth: fidl::encoding::Depth,
3521        ) -> fidl::Result<()> {
3522            encoder.debug_check_bounds::<RollingPacketCaptureStopAndDownloadRequest>(offset);
3523            // Zero out padding regions. There's no need to apply masks
3524            // because the unmasked parts will be overwritten by fields.
3525            // Write the fields.
3526            self.0.encode(encoder, offset + 0, depth)?;
3527            Ok(())
3528        }
3529    }
3530
3531    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3532        for RollingPacketCaptureStopAndDownloadRequest
3533    {
3534        #[inline(always)]
3535        fn new_empty() -> Self {
3536            Self {
3537                channel: fidl::new_empty!(
3538                    fidl::encoding::Endpoint<
3539                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>,
3540                    >,
3541                    fidl::encoding::DefaultFuchsiaResourceDialect
3542                ),
3543            }
3544        }
3545
3546        #[inline]
3547        unsafe fn decode(
3548            &mut self,
3549            decoder: &mut fidl::encoding::Decoder<
3550                '_,
3551                fidl::encoding::DefaultFuchsiaResourceDialect,
3552            >,
3553            offset: usize,
3554            _depth: fidl::encoding::Depth,
3555        ) -> fidl::Result<()> {
3556            decoder.debug_check_bounds::<Self>(offset);
3557            // Verify that padding bytes are zero.
3558            fidl::decode!(
3559                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::FileMarker>>,
3560                fidl::encoding::DefaultFuchsiaResourceDialect,
3561                &mut self.channel,
3562                decoder,
3563                offset + 0,
3564                _depth
3565            )?;
3566            Ok(())
3567        }
3568    }
3569
3570    impl CommonPacketCaptureParams {
3571        #[inline(always)]
3572        fn max_ordinal_present(&self) -> u64 {
3573            if let Some(_) = self.snap_len {
3574                return 3;
3575            }
3576            if let Some(_) = self.bpf_program {
3577                return 2;
3578            }
3579            if let Some(_) = self.interfaces {
3580                return 1;
3581            }
3582            0
3583        }
3584    }
3585
3586    impl fidl::encoding::ResourceTypeMarker for CommonPacketCaptureParams {
3587        type Borrowed<'a> = &'a mut Self;
3588        fn take_or_borrow<'a>(
3589            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3590        ) -> Self::Borrowed<'a> {
3591            value
3592        }
3593    }
3594
3595    unsafe impl fidl::encoding::TypeMarker for CommonPacketCaptureParams {
3596        type Owned = Self;
3597
3598        #[inline(always)]
3599        fn inline_align(_context: fidl::encoding::Context) -> usize {
3600            8
3601        }
3602
3603        #[inline(always)]
3604        fn inline_size(_context: fidl::encoding::Context) -> usize {
3605            16
3606        }
3607    }
3608
3609    unsafe impl
3610        fidl::encoding::Encode<
3611            CommonPacketCaptureParams,
3612            fidl::encoding::DefaultFuchsiaResourceDialect,
3613        > for &mut CommonPacketCaptureParams
3614    {
3615        unsafe fn encode(
3616            self,
3617            encoder: &mut fidl::encoding::Encoder<
3618                '_,
3619                fidl::encoding::DefaultFuchsiaResourceDialect,
3620            >,
3621            offset: usize,
3622            mut depth: fidl::encoding::Depth,
3623        ) -> fidl::Result<()> {
3624            encoder.debug_check_bounds::<CommonPacketCaptureParams>(offset);
3625            // Vector header
3626            let max_ordinal: u64 = self.max_ordinal_present();
3627            encoder.write_num(max_ordinal, offset);
3628            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3629            // Calling encoder.out_of_line_offset(0) is not allowed.
3630            if max_ordinal == 0 {
3631                return Ok(());
3632            }
3633            depth.increment()?;
3634            let envelope_size = 8;
3635            let bytes_len = max_ordinal as usize * envelope_size;
3636            #[allow(unused_variables)]
3637            let offset = encoder.out_of_line_offset(bytes_len);
3638            let mut _prev_end_offset: usize = 0;
3639            if 1 > max_ordinal {
3640                return Ok(());
3641            }
3642
3643            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3644            // are envelope_size bytes.
3645            let cur_offset: usize = (1 - 1) * envelope_size;
3646
3647            // Zero reserved fields.
3648            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3649
3650            // Safety:
3651            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3652            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3653            //   envelope_size bytes, there is always sufficient room.
3654            fidl::encoding::encode_in_envelope_optional::<
3655                InterfaceSpecifier,
3656                fidl::encoding::DefaultFuchsiaResourceDialect,
3657            >(
3658                self.interfaces
3659                    .as_ref()
3660                    .map(<InterfaceSpecifier as fidl::encoding::ValueTypeMarker>::borrow),
3661                encoder,
3662                offset + cur_offset,
3663                depth,
3664            )?;
3665
3666            _prev_end_offset = cur_offset + envelope_size;
3667            if 2 > max_ordinal {
3668                return Ok(());
3669            }
3670
3671            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3672            // are envelope_size bytes.
3673            let cur_offset: usize = (2 - 1) * envelope_size;
3674
3675            // Zero reserved fields.
3676            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3677
3678            // Safety:
3679            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3680            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3681            //   envelope_size bytes, there is always sufficient room.
3682            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ebpf::VerifiedProgram, fidl::encoding::DefaultFuchsiaResourceDialect>(
3683            self.bpf_program.as_mut().map(<fidl_fuchsia_ebpf::VerifiedProgram as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3684            encoder, offset + cur_offset, depth
3685        )?;
3686
3687            _prev_end_offset = cur_offset + envelope_size;
3688            if 3 > max_ordinal {
3689                return Ok(());
3690            }
3691
3692            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3693            // are envelope_size bytes.
3694            let cur_offset: usize = (3 - 1) * envelope_size;
3695
3696            // Zero reserved fields.
3697            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3698
3699            // Safety:
3700            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3701            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3702            //   envelope_size bytes, there is always sufficient room.
3703            fidl::encoding::encode_in_envelope_optional::<
3704                u32,
3705                fidl::encoding::DefaultFuchsiaResourceDialect,
3706            >(
3707                self.snap_len.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3708                encoder,
3709                offset + cur_offset,
3710                depth,
3711            )?;
3712
3713            _prev_end_offset = cur_offset + envelope_size;
3714
3715            Ok(())
3716        }
3717    }
3718
3719    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3720        for CommonPacketCaptureParams
3721    {
3722        #[inline(always)]
3723        fn new_empty() -> Self {
3724            Self::default()
3725        }
3726
3727        unsafe fn decode(
3728            &mut self,
3729            decoder: &mut fidl::encoding::Decoder<
3730                '_,
3731                fidl::encoding::DefaultFuchsiaResourceDialect,
3732            >,
3733            offset: usize,
3734            mut depth: fidl::encoding::Depth,
3735        ) -> fidl::Result<()> {
3736            decoder.debug_check_bounds::<Self>(offset);
3737            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3738                None => return Err(fidl::Error::NotNullable),
3739                Some(len) => len,
3740            };
3741            // Calling decoder.out_of_line_offset(0) is not allowed.
3742            if len == 0 {
3743                return Ok(());
3744            };
3745            depth.increment()?;
3746            let envelope_size = 8;
3747            let bytes_len = len * envelope_size;
3748            let offset = decoder.out_of_line_offset(bytes_len)?;
3749            // Decode the envelope for each type.
3750            let mut _next_ordinal_to_read = 0;
3751            let mut next_offset = offset;
3752            let end_offset = offset + bytes_len;
3753            _next_ordinal_to_read += 1;
3754            if next_offset >= end_offset {
3755                return Ok(());
3756            }
3757
3758            // Decode unknown envelopes for gaps in ordinals.
3759            while _next_ordinal_to_read < 1 {
3760                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3761                _next_ordinal_to_read += 1;
3762                next_offset += envelope_size;
3763            }
3764
3765            let next_out_of_line = decoder.next_out_of_line();
3766            let handles_before = decoder.remaining_handles();
3767            if let Some((inlined, num_bytes, num_handles)) =
3768                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3769            {
3770                let member_inline_size =
3771                    <InterfaceSpecifier as fidl::encoding::TypeMarker>::inline_size(
3772                        decoder.context,
3773                    );
3774                if inlined != (member_inline_size <= 4) {
3775                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3776                }
3777                let inner_offset;
3778                let mut inner_depth = depth.clone();
3779                if inlined {
3780                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3781                    inner_offset = next_offset;
3782                } else {
3783                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3784                    inner_depth.increment()?;
3785                }
3786                let val_ref = self.interfaces.get_or_insert_with(|| {
3787                    fidl::new_empty!(
3788                        InterfaceSpecifier,
3789                        fidl::encoding::DefaultFuchsiaResourceDialect
3790                    )
3791                });
3792                fidl::decode!(
3793                    InterfaceSpecifier,
3794                    fidl::encoding::DefaultFuchsiaResourceDialect,
3795                    val_ref,
3796                    decoder,
3797                    inner_offset,
3798                    inner_depth
3799                )?;
3800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3801                {
3802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3803                }
3804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3806                }
3807            }
3808
3809            next_offset += envelope_size;
3810            _next_ordinal_to_read += 1;
3811            if next_offset >= end_offset {
3812                return Ok(());
3813            }
3814
3815            // Decode unknown envelopes for gaps in ordinals.
3816            while _next_ordinal_to_read < 2 {
3817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3818                _next_ordinal_to_read += 1;
3819                next_offset += envelope_size;
3820            }
3821
3822            let next_out_of_line = decoder.next_out_of_line();
3823            let handles_before = decoder.remaining_handles();
3824            if let Some((inlined, num_bytes, num_handles)) =
3825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3826            {
3827                let member_inline_size =
3828                    <fidl_fuchsia_ebpf::VerifiedProgram as fidl::encoding::TypeMarker>::inline_size(
3829                        decoder.context,
3830                    );
3831                if inlined != (member_inline_size <= 4) {
3832                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3833                }
3834                let inner_offset;
3835                let mut inner_depth = depth.clone();
3836                if inlined {
3837                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3838                    inner_offset = next_offset;
3839                } else {
3840                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3841                    inner_depth.increment()?;
3842                }
3843                let val_ref = self.bpf_program.get_or_insert_with(|| {
3844                    fidl::new_empty!(
3845                        fidl_fuchsia_ebpf::VerifiedProgram,
3846                        fidl::encoding::DefaultFuchsiaResourceDialect
3847                    )
3848                });
3849                fidl::decode!(
3850                    fidl_fuchsia_ebpf::VerifiedProgram,
3851                    fidl::encoding::DefaultFuchsiaResourceDialect,
3852                    val_ref,
3853                    decoder,
3854                    inner_offset,
3855                    inner_depth
3856                )?;
3857                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3858                {
3859                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3860                }
3861                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3862                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3863                }
3864            }
3865
3866            next_offset += envelope_size;
3867            _next_ordinal_to_read += 1;
3868            if next_offset >= end_offset {
3869                return Ok(());
3870            }
3871
3872            // Decode unknown envelopes for gaps in ordinals.
3873            while _next_ordinal_to_read < 3 {
3874                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3875                _next_ordinal_to_read += 1;
3876                next_offset += envelope_size;
3877            }
3878
3879            let next_out_of_line = decoder.next_out_of_line();
3880            let handles_before = decoder.remaining_handles();
3881            if let Some((inlined, num_bytes, num_handles)) =
3882                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3883            {
3884                let member_inline_size =
3885                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3886                if inlined != (member_inline_size <= 4) {
3887                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3888                }
3889                let inner_offset;
3890                let mut inner_depth = depth.clone();
3891                if inlined {
3892                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3893                    inner_offset = next_offset;
3894                } else {
3895                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3896                    inner_depth.increment()?;
3897                }
3898                let val_ref = self.snap_len.get_or_insert_with(|| {
3899                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
3900                });
3901                fidl::decode!(
3902                    u32,
3903                    fidl::encoding::DefaultFuchsiaResourceDialect,
3904                    val_ref,
3905                    decoder,
3906                    inner_offset,
3907                    inner_depth
3908                )?;
3909                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3910                {
3911                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3912                }
3913                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3914                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3915                }
3916            }
3917
3918            next_offset += envelope_size;
3919
3920            // Decode the remaining unknown envelopes.
3921            while next_offset < end_offset {
3922                _next_ordinal_to_read += 1;
3923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3924                next_offset += envelope_size;
3925            }
3926
3927            Ok(())
3928        }
3929    }
3930}