Skip to main content

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