Skip to main content

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