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