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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// A path to a device node.
14pub type DevicePath = String;
15
16/// A value indicating that a [`ForwardingEntry`]'s metric is unspecified.
17pub const UNSPECIFIED_METRIC: u32 = 0;
18
19#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
20#[repr(u32)]
21pub enum Error {
22    Internal = 1,
23    NotSupported = 2,
24    InvalidArgs = 3,
25    BadState = 4,
26    TimeOut = 5,
27    NotFound = 6,
28    AlreadyExists = 7,
29    Io = 8,
30}
31
32impl Error {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            1 => Some(Self::Internal),
37            2 => Some(Self::NotSupported),
38            3 => Some(Self::InvalidArgs),
39            4 => Some(Self::BadState),
40            5 => Some(Self::TimeOut),
41            6 => Some(Self::NotFound),
42            7 => Some(Self::AlreadyExists),
43            8 => Some(Self::Io),
44            _ => None,
45        }
46    }
47
48    #[inline]
49    pub const fn into_primitive(self) -> u32 {
50        self as u32
51    }
52
53    #[deprecated = "Strict enums should not use `is_unknown`"]
54    #[inline]
55    pub fn is_unknown(&self) -> bool {
56        false
57    }
58}
59
60/// An entry in the forwarding table for the network stack.
61///
62/// Valid if at least one of [`device_id`] and [`next_hop`] is specified.
63#[derive(Clone, Debug, PartialEq)]
64pub struct ForwardingEntry {
65    /// The destination subnet this route can be used to send to.
66    pub subnet: fidl_fuchsia_net::Subnet,
67    /// The opaque identifier of the device to which packets should be forwarded. The zero value is
68    /// interpreted as unspecified. If unspecified, [`next_hop`] must be set, and will be used by
69    /// the server to select an appropriate device.
70    pub device_id: u64,
71    /// The IP address of the next hop. Used for link-layer address resolution, if present.
72    pub next_hop: Option<Box<fidl_fuchsia_net::IpAddress>>,
73    /// This entry's metric.
74    ///
75    /// [`UNSPECIFIED_METRIC`] is interpreted as unspecified.
76    pub metric: u32,
77}
78
79impl fidl::Persistable for ForwardingEntry {}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub struct LogSetLogPacketsRequest {
83    pub enabled: bool,
84}
85
86impl fidl::Persistable for LogSetLogPacketsRequest {}
87
88#[derive(Clone, Debug, PartialEq)]
89pub struct StackAddForwardingEntryRequest {
90    pub entry: ForwardingEntry,
91}
92
93impl fidl::Persistable for StackAddForwardingEntryRequest {}
94
95#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96pub struct StackBridgeInterfacesRequest {
97    pub interfaces: Vec<u64>,
98    pub bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
99}
100
101impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
102    for StackBridgeInterfacesRequest
103{
104}
105
106#[derive(Clone, Debug, PartialEq)]
107pub struct StackDelForwardingEntryRequest {
108    pub entry: ForwardingEntry,
109}
110
111impl fidl::Persistable for StackDelForwardingEntryRequest {}
112
113#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
114pub struct StackSetDhcpClientEnabledRequest {
115    pub id: u64,
116    pub enable: bool,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
120    for StackSetDhcpClientEnabledRequest
121{
122}
123
124#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
125pub struct LogMarker;
126
127impl fidl::endpoints::ProtocolMarker for LogMarker {
128    type Proxy = LogProxy;
129    type RequestStream = LogRequestStream;
130    #[cfg(target_os = "fuchsia")]
131    type SynchronousProxy = LogSynchronousProxy;
132
133    const DEBUG_NAME: &'static str = "fuchsia.net.stack.Log";
134}
135impl fidl::endpoints::DiscoverableProtocolMarker for LogMarker {}
136
137pub trait LogProxyInterface: Send + Sync {
138    type SetLogPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
139    fn r#set_log_packets(&self, enabled: bool) -> Self::SetLogPacketsResponseFut;
140}
141#[derive(Debug)]
142#[cfg(target_os = "fuchsia")]
143pub struct LogSynchronousProxy {
144    client: fidl::client::sync::Client,
145}
146
147#[cfg(target_os = "fuchsia")]
148impl fidl::endpoints::SynchronousProxy for LogSynchronousProxy {
149    type Proxy = LogProxy;
150    type Protocol = LogMarker;
151
152    fn from_channel(inner: fidl::Channel) -> Self {
153        Self::new(inner)
154    }
155
156    fn into_channel(self) -> fidl::Channel {
157        self.client.into_channel()
158    }
159
160    fn as_channel(&self) -> &fidl::Channel {
161        self.client.as_channel()
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl LogSynchronousProxy {
167    pub fn new(channel: fidl::Channel) -> Self {
168        let protocol_name = <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
169        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
170    }
171
172    pub fn into_channel(self) -> fidl::Channel {
173        self.client.into_channel()
174    }
175
176    /// Waits until an event arrives and returns it. It is safe for other
177    /// threads to make concurrent requests while waiting for an event.
178    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<LogEvent, fidl::Error> {
179        LogEvent::decode(self.client.wait_for_event(deadline)?)
180    }
181
182    /// Dynamically set packet logging.
183    pub fn r#set_log_packets(
184        &self,
185        mut enabled: bool,
186        ___deadline: zx::MonotonicInstant,
187    ) -> Result<(), fidl::Error> {
188        let _response =
189            self.client.send_query::<LogSetLogPacketsRequest, fidl::encoding::EmptyPayload>(
190                (enabled,),
191                0x2176044cba5f378e,
192                fidl::encoding::DynamicFlags::empty(),
193                ___deadline,
194            )?;
195        Ok(_response)
196    }
197}
198
199#[derive(Debug, Clone)]
200pub struct LogProxy {
201    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
202}
203
204impl fidl::endpoints::Proxy for LogProxy {
205    type Protocol = LogMarker;
206
207    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
208        Self::new(inner)
209    }
210
211    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
212        self.client.into_channel().map_err(|client| Self { client })
213    }
214
215    fn as_channel(&self) -> &::fidl::AsyncChannel {
216        self.client.as_channel()
217    }
218}
219
220impl LogProxy {
221    /// Create a new Proxy for fuchsia.net.stack/Log.
222    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
223        let protocol_name = <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
224        Self { client: fidl::client::Client::new(channel, protocol_name) }
225    }
226
227    /// Get a Stream of events from the remote end of the protocol.
228    ///
229    /// # Panics
230    ///
231    /// Panics if the event stream was already taken.
232    pub fn take_event_stream(&self) -> LogEventStream {
233        LogEventStream { event_receiver: self.client.take_event_receiver() }
234    }
235
236    /// Dynamically set packet logging.
237    pub fn r#set_log_packets(
238        &self,
239        mut enabled: bool,
240    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
241        LogProxyInterface::r#set_log_packets(self, enabled)
242    }
243}
244
245impl LogProxyInterface for LogProxy {
246    type SetLogPacketsResponseFut =
247        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
248    fn r#set_log_packets(&self, mut enabled: bool) -> Self::SetLogPacketsResponseFut {
249        fn _decode(
250            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
251        ) -> Result<(), fidl::Error> {
252            let _response = fidl::client::decode_transaction_body::<
253                fidl::encoding::EmptyPayload,
254                fidl::encoding::DefaultFuchsiaResourceDialect,
255                0x2176044cba5f378e,
256            >(_buf?)?;
257            Ok(_response)
258        }
259        self.client.send_query_and_decode::<LogSetLogPacketsRequest, ()>(
260            (enabled,),
261            0x2176044cba5f378e,
262            fidl::encoding::DynamicFlags::empty(),
263            _decode,
264        )
265    }
266}
267
268pub struct LogEventStream {
269    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
270}
271
272impl std::marker::Unpin for LogEventStream {}
273
274impl futures::stream::FusedStream for LogEventStream {
275    fn is_terminated(&self) -> bool {
276        self.event_receiver.is_terminated()
277    }
278}
279
280impl futures::Stream for LogEventStream {
281    type Item = Result<LogEvent, fidl::Error>;
282
283    fn poll_next(
284        mut self: std::pin::Pin<&mut Self>,
285        cx: &mut std::task::Context<'_>,
286    ) -> std::task::Poll<Option<Self::Item>> {
287        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
288            &mut self.event_receiver,
289            cx
290        )?) {
291            Some(buf) => std::task::Poll::Ready(Some(LogEvent::decode(buf))),
292            None => std::task::Poll::Ready(None),
293        }
294    }
295}
296
297#[derive(Debug)]
298pub enum LogEvent {}
299
300impl LogEvent {
301    /// Decodes a message buffer as a [`LogEvent`].
302    fn decode(
303        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
304    ) -> Result<LogEvent, fidl::Error> {
305        let (bytes, _handles) = buf.split_mut();
306        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
307        debug_assert_eq!(tx_header.tx_id, 0);
308        match tx_header.ordinal {
309            _ => Err(fidl::Error::UnknownOrdinal {
310                ordinal: tx_header.ordinal,
311                protocol_name: <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
312            }),
313        }
314    }
315}
316
317/// A Stream of incoming requests for fuchsia.net.stack/Log.
318pub struct LogRequestStream {
319    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
320    is_terminated: bool,
321}
322
323impl std::marker::Unpin for LogRequestStream {}
324
325impl futures::stream::FusedStream for LogRequestStream {
326    fn is_terminated(&self) -> bool {
327        self.is_terminated
328    }
329}
330
331impl fidl::endpoints::RequestStream for LogRequestStream {
332    type Protocol = LogMarker;
333    type ControlHandle = LogControlHandle;
334
335    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
336        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
337    }
338
339    fn control_handle(&self) -> Self::ControlHandle {
340        LogControlHandle { inner: self.inner.clone() }
341    }
342
343    fn into_inner(
344        self,
345    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
346    {
347        (self.inner, self.is_terminated)
348    }
349
350    fn from_inner(
351        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
352        is_terminated: bool,
353    ) -> Self {
354        Self { inner, is_terminated }
355    }
356}
357
358impl futures::Stream for LogRequestStream {
359    type Item = Result<LogRequest, fidl::Error>;
360
361    fn poll_next(
362        mut self: std::pin::Pin<&mut Self>,
363        cx: &mut std::task::Context<'_>,
364    ) -> std::task::Poll<Option<Self::Item>> {
365        let this = &mut *self;
366        if this.inner.check_shutdown(cx) {
367            this.is_terminated = true;
368            return std::task::Poll::Ready(None);
369        }
370        if this.is_terminated {
371            panic!("polled LogRequestStream after completion");
372        }
373        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
374            |bytes, handles| {
375                match this.inner.channel().read_etc(cx, bytes, handles) {
376                    std::task::Poll::Ready(Ok(())) => {}
377                    std::task::Poll::Pending => return std::task::Poll::Pending,
378                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
379                        this.is_terminated = true;
380                        return std::task::Poll::Ready(None);
381                    }
382                    std::task::Poll::Ready(Err(e)) => {
383                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
384                            e.into(),
385                        ))))
386                    }
387                }
388
389                // A message has been received from the channel
390                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
391
392                std::task::Poll::Ready(Some(match header.ordinal {
393                    0x2176044cba5f378e => {
394                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
395                        let mut req = fidl::new_empty!(
396                            LogSetLogPacketsRequest,
397                            fidl::encoding::DefaultFuchsiaResourceDialect
398                        );
399                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogSetLogPacketsRequest>(&header, _body_bytes, handles, &mut req)?;
400                        let control_handle = LogControlHandle { inner: this.inner.clone() };
401                        Ok(LogRequest::SetLogPackets {
402                            enabled: req.enabled,
403
404                            responder: LogSetLogPacketsResponder {
405                                control_handle: std::mem::ManuallyDrop::new(control_handle),
406                                tx_id: header.tx_id,
407                            },
408                        })
409                    }
410                    _ => Err(fidl::Error::UnknownOrdinal {
411                        ordinal: header.ordinal,
412                        protocol_name: <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
413                    }),
414                }))
415            },
416        )
417    }
418}
419
420#[derive(Debug)]
421pub enum LogRequest {
422    /// Dynamically set packet logging.
423    SetLogPackets { enabled: bool, responder: LogSetLogPacketsResponder },
424}
425
426impl LogRequest {
427    #[allow(irrefutable_let_patterns)]
428    pub fn into_set_log_packets(self) -> Option<(bool, LogSetLogPacketsResponder)> {
429        if let LogRequest::SetLogPackets { enabled, responder } = self {
430            Some((enabled, responder))
431        } else {
432            None
433        }
434    }
435
436    /// Name of the method defined in FIDL
437    pub fn method_name(&self) -> &'static str {
438        match *self {
439            LogRequest::SetLogPackets { .. } => "set_log_packets",
440        }
441    }
442}
443
444#[derive(Debug, Clone)]
445pub struct LogControlHandle {
446    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447}
448
449impl fidl::endpoints::ControlHandle for LogControlHandle {
450    fn shutdown(&self) {
451        self.inner.shutdown()
452    }
453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
454        self.inner.shutdown_with_epitaph(status)
455    }
456
457    fn is_closed(&self) -> bool {
458        self.inner.channel().is_closed()
459    }
460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
461        self.inner.channel().on_closed()
462    }
463
464    #[cfg(target_os = "fuchsia")]
465    fn signal_peer(
466        &self,
467        clear_mask: zx::Signals,
468        set_mask: zx::Signals,
469    ) -> Result<(), zx_status::Status> {
470        use fidl::Peered;
471        self.inner.channel().signal_peer(clear_mask, set_mask)
472    }
473}
474
475impl LogControlHandle {}
476
477#[must_use = "FIDL methods require a response to be sent"]
478#[derive(Debug)]
479pub struct LogSetLogPacketsResponder {
480    control_handle: std::mem::ManuallyDrop<LogControlHandle>,
481    tx_id: u32,
482}
483
484/// Set the the channel to be shutdown (see [`LogControlHandle::shutdown`])
485/// if the responder is dropped without sending a response, so that the client
486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
487impl std::ops::Drop for LogSetLogPacketsResponder {
488    fn drop(&mut self) {
489        self.control_handle.shutdown();
490        // Safety: drops once, never accessed again
491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492    }
493}
494
495impl fidl::endpoints::Responder for LogSetLogPacketsResponder {
496    type ControlHandle = LogControlHandle;
497
498    fn control_handle(&self) -> &LogControlHandle {
499        &self.control_handle
500    }
501
502    fn drop_without_shutdown(mut self) {
503        // Safety: drops once, never accessed again due to mem::forget
504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505        // Prevent Drop from running (which would shut down the channel)
506        std::mem::forget(self);
507    }
508}
509
510impl LogSetLogPacketsResponder {
511    /// Sends a response to the FIDL transaction.
512    ///
513    /// Sets the channel to shutdown if an error occurs.
514    pub fn send(self) -> Result<(), fidl::Error> {
515        let _result = self.send_raw();
516        if _result.is_err() {
517            self.control_handle.shutdown();
518        }
519        self.drop_without_shutdown();
520        _result
521    }
522
523    /// Similar to "send" but does not shutdown the channel if an error occurs.
524    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
525        let _result = self.send_raw();
526        self.drop_without_shutdown();
527        _result
528    }
529
530    fn send_raw(&self) -> Result<(), fidl::Error> {
531        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
532            (),
533            self.tx_id,
534            0x2176044cba5f378e,
535            fidl::encoding::DynamicFlags::empty(),
536        )
537    }
538}
539
540#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
541pub struct StackMarker;
542
543impl fidl::endpoints::ProtocolMarker for StackMarker {
544    type Proxy = StackProxy;
545    type RequestStream = StackRequestStream;
546    #[cfg(target_os = "fuchsia")]
547    type SynchronousProxy = StackSynchronousProxy;
548
549    const DEBUG_NAME: &'static str = "fuchsia.net.stack.Stack";
550}
551impl fidl::endpoints::DiscoverableProtocolMarker for StackMarker {}
552pub type StackAddForwardingEntryResult = Result<(), Error>;
553pub type StackDelForwardingEntryResult = Result<(), Error>;
554pub type StackSetDhcpClientEnabledResult = Result<(), Error>;
555
556pub trait StackProxyInterface: Send + Sync {
557    type AddForwardingEntryResponseFut: std::future::Future<Output = Result<StackAddForwardingEntryResult, fidl::Error>>
558        + Send;
559    fn r#add_forwarding_entry(
560        &self,
561        entry: &ForwardingEntry,
562    ) -> Self::AddForwardingEntryResponseFut;
563    type DelForwardingEntryResponseFut: std::future::Future<Output = Result<StackDelForwardingEntryResult, fidl::Error>>
564        + Send;
565    fn r#del_forwarding_entry(
566        &self,
567        entry: &ForwardingEntry,
568    ) -> Self::DelForwardingEntryResponseFut;
569    type SetDhcpClientEnabledResponseFut: std::future::Future<Output = Result<StackSetDhcpClientEnabledResult, fidl::Error>>
570        + Send;
571    fn r#set_dhcp_client_enabled(
572        &self,
573        id: u64,
574        enable: bool,
575    ) -> Self::SetDhcpClientEnabledResponseFut;
576    fn r#bridge_interfaces(
577        &self,
578        interfaces: &[u64],
579        bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
580    ) -> Result<(), fidl::Error>;
581}
582#[derive(Debug)]
583#[cfg(target_os = "fuchsia")]
584pub struct StackSynchronousProxy {
585    client: fidl::client::sync::Client,
586}
587
588#[cfg(target_os = "fuchsia")]
589impl fidl::endpoints::SynchronousProxy for StackSynchronousProxy {
590    type Proxy = StackProxy;
591    type Protocol = StackMarker;
592
593    fn from_channel(inner: fidl::Channel) -> Self {
594        Self::new(inner)
595    }
596
597    fn into_channel(self) -> fidl::Channel {
598        self.client.into_channel()
599    }
600
601    fn as_channel(&self) -> &fidl::Channel {
602        self.client.as_channel()
603    }
604}
605
606#[cfg(target_os = "fuchsia")]
607impl StackSynchronousProxy {
608    pub fn new(channel: fidl::Channel) -> Self {
609        let protocol_name = <StackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
610        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
611    }
612
613    pub fn into_channel(self) -> fidl::Channel {
614        self.client.into_channel()
615    }
616
617    /// Waits until an event arrives and returns it. It is safe for other
618    /// threads to make concurrent requests while waiting for an event.
619    pub fn wait_for_event(
620        &self,
621        deadline: zx::MonotonicInstant,
622    ) -> Result<StackEvent, fidl::Error> {
623        StackEvent::decode(self.client.wait_for_event(deadline)?)
624    }
625
626    /// Add a new entry to the forwarding table.
627    ///
628    /// If the table already contains an entry with the same subnet and
629    /// destination, an already exists error is returned.
630    pub fn r#add_forwarding_entry(
631        &self,
632        mut entry: &ForwardingEntry,
633        ___deadline: zx::MonotonicInstant,
634    ) -> Result<StackAddForwardingEntryResult, fidl::Error> {
635        let _response = self.client.send_query::<
636            StackAddForwardingEntryRequest,
637            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
638        >(
639            (entry,),
640            0x5fe2020877107909,
641            fidl::encoding::DynamicFlags::empty(),
642            ___deadline,
643        )?;
644        Ok(_response.map(|x| x))
645    }
646
647    /// Removes the forwarding entry. The entry must exactly match an entry in
648    /// the forwarding table, with the exception of the metric value, which is
649    /// ignored.
650    pub fn r#del_forwarding_entry(
651        &self,
652        mut entry: &ForwardingEntry,
653        ___deadline: zx::MonotonicInstant,
654    ) -> Result<StackDelForwardingEntryResult, fidl::Error> {
655        let _response = self.client.send_query::<
656            StackDelForwardingEntryRequest,
657            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
658        >(
659            (entry,),
660            0x560f3944c4cb51bd,
661            fidl::encoding::DynamicFlags::empty(),
662            ___deadline,
663        )?;
664        Ok(_response.map(|x| x))
665    }
666
667    /// Enables or disables the DHCP client on an interface.
668    /// TODO(https://fxbug.dev/42162065): Remove this once the DHCP client is moved
669    /// out of the netstack.
670    pub fn r#set_dhcp_client_enabled(
671        &self,
672        mut id: u64,
673        mut enable: bool,
674        ___deadline: zx::MonotonicInstant,
675    ) -> Result<StackSetDhcpClientEnabledResult, fidl::Error> {
676        let _response = self.client.send_query::<
677            StackSetDhcpClientEnabledRequest,
678            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
679        >(
680            (id, enable,),
681            0x6dead3a6025b0543,
682            fidl::encoding::DynamicFlags::empty(),
683            ___deadline,
684        )?;
685        Ok(_response.map(|x| x))
686    }
687
688    /// Creates a bridge over the provided `interfaces`.
689    ///
690    /// If the bridge can't be created, `bridge` is closed with a `BAD_PORT`
691    /// termination reason.
692    ///
693    /// NOTE: We're shoehorning bridging into the `admin/Control` API and
694    /// reassigning meaning to `BAD_PORT` because we don't want to leak
695    /// bridging-specific errors there. The POR is that bridging is going to get
696    /// its own API at some point.
697    ///
698    /// Bridge lifetime is controlled through the `bridge` handle.
699    pub fn r#bridge_interfaces(
700        &self,
701        mut interfaces: &[u64],
702        mut bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
703    ) -> Result<(), fidl::Error> {
704        self.client.send::<StackBridgeInterfacesRequest>(
705            (interfaces, bridge),
706            0x60509044a41ac976,
707            fidl::encoding::DynamicFlags::empty(),
708        )
709    }
710}
711
712#[derive(Debug, Clone)]
713pub struct StackProxy {
714    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
715}
716
717impl fidl::endpoints::Proxy for StackProxy {
718    type Protocol = StackMarker;
719
720    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
721        Self::new(inner)
722    }
723
724    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
725        self.client.into_channel().map_err(|client| Self { client })
726    }
727
728    fn as_channel(&self) -> &::fidl::AsyncChannel {
729        self.client.as_channel()
730    }
731}
732
733impl StackProxy {
734    /// Create a new Proxy for fuchsia.net.stack/Stack.
735    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
736        let protocol_name = <StackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
737        Self { client: fidl::client::Client::new(channel, protocol_name) }
738    }
739
740    /// Get a Stream of events from the remote end of the protocol.
741    ///
742    /// # Panics
743    ///
744    /// Panics if the event stream was already taken.
745    pub fn take_event_stream(&self) -> StackEventStream {
746        StackEventStream { event_receiver: self.client.take_event_receiver() }
747    }
748
749    /// Add a new entry to the forwarding table.
750    ///
751    /// If the table already contains an entry with the same subnet and
752    /// destination, an already exists error is returned.
753    pub fn r#add_forwarding_entry(
754        &self,
755        mut entry: &ForwardingEntry,
756    ) -> fidl::client::QueryResponseFut<
757        StackAddForwardingEntryResult,
758        fidl::encoding::DefaultFuchsiaResourceDialect,
759    > {
760        StackProxyInterface::r#add_forwarding_entry(self, entry)
761    }
762
763    /// Removes the forwarding entry. The entry must exactly match an entry in
764    /// the forwarding table, with the exception of the metric value, which is
765    /// ignored.
766    pub fn r#del_forwarding_entry(
767        &self,
768        mut entry: &ForwardingEntry,
769    ) -> fidl::client::QueryResponseFut<
770        StackDelForwardingEntryResult,
771        fidl::encoding::DefaultFuchsiaResourceDialect,
772    > {
773        StackProxyInterface::r#del_forwarding_entry(self, entry)
774    }
775
776    /// Enables or disables the DHCP client on an interface.
777    /// TODO(https://fxbug.dev/42162065): Remove this once the DHCP client is moved
778    /// out of the netstack.
779    pub fn r#set_dhcp_client_enabled(
780        &self,
781        mut id: u64,
782        mut enable: bool,
783    ) -> fidl::client::QueryResponseFut<
784        StackSetDhcpClientEnabledResult,
785        fidl::encoding::DefaultFuchsiaResourceDialect,
786    > {
787        StackProxyInterface::r#set_dhcp_client_enabled(self, id, enable)
788    }
789
790    /// Creates a bridge over the provided `interfaces`.
791    ///
792    /// If the bridge can't be created, `bridge` is closed with a `BAD_PORT`
793    /// termination reason.
794    ///
795    /// NOTE: We're shoehorning bridging into the `admin/Control` API and
796    /// reassigning meaning to `BAD_PORT` because we don't want to leak
797    /// bridging-specific errors there. The POR is that bridging is going to get
798    /// its own API at some point.
799    ///
800    /// Bridge lifetime is controlled through the `bridge` handle.
801    pub fn r#bridge_interfaces(
802        &self,
803        mut interfaces: &[u64],
804        mut bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
805    ) -> Result<(), fidl::Error> {
806        StackProxyInterface::r#bridge_interfaces(self, interfaces, bridge)
807    }
808}
809
810impl StackProxyInterface for StackProxy {
811    type AddForwardingEntryResponseFut = fidl::client::QueryResponseFut<
812        StackAddForwardingEntryResult,
813        fidl::encoding::DefaultFuchsiaResourceDialect,
814    >;
815    fn r#add_forwarding_entry(
816        &self,
817        mut entry: &ForwardingEntry,
818    ) -> Self::AddForwardingEntryResponseFut {
819        fn _decode(
820            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
821        ) -> Result<StackAddForwardingEntryResult, fidl::Error> {
822            let _response = fidl::client::decode_transaction_body::<
823                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
824                fidl::encoding::DefaultFuchsiaResourceDialect,
825                0x5fe2020877107909,
826            >(_buf?)?;
827            Ok(_response.map(|x| x))
828        }
829        self.client
830            .send_query_and_decode::<StackAddForwardingEntryRequest, StackAddForwardingEntryResult>(
831                (entry,),
832                0x5fe2020877107909,
833                fidl::encoding::DynamicFlags::empty(),
834                _decode,
835            )
836    }
837
838    type DelForwardingEntryResponseFut = fidl::client::QueryResponseFut<
839        StackDelForwardingEntryResult,
840        fidl::encoding::DefaultFuchsiaResourceDialect,
841    >;
842    fn r#del_forwarding_entry(
843        &self,
844        mut entry: &ForwardingEntry,
845    ) -> Self::DelForwardingEntryResponseFut {
846        fn _decode(
847            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
848        ) -> Result<StackDelForwardingEntryResult, fidl::Error> {
849            let _response = fidl::client::decode_transaction_body::<
850                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
851                fidl::encoding::DefaultFuchsiaResourceDialect,
852                0x560f3944c4cb51bd,
853            >(_buf?)?;
854            Ok(_response.map(|x| x))
855        }
856        self.client
857            .send_query_and_decode::<StackDelForwardingEntryRequest, StackDelForwardingEntryResult>(
858                (entry,),
859                0x560f3944c4cb51bd,
860                fidl::encoding::DynamicFlags::empty(),
861                _decode,
862            )
863    }
864
865    type SetDhcpClientEnabledResponseFut = fidl::client::QueryResponseFut<
866        StackSetDhcpClientEnabledResult,
867        fidl::encoding::DefaultFuchsiaResourceDialect,
868    >;
869    fn r#set_dhcp_client_enabled(
870        &self,
871        mut id: u64,
872        mut enable: bool,
873    ) -> Self::SetDhcpClientEnabledResponseFut {
874        fn _decode(
875            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
876        ) -> Result<StackSetDhcpClientEnabledResult, fidl::Error> {
877            let _response = fidl::client::decode_transaction_body::<
878                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
879                fidl::encoding::DefaultFuchsiaResourceDialect,
880                0x6dead3a6025b0543,
881            >(_buf?)?;
882            Ok(_response.map(|x| x))
883        }
884        self.client.send_query_and_decode::<
885            StackSetDhcpClientEnabledRequest,
886            StackSetDhcpClientEnabledResult,
887        >(
888            (id, enable,),
889            0x6dead3a6025b0543,
890            fidl::encoding::DynamicFlags::empty(),
891            _decode,
892        )
893    }
894
895    fn r#bridge_interfaces(
896        &self,
897        mut interfaces: &[u64],
898        mut bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
899    ) -> Result<(), fidl::Error> {
900        self.client.send::<StackBridgeInterfacesRequest>(
901            (interfaces, bridge),
902            0x60509044a41ac976,
903            fidl::encoding::DynamicFlags::empty(),
904        )
905    }
906}
907
908pub struct StackEventStream {
909    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
910}
911
912impl std::marker::Unpin for StackEventStream {}
913
914impl futures::stream::FusedStream for StackEventStream {
915    fn is_terminated(&self) -> bool {
916        self.event_receiver.is_terminated()
917    }
918}
919
920impl futures::Stream for StackEventStream {
921    type Item = Result<StackEvent, fidl::Error>;
922
923    fn poll_next(
924        mut self: std::pin::Pin<&mut Self>,
925        cx: &mut std::task::Context<'_>,
926    ) -> std::task::Poll<Option<Self::Item>> {
927        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
928            &mut self.event_receiver,
929            cx
930        )?) {
931            Some(buf) => std::task::Poll::Ready(Some(StackEvent::decode(buf))),
932            None => std::task::Poll::Ready(None),
933        }
934    }
935}
936
937#[derive(Debug)]
938pub enum StackEvent {}
939
940impl StackEvent {
941    /// Decodes a message buffer as a [`StackEvent`].
942    fn decode(
943        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
944    ) -> Result<StackEvent, fidl::Error> {
945        let (bytes, _handles) = buf.split_mut();
946        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
947        debug_assert_eq!(tx_header.tx_id, 0);
948        match tx_header.ordinal {
949            _ => Err(fidl::Error::UnknownOrdinal {
950                ordinal: tx_header.ordinal,
951                protocol_name: <StackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
952            }),
953        }
954    }
955}
956
957/// A Stream of incoming requests for fuchsia.net.stack/Stack.
958pub struct StackRequestStream {
959    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
960    is_terminated: bool,
961}
962
963impl std::marker::Unpin for StackRequestStream {}
964
965impl futures::stream::FusedStream for StackRequestStream {
966    fn is_terminated(&self) -> bool {
967        self.is_terminated
968    }
969}
970
971impl fidl::endpoints::RequestStream for StackRequestStream {
972    type Protocol = StackMarker;
973    type ControlHandle = StackControlHandle;
974
975    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
976        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
977    }
978
979    fn control_handle(&self) -> Self::ControlHandle {
980        StackControlHandle { inner: self.inner.clone() }
981    }
982
983    fn into_inner(
984        self,
985    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
986    {
987        (self.inner, self.is_terminated)
988    }
989
990    fn from_inner(
991        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
992        is_terminated: bool,
993    ) -> Self {
994        Self { inner, is_terminated }
995    }
996}
997
998impl futures::Stream for StackRequestStream {
999    type Item = Result<StackRequest, fidl::Error>;
1000
1001    fn poll_next(
1002        mut self: std::pin::Pin<&mut Self>,
1003        cx: &mut std::task::Context<'_>,
1004    ) -> std::task::Poll<Option<Self::Item>> {
1005        let this = &mut *self;
1006        if this.inner.check_shutdown(cx) {
1007            this.is_terminated = true;
1008            return std::task::Poll::Ready(None);
1009        }
1010        if this.is_terminated {
1011            panic!("polled StackRequestStream after completion");
1012        }
1013        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1014            |bytes, handles| {
1015                match this.inner.channel().read_etc(cx, bytes, handles) {
1016                    std::task::Poll::Ready(Ok(())) => {}
1017                    std::task::Poll::Pending => return std::task::Poll::Pending,
1018                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1019                        this.is_terminated = true;
1020                        return std::task::Poll::Ready(None);
1021                    }
1022                    std::task::Poll::Ready(Err(e)) => {
1023                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1024                            e.into(),
1025                        ))))
1026                    }
1027                }
1028
1029                // A message has been received from the channel
1030                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1031
1032                std::task::Poll::Ready(Some(match header.ordinal {
1033                    0x5fe2020877107909 => {
1034                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1035                        let mut req = fidl::new_empty!(
1036                            StackAddForwardingEntryRequest,
1037                            fidl::encoding::DefaultFuchsiaResourceDialect
1038                        );
1039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StackAddForwardingEntryRequest>(&header, _body_bytes, handles, &mut req)?;
1040                        let control_handle = StackControlHandle { inner: this.inner.clone() };
1041                        Ok(StackRequest::AddForwardingEntry {
1042                            entry: req.entry,
1043
1044                            responder: StackAddForwardingEntryResponder {
1045                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1046                                tx_id: header.tx_id,
1047                            },
1048                        })
1049                    }
1050                    0x560f3944c4cb51bd => {
1051                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1052                        let mut req = fidl::new_empty!(
1053                            StackDelForwardingEntryRequest,
1054                            fidl::encoding::DefaultFuchsiaResourceDialect
1055                        );
1056                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StackDelForwardingEntryRequest>(&header, _body_bytes, handles, &mut req)?;
1057                        let control_handle = StackControlHandle { inner: this.inner.clone() };
1058                        Ok(StackRequest::DelForwardingEntry {
1059                            entry: req.entry,
1060
1061                            responder: StackDelForwardingEntryResponder {
1062                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1063                                tx_id: header.tx_id,
1064                            },
1065                        })
1066                    }
1067                    0x6dead3a6025b0543 => {
1068                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1069                        let mut req = fidl::new_empty!(
1070                            StackSetDhcpClientEnabledRequest,
1071                            fidl::encoding::DefaultFuchsiaResourceDialect
1072                        );
1073                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StackSetDhcpClientEnabledRequest>(&header, _body_bytes, handles, &mut req)?;
1074                        let control_handle = StackControlHandle { inner: this.inner.clone() };
1075                        Ok(StackRequest::SetDhcpClientEnabled {
1076                            id: req.id,
1077                            enable: req.enable,
1078
1079                            responder: StackSetDhcpClientEnabledResponder {
1080                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1081                                tx_id: header.tx_id,
1082                            },
1083                        })
1084                    }
1085                    0x60509044a41ac976 => {
1086                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1087                        let mut req = fidl::new_empty!(
1088                            StackBridgeInterfacesRequest,
1089                            fidl::encoding::DefaultFuchsiaResourceDialect
1090                        );
1091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StackBridgeInterfacesRequest>(&header, _body_bytes, handles, &mut req)?;
1092                        let control_handle = StackControlHandle { inner: this.inner.clone() };
1093                        Ok(StackRequest::BridgeInterfaces {
1094                            interfaces: req.interfaces,
1095                            bridge: req.bridge,
1096
1097                            control_handle,
1098                        })
1099                    }
1100                    _ => Err(fidl::Error::UnknownOrdinal {
1101                        ordinal: header.ordinal,
1102                        protocol_name: <StackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1103                    }),
1104                }))
1105            },
1106        )
1107    }
1108}
1109
1110#[derive(Debug)]
1111pub enum StackRequest {
1112    /// Add a new entry to the forwarding table.
1113    ///
1114    /// If the table already contains an entry with the same subnet and
1115    /// destination, an already exists error is returned.
1116    AddForwardingEntry { entry: ForwardingEntry, responder: StackAddForwardingEntryResponder },
1117    /// Removes the forwarding entry. The entry must exactly match an entry in
1118    /// the forwarding table, with the exception of the metric value, which is
1119    /// ignored.
1120    DelForwardingEntry { entry: ForwardingEntry, responder: StackDelForwardingEntryResponder },
1121    /// Enables or disables the DHCP client on an interface.
1122    /// TODO(https://fxbug.dev/42162065): Remove this once the DHCP client is moved
1123    /// out of the netstack.
1124    SetDhcpClientEnabled { id: u64, enable: bool, responder: StackSetDhcpClientEnabledResponder },
1125    /// Creates a bridge over the provided `interfaces`.
1126    ///
1127    /// If the bridge can't be created, `bridge` is closed with a `BAD_PORT`
1128    /// termination reason.
1129    ///
1130    /// NOTE: We're shoehorning bridging into the `admin/Control` API and
1131    /// reassigning meaning to `BAD_PORT` because we don't want to leak
1132    /// bridging-specific errors there. The POR is that bridging is going to get
1133    /// its own API at some point.
1134    ///
1135    /// Bridge lifetime is controlled through the `bridge` handle.
1136    BridgeInterfaces {
1137        interfaces: Vec<u64>,
1138        bridge: fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
1139        control_handle: StackControlHandle,
1140    },
1141}
1142
1143impl StackRequest {
1144    #[allow(irrefutable_let_patterns)]
1145    pub fn into_add_forwarding_entry(
1146        self,
1147    ) -> Option<(ForwardingEntry, StackAddForwardingEntryResponder)> {
1148        if let StackRequest::AddForwardingEntry { entry, responder } = self {
1149            Some((entry, responder))
1150        } else {
1151            None
1152        }
1153    }
1154
1155    #[allow(irrefutable_let_patterns)]
1156    pub fn into_del_forwarding_entry(
1157        self,
1158    ) -> Option<(ForwardingEntry, StackDelForwardingEntryResponder)> {
1159        if let StackRequest::DelForwardingEntry { entry, responder } = self {
1160            Some((entry, responder))
1161        } else {
1162            None
1163        }
1164    }
1165
1166    #[allow(irrefutable_let_patterns)]
1167    pub fn into_set_dhcp_client_enabled(
1168        self,
1169    ) -> Option<(u64, bool, StackSetDhcpClientEnabledResponder)> {
1170        if let StackRequest::SetDhcpClientEnabled { id, enable, responder } = self {
1171            Some((id, enable, responder))
1172        } else {
1173            None
1174        }
1175    }
1176
1177    #[allow(irrefutable_let_patterns)]
1178    pub fn into_bridge_interfaces(
1179        self,
1180    ) -> Option<(
1181        Vec<u64>,
1182        fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
1183        StackControlHandle,
1184    )> {
1185        if let StackRequest::BridgeInterfaces { interfaces, bridge, control_handle } = self {
1186            Some((interfaces, bridge, control_handle))
1187        } else {
1188            None
1189        }
1190    }
1191
1192    /// Name of the method defined in FIDL
1193    pub fn method_name(&self) -> &'static str {
1194        match *self {
1195            StackRequest::AddForwardingEntry { .. } => "add_forwarding_entry",
1196            StackRequest::DelForwardingEntry { .. } => "del_forwarding_entry",
1197            StackRequest::SetDhcpClientEnabled { .. } => "set_dhcp_client_enabled",
1198            StackRequest::BridgeInterfaces { .. } => "bridge_interfaces",
1199        }
1200    }
1201}
1202
1203#[derive(Debug, Clone)]
1204pub struct StackControlHandle {
1205    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1206}
1207
1208impl fidl::endpoints::ControlHandle for StackControlHandle {
1209    fn shutdown(&self) {
1210        self.inner.shutdown()
1211    }
1212    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1213        self.inner.shutdown_with_epitaph(status)
1214    }
1215
1216    fn is_closed(&self) -> bool {
1217        self.inner.channel().is_closed()
1218    }
1219    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1220        self.inner.channel().on_closed()
1221    }
1222
1223    #[cfg(target_os = "fuchsia")]
1224    fn signal_peer(
1225        &self,
1226        clear_mask: zx::Signals,
1227        set_mask: zx::Signals,
1228    ) -> Result<(), zx_status::Status> {
1229        use fidl::Peered;
1230        self.inner.channel().signal_peer(clear_mask, set_mask)
1231    }
1232}
1233
1234impl StackControlHandle {}
1235
1236#[must_use = "FIDL methods require a response to be sent"]
1237#[derive(Debug)]
1238pub struct StackAddForwardingEntryResponder {
1239    control_handle: std::mem::ManuallyDrop<StackControlHandle>,
1240    tx_id: u32,
1241}
1242
1243/// Set the the channel to be shutdown (see [`StackControlHandle::shutdown`])
1244/// if the responder is dropped without sending a response, so that the client
1245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1246impl std::ops::Drop for StackAddForwardingEntryResponder {
1247    fn drop(&mut self) {
1248        self.control_handle.shutdown();
1249        // Safety: drops once, never accessed again
1250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1251    }
1252}
1253
1254impl fidl::endpoints::Responder for StackAddForwardingEntryResponder {
1255    type ControlHandle = StackControlHandle;
1256
1257    fn control_handle(&self) -> &StackControlHandle {
1258        &self.control_handle
1259    }
1260
1261    fn drop_without_shutdown(mut self) {
1262        // Safety: drops once, never accessed again due to mem::forget
1263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1264        // Prevent Drop from running (which would shut down the channel)
1265        std::mem::forget(self);
1266    }
1267}
1268
1269impl StackAddForwardingEntryResponder {
1270    /// Sends a response to the FIDL transaction.
1271    ///
1272    /// Sets the channel to shutdown if an error occurs.
1273    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1274        let _result = self.send_raw(result);
1275        if _result.is_err() {
1276            self.control_handle.shutdown();
1277        }
1278        self.drop_without_shutdown();
1279        _result
1280    }
1281
1282    /// Similar to "send" but does not shutdown the channel if an error occurs.
1283    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1284        let _result = self.send_raw(result);
1285        self.drop_without_shutdown();
1286        _result
1287    }
1288
1289    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1290        self.control_handle
1291            .inner
1292            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1293                result,
1294                self.tx_id,
1295                0x5fe2020877107909,
1296                fidl::encoding::DynamicFlags::empty(),
1297            )
1298    }
1299}
1300
1301#[must_use = "FIDL methods require a response to be sent"]
1302#[derive(Debug)]
1303pub struct StackDelForwardingEntryResponder {
1304    control_handle: std::mem::ManuallyDrop<StackControlHandle>,
1305    tx_id: u32,
1306}
1307
1308/// Set the the channel to be shutdown (see [`StackControlHandle::shutdown`])
1309/// if the responder is dropped without sending a response, so that the client
1310/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1311impl std::ops::Drop for StackDelForwardingEntryResponder {
1312    fn drop(&mut self) {
1313        self.control_handle.shutdown();
1314        // Safety: drops once, never accessed again
1315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1316    }
1317}
1318
1319impl fidl::endpoints::Responder for StackDelForwardingEntryResponder {
1320    type ControlHandle = StackControlHandle;
1321
1322    fn control_handle(&self) -> &StackControlHandle {
1323        &self.control_handle
1324    }
1325
1326    fn drop_without_shutdown(mut self) {
1327        // Safety: drops once, never accessed again due to mem::forget
1328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1329        // Prevent Drop from running (which would shut down the channel)
1330        std::mem::forget(self);
1331    }
1332}
1333
1334impl StackDelForwardingEntryResponder {
1335    /// Sends a response to the FIDL transaction.
1336    ///
1337    /// Sets the channel to shutdown if an error occurs.
1338    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1339        let _result = self.send_raw(result);
1340        if _result.is_err() {
1341            self.control_handle.shutdown();
1342        }
1343        self.drop_without_shutdown();
1344        _result
1345    }
1346
1347    /// Similar to "send" but does not shutdown the channel if an error occurs.
1348    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1349        let _result = self.send_raw(result);
1350        self.drop_without_shutdown();
1351        _result
1352    }
1353
1354    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1355        self.control_handle
1356            .inner
1357            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1358                result,
1359                self.tx_id,
1360                0x560f3944c4cb51bd,
1361                fidl::encoding::DynamicFlags::empty(),
1362            )
1363    }
1364}
1365
1366#[must_use = "FIDL methods require a response to be sent"]
1367#[derive(Debug)]
1368pub struct StackSetDhcpClientEnabledResponder {
1369    control_handle: std::mem::ManuallyDrop<StackControlHandle>,
1370    tx_id: u32,
1371}
1372
1373/// Set the the channel to be shutdown (see [`StackControlHandle::shutdown`])
1374/// if the responder is dropped without sending a response, so that the client
1375/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1376impl std::ops::Drop for StackSetDhcpClientEnabledResponder {
1377    fn drop(&mut self) {
1378        self.control_handle.shutdown();
1379        // Safety: drops once, never accessed again
1380        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1381    }
1382}
1383
1384impl fidl::endpoints::Responder for StackSetDhcpClientEnabledResponder {
1385    type ControlHandle = StackControlHandle;
1386
1387    fn control_handle(&self) -> &StackControlHandle {
1388        &self.control_handle
1389    }
1390
1391    fn drop_without_shutdown(mut self) {
1392        // Safety: drops once, never accessed again due to mem::forget
1393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1394        // Prevent Drop from running (which would shut down the channel)
1395        std::mem::forget(self);
1396    }
1397}
1398
1399impl StackSetDhcpClientEnabledResponder {
1400    /// Sends a response to the FIDL transaction.
1401    ///
1402    /// Sets the channel to shutdown if an error occurs.
1403    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1404        let _result = self.send_raw(result);
1405        if _result.is_err() {
1406            self.control_handle.shutdown();
1407        }
1408        self.drop_without_shutdown();
1409        _result
1410    }
1411
1412    /// Similar to "send" but does not shutdown the channel if an error occurs.
1413    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1414        let _result = self.send_raw(result);
1415        self.drop_without_shutdown();
1416        _result
1417    }
1418
1419    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1420        self.control_handle
1421            .inner
1422            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1423                result,
1424                self.tx_id,
1425                0x6dead3a6025b0543,
1426                fidl::encoding::DynamicFlags::empty(),
1427            )
1428    }
1429}
1430
1431mod internal {
1432    use super::*;
1433    unsafe impl fidl::encoding::TypeMarker for Error {
1434        type Owned = Self;
1435
1436        #[inline(always)]
1437        fn inline_align(_context: fidl::encoding::Context) -> usize {
1438            std::mem::align_of::<u32>()
1439        }
1440
1441        #[inline(always)]
1442        fn inline_size(_context: fidl::encoding::Context) -> usize {
1443            std::mem::size_of::<u32>()
1444        }
1445
1446        #[inline(always)]
1447        fn encode_is_copy() -> bool {
1448            true
1449        }
1450
1451        #[inline(always)]
1452        fn decode_is_copy() -> bool {
1453            false
1454        }
1455    }
1456
1457    impl fidl::encoding::ValueTypeMarker for Error {
1458        type Borrowed<'a> = Self;
1459        #[inline(always)]
1460        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1461            *value
1462        }
1463    }
1464
1465    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
1466        #[inline]
1467        unsafe fn encode(
1468            self,
1469            encoder: &mut fidl::encoding::Encoder<'_, D>,
1470            offset: usize,
1471            _depth: fidl::encoding::Depth,
1472        ) -> fidl::Result<()> {
1473            encoder.debug_check_bounds::<Self>(offset);
1474            encoder.write_num(self.into_primitive(), offset);
1475            Ok(())
1476        }
1477    }
1478
1479    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
1480        #[inline(always)]
1481        fn new_empty() -> Self {
1482            Self::Internal
1483        }
1484
1485        #[inline]
1486        unsafe fn decode(
1487            &mut self,
1488            decoder: &mut fidl::encoding::Decoder<'_, D>,
1489            offset: usize,
1490            _depth: fidl::encoding::Depth,
1491        ) -> fidl::Result<()> {
1492            decoder.debug_check_bounds::<Self>(offset);
1493            let prim = decoder.read_num::<u32>(offset);
1494
1495            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1496            Ok(())
1497        }
1498    }
1499
1500    impl fidl::encoding::ValueTypeMarker for ForwardingEntry {
1501        type Borrowed<'a> = &'a Self;
1502        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1503            value
1504        }
1505    }
1506
1507    unsafe impl fidl::encoding::TypeMarker for ForwardingEntry {
1508        type Owned = Self;
1509
1510        #[inline(always)]
1511        fn inline_align(_context: fidl::encoding::Context) -> usize {
1512            8
1513        }
1514
1515        #[inline(always)]
1516        fn inline_size(_context: fidl::encoding::Context) -> usize {
1517            56
1518        }
1519    }
1520
1521    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ForwardingEntry, D>
1522        for &ForwardingEntry
1523    {
1524        #[inline]
1525        unsafe fn encode(
1526            self,
1527            encoder: &mut fidl::encoding::Encoder<'_, D>,
1528            offset: usize,
1529            _depth: fidl::encoding::Depth,
1530        ) -> fidl::Result<()> {
1531            encoder.debug_check_bounds::<ForwardingEntry>(offset);
1532            // Delegate to tuple encoding.
1533            fidl::encoding::Encode::<ForwardingEntry, D>::encode(
1534                (
1535                    <fidl_fuchsia_net::Subnet as fidl::encoding::ValueTypeMarker>::borrow(&self.subnet),
1536                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.device_id),
1537                    <fidl::encoding::OptionalUnion<fidl_fuchsia_net::IpAddress> as fidl::encoding::ValueTypeMarker>::borrow(&self.next_hop),
1538                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.metric),
1539                ),
1540                encoder, offset, _depth
1541            )
1542        }
1543    }
1544    unsafe impl<
1545            D: fidl::encoding::ResourceDialect,
1546            T0: fidl::encoding::Encode<fidl_fuchsia_net::Subnet, D>,
1547            T1: fidl::encoding::Encode<u64, D>,
1548            T2: fidl::encoding::Encode<fidl::encoding::OptionalUnion<fidl_fuchsia_net::IpAddress>, D>,
1549            T3: fidl::encoding::Encode<u32, D>,
1550        > fidl::encoding::Encode<ForwardingEntry, D> for (T0, T1, T2, T3)
1551    {
1552        #[inline]
1553        unsafe fn encode(
1554            self,
1555            encoder: &mut fidl::encoding::Encoder<'_, D>,
1556            offset: usize,
1557            depth: fidl::encoding::Depth,
1558        ) -> fidl::Result<()> {
1559            encoder.debug_check_bounds::<ForwardingEntry>(offset);
1560            // Zero out padding regions. There's no need to apply masks
1561            // because the unmasked parts will be overwritten by fields.
1562            unsafe {
1563                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
1564                (ptr as *mut u64).write_unaligned(0);
1565            }
1566            // Write the fields.
1567            self.0.encode(encoder, offset + 0, depth)?;
1568            self.1.encode(encoder, offset + 24, depth)?;
1569            self.2.encode(encoder, offset + 32, depth)?;
1570            self.3.encode(encoder, offset + 48, depth)?;
1571            Ok(())
1572        }
1573    }
1574
1575    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ForwardingEntry {
1576        #[inline(always)]
1577        fn new_empty() -> Self {
1578            Self {
1579                subnet: fidl::new_empty!(fidl_fuchsia_net::Subnet, D),
1580                device_id: fidl::new_empty!(u64, D),
1581                next_hop: fidl::new_empty!(
1582                    fidl::encoding::OptionalUnion<fidl_fuchsia_net::IpAddress>,
1583                    D
1584                ),
1585                metric: fidl::new_empty!(u32, D),
1586            }
1587        }
1588
1589        #[inline]
1590        unsafe fn decode(
1591            &mut self,
1592            decoder: &mut fidl::encoding::Decoder<'_, D>,
1593            offset: usize,
1594            _depth: fidl::encoding::Depth,
1595        ) -> fidl::Result<()> {
1596            decoder.debug_check_bounds::<Self>(offset);
1597            // Verify that padding bytes are zero.
1598            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
1599            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1600            let mask = 0xffffffff00000000u64;
1601            let maskedval = padval & mask;
1602            if maskedval != 0 {
1603                return Err(fidl::Error::NonZeroPadding {
1604                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
1605                });
1606            }
1607            fidl::decode!(
1608                fidl_fuchsia_net::Subnet,
1609                D,
1610                &mut self.subnet,
1611                decoder,
1612                offset + 0,
1613                _depth
1614            )?;
1615            fidl::decode!(u64, D, &mut self.device_id, decoder, offset + 24, _depth)?;
1616            fidl::decode!(
1617                fidl::encoding::OptionalUnion<fidl_fuchsia_net::IpAddress>,
1618                D,
1619                &mut self.next_hop,
1620                decoder,
1621                offset + 32,
1622                _depth
1623            )?;
1624            fidl::decode!(u32, D, &mut self.metric, decoder, offset + 48, _depth)?;
1625            Ok(())
1626        }
1627    }
1628
1629    impl fidl::encoding::ValueTypeMarker for LogSetLogPacketsRequest {
1630        type Borrowed<'a> = &'a Self;
1631        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1632            value
1633        }
1634    }
1635
1636    unsafe impl fidl::encoding::TypeMarker for LogSetLogPacketsRequest {
1637        type Owned = Self;
1638
1639        #[inline(always)]
1640        fn inline_align(_context: fidl::encoding::Context) -> usize {
1641            1
1642        }
1643
1644        #[inline(always)]
1645        fn inline_size(_context: fidl::encoding::Context) -> usize {
1646            1
1647        }
1648    }
1649
1650    unsafe impl<D: fidl::encoding::ResourceDialect>
1651        fidl::encoding::Encode<LogSetLogPacketsRequest, D> for &LogSetLogPacketsRequest
1652    {
1653        #[inline]
1654        unsafe fn encode(
1655            self,
1656            encoder: &mut fidl::encoding::Encoder<'_, D>,
1657            offset: usize,
1658            _depth: fidl::encoding::Depth,
1659        ) -> fidl::Result<()> {
1660            encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
1661            // Delegate to tuple encoding.
1662            fidl::encoding::Encode::<LogSetLogPacketsRequest, D>::encode(
1663                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
1664                encoder,
1665                offset,
1666                _depth,
1667            )
1668        }
1669    }
1670    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
1671        fidl::encoding::Encode<LogSetLogPacketsRequest, D> for (T0,)
1672    {
1673        #[inline]
1674        unsafe fn encode(
1675            self,
1676            encoder: &mut fidl::encoding::Encoder<'_, D>,
1677            offset: usize,
1678            depth: fidl::encoding::Depth,
1679        ) -> fidl::Result<()> {
1680            encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
1681            // Zero out padding regions. There's no need to apply masks
1682            // because the unmasked parts will be overwritten by fields.
1683            // Write the fields.
1684            self.0.encode(encoder, offset + 0, depth)?;
1685            Ok(())
1686        }
1687    }
1688
1689    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1690        for LogSetLogPacketsRequest
1691    {
1692        #[inline(always)]
1693        fn new_empty() -> Self {
1694            Self { enabled: fidl::new_empty!(bool, D) }
1695        }
1696
1697        #[inline]
1698        unsafe fn decode(
1699            &mut self,
1700            decoder: &mut fidl::encoding::Decoder<'_, D>,
1701            offset: usize,
1702            _depth: fidl::encoding::Depth,
1703        ) -> fidl::Result<()> {
1704            decoder.debug_check_bounds::<Self>(offset);
1705            // Verify that padding bytes are zero.
1706            fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
1707            Ok(())
1708        }
1709    }
1710
1711    impl fidl::encoding::ValueTypeMarker for StackAddForwardingEntryRequest {
1712        type Borrowed<'a> = &'a Self;
1713        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1714            value
1715        }
1716    }
1717
1718    unsafe impl fidl::encoding::TypeMarker for StackAddForwardingEntryRequest {
1719        type Owned = Self;
1720
1721        #[inline(always)]
1722        fn inline_align(_context: fidl::encoding::Context) -> usize {
1723            8
1724        }
1725
1726        #[inline(always)]
1727        fn inline_size(_context: fidl::encoding::Context) -> usize {
1728            56
1729        }
1730    }
1731
1732    unsafe impl<D: fidl::encoding::ResourceDialect>
1733        fidl::encoding::Encode<StackAddForwardingEntryRequest, D>
1734        for &StackAddForwardingEntryRequest
1735    {
1736        #[inline]
1737        unsafe fn encode(
1738            self,
1739            encoder: &mut fidl::encoding::Encoder<'_, D>,
1740            offset: usize,
1741            _depth: fidl::encoding::Depth,
1742        ) -> fidl::Result<()> {
1743            encoder.debug_check_bounds::<StackAddForwardingEntryRequest>(offset);
1744            // Delegate to tuple encoding.
1745            fidl::encoding::Encode::<StackAddForwardingEntryRequest, D>::encode(
1746                (<ForwardingEntry as fidl::encoding::ValueTypeMarker>::borrow(&self.entry),),
1747                encoder,
1748                offset,
1749                _depth,
1750            )
1751        }
1752    }
1753    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ForwardingEntry, D>>
1754        fidl::encoding::Encode<StackAddForwardingEntryRequest, D> for (T0,)
1755    {
1756        #[inline]
1757        unsafe fn encode(
1758            self,
1759            encoder: &mut fidl::encoding::Encoder<'_, D>,
1760            offset: usize,
1761            depth: fidl::encoding::Depth,
1762        ) -> fidl::Result<()> {
1763            encoder.debug_check_bounds::<StackAddForwardingEntryRequest>(offset);
1764            // Zero out padding regions. There's no need to apply masks
1765            // because the unmasked parts will be overwritten by fields.
1766            // Write the fields.
1767            self.0.encode(encoder, offset + 0, depth)?;
1768            Ok(())
1769        }
1770    }
1771
1772    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1773        for StackAddForwardingEntryRequest
1774    {
1775        #[inline(always)]
1776        fn new_empty() -> Self {
1777            Self { entry: fidl::new_empty!(ForwardingEntry, D) }
1778        }
1779
1780        #[inline]
1781        unsafe fn decode(
1782            &mut self,
1783            decoder: &mut fidl::encoding::Decoder<'_, D>,
1784            offset: usize,
1785            _depth: fidl::encoding::Depth,
1786        ) -> fidl::Result<()> {
1787            decoder.debug_check_bounds::<Self>(offset);
1788            // Verify that padding bytes are zero.
1789            fidl::decode!(ForwardingEntry, D, &mut self.entry, decoder, offset + 0, _depth)?;
1790            Ok(())
1791        }
1792    }
1793
1794    impl fidl::encoding::ResourceTypeMarker for StackBridgeInterfacesRequest {
1795        type Borrowed<'a> = &'a mut Self;
1796        fn take_or_borrow<'a>(
1797            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1798        ) -> Self::Borrowed<'a> {
1799            value
1800        }
1801    }
1802
1803    unsafe impl fidl::encoding::TypeMarker for StackBridgeInterfacesRequest {
1804        type Owned = Self;
1805
1806        #[inline(always)]
1807        fn inline_align(_context: fidl::encoding::Context) -> usize {
1808            8
1809        }
1810
1811        #[inline(always)]
1812        fn inline_size(_context: fidl::encoding::Context) -> usize {
1813            24
1814        }
1815    }
1816
1817    unsafe impl
1818        fidl::encoding::Encode<
1819            StackBridgeInterfacesRequest,
1820            fidl::encoding::DefaultFuchsiaResourceDialect,
1821        > for &mut StackBridgeInterfacesRequest
1822    {
1823        #[inline]
1824        unsafe fn encode(
1825            self,
1826            encoder: &mut fidl::encoding::Encoder<
1827                '_,
1828                fidl::encoding::DefaultFuchsiaResourceDialect,
1829            >,
1830            offset: usize,
1831            _depth: fidl::encoding::Depth,
1832        ) -> fidl::Result<()> {
1833            encoder.debug_check_bounds::<StackBridgeInterfacesRequest>(offset);
1834            // Delegate to tuple encoding.
1835            fidl::encoding::Encode::<StackBridgeInterfacesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1836                (
1837                    <fidl::encoding::UnboundedVector<u64> as fidl::encoding::ValueTypeMarker>::borrow(&self.interfaces),
1838                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.bridge),
1839                ),
1840                encoder, offset, _depth
1841            )
1842        }
1843    }
1844    unsafe impl<
1845            T0: fidl::encoding::Encode<
1846                fidl::encoding::UnboundedVector<u64>,
1847                fidl::encoding::DefaultFuchsiaResourceDialect,
1848            >,
1849            T1: fidl::encoding::Encode<
1850                fidl::encoding::Endpoint<
1851                    fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
1852                >,
1853                fidl::encoding::DefaultFuchsiaResourceDialect,
1854            >,
1855        >
1856        fidl::encoding::Encode<
1857            StackBridgeInterfacesRequest,
1858            fidl::encoding::DefaultFuchsiaResourceDialect,
1859        > for (T0, T1)
1860    {
1861        #[inline]
1862        unsafe fn encode(
1863            self,
1864            encoder: &mut fidl::encoding::Encoder<
1865                '_,
1866                fidl::encoding::DefaultFuchsiaResourceDialect,
1867            >,
1868            offset: usize,
1869            depth: fidl::encoding::Depth,
1870        ) -> fidl::Result<()> {
1871            encoder.debug_check_bounds::<StackBridgeInterfacesRequest>(offset);
1872            // Zero out padding regions. There's no need to apply masks
1873            // because the unmasked parts will be overwritten by fields.
1874            unsafe {
1875                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1876                (ptr as *mut u64).write_unaligned(0);
1877            }
1878            // Write the fields.
1879            self.0.encode(encoder, offset + 0, depth)?;
1880            self.1.encode(encoder, offset + 16, depth)?;
1881            Ok(())
1882        }
1883    }
1884
1885    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1886        for StackBridgeInterfacesRequest
1887    {
1888        #[inline(always)]
1889        fn new_empty() -> Self {
1890            Self {
1891                interfaces: fidl::new_empty!(
1892                    fidl::encoding::UnboundedVector<u64>,
1893                    fidl::encoding::DefaultFuchsiaResourceDialect
1894                ),
1895                bridge: fidl::new_empty!(
1896                    fidl::encoding::Endpoint<
1897                        fidl::endpoints::ServerEnd<
1898                            fidl_fuchsia_net_interfaces_admin::ControlMarker,
1899                        >,
1900                    >,
1901                    fidl::encoding::DefaultFuchsiaResourceDialect
1902                ),
1903            }
1904        }
1905
1906        #[inline]
1907        unsafe fn decode(
1908            &mut self,
1909            decoder: &mut fidl::encoding::Decoder<
1910                '_,
1911                fidl::encoding::DefaultFuchsiaResourceDialect,
1912            >,
1913            offset: usize,
1914            _depth: fidl::encoding::Depth,
1915        ) -> fidl::Result<()> {
1916            decoder.debug_check_bounds::<Self>(offset);
1917            // Verify that padding bytes are zero.
1918            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1919            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1920            let mask = 0xffffffff00000000u64;
1921            let maskedval = padval & mask;
1922            if maskedval != 0 {
1923                return Err(fidl::Error::NonZeroPadding {
1924                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1925                });
1926            }
1927            fidl::decode!(
1928                fidl::encoding::UnboundedVector<u64>,
1929                fidl::encoding::DefaultFuchsiaResourceDialect,
1930                &mut self.interfaces,
1931                decoder,
1932                offset + 0,
1933                _depth
1934            )?;
1935            fidl::decode!(
1936                fidl::encoding::Endpoint<
1937                    fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::ControlMarker>,
1938                >,
1939                fidl::encoding::DefaultFuchsiaResourceDialect,
1940                &mut self.bridge,
1941                decoder,
1942                offset + 16,
1943                _depth
1944            )?;
1945            Ok(())
1946        }
1947    }
1948
1949    impl fidl::encoding::ValueTypeMarker for StackDelForwardingEntryRequest {
1950        type Borrowed<'a> = &'a Self;
1951        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1952            value
1953        }
1954    }
1955
1956    unsafe impl fidl::encoding::TypeMarker for StackDelForwardingEntryRequest {
1957        type Owned = Self;
1958
1959        #[inline(always)]
1960        fn inline_align(_context: fidl::encoding::Context) -> usize {
1961            8
1962        }
1963
1964        #[inline(always)]
1965        fn inline_size(_context: fidl::encoding::Context) -> usize {
1966            56
1967        }
1968    }
1969
1970    unsafe impl<D: fidl::encoding::ResourceDialect>
1971        fidl::encoding::Encode<StackDelForwardingEntryRequest, D>
1972        for &StackDelForwardingEntryRequest
1973    {
1974        #[inline]
1975        unsafe fn encode(
1976            self,
1977            encoder: &mut fidl::encoding::Encoder<'_, D>,
1978            offset: usize,
1979            _depth: fidl::encoding::Depth,
1980        ) -> fidl::Result<()> {
1981            encoder.debug_check_bounds::<StackDelForwardingEntryRequest>(offset);
1982            // Delegate to tuple encoding.
1983            fidl::encoding::Encode::<StackDelForwardingEntryRequest, D>::encode(
1984                (<ForwardingEntry as fidl::encoding::ValueTypeMarker>::borrow(&self.entry),),
1985                encoder,
1986                offset,
1987                _depth,
1988            )
1989        }
1990    }
1991    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ForwardingEntry, D>>
1992        fidl::encoding::Encode<StackDelForwardingEntryRequest, D> for (T0,)
1993    {
1994        #[inline]
1995        unsafe fn encode(
1996            self,
1997            encoder: &mut fidl::encoding::Encoder<'_, D>,
1998            offset: usize,
1999            depth: fidl::encoding::Depth,
2000        ) -> fidl::Result<()> {
2001            encoder.debug_check_bounds::<StackDelForwardingEntryRequest>(offset);
2002            // Zero out padding regions. There's no need to apply masks
2003            // because the unmasked parts will be overwritten by fields.
2004            // Write the fields.
2005            self.0.encode(encoder, offset + 0, depth)?;
2006            Ok(())
2007        }
2008    }
2009
2010    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2011        for StackDelForwardingEntryRequest
2012    {
2013        #[inline(always)]
2014        fn new_empty() -> Self {
2015            Self { entry: fidl::new_empty!(ForwardingEntry, D) }
2016        }
2017
2018        #[inline]
2019        unsafe fn decode(
2020            &mut self,
2021            decoder: &mut fidl::encoding::Decoder<'_, D>,
2022            offset: usize,
2023            _depth: fidl::encoding::Depth,
2024        ) -> fidl::Result<()> {
2025            decoder.debug_check_bounds::<Self>(offset);
2026            // Verify that padding bytes are zero.
2027            fidl::decode!(ForwardingEntry, D, &mut self.entry, decoder, offset + 0, _depth)?;
2028            Ok(())
2029        }
2030    }
2031
2032    impl fidl::encoding::ResourceTypeMarker for StackSetDhcpClientEnabledRequest {
2033        type Borrowed<'a> = &'a mut Self;
2034        fn take_or_borrow<'a>(
2035            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2036        ) -> Self::Borrowed<'a> {
2037            value
2038        }
2039    }
2040
2041    unsafe impl fidl::encoding::TypeMarker for StackSetDhcpClientEnabledRequest {
2042        type Owned = Self;
2043
2044        #[inline(always)]
2045        fn inline_align(_context: fidl::encoding::Context) -> usize {
2046            8
2047        }
2048
2049        #[inline(always)]
2050        fn inline_size(_context: fidl::encoding::Context) -> usize {
2051            16
2052        }
2053    }
2054
2055    unsafe impl
2056        fidl::encoding::Encode<
2057            StackSetDhcpClientEnabledRequest,
2058            fidl::encoding::DefaultFuchsiaResourceDialect,
2059        > for &mut StackSetDhcpClientEnabledRequest
2060    {
2061        #[inline]
2062        unsafe fn encode(
2063            self,
2064            encoder: &mut fidl::encoding::Encoder<
2065                '_,
2066                fidl::encoding::DefaultFuchsiaResourceDialect,
2067            >,
2068            offset: usize,
2069            _depth: fidl::encoding::Depth,
2070        ) -> fidl::Result<()> {
2071            encoder.debug_check_bounds::<StackSetDhcpClientEnabledRequest>(offset);
2072            // Delegate to tuple encoding.
2073            fidl::encoding::Encode::<
2074                StackSetDhcpClientEnabledRequest,
2075                fidl::encoding::DefaultFuchsiaResourceDialect,
2076            >::encode(
2077                (
2078                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2079                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable),
2080                ),
2081                encoder,
2082                offset,
2083                _depth,
2084            )
2085        }
2086    }
2087    unsafe impl<
2088            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2089            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
2090        >
2091        fidl::encoding::Encode<
2092            StackSetDhcpClientEnabledRequest,
2093            fidl::encoding::DefaultFuchsiaResourceDialect,
2094        > for (T0, T1)
2095    {
2096        #[inline]
2097        unsafe fn encode(
2098            self,
2099            encoder: &mut fidl::encoding::Encoder<
2100                '_,
2101                fidl::encoding::DefaultFuchsiaResourceDialect,
2102            >,
2103            offset: usize,
2104            depth: fidl::encoding::Depth,
2105        ) -> fidl::Result<()> {
2106            encoder.debug_check_bounds::<StackSetDhcpClientEnabledRequest>(offset);
2107            // Zero out padding regions. There's no need to apply masks
2108            // because the unmasked parts will be overwritten by fields.
2109            unsafe {
2110                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2111                (ptr as *mut u64).write_unaligned(0);
2112            }
2113            // Write the fields.
2114            self.0.encode(encoder, offset + 0, depth)?;
2115            self.1.encode(encoder, offset + 8, depth)?;
2116            Ok(())
2117        }
2118    }
2119
2120    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2121        for StackSetDhcpClientEnabledRequest
2122    {
2123        #[inline(always)]
2124        fn new_empty() -> Self {
2125            Self {
2126                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2127                enable: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
2128            }
2129        }
2130
2131        #[inline]
2132        unsafe fn decode(
2133            &mut self,
2134            decoder: &mut fidl::encoding::Decoder<
2135                '_,
2136                fidl::encoding::DefaultFuchsiaResourceDialect,
2137            >,
2138            offset: usize,
2139            _depth: fidl::encoding::Depth,
2140        ) -> fidl::Result<()> {
2141            decoder.debug_check_bounds::<Self>(offset);
2142            // Verify that padding bytes are zero.
2143            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2144            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2145            let mask = 0xffffffffffffff00u64;
2146            let maskedval = padval & mask;
2147            if maskedval != 0 {
2148                return Err(fidl::Error::NonZeroPadding {
2149                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2150                });
2151            }
2152            fidl::decode!(
2153                u64,
2154                fidl::encoding::DefaultFuchsiaResourceDialect,
2155                &mut self.id,
2156                decoder,
2157                offset + 0,
2158                _depth
2159            )?;
2160            fidl::decode!(
2161                bool,
2162                fidl::encoding::DefaultFuchsiaResourceDialect,
2163                &mut self.enable,
2164                decoder,
2165                offset + 8,
2166                _depth
2167            )?;
2168            Ok(())
2169        }
2170    }
2171}