Skip to main content

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