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    /// If another channel is already connected to the packet capture, it will be
1176    /// closed to make room for this connection.
1177    ///
1178    /// Note reconnecting does not reattach the lifetime of the packet capture to
1179    /// `channel`.
1180    pub fn r#reconnect_rolling(
1181        &self,
1182        mut name: &str,
1183    ) -> fidl::client::QueryResponseFut<
1184        PacketCaptureProviderReconnectRollingResult,
1185        fdomain_client::fidl::FDomainResourceDialect,
1186    > {
1187        PacketCaptureProviderProxyInterface::r#reconnect_rolling(self, name)
1188    }
1189}
1190
1191impl PacketCaptureProviderProxyInterface for PacketCaptureProviderProxy {
1192    type StartRollingResponseFut = fidl::client::QueryResponseFut<
1193        PacketCaptureProviderStartRollingResult,
1194        fdomain_client::fidl::FDomainResourceDialect,
1195    >;
1196    fn r#start_rolling(
1197        &self,
1198        mut common_params: CommonPacketCaptureParams,
1199        mut params: &RollingPacketCaptureParams,
1200    ) -> Self::StartRollingResponseFut {
1201        fn _decode(
1202            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1203        ) -> Result<PacketCaptureProviderStartRollingResult, fidl::Error> {
1204            let _response = fidl::client::decode_transaction_body::<
1205                fidl::encoding::ResultType<
1206                    PacketCaptureProviderStartRollingResponse,
1207                    PacketCaptureStartError,
1208                >,
1209                fdomain_client::fidl::FDomainResourceDialect,
1210                0x4a5b2305ea27e845,
1211            >(_buf?)?;
1212            Ok(_response.map(|x| x.channel))
1213        }
1214        self.client.send_query_and_decode::<
1215            PacketCaptureProviderStartRollingRequest,
1216            PacketCaptureProviderStartRollingResult,
1217        >(
1218            (&mut common_params, params,),
1219            0x4a5b2305ea27e845,
1220            fidl::encoding::DynamicFlags::empty(),
1221            _decode,
1222        )
1223    }
1224
1225    type ReconnectRollingResponseFut = fidl::client::QueryResponseFut<
1226        PacketCaptureProviderReconnectRollingResult,
1227        fdomain_client::fidl::FDomainResourceDialect,
1228    >;
1229    fn r#reconnect_rolling(&self, mut name: &str) -> Self::ReconnectRollingResponseFut {
1230        fn _decode(
1231            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1232        ) -> Result<PacketCaptureProviderReconnectRollingResult, fidl::Error> {
1233            let _response = fidl::client::decode_transaction_body::<
1234                fidl::encoding::ResultType<
1235                    PacketCaptureProviderReconnectRollingResponse,
1236                    PacketCaptureReconnectError,
1237                >,
1238                fdomain_client::fidl::FDomainResourceDialect,
1239                0x57828e9ed034a522,
1240            >(_buf?)?;
1241            Ok(_response.map(|x| x.channel))
1242        }
1243        self.client.send_query_and_decode::<
1244            PacketCaptureProviderReconnectRollingRequest,
1245            PacketCaptureProviderReconnectRollingResult,
1246        >(
1247            (name,),
1248            0x57828e9ed034a522,
1249            fidl::encoding::DynamicFlags::empty(),
1250            _decode,
1251        )
1252    }
1253}
1254
1255pub struct PacketCaptureProviderEventStream {
1256    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1257}
1258
1259impl std::marker::Unpin for PacketCaptureProviderEventStream {}
1260
1261impl futures::stream::FusedStream for PacketCaptureProviderEventStream {
1262    fn is_terminated(&self) -> bool {
1263        self.event_receiver.is_terminated()
1264    }
1265}
1266
1267impl futures::Stream for PacketCaptureProviderEventStream {
1268    type Item = Result<PacketCaptureProviderEvent, fidl::Error>;
1269
1270    fn poll_next(
1271        mut self: std::pin::Pin<&mut Self>,
1272        cx: &mut std::task::Context<'_>,
1273    ) -> std::task::Poll<Option<Self::Item>> {
1274        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1275            &mut self.event_receiver,
1276            cx
1277        )?) {
1278            Some(buf) => std::task::Poll::Ready(Some(PacketCaptureProviderEvent::decode(buf))),
1279            None => std::task::Poll::Ready(None),
1280        }
1281    }
1282}
1283
1284#[derive(Debug)]
1285pub enum PacketCaptureProviderEvent {}
1286
1287impl PacketCaptureProviderEvent {
1288    /// Decodes a message buffer as a [`PacketCaptureProviderEvent`].
1289    fn decode(
1290        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1291    ) -> Result<PacketCaptureProviderEvent, fidl::Error> {
1292        let (bytes, _handles) = buf.split_mut();
1293        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1294        debug_assert_eq!(tx_header.tx_id, 0);
1295        match tx_header.ordinal {
1296            _ => Err(fidl::Error::UnknownOrdinal {
1297                ordinal: tx_header.ordinal,
1298                protocol_name: <PacketCaptureProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1299            })
1300        }
1301    }
1302}
1303
1304/// A Stream of incoming requests for fuchsia.net.debug/PacketCaptureProvider.
1305pub struct PacketCaptureProviderRequestStream {
1306    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1307    is_terminated: bool,
1308}
1309
1310impl std::marker::Unpin for PacketCaptureProviderRequestStream {}
1311
1312impl futures::stream::FusedStream for PacketCaptureProviderRequestStream {
1313    fn is_terminated(&self) -> bool {
1314        self.is_terminated
1315    }
1316}
1317
1318impl fdomain_client::fidl::RequestStream for PacketCaptureProviderRequestStream {
1319    type Protocol = PacketCaptureProviderMarker;
1320    type ControlHandle = PacketCaptureProviderControlHandle;
1321
1322    fn from_channel(channel: fdomain_client::Channel) -> Self {
1323        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1324    }
1325
1326    fn control_handle(&self) -> Self::ControlHandle {
1327        PacketCaptureProviderControlHandle { inner: self.inner.clone() }
1328    }
1329
1330    fn into_inner(
1331        self,
1332    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1333    {
1334        (self.inner, self.is_terminated)
1335    }
1336
1337    fn from_inner(
1338        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1339        is_terminated: bool,
1340    ) -> Self {
1341        Self { inner, is_terminated }
1342    }
1343}
1344
1345impl futures::Stream for PacketCaptureProviderRequestStream {
1346    type Item = Result<PacketCaptureProviderRequest, fidl::Error>;
1347
1348    fn poll_next(
1349        mut self: std::pin::Pin<&mut Self>,
1350        cx: &mut std::task::Context<'_>,
1351    ) -> std::task::Poll<Option<Self::Item>> {
1352        let this = &mut *self;
1353        if this.inner.check_shutdown(cx) {
1354            this.is_terminated = true;
1355            return std::task::Poll::Ready(None);
1356        }
1357        if this.is_terminated {
1358            panic!("polled PacketCaptureProviderRequestStream after completion");
1359        }
1360        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1361            |bytes, handles| {
1362                match this.inner.channel().read_etc(cx, bytes, handles) {
1363                    std::task::Poll::Ready(Ok(())) => {}
1364                    std::task::Poll::Pending => return std::task::Poll::Pending,
1365                    std::task::Poll::Ready(Err(None)) => {
1366                        this.is_terminated = true;
1367                        return std::task::Poll::Ready(None);
1368                    }
1369                    std::task::Poll::Ready(Err(Some(e))) => {
1370                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1371                            e.into(),
1372                        ))));
1373                    }
1374                }
1375
1376                // A message has been received from the channel
1377                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1378
1379                std::task::Poll::Ready(Some(match header.ordinal {
1380                0x4a5b2305ea27e845 => {
1381                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1382                    let mut req = fidl::new_empty!(PacketCaptureProviderStartRollingRequest, fdomain_client::fidl::FDomainResourceDialect);
1383                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PacketCaptureProviderStartRollingRequest>(&header, _body_bytes, handles, &mut req)?;
1384                    let control_handle = PacketCaptureProviderControlHandle {
1385                        inner: this.inner.clone(),
1386                    };
1387                    Ok(PacketCaptureProviderRequest::StartRolling {common_params: req.common_params,
1388params: req.params,
1389
1390                        responder: PacketCaptureProviderStartRollingResponder {
1391                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1392                            tx_id: header.tx_id,
1393                        },
1394                    })
1395                }
1396                0x57828e9ed034a522 => {
1397                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1398                    let mut req = fidl::new_empty!(PacketCaptureProviderReconnectRollingRequest, fdomain_client::fidl::FDomainResourceDialect);
1399                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PacketCaptureProviderReconnectRollingRequest>(&header, _body_bytes, handles, &mut req)?;
1400                    let control_handle = PacketCaptureProviderControlHandle {
1401                        inner: this.inner.clone(),
1402                    };
1403                    Ok(PacketCaptureProviderRequest::ReconnectRolling {name: req.name,
1404
1405                        responder: PacketCaptureProviderReconnectRollingResponder {
1406                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1407                            tx_id: header.tx_id,
1408                        },
1409                    })
1410                }
1411                _ => Err(fidl::Error::UnknownOrdinal {
1412                    ordinal: header.ordinal,
1413                    protocol_name: <PacketCaptureProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1414                }),
1415            }))
1416            },
1417        )
1418    }
1419}
1420
1421/// Provides packet captures.
1422///
1423/// [`PacketCaptureProvider.StartRolling`] is recommended if:
1424/// 1. You need resilience against network interruptions closing the channel
1425///    tied to the packet capture’s lifetime.
1426/// 2. You know when the packets of interest get captured, e.g. when a specific
1427///    networking event you’re looking for occurs.
1428/// 3. Not having to continuously read packet capture data from the Netstack
1429///    is a benefit.
1430///
1431/// Note that in order to conserve memory, the server maintains a limit on the
1432/// number of concurrent packet captures, and starting another packet capture
1433/// when the quota has been met fails.
1434///
1435/// In all cases, the server sends the packet captures in [pcapng format],
1436/// i.e. there is a Section Header Block at the start of each packet capture
1437/// followed by one or more Interface Description Blocks, followed by Enhanced
1438/// Packet Blocks containing packet data. Other blocks defined by the pcapng
1439/// file standard may appear as well.
1440///
1441/// [pcapng format]: https://www.ietf.org/archive/id/draft-ietf-opsawg-pcapng-05.html
1442#[derive(Debug)]
1443pub enum PacketCaptureProviderRequest {
1444    /// Start a rolling packet capture.
1445    ///
1446    /// Lifetime of the packet capture is tied to the pipelined `channel` unless
1447    /// [`RollingPacketCapture.Detach`] has been called.
1448    ///
1449    /// ## Error
1450    ///
1451    /// All variants of [`PacketCaptureStartError`] may be returned by this
1452    /// method.
1453    StartRolling {
1454        common_params: CommonPacketCaptureParams,
1455        params: RollingPacketCaptureParams,
1456        responder: PacketCaptureProviderStartRollingResponder,
1457    },
1458    /// Reconnects to a packet capture previously started with
1459    /// [`PacketCaptureProvider/StartRolling`].
1460    ///
1461    /// If another channel is already connected to the packet capture, it will be
1462    /// closed to make room for this connection.
1463    ///
1464    /// Note reconnecting does not reattach the lifetime of the packet capture to
1465    /// `channel`.
1466    ReconnectRolling { name: String, responder: PacketCaptureProviderReconnectRollingResponder },
1467}
1468
1469impl PacketCaptureProviderRequest {
1470    #[allow(irrefutable_let_patterns)]
1471    pub fn into_start_rolling(
1472        self,
1473    ) -> Option<(
1474        CommonPacketCaptureParams,
1475        RollingPacketCaptureParams,
1476        PacketCaptureProviderStartRollingResponder,
1477    )> {
1478        if let PacketCaptureProviderRequest::StartRolling { common_params, params, responder } =
1479            self
1480        {
1481            Some((common_params, params, responder))
1482        } else {
1483            None
1484        }
1485    }
1486
1487    #[allow(irrefutable_let_patterns)]
1488    pub fn into_reconnect_rolling(
1489        self,
1490    ) -> Option<(String, PacketCaptureProviderReconnectRollingResponder)> {
1491        if let PacketCaptureProviderRequest::ReconnectRolling { name, responder } = self {
1492            Some((name, responder))
1493        } else {
1494            None
1495        }
1496    }
1497
1498    /// Name of the method defined in FIDL
1499    pub fn method_name(&self) -> &'static str {
1500        match *self {
1501            PacketCaptureProviderRequest::StartRolling { .. } => "start_rolling",
1502            PacketCaptureProviderRequest::ReconnectRolling { .. } => "reconnect_rolling",
1503        }
1504    }
1505}
1506
1507#[derive(Debug, Clone)]
1508pub struct PacketCaptureProviderControlHandle {
1509    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1510}
1511
1512impl fdomain_client::fidl::ControlHandle for PacketCaptureProviderControlHandle {
1513    fn shutdown(&self) {
1514        self.inner.shutdown()
1515    }
1516
1517    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1518        self.inner.shutdown_with_epitaph(status)
1519    }
1520
1521    fn is_closed(&self) -> bool {
1522        self.inner.channel().is_closed()
1523    }
1524    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1525        self.inner.channel().on_closed()
1526    }
1527}
1528
1529impl PacketCaptureProviderControlHandle {}
1530
1531#[must_use = "FIDL methods require a response to be sent"]
1532#[derive(Debug)]
1533pub struct PacketCaptureProviderStartRollingResponder {
1534    control_handle: std::mem::ManuallyDrop<PacketCaptureProviderControlHandle>,
1535    tx_id: u32,
1536}
1537
1538/// Set the the channel to be shutdown (see [`PacketCaptureProviderControlHandle::shutdown`])
1539/// if the responder is dropped without sending a response, so that the client
1540/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1541impl std::ops::Drop for PacketCaptureProviderStartRollingResponder {
1542    fn drop(&mut self) {
1543        self.control_handle.shutdown();
1544        // Safety: drops once, never accessed again
1545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1546    }
1547}
1548
1549impl fdomain_client::fidl::Responder for PacketCaptureProviderStartRollingResponder {
1550    type ControlHandle = PacketCaptureProviderControlHandle;
1551
1552    fn control_handle(&self) -> &PacketCaptureProviderControlHandle {
1553        &self.control_handle
1554    }
1555
1556    fn drop_without_shutdown(mut self) {
1557        // Safety: drops once, never accessed again due to mem::forget
1558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1559        // Prevent Drop from running (which would shut down the channel)
1560        std::mem::forget(self);
1561    }
1562}
1563
1564impl PacketCaptureProviderStartRollingResponder {
1565    /// Sends a response to the FIDL transaction.
1566    ///
1567    /// Sets the channel to shutdown if an error occurs.
1568    pub fn send(
1569        self,
1570        mut result: Result<
1571            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1572            PacketCaptureStartError,
1573        >,
1574    ) -> Result<(), fidl::Error> {
1575        let _result = self.send_raw(result);
1576        if _result.is_err() {
1577            self.control_handle.shutdown();
1578        }
1579        self.drop_without_shutdown();
1580        _result
1581    }
1582
1583    /// Similar to "send" but does not shutdown the channel if an error occurs.
1584    pub fn send_no_shutdown_on_err(
1585        self,
1586        mut result: Result<
1587            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1588            PacketCaptureStartError,
1589        >,
1590    ) -> Result<(), fidl::Error> {
1591        let _result = self.send_raw(result);
1592        self.drop_without_shutdown();
1593        _result
1594    }
1595
1596    fn send_raw(
1597        &self,
1598        mut result: Result<
1599            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1600            PacketCaptureStartError,
1601        >,
1602    ) -> Result<(), fidl::Error> {
1603        self.control_handle.inner.send::<fidl::encoding::ResultType<
1604            PacketCaptureProviderStartRollingResponse,
1605            PacketCaptureStartError,
1606        >>(
1607            result.map(|channel| (channel,)),
1608            self.tx_id,
1609            0x4a5b2305ea27e845,
1610            fidl::encoding::DynamicFlags::empty(),
1611        )
1612    }
1613}
1614
1615#[must_use = "FIDL methods require a response to be sent"]
1616#[derive(Debug)]
1617pub struct PacketCaptureProviderReconnectRollingResponder {
1618    control_handle: std::mem::ManuallyDrop<PacketCaptureProviderControlHandle>,
1619    tx_id: u32,
1620}
1621
1622/// Set the the channel to be shutdown (see [`PacketCaptureProviderControlHandle::shutdown`])
1623/// if the responder is dropped without sending a response, so that the client
1624/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1625impl std::ops::Drop for PacketCaptureProviderReconnectRollingResponder {
1626    fn drop(&mut self) {
1627        self.control_handle.shutdown();
1628        // Safety: drops once, never accessed again
1629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1630    }
1631}
1632
1633impl fdomain_client::fidl::Responder for PacketCaptureProviderReconnectRollingResponder {
1634    type ControlHandle = PacketCaptureProviderControlHandle;
1635
1636    fn control_handle(&self) -> &PacketCaptureProviderControlHandle {
1637        &self.control_handle
1638    }
1639
1640    fn drop_without_shutdown(mut self) {
1641        // Safety: drops once, never accessed again due to mem::forget
1642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1643        // Prevent Drop from running (which would shut down the channel)
1644        std::mem::forget(self);
1645    }
1646}
1647
1648impl PacketCaptureProviderReconnectRollingResponder {
1649    /// Sends a response to the FIDL transaction.
1650    ///
1651    /// Sets the channel to shutdown if an error occurs.
1652    pub fn send(
1653        self,
1654        mut result: Result<
1655            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1656            PacketCaptureReconnectError,
1657        >,
1658    ) -> Result<(), fidl::Error> {
1659        let _result = self.send_raw(result);
1660        if _result.is_err() {
1661            self.control_handle.shutdown();
1662        }
1663        self.drop_without_shutdown();
1664        _result
1665    }
1666
1667    /// Similar to "send" but does not shutdown the channel if an error occurs.
1668    pub fn send_no_shutdown_on_err(
1669        self,
1670        mut result: Result<
1671            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1672            PacketCaptureReconnectError,
1673        >,
1674    ) -> Result<(), fidl::Error> {
1675        let _result = self.send_raw(result);
1676        self.drop_without_shutdown();
1677        _result
1678    }
1679
1680    fn send_raw(
1681        &self,
1682        mut result: Result<
1683            fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
1684            PacketCaptureReconnectError,
1685        >,
1686    ) -> Result<(), fidl::Error> {
1687        self.control_handle.inner.send::<fidl::encoding::ResultType<
1688            PacketCaptureProviderReconnectRollingResponse,
1689            PacketCaptureReconnectError,
1690        >>(
1691            result.map(|channel| (channel,)),
1692            self.tx_id,
1693            0x57828e9ed034a522,
1694            fidl::encoding::DynamicFlags::empty(),
1695        )
1696    }
1697}
1698
1699#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1700pub struct RollingPacketCaptureMarker;
1701
1702impl fdomain_client::fidl::ProtocolMarker for RollingPacketCaptureMarker {
1703    type Proxy = RollingPacketCaptureProxy;
1704    type RequestStream = RollingPacketCaptureRequestStream;
1705
1706    const DEBUG_NAME: &'static str = "(anonymous) RollingPacketCapture";
1707}
1708pub type RollingPacketCaptureDetachResult = Result<(), RollingPacketCaptureDetachError>;
1709
1710pub trait RollingPacketCaptureProxyInterface: Send + Sync {
1711    type DetachResponseFut: std::future::Future<Output = Result<RollingPacketCaptureDetachResult, fidl::Error>>
1712        + Send;
1713    fn r#detach(&self, name: &str) -> Self::DetachResponseFut;
1714    fn r#stop_and_download(
1715        &self,
1716        channel: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
1717    ) -> Result<(), fidl::Error>;
1718    type DiscardResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1719    fn r#discard(&self) -> Self::DiscardResponseFut;
1720}
1721
1722#[derive(Debug, Clone)]
1723pub struct RollingPacketCaptureProxy {
1724    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1725}
1726
1727impl fdomain_client::fidl::Proxy for RollingPacketCaptureProxy {
1728    type Protocol = RollingPacketCaptureMarker;
1729
1730    fn from_channel(inner: fdomain_client::Channel) -> Self {
1731        Self::new(inner)
1732    }
1733
1734    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1735        self.client.into_channel().map_err(|client| Self { client })
1736    }
1737
1738    fn as_channel(&self) -> &fdomain_client::Channel {
1739        self.client.as_channel()
1740    }
1741}
1742
1743impl RollingPacketCaptureProxy {
1744    /// Create a new Proxy for fuchsia.net.debug/RollingPacketCapture.
1745    pub fn new(channel: fdomain_client::Channel) -> Self {
1746        let protocol_name =
1747            <RollingPacketCaptureMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1748        Self { client: fidl::client::Client::new(channel, protocol_name) }
1749    }
1750
1751    /// Get a Stream of events from the remote end of the protocol.
1752    ///
1753    /// # Panics
1754    ///
1755    /// Panics if the event stream was already taken.
1756    pub fn take_event_stream(&self) -> RollingPacketCaptureEventStream {
1757        RollingPacketCaptureEventStream { event_receiver: self.client.take_event_receiver() }
1758    }
1759
1760    /// Detaches the lifetime of this protocol from the underlying packet
1761    /// capture.
1762    ///
1763    /// After calling `Detach`, closing the client end no longer results in
1764    /// the packet capture from being terminated. The passed string names
1765    /// this packet capture and can be used thereafter to reconnect via
1766    /// [`PacketCaptureProvider.ReconnectRolling`]. The protocol is still
1767    /// detached after reconnecting. This gives the client the option of
1768    /// ensuring the packet capture is resilient against disconnections.
1769    ///
1770    /// Only the first call to `Detach` over the lifetime of the packet
1771    /// capture (note this is different from the lifetime of this protocol
1772    /// since it's possible to disconnect and reconnect) is valid. Subsequent
1773    /// calls cannot change the name of this capture.
1774    ///
1775    /// Once this method returns, it is guaranteed that this rolling packet
1776    /// capture is detached.
1777    pub fn r#detach(
1778        &self,
1779        mut name: &str,
1780    ) -> fidl::client::QueryResponseFut<
1781        RollingPacketCaptureDetachResult,
1782        fdomain_client::fidl::FDomainResourceDialect,
1783    > {
1784        RollingPacketCaptureProxyInterface::r#detach(self, name)
1785    }
1786
1787    /// Stop and make this rolling packet capture downloadable.
1788    ///
1789    /// It is implicit by calling this method that the packet capture is stopped
1790    /// due to user request, so the [`RollingPacketCapture.OnEnded`] event is
1791    /// not emitted.
1792    ///
1793    /// This method can be called multiple times, including across disconnects:
1794    /// a client can call this method, disconnect, reconnect, and call this
1795    /// method again.
1796    ///
1797    /// The server discards the contents of the packet capture once this
1798    /// method has been called and there is no client connected to this protocol
1799    /// for some time.
1800    pub fn r#stop_and_download(
1801        &self,
1802        mut channel: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
1803    ) -> Result<(), fidl::Error> {
1804        RollingPacketCaptureProxyInterface::r#stop_and_download(self, channel)
1805    }
1806
1807    /// Discard this rolling packet capture.
1808    ///
1809    /// Clients should call this method when they have successfully downloaded
1810    /// the packet capture, or if they no longer need it for any reason.
1811    ///
1812    /// The server closes all readers initialized via [`StopAndDownload`]
1813    /// and all future interactions on this protocol are invalid. When this
1814    /// method returns, it is guaranteed that the packet capture has been
1815    /// discarded and the usage quota has been released.
1816    pub fn r#discard(
1817        &self,
1818    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1819        RollingPacketCaptureProxyInterface::r#discard(self)
1820    }
1821}
1822
1823impl RollingPacketCaptureProxyInterface for RollingPacketCaptureProxy {
1824    type DetachResponseFut = fidl::client::QueryResponseFut<
1825        RollingPacketCaptureDetachResult,
1826        fdomain_client::fidl::FDomainResourceDialect,
1827    >;
1828    fn r#detach(&self, mut name: &str) -> Self::DetachResponseFut {
1829        fn _decode(
1830            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1831        ) -> Result<RollingPacketCaptureDetachResult, fidl::Error> {
1832            let _response = fidl::client::decode_transaction_body::<
1833                fidl::encoding::ResultType<
1834                    fidl::encoding::EmptyStruct,
1835                    RollingPacketCaptureDetachError,
1836                >,
1837                fdomain_client::fidl::FDomainResourceDialect,
1838                0xb3d28b9518e7db0,
1839            >(_buf?)?;
1840            Ok(_response.map(|x| x))
1841        }
1842        self.client.send_query_and_decode::<
1843            RollingPacketCaptureDetachRequest,
1844            RollingPacketCaptureDetachResult,
1845        >(
1846            (name,),
1847            0xb3d28b9518e7db0,
1848            fidl::encoding::DynamicFlags::empty(),
1849            _decode,
1850        )
1851    }
1852
1853    fn r#stop_and_download(
1854        &self,
1855        mut channel: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
1856    ) -> Result<(), fidl::Error> {
1857        self.client.send::<RollingPacketCaptureStopAndDownloadRequest>(
1858            (channel,),
1859            0x268270260a49e2ea,
1860            fidl::encoding::DynamicFlags::empty(),
1861        )
1862    }
1863
1864    type DiscardResponseFut =
1865        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1866    fn r#discard(&self) -> Self::DiscardResponseFut {
1867        fn _decode(
1868            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1869        ) -> Result<(), fidl::Error> {
1870            let _response = fidl::client::decode_transaction_body::<
1871                fidl::encoding::EmptyPayload,
1872                fdomain_client::fidl::FDomainResourceDialect,
1873                0x89e60c428d47a1,
1874            >(_buf?)?;
1875            Ok(_response)
1876        }
1877        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1878            (),
1879            0x89e60c428d47a1,
1880            fidl::encoding::DynamicFlags::empty(),
1881            _decode,
1882        )
1883    }
1884}
1885
1886pub struct RollingPacketCaptureEventStream {
1887    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1888}
1889
1890impl std::marker::Unpin for RollingPacketCaptureEventStream {}
1891
1892impl futures::stream::FusedStream for RollingPacketCaptureEventStream {
1893    fn is_terminated(&self) -> bool {
1894        self.event_receiver.is_terminated()
1895    }
1896}
1897
1898impl futures::Stream for RollingPacketCaptureEventStream {
1899    type Item = Result<RollingPacketCaptureEvent, fidl::Error>;
1900
1901    fn poll_next(
1902        mut self: std::pin::Pin<&mut Self>,
1903        cx: &mut std::task::Context<'_>,
1904    ) -> std::task::Poll<Option<Self::Item>> {
1905        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1906            &mut self.event_receiver,
1907            cx
1908        )?) {
1909            Some(buf) => std::task::Poll::Ready(Some(RollingPacketCaptureEvent::decode(buf))),
1910            None => std::task::Poll::Ready(None),
1911        }
1912    }
1913}
1914
1915#[derive(Debug)]
1916pub enum RollingPacketCaptureEvent {
1917    OnEnded { reason: PacketCaptureEndReason },
1918}
1919
1920impl RollingPacketCaptureEvent {
1921    #[allow(irrefutable_let_patterns)]
1922    pub fn into_on_ended(self) -> Option<PacketCaptureEndReason> {
1923        if let RollingPacketCaptureEvent::OnEnded { reason } = self { Some((reason)) } else { None }
1924    }
1925
1926    /// Decodes a message buffer as a [`RollingPacketCaptureEvent`].
1927    fn decode(
1928        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1929    ) -> Result<RollingPacketCaptureEvent, fidl::Error> {
1930        let (bytes, _handles) = buf.split_mut();
1931        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1932        debug_assert_eq!(tx_header.tx_id, 0);
1933        match tx_header.ordinal {
1934            0x74690c9d4f59f506 => {
1935                let mut out = fidl::new_empty!(
1936                    RollingPacketCaptureOnEndedRequest,
1937                    fdomain_client::fidl::FDomainResourceDialect
1938                );
1939                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<RollingPacketCaptureOnEndedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1940                Ok((RollingPacketCaptureEvent::OnEnded { reason: out.reason }))
1941            }
1942            _ => Err(fidl::Error::UnknownOrdinal {
1943                ordinal: tx_header.ordinal,
1944                protocol_name:
1945                    <RollingPacketCaptureMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1946            }),
1947        }
1948    }
1949}
1950
1951/// A Stream of incoming requests for fuchsia.net.debug/RollingPacketCapture.
1952pub struct RollingPacketCaptureRequestStream {
1953    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1954    is_terminated: bool,
1955}
1956
1957impl std::marker::Unpin for RollingPacketCaptureRequestStream {}
1958
1959impl futures::stream::FusedStream for RollingPacketCaptureRequestStream {
1960    fn is_terminated(&self) -> bool {
1961        self.is_terminated
1962    }
1963}
1964
1965impl fdomain_client::fidl::RequestStream for RollingPacketCaptureRequestStream {
1966    type Protocol = RollingPacketCaptureMarker;
1967    type ControlHandle = RollingPacketCaptureControlHandle;
1968
1969    fn from_channel(channel: fdomain_client::Channel) -> Self {
1970        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1971    }
1972
1973    fn control_handle(&self) -> Self::ControlHandle {
1974        RollingPacketCaptureControlHandle { inner: self.inner.clone() }
1975    }
1976
1977    fn into_inner(
1978        self,
1979    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1980    {
1981        (self.inner, self.is_terminated)
1982    }
1983
1984    fn from_inner(
1985        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1986        is_terminated: bool,
1987    ) -> Self {
1988        Self { inner, is_terminated }
1989    }
1990}
1991
1992impl futures::Stream for RollingPacketCaptureRequestStream {
1993    type Item = Result<RollingPacketCaptureRequest, fidl::Error>;
1994
1995    fn poll_next(
1996        mut self: std::pin::Pin<&mut Self>,
1997        cx: &mut std::task::Context<'_>,
1998    ) -> std::task::Poll<Option<Self::Item>> {
1999        let this = &mut *self;
2000        if this.inner.check_shutdown(cx) {
2001            this.is_terminated = true;
2002            return std::task::Poll::Ready(None);
2003        }
2004        if this.is_terminated {
2005            panic!("polled RollingPacketCaptureRequestStream after completion");
2006        }
2007        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2008            |bytes, handles| {
2009                match this.inner.channel().read_etc(cx, bytes, handles) {
2010                    std::task::Poll::Ready(Ok(())) => {}
2011                    std::task::Poll::Pending => return std::task::Poll::Pending,
2012                    std::task::Poll::Ready(Err(None)) => {
2013                        this.is_terminated = true;
2014                        return std::task::Poll::Ready(None);
2015                    }
2016                    std::task::Poll::Ready(Err(Some(e))) => {
2017                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2018                            e.into(),
2019                        ))));
2020                    }
2021                }
2022
2023                // A message has been received from the channel
2024                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2025
2026                std::task::Poll::Ready(Some(match header.ordinal {
2027                0xb3d28b9518e7db0 => {
2028                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2029                    let mut req = fidl::new_empty!(RollingPacketCaptureDetachRequest, fdomain_client::fidl::FDomainResourceDialect);
2030                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<RollingPacketCaptureDetachRequest>(&header, _body_bytes, handles, &mut req)?;
2031                    let control_handle = RollingPacketCaptureControlHandle {
2032                        inner: this.inner.clone(),
2033                    };
2034                    Ok(RollingPacketCaptureRequest::Detach {name: req.name,
2035
2036                        responder: RollingPacketCaptureDetachResponder {
2037                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2038                            tx_id: header.tx_id,
2039                        },
2040                    })
2041                }
2042                0x268270260a49e2ea => {
2043                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2044                    let mut req = fidl::new_empty!(RollingPacketCaptureStopAndDownloadRequest, fdomain_client::fidl::FDomainResourceDialect);
2045                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<RollingPacketCaptureStopAndDownloadRequest>(&header, _body_bytes, handles, &mut req)?;
2046                    let control_handle = RollingPacketCaptureControlHandle {
2047                        inner: this.inner.clone(),
2048                    };
2049                    Ok(RollingPacketCaptureRequest::StopAndDownload {channel: req.channel,
2050
2051                        control_handle,
2052                    })
2053                }
2054                0x89e60c428d47a1 => {
2055                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2056                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2057                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2058                    let control_handle = RollingPacketCaptureControlHandle {
2059                        inner: this.inner.clone(),
2060                    };
2061                    Ok(RollingPacketCaptureRequest::Discard {
2062                        responder: RollingPacketCaptureDiscardResponder {
2063                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2064                            tx_id: header.tx_id,
2065                        },
2066                    })
2067                }
2068                _ => Err(fidl::Error::UnknownOrdinal {
2069                    ordinal: header.ordinal,
2070                    protocol_name: <RollingPacketCaptureMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2071                }),
2072            }))
2073            },
2074        )
2075    }
2076}
2077
2078/// Rolling packet capture.
2079///
2080/// Once a rolling packet capture has stopped either because [`StopAndDownload`]
2081/// has been called or the capture stopped for some other reason and the server
2082/// has emitted [`OnEnded`], and there is no client connected to this protocol
2083/// for some time, the server discards the contents of the packet capture.
2084/// This timeout resets every time a client reconnects to this protocol, and
2085/// exists to provide resilience against disconnections.
2086#[derive(Debug)]
2087pub enum RollingPacketCaptureRequest {
2088    /// Detaches the lifetime of this protocol from the underlying packet
2089    /// capture.
2090    ///
2091    /// After calling `Detach`, closing the client end no longer results in
2092    /// the packet capture from being terminated. The passed string names
2093    /// this packet capture and can be used thereafter to reconnect via
2094    /// [`PacketCaptureProvider.ReconnectRolling`]. The protocol is still
2095    /// detached after reconnecting. This gives the client the option of
2096    /// ensuring the packet capture is resilient against disconnections.
2097    ///
2098    /// Only the first call to `Detach` over the lifetime of the packet
2099    /// capture (note this is different from the lifetime of this protocol
2100    /// since it's possible to disconnect and reconnect) is valid. Subsequent
2101    /// calls cannot change the name of this capture.
2102    ///
2103    /// Once this method returns, it is guaranteed that this rolling packet
2104    /// capture is detached.
2105    Detach { name: String, responder: RollingPacketCaptureDetachResponder },
2106    /// Stop and make this rolling packet capture downloadable.
2107    ///
2108    /// It is implicit by calling this method that the packet capture is stopped
2109    /// due to user request, so the [`RollingPacketCapture.OnEnded`] event is
2110    /// not emitted.
2111    ///
2112    /// This method can be called multiple times, including across disconnects:
2113    /// a client can call this method, disconnect, reconnect, and call this
2114    /// method again.
2115    ///
2116    /// The server discards the contents of the packet capture once this
2117    /// method has been called and there is no client connected to this protocol
2118    /// for some time.
2119    StopAndDownload {
2120        channel: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
2121        control_handle: RollingPacketCaptureControlHandle,
2122    },
2123    /// Discard this rolling packet capture.
2124    ///
2125    /// Clients should call this method when they have successfully downloaded
2126    /// the packet capture, or if they no longer need it for any reason.
2127    ///
2128    /// The server closes all readers initialized via [`StopAndDownload`]
2129    /// and all future interactions on this protocol are invalid. When this
2130    /// method returns, it is guaranteed that the packet capture has been
2131    /// discarded and the usage quota has been released.
2132    Discard { responder: RollingPacketCaptureDiscardResponder },
2133}
2134
2135impl RollingPacketCaptureRequest {
2136    #[allow(irrefutable_let_patterns)]
2137    pub fn into_detach(self) -> Option<(String, RollingPacketCaptureDetachResponder)> {
2138        if let RollingPacketCaptureRequest::Detach { name, responder } = self {
2139            Some((name, responder))
2140        } else {
2141            None
2142        }
2143    }
2144
2145    #[allow(irrefutable_let_patterns)]
2146    pub fn into_stop_and_download(
2147        self,
2148    ) -> Option<(
2149        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
2150        RollingPacketCaptureControlHandle,
2151    )> {
2152        if let RollingPacketCaptureRequest::StopAndDownload { channel, control_handle } = self {
2153            Some((channel, control_handle))
2154        } else {
2155            None
2156        }
2157    }
2158
2159    #[allow(irrefutable_let_patterns)]
2160    pub fn into_discard(self) -> Option<(RollingPacketCaptureDiscardResponder)> {
2161        if let RollingPacketCaptureRequest::Discard { responder } = self {
2162            Some((responder))
2163        } else {
2164            None
2165        }
2166    }
2167
2168    /// Name of the method defined in FIDL
2169    pub fn method_name(&self) -> &'static str {
2170        match *self {
2171            RollingPacketCaptureRequest::Detach { .. } => "detach",
2172            RollingPacketCaptureRequest::StopAndDownload { .. } => "stop_and_download",
2173            RollingPacketCaptureRequest::Discard { .. } => "discard",
2174        }
2175    }
2176}
2177
2178#[derive(Debug, Clone)]
2179pub struct RollingPacketCaptureControlHandle {
2180    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2181}
2182
2183impl fdomain_client::fidl::ControlHandle for RollingPacketCaptureControlHandle {
2184    fn shutdown(&self) {
2185        self.inner.shutdown()
2186    }
2187
2188    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2189        self.inner.shutdown_with_epitaph(status)
2190    }
2191
2192    fn is_closed(&self) -> bool {
2193        self.inner.channel().is_closed()
2194    }
2195    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2196        self.inner.channel().on_closed()
2197    }
2198}
2199
2200impl RollingPacketCaptureControlHandle {
2201    pub fn send_on_ended(&self, mut reason: PacketCaptureEndReason) -> Result<(), fidl::Error> {
2202        self.inner.send::<RollingPacketCaptureOnEndedRequest>(
2203            (reason,),
2204            0,
2205            0x74690c9d4f59f506,
2206            fidl::encoding::DynamicFlags::empty(),
2207        )
2208    }
2209}
2210
2211#[must_use = "FIDL methods require a response to be sent"]
2212#[derive(Debug)]
2213pub struct RollingPacketCaptureDetachResponder {
2214    control_handle: std::mem::ManuallyDrop<RollingPacketCaptureControlHandle>,
2215    tx_id: u32,
2216}
2217
2218/// Set the the channel to be shutdown (see [`RollingPacketCaptureControlHandle::shutdown`])
2219/// if the responder is dropped without sending a response, so that the client
2220/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2221impl std::ops::Drop for RollingPacketCaptureDetachResponder {
2222    fn drop(&mut self) {
2223        self.control_handle.shutdown();
2224        // Safety: drops once, never accessed again
2225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2226    }
2227}
2228
2229impl fdomain_client::fidl::Responder for RollingPacketCaptureDetachResponder {
2230    type ControlHandle = RollingPacketCaptureControlHandle;
2231
2232    fn control_handle(&self) -> &RollingPacketCaptureControlHandle {
2233        &self.control_handle
2234    }
2235
2236    fn drop_without_shutdown(mut self) {
2237        // Safety: drops once, never accessed again due to mem::forget
2238        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2239        // Prevent Drop from running (which would shut down the channel)
2240        std::mem::forget(self);
2241    }
2242}
2243
2244impl RollingPacketCaptureDetachResponder {
2245    /// Sends a response to the FIDL transaction.
2246    ///
2247    /// Sets the channel to shutdown if an error occurs.
2248    pub fn send(
2249        self,
2250        mut result: Result<(), RollingPacketCaptureDetachError>,
2251    ) -> Result<(), fidl::Error> {
2252        let _result = self.send_raw(result);
2253        if _result.is_err() {
2254            self.control_handle.shutdown();
2255        }
2256        self.drop_without_shutdown();
2257        _result
2258    }
2259
2260    /// Similar to "send" but does not shutdown the channel if an error occurs.
2261    pub fn send_no_shutdown_on_err(
2262        self,
2263        mut result: Result<(), RollingPacketCaptureDetachError>,
2264    ) -> Result<(), fidl::Error> {
2265        let _result = self.send_raw(result);
2266        self.drop_without_shutdown();
2267        _result
2268    }
2269
2270    fn send_raw(
2271        &self,
2272        mut result: Result<(), RollingPacketCaptureDetachError>,
2273    ) -> Result<(), fidl::Error> {
2274        self.control_handle.inner.send::<fidl::encoding::ResultType<
2275            fidl::encoding::EmptyStruct,
2276            RollingPacketCaptureDetachError,
2277        >>(
2278            result,
2279            self.tx_id,
2280            0xb3d28b9518e7db0,
2281            fidl::encoding::DynamicFlags::empty(),
2282        )
2283    }
2284}
2285
2286#[must_use = "FIDL methods require a response to be sent"]
2287#[derive(Debug)]
2288pub struct RollingPacketCaptureDiscardResponder {
2289    control_handle: std::mem::ManuallyDrop<RollingPacketCaptureControlHandle>,
2290    tx_id: u32,
2291}
2292
2293/// Set the the channel to be shutdown (see [`RollingPacketCaptureControlHandle::shutdown`])
2294/// if the responder is dropped without sending a response, so that the client
2295/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2296impl std::ops::Drop for RollingPacketCaptureDiscardResponder {
2297    fn drop(&mut self) {
2298        self.control_handle.shutdown();
2299        // Safety: drops once, never accessed again
2300        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2301    }
2302}
2303
2304impl fdomain_client::fidl::Responder for RollingPacketCaptureDiscardResponder {
2305    type ControlHandle = RollingPacketCaptureControlHandle;
2306
2307    fn control_handle(&self) -> &RollingPacketCaptureControlHandle {
2308        &self.control_handle
2309    }
2310
2311    fn drop_without_shutdown(mut self) {
2312        // Safety: drops once, never accessed again due to mem::forget
2313        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2314        // Prevent Drop from running (which would shut down the channel)
2315        std::mem::forget(self);
2316    }
2317}
2318
2319impl RollingPacketCaptureDiscardResponder {
2320    /// Sends a response to the FIDL transaction.
2321    ///
2322    /// Sets the channel to shutdown if an error occurs.
2323    pub fn send(self) -> Result<(), fidl::Error> {
2324        let _result = self.send_raw();
2325        if _result.is_err() {
2326            self.control_handle.shutdown();
2327        }
2328        self.drop_without_shutdown();
2329        _result
2330    }
2331
2332    /// Similar to "send" but does not shutdown the channel if an error occurs.
2333    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2334        let _result = self.send_raw();
2335        self.drop_without_shutdown();
2336        _result
2337    }
2338
2339    fn send_raw(&self) -> Result<(), fidl::Error> {
2340        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2341            (),
2342            self.tx_id,
2343            0x89e60c428d47a1,
2344            fidl::encoding::DynamicFlags::empty(),
2345        )
2346    }
2347}
2348
2349mod internal {
2350    use super::*;
2351
2352    impl fidl::encoding::ResourceTypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
2353        type Borrowed<'a> = &'a mut Self;
2354        fn take_or_borrow<'a>(
2355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2356        ) -> Self::Borrowed<'a> {
2357            value
2358        }
2359    }
2360
2361    unsafe impl fidl::encoding::TypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
2362        type Owned = Self;
2363
2364        #[inline(always)]
2365        fn inline_align(_context: fidl::encoding::Context) -> usize {
2366            4
2367        }
2368
2369        #[inline(always)]
2370        fn inline_size(_context: fidl::encoding::Context) -> usize {
2371            4
2372        }
2373    }
2374
2375    unsafe impl
2376        fidl::encoding::Encode<
2377            DiagnosticsGetProcessHandleForInspectionResponse,
2378            fdomain_client::fidl::FDomainResourceDialect,
2379        > for &mut DiagnosticsGetProcessHandleForInspectionResponse
2380    {
2381        #[inline]
2382        unsafe fn encode(
2383            self,
2384            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2385            offset: usize,
2386            _depth: fidl::encoding::Depth,
2387        ) -> fidl::Result<()> {
2388            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
2389            // Delegate to tuple encoding.
2390            fidl::encoding::Encode::<
2391                DiagnosticsGetProcessHandleForInspectionResponse,
2392                fdomain_client::fidl::FDomainResourceDialect,
2393            >::encode(
2394                (<fidl::encoding::HandleType<
2395                    fdomain_client::Process,
2396                    { fidl::ObjectType::PROCESS.into_raw() },
2397                    32768,
2398                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2399                    &mut self.process
2400                ),),
2401                encoder,
2402                offset,
2403                _depth,
2404            )
2405        }
2406    }
2407    unsafe impl<
2408        T0: fidl::encoding::Encode<
2409                fidl::encoding::HandleType<
2410                    fdomain_client::Process,
2411                    { fidl::ObjectType::PROCESS.into_raw() },
2412                    32768,
2413                >,
2414                fdomain_client::fidl::FDomainResourceDialect,
2415            >,
2416    >
2417        fidl::encoding::Encode<
2418            DiagnosticsGetProcessHandleForInspectionResponse,
2419            fdomain_client::fidl::FDomainResourceDialect,
2420        > for (T0,)
2421    {
2422        #[inline]
2423        unsafe fn encode(
2424            self,
2425            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2426            offset: usize,
2427            depth: fidl::encoding::Depth,
2428        ) -> fidl::Result<()> {
2429            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
2430            // Zero out padding regions. There's no need to apply masks
2431            // because the unmasked parts will be overwritten by fields.
2432            // Write the fields.
2433            self.0.encode(encoder, offset + 0, depth)?;
2434            Ok(())
2435        }
2436    }
2437
2438    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2439        for DiagnosticsGetProcessHandleForInspectionResponse
2440    {
2441        #[inline(always)]
2442        fn new_empty() -> Self {
2443            Self {
2444                process: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 32768>, fdomain_client::fidl::FDomainResourceDialect),
2445            }
2446        }
2447
2448        #[inline]
2449        unsafe fn decode(
2450            &mut self,
2451            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2452            offset: usize,
2453            _depth: fidl::encoding::Depth,
2454        ) -> fidl::Result<()> {
2455            decoder.debug_check_bounds::<Self>(offset);
2456            // Verify that padding bytes are zero.
2457            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)?;
2458            Ok(())
2459        }
2460    }
2461
2462    impl fidl::encoding::ResourceTypeMarker for InterfacesGetPortRequest {
2463        type Borrowed<'a> = &'a mut Self;
2464        fn take_or_borrow<'a>(
2465            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2466        ) -> Self::Borrowed<'a> {
2467            value
2468        }
2469    }
2470
2471    unsafe impl fidl::encoding::TypeMarker for InterfacesGetPortRequest {
2472        type Owned = Self;
2473
2474        #[inline(always)]
2475        fn inline_align(_context: fidl::encoding::Context) -> usize {
2476            8
2477        }
2478
2479        #[inline(always)]
2480        fn inline_size(_context: fidl::encoding::Context) -> usize {
2481            16
2482        }
2483    }
2484
2485    unsafe impl
2486        fidl::encoding::Encode<
2487            InterfacesGetPortRequest,
2488            fdomain_client::fidl::FDomainResourceDialect,
2489        > for &mut InterfacesGetPortRequest
2490    {
2491        #[inline]
2492        unsafe fn encode(
2493            self,
2494            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2495            offset: usize,
2496            _depth: fidl::encoding::Depth,
2497        ) -> fidl::Result<()> {
2498            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
2499            // Delegate to tuple encoding.
2500            fidl::encoding::Encode::<
2501                InterfacesGetPortRequest,
2502                fdomain_client::fidl::FDomainResourceDialect,
2503            >::encode(
2504                (
2505                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2506                    <fidl::encoding::Endpoint<
2507                        fdomain_client::fidl::ServerEnd<
2508                            fdomain_fuchsia_hardware_network::PortMarker,
2509                        >,
2510                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2511                        &mut self.port
2512                    ),
2513                ),
2514                encoder,
2515                offset,
2516                _depth,
2517            )
2518        }
2519    }
2520    unsafe impl<
2521        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
2522        T1: fidl::encoding::Encode<
2523                fidl::encoding::Endpoint<
2524                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_hardware_network::PortMarker>,
2525                >,
2526                fdomain_client::fidl::FDomainResourceDialect,
2527            >,
2528    >
2529        fidl::encoding::Encode<
2530            InterfacesGetPortRequest,
2531            fdomain_client::fidl::FDomainResourceDialect,
2532        > for (T0, T1)
2533    {
2534        #[inline]
2535        unsafe fn encode(
2536            self,
2537            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2538            offset: usize,
2539            depth: fidl::encoding::Depth,
2540        ) -> fidl::Result<()> {
2541            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
2542            // Zero out padding regions. There's no need to apply masks
2543            // because the unmasked parts will be overwritten by fields.
2544            unsafe {
2545                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2546                (ptr as *mut u64).write_unaligned(0);
2547            }
2548            // Write the fields.
2549            self.0.encode(encoder, offset + 0, depth)?;
2550            self.1.encode(encoder, offset + 8, depth)?;
2551            Ok(())
2552        }
2553    }
2554
2555    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2556        for InterfacesGetPortRequest
2557    {
2558        #[inline(always)]
2559        fn new_empty() -> Self {
2560            Self {
2561                id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
2562                port: fidl::new_empty!(
2563                    fidl::encoding::Endpoint<
2564                        fdomain_client::fidl::ServerEnd<
2565                            fdomain_fuchsia_hardware_network::PortMarker,
2566                        >,
2567                    >,
2568                    fdomain_client::fidl::FDomainResourceDialect
2569                ),
2570            }
2571        }
2572
2573        #[inline]
2574        unsafe fn decode(
2575            &mut self,
2576            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2577            offset: usize,
2578            _depth: fidl::encoding::Depth,
2579        ) -> fidl::Result<()> {
2580            decoder.debug_check_bounds::<Self>(offset);
2581            // Verify that padding bytes are zero.
2582            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2583            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2584            let mask = 0xffffffff00000000u64;
2585            let maskedval = padval & mask;
2586            if maskedval != 0 {
2587                return Err(fidl::Error::NonZeroPadding {
2588                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2589                });
2590            }
2591            fidl::decode!(
2592                u64,
2593                fdomain_client::fidl::FDomainResourceDialect,
2594                &mut self.id,
2595                decoder,
2596                offset + 0,
2597                _depth
2598            )?;
2599            fidl::decode!(
2600                fidl::encoding::Endpoint<
2601                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_hardware_network::PortMarker>,
2602                >,
2603                fdomain_client::fidl::FDomainResourceDialect,
2604                &mut self.port,
2605                decoder,
2606                offset + 8,
2607                _depth
2608            )?;
2609            Ok(())
2610        }
2611    }
2612
2613    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderReconnectRollingRequest {
2614        type Borrowed<'a> = &'a mut Self;
2615        fn take_or_borrow<'a>(
2616            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2617        ) -> Self::Borrowed<'a> {
2618            value
2619        }
2620    }
2621
2622    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderReconnectRollingRequest {
2623        type Owned = Self;
2624
2625        #[inline(always)]
2626        fn inline_align(_context: fidl::encoding::Context) -> usize {
2627            8
2628        }
2629
2630        #[inline(always)]
2631        fn inline_size(_context: fidl::encoding::Context) -> usize {
2632            16
2633        }
2634    }
2635
2636    unsafe impl
2637        fidl::encoding::Encode<
2638            PacketCaptureProviderReconnectRollingRequest,
2639            fdomain_client::fidl::FDomainResourceDialect,
2640        > for &mut PacketCaptureProviderReconnectRollingRequest
2641    {
2642        #[inline]
2643        unsafe fn encode(
2644            self,
2645            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2646            offset: usize,
2647            _depth: fidl::encoding::Depth,
2648        ) -> fidl::Result<()> {
2649            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingRequest>(offset);
2650            // Delegate to tuple encoding.
2651            fidl::encoding::Encode::<
2652                PacketCaptureProviderReconnectRollingRequest,
2653                fdomain_client::fidl::FDomainResourceDialect,
2654            >::encode(
2655                (<fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
2656                    &self.name,
2657                ),),
2658                encoder,
2659                offset,
2660                _depth,
2661            )
2662        }
2663    }
2664    unsafe impl<
2665        T0: fidl::encoding::Encode<
2666                fidl::encoding::BoundedString<64>,
2667                fdomain_client::fidl::FDomainResourceDialect,
2668            >,
2669    >
2670        fidl::encoding::Encode<
2671            PacketCaptureProviderReconnectRollingRequest,
2672            fdomain_client::fidl::FDomainResourceDialect,
2673        > for (T0,)
2674    {
2675        #[inline]
2676        unsafe fn encode(
2677            self,
2678            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2679            offset: usize,
2680            depth: fidl::encoding::Depth,
2681        ) -> fidl::Result<()> {
2682            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingRequest>(offset);
2683            // Zero out padding regions. There's no need to apply masks
2684            // because the unmasked parts will be overwritten by fields.
2685            // Write the fields.
2686            self.0.encode(encoder, offset + 0, depth)?;
2687            Ok(())
2688        }
2689    }
2690
2691    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2692        for PacketCaptureProviderReconnectRollingRequest
2693    {
2694        #[inline(always)]
2695        fn new_empty() -> Self {
2696            Self {
2697                name: fidl::new_empty!(
2698                    fidl::encoding::BoundedString<64>,
2699                    fdomain_client::fidl::FDomainResourceDialect
2700                ),
2701            }
2702        }
2703
2704        #[inline]
2705        unsafe fn decode(
2706            &mut self,
2707            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2708            offset: usize,
2709            _depth: fidl::encoding::Depth,
2710        ) -> fidl::Result<()> {
2711            decoder.debug_check_bounds::<Self>(offset);
2712            // Verify that padding bytes are zero.
2713            fidl::decode!(
2714                fidl::encoding::BoundedString<64>,
2715                fdomain_client::fidl::FDomainResourceDialect,
2716                &mut self.name,
2717                decoder,
2718                offset + 0,
2719                _depth
2720            )?;
2721            Ok(())
2722        }
2723    }
2724
2725    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderStartRollingRequest {
2726        type Borrowed<'a> = &'a mut Self;
2727        fn take_or_borrow<'a>(
2728            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2729        ) -> Self::Borrowed<'a> {
2730            value
2731        }
2732    }
2733
2734    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderStartRollingRequest {
2735        type Owned = Self;
2736
2737        #[inline(always)]
2738        fn inline_align(_context: fidl::encoding::Context) -> usize {
2739            8
2740        }
2741
2742        #[inline(always)]
2743        fn inline_size(_context: fidl::encoding::Context) -> usize {
2744            32
2745        }
2746    }
2747
2748    unsafe impl
2749        fidl::encoding::Encode<
2750            PacketCaptureProviderStartRollingRequest,
2751            fdomain_client::fidl::FDomainResourceDialect,
2752        > for &mut PacketCaptureProviderStartRollingRequest
2753    {
2754        #[inline]
2755        unsafe fn encode(
2756            self,
2757            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2758            offset: usize,
2759            _depth: fidl::encoding::Depth,
2760        ) -> fidl::Result<()> {
2761            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingRequest>(offset);
2762            // Delegate to tuple encoding.
2763            fidl::encoding::Encode::<PacketCaptureProviderStartRollingRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
2764                (
2765                    <CommonPacketCaptureParams as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.common_params),
2766                    <RollingPacketCaptureParams as fidl::encoding::ValueTypeMarker>::borrow(&self.params),
2767                ),
2768                encoder, offset, _depth
2769            )
2770        }
2771    }
2772    unsafe impl<
2773        T0: fidl::encoding::Encode<
2774                CommonPacketCaptureParams,
2775                fdomain_client::fidl::FDomainResourceDialect,
2776            >,
2777        T1: fidl::encoding::Encode<
2778                RollingPacketCaptureParams,
2779                fdomain_client::fidl::FDomainResourceDialect,
2780            >,
2781    >
2782        fidl::encoding::Encode<
2783            PacketCaptureProviderStartRollingRequest,
2784            fdomain_client::fidl::FDomainResourceDialect,
2785        > for (T0, T1)
2786    {
2787        #[inline]
2788        unsafe fn encode(
2789            self,
2790            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2791            offset: usize,
2792            depth: fidl::encoding::Depth,
2793        ) -> fidl::Result<()> {
2794            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingRequest>(offset);
2795            // Zero out padding regions. There's no need to apply masks
2796            // because the unmasked parts will be overwritten by fields.
2797            // Write the fields.
2798            self.0.encode(encoder, offset + 0, depth)?;
2799            self.1.encode(encoder, offset + 16, depth)?;
2800            Ok(())
2801        }
2802    }
2803
2804    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2805        for PacketCaptureProviderStartRollingRequest
2806    {
2807        #[inline(always)]
2808        fn new_empty() -> Self {
2809            Self {
2810                common_params: fidl::new_empty!(
2811                    CommonPacketCaptureParams,
2812                    fdomain_client::fidl::FDomainResourceDialect
2813                ),
2814                params: fidl::new_empty!(
2815                    RollingPacketCaptureParams,
2816                    fdomain_client::fidl::FDomainResourceDialect
2817                ),
2818            }
2819        }
2820
2821        #[inline]
2822        unsafe fn decode(
2823            &mut self,
2824            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2825            offset: usize,
2826            _depth: fidl::encoding::Depth,
2827        ) -> fidl::Result<()> {
2828            decoder.debug_check_bounds::<Self>(offset);
2829            // Verify that padding bytes are zero.
2830            fidl::decode!(
2831                CommonPacketCaptureParams,
2832                fdomain_client::fidl::FDomainResourceDialect,
2833                &mut self.common_params,
2834                decoder,
2835                offset + 0,
2836                _depth
2837            )?;
2838            fidl::decode!(
2839                RollingPacketCaptureParams,
2840                fdomain_client::fidl::FDomainResourceDialect,
2841                &mut self.params,
2842                decoder,
2843                offset + 16,
2844                _depth
2845            )?;
2846            Ok(())
2847        }
2848    }
2849
2850    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderReconnectRollingResponse {
2851        type Borrowed<'a> = &'a mut Self;
2852        fn take_or_borrow<'a>(
2853            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2854        ) -> Self::Borrowed<'a> {
2855            value
2856        }
2857    }
2858
2859    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderReconnectRollingResponse {
2860        type Owned = Self;
2861
2862        #[inline(always)]
2863        fn inline_align(_context: fidl::encoding::Context) -> usize {
2864            4
2865        }
2866
2867        #[inline(always)]
2868        fn inline_size(_context: fidl::encoding::Context) -> usize {
2869            4
2870        }
2871    }
2872
2873    unsafe impl
2874        fidl::encoding::Encode<
2875            PacketCaptureProviderReconnectRollingResponse,
2876            fdomain_client::fidl::FDomainResourceDialect,
2877        > for &mut PacketCaptureProviderReconnectRollingResponse
2878    {
2879        #[inline]
2880        unsafe fn encode(
2881            self,
2882            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2883            offset: usize,
2884            _depth: fidl::encoding::Depth,
2885        ) -> fidl::Result<()> {
2886            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingResponse>(offset);
2887            // Delegate to tuple encoding.
2888            fidl::encoding::Encode::<
2889                PacketCaptureProviderReconnectRollingResponse,
2890                fdomain_client::fidl::FDomainResourceDialect,
2891            >::encode(
2892                (<fidl::encoding::Endpoint<
2893                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
2894                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2895                    &mut self.channel
2896                ),),
2897                encoder,
2898                offset,
2899                _depth,
2900            )
2901        }
2902    }
2903    unsafe impl<
2904        T0: fidl::encoding::Encode<
2905                fidl::encoding::Endpoint<
2906                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
2907                >,
2908                fdomain_client::fidl::FDomainResourceDialect,
2909            >,
2910    >
2911        fidl::encoding::Encode<
2912            PacketCaptureProviderReconnectRollingResponse,
2913            fdomain_client::fidl::FDomainResourceDialect,
2914        > for (T0,)
2915    {
2916        #[inline]
2917        unsafe fn encode(
2918            self,
2919            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2920            offset: usize,
2921            depth: fidl::encoding::Depth,
2922        ) -> fidl::Result<()> {
2923            encoder.debug_check_bounds::<PacketCaptureProviderReconnectRollingResponse>(offset);
2924            // Zero out padding regions. There's no need to apply masks
2925            // because the unmasked parts will be overwritten by fields.
2926            // Write the fields.
2927            self.0.encode(encoder, offset + 0, depth)?;
2928            Ok(())
2929        }
2930    }
2931
2932    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2933        for PacketCaptureProviderReconnectRollingResponse
2934    {
2935        #[inline(always)]
2936        fn new_empty() -> Self {
2937            Self {
2938                channel: fidl::new_empty!(
2939                    fidl::encoding::Endpoint<
2940                        fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
2941                    >,
2942                    fdomain_client::fidl::FDomainResourceDialect
2943                ),
2944            }
2945        }
2946
2947        #[inline]
2948        unsafe fn decode(
2949            &mut self,
2950            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2951            offset: usize,
2952            _depth: fidl::encoding::Depth,
2953        ) -> fidl::Result<()> {
2954            decoder.debug_check_bounds::<Self>(offset);
2955            // Verify that padding bytes are zero.
2956            fidl::decode!(
2957                fidl::encoding::Endpoint<
2958                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
2959                >,
2960                fdomain_client::fidl::FDomainResourceDialect,
2961                &mut self.channel,
2962                decoder,
2963                offset + 0,
2964                _depth
2965            )?;
2966            Ok(())
2967        }
2968    }
2969
2970    impl fidl::encoding::ResourceTypeMarker for PacketCaptureProviderStartRollingResponse {
2971        type Borrowed<'a> = &'a mut Self;
2972        fn take_or_borrow<'a>(
2973            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2974        ) -> Self::Borrowed<'a> {
2975            value
2976        }
2977    }
2978
2979    unsafe impl fidl::encoding::TypeMarker for PacketCaptureProviderStartRollingResponse {
2980        type Owned = Self;
2981
2982        #[inline(always)]
2983        fn inline_align(_context: fidl::encoding::Context) -> usize {
2984            4
2985        }
2986
2987        #[inline(always)]
2988        fn inline_size(_context: fidl::encoding::Context) -> usize {
2989            4
2990        }
2991    }
2992
2993    unsafe impl
2994        fidl::encoding::Encode<
2995            PacketCaptureProviderStartRollingResponse,
2996            fdomain_client::fidl::FDomainResourceDialect,
2997        > for &mut PacketCaptureProviderStartRollingResponse
2998    {
2999        #[inline]
3000        unsafe fn encode(
3001            self,
3002            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3003            offset: usize,
3004            _depth: fidl::encoding::Depth,
3005        ) -> fidl::Result<()> {
3006            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingResponse>(offset);
3007            // Delegate to tuple encoding.
3008            fidl::encoding::Encode::<
3009                PacketCaptureProviderStartRollingResponse,
3010                fdomain_client::fidl::FDomainResourceDialect,
3011            >::encode(
3012                (<fidl::encoding::Endpoint<
3013                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
3014                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3015                    &mut self.channel
3016                ),),
3017                encoder,
3018                offset,
3019                _depth,
3020            )
3021        }
3022    }
3023    unsafe impl<
3024        T0: fidl::encoding::Encode<
3025                fidl::encoding::Endpoint<
3026                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
3027                >,
3028                fdomain_client::fidl::FDomainResourceDialect,
3029            >,
3030    >
3031        fidl::encoding::Encode<
3032            PacketCaptureProviderStartRollingResponse,
3033            fdomain_client::fidl::FDomainResourceDialect,
3034        > for (T0,)
3035    {
3036        #[inline]
3037        unsafe fn encode(
3038            self,
3039            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3040            offset: usize,
3041            depth: fidl::encoding::Depth,
3042        ) -> fidl::Result<()> {
3043            encoder.debug_check_bounds::<PacketCaptureProviderStartRollingResponse>(offset);
3044            // Zero out padding regions. There's no need to apply masks
3045            // because the unmasked parts will be overwritten by fields.
3046            // Write the fields.
3047            self.0.encode(encoder, offset + 0, depth)?;
3048            Ok(())
3049        }
3050    }
3051
3052    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3053        for PacketCaptureProviderStartRollingResponse
3054    {
3055        #[inline(always)]
3056        fn new_empty() -> Self {
3057            Self {
3058                channel: fidl::new_empty!(
3059                    fidl::encoding::Endpoint<
3060                        fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
3061                    >,
3062                    fdomain_client::fidl::FDomainResourceDialect
3063                ),
3064            }
3065        }
3066
3067        #[inline]
3068        unsafe fn decode(
3069            &mut self,
3070            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3071            offset: usize,
3072            _depth: fidl::encoding::Depth,
3073        ) -> fidl::Result<()> {
3074            decoder.debug_check_bounds::<Self>(offset);
3075            // Verify that padding bytes are zero.
3076            fidl::decode!(
3077                fidl::encoding::Endpoint<
3078                    fdomain_client::fidl::ClientEnd<RollingPacketCaptureMarker>,
3079                >,
3080                fdomain_client::fidl::FDomainResourceDialect,
3081                &mut self.channel,
3082                decoder,
3083                offset + 0,
3084                _depth
3085            )?;
3086            Ok(())
3087        }
3088    }
3089
3090    impl fidl::encoding::ResourceTypeMarker for RollingPacketCaptureStopAndDownloadRequest {
3091        type Borrowed<'a> = &'a mut Self;
3092        fn take_or_borrow<'a>(
3093            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3094        ) -> Self::Borrowed<'a> {
3095            value
3096        }
3097    }
3098
3099    unsafe impl fidl::encoding::TypeMarker for RollingPacketCaptureStopAndDownloadRequest {
3100        type Owned = Self;
3101
3102        #[inline(always)]
3103        fn inline_align(_context: fidl::encoding::Context) -> usize {
3104            4
3105        }
3106
3107        #[inline(always)]
3108        fn inline_size(_context: fidl::encoding::Context) -> usize {
3109            4
3110        }
3111    }
3112
3113    unsafe impl
3114        fidl::encoding::Encode<
3115            RollingPacketCaptureStopAndDownloadRequest,
3116            fdomain_client::fidl::FDomainResourceDialect,
3117        > for &mut RollingPacketCaptureStopAndDownloadRequest
3118    {
3119        #[inline]
3120        unsafe fn encode(
3121            self,
3122            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3123            offset: usize,
3124            _depth: fidl::encoding::Depth,
3125        ) -> fidl::Result<()> {
3126            encoder.debug_check_bounds::<RollingPacketCaptureStopAndDownloadRequest>(offset);
3127            // Delegate to tuple encoding.
3128            fidl::encoding::Encode::<
3129                RollingPacketCaptureStopAndDownloadRequest,
3130                fdomain_client::fidl::FDomainResourceDialect,
3131            >::encode(
3132                (<fidl::encoding::Endpoint<
3133                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
3134                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3135                    &mut self.channel
3136                ),),
3137                encoder,
3138                offset,
3139                _depth,
3140            )
3141        }
3142    }
3143    unsafe impl<
3144        T0: fidl::encoding::Encode<
3145                fidl::encoding::Endpoint<
3146                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
3147                >,
3148                fdomain_client::fidl::FDomainResourceDialect,
3149            >,
3150    >
3151        fidl::encoding::Encode<
3152            RollingPacketCaptureStopAndDownloadRequest,
3153            fdomain_client::fidl::FDomainResourceDialect,
3154        > for (T0,)
3155    {
3156        #[inline]
3157        unsafe fn encode(
3158            self,
3159            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3160            offset: usize,
3161            depth: fidl::encoding::Depth,
3162        ) -> fidl::Result<()> {
3163            encoder.debug_check_bounds::<RollingPacketCaptureStopAndDownloadRequest>(offset);
3164            // Zero out padding regions. There's no need to apply masks
3165            // because the unmasked parts will be overwritten by fields.
3166            // Write the fields.
3167            self.0.encode(encoder, offset + 0, depth)?;
3168            Ok(())
3169        }
3170    }
3171
3172    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3173        for RollingPacketCaptureStopAndDownloadRequest
3174    {
3175        #[inline(always)]
3176        fn new_empty() -> Self {
3177            Self {
3178                channel: fidl::new_empty!(
3179                    fidl::encoding::Endpoint<
3180                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
3181                    >,
3182                    fdomain_client::fidl::FDomainResourceDialect
3183                ),
3184            }
3185        }
3186
3187        #[inline]
3188        unsafe fn decode(
3189            &mut self,
3190            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3191            offset: usize,
3192            _depth: fidl::encoding::Depth,
3193        ) -> fidl::Result<()> {
3194            decoder.debug_check_bounds::<Self>(offset);
3195            // Verify that padding bytes are zero.
3196            fidl::decode!(
3197                fidl::encoding::Endpoint<
3198                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::FileMarker>,
3199                >,
3200                fdomain_client::fidl::FDomainResourceDialect,
3201                &mut self.channel,
3202                decoder,
3203                offset + 0,
3204                _depth
3205            )?;
3206            Ok(())
3207        }
3208    }
3209
3210    impl CommonPacketCaptureParams {
3211        #[inline(always)]
3212        fn max_ordinal_present(&self) -> u64 {
3213            if let Some(_) = self.snap_len {
3214                return 3;
3215            }
3216            if let Some(_) = self.bpf_program {
3217                return 2;
3218            }
3219            if let Some(_) = self.interfaces {
3220                return 1;
3221            }
3222            0
3223        }
3224    }
3225
3226    impl fidl::encoding::ResourceTypeMarker for CommonPacketCaptureParams {
3227        type Borrowed<'a> = &'a mut Self;
3228        fn take_or_borrow<'a>(
3229            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3230        ) -> Self::Borrowed<'a> {
3231            value
3232        }
3233    }
3234
3235    unsafe impl fidl::encoding::TypeMarker for CommonPacketCaptureParams {
3236        type Owned = Self;
3237
3238        #[inline(always)]
3239        fn inline_align(_context: fidl::encoding::Context) -> usize {
3240            8
3241        }
3242
3243        #[inline(always)]
3244        fn inline_size(_context: fidl::encoding::Context) -> usize {
3245            16
3246        }
3247    }
3248
3249    unsafe impl
3250        fidl::encoding::Encode<
3251            CommonPacketCaptureParams,
3252            fdomain_client::fidl::FDomainResourceDialect,
3253        > for &mut CommonPacketCaptureParams
3254    {
3255        unsafe fn encode(
3256            self,
3257            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3258            offset: usize,
3259            mut depth: fidl::encoding::Depth,
3260        ) -> fidl::Result<()> {
3261            encoder.debug_check_bounds::<CommonPacketCaptureParams>(offset);
3262            // Vector header
3263            let max_ordinal: u64 = self.max_ordinal_present();
3264            encoder.write_num(max_ordinal, offset);
3265            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3266            // Calling encoder.out_of_line_offset(0) is not allowed.
3267            if max_ordinal == 0 {
3268                return Ok(());
3269            }
3270            depth.increment()?;
3271            let envelope_size = 8;
3272            let bytes_len = max_ordinal as usize * envelope_size;
3273            #[allow(unused_variables)]
3274            let offset = encoder.out_of_line_offset(bytes_len);
3275            let mut _prev_end_offset: usize = 0;
3276            if 1 > max_ordinal {
3277                return Ok(());
3278            }
3279
3280            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3281            // are envelope_size bytes.
3282            let cur_offset: usize = (1 - 1) * envelope_size;
3283
3284            // Zero reserved fields.
3285            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3286
3287            // Safety:
3288            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3289            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3290            //   envelope_size bytes, there is always sufficient room.
3291            fidl::encoding::encode_in_envelope_optional::<
3292                InterfaceSpecifier,
3293                fdomain_client::fidl::FDomainResourceDialect,
3294            >(
3295                self.interfaces
3296                    .as_ref()
3297                    .map(<InterfaceSpecifier as fidl::encoding::ValueTypeMarker>::borrow),
3298                encoder,
3299                offset + cur_offset,
3300                depth,
3301            )?;
3302
3303            _prev_end_offset = cur_offset + envelope_size;
3304            if 2 > max_ordinal {
3305                return Ok(());
3306            }
3307
3308            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3309            // are envelope_size bytes.
3310            let cur_offset: usize = (2 - 1) * envelope_size;
3311
3312            // Zero reserved fields.
3313            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3314
3315            // Safety:
3316            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3317            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3318            //   envelope_size bytes, there is always sufficient room.
3319            fidl::encoding::encode_in_envelope_optional::<fdomain_fuchsia_ebpf::VerifiedProgram, fdomain_client::fidl::FDomainResourceDialect>(
3320            self.bpf_program.as_mut().map(<fdomain_fuchsia_ebpf::VerifiedProgram as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3321            encoder, offset + cur_offset, depth
3322        )?;
3323
3324            _prev_end_offset = cur_offset + envelope_size;
3325            if 3 > max_ordinal {
3326                return Ok(());
3327            }
3328
3329            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3330            // are envelope_size bytes.
3331            let cur_offset: usize = (3 - 1) * envelope_size;
3332
3333            // Zero reserved fields.
3334            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3335
3336            // Safety:
3337            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3338            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3339            //   envelope_size bytes, there is always sufficient room.
3340            fidl::encoding::encode_in_envelope_optional::<
3341                u32,
3342                fdomain_client::fidl::FDomainResourceDialect,
3343            >(
3344                self.snap_len.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3345                encoder,
3346                offset + cur_offset,
3347                depth,
3348            )?;
3349
3350            _prev_end_offset = cur_offset + envelope_size;
3351
3352            Ok(())
3353        }
3354    }
3355
3356    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3357        for CommonPacketCaptureParams
3358    {
3359        #[inline(always)]
3360        fn new_empty() -> Self {
3361            Self::default()
3362        }
3363
3364        unsafe fn decode(
3365            &mut self,
3366            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3367            offset: usize,
3368            mut depth: fidl::encoding::Depth,
3369        ) -> fidl::Result<()> {
3370            decoder.debug_check_bounds::<Self>(offset);
3371            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3372                None => return Err(fidl::Error::NotNullable),
3373                Some(len) => len,
3374            };
3375            // Calling decoder.out_of_line_offset(0) is not allowed.
3376            if len == 0 {
3377                return Ok(());
3378            };
3379            depth.increment()?;
3380            let envelope_size = 8;
3381            let bytes_len = len * envelope_size;
3382            let offset = decoder.out_of_line_offset(bytes_len)?;
3383            // Decode the envelope for each type.
3384            let mut _next_ordinal_to_read = 0;
3385            let mut next_offset = offset;
3386            let end_offset = offset + bytes_len;
3387            _next_ordinal_to_read += 1;
3388            if next_offset >= end_offset {
3389                return Ok(());
3390            }
3391
3392            // Decode unknown envelopes for gaps in ordinals.
3393            while _next_ordinal_to_read < 1 {
3394                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3395                _next_ordinal_to_read += 1;
3396                next_offset += envelope_size;
3397            }
3398
3399            let next_out_of_line = decoder.next_out_of_line();
3400            let handles_before = decoder.remaining_handles();
3401            if let Some((inlined, num_bytes, num_handles)) =
3402                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3403            {
3404                let member_inline_size =
3405                    <InterfaceSpecifier as fidl::encoding::TypeMarker>::inline_size(
3406                        decoder.context,
3407                    );
3408                if inlined != (member_inline_size <= 4) {
3409                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3410                }
3411                let inner_offset;
3412                let mut inner_depth = depth.clone();
3413                if inlined {
3414                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3415                    inner_offset = next_offset;
3416                } else {
3417                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3418                    inner_depth.increment()?;
3419                }
3420                let val_ref = self.interfaces.get_or_insert_with(|| {
3421                    fidl::new_empty!(
3422                        InterfaceSpecifier,
3423                        fdomain_client::fidl::FDomainResourceDialect
3424                    )
3425                });
3426                fidl::decode!(
3427                    InterfaceSpecifier,
3428                    fdomain_client::fidl::FDomainResourceDialect,
3429                    val_ref,
3430                    decoder,
3431                    inner_offset,
3432                    inner_depth
3433                )?;
3434                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3435                {
3436                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3437                }
3438                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3439                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3440                }
3441            }
3442
3443            next_offset += envelope_size;
3444            _next_ordinal_to_read += 1;
3445            if next_offset >= end_offset {
3446                return Ok(());
3447            }
3448
3449            // Decode unknown envelopes for gaps in ordinals.
3450            while _next_ordinal_to_read < 2 {
3451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3452                _next_ordinal_to_read += 1;
3453                next_offset += envelope_size;
3454            }
3455
3456            let next_out_of_line = decoder.next_out_of_line();
3457            let handles_before = decoder.remaining_handles();
3458            if let Some((inlined, num_bytes, num_handles)) =
3459                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3460            {
3461                let member_inline_size = <fdomain_fuchsia_ebpf::VerifiedProgram as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3462                if inlined != (member_inline_size <= 4) {
3463                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3464                }
3465                let inner_offset;
3466                let mut inner_depth = depth.clone();
3467                if inlined {
3468                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3469                    inner_offset = next_offset;
3470                } else {
3471                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3472                    inner_depth.increment()?;
3473                }
3474                let val_ref = self.bpf_program.get_or_insert_with(|| {
3475                    fidl::new_empty!(
3476                        fdomain_fuchsia_ebpf::VerifiedProgram,
3477                        fdomain_client::fidl::FDomainResourceDialect
3478                    )
3479                });
3480                fidl::decode!(
3481                    fdomain_fuchsia_ebpf::VerifiedProgram,
3482                    fdomain_client::fidl::FDomainResourceDialect,
3483                    val_ref,
3484                    decoder,
3485                    inner_offset,
3486                    inner_depth
3487                )?;
3488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3489                {
3490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3491                }
3492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3494                }
3495            }
3496
3497            next_offset += envelope_size;
3498            _next_ordinal_to_read += 1;
3499            if next_offset >= end_offset {
3500                return Ok(());
3501            }
3502
3503            // Decode unknown envelopes for gaps in ordinals.
3504            while _next_ordinal_to_read < 3 {
3505                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3506                _next_ordinal_to_read += 1;
3507                next_offset += envelope_size;
3508            }
3509
3510            let next_out_of_line = decoder.next_out_of_line();
3511            let handles_before = decoder.remaining_handles();
3512            if let Some((inlined, num_bytes, num_handles)) =
3513                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3514            {
3515                let member_inline_size =
3516                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3517                if inlined != (member_inline_size <= 4) {
3518                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3519                }
3520                let inner_offset;
3521                let mut inner_depth = depth.clone();
3522                if inlined {
3523                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3524                    inner_offset = next_offset;
3525                } else {
3526                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3527                    inner_depth.increment()?;
3528                }
3529                let val_ref = self.snap_len.get_or_insert_with(|| {
3530                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
3531                });
3532                fidl::decode!(
3533                    u32,
3534                    fdomain_client::fidl::FDomainResourceDialect,
3535                    val_ref,
3536                    decoder,
3537                    inner_offset,
3538                    inner_depth
3539                )?;
3540                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3541                {
3542                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3543                }
3544                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3545                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3546                }
3547            }
3548
3549            next_offset += envelope_size;
3550
3551            // Decode the remaining unknown envelopes.
3552            while next_offset < end_offset {
3553                _next_ordinal_to_read += 1;
3554                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3555                next_offset += envelope_size;
3556            }
3557
3558            Ok(())
3559        }
3560    }
3561}