fidl_fuchsia_net_debug/
fidl_fuchsia_net_debug.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_debug__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DiagnosticsGetProcessHandleForInspectionResponse {
16    pub process: fidl::Process,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DiagnosticsGetProcessHandleForInspectionResponse
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct InterfacesGetPortRequest {
26    pub id: u64,
27    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for InterfacesGetPortRequest {}
31
32#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
33pub struct DiagnosticsMarker;
34
35impl fidl::endpoints::ProtocolMarker for DiagnosticsMarker {
36    type Proxy = DiagnosticsProxy;
37    type RequestStream = DiagnosticsRequestStream;
38    #[cfg(target_os = "fuchsia")]
39    type SynchronousProxy = DiagnosticsSynchronousProxy;
40
41    const DEBUG_NAME: &'static str = "fuchsia.net.debug.Diagnostics";
42}
43impl fidl::endpoints::DiscoverableProtocolMarker for DiagnosticsMarker {}
44
45pub trait DiagnosticsProxyInterface: Send + Sync {
46    type LogDebugInfoToSyslogResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
47        + Send;
48    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut;
49    type GetProcessHandleForInspectionResponseFut: std::future::Future<Output = Result<fidl::Process, fidl::Error>>
50        + Send;
51    fn r#get_process_handle_for_inspection(&self)
52    -> Self::GetProcessHandleForInspectionResponseFut;
53}
54#[derive(Debug)]
55#[cfg(target_os = "fuchsia")]
56pub struct DiagnosticsSynchronousProxy {
57    client: fidl::client::sync::Client,
58}
59
60#[cfg(target_os = "fuchsia")]
61impl fidl::endpoints::SynchronousProxy for DiagnosticsSynchronousProxy {
62    type Proxy = DiagnosticsProxy;
63    type Protocol = DiagnosticsMarker;
64
65    fn from_channel(inner: fidl::Channel) -> Self {
66        Self::new(inner)
67    }
68
69    fn into_channel(self) -> fidl::Channel {
70        self.client.into_channel()
71    }
72
73    fn as_channel(&self) -> &fidl::Channel {
74        self.client.as_channel()
75    }
76}
77
78#[cfg(target_os = "fuchsia")]
79impl DiagnosticsSynchronousProxy {
80    pub fn new(channel: fidl::Channel) -> Self {
81        let protocol_name = <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
82        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
83    }
84
85    pub fn into_channel(self) -> fidl::Channel {
86        self.client.into_channel()
87    }
88
89    /// Waits until an event arrives and returns it. It is safe for other
90    /// threads to make concurrent requests while waiting for an event.
91    pub fn wait_for_event(
92        &self,
93        deadline: zx::MonotonicInstant,
94    ) -> Result<DiagnosticsEvent, fidl::Error> {
95        DiagnosticsEvent::decode(self.client.wait_for_event(deadline)?)
96    }
97
98    /// Requests that the network stack produces debugging information in the
99    /// system logs.
100    ///
101    /// The call returns once debug information has been produced.
102    pub fn r#log_debug_info_to_syslog(
103        &self,
104        ___deadline: zx::MonotonicInstant,
105    ) -> Result<(), fidl::Error> {
106        let _response =
107            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
108                (),
109                0x336c39330bd8e1ac,
110                fidl::encoding::DynamicFlags::empty(),
111                ___deadline,
112            )?;
113        Ok(_response)
114    }
115
116    /// Requests a handle to the netstack's process.
117    ///
118    /// This handle is not meant to be used for anything other than diagnostics,
119    /// so only the `INSPECT` right is provided to the caller.
120    pub fn r#get_process_handle_for_inspection(
121        &self,
122        ___deadline: zx::MonotonicInstant,
123    ) -> Result<fidl::Process, fidl::Error> {
124        let _response = self.client.send_query::<
125            fidl::encoding::EmptyPayload,
126            DiagnosticsGetProcessHandleForInspectionResponse,
127        >(
128            (),
129            0x563e5df030f2f4d5,
130            fidl::encoding::DynamicFlags::empty(),
131            ___deadline,
132        )?;
133        Ok(_response.process)
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<DiagnosticsSynchronousProxy> for zx::NullableHandle {
139    fn from(value: DiagnosticsSynchronousProxy) -> Self {
140        value.into_channel().into()
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<fidl::Channel> for DiagnosticsSynchronousProxy {
146    fn from(value: fidl::Channel) -> Self {
147        Self::new(value)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl fidl::endpoints::FromClient for DiagnosticsSynchronousProxy {
153    type Protocol = DiagnosticsMarker;
154
155    fn from_client(value: fidl::endpoints::ClientEnd<DiagnosticsMarker>) -> Self {
156        Self::new(value.into_channel())
157    }
158}
159
160#[derive(Debug, Clone)]
161pub struct DiagnosticsProxy {
162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
163}
164
165impl fidl::endpoints::Proxy for DiagnosticsProxy {
166    type Protocol = DiagnosticsMarker;
167
168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
169        Self::new(inner)
170    }
171
172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
173        self.client.into_channel().map_err(|client| Self { client })
174    }
175
176    fn as_channel(&self) -> &::fidl::AsyncChannel {
177        self.client.as_channel()
178    }
179}
180
181impl DiagnosticsProxy {
182    /// Create a new Proxy for fuchsia.net.debug/Diagnostics.
183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
184        let protocol_name = <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
185        Self { client: fidl::client::Client::new(channel, protocol_name) }
186    }
187
188    /// Get a Stream of events from the remote end of the protocol.
189    ///
190    /// # Panics
191    ///
192    /// Panics if the event stream was already taken.
193    pub fn take_event_stream(&self) -> DiagnosticsEventStream {
194        DiagnosticsEventStream { event_receiver: self.client.take_event_receiver() }
195    }
196
197    /// Requests that the network stack produces debugging information in the
198    /// system logs.
199    ///
200    /// The call returns once debug information has been produced.
201    pub fn r#log_debug_info_to_syslog(
202        &self,
203    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
204        DiagnosticsProxyInterface::r#log_debug_info_to_syslog(self)
205    }
206
207    /// Requests a handle to the netstack's process.
208    ///
209    /// This handle is not meant to be used for anything other than diagnostics,
210    /// so only the `INSPECT` right is provided to the caller.
211    pub fn r#get_process_handle_for_inspection(
212        &self,
213    ) -> fidl::client::QueryResponseFut<fidl::Process, fidl::encoding::DefaultFuchsiaResourceDialect>
214    {
215        DiagnosticsProxyInterface::r#get_process_handle_for_inspection(self)
216    }
217}
218
219impl DiagnosticsProxyInterface for DiagnosticsProxy {
220    type LogDebugInfoToSyslogResponseFut =
221        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
222    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut {
223        fn _decode(
224            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
225        ) -> Result<(), fidl::Error> {
226            let _response = fidl::client::decode_transaction_body::<
227                fidl::encoding::EmptyPayload,
228                fidl::encoding::DefaultFuchsiaResourceDialect,
229                0x336c39330bd8e1ac,
230            >(_buf?)?;
231            Ok(_response)
232        }
233        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
234            (),
235            0x336c39330bd8e1ac,
236            fidl::encoding::DynamicFlags::empty(),
237            _decode,
238        )
239    }
240
241    type GetProcessHandleForInspectionResponseFut = fidl::client::QueryResponseFut<
242        fidl::Process,
243        fidl::encoding::DefaultFuchsiaResourceDialect,
244    >;
245    fn r#get_process_handle_for_inspection(
246        &self,
247    ) -> Self::GetProcessHandleForInspectionResponseFut {
248        fn _decode(
249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
250        ) -> Result<fidl::Process, fidl::Error> {
251            let _response = fidl::client::decode_transaction_body::<
252                DiagnosticsGetProcessHandleForInspectionResponse,
253                fidl::encoding::DefaultFuchsiaResourceDialect,
254                0x563e5df030f2f4d5,
255            >(_buf?)?;
256            Ok(_response.process)
257        }
258        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Process>(
259            (),
260            0x563e5df030f2f4d5,
261            fidl::encoding::DynamicFlags::empty(),
262            _decode,
263        )
264    }
265}
266
267pub struct DiagnosticsEventStream {
268    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
269}
270
271impl std::marker::Unpin for DiagnosticsEventStream {}
272
273impl futures::stream::FusedStream for DiagnosticsEventStream {
274    fn is_terminated(&self) -> bool {
275        self.event_receiver.is_terminated()
276    }
277}
278
279impl futures::Stream for DiagnosticsEventStream {
280    type Item = Result<DiagnosticsEvent, fidl::Error>;
281
282    fn poll_next(
283        mut self: std::pin::Pin<&mut Self>,
284        cx: &mut std::task::Context<'_>,
285    ) -> std::task::Poll<Option<Self::Item>> {
286        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
287            &mut self.event_receiver,
288            cx
289        )?) {
290            Some(buf) => std::task::Poll::Ready(Some(DiagnosticsEvent::decode(buf))),
291            None => std::task::Poll::Ready(None),
292        }
293    }
294}
295
296#[derive(Debug)]
297pub enum DiagnosticsEvent {}
298
299impl DiagnosticsEvent {
300    /// Decodes a message buffer as a [`DiagnosticsEvent`].
301    fn decode(
302        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
303    ) -> Result<DiagnosticsEvent, fidl::Error> {
304        let (bytes, _handles) = buf.split_mut();
305        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
306        debug_assert_eq!(tx_header.tx_id, 0);
307        match tx_header.ordinal {
308            _ => Err(fidl::Error::UnknownOrdinal {
309                ordinal: tx_header.ordinal,
310                protocol_name: <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
311            }),
312        }
313    }
314}
315
316/// A Stream of incoming requests for fuchsia.net.debug/Diagnostics.
317pub struct DiagnosticsRequestStream {
318    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
319    is_terminated: bool,
320}
321
322impl std::marker::Unpin for DiagnosticsRequestStream {}
323
324impl futures::stream::FusedStream for DiagnosticsRequestStream {
325    fn is_terminated(&self) -> bool {
326        self.is_terminated
327    }
328}
329
330impl fidl::endpoints::RequestStream for DiagnosticsRequestStream {
331    type Protocol = DiagnosticsMarker;
332    type ControlHandle = DiagnosticsControlHandle;
333
334    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
335        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
336    }
337
338    fn control_handle(&self) -> Self::ControlHandle {
339        DiagnosticsControlHandle { inner: self.inner.clone() }
340    }
341
342    fn into_inner(
343        self,
344    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
345    {
346        (self.inner, self.is_terminated)
347    }
348
349    fn from_inner(
350        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
351        is_terminated: bool,
352    ) -> Self {
353        Self { inner, is_terminated }
354    }
355}
356
357impl futures::Stream for DiagnosticsRequestStream {
358    type Item = Result<DiagnosticsRequest, fidl::Error>;
359
360    fn poll_next(
361        mut self: std::pin::Pin<&mut Self>,
362        cx: &mut std::task::Context<'_>,
363    ) -> std::task::Poll<Option<Self::Item>> {
364        let this = &mut *self;
365        if this.inner.check_shutdown(cx) {
366            this.is_terminated = true;
367            return std::task::Poll::Ready(None);
368        }
369        if this.is_terminated {
370            panic!("polled DiagnosticsRequestStream after completion");
371        }
372        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
373            |bytes, handles| {
374                match this.inner.channel().read_etc(cx, bytes, handles) {
375                    std::task::Poll::Ready(Ok(())) => {}
376                    std::task::Poll::Pending => return std::task::Poll::Pending,
377                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
378                        this.is_terminated = true;
379                        return std::task::Poll::Ready(None);
380                    }
381                    std::task::Poll::Ready(Err(e)) => {
382                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
383                            e.into(),
384                        ))));
385                    }
386                }
387
388                // A message has been received from the channel
389                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
390
391                std::task::Poll::Ready(Some(match header.ordinal {
392                    0x336c39330bd8e1ac => {
393                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
394                        let mut req = fidl::new_empty!(
395                            fidl::encoding::EmptyPayload,
396                            fidl::encoding::DefaultFuchsiaResourceDialect
397                        );
398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
399                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
400                        Ok(DiagnosticsRequest::LogDebugInfoToSyslog {
401                            responder: DiagnosticsLogDebugInfoToSyslogResponder {
402                                control_handle: std::mem::ManuallyDrop::new(control_handle),
403                                tx_id: header.tx_id,
404                            },
405                        })
406                    }
407                    0x563e5df030f2f4d5 => {
408                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
409                        let mut req = fidl::new_empty!(
410                            fidl::encoding::EmptyPayload,
411                            fidl::encoding::DefaultFuchsiaResourceDialect
412                        );
413                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
414                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
415                        Ok(DiagnosticsRequest::GetProcessHandleForInspection {
416                            responder: DiagnosticsGetProcessHandleForInspectionResponder {
417                                control_handle: std::mem::ManuallyDrop::new(control_handle),
418                                tx_id: header.tx_id,
419                            },
420                        })
421                    }
422                    _ => Err(fidl::Error::UnknownOrdinal {
423                        ordinal: header.ordinal,
424                        protocol_name:
425                            <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
426                    }),
427                }))
428            },
429        )
430    }
431}
432
433/// Provides access to Network stack diagnostics information.
434#[derive(Debug)]
435pub enum DiagnosticsRequest {
436    /// Requests that the network stack produces debugging information in the
437    /// system logs.
438    ///
439    /// The call returns once debug information has been produced.
440    LogDebugInfoToSyslog { responder: DiagnosticsLogDebugInfoToSyslogResponder },
441    /// Requests a handle to the netstack's process.
442    ///
443    /// This handle is not meant to be used for anything other than diagnostics,
444    /// so only the `INSPECT` right is provided to the caller.
445    GetProcessHandleForInspection { responder: DiagnosticsGetProcessHandleForInspectionResponder },
446}
447
448impl DiagnosticsRequest {
449    #[allow(irrefutable_let_patterns)]
450    pub fn into_log_debug_info_to_syslog(
451        self,
452    ) -> Option<(DiagnosticsLogDebugInfoToSyslogResponder)> {
453        if let DiagnosticsRequest::LogDebugInfoToSyslog { responder } = self {
454            Some((responder))
455        } else {
456            None
457        }
458    }
459
460    #[allow(irrefutable_let_patterns)]
461    pub fn into_get_process_handle_for_inspection(
462        self,
463    ) -> Option<(DiagnosticsGetProcessHandleForInspectionResponder)> {
464        if let DiagnosticsRequest::GetProcessHandleForInspection { responder } = self {
465            Some((responder))
466        } else {
467            None
468        }
469    }
470
471    /// Name of the method defined in FIDL
472    pub fn method_name(&self) -> &'static str {
473        match *self {
474            DiagnosticsRequest::LogDebugInfoToSyslog { .. } => "log_debug_info_to_syslog",
475            DiagnosticsRequest::GetProcessHandleForInspection { .. } => {
476                "get_process_handle_for_inspection"
477            }
478        }
479    }
480}
481
482#[derive(Debug, Clone)]
483pub struct DiagnosticsControlHandle {
484    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
485}
486
487impl fidl::endpoints::ControlHandle for DiagnosticsControlHandle {
488    fn shutdown(&self) {
489        self.inner.shutdown()
490    }
491
492    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
493        self.inner.shutdown_with_epitaph(status)
494    }
495
496    fn is_closed(&self) -> bool {
497        self.inner.channel().is_closed()
498    }
499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
500        self.inner.channel().on_closed()
501    }
502
503    #[cfg(target_os = "fuchsia")]
504    fn signal_peer(
505        &self,
506        clear_mask: zx::Signals,
507        set_mask: zx::Signals,
508    ) -> Result<(), zx_status::Status> {
509        use fidl::Peered;
510        self.inner.channel().signal_peer(clear_mask, set_mask)
511    }
512}
513
514impl DiagnosticsControlHandle {}
515
516#[must_use = "FIDL methods require a response to be sent"]
517#[derive(Debug)]
518pub struct DiagnosticsLogDebugInfoToSyslogResponder {
519    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
520    tx_id: u32,
521}
522
523/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
524/// if the responder is dropped without sending a response, so that the client
525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
526impl std::ops::Drop for DiagnosticsLogDebugInfoToSyslogResponder {
527    fn drop(&mut self) {
528        self.control_handle.shutdown();
529        // Safety: drops once, never accessed again
530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
531    }
532}
533
534impl fidl::endpoints::Responder for DiagnosticsLogDebugInfoToSyslogResponder {
535    type ControlHandle = DiagnosticsControlHandle;
536
537    fn control_handle(&self) -> &DiagnosticsControlHandle {
538        &self.control_handle
539    }
540
541    fn drop_without_shutdown(mut self) {
542        // Safety: drops once, never accessed again due to mem::forget
543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
544        // Prevent Drop from running (which would shut down the channel)
545        std::mem::forget(self);
546    }
547}
548
549impl DiagnosticsLogDebugInfoToSyslogResponder {
550    /// Sends a response to the FIDL transaction.
551    ///
552    /// Sets the channel to shutdown if an error occurs.
553    pub fn send(self) -> Result<(), fidl::Error> {
554        let _result = self.send_raw();
555        if _result.is_err() {
556            self.control_handle.shutdown();
557        }
558        self.drop_without_shutdown();
559        _result
560    }
561
562    /// Similar to "send" but does not shutdown the channel if an error occurs.
563    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
564        let _result = self.send_raw();
565        self.drop_without_shutdown();
566        _result
567    }
568
569    fn send_raw(&self) -> Result<(), fidl::Error> {
570        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
571            (),
572            self.tx_id,
573            0x336c39330bd8e1ac,
574            fidl::encoding::DynamicFlags::empty(),
575        )
576    }
577}
578
579#[must_use = "FIDL methods require a response to be sent"]
580#[derive(Debug)]
581pub struct DiagnosticsGetProcessHandleForInspectionResponder {
582    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
583    tx_id: u32,
584}
585
586/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
587/// if the responder is dropped without sending a response, so that the client
588/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
589impl std::ops::Drop for DiagnosticsGetProcessHandleForInspectionResponder {
590    fn drop(&mut self) {
591        self.control_handle.shutdown();
592        // Safety: drops once, never accessed again
593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
594    }
595}
596
597impl fidl::endpoints::Responder for DiagnosticsGetProcessHandleForInspectionResponder {
598    type ControlHandle = DiagnosticsControlHandle;
599
600    fn control_handle(&self) -> &DiagnosticsControlHandle {
601        &self.control_handle
602    }
603
604    fn drop_without_shutdown(mut self) {
605        // Safety: drops once, never accessed again due to mem::forget
606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
607        // Prevent Drop from running (which would shut down the channel)
608        std::mem::forget(self);
609    }
610}
611
612impl DiagnosticsGetProcessHandleForInspectionResponder {
613    /// Sends a response to the FIDL transaction.
614    ///
615    /// Sets the channel to shutdown if an error occurs.
616    pub fn send(self, mut process: fidl::Process) -> Result<(), fidl::Error> {
617        let _result = self.send_raw(process);
618        if _result.is_err() {
619            self.control_handle.shutdown();
620        }
621        self.drop_without_shutdown();
622        _result
623    }
624
625    /// Similar to "send" but does not shutdown the channel if an error occurs.
626    pub fn send_no_shutdown_on_err(self, mut process: fidl::Process) -> Result<(), fidl::Error> {
627        let _result = self.send_raw(process);
628        self.drop_without_shutdown();
629        _result
630    }
631
632    fn send_raw(&self, mut process: fidl::Process) -> Result<(), fidl::Error> {
633        self.control_handle.inner.send::<DiagnosticsGetProcessHandleForInspectionResponse>(
634            (process,),
635            self.tx_id,
636            0x563e5df030f2f4d5,
637            fidl::encoding::DynamicFlags::empty(),
638        )
639    }
640}
641
642#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
643pub struct InterfacesMarker;
644
645impl fidl::endpoints::ProtocolMarker for InterfacesMarker {
646    type Proxy = InterfacesProxy;
647    type RequestStream = InterfacesRequestStream;
648    #[cfg(target_os = "fuchsia")]
649    type SynchronousProxy = InterfacesSynchronousProxy;
650
651    const DEBUG_NAME: &'static str = "fuchsia.net.debug.Interfaces";
652}
653impl fidl::endpoints::DiscoverableProtocolMarker for InterfacesMarker {}
654
655pub trait InterfacesProxyInterface: Send + Sync {
656    fn r#get_port(
657        &self,
658        id: u64,
659        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
660    ) -> Result<(), fidl::Error>;
661}
662#[derive(Debug)]
663#[cfg(target_os = "fuchsia")]
664pub struct InterfacesSynchronousProxy {
665    client: fidl::client::sync::Client,
666}
667
668#[cfg(target_os = "fuchsia")]
669impl fidl::endpoints::SynchronousProxy for InterfacesSynchronousProxy {
670    type Proxy = InterfacesProxy;
671    type Protocol = InterfacesMarker;
672
673    fn from_channel(inner: fidl::Channel) -> Self {
674        Self::new(inner)
675    }
676
677    fn into_channel(self) -> fidl::Channel {
678        self.client.into_channel()
679    }
680
681    fn as_channel(&self) -> &fidl::Channel {
682        self.client.as_channel()
683    }
684}
685
686#[cfg(target_os = "fuchsia")]
687impl InterfacesSynchronousProxy {
688    pub fn new(channel: fidl::Channel) -> Self {
689        let protocol_name = <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
690        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
691    }
692
693    pub fn into_channel(self) -> fidl::Channel {
694        self.client.into_channel()
695    }
696
697    /// Waits until an event arrives and returns it. It is safe for other
698    /// threads to make concurrent requests while waiting for an event.
699    pub fn wait_for_event(
700        &self,
701        deadline: zx::MonotonicInstant,
702    ) -> Result<InterfacesEvent, fidl::Error> {
703        InterfacesEvent::decode(self.client.wait_for_event(deadline)?)
704    }
705
706    /// Provides access to the port backing an interface.
707    ///
708    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
709    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
710    /// [`fuchsia.hardware.network/Port`].
711    ///
712    /// + request `id` identifies the interface whose port is granted.
713    /// + request `port` grants access to the interface's device port.
714    pub fn r#get_port(
715        &self,
716        mut id: u64,
717        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
718    ) -> Result<(), fidl::Error> {
719        self.client.send::<InterfacesGetPortRequest>(
720            (id, port),
721            0xdd15c4df17fb148,
722            fidl::encoding::DynamicFlags::empty(),
723        )
724    }
725}
726
727#[cfg(target_os = "fuchsia")]
728impl From<InterfacesSynchronousProxy> for zx::NullableHandle {
729    fn from(value: InterfacesSynchronousProxy) -> Self {
730        value.into_channel().into()
731    }
732}
733
734#[cfg(target_os = "fuchsia")]
735impl From<fidl::Channel> for InterfacesSynchronousProxy {
736    fn from(value: fidl::Channel) -> Self {
737        Self::new(value)
738    }
739}
740
741#[cfg(target_os = "fuchsia")]
742impl fidl::endpoints::FromClient for InterfacesSynchronousProxy {
743    type Protocol = InterfacesMarker;
744
745    fn from_client(value: fidl::endpoints::ClientEnd<InterfacesMarker>) -> Self {
746        Self::new(value.into_channel())
747    }
748}
749
750#[derive(Debug, Clone)]
751pub struct InterfacesProxy {
752    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
753}
754
755impl fidl::endpoints::Proxy for InterfacesProxy {
756    type Protocol = InterfacesMarker;
757
758    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
759        Self::new(inner)
760    }
761
762    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
763        self.client.into_channel().map_err(|client| Self { client })
764    }
765
766    fn as_channel(&self) -> &::fidl::AsyncChannel {
767        self.client.as_channel()
768    }
769}
770
771impl InterfacesProxy {
772    /// Create a new Proxy for fuchsia.net.debug/Interfaces.
773    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
774        let protocol_name = <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
775        Self { client: fidl::client::Client::new(channel, protocol_name) }
776    }
777
778    /// Get a Stream of events from the remote end of the protocol.
779    ///
780    /// # Panics
781    ///
782    /// Panics if the event stream was already taken.
783    pub fn take_event_stream(&self) -> InterfacesEventStream {
784        InterfacesEventStream { event_receiver: self.client.take_event_receiver() }
785    }
786
787    /// Provides access to the port backing an interface.
788    ///
789    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
790    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
791    /// [`fuchsia.hardware.network/Port`].
792    ///
793    /// + request `id` identifies the interface whose port is granted.
794    /// + request `port` grants access to the interface's device port.
795    pub fn r#get_port(
796        &self,
797        mut id: u64,
798        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
799    ) -> Result<(), fidl::Error> {
800        InterfacesProxyInterface::r#get_port(self, id, port)
801    }
802}
803
804impl InterfacesProxyInterface for InterfacesProxy {
805    fn r#get_port(
806        &self,
807        mut id: u64,
808        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
809    ) -> Result<(), fidl::Error> {
810        self.client.send::<InterfacesGetPortRequest>(
811            (id, port),
812            0xdd15c4df17fb148,
813            fidl::encoding::DynamicFlags::empty(),
814        )
815    }
816}
817
818pub struct InterfacesEventStream {
819    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
820}
821
822impl std::marker::Unpin for InterfacesEventStream {}
823
824impl futures::stream::FusedStream for InterfacesEventStream {
825    fn is_terminated(&self) -> bool {
826        self.event_receiver.is_terminated()
827    }
828}
829
830impl futures::Stream for InterfacesEventStream {
831    type Item = Result<InterfacesEvent, fidl::Error>;
832
833    fn poll_next(
834        mut self: std::pin::Pin<&mut Self>,
835        cx: &mut std::task::Context<'_>,
836    ) -> std::task::Poll<Option<Self::Item>> {
837        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
838            &mut self.event_receiver,
839            cx
840        )?) {
841            Some(buf) => std::task::Poll::Ready(Some(InterfacesEvent::decode(buf))),
842            None => std::task::Poll::Ready(None),
843        }
844    }
845}
846
847#[derive(Debug)]
848pub enum InterfacesEvent {}
849
850impl InterfacesEvent {
851    /// Decodes a message buffer as a [`InterfacesEvent`].
852    fn decode(
853        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
854    ) -> Result<InterfacesEvent, fidl::Error> {
855        let (bytes, _handles) = buf.split_mut();
856        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
857        debug_assert_eq!(tx_header.tx_id, 0);
858        match tx_header.ordinal {
859            _ => Err(fidl::Error::UnknownOrdinal {
860                ordinal: tx_header.ordinal,
861                protocol_name: <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
862            }),
863        }
864    }
865}
866
867/// A Stream of incoming requests for fuchsia.net.debug/Interfaces.
868pub struct InterfacesRequestStream {
869    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
870    is_terminated: bool,
871}
872
873impl std::marker::Unpin for InterfacesRequestStream {}
874
875impl futures::stream::FusedStream for InterfacesRequestStream {
876    fn is_terminated(&self) -> bool {
877        self.is_terminated
878    }
879}
880
881impl fidl::endpoints::RequestStream for InterfacesRequestStream {
882    type Protocol = InterfacesMarker;
883    type ControlHandle = InterfacesControlHandle;
884
885    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
886        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
887    }
888
889    fn control_handle(&self) -> Self::ControlHandle {
890        InterfacesControlHandle { inner: self.inner.clone() }
891    }
892
893    fn into_inner(
894        self,
895    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
896    {
897        (self.inner, self.is_terminated)
898    }
899
900    fn from_inner(
901        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
902        is_terminated: bool,
903    ) -> Self {
904        Self { inner, is_terminated }
905    }
906}
907
908impl futures::Stream for InterfacesRequestStream {
909    type Item = Result<InterfacesRequest, fidl::Error>;
910
911    fn poll_next(
912        mut self: std::pin::Pin<&mut Self>,
913        cx: &mut std::task::Context<'_>,
914    ) -> std::task::Poll<Option<Self::Item>> {
915        let this = &mut *self;
916        if this.inner.check_shutdown(cx) {
917            this.is_terminated = true;
918            return std::task::Poll::Ready(None);
919        }
920        if this.is_terminated {
921            panic!("polled InterfacesRequestStream after completion");
922        }
923        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
924            |bytes, handles| {
925                match this.inner.channel().read_etc(cx, bytes, handles) {
926                    std::task::Poll::Ready(Ok(())) => {}
927                    std::task::Poll::Pending => return std::task::Poll::Pending,
928                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
929                        this.is_terminated = true;
930                        return std::task::Poll::Ready(None);
931                    }
932                    std::task::Poll::Ready(Err(e)) => {
933                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
934                            e.into(),
935                        ))));
936                    }
937                }
938
939                // A message has been received from the channel
940                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
941
942                std::task::Poll::Ready(Some(match header.ordinal {
943                    0xdd15c4df17fb148 => {
944                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
945                        let mut req = fidl::new_empty!(
946                            InterfacesGetPortRequest,
947                            fidl::encoding::DefaultFuchsiaResourceDialect
948                        );
949                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterfacesGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
950                        let control_handle = InterfacesControlHandle { inner: this.inner.clone() };
951                        Ok(InterfacesRequest::GetPort {
952                            id: req.id,
953                            port: req.port,
954
955                            control_handle,
956                        })
957                    }
958                    _ => Err(fidl::Error::UnknownOrdinal {
959                        ordinal: header.ordinal,
960                        protocol_name:
961                            <InterfacesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
962                    }),
963                }))
964            },
965        )
966    }
967}
968
969/// Network interface debugging functionality.
970///
971/// This protocol is intended for debugging and testing only; and not meant for
972/// load-bearing code.
973#[derive(Debug)]
974pub enum InterfacesRequest {
975    /// Provides access to the port backing an interface.
976    ///
977    /// `port` is closed with `ZX_ERR_NOT_FOUND` if an interface referenced by
978    /// `id` does not exist or `ZX_ERR_NOT_SUPPORTED` if it is not backed by a
979    /// [`fuchsia.hardware.network/Port`].
980    ///
981    /// + request `id` identifies the interface whose port is granted.
982    /// + request `port` grants access to the interface's device port.
983    GetPort {
984        id: u64,
985        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
986        control_handle: InterfacesControlHandle,
987    },
988}
989
990impl InterfacesRequest {
991    #[allow(irrefutable_let_patterns)]
992    pub fn into_get_port(
993        self,
994    ) -> Option<(
995        u64,
996        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
997        InterfacesControlHandle,
998    )> {
999        if let InterfacesRequest::GetPort { id, port, control_handle } = self {
1000            Some((id, port, control_handle))
1001        } else {
1002            None
1003        }
1004    }
1005
1006    /// Name of the method defined in FIDL
1007    pub fn method_name(&self) -> &'static str {
1008        match *self {
1009            InterfacesRequest::GetPort { .. } => "get_port",
1010        }
1011    }
1012}
1013
1014#[derive(Debug, Clone)]
1015pub struct InterfacesControlHandle {
1016    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1017}
1018
1019impl fidl::endpoints::ControlHandle for InterfacesControlHandle {
1020    fn shutdown(&self) {
1021        self.inner.shutdown()
1022    }
1023
1024    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1025        self.inner.shutdown_with_epitaph(status)
1026    }
1027
1028    fn is_closed(&self) -> bool {
1029        self.inner.channel().is_closed()
1030    }
1031    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1032        self.inner.channel().on_closed()
1033    }
1034
1035    #[cfg(target_os = "fuchsia")]
1036    fn signal_peer(
1037        &self,
1038        clear_mask: zx::Signals,
1039        set_mask: zx::Signals,
1040    ) -> Result<(), zx_status::Status> {
1041        use fidl::Peered;
1042        self.inner.channel().signal_peer(clear_mask, set_mask)
1043    }
1044}
1045
1046impl InterfacesControlHandle {}
1047
1048mod internal {
1049    use super::*;
1050
1051    impl fidl::encoding::ResourceTypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
1052        type Borrowed<'a> = &'a mut Self;
1053        fn take_or_borrow<'a>(
1054            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1055        ) -> Self::Borrowed<'a> {
1056            value
1057        }
1058    }
1059
1060    unsafe impl fidl::encoding::TypeMarker for DiagnosticsGetProcessHandleForInspectionResponse {
1061        type Owned = Self;
1062
1063        #[inline(always)]
1064        fn inline_align(_context: fidl::encoding::Context) -> usize {
1065            4
1066        }
1067
1068        #[inline(always)]
1069        fn inline_size(_context: fidl::encoding::Context) -> usize {
1070            4
1071        }
1072    }
1073
1074    unsafe impl
1075        fidl::encoding::Encode<
1076            DiagnosticsGetProcessHandleForInspectionResponse,
1077            fidl::encoding::DefaultFuchsiaResourceDialect,
1078        > for &mut DiagnosticsGetProcessHandleForInspectionResponse
1079    {
1080        #[inline]
1081        unsafe fn encode(
1082            self,
1083            encoder: &mut fidl::encoding::Encoder<
1084                '_,
1085                fidl::encoding::DefaultFuchsiaResourceDialect,
1086            >,
1087            offset: usize,
1088            _depth: fidl::encoding::Depth,
1089        ) -> fidl::Result<()> {
1090            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
1091            // Delegate to tuple encoding.
1092            fidl::encoding::Encode::<
1093                DiagnosticsGetProcessHandleForInspectionResponse,
1094                fidl::encoding::DefaultFuchsiaResourceDialect,
1095            >::encode(
1096                (<fidl::encoding::HandleType<
1097                    fidl::Process,
1098                    { fidl::ObjectType::PROCESS.into_raw() },
1099                    32768,
1100                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1101                    &mut self.process
1102                ),),
1103                encoder,
1104                offset,
1105                _depth,
1106            )
1107        }
1108    }
1109    unsafe impl<
1110        T0: fidl::encoding::Encode<
1111                fidl::encoding::HandleType<
1112                    fidl::Process,
1113                    { fidl::ObjectType::PROCESS.into_raw() },
1114                    32768,
1115                >,
1116                fidl::encoding::DefaultFuchsiaResourceDialect,
1117            >,
1118    >
1119        fidl::encoding::Encode<
1120            DiagnosticsGetProcessHandleForInspectionResponse,
1121            fidl::encoding::DefaultFuchsiaResourceDialect,
1122        > for (T0,)
1123    {
1124        #[inline]
1125        unsafe fn encode(
1126            self,
1127            encoder: &mut fidl::encoding::Encoder<
1128                '_,
1129                fidl::encoding::DefaultFuchsiaResourceDialect,
1130            >,
1131            offset: usize,
1132            depth: fidl::encoding::Depth,
1133        ) -> fidl::Result<()> {
1134            encoder.debug_check_bounds::<DiagnosticsGetProcessHandleForInspectionResponse>(offset);
1135            // Zero out padding regions. There's no need to apply masks
1136            // because the unmasked parts will be overwritten by fields.
1137            // Write the fields.
1138            self.0.encode(encoder, offset + 0, depth)?;
1139            Ok(())
1140        }
1141    }
1142
1143    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1144        for DiagnosticsGetProcessHandleForInspectionResponse
1145    {
1146        #[inline(always)]
1147        fn new_empty() -> Self {
1148            Self {
1149                process: fidl::new_empty!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect),
1150            }
1151        }
1152
1153        #[inline]
1154        unsafe fn decode(
1155            &mut self,
1156            decoder: &mut fidl::encoding::Decoder<
1157                '_,
1158                fidl::encoding::DefaultFuchsiaResourceDialect,
1159            >,
1160            offset: usize,
1161            _depth: fidl::encoding::Depth,
1162        ) -> fidl::Result<()> {
1163            decoder.debug_check_bounds::<Self>(offset);
1164            // Verify that padding bytes are zero.
1165            fidl::decode!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.process, decoder, offset + 0, _depth)?;
1166            Ok(())
1167        }
1168    }
1169
1170    impl fidl::encoding::ResourceTypeMarker for InterfacesGetPortRequest {
1171        type Borrowed<'a> = &'a mut Self;
1172        fn take_or_borrow<'a>(
1173            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1174        ) -> Self::Borrowed<'a> {
1175            value
1176        }
1177    }
1178
1179    unsafe impl fidl::encoding::TypeMarker for InterfacesGetPortRequest {
1180        type Owned = Self;
1181
1182        #[inline(always)]
1183        fn inline_align(_context: fidl::encoding::Context) -> usize {
1184            8
1185        }
1186
1187        #[inline(always)]
1188        fn inline_size(_context: fidl::encoding::Context) -> usize {
1189            16
1190        }
1191    }
1192
1193    unsafe impl
1194        fidl::encoding::Encode<
1195            InterfacesGetPortRequest,
1196            fidl::encoding::DefaultFuchsiaResourceDialect,
1197        > for &mut InterfacesGetPortRequest
1198    {
1199        #[inline]
1200        unsafe fn encode(
1201            self,
1202            encoder: &mut fidl::encoding::Encoder<
1203                '_,
1204                fidl::encoding::DefaultFuchsiaResourceDialect,
1205            >,
1206            offset: usize,
1207            _depth: fidl::encoding::Depth,
1208        ) -> fidl::Result<()> {
1209            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
1210            // Delegate to tuple encoding.
1211            fidl::encoding::Encode::<
1212                InterfacesGetPortRequest,
1213                fidl::encoding::DefaultFuchsiaResourceDialect,
1214            >::encode(
1215                (
1216                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1217                    <fidl::encoding::Endpoint<
1218                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1219                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1220                        &mut self.port
1221                    ),
1222                ),
1223                encoder,
1224                offset,
1225                _depth,
1226            )
1227        }
1228    }
1229    unsafe impl<
1230        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1231        T1: fidl::encoding::Encode<
1232                fidl::encoding::Endpoint<
1233                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1234                >,
1235                fidl::encoding::DefaultFuchsiaResourceDialect,
1236            >,
1237    >
1238        fidl::encoding::Encode<
1239            InterfacesGetPortRequest,
1240            fidl::encoding::DefaultFuchsiaResourceDialect,
1241        > for (T0, T1)
1242    {
1243        #[inline]
1244        unsafe fn encode(
1245            self,
1246            encoder: &mut fidl::encoding::Encoder<
1247                '_,
1248                fidl::encoding::DefaultFuchsiaResourceDialect,
1249            >,
1250            offset: usize,
1251            depth: fidl::encoding::Depth,
1252        ) -> fidl::Result<()> {
1253            encoder.debug_check_bounds::<InterfacesGetPortRequest>(offset);
1254            // Zero out padding regions. There's no need to apply masks
1255            // because the unmasked parts will be overwritten by fields.
1256            unsafe {
1257                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1258                (ptr as *mut u64).write_unaligned(0);
1259            }
1260            // Write the fields.
1261            self.0.encode(encoder, offset + 0, depth)?;
1262            self.1.encode(encoder, offset + 8, depth)?;
1263            Ok(())
1264        }
1265    }
1266
1267    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1268        for InterfacesGetPortRequest
1269    {
1270        #[inline(always)]
1271        fn new_empty() -> Self {
1272            Self {
1273                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1274                port: fidl::new_empty!(
1275                    fidl::encoding::Endpoint<
1276                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1277                    >,
1278                    fidl::encoding::DefaultFuchsiaResourceDialect
1279                ),
1280            }
1281        }
1282
1283        #[inline]
1284        unsafe fn decode(
1285            &mut self,
1286            decoder: &mut fidl::encoding::Decoder<
1287                '_,
1288                fidl::encoding::DefaultFuchsiaResourceDialect,
1289            >,
1290            offset: usize,
1291            _depth: fidl::encoding::Depth,
1292        ) -> fidl::Result<()> {
1293            decoder.debug_check_bounds::<Self>(offset);
1294            // Verify that padding bytes are zero.
1295            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1296            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1297            let mask = 0xffffffff00000000u64;
1298            let maskedval = padval & mask;
1299            if maskedval != 0 {
1300                return Err(fidl::Error::NonZeroPadding {
1301                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1302                });
1303            }
1304            fidl::decode!(
1305                u64,
1306                fidl::encoding::DefaultFuchsiaResourceDialect,
1307                &mut self.id,
1308                decoder,
1309                offset + 0,
1310                _depth
1311            )?;
1312            fidl::decode!(
1313                fidl::encoding::Endpoint<
1314                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1315                >,
1316                fidl::encoding::DefaultFuchsiaResourceDialect,
1317                &mut self.port,
1318                decoder,
1319                offset + 8,
1320                _depth
1321            )?;
1322            Ok(())
1323        }
1324    }
1325}