Skip to main content

fidl_fuchsia_net_debug/
fidl_fuchsia_net_debug.rs

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