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