fidl_fuchsia_net_interfaces_admin/
fidl_fuchsia_net_interfaces_admin.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_interfaces_admin__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControlAddAddressRequest {
16    pub address: fidl_fuchsia_net::Subnet,
17    pub parameters: AddressParameters,
18    pub address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControlAddAddressRequest {}
22
23#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct ControlGetAuthorizationForInterfaceResponse {
25    pub credential: GrantForInterfaceAuthorization,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
29    for ControlGetAuthorizationForInterfaceResponse
30{
31}
32
33#[derive(Debug, PartialEq)]
34pub struct DeviceControlCreateInterfaceRequest {
35    pub port: fidl_fuchsia_hardware_network::PortId,
36    pub control: fidl::endpoints::ServerEnd<ControlMarker>,
37    pub options: Options,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for DeviceControlCreateInterfaceRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct GrantForInterfaceAuthorization {
47    /// The ID of the interface this credential is authenticating.
48    pub interface_id: u64,
49    /// The EVENT providing authentication over this interface.
50    pub token: fidl::Event,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for GrantForInterfaceAuthorization
55{
56}
57
58#[derive(Debug, PartialEq)]
59pub struct InstallerInstallBlackholeInterfaceRequest {
60    pub interface: fidl::endpoints::ServerEnd<ControlMarker>,
61    pub options: Options,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for InstallerInstallBlackholeInterfaceRequest
66{
67}
68
69#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70pub struct InstallerInstallDeviceRequest {
71    pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
72    pub device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
76    for InstallerInstallDeviceRequest
77{
78}
79
80/// A credential passed into the `fuchsia.net.*` family of APIs to authenticate
81/// access to a particular interface. The Netstack only needs the ability to
82/// inspect the token's basic info when proving that the client is authorized
83/// to access a resource.
84#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub struct ProofOfInterfaceAuthorization {
86    /// The ID of the interface this credential is authenticating.
87    pub interface_id: u64,
88    /// The EVENT providing authentication over this interface.
89    pub token: fidl::Event,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
93    for ProofOfInterfaceAuthorization
94{
95}
96
97/// Options for creating an interface.
98#[derive(Debug, Default, PartialEq)]
99pub struct Options {
100    /// New interface name.
101    ///
102    /// An implementation-defined name is selected if absent.
103    pub name: Option<String>,
104    /// The default metric value used for routes through this interface.
105    ///
106    /// The server uses a sensible default if absent.
107    pub metric: Option<u32>,
108    /// The designation for the netstack-sourced routes.
109    ///
110    /// Interpreted as `NetstackManagedRoutesDesignation.main` if absent.
111    pub netstack_managed_routes_designation: Option<NetstackManagedRoutesDesignation>,
112    #[doc(hidden)]
113    pub __source_breaking: fidl::marker::SourceBreaking,
114}
115
116impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Options {}
117
118/// This can be provided on interface creation to appoint a route table into
119/// which netstack managed routes are installed.
120#[derive(Debug)]
121pub enum NetstackManagedRoutesDesignation {
122    /// The netstack managed routes are installed in the main table.
123    Main(Empty),
124    /// The netstack managed routes are installed in an interface-local table.
125    ///
126    /// The interface creates local tables (one for each IP version). When the
127    /// interface is removed and all the outstanding `RouteTableV{4,6}` protocol
128    /// channels are closed, the local table is removed.
129    InterfaceLocal(Empty),
130    #[doc(hidden)]
131    __SourceBreaking { unknown_ordinal: u64 },
132}
133
134/// Pattern that matches an unknown `NetstackManagedRoutesDesignation` member.
135#[macro_export]
136macro_rules! NetstackManagedRoutesDesignationUnknown {
137    () => {
138        _
139    };
140}
141
142// Custom PartialEq so that unknown variants are not equal to themselves.
143impl PartialEq for NetstackManagedRoutesDesignation {
144    fn eq(&self, other: &Self) -> bool {
145        match (self, other) {
146            (Self::Main(x), Self::Main(y)) => *x == *y,
147            (Self::InterfaceLocal(x), Self::InterfaceLocal(y)) => *x == *y,
148            _ => false,
149        }
150    }
151}
152
153impl NetstackManagedRoutesDesignation {
154    #[inline]
155    pub fn ordinal(&self) -> u64 {
156        match *self {
157            Self::Main(_) => 1,
158            Self::InterfaceLocal(_) => 2,
159            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
160        }
161    }
162
163    #[inline]
164    pub fn unknown_variant_for_testing() -> Self {
165        Self::__SourceBreaking { unknown_ordinal: 0 }
166    }
167
168    #[inline]
169    pub fn is_unknown(&self) -> bool {
170        match self {
171            Self::__SourceBreaking { .. } => true,
172            _ => false,
173        }
174    }
175}
176
177impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
178    for NetstackManagedRoutesDesignation
179{
180}
181
182#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
183pub struct AddressStateProviderMarker;
184
185impl fidl::endpoints::ProtocolMarker for AddressStateProviderMarker {
186    type Proxy = AddressStateProviderProxy;
187    type RequestStream = AddressStateProviderRequestStream;
188    #[cfg(target_os = "fuchsia")]
189    type SynchronousProxy = AddressStateProviderSynchronousProxy;
190
191    const DEBUG_NAME: &'static str = "(anonymous) AddressStateProvider";
192}
193
194pub trait AddressStateProviderProxyInterface: Send + Sync {
195    type UpdateAddressPropertiesResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
196        + Send;
197    fn r#update_address_properties(
198        &self,
199        address_properties: &AddressProperties,
200    ) -> Self::UpdateAddressPropertiesResponseFut;
201    type WatchAddressAssignmentStateResponseFut: std::future::Future<
202            Output = Result<fidl_fuchsia_net_interfaces::AddressAssignmentState, fidl::Error>,
203        > + Send;
204    fn r#watch_address_assignment_state(&self) -> Self::WatchAddressAssignmentStateResponseFut;
205    fn r#detach(&self) -> Result<(), fidl::Error>;
206    fn r#remove(&self) -> Result<(), fidl::Error>;
207}
208#[derive(Debug)]
209#[cfg(target_os = "fuchsia")]
210pub struct AddressStateProviderSynchronousProxy {
211    client: fidl::client::sync::Client,
212}
213
214#[cfg(target_os = "fuchsia")]
215impl fidl::endpoints::SynchronousProxy for AddressStateProviderSynchronousProxy {
216    type Proxy = AddressStateProviderProxy;
217    type Protocol = AddressStateProviderMarker;
218
219    fn from_channel(inner: fidl::Channel) -> Self {
220        Self::new(inner)
221    }
222
223    fn into_channel(self) -> fidl::Channel {
224        self.client.into_channel()
225    }
226
227    fn as_channel(&self) -> &fidl::Channel {
228        self.client.as_channel()
229    }
230}
231
232#[cfg(target_os = "fuchsia")]
233impl AddressStateProviderSynchronousProxy {
234    pub fn new(channel: fidl::Channel) -> Self {
235        let protocol_name =
236            <AddressStateProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
237        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
238    }
239
240    pub fn into_channel(self) -> fidl::Channel {
241        self.client.into_channel()
242    }
243
244    /// Waits until an event arrives and returns it. It is safe for other
245    /// threads to make concurrent requests while waiting for an event.
246    pub fn wait_for_event(
247        &self,
248        deadline: zx::MonotonicInstant,
249    ) -> Result<AddressStateProviderEvent, fidl::Error> {
250        AddressStateProviderEvent::decode(self.client.wait_for_event(deadline)?)
251    }
252
253    /// Push an update when the address properties change.
254    ///
255    /// The client pushes updates on address properties changes, such as the
256    /// address becoming deprecated, or the preferred and valid lifetimes being
257    /// updated as a result of extending the address' lifetime. The server is
258    /// expected to cache address properties.
259    ///
260    /// If `address_properties` contains invalid property values, the address is
261    /// removed and [`AddressRemovalReason.INVALID_PROPERTIES`] is issued.
262    ///
263    /// + request `address_properties` the updated properties of the address.
264    pub fn r#update_address_properties(
265        &self,
266        mut address_properties: &AddressProperties,
267        ___deadline: zx::MonotonicInstant,
268    ) -> Result<(), fidl::Error> {
269        let _response = self.client.send_query::<
270            AddressStateProviderUpdateAddressPropertiesRequest,
271            fidl::encoding::EmptyPayload,
272        >(
273            (address_properties,),
274            0x52bdf5ed96ef573c,
275            fidl::encoding::DynamicFlags::empty(),
276            ___deadline,
277        )?;
278        Ok(_response)
279    }
280
281    /// Hanging get for address assignment state.
282    ///
283    /// The server does not keep a queue of assignment states, it returns the
284    /// latest state if it differs from the last one observed.
285    ///
286    /// The first call will always immediately return the current assignment
287    /// state. Subsequent calls will block until the returned value differs
288    /// from the last observed value.
289    ///
290    /// It is invalid to call this method while a previous call is pending.
291    /// Doing so will cause the server end of the protocol to be closed.
292    ///
293    /// - response `assignment_state` the assignment state of the address.
294    pub fn r#watch_address_assignment_state(
295        &self,
296        ___deadline: zx::MonotonicInstant,
297    ) -> Result<fidl_fuchsia_net_interfaces::AddressAssignmentState, fidl::Error> {
298        let _response = self.client.send_query::<
299            fidl::encoding::EmptyPayload,
300            AddressStateProviderWatchAddressAssignmentStateResponse,
301        >(
302            (),
303            0x740bb58c1b2d3188,
304            fidl::encoding::DynamicFlags::empty(),
305            ___deadline,
306        )?;
307        Ok(_response.assignment_state)
308    }
309
310    /// Detaches the address' lifetime from the client end of the protocol.
311    ///
312    /// The client end of the protocol can be closed immediately after
313    /// calling this method, and the address will not be removed.
314    pub fn r#detach(&self) -> Result<(), fidl::Error> {
315        self.client.send::<fidl::encoding::EmptyPayload>(
316            (),
317            0xc752381d739622f,
318            fidl::encoding::DynamicFlags::empty(),
319        )
320    }
321
322    /// Removes the address.
323    ///
324    /// The server end of the protocol is closed after address removal has
325    /// completed, and the `USER_REMOVED` `OnAddressRemoved` event is sent.
326    pub fn r#remove(&self) -> Result<(), fidl::Error> {
327        self.client.send::<fidl::encoding::EmptyPayload>(
328            (),
329            0x554407fe183e78ad,
330            fidl::encoding::DynamicFlags::empty(),
331        )
332    }
333}
334
335#[cfg(target_os = "fuchsia")]
336impl From<AddressStateProviderSynchronousProxy> for zx::Handle {
337    fn from(value: AddressStateProviderSynchronousProxy) -> Self {
338        value.into_channel().into()
339    }
340}
341
342#[cfg(target_os = "fuchsia")]
343impl From<fidl::Channel> for AddressStateProviderSynchronousProxy {
344    fn from(value: fidl::Channel) -> Self {
345        Self::new(value)
346    }
347}
348
349#[derive(Debug, Clone)]
350pub struct AddressStateProviderProxy {
351    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
352}
353
354impl fidl::endpoints::Proxy for AddressStateProviderProxy {
355    type Protocol = AddressStateProviderMarker;
356
357    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
358        Self::new(inner)
359    }
360
361    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
362        self.client.into_channel().map_err(|client| Self { client })
363    }
364
365    fn as_channel(&self) -> &::fidl::AsyncChannel {
366        self.client.as_channel()
367    }
368}
369
370impl AddressStateProviderProxy {
371    /// Create a new Proxy for fuchsia.net.interfaces.admin/AddressStateProvider.
372    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
373        let protocol_name =
374            <AddressStateProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
375        Self { client: fidl::client::Client::new(channel, protocol_name) }
376    }
377
378    /// Get a Stream of events from the remote end of the protocol.
379    ///
380    /// # Panics
381    ///
382    /// Panics if the event stream was already taken.
383    pub fn take_event_stream(&self) -> AddressStateProviderEventStream {
384        AddressStateProviderEventStream { event_receiver: self.client.take_event_receiver() }
385    }
386
387    /// Push an update when the address properties change.
388    ///
389    /// The client pushes updates on address properties changes, such as the
390    /// address becoming deprecated, or the preferred and valid lifetimes being
391    /// updated as a result of extending the address' lifetime. The server is
392    /// expected to cache address properties.
393    ///
394    /// If `address_properties` contains invalid property values, the address is
395    /// removed and [`AddressRemovalReason.INVALID_PROPERTIES`] is issued.
396    ///
397    /// + request `address_properties` the updated properties of the address.
398    pub fn r#update_address_properties(
399        &self,
400        mut address_properties: &AddressProperties,
401    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
402        AddressStateProviderProxyInterface::r#update_address_properties(self, address_properties)
403    }
404
405    /// Hanging get for address assignment state.
406    ///
407    /// The server does not keep a queue of assignment states, it returns the
408    /// latest state if it differs from the last one observed.
409    ///
410    /// The first call will always immediately return the current assignment
411    /// state. Subsequent calls will block until the returned value differs
412    /// from the last observed value.
413    ///
414    /// It is invalid to call this method while a previous call is pending.
415    /// Doing so will cause the server end of the protocol to be closed.
416    ///
417    /// - response `assignment_state` the assignment state of the address.
418    pub fn r#watch_address_assignment_state(
419        &self,
420    ) -> fidl::client::QueryResponseFut<
421        fidl_fuchsia_net_interfaces::AddressAssignmentState,
422        fidl::encoding::DefaultFuchsiaResourceDialect,
423    > {
424        AddressStateProviderProxyInterface::r#watch_address_assignment_state(self)
425    }
426
427    /// Detaches the address' lifetime from the client end of the protocol.
428    ///
429    /// The client end of the protocol can be closed immediately after
430    /// calling this method, and the address will not be removed.
431    pub fn r#detach(&self) -> Result<(), fidl::Error> {
432        AddressStateProviderProxyInterface::r#detach(self)
433    }
434
435    /// Removes the address.
436    ///
437    /// The server end of the protocol is closed after address removal has
438    /// completed, and the `USER_REMOVED` `OnAddressRemoved` event is sent.
439    pub fn r#remove(&self) -> Result<(), fidl::Error> {
440        AddressStateProviderProxyInterface::r#remove(self)
441    }
442}
443
444impl AddressStateProviderProxyInterface for AddressStateProviderProxy {
445    type UpdateAddressPropertiesResponseFut =
446        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
447    fn r#update_address_properties(
448        &self,
449        mut address_properties: &AddressProperties,
450    ) -> Self::UpdateAddressPropertiesResponseFut {
451        fn _decode(
452            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
453        ) -> Result<(), fidl::Error> {
454            let _response = fidl::client::decode_transaction_body::<
455                fidl::encoding::EmptyPayload,
456                fidl::encoding::DefaultFuchsiaResourceDialect,
457                0x52bdf5ed96ef573c,
458            >(_buf?)?;
459            Ok(_response)
460        }
461        self.client.send_query_and_decode::<AddressStateProviderUpdateAddressPropertiesRequest, ()>(
462            (address_properties,),
463            0x52bdf5ed96ef573c,
464            fidl::encoding::DynamicFlags::empty(),
465            _decode,
466        )
467    }
468
469    type WatchAddressAssignmentStateResponseFut = fidl::client::QueryResponseFut<
470        fidl_fuchsia_net_interfaces::AddressAssignmentState,
471        fidl::encoding::DefaultFuchsiaResourceDialect,
472    >;
473    fn r#watch_address_assignment_state(&self) -> Self::WatchAddressAssignmentStateResponseFut {
474        fn _decode(
475            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
476        ) -> Result<fidl_fuchsia_net_interfaces::AddressAssignmentState, fidl::Error> {
477            let _response = fidl::client::decode_transaction_body::<
478                AddressStateProviderWatchAddressAssignmentStateResponse,
479                fidl::encoding::DefaultFuchsiaResourceDialect,
480                0x740bb58c1b2d3188,
481            >(_buf?)?;
482            Ok(_response.assignment_state)
483        }
484        self.client.send_query_and_decode::<
485            fidl::encoding::EmptyPayload,
486            fidl_fuchsia_net_interfaces::AddressAssignmentState,
487        >(
488            (),
489            0x740bb58c1b2d3188,
490            fidl::encoding::DynamicFlags::empty(),
491            _decode,
492        )
493    }
494
495    fn r#detach(&self) -> Result<(), fidl::Error> {
496        self.client.send::<fidl::encoding::EmptyPayload>(
497            (),
498            0xc752381d739622f,
499            fidl::encoding::DynamicFlags::empty(),
500        )
501    }
502
503    fn r#remove(&self) -> Result<(), fidl::Error> {
504        self.client.send::<fidl::encoding::EmptyPayload>(
505            (),
506            0x554407fe183e78ad,
507            fidl::encoding::DynamicFlags::empty(),
508        )
509    }
510}
511
512pub struct AddressStateProviderEventStream {
513    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
514}
515
516impl std::marker::Unpin for AddressStateProviderEventStream {}
517
518impl futures::stream::FusedStream for AddressStateProviderEventStream {
519    fn is_terminated(&self) -> bool {
520        self.event_receiver.is_terminated()
521    }
522}
523
524impl futures::Stream for AddressStateProviderEventStream {
525    type Item = Result<AddressStateProviderEvent, fidl::Error>;
526
527    fn poll_next(
528        mut self: std::pin::Pin<&mut Self>,
529        cx: &mut std::task::Context<'_>,
530    ) -> std::task::Poll<Option<Self::Item>> {
531        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
532            &mut self.event_receiver,
533            cx
534        )?) {
535            Some(buf) => std::task::Poll::Ready(Some(AddressStateProviderEvent::decode(buf))),
536            None => std::task::Poll::Ready(None),
537        }
538    }
539}
540
541#[derive(Debug)]
542pub enum AddressStateProviderEvent {
543    OnAddressAdded {},
544    OnAddressRemoved { error: AddressRemovalReason },
545}
546
547impl AddressStateProviderEvent {
548    #[allow(irrefutable_let_patterns)]
549    pub fn into_on_address_added(self) -> Option<()> {
550        if let AddressStateProviderEvent::OnAddressAdded {} = self {
551            Some(())
552        } else {
553            None
554        }
555    }
556    #[allow(irrefutable_let_patterns)]
557    pub fn into_on_address_removed(self) -> Option<AddressRemovalReason> {
558        if let AddressStateProviderEvent::OnAddressRemoved { error } = self {
559            Some((error))
560        } else {
561            None
562        }
563    }
564
565    /// Decodes a message buffer as a [`AddressStateProviderEvent`].
566    fn decode(
567        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
568    ) -> Result<AddressStateProviderEvent, fidl::Error> {
569        let (bytes, _handles) = buf.split_mut();
570        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
571        debug_assert_eq!(tx_header.tx_id, 0);
572        match tx_header.ordinal {
573            0x624f6ea62cce189e => {
574                let mut out = fidl::new_empty!(
575                    fidl::encoding::EmptyPayload,
576                    fidl::encoding::DefaultFuchsiaResourceDialect
577                );
578                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
579                Ok((AddressStateProviderEvent::OnAddressAdded {}))
580            }
581            0x2480eb672ffd5962 => {
582                let mut out = fidl::new_empty!(
583                    AddressStateProviderOnAddressRemovedRequest,
584                    fidl::encoding::DefaultFuchsiaResourceDialect
585                );
586                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AddressStateProviderOnAddressRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
587                Ok((AddressStateProviderEvent::OnAddressRemoved { error: out.error }))
588            }
589            _ => Err(fidl::Error::UnknownOrdinal {
590                ordinal: tx_header.ordinal,
591                protocol_name:
592                    <AddressStateProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
593            }),
594        }
595    }
596}
597
598/// A Stream of incoming requests for fuchsia.net.interfaces.admin/AddressStateProvider.
599pub struct AddressStateProviderRequestStream {
600    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
601    is_terminated: bool,
602}
603
604impl std::marker::Unpin for AddressStateProviderRequestStream {}
605
606impl futures::stream::FusedStream for AddressStateProviderRequestStream {
607    fn is_terminated(&self) -> bool {
608        self.is_terminated
609    }
610}
611
612impl fidl::endpoints::RequestStream for AddressStateProviderRequestStream {
613    type Protocol = AddressStateProviderMarker;
614    type ControlHandle = AddressStateProviderControlHandle;
615
616    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
617        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
618    }
619
620    fn control_handle(&self) -> Self::ControlHandle {
621        AddressStateProviderControlHandle { inner: self.inner.clone() }
622    }
623
624    fn into_inner(
625        self,
626    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
627    {
628        (self.inner, self.is_terminated)
629    }
630
631    fn from_inner(
632        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
633        is_terminated: bool,
634    ) -> Self {
635        Self { inner, is_terminated }
636    }
637}
638
639impl futures::Stream for AddressStateProviderRequestStream {
640    type Item = Result<AddressStateProviderRequest, fidl::Error>;
641
642    fn poll_next(
643        mut self: std::pin::Pin<&mut Self>,
644        cx: &mut std::task::Context<'_>,
645    ) -> std::task::Poll<Option<Self::Item>> {
646        let this = &mut *self;
647        if this.inner.check_shutdown(cx) {
648            this.is_terminated = true;
649            return std::task::Poll::Ready(None);
650        }
651        if this.is_terminated {
652            panic!("polled AddressStateProviderRequestStream after completion");
653        }
654        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
655            |bytes, handles| {
656                match this.inner.channel().read_etc(cx, bytes, handles) {
657                    std::task::Poll::Ready(Ok(())) => {}
658                    std::task::Poll::Pending => return std::task::Poll::Pending,
659                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
660                        this.is_terminated = true;
661                        return std::task::Poll::Ready(None);
662                    }
663                    std::task::Poll::Ready(Err(e)) => {
664                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
665                            e.into(),
666                        ))))
667                    }
668                }
669
670                // A message has been received from the channel
671                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
672
673                std::task::Poll::Ready(Some(match header.ordinal {
674                0x52bdf5ed96ef573c => {
675                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
676                    let mut req = fidl::new_empty!(AddressStateProviderUpdateAddressPropertiesRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
677                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AddressStateProviderUpdateAddressPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
678                    let control_handle = AddressStateProviderControlHandle {
679                        inner: this.inner.clone(),
680                    };
681                    Ok(AddressStateProviderRequest::UpdateAddressProperties {address_properties: req.address_properties,
682
683                        responder: AddressStateProviderUpdateAddressPropertiesResponder {
684                            control_handle: std::mem::ManuallyDrop::new(control_handle),
685                            tx_id: header.tx_id,
686                        },
687                    })
688                }
689                0x740bb58c1b2d3188 => {
690                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
691                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
692                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
693                    let control_handle = AddressStateProviderControlHandle {
694                        inner: this.inner.clone(),
695                    };
696                    Ok(AddressStateProviderRequest::WatchAddressAssignmentState {
697                        responder: AddressStateProviderWatchAddressAssignmentStateResponder {
698                            control_handle: std::mem::ManuallyDrop::new(control_handle),
699                            tx_id: header.tx_id,
700                        },
701                    })
702                }
703                0xc752381d739622f => {
704                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
705                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
706                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
707                    let control_handle = AddressStateProviderControlHandle {
708                        inner: this.inner.clone(),
709                    };
710                    Ok(AddressStateProviderRequest::Detach {
711                        control_handle,
712                    })
713                }
714                0x554407fe183e78ad => {
715                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
716                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
717                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
718                    let control_handle = AddressStateProviderControlHandle {
719                        inner: this.inner.clone(),
720                    };
721                    Ok(AddressStateProviderRequest::Remove {
722                        control_handle,
723                    })
724                }
725                _ => Err(fidl::Error::UnknownOrdinal {
726                    ordinal: header.ordinal,
727                    protocol_name: <AddressStateProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
728                }),
729            }))
730            },
731        )
732    }
733}
734
735/// Offers state information about an IP address.
736///
737/// This protocol encodes the underlying object's lifetime in both directions;
738/// the underlying object is alive iff both ends of the protocol are open
739/// (unless [`AddressStateProvider.Detach`] has been called). That is:
740///
741/// - Closing the client end causes the object to be destroyed.
742/// - Observing a closure of the server end indicates the object no longer
743///   exists.
744#[derive(Debug)]
745pub enum AddressStateProviderRequest {
746    /// Push an update when the address properties change.
747    ///
748    /// The client pushes updates on address properties changes, such as the
749    /// address becoming deprecated, or the preferred and valid lifetimes being
750    /// updated as a result of extending the address' lifetime. The server is
751    /// expected to cache address properties.
752    ///
753    /// If `address_properties` contains invalid property values, the address is
754    /// removed and [`AddressRemovalReason.INVALID_PROPERTIES`] is issued.
755    ///
756    /// + request `address_properties` the updated properties of the address.
757    UpdateAddressProperties {
758        address_properties: AddressProperties,
759        responder: AddressStateProviderUpdateAddressPropertiesResponder,
760    },
761    /// Hanging get for address assignment state.
762    ///
763    /// The server does not keep a queue of assignment states, it returns the
764    /// latest state if it differs from the last one observed.
765    ///
766    /// The first call will always immediately return the current assignment
767    /// state. Subsequent calls will block until the returned value differs
768    /// from the last observed value.
769    ///
770    /// It is invalid to call this method while a previous call is pending.
771    /// Doing so will cause the server end of the protocol to be closed.
772    ///
773    /// - response `assignment_state` the assignment state of the address.
774    WatchAddressAssignmentState {
775        responder: AddressStateProviderWatchAddressAssignmentStateResponder,
776    },
777    /// Detaches the address' lifetime from the client end of the protocol.
778    ///
779    /// The client end of the protocol can be closed immediately after
780    /// calling this method, and the address will not be removed.
781    Detach { control_handle: AddressStateProviderControlHandle },
782    /// Removes the address.
783    ///
784    /// The server end of the protocol is closed after address removal has
785    /// completed, and the `USER_REMOVED` `OnAddressRemoved` event is sent.
786    Remove { control_handle: AddressStateProviderControlHandle },
787}
788
789impl AddressStateProviderRequest {
790    #[allow(irrefutable_let_patterns)]
791    pub fn into_update_address_properties(
792        self,
793    ) -> Option<(AddressProperties, AddressStateProviderUpdateAddressPropertiesResponder)> {
794        if let AddressStateProviderRequest::UpdateAddressProperties {
795            address_properties,
796            responder,
797        } = self
798        {
799            Some((address_properties, responder))
800        } else {
801            None
802        }
803    }
804
805    #[allow(irrefutable_let_patterns)]
806    pub fn into_watch_address_assignment_state(
807        self,
808    ) -> Option<(AddressStateProviderWatchAddressAssignmentStateResponder)> {
809        if let AddressStateProviderRequest::WatchAddressAssignmentState { responder } = self {
810            Some((responder))
811        } else {
812            None
813        }
814    }
815
816    #[allow(irrefutable_let_patterns)]
817    pub fn into_detach(self) -> Option<(AddressStateProviderControlHandle)> {
818        if let AddressStateProviderRequest::Detach { control_handle } = self {
819            Some((control_handle))
820        } else {
821            None
822        }
823    }
824
825    #[allow(irrefutable_let_patterns)]
826    pub fn into_remove(self) -> Option<(AddressStateProviderControlHandle)> {
827        if let AddressStateProviderRequest::Remove { control_handle } = self {
828            Some((control_handle))
829        } else {
830            None
831        }
832    }
833
834    /// Name of the method defined in FIDL
835    pub fn method_name(&self) -> &'static str {
836        match *self {
837            AddressStateProviderRequest::UpdateAddressProperties { .. } => {
838                "update_address_properties"
839            }
840            AddressStateProviderRequest::WatchAddressAssignmentState { .. } => {
841                "watch_address_assignment_state"
842            }
843            AddressStateProviderRequest::Detach { .. } => "detach",
844            AddressStateProviderRequest::Remove { .. } => "remove",
845        }
846    }
847}
848
849#[derive(Debug, Clone)]
850pub struct AddressStateProviderControlHandle {
851    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
852}
853
854impl fidl::endpoints::ControlHandle for AddressStateProviderControlHandle {
855    fn shutdown(&self) {
856        self.inner.shutdown()
857    }
858    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
859        self.inner.shutdown_with_epitaph(status)
860    }
861
862    fn is_closed(&self) -> bool {
863        self.inner.channel().is_closed()
864    }
865    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
866        self.inner.channel().on_closed()
867    }
868
869    #[cfg(target_os = "fuchsia")]
870    fn signal_peer(
871        &self,
872        clear_mask: zx::Signals,
873        set_mask: zx::Signals,
874    ) -> Result<(), zx_status::Status> {
875        use fidl::Peered;
876        self.inner.channel().signal_peer(clear_mask, set_mask)
877    }
878}
879
880impl AddressStateProviderControlHandle {
881    pub fn send_on_address_added(&self) -> Result<(), fidl::Error> {
882        self.inner.send::<fidl::encoding::EmptyPayload>(
883            (),
884            0,
885            0x624f6ea62cce189e,
886            fidl::encoding::DynamicFlags::empty(),
887        )
888    }
889
890    pub fn send_on_address_removed(
891        &self,
892        mut error: AddressRemovalReason,
893    ) -> Result<(), fidl::Error> {
894        self.inner.send::<AddressStateProviderOnAddressRemovedRequest>(
895            (error,),
896            0,
897            0x2480eb672ffd5962,
898            fidl::encoding::DynamicFlags::empty(),
899        )
900    }
901}
902
903#[must_use = "FIDL methods require a response to be sent"]
904#[derive(Debug)]
905pub struct AddressStateProviderUpdateAddressPropertiesResponder {
906    control_handle: std::mem::ManuallyDrop<AddressStateProviderControlHandle>,
907    tx_id: u32,
908}
909
910/// Set the the channel to be shutdown (see [`AddressStateProviderControlHandle::shutdown`])
911/// if the responder is dropped without sending a response, so that the client
912/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
913impl std::ops::Drop for AddressStateProviderUpdateAddressPropertiesResponder {
914    fn drop(&mut self) {
915        self.control_handle.shutdown();
916        // Safety: drops once, never accessed again
917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
918    }
919}
920
921impl fidl::endpoints::Responder for AddressStateProviderUpdateAddressPropertiesResponder {
922    type ControlHandle = AddressStateProviderControlHandle;
923
924    fn control_handle(&self) -> &AddressStateProviderControlHandle {
925        &self.control_handle
926    }
927
928    fn drop_without_shutdown(mut self) {
929        // Safety: drops once, never accessed again due to mem::forget
930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
931        // Prevent Drop from running (which would shut down the channel)
932        std::mem::forget(self);
933    }
934}
935
936impl AddressStateProviderUpdateAddressPropertiesResponder {
937    /// Sends a response to the FIDL transaction.
938    ///
939    /// Sets the channel to shutdown if an error occurs.
940    pub fn send(self) -> Result<(), fidl::Error> {
941        let _result = self.send_raw();
942        if _result.is_err() {
943            self.control_handle.shutdown();
944        }
945        self.drop_without_shutdown();
946        _result
947    }
948
949    /// Similar to "send" but does not shutdown the channel if an error occurs.
950    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
951        let _result = self.send_raw();
952        self.drop_without_shutdown();
953        _result
954    }
955
956    fn send_raw(&self) -> Result<(), fidl::Error> {
957        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
958            (),
959            self.tx_id,
960            0x52bdf5ed96ef573c,
961            fidl::encoding::DynamicFlags::empty(),
962        )
963    }
964}
965
966#[must_use = "FIDL methods require a response to be sent"]
967#[derive(Debug)]
968pub struct AddressStateProviderWatchAddressAssignmentStateResponder {
969    control_handle: std::mem::ManuallyDrop<AddressStateProviderControlHandle>,
970    tx_id: u32,
971}
972
973/// Set the the channel to be shutdown (see [`AddressStateProviderControlHandle::shutdown`])
974/// if the responder is dropped without sending a response, so that the client
975/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
976impl std::ops::Drop for AddressStateProviderWatchAddressAssignmentStateResponder {
977    fn drop(&mut self) {
978        self.control_handle.shutdown();
979        // Safety: drops once, never accessed again
980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
981    }
982}
983
984impl fidl::endpoints::Responder for AddressStateProviderWatchAddressAssignmentStateResponder {
985    type ControlHandle = AddressStateProviderControlHandle;
986
987    fn control_handle(&self) -> &AddressStateProviderControlHandle {
988        &self.control_handle
989    }
990
991    fn drop_without_shutdown(mut self) {
992        // Safety: drops once, never accessed again due to mem::forget
993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
994        // Prevent Drop from running (which would shut down the channel)
995        std::mem::forget(self);
996    }
997}
998
999impl AddressStateProviderWatchAddressAssignmentStateResponder {
1000    /// Sends a response to the FIDL transaction.
1001    ///
1002    /// Sets the channel to shutdown if an error occurs.
1003    pub fn send(
1004        self,
1005        mut assignment_state: fidl_fuchsia_net_interfaces::AddressAssignmentState,
1006    ) -> Result<(), fidl::Error> {
1007        let _result = self.send_raw(assignment_state);
1008        if _result.is_err() {
1009            self.control_handle.shutdown();
1010        }
1011        self.drop_without_shutdown();
1012        _result
1013    }
1014
1015    /// Similar to "send" but does not shutdown the channel if an error occurs.
1016    pub fn send_no_shutdown_on_err(
1017        self,
1018        mut assignment_state: fidl_fuchsia_net_interfaces::AddressAssignmentState,
1019    ) -> Result<(), fidl::Error> {
1020        let _result = self.send_raw(assignment_state);
1021        self.drop_without_shutdown();
1022        _result
1023    }
1024
1025    fn send_raw(
1026        &self,
1027        mut assignment_state: fidl_fuchsia_net_interfaces::AddressAssignmentState,
1028    ) -> Result<(), fidl::Error> {
1029        self.control_handle.inner.send::<AddressStateProviderWatchAddressAssignmentStateResponse>(
1030            (assignment_state,),
1031            self.tx_id,
1032            0x740bb58c1b2d3188,
1033            fidl::encoding::DynamicFlags::empty(),
1034        )
1035    }
1036}
1037
1038#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1039pub struct ControlMarker;
1040
1041impl fidl::endpoints::ProtocolMarker for ControlMarker {
1042    type Proxy = ControlProxy;
1043    type RequestStream = ControlRequestStream;
1044    #[cfg(target_os = "fuchsia")]
1045    type SynchronousProxy = ControlSynchronousProxy;
1046
1047    const DEBUG_NAME: &'static str = "(anonymous) Control";
1048}
1049pub type ControlRemoveAddressResult = Result<bool, ControlRemoveAddressError>;
1050pub type ControlSetConfigurationResult = Result<Configuration, ControlSetConfigurationError>;
1051pub type ControlGetConfigurationResult = Result<Configuration, ControlGetConfigurationError>;
1052pub type ControlEnableResult = Result<bool, ControlEnableError>;
1053pub type ControlDisableResult = Result<bool, ControlDisableError>;
1054pub type ControlRemoveResult = Result<(), ControlRemoveError>;
1055
1056pub trait ControlProxyInterface: Send + Sync {
1057    fn r#add_address(
1058        &self,
1059        address: &fidl_fuchsia_net::Subnet,
1060        parameters: &AddressParameters,
1061        address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
1062    ) -> Result<(), fidl::Error>;
1063    type RemoveAddressResponseFut: std::future::Future<Output = Result<ControlRemoveAddressResult, fidl::Error>>
1064        + Send;
1065    fn r#remove_address(
1066        &self,
1067        address: &fidl_fuchsia_net::Subnet,
1068    ) -> Self::RemoveAddressResponseFut;
1069    type GetIdResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
1070    fn r#get_id(&self) -> Self::GetIdResponseFut;
1071    type SetConfigurationResponseFut: std::future::Future<Output = Result<ControlSetConfigurationResult, fidl::Error>>
1072        + Send;
1073    fn r#set_configuration(&self, config: &Configuration) -> Self::SetConfigurationResponseFut;
1074    type GetConfigurationResponseFut: std::future::Future<Output = Result<ControlGetConfigurationResult, fidl::Error>>
1075        + Send;
1076    fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut;
1077    type EnableResponseFut: std::future::Future<Output = Result<ControlEnableResult, fidl::Error>>
1078        + Send;
1079    fn r#enable(&self) -> Self::EnableResponseFut;
1080    type DisableResponseFut: std::future::Future<Output = Result<ControlDisableResult, fidl::Error>>
1081        + Send;
1082    fn r#disable(&self) -> Self::DisableResponseFut;
1083    fn r#detach(&self) -> Result<(), fidl::Error>;
1084    type GetAuthorizationForInterfaceResponseFut: std::future::Future<Output = Result<GrantForInterfaceAuthorization, fidl::Error>>
1085        + Send;
1086    fn r#get_authorization_for_interface(&self) -> Self::GetAuthorizationForInterfaceResponseFut;
1087    type RemoveResponseFut: std::future::Future<Output = Result<ControlRemoveResult, fidl::Error>>
1088        + Send;
1089    fn r#remove(&self) -> Self::RemoveResponseFut;
1090}
1091#[derive(Debug)]
1092#[cfg(target_os = "fuchsia")]
1093pub struct ControlSynchronousProxy {
1094    client: fidl::client::sync::Client,
1095}
1096
1097#[cfg(target_os = "fuchsia")]
1098impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
1099    type Proxy = ControlProxy;
1100    type Protocol = ControlMarker;
1101
1102    fn from_channel(inner: fidl::Channel) -> Self {
1103        Self::new(inner)
1104    }
1105
1106    fn into_channel(self) -> fidl::Channel {
1107        self.client.into_channel()
1108    }
1109
1110    fn as_channel(&self) -> &fidl::Channel {
1111        self.client.as_channel()
1112    }
1113}
1114
1115#[cfg(target_os = "fuchsia")]
1116impl ControlSynchronousProxy {
1117    pub fn new(channel: fidl::Channel) -> Self {
1118        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1119        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1120    }
1121
1122    pub fn into_channel(self) -> fidl::Channel {
1123        self.client.into_channel()
1124    }
1125
1126    /// Waits until an event arrives and returns it. It is safe for other
1127    /// threads to make concurrent requests while waiting for an event.
1128    pub fn wait_for_event(
1129        &self,
1130        deadline: zx::MonotonicInstant,
1131    ) -> Result<ControlEvent, fidl::Error> {
1132        ControlEvent::decode(self.client.wait_for_event(deadline)?)
1133    }
1134
1135    /// Assigns an address to the interface.
1136    ///
1137    /// Errors are communicated via
1138    /// [`fuchsia.net.interfaces.admin/AddressStateProvider.OnAddressRemoved`].
1139    ///
1140    /// + request `address` the address to assign to the interface.
1141    /// + request `parameters` additional address-specific options.
1142    /// + request `address_state_provider` provides address assignment state
1143    ///     and enables updating address properties.
1144    pub fn r#add_address(
1145        &self,
1146        mut address: &fidl_fuchsia_net::Subnet,
1147        mut parameters: &AddressParameters,
1148        mut address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
1149    ) -> Result<(), fidl::Error> {
1150        self.client.send::<ControlAddAddressRequest>(
1151            (address, parameters, address_state_provider),
1152            0x1349d36da453ce,
1153            fidl::encoding::DynamicFlags::empty(),
1154        )
1155    }
1156
1157    /// Removes an address from the interface.
1158    ///
1159    /// + request `address` the address to remove.
1160    /// - response `did_remove` `true` iff `address` was removed from the
1161    ///  interface as a consequence of this call.
1162    pub fn r#remove_address(
1163        &self,
1164        mut address: &fidl_fuchsia_net::Subnet,
1165        ___deadline: zx::MonotonicInstant,
1166    ) -> Result<ControlRemoveAddressResult, fidl::Error> {
1167        let _response =
1168            self.client.send_query::<ControlRemoveAddressRequest, fidl::encoding::ResultType<
1169                ControlRemoveAddressResponse,
1170                ControlRemoveAddressError,
1171            >>(
1172                (address,),
1173                0x213ba73da997a620,
1174                fidl::encoding::DynamicFlags::empty(),
1175                ___deadline,
1176            )?;
1177        Ok(_response.map(|x| x.did_remove))
1178    }
1179
1180    /// Gets the interface identifier.
1181    ///
1182    /// - response `id` the interface identifier.
1183    pub fn r#get_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
1184        let _response =
1185            self.client.send_query::<fidl::encoding::EmptyPayload, ControlGetIdResponse>(
1186                (),
1187                0x2a2459768d9ecc6f,
1188                fidl::encoding::DynamicFlags::empty(),
1189                ___deadline,
1190            )?;
1191        Ok(_response.id)
1192    }
1193
1194    /// Sets the configuration for the interface.
1195    ///
1196    /// Only set fields that are supported in the provided [`Configuration`]
1197    /// will be set; unset fields will be left unmodified. The server will
1198    /// return a [`Configuration`] which holds the previous configuration for
1199    /// fields that the interface supports and set, even if the call did not
1200    /// update the configuration's value.
1201    ///
1202    /// + request `config` the configuration fields to update on the interface.
1203    /// - response `previous_config` a snapshot of the interface's previous
1204    ///   configuration. Only supported fields present in `config` will be set.
1205    pub fn r#set_configuration(
1206        &self,
1207        mut config: &Configuration,
1208        ___deadline: zx::MonotonicInstant,
1209    ) -> Result<ControlSetConfigurationResult, fidl::Error> {
1210        let _response = self
1211            .client
1212            .send_query::<ControlSetConfigurationRequest, fidl::encoding::ResultType<
1213                ControlSetConfigurationResponse,
1214                ControlSetConfigurationError,
1215            >>(
1216                (config,), 0x573923b7b4bde27f, fidl::encoding::DynamicFlags::empty(), ___deadline
1217            )?;
1218        Ok(_response.map(|x| x.previous_config))
1219    }
1220
1221    /// Gets a snapshot of the interface's configuration.
1222    ///
1223    /// The server will populate the returned [`Configuration`] with the
1224    /// configuration for features/protocols that the interface supports. That
1225    /// is, fields for unsupported configurations will be unset in the returned
1226    /// [`Configuration`].
1227    ///
1228    /// - response `config` a snapshot of the interface's configuration.
1229    pub fn r#get_configuration(
1230        &self,
1231        ___deadline: zx::MonotonicInstant,
1232    ) -> Result<ControlGetConfigurationResult, fidl::Error> {
1233        let _response = self
1234            .client
1235            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1236                ControlGetConfigurationResponse,
1237                ControlGetConfigurationError,
1238            >>(
1239                (), 0x5f5d239820bdcc65, fidl::encoding::DynamicFlags::empty(), ___deadline
1240            )?;
1241        Ok(_response.map(|x| x.config))
1242    }
1243
1244    /// Enables the interface.
1245    ///
1246    /// - response `did_enable` `true` iff the interface moved from disabled to
1247    /// enabled as a consequence of this call.
1248    pub fn r#enable(
1249        &self,
1250        ___deadline: zx::MonotonicInstant,
1251    ) -> Result<ControlEnableResult, fidl::Error> {
1252        let _response = self.client.send_query::<
1253            fidl::encoding::EmptyPayload,
1254            fidl::encoding::ResultType<ControlEnableResponse, ControlEnableError>,
1255        >(
1256            (),
1257            0x15c983d3a8ac0b98,
1258            fidl::encoding::DynamicFlags::empty(),
1259            ___deadline,
1260        )?;
1261        Ok(_response.map(|x| x.did_enable))
1262    }
1263
1264    /// Disables the interface.
1265    ///
1266    /// - response `did_disable` `true` iff the interface moved from enabled to
1267    /// disabled as a consequence of this call.
1268    pub fn r#disable(
1269        &self,
1270        ___deadline: zx::MonotonicInstant,
1271    ) -> Result<ControlDisableResult, fidl::Error> {
1272        let _response = self.client.send_query::<
1273            fidl::encoding::EmptyPayload,
1274            fidl::encoding::ResultType<ControlDisableResponse, ControlDisableError>,
1275        >(
1276            (),
1277            0x98d3a585d905473,
1278            fidl::encoding::DynamicFlags::empty(),
1279            ___deadline,
1280        )?;
1281        Ok(_response.map(|x| x.did_disable))
1282    }
1283
1284    /// Detaches the client end from the interface's lifetime.
1285    ///
1286    /// After calling `Detach`, closing this client end no longer causes the
1287    /// interface to be removed.
1288    pub fn r#detach(&self) -> Result<(), fidl::Error> {
1289        self.client.send::<fidl::encoding::EmptyPayload>(
1290            (),
1291            0x78ee27518b2dbfa,
1292            fidl::encoding::DynamicFlags::empty(),
1293        )
1294    }
1295
1296    /// Get an authentication credential for this interface.
1297    ///
1298    /// The credential contains a [`zx::handle::EVENT`], whose entangled
1299    /// partner is held by the server. This credential can be converted into a
1300    /// [`ProofOfInterfaceAuthorization`] and then passed into `fuchsia.net.*`
1301    /// API calls to prove ownership of this interface. The `EVENT` is
1302    /// stable throughout the lifetime of the interface. Clients may duplicate
1303    /// this `EVENT` to make multiple API calls, or transfer the `EVENT`
1304    /// to other clients.
1305    ///
1306    /// - response `credential` the authorization credential for this interface.
1307    pub fn r#get_authorization_for_interface(
1308        &self,
1309        ___deadline: zx::MonotonicInstant,
1310    ) -> Result<GrantForInterfaceAuthorization, fidl::Error> {
1311        let _response = self.client.send_query::<
1312            fidl::encoding::EmptyPayload,
1313            ControlGetAuthorizationForInterfaceResponse,
1314        >(
1315            (),
1316            0xc1de2ab60b5cb9e,
1317            fidl::encoding::DynamicFlags::empty(),
1318            ___deadline,
1319        )?;
1320        Ok(_response.credential)
1321    }
1322
1323    /// Initiates interface removal.
1324    ///
1325    /// This method returns success once interface removal has started. When the
1326    /// interface is removed, a `USER` removed reason is issued in
1327    /// [`OnInterfaceRemoved`] and the server end is closed.
1328    pub fn r#remove(
1329        &self,
1330        ___deadline: zx::MonotonicInstant,
1331    ) -> Result<ControlRemoveResult, fidl::Error> {
1332        let _response =
1333            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1334                fidl::encoding::EmptyStruct,
1335                ControlRemoveError,
1336            >>(
1337                (),
1338                0x13aab8bbecc7ff0b,
1339                fidl::encoding::DynamicFlags::empty(),
1340                ___deadline,
1341            )?;
1342        Ok(_response.map(|x| x))
1343    }
1344}
1345
1346#[cfg(target_os = "fuchsia")]
1347impl From<ControlSynchronousProxy> for zx::Handle {
1348    fn from(value: ControlSynchronousProxy) -> Self {
1349        value.into_channel().into()
1350    }
1351}
1352
1353#[cfg(target_os = "fuchsia")]
1354impl From<fidl::Channel> for ControlSynchronousProxy {
1355    fn from(value: fidl::Channel) -> Self {
1356        Self::new(value)
1357    }
1358}
1359
1360#[derive(Debug, Clone)]
1361pub struct ControlProxy {
1362    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1363}
1364
1365impl fidl::endpoints::Proxy for ControlProxy {
1366    type Protocol = ControlMarker;
1367
1368    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1369        Self::new(inner)
1370    }
1371
1372    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1373        self.client.into_channel().map_err(|client| Self { client })
1374    }
1375
1376    fn as_channel(&self) -> &::fidl::AsyncChannel {
1377        self.client.as_channel()
1378    }
1379}
1380
1381impl ControlProxy {
1382    /// Create a new Proxy for fuchsia.net.interfaces.admin/Control.
1383    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1384        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1385        Self { client: fidl::client::Client::new(channel, protocol_name) }
1386    }
1387
1388    /// Get a Stream of events from the remote end of the protocol.
1389    ///
1390    /// # Panics
1391    ///
1392    /// Panics if the event stream was already taken.
1393    pub fn take_event_stream(&self) -> ControlEventStream {
1394        ControlEventStream { event_receiver: self.client.take_event_receiver() }
1395    }
1396
1397    /// Assigns an address to the interface.
1398    ///
1399    /// Errors are communicated via
1400    /// [`fuchsia.net.interfaces.admin/AddressStateProvider.OnAddressRemoved`].
1401    ///
1402    /// + request `address` the address to assign to the interface.
1403    /// + request `parameters` additional address-specific options.
1404    /// + request `address_state_provider` provides address assignment state
1405    ///     and enables updating address properties.
1406    pub fn r#add_address(
1407        &self,
1408        mut address: &fidl_fuchsia_net::Subnet,
1409        mut parameters: &AddressParameters,
1410        mut address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
1411    ) -> Result<(), fidl::Error> {
1412        ControlProxyInterface::r#add_address(self, address, parameters, address_state_provider)
1413    }
1414
1415    /// Removes an address from the interface.
1416    ///
1417    /// + request `address` the address to remove.
1418    /// - response `did_remove` `true` iff `address` was removed from the
1419    ///  interface as a consequence of this call.
1420    pub fn r#remove_address(
1421        &self,
1422        mut address: &fidl_fuchsia_net::Subnet,
1423    ) -> fidl::client::QueryResponseFut<
1424        ControlRemoveAddressResult,
1425        fidl::encoding::DefaultFuchsiaResourceDialect,
1426    > {
1427        ControlProxyInterface::r#remove_address(self, address)
1428    }
1429
1430    /// Gets the interface identifier.
1431    ///
1432    /// - response `id` the interface identifier.
1433    pub fn r#get_id(
1434        &self,
1435    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
1436        ControlProxyInterface::r#get_id(self)
1437    }
1438
1439    /// Sets the configuration for the interface.
1440    ///
1441    /// Only set fields that are supported in the provided [`Configuration`]
1442    /// will be set; unset fields will be left unmodified. The server will
1443    /// return a [`Configuration`] which holds the previous configuration for
1444    /// fields that the interface supports and set, even if the call did not
1445    /// update the configuration's value.
1446    ///
1447    /// + request `config` the configuration fields to update on the interface.
1448    /// - response `previous_config` a snapshot of the interface's previous
1449    ///   configuration. Only supported fields present in `config` will be set.
1450    pub fn r#set_configuration(
1451        &self,
1452        mut config: &Configuration,
1453    ) -> fidl::client::QueryResponseFut<
1454        ControlSetConfigurationResult,
1455        fidl::encoding::DefaultFuchsiaResourceDialect,
1456    > {
1457        ControlProxyInterface::r#set_configuration(self, config)
1458    }
1459
1460    /// Gets a snapshot of the interface's configuration.
1461    ///
1462    /// The server will populate the returned [`Configuration`] with the
1463    /// configuration for features/protocols that the interface supports. That
1464    /// is, fields for unsupported configurations will be unset in the returned
1465    /// [`Configuration`].
1466    ///
1467    /// - response `config` a snapshot of the interface's configuration.
1468    pub fn r#get_configuration(
1469        &self,
1470    ) -> fidl::client::QueryResponseFut<
1471        ControlGetConfigurationResult,
1472        fidl::encoding::DefaultFuchsiaResourceDialect,
1473    > {
1474        ControlProxyInterface::r#get_configuration(self)
1475    }
1476
1477    /// Enables the interface.
1478    ///
1479    /// - response `did_enable` `true` iff the interface moved from disabled to
1480    /// enabled as a consequence of this call.
1481    pub fn r#enable(
1482        &self,
1483    ) -> fidl::client::QueryResponseFut<
1484        ControlEnableResult,
1485        fidl::encoding::DefaultFuchsiaResourceDialect,
1486    > {
1487        ControlProxyInterface::r#enable(self)
1488    }
1489
1490    /// Disables the interface.
1491    ///
1492    /// - response `did_disable` `true` iff the interface moved from enabled to
1493    /// disabled as a consequence of this call.
1494    pub fn r#disable(
1495        &self,
1496    ) -> fidl::client::QueryResponseFut<
1497        ControlDisableResult,
1498        fidl::encoding::DefaultFuchsiaResourceDialect,
1499    > {
1500        ControlProxyInterface::r#disable(self)
1501    }
1502
1503    /// Detaches the client end from the interface's lifetime.
1504    ///
1505    /// After calling `Detach`, closing this client end no longer causes the
1506    /// interface to be removed.
1507    pub fn r#detach(&self) -> Result<(), fidl::Error> {
1508        ControlProxyInterface::r#detach(self)
1509    }
1510
1511    /// Get an authentication credential for this interface.
1512    ///
1513    /// The credential contains a [`zx::handle::EVENT`], whose entangled
1514    /// partner is held by the server. This credential can be converted into a
1515    /// [`ProofOfInterfaceAuthorization`] and then passed into `fuchsia.net.*`
1516    /// API calls to prove ownership of this interface. The `EVENT` is
1517    /// stable throughout the lifetime of the interface. Clients may duplicate
1518    /// this `EVENT` to make multiple API calls, or transfer the `EVENT`
1519    /// to other clients.
1520    ///
1521    /// - response `credential` the authorization credential for this interface.
1522    pub fn r#get_authorization_for_interface(
1523        &self,
1524    ) -> fidl::client::QueryResponseFut<
1525        GrantForInterfaceAuthorization,
1526        fidl::encoding::DefaultFuchsiaResourceDialect,
1527    > {
1528        ControlProxyInterface::r#get_authorization_for_interface(self)
1529    }
1530
1531    /// Initiates interface removal.
1532    ///
1533    /// This method returns success once interface removal has started. When the
1534    /// interface is removed, a `USER` removed reason is issued in
1535    /// [`OnInterfaceRemoved`] and the server end is closed.
1536    pub fn r#remove(
1537        &self,
1538    ) -> fidl::client::QueryResponseFut<
1539        ControlRemoveResult,
1540        fidl::encoding::DefaultFuchsiaResourceDialect,
1541    > {
1542        ControlProxyInterface::r#remove(self)
1543    }
1544}
1545
1546impl ControlProxyInterface for ControlProxy {
1547    fn r#add_address(
1548        &self,
1549        mut address: &fidl_fuchsia_net::Subnet,
1550        mut parameters: &AddressParameters,
1551        mut address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
1552    ) -> Result<(), fidl::Error> {
1553        self.client.send::<ControlAddAddressRequest>(
1554            (address, parameters, address_state_provider),
1555            0x1349d36da453ce,
1556            fidl::encoding::DynamicFlags::empty(),
1557        )
1558    }
1559
1560    type RemoveAddressResponseFut = fidl::client::QueryResponseFut<
1561        ControlRemoveAddressResult,
1562        fidl::encoding::DefaultFuchsiaResourceDialect,
1563    >;
1564    fn r#remove_address(
1565        &self,
1566        mut address: &fidl_fuchsia_net::Subnet,
1567    ) -> Self::RemoveAddressResponseFut {
1568        fn _decode(
1569            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1570        ) -> Result<ControlRemoveAddressResult, fidl::Error> {
1571            let _response = fidl::client::decode_transaction_body::<
1572                fidl::encoding::ResultType<ControlRemoveAddressResponse, ControlRemoveAddressError>,
1573                fidl::encoding::DefaultFuchsiaResourceDialect,
1574                0x213ba73da997a620,
1575            >(_buf?)?;
1576            Ok(_response.map(|x| x.did_remove))
1577        }
1578        self.client
1579            .send_query_and_decode::<ControlRemoveAddressRequest, ControlRemoveAddressResult>(
1580                (address,),
1581                0x213ba73da997a620,
1582                fidl::encoding::DynamicFlags::empty(),
1583                _decode,
1584            )
1585    }
1586
1587    type GetIdResponseFut =
1588        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
1589    fn r#get_id(&self) -> Self::GetIdResponseFut {
1590        fn _decode(
1591            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1592        ) -> Result<u64, fidl::Error> {
1593            let _response = fidl::client::decode_transaction_body::<
1594                ControlGetIdResponse,
1595                fidl::encoding::DefaultFuchsiaResourceDialect,
1596                0x2a2459768d9ecc6f,
1597            >(_buf?)?;
1598            Ok(_response.id)
1599        }
1600        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
1601            (),
1602            0x2a2459768d9ecc6f,
1603            fidl::encoding::DynamicFlags::empty(),
1604            _decode,
1605        )
1606    }
1607
1608    type SetConfigurationResponseFut = fidl::client::QueryResponseFut<
1609        ControlSetConfigurationResult,
1610        fidl::encoding::DefaultFuchsiaResourceDialect,
1611    >;
1612    fn r#set_configuration(&self, mut config: &Configuration) -> Self::SetConfigurationResponseFut {
1613        fn _decode(
1614            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1615        ) -> Result<ControlSetConfigurationResult, fidl::Error> {
1616            let _response = fidl::client::decode_transaction_body::<
1617                fidl::encoding::ResultType<
1618                    ControlSetConfigurationResponse,
1619                    ControlSetConfigurationError,
1620                >,
1621                fidl::encoding::DefaultFuchsiaResourceDialect,
1622                0x573923b7b4bde27f,
1623            >(_buf?)?;
1624            Ok(_response.map(|x| x.previous_config))
1625        }
1626        self.client
1627            .send_query_and_decode::<ControlSetConfigurationRequest, ControlSetConfigurationResult>(
1628                (config,),
1629                0x573923b7b4bde27f,
1630                fidl::encoding::DynamicFlags::empty(),
1631                _decode,
1632            )
1633    }
1634
1635    type GetConfigurationResponseFut = fidl::client::QueryResponseFut<
1636        ControlGetConfigurationResult,
1637        fidl::encoding::DefaultFuchsiaResourceDialect,
1638    >;
1639    fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut {
1640        fn _decode(
1641            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1642        ) -> Result<ControlGetConfigurationResult, fidl::Error> {
1643            let _response = fidl::client::decode_transaction_body::<
1644                fidl::encoding::ResultType<
1645                    ControlGetConfigurationResponse,
1646                    ControlGetConfigurationError,
1647                >,
1648                fidl::encoding::DefaultFuchsiaResourceDialect,
1649                0x5f5d239820bdcc65,
1650            >(_buf?)?;
1651            Ok(_response.map(|x| x.config))
1652        }
1653        self.client
1654            .send_query_and_decode::<fidl::encoding::EmptyPayload, ControlGetConfigurationResult>(
1655                (),
1656                0x5f5d239820bdcc65,
1657                fidl::encoding::DynamicFlags::empty(),
1658                _decode,
1659            )
1660    }
1661
1662    type EnableResponseFut = fidl::client::QueryResponseFut<
1663        ControlEnableResult,
1664        fidl::encoding::DefaultFuchsiaResourceDialect,
1665    >;
1666    fn r#enable(&self) -> Self::EnableResponseFut {
1667        fn _decode(
1668            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1669        ) -> Result<ControlEnableResult, fidl::Error> {
1670            let _response = fidl::client::decode_transaction_body::<
1671                fidl::encoding::ResultType<ControlEnableResponse, ControlEnableError>,
1672                fidl::encoding::DefaultFuchsiaResourceDialect,
1673                0x15c983d3a8ac0b98,
1674            >(_buf?)?;
1675            Ok(_response.map(|x| x.did_enable))
1676        }
1677        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlEnableResult>(
1678            (),
1679            0x15c983d3a8ac0b98,
1680            fidl::encoding::DynamicFlags::empty(),
1681            _decode,
1682        )
1683    }
1684
1685    type DisableResponseFut = fidl::client::QueryResponseFut<
1686        ControlDisableResult,
1687        fidl::encoding::DefaultFuchsiaResourceDialect,
1688    >;
1689    fn r#disable(&self) -> Self::DisableResponseFut {
1690        fn _decode(
1691            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1692        ) -> Result<ControlDisableResult, fidl::Error> {
1693            let _response = fidl::client::decode_transaction_body::<
1694                fidl::encoding::ResultType<ControlDisableResponse, ControlDisableError>,
1695                fidl::encoding::DefaultFuchsiaResourceDialect,
1696                0x98d3a585d905473,
1697            >(_buf?)?;
1698            Ok(_response.map(|x| x.did_disable))
1699        }
1700        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlDisableResult>(
1701            (),
1702            0x98d3a585d905473,
1703            fidl::encoding::DynamicFlags::empty(),
1704            _decode,
1705        )
1706    }
1707
1708    fn r#detach(&self) -> Result<(), fidl::Error> {
1709        self.client.send::<fidl::encoding::EmptyPayload>(
1710            (),
1711            0x78ee27518b2dbfa,
1712            fidl::encoding::DynamicFlags::empty(),
1713        )
1714    }
1715
1716    type GetAuthorizationForInterfaceResponseFut = fidl::client::QueryResponseFut<
1717        GrantForInterfaceAuthorization,
1718        fidl::encoding::DefaultFuchsiaResourceDialect,
1719    >;
1720    fn r#get_authorization_for_interface(&self) -> Self::GetAuthorizationForInterfaceResponseFut {
1721        fn _decode(
1722            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1723        ) -> Result<GrantForInterfaceAuthorization, fidl::Error> {
1724            let _response = fidl::client::decode_transaction_body::<
1725                ControlGetAuthorizationForInterfaceResponse,
1726                fidl::encoding::DefaultFuchsiaResourceDialect,
1727                0xc1de2ab60b5cb9e,
1728            >(_buf?)?;
1729            Ok(_response.credential)
1730        }
1731        self.client
1732            .send_query_and_decode::<fidl::encoding::EmptyPayload, GrantForInterfaceAuthorization>(
1733                (),
1734                0xc1de2ab60b5cb9e,
1735                fidl::encoding::DynamicFlags::empty(),
1736                _decode,
1737            )
1738    }
1739
1740    type RemoveResponseFut = fidl::client::QueryResponseFut<
1741        ControlRemoveResult,
1742        fidl::encoding::DefaultFuchsiaResourceDialect,
1743    >;
1744    fn r#remove(&self) -> Self::RemoveResponseFut {
1745        fn _decode(
1746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1747        ) -> Result<ControlRemoveResult, fidl::Error> {
1748            let _response = fidl::client::decode_transaction_body::<
1749                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControlRemoveError>,
1750                fidl::encoding::DefaultFuchsiaResourceDialect,
1751                0x13aab8bbecc7ff0b,
1752            >(_buf?)?;
1753            Ok(_response.map(|x| x))
1754        }
1755        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlRemoveResult>(
1756            (),
1757            0x13aab8bbecc7ff0b,
1758            fidl::encoding::DynamicFlags::empty(),
1759            _decode,
1760        )
1761    }
1762}
1763
1764pub struct ControlEventStream {
1765    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1766}
1767
1768impl std::marker::Unpin for ControlEventStream {}
1769
1770impl futures::stream::FusedStream for ControlEventStream {
1771    fn is_terminated(&self) -> bool {
1772        self.event_receiver.is_terminated()
1773    }
1774}
1775
1776impl futures::Stream for ControlEventStream {
1777    type Item = Result<ControlEvent, fidl::Error>;
1778
1779    fn poll_next(
1780        mut self: std::pin::Pin<&mut Self>,
1781        cx: &mut std::task::Context<'_>,
1782    ) -> std::task::Poll<Option<Self::Item>> {
1783        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1784            &mut self.event_receiver,
1785            cx
1786        )?) {
1787            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1788            None => std::task::Poll::Ready(None),
1789        }
1790    }
1791}
1792
1793#[derive(Debug)]
1794pub enum ControlEvent {
1795    OnInterfaceRemoved { reason: InterfaceRemovedReason },
1796}
1797
1798impl ControlEvent {
1799    #[allow(irrefutable_let_patterns)]
1800    pub fn into_on_interface_removed(self) -> Option<InterfaceRemovedReason> {
1801        if let ControlEvent::OnInterfaceRemoved { reason } = self {
1802            Some((reason))
1803        } else {
1804            None
1805        }
1806    }
1807
1808    /// Decodes a message buffer as a [`ControlEvent`].
1809    fn decode(
1810        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1811    ) -> Result<ControlEvent, fidl::Error> {
1812        let (bytes, _handles) = buf.split_mut();
1813        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1814        debug_assert_eq!(tx_header.tx_id, 0);
1815        match tx_header.ordinal {
1816            0x800d39e76c1cddd => {
1817                let mut out = fidl::new_empty!(
1818                    ControlOnInterfaceRemovedRequest,
1819                    fidl::encoding::DefaultFuchsiaResourceDialect
1820                );
1821                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlOnInterfaceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1822                Ok((ControlEvent::OnInterfaceRemoved { reason: out.reason }))
1823            }
1824            _ => Err(fidl::Error::UnknownOrdinal {
1825                ordinal: tx_header.ordinal,
1826                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1827            }),
1828        }
1829    }
1830}
1831
1832/// A Stream of incoming requests for fuchsia.net.interfaces.admin/Control.
1833pub struct ControlRequestStream {
1834    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1835    is_terminated: bool,
1836}
1837
1838impl std::marker::Unpin for ControlRequestStream {}
1839
1840impl futures::stream::FusedStream for ControlRequestStream {
1841    fn is_terminated(&self) -> bool {
1842        self.is_terminated
1843    }
1844}
1845
1846impl fidl::endpoints::RequestStream for ControlRequestStream {
1847    type Protocol = ControlMarker;
1848    type ControlHandle = ControlControlHandle;
1849
1850    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1851        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1852    }
1853
1854    fn control_handle(&self) -> Self::ControlHandle {
1855        ControlControlHandle { inner: self.inner.clone() }
1856    }
1857
1858    fn into_inner(
1859        self,
1860    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1861    {
1862        (self.inner, self.is_terminated)
1863    }
1864
1865    fn from_inner(
1866        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1867        is_terminated: bool,
1868    ) -> Self {
1869        Self { inner, is_terminated }
1870    }
1871}
1872
1873impl futures::Stream for ControlRequestStream {
1874    type Item = Result<ControlRequest, fidl::Error>;
1875
1876    fn poll_next(
1877        mut self: std::pin::Pin<&mut Self>,
1878        cx: &mut std::task::Context<'_>,
1879    ) -> std::task::Poll<Option<Self::Item>> {
1880        let this = &mut *self;
1881        if this.inner.check_shutdown(cx) {
1882            this.is_terminated = true;
1883            return std::task::Poll::Ready(None);
1884        }
1885        if this.is_terminated {
1886            panic!("polled ControlRequestStream after completion");
1887        }
1888        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1889            |bytes, handles| {
1890                match this.inner.channel().read_etc(cx, bytes, handles) {
1891                    std::task::Poll::Ready(Ok(())) => {}
1892                    std::task::Poll::Pending => return std::task::Poll::Pending,
1893                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1894                        this.is_terminated = true;
1895                        return std::task::Poll::Ready(None);
1896                    }
1897                    std::task::Poll::Ready(Err(e)) => {
1898                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1899                            e.into(),
1900                        ))))
1901                    }
1902                }
1903
1904                // A message has been received from the channel
1905                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1906
1907                std::task::Poll::Ready(Some(match header.ordinal {
1908                    0x1349d36da453ce => {
1909                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1910                        let mut req = fidl::new_empty!(
1911                            ControlAddAddressRequest,
1912                            fidl::encoding::DefaultFuchsiaResourceDialect
1913                        );
1914                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlAddAddressRequest>(&header, _body_bytes, handles, &mut req)?;
1915                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1916                        Ok(ControlRequest::AddAddress {
1917                            address: req.address,
1918                            parameters: req.parameters,
1919                            address_state_provider: req.address_state_provider,
1920
1921                            control_handle,
1922                        })
1923                    }
1924                    0x213ba73da997a620 => {
1925                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1926                        let mut req = fidl::new_empty!(
1927                            ControlRemoveAddressRequest,
1928                            fidl::encoding::DefaultFuchsiaResourceDialect
1929                        );
1930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlRemoveAddressRequest>(&header, _body_bytes, handles, &mut req)?;
1931                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1932                        Ok(ControlRequest::RemoveAddress {
1933                            address: req.address,
1934
1935                            responder: ControlRemoveAddressResponder {
1936                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1937                                tx_id: header.tx_id,
1938                            },
1939                        })
1940                    }
1941                    0x2a2459768d9ecc6f => {
1942                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1943                        let mut req = fidl::new_empty!(
1944                            fidl::encoding::EmptyPayload,
1945                            fidl::encoding::DefaultFuchsiaResourceDialect
1946                        );
1947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1948                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1949                        Ok(ControlRequest::GetId {
1950                            responder: ControlGetIdResponder {
1951                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1952                                tx_id: header.tx_id,
1953                            },
1954                        })
1955                    }
1956                    0x573923b7b4bde27f => {
1957                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1958                        let mut req = fidl::new_empty!(
1959                            ControlSetConfigurationRequest,
1960                            fidl::encoding::DefaultFuchsiaResourceDialect
1961                        );
1962                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
1963                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1964                        Ok(ControlRequest::SetConfiguration {
1965                            config: req.config,
1966
1967                            responder: ControlSetConfigurationResponder {
1968                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1969                                tx_id: header.tx_id,
1970                            },
1971                        })
1972                    }
1973                    0x5f5d239820bdcc65 => {
1974                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1975                        let mut req = fidl::new_empty!(
1976                            fidl::encoding::EmptyPayload,
1977                            fidl::encoding::DefaultFuchsiaResourceDialect
1978                        );
1979                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1980                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1981                        Ok(ControlRequest::GetConfiguration {
1982                            responder: ControlGetConfigurationResponder {
1983                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1984                                tx_id: header.tx_id,
1985                            },
1986                        })
1987                    }
1988                    0x15c983d3a8ac0b98 => {
1989                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1990                        let mut req = fidl::new_empty!(
1991                            fidl::encoding::EmptyPayload,
1992                            fidl::encoding::DefaultFuchsiaResourceDialect
1993                        );
1994                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1995                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1996                        Ok(ControlRequest::Enable {
1997                            responder: ControlEnableResponder {
1998                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1999                                tx_id: header.tx_id,
2000                            },
2001                        })
2002                    }
2003                    0x98d3a585d905473 => {
2004                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2005                        let mut req = fidl::new_empty!(
2006                            fidl::encoding::EmptyPayload,
2007                            fidl::encoding::DefaultFuchsiaResourceDialect
2008                        );
2009                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2010                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
2011                        Ok(ControlRequest::Disable {
2012                            responder: ControlDisableResponder {
2013                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2014                                tx_id: header.tx_id,
2015                            },
2016                        })
2017                    }
2018                    0x78ee27518b2dbfa => {
2019                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2020                        let mut req = fidl::new_empty!(
2021                            fidl::encoding::EmptyPayload,
2022                            fidl::encoding::DefaultFuchsiaResourceDialect
2023                        );
2024                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2025                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
2026                        Ok(ControlRequest::Detach { control_handle })
2027                    }
2028                    0xc1de2ab60b5cb9e => {
2029                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2030                        let mut req = fidl::new_empty!(
2031                            fidl::encoding::EmptyPayload,
2032                            fidl::encoding::DefaultFuchsiaResourceDialect
2033                        );
2034                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2035                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
2036                        Ok(ControlRequest::GetAuthorizationForInterface {
2037                            responder: ControlGetAuthorizationForInterfaceResponder {
2038                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2039                                tx_id: header.tx_id,
2040                            },
2041                        })
2042                    }
2043                    0x13aab8bbecc7ff0b => {
2044                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2045                        let mut req = fidl::new_empty!(
2046                            fidl::encoding::EmptyPayload,
2047                            fidl::encoding::DefaultFuchsiaResourceDialect
2048                        );
2049                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2050                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
2051                        Ok(ControlRequest::Remove {
2052                            responder: ControlRemoveResponder {
2053                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2054                                tx_id: header.tx_id,
2055                            },
2056                        })
2057                    }
2058                    _ => Err(fidl::Error::UnknownOrdinal {
2059                        ordinal: header.ordinal,
2060                        protocol_name:
2061                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2062                    }),
2063                }))
2064            },
2065        )
2066    }
2067}
2068
2069/// Provides control over an interface.
2070///
2071/// This protocol encodes the underlying interface's lifetime in both
2072/// directions; the interface exists iff both ends of the protocol are open.
2073/// That is:
2074///
2075/// - Closing the client end causes the interface to be removed.
2076/// - Observing a closure of the server end indicates the interface no longer
2077///   exists.
2078#[derive(Debug)]
2079pub enum ControlRequest {
2080    /// Assigns an address to the interface.
2081    ///
2082    /// Errors are communicated via
2083    /// [`fuchsia.net.interfaces.admin/AddressStateProvider.OnAddressRemoved`].
2084    ///
2085    /// + request `address` the address to assign to the interface.
2086    /// + request `parameters` additional address-specific options.
2087    /// + request `address_state_provider` provides address assignment state
2088    ///     and enables updating address properties.
2089    AddAddress {
2090        address: fidl_fuchsia_net::Subnet,
2091        parameters: AddressParameters,
2092        address_state_provider: fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
2093        control_handle: ControlControlHandle,
2094    },
2095    /// Removes an address from the interface.
2096    ///
2097    /// + request `address` the address to remove.
2098    /// - response `did_remove` `true` iff `address` was removed from the
2099    ///  interface as a consequence of this call.
2100    RemoveAddress { address: fidl_fuchsia_net::Subnet, responder: ControlRemoveAddressResponder },
2101    /// Gets the interface identifier.
2102    ///
2103    /// - response `id` the interface identifier.
2104    GetId { responder: ControlGetIdResponder },
2105    /// Sets the configuration for the interface.
2106    ///
2107    /// Only set fields that are supported in the provided [`Configuration`]
2108    /// will be set; unset fields will be left unmodified. The server will
2109    /// return a [`Configuration`] which holds the previous configuration for
2110    /// fields that the interface supports and set, even if the call did not
2111    /// update the configuration's value.
2112    ///
2113    /// + request `config` the configuration fields to update on the interface.
2114    /// - response `previous_config` a snapshot of the interface's previous
2115    ///   configuration. Only supported fields present in `config` will be set.
2116    SetConfiguration { config: Configuration, responder: ControlSetConfigurationResponder },
2117    /// Gets a snapshot of the interface's configuration.
2118    ///
2119    /// The server will populate the returned [`Configuration`] with the
2120    /// configuration for features/protocols that the interface supports. That
2121    /// is, fields for unsupported configurations will be unset in the returned
2122    /// [`Configuration`].
2123    ///
2124    /// - response `config` a snapshot of the interface's configuration.
2125    GetConfiguration { responder: ControlGetConfigurationResponder },
2126    /// Enables the interface.
2127    ///
2128    /// - response `did_enable` `true` iff the interface moved from disabled to
2129    /// enabled as a consequence of this call.
2130    Enable { responder: ControlEnableResponder },
2131    /// Disables the interface.
2132    ///
2133    /// - response `did_disable` `true` iff the interface moved from enabled to
2134    /// disabled as a consequence of this call.
2135    Disable { responder: ControlDisableResponder },
2136    /// Detaches the client end from the interface's lifetime.
2137    ///
2138    /// After calling `Detach`, closing this client end no longer causes the
2139    /// interface to be removed.
2140    Detach { control_handle: ControlControlHandle },
2141    /// Get an authentication credential for this interface.
2142    ///
2143    /// The credential contains a [`zx::handle::EVENT`], whose entangled
2144    /// partner is held by the server. This credential can be converted into a
2145    /// [`ProofOfInterfaceAuthorization`] and then passed into `fuchsia.net.*`
2146    /// API calls to prove ownership of this interface. The `EVENT` is
2147    /// stable throughout the lifetime of the interface. Clients may duplicate
2148    /// this `EVENT` to make multiple API calls, or transfer the `EVENT`
2149    /// to other clients.
2150    ///
2151    /// - response `credential` the authorization credential for this interface.
2152    GetAuthorizationForInterface { responder: ControlGetAuthorizationForInterfaceResponder },
2153    /// Initiates interface removal.
2154    ///
2155    /// This method returns success once interface removal has started. When the
2156    /// interface is removed, a `USER` removed reason is issued in
2157    /// [`OnInterfaceRemoved`] and the server end is closed.
2158    Remove { responder: ControlRemoveResponder },
2159}
2160
2161impl ControlRequest {
2162    #[allow(irrefutable_let_patterns)]
2163    pub fn into_add_address(
2164        self,
2165    ) -> Option<(
2166        fidl_fuchsia_net::Subnet,
2167        AddressParameters,
2168        fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
2169        ControlControlHandle,
2170    )> {
2171        if let ControlRequest::AddAddress {
2172            address,
2173            parameters,
2174            address_state_provider,
2175            control_handle,
2176        } = self
2177        {
2178            Some((address, parameters, address_state_provider, control_handle))
2179        } else {
2180            None
2181        }
2182    }
2183
2184    #[allow(irrefutable_let_patterns)]
2185    pub fn into_remove_address(
2186        self,
2187    ) -> Option<(fidl_fuchsia_net::Subnet, ControlRemoveAddressResponder)> {
2188        if let ControlRequest::RemoveAddress { address, responder } = self {
2189            Some((address, responder))
2190        } else {
2191            None
2192        }
2193    }
2194
2195    #[allow(irrefutable_let_patterns)]
2196    pub fn into_get_id(self) -> Option<(ControlGetIdResponder)> {
2197        if let ControlRequest::GetId { responder } = self {
2198            Some((responder))
2199        } else {
2200            None
2201        }
2202    }
2203
2204    #[allow(irrefutable_let_patterns)]
2205    pub fn into_set_configuration(
2206        self,
2207    ) -> Option<(Configuration, ControlSetConfigurationResponder)> {
2208        if let ControlRequest::SetConfiguration { config, responder } = self {
2209            Some((config, responder))
2210        } else {
2211            None
2212        }
2213    }
2214
2215    #[allow(irrefutable_let_patterns)]
2216    pub fn into_get_configuration(self) -> Option<(ControlGetConfigurationResponder)> {
2217        if let ControlRequest::GetConfiguration { responder } = self {
2218            Some((responder))
2219        } else {
2220            None
2221        }
2222    }
2223
2224    #[allow(irrefutable_let_patterns)]
2225    pub fn into_enable(self) -> Option<(ControlEnableResponder)> {
2226        if let ControlRequest::Enable { responder } = self {
2227            Some((responder))
2228        } else {
2229            None
2230        }
2231    }
2232
2233    #[allow(irrefutable_let_patterns)]
2234    pub fn into_disable(self) -> Option<(ControlDisableResponder)> {
2235        if let ControlRequest::Disable { responder } = self {
2236            Some((responder))
2237        } else {
2238            None
2239        }
2240    }
2241
2242    #[allow(irrefutable_let_patterns)]
2243    pub fn into_detach(self) -> Option<(ControlControlHandle)> {
2244        if let ControlRequest::Detach { control_handle } = self {
2245            Some((control_handle))
2246        } else {
2247            None
2248        }
2249    }
2250
2251    #[allow(irrefutable_let_patterns)]
2252    pub fn into_get_authorization_for_interface(
2253        self,
2254    ) -> Option<(ControlGetAuthorizationForInterfaceResponder)> {
2255        if let ControlRequest::GetAuthorizationForInterface { responder } = self {
2256            Some((responder))
2257        } else {
2258            None
2259        }
2260    }
2261
2262    #[allow(irrefutable_let_patterns)]
2263    pub fn into_remove(self) -> Option<(ControlRemoveResponder)> {
2264        if let ControlRequest::Remove { responder } = self {
2265            Some((responder))
2266        } else {
2267            None
2268        }
2269    }
2270
2271    /// Name of the method defined in FIDL
2272    pub fn method_name(&self) -> &'static str {
2273        match *self {
2274            ControlRequest::AddAddress { .. } => "add_address",
2275            ControlRequest::RemoveAddress { .. } => "remove_address",
2276            ControlRequest::GetId { .. } => "get_id",
2277            ControlRequest::SetConfiguration { .. } => "set_configuration",
2278            ControlRequest::GetConfiguration { .. } => "get_configuration",
2279            ControlRequest::Enable { .. } => "enable",
2280            ControlRequest::Disable { .. } => "disable",
2281            ControlRequest::Detach { .. } => "detach",
2282            ControlRequest::GetAuthorizationForInterface { .. } => {
2283                "get_authorization_for_interface"
2284            }
2285            ControlRequest::Remove { .. } => "remove",
2286        }
2287    }
2288}
2289
2290#[derive(Debug, Clone)]
2291pub struct ControlControlHandle {
2292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2293}
2294
2295impl fidl::endpoints::ControlHandle for ControlControlHandle {
2296    fn shutdown(&self) {
2297        self.inner.shutdown()
2298    }
2299    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2300        self.inner.shutdown_with_epitaph(status)
2301    }
2302
2303    fn is_closed(&self) -> bool {
2304        self.inner.channel().is_closed()
2305    }
2306    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2307        self.inner.channel().on_closed()
2308    }
2309
2310    #[cfg(target_os = "fuchsia")]
2311    fn signal_peer(
2312        &self,
2313        clear_mask: zx::Signals,
2314        set_mask: zx::Signals,
2315    ) -> Result<(), zx_status::Status> {
2316        use fidl::Peered;
2317        self.inner.channel().signal_peer(clear_mask, set_mask)
2318    }
2319}
2320
2321impl ControlControlHandle {
2322    pub fn send_on_interface_removed(
2323        &self,
2324        mut reason: InterfaceRemovedReason,
2325    ) -> Result<(), fidl::Error> {
2326        self.inner.send::<ControlOnInterfaceRemovedRequest>(
2327            (reason,),
2328            0,
2329            0x800d39e76c1cddd,
2330            fidl::encoding::DynamicFlags::empty(),
2331        )
2332    }
2333}
2334
2335#[must_use = "FIDL methods require a response to be sent"]
2336#[derive(Debug)]
2337pub struct ControlRemoveAddressResponder {
2338    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2339    tx_id: u32,
2340}
2341
2342/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2343/// if the responder is dropped without sending a response, so that the client
2344/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2345impl std::ops::Drop for ControlRemoveAddressResponder {
2346    fn drop(&mut self) {
2347        self.control_handle.shutdown();
2348        // Safety: drops once, never accessed again
2349        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2350    }
2351}
2352
2353impl fidl::endpoints::Responder for ControlRemoveAddressResponder {
2354    type ControlHandle = ControlControlHandle;
2355
2356    fn control_handle(&self) -> &ControlControlHandle {
2357        &self.control_handle
2358    }
2359
2360    fn drop_without_shutdown(mut self) {
2361        // Safety: drops once, never accessed again due to mem::forget
2362        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2363        // Prevent Drop from running (which would shut down the channel)
2364        std::mem::forget(self);
2365    }
2366}
2367
2368impl ControlRemoveAddressResponder {
2369    /// Sends a response to the FIDL transaction.
2370    ///
2371    /// Sets the channel to shutdown if an error occurs.
2372    pub fn send(
2373        self,
2374        mut result: Result<bool, ControlRemoveAddressError>,
2375    ) -> Result<(), fidl::Error> {
2376        let _result = self.send_raw(result);
2377        if _result.is_err() {
2378            self.control_handle.shutdown();
2379        }
2380        self.drop_without_shutdown();
2381        _result
2382    }
2383
2384    /// Similar to "send" but does not shutdown the channel if an error occurs.
2385    pub fn send_no_shutdown_on_err(
2386        self,
2387        mut result: Result<bool, ControlRemoveAddressError>,
2388    ) -> Result<(), fidl::Error> {
2389        let _result = self.send_raw(result);
2390        self.drop_without_shutdown();
2391        _result
2392    }
2393
2394    fn send_raw(
2395        &self,
2396        mut result: Result<bool, ControlRemoveAddressError>,
2397    ) -> Result<(), fidl::Error> {
2398        self.control_handle.inner.send::<fidl::encoding::ResultType<
2399            ControlRemoveAddressResponse,
2400            ControlRemoveAddressError,
2401        >>(
2402            result.map(|did_remove| (did_remove,)),
2403            self.tx_id,
2404            0x213ba73da997a620,
2405            fidl::encoding::DynamicFlags::empty(),
2406        )
2407    }
2408}
2409
2410#[must_use = "FIDL methods require a response to be sent"]
2411#[derive(Debug)]
2412pub struct ControlGetIdResponder {
2413    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2414    tx_id: u32,
2415}
2416
2417/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2418/// if the responder is dropped without sending a response, so that the client
2419/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2420impl std::ops::Drop for ControlGetIdResponder {
2421    fn drop(&mut self) {
2422        self.control_handle.shutdown();
2423        // Safety: drops once, never accessed again
2424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2425    }
2426}
2427
2428impl fidl::endpoints::Responder for ControlGetIdResponder {
2429    type ControlHandle = ControlControlHandle;
2430
2431    fn control_handle(&self) -> &ControlControlHandle {
2432        &self.control_handle
2433    }
2434
2435    fn drop_without_shutdown(mut self) {
2436        // Safety: drops once, never accessed again due to mem::forget
2437        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2438        // Prevent Drop from running (which would shut down the channel)
2439        std::mem::forget(self);
2440    }
2441}
2442
2443impl ControlGetIdResponder {
2444    /// Sends a response to the FIDL transaction.
2445    ///
2446    /// Sets the channel to shutdown if an error occurs.
2447    pub fn send(self, mut id: u64) -> Result<(), fidl::Error> {
2448        let _result = self.send_raw(id);
2449        if _result.is_err() {
2450            self.control_handle.shutdown();
2451        }
2452        self.drop_without_shutdown();
2453        _result
2454    }
2455
2456    /// Similar to "send" but does not shutdown the channel if an error occurs.
2457    pub fn send_no_shutdown_on_err(self, mut id: u64) -> Result<(), fidl::Error> {
2458        let _result = self.send_raw(id);
2459        self.drop_without_shutdown();
2460        _result
2461    }
2462
2463    fn send_raw(&self, mut id: u64) -> Result<(), fidl::Error> {
2464        self.control_handle.inner.send::<ControlGetIdResponse>(
2465            (id,),
2466            self.tx_id,
2467            0x2a2459768d9ecc6f,
2468            fidl::encoding::DynamicFlags::empty(),
2469        )
2470    }
2471}
2472
2473#[must_use = "FIDL methods require a response to be sent"]
2474#[derive(Debug)]
2475pub struct ControlSetConfigurationResponder {
2476    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2477    tx_id: u32,
2478}
2479
2480/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2481/// if the responder is dropped without sending a response, so that the client
2482/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2483impl std::ops::Drop for ControlSetConfigurationResponder {
2484    fn drop(&mut self) {
2485        self.control_handle.shutdown();
2486        // Safety: drops once, never accessed again
2487        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2488    }
2489}
2490
2491impl fidl::endpoints::Responder for ControlSetConfigurationResponder {
2492    type ControlHandle = ControlControlHandle;
2493
2494    fn control_handle(&self) -> &ControlControlHandle {
2495        &self.control_handle
2496    }
2497
2498    fn drop_without_shutdown(mut self) {
2499        // Safety: drops once, never accessed again due to mem::forget
2500        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2501        // Prevent Drop from running (which would shut down the channel)
2502        std::mem::forget(self);
2503    }
2504}
2505
2506impl ControlSetConfigurationResponder {
2507    /// Sends a response to the FIDL transaction.
2508    ///
2509    /// Sets the channel to shutdown if an error occurs.
2510    pub fn send(
2511        self,
2512        mut result: Result<&Configuration, ControlSetConfigurationError>,
2513    ) -> Result<(), fidl::Error> {
2514        let _result = self.send_raw(result);
2515        if _result.is_err() {
2516            self.control_handle.shutdown();
2517        }
2518        self.drop_without_shutdown();
2519        _result
2520    }
2521
2522    /// Similar to "send" but does not shutdown the channel if an error occurs.
2523    pub fn send_no_shutdown_on_err(
2524        self,
2525        mut result: Result<&Configuration, ControlSetConfigurationError>,
2526    ) -> Result<(), fidl::Error> {
2527        let _result = self.send_raw(result);
2528        self.drop_without_shutdown();
2529        _result
2530    }
2531
2532    fn send_raw(
2533        &self,
2534        mut result: Result<&Configuration, ControlSetConfigurationError>,
2535    ) -> Result<(), fidl::Error> {
2536        self.control_handle.inner.send::<fidl::encoding::ResultType<
2537            ControlSetConfigurationResponse,
2538            ControlSetConfigurationError,
2539        >>(
2540            result.map(|previous_config| (previous_config,)),
2541            self.tx_id,
2542            0x573923b7b4bde27f,
2543            fidl::encoding::DynamicFlags::empty(),
2544        )
2545    }
2546}
2547
2548#[must_use = "FIDL methods require a response to be sent"]
2549#[derive(Debug)]
2550pub struct ControlGetConfigurationResponder {
2551    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2552    tx_id: u32,
2553}
2554
2555/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2556/// if the responder is dropped without sending a response, so that the client
2557/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2558impl std::ops::Drop for ControlGetConfigurationResponder {
2559    fn drop(&mut self) {
2560        self.control_handle.shutdown();
2561        // Safety: drops once, never accessed again
2562        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2563    }
2564}
2565
2566impl fidl::endpoints::Responder for ControlGetConfigurationResponder {
2567    type ControlHandle = ControlControlHandle;
2568
2569    fn control_handle(&self) -> &ControlControlHandle {
2570        &self.control_handle
2571    }
2572
2573    fn drop_without_shutdown(mut self) {
2574        // Safety: drops once, never accessed again due to mem::forget
2575        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2576        // Prevent Drop from running (which would shut down the channel)
2577        std::mem::forget(self);
2578    }
2579}
2580
2581impl ControlGetConfigurationResponder {
2582    /// Sends a response to the FIDL transaction.
2583    ///
2584    /// Sets the channel to shutdown if an error occurs.
2585    pub fn send(
2586        self,
2587        mut result: Result<&Configuration, ControlGetConfigurationError>,
2588    ) -> Result<(), fidl::Error> {
2589        let _result = self.send_raw(result);
2590        if _result.is_err() {
2591            self.control_handle.shutdown();
2592        }
2593        self.drop_without_shutdown();
2594        _result
2595    }
2596
2597    /// Similar to "send" but does not shutdown the channel if an error occurs.
2598    pub fn send_no_shutdown_on_err(
2599        self,
2600        mut result: Result<&Configuration, ControlGetConfigurationError>,
2601    ) -> Result<(), fidl::Error> {
2602        let _result = self.send_raw(result);
2603        self.drop_without_shutdown();
2604        _result
2605    }
2606
2607    fn send_raw(
2608        &self,
2609        mut result: Result<&Configuration, ControlGetConfigurationError>,
2610    ) -> Result<(), fidl::Error> {
2611        self.control_handle.inner.send::<fidl::encoding::ResultType<
2612            ControlGetConfigurationResponse,
2613            ControlGetConfigurationError,
2614        >>(
2615            result.map(|config| (config,)),
2616            self.tx_id,
2617            0x5f5d239820bdcc65,
2618            fidl::encoding::DynamicFlags::empty(),
2619        )
2620    }
2621}
2622
2623#[must_use = "FIDL methods require a response to be sent"]
2624#[derive(Debug)]
2625pub struct ControlEnableResponder {
2626    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2627    tx_id: u32,
2628}
2629
2630/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2631/// if the responder is dropped without sending a response, so that the client
2632/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2633impl std::ops::Drop for ControlEnableResponder {
2634    fn drop(&mut self) {
2635        self.control_handle.shutdown();
2636        // Safety: drops once, never accessed again
2637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2638    }
2639}
2640
2641impl fidl::endpoints::Responder for ControlEnableResponder {
2642    type ControlHandle = ControlControlHandle;
2643
2644    fn control_handle(&self) -> &ControlControlHandle {
2645        &self.control_handle
2646    }
2647
2648    fn drop_without_shutdown(mut self) {
2649        // Safety: drops once, never accessed again due to mem::forget
2650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2651        // Prevent Drop from running (which would shut down the channel)
2652        std::mem::forget(self);
2653    }
2654}
2655
2656impl ControlEnableResponder {
2657    /// Sends a response to the FIDL transaction.
2658    ///
2659    /// Sets the channel to shutdown if an error occurs.
2660    pub fn send(self, mut result: Result<bool, ControlEnableError>) -> Result<(), fidl::Error> {
2661        let _result = self.send_raw(result);
2662        if _result.is_err() {
2663            self.control_handle.shutdown();
2664        }
2665        self.drop_without_shutdown();
2666        _result
2667    }
2668
2669    /// Similar to "send" but does not shutdown the channel if an error occurs.
2670    pub fn send_no_shutdown_on_err(
2671        self,
2672        mut result: Result<bool, ControlEnableError>,
2673    ) -> Result<(), fidl::Error> {
2674        let _result = self.send_raw(result);
2675        self.drop_without_shutdown();
2676        _result
2677    }
2678
2679    fn send_raw(&self, mut result: Result<bool, ControlEnableError>) -> Result<(), fidl::Error> {
2680        self.control_handle.inner.send::<fidl::encoding::ResultType<
2681            ControlEnableResponse,
2682            ControlEnableError,
2683        >>(
2684            result.map(|did_enable| (did_enable,)),
2685            self.tx_id,
2686            0x15c983d3a8ac0b98,
2687            fidl::encoding::DynamicFlags::empty(),
2688        )
2689    }
2690}
2691
2692#[must_use = "FIDL methods require a response to be sent"]
2693#[derive(Debug)]
2694pub struct ControlDisableResponder {
2695    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2696    tx_id: u32,
2697}
2698
2699/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2700/// if the responder is dropped without sending a response, so that the client
2701/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2702impl std::ops::Drop for ControlDisableResponder {
2703    fn drop(&mut self) {
2704        self.control_handle.shutdown();
2705        // Safety: drops once, never accessed again
2706        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2707    }
2708}
2709
2710impl fidl::endpoints::Responder for ControlDisableResponder {
2711    type ControlHandle = ControlControlHandle;
2712
2713    fn control_handle(&self) -> &ControlControlHandle {
2714        &self.control_handle
2715    }
2716
2717    fn drop_without_shutdown(mut self) {
2718        // Safety: drops once, never accessed again due to mem::forget
2719        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2720        // Prevent Drop from running (which would shut down the channel)
2721        std::mem::forget(self);
2722    }
2723}
2724
2725impl ControlDisableResponder {
2726    /// Sends a response to the FIDL transaction.
2727    ///
2728    /// Sets the channel to shutdown if an error occurs.
2729    pub fn send(self, mut result: Result<bool, ControlDisableError>) -> Result<(), fidl::Error> {
2730        let _result = self.send_raw(result);
2731        if _result.is_err() {
2732            self.control_handle.shutdown();
2733        }
2734        self.drop_without_shutdown();
2735        _result
2736    }
2737
2738    /// Similar to "send" but does not shutdown the channel if an error occurs.
2739    pub fn send_no_shutdown_on_err(
2740        self,
2741        mut result: Result<bool, ControlDisableError>,
2742    ) -> Result<(), fidl::Error> {
2743        let _result = self.send_raw(result);
2744        self.drop_without_shutdown();
2745        _result
2746    }
2747
2748    fn send_raw(&self, mut result: Result<bool, ControlDisableError>) -> Result<(), fidl::Error> {
2749        self.control_handle.inner.send::<fidl::encoding::ResultType<
2750            ControlDisableResponse,
2751            ControlDisableError,
2752        >>(
2753            result.map(|did_disable| (did_disable,)),
2754            self.tx_id,
2755            0x98d3a585d905473,
2756            fidl::encoding::DynamicFlags::empty(),
2757        )
2758    }
2759}
2760
2761#[must_use = "FIDL methods require a response to be sent"]
2762#[derive(Debug)]
2763pub struct ControlGetAuthorizationForInterfaceResponder {
2764    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2765    tx_id: u32,
2766}
2767
2768/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2769/// if the responder is dropped without sending a response, so that the client
2770/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2771impl std::ops::Drop for ControlGetAuthorizationForInterfaceResponder {
2772    fn drop(&mut self) {
2773        self.control_handle.shutdown();
2774        // Safety: drops once, never accessed again
2775        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2776    }
2777}
2778
2779impl fidl::endpoints::Responder for ControlGetAuthorizationForInterfaceResponder {
2780    type ControlHandle = ControlControlHandle;
2781
2782    fn control_handle(&self) -> &ControlControlHandle {
2783        &self.control_handle
2784    }
2785
2786    fn drop_without_shutdown(mut self) {
2787        // Safety: drops once, never accessed again due to mem::forget
2788        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2789        // Prevent Drop from running (which would shut down the channel)
2790        std::mem::forget(self);
2791    }
2792}
2793
2794impl ControlGetAuthorizationForInterfaceResponder {
2795    /// Sends a response to the FIDL transaction.
2796    ///
2797    /// Sets the channel to shutdown if an error occurs.
2798    pub fn send(self, mut credential: GrantForInterfaceAuthorization) -> Result<(), fidl::Error> {
2799        let _result = self.send_raw(credential);
2800        if _result.is_err() {
2801            self.control_handle.shutdown();
2802        }
2803        self.drop_without_shutdown();
2804        _result
2805    }
2806
2807    /// Similar to "send" but does not shutdown the channel if an error occurs.
2808    pub fn send_no_shutdown_on_err(
2809        self,
2810        mut credential: GrantForInterfaceAuthorization,
2811    ) -> Result<(), fidl::Error> {
2812        let _result = self.send_raw(credential);
2813        self.drop_without_shutdown();
2814        _result
2815    }
2816
2817    fn send_raw(&self, mut credential: GrantForInterfaceAuthorization) -> Result<(), fidl::Error> {
2818        self.control_handle.inner.send::<ControlGetAuthorizationForInterfaceResponse>(
2819            (&mut credential,),
2820            self.tx_id,
2821            0xc1de2ab60b5cb9e,
2822            fidl::encoding::DynamicFlags::empty(),
2823        )
2824    }
2825}
2826
2827#[must_use = "FIDL methods require a response to be sent"]
2828#[derive(Debug)]
2829pub struct ControlRemoveResponder {
2830    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2831    tx_id: u32,
2832}
2833
2834/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2835/// if the responder is dropped without sending a response, so that the client
2836/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2837impl std::ops::Drop for ControlRemoveResponder {
2838    fn drop(&mut self) {
2839        self.control_handle.shutdown();
2840        // Safety: drops once, never accessed again
2841        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2842    }
2843}
2844
2845impl fidl::endpoints::Responder for ControlRemoveResponder {
2846    type ControlHandle = ControlControlHandle;
2847
2848    fn control_handle(&self) -> &ControlControlHandle {
2849        &self.control_handle
2850    }
2851
2852    fn drop_without_shutdown(mut self) {
2853        // Safety: drops once, never accessed again due to mem::forget
2854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2855        // Prevent Drop from running (which would shut down the channel)
2856        std::mem::forget(self);
2857    }
2858}
2859
2860impl ControlRemoveResponder {
2861    /// Sends a response to the FIDL transaction.
2862    ///
2863    /// Sets the channel to shutdown if an error occurs.
2864    pub fn send(self, mut result: Result<(), ControlRemoveError>) -> Result<(), fidl::Error> {
2865        let _result = self.send_raw(result);
2866        if _result.is_err() {
2867            self.control_handle.shutdown();
2868        }
2869        self.drop_without_shutdown();
2870        _result
2871    }
2872
2873    /// Similar to "send" but does not shutdown the channel if an error occurs.
2874    pub fn send_no_shutdown_on_err(
2875        self,
2876        mut result: Result<(), ControlRemoveError>,
2877    ) -> Result<(), fidl::Error> {
2878        let _result = self.send_raw(result);
2879        self.drop_without_shutdown();
2880        _result
2881    }
2882
2883    fn send_raw(&self, mut result: Result<(), ControlRemoveError>) -> Result<(), fidl::Error> {
2884        self.control_handle.inner.send::<fidl::encoding::ResultType<
2885            fidl::encoding::EmptyStruct,
2886            ControlRemoveError,
2887        >>(
2888            result,
2889            self.tx_id,
2890            0x13aab8bbecc7ff0b,
2891            fidl::encoding::DynamicFlags::empty(),
2892        )
2893    }
2894}
2895
2896#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2897pub struct DeviceControlMarker;
2898
2899impl fidl::endpoints::ProtocolMarker for DeviceControlMarker {
2900    type Proxy = DeviceControlProxy;
2901    type RequestStream = DeviceControlRequestStream;
2902    #[cfg(target_os = "fuchsia")]
2903    type SynchronousProxy = DeviceControlSynchronousProxy;
2904
2905    const DEBUG_NAME: &'static str = "(anonymous) DeviceControl";
2906}
2907
2908pub trait DeviceControlProxyInterface: Send + Sync {
2909    fn r#create_interface(
2910        &self,
2911        port: &fidl_fuchsia_hardware_network::PortId,
2912        control: fidl::endpoints::ServerEnd<ControlMarker>,
2913        options: Options,
2914    ) -> Result<(), fidl::Error>;
2915    fn r#detach(&self) -> Result<(), fidl::Error>;
2916}
2917#[derive(Debug)]
2918#[cfg(target_os = "fuchsia")]
2919pub struct DeviceControlSynchronousProxy {
2920    client: fidl::client::sync::Client,
2921}
2922
2923#[cfg(target_os = "fuchsia")]
2924impl fidl::endpoints::SynchronousProxy for DeviceControlSynchronousProxy {
2925    type Proxy = DeviceControlProxy;
2926    type Protocol = DeviceControlMarker;
2927
2928    fn from_channel(inner: fidl::Channel) -> Self {
2929        Self::new(inner)
2930    }
2931
2932    fn into_channel(self) -> fidl::Channel {
2933        self.client.into_channel()
2934    }
2935
2936    fn as_channel(&self) -> &fidl::Channel {
2937        self.client.as_channel()
2938    }
2939}
2940
2941#[cfg(target_os = "fuchsia")]
2942impl DeviceControlSynchronousProxy {
2943    pub fn new(channel: fidl::Channel) -> Self {
2944        let protocol_name = <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2945        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2946    }
2947
2948    pub fn into_channel(self) -> fidl::Channel {
2949        self.client.into_channel()
2950    }
2951
2952    /// Waits until an event arrives and returns it. It is safe for other
2953    /// threads to make concurrent requests while waiting for an event.
2954    pub fn wait_for_event(
2955        &self,
2956        deadline: zx::MonotonicInstant,
2957    ) -> Result<DeviceControlEvent, fidl::Error> {
2958        DeviceControlEvent::decode(self.client.wait_for_event(deadline)?)
2959    }
2960
2961    /// Creates an interface on the network stack.
2962    ///
2963    /// + request `port` the device's port to instantiate as an interface.
2964    /// + request `control` grants access to the created interface.
2965    pub fn r#create_interface(
2966        &self,
2967        mut port: &fidl_fuchsia_hardware_network::PortId,
2968        mut control: fidl::endpoints::ServerEnd<ControlMarker>,
2969        mut options: Options,
2970    ) -> Result<(), fidl::Error> {
2971        self.client.send::<DeviceControlCreateInterfaceRequest>(
2972            (port, control, &mut options),
2973            0x4ff8be7351d12f86,
2974            fidl::encoding::DynamicFlags::empty(),
2975        )
2976    }
2977
2978    /// Detaches the client end from the device's lifetime.
2979    ///
2980    /// After calling `Detach`, closing this client end no longer causes the
2981    /// device or any of the interfaces created from it to be removed. Note that
2982    /// the lifetime of any created interface will continue to be coupled with
2983    /// the associated [`Control`] client end.
2984    pub fn r#detach(&self) -> Result<(), fidl::Error> {
2985        self.client.send::<fidl::encoding::EmptyPayload>(
2986            (),
2987            0x57489f1554d489d2,
2988            fidl::encoding::DynamicFlags::empty(),
2989        )
2990    }
2991}
2992
2993#[cfg(target_os = "fuchsia")]
2994impl From<DeviceControlSynchronousProxy> for zx::Handle {
2995    fn from(value: DeviceControlSynchronousProxy) -> Self {
2996        value.into_channel().into()
2997    }
2998}
2999
3000#[cfg(target_os = "fuchsia")]
3001impl From<fidl::Channel> for DeviceControlSynchronousProxy {
3002    fn from(value: fidl::Channel) -> Self {
3003        Self::new(value)
3004    }
3005}
3006
3007#[derive(Debug, Clone)]
3008pub struct DeviceControlProxy {
3009    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3010}
3011
3012impl fidl::endpoints::Proxy for DeviceControlProxy {
3013    type Protocol = DeviceControlMarker;
3014
3015    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3016        Self::new(inner)
3017    }
3018
3019    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3020        self.client.into_channel().map_err(|client| Self { client })
3021    }
3022
3023    fn as_channel(&self) -> &::fidl::AsyncChannel {
3024        self.client.as_channel()
3025    }
3026}
3027
3028impl DeviceControlProxy {
3029    /// Create a new Proxy for fuchsia.net.interfaces.admin/DeviceControl.
3030    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3031        let protocol_name = <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3032        Self { client: fidl::client::Client::new(channel, protocol_name) }
3033    }
3034
3035    /// Get a Stream of events from the remote end of the protocol.
3036    ///
3037    /// # Panics
3038    ///
3039    /// Panics if the event stream was already taken.
3040    pub fn take_event_stream(&self) -> DeviceControlEventStream {
3041        DeviceControlEventStream { event_receiver: self.client.take_event_receiver() }
3042    }
3043
3044    /// Creates an interface on the network stack.
3045    ///
3046    /// + request `port` the device's port to instantiate as an interface.
3047    /// + request `control` grants access to the created interface.
3048    pub fn r#create_interface(
3049        &self,
3050        mut port: &fidl_fuchsia_hardware_network::PortId,
3051        mut control: fidl::endpoints::ServerEnd<ControlMarker>,
3052        mut options: Options,
3053    ) -> Result<(), fidl::Error> {
3054        DeviceControlProxyInterface::r#create_interface(self, port, control, options)
3055    }
3056
3057    /// Detaches the client end from the device's lifetime.
3058    ///
3059    /// After calling `Detach`, closing this client end no longer causes the
3060    /// device or any of the interfaces created from it to be removed. Note that
3061    /// the lifetime of any created interface will continue to be coupled with
3062    /// the associated [`Control`] client end.
3063    pub fn r#detach(&self) -> Result<(), fidl::Error> {
3064        DeviceControlProxyInterface::r#detach(self)
3065    }
3066}
3067
3068impl DeviceControlProxyInterface for DeviceControlProxy {
3069    fn r#create_interface(
3070        &self,
3071        mut port: &fidl_fuchsia_hardware_network::PortId,
3072        mut control: fidl::endpoints::ServerEnd<ControlMarker>,
3073        mut options: Options,
3074    ) -> Result<(), fidl::Error> {
3075        self.client.send::<DeviceControlCreateInterfaceRequest>(
3076            (port, control, &mut options),
3077            0x4ff8be7351d12f86,
3078            fidl::encoding::DynamicFlags::empty(),
3079        )
3080    }
3081
3082    fn r#detach(&self) -> Result<(), fidl::Error> {
3083        self.client.send::<fidl::encoding::EmptyPayload>(
3084            (),
3085            0x57489f1554d489d2,
3086            fidl::encoding::DynamicFlags::empty(),
3087        )
3088    }
3089}
3090
3091pub struct DeviceControlEventStream {
3092    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3093}
3094
3095impl std::marker::Unpin for DeviceControlEventStream {}
3096
3097impl futures::stream::FusedStream for DeviceControlEventStream {
3098    fn is_terminated(&self) -> bool {
3099        self.event_receiver.is_terminated()
3100    }
3101}
3102
3103impl futures::Stream for DeviceControlEventStream {
3104    type Item = Result<DeviceControlEvent, fidl::Error>;
3105
3106    fn poll_next(
3107        mut self: std::pin::Pin<&mut Self>,
3108        cx: &mut std::task::Context<'_>,
3109    ) -> std::task::Poll<Option<Self::Item>> {
3110        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3111            &mut self.event_receiver,
3112            cx
3113        )?) {
3114            Some(buf) => std::task::Poll::Ready(Some(DeviceControlEvent::decode(buf))),
3115            None => std::task::Poll::Ready(None),
3116        }
3117    }
3118}
3119
3120#[derive(Debug)]
3121pub enum DeviceControlEvent {}
3122
3123impl DeviceControlEvent {
3124    /// Decodes a message buffer as a [`DeviceControlEvent`].
3125    fn decode(
3126        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3127    ) -> Result<DeviceControlEvent, fidl::Error> {
3128        let (bytes, _handles) = buf.split_mut();
3129        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3130        debug_assert_eq!(tx_header.tx_id, 0);
3131        match tx_header.ordinal {
3132            _ => Err(fidl::Error::UnknownOrdinal {
3133                ordinal: tx_header.ordinal,
3134                protocol_name: <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3135            }),
3136        }
3137    }
3138}
3139
3140/// A Stream of incoming requests for fuchsia.net.interfaces.admin/DeviceControl.
3141pub struct DeviceControlRequestStream {
3142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3143    is_terminated: bool,
3144}
3145
3146impl std::marker::Unpin for DeviceControlRequestStream {}
3147
3148impl futures::stream::FusedStream for DeviceControlRequestStream {
3149    fn is_terminated(&self) -> bool {
3150        self.is_terminated
3151    }
3152}
3153
3154impl fidl::endpoints::RequestStream for DeviceControlRequestStream {
3155    type Protocol = DeviceControlMarker;
3156    type ControlHandle = DeviceControlControlHandle;
3157
3158    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3159        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3160    }
3161
3162    fn control_handle(&self) -> Self::ControlHandle {
3163        DeviceControlControlHandle { inner: self.inner.clone() }
3164    }
3165
3166    fn into_inner(
3167        self,
3168    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3169    {
3170        (self.inner, self.is_terminated)
3171    }
3172
3173    fn from_inner(
3174        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3175        is_terminated: bool,
3176    ) -> Self {
3177        Self { inner, is_terminated }
3178    }
3179}
3180
3181impl futures::Stream for DeviceControlRequestStream {
3182    type Item = Result<DeviceControlRequest, fidl::Error>;
3183
3184    fn poll_next(
3185        mut self: std::pin::Pin<&mut Self>,
3186        cx: &mut std::task::Context<'_>,
3187    ) -> std::task::Poll<Option<Self::Item>> {
3188        let this = &mut *self;
3189        if this.inner.check_shutdown(cx) {
3190            this.is_terminated = true;
3191            return std::task::Poll::Ready(None);
3192        }
3193        if this.is_terminated {
3194            panic!("polled DeviceControlRequestStream after completion");
3195        }
3196        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3197            |bytes, handles| {
3198                match this.inner.channel().read_etc(cx, bytes, handles) {
3199                    std::task::Poll::Ready(Ok(())) => {}
3200                    std::task::Poll::Pending => return std::task::Poll::Pending,
3201                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3202                        this.is_terminated = true;
3203                        return std::task::Poll::Ready(None);
3204                    }
3205                    std::task::Poll::Ready(Err(e)) => {
3206                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3207                            e.into(),
3208                        ))))
3209                    }
3210                }
3211
3212                // A message has been received from the channel
3213                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3214
3215                std::task::Poll::Ready(Some(match header.ordinal {
3216                    0x4ff8be7351d12f86 => {
3217                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3218                        let mut req = fidl::new_empty!(
3219                            DeviceControlCreateInterfaceRequest,
3220                            fidl::encoding::DefaultFuchsiaResourceDialect
3221                        );
3222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceControlCreateInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
3223                        let control_handle =
3224                            DeviceControlControlHandle { inner: this.inner.clone() };
3225                        Ok(DeviceControlRequest::CreateInterface {
3226                            port: req.port,
3227                            control: req.control,
3228                            options: req.options,
3229
3230                            control_handle,
3231                        })
3232                    }
3233                    0x57489f1554d489d2 => {
3234                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3235                        let mut req = fidl::new_empty!(
3236                            fidl::encoding::EmptyPayload,
3237                            fidl::encoding::DefaultFuchsiaResourceDialect
3238                        );
3239                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3240                        let control_handle =
3241                            DeviceControlControlHandle { inner: this.inner.clone() };
3242                        Ok(DeviceControlRequest::Detach { control_handle })
3243                    }
3244                    _ => Err(fidl::Error::UnknownOrdinal {
3245                        ordinal: header.ordinal,
3246                        protocol_name:
3247                            <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3248                    }),
3249                }))
3250            },
3251        )
3252    }
3253}
3254
3255/// Administrative control over an installed device on the network stack.
3256///
3257/// An instance of `DeviceControl` maps to an instance of
3258/// [`fuchsia.hardware.network/Session`]. All interfaces generated from a single
3259/// `DeviceControl` instance share the same `Session` and set of device buffers;
3260/// and are therefore subject to backpressure over the same pool of resources.
3261///
3262/// By the same measure, creating multiple `DeviceControl` instances attached to
3263/// the same underlying device causes data copies, because each `DeviceControl`
3264/// starts a new `Session`. For that reason, users should avoid creating
3265/// multiple `DeviceControl` instances for the same device and prefer
3266/// instantiating ports into interfaces from a single `DeviceControl` instance
3267/// per device.
3268///
3269/// This protocol encodes the underlying device's lifetime in both
3270/// directions; the device exists iff both ends of the protocol are open.
3271/// That is:
3272///
3273/// - Closing the client end causes the device to be removed, including all
3274///   interfaces created from it.
3275/// - Observing a closure of the server end indicates the device (and all
3276///   interfaces created from it) no longer exists.
3277#[derive(Debug)]
3278pub enum DeviceControlRequest {
3279    /// Creates an interface on the network stack.
3280    ///
3281    /// + request `port` the device's port to instantiate as an interface.
3282    /// + request `control` grants access to the created interface.
3283    CreateInterface {
3284        port: fidl_fuchsia_hardware_network::PortId,
3285        control: fidl::endpoints::ServerEnd<ControlMarker>,
3286        options: Options,
3287        control_handle: DeviceControlControlHandle,
3288    },
3289    /// Detaches the client end from the device's lifetime.
3290    ///
3291    /// After calling `Detach`, closing this client end no longer causes the
3292    /// device or any of the interfaces created from it to be removed. Note that
3293    /// the lifetime of any created interface will continue to be coupled with
3294    /// the associated [`Control`] client end.
3295    Detach { control_handle: DeviceControlControlHandle },
3296}
3297
3298impl DeviceControlRequest {
3299    #[allow(irrefutable_let_patterns)]
3300    pub fn into_create_interface(
3301        self,
3302    ) -> Option<(
3303        fidl_fuchsia_hardware_network::PortId,
3304        fidl::endpoints::ServerEnd<ControlMarker>,
3305        Options,
3306        DeviceControlControlHandle,
3307    )> {
3308        if let DeviceControlRequest::CreateInterface { port, control, options, control_handle } =
3309            self
3310        {
3311            Some((port, control, options, control_handle))
3312        } else {
3313            None
3314        }
3315    }
3316
3317    #[allow(irrefutable_let_patterns)]
3318    pub fn into_detach(self) -> Option<(DeviceControlControlHandle)> {
3319        if let DeviceControlRequest::Detach { control_handle } = self {
3320            Some((control_handle))
3321        } else {
3322            None
3323        }
3324    }
3325
3326    /// Name of the method defined in FIDL
3327    pub fn method_name(&self) -> &'static str {
3328        match *self {
3329            DeviceControlRequest::CreateInterface { .. } => "create_interface",
3330            DeviceControlRequest::Detach { .. } => "detach",
3331        }
3332    }
3333}
3334
3335#[derive(Debug, Clone)]
3336pub struct DeviceControlControlHandle {
3337    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3338}
3339
3340impl fidl::endpoints::ControlHandle for DeviceControlControlHandle {
3341    fn shutdown(&self) {
3342        self.inner.shutdown()
3343    }
3344    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3345        self.inner.shutdown_with_epitaph(status)
3346    }
3347
3348    fn is_closed(&self) -> bool {
3349        self.inner.channel().is_closed()
3350    }
3351    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3352        self.inner.channel().on_closed()
3353    }
3354
3355    #[cfg(target_os = "fuchsia")]
3356    fn signal_peer(
3357        &self,
3358        clear_mask: zx::Signals,
3359        set_mask: zx::Signals,
3360    ) -> Result<(), zx_status::Status> {
3361        use fidl::Peered;
3362        self.inner.channel().signal_peer(clear_mask, set_mask)
3363    }
3364}
3365
3366impl DeviceControlControlHandle {}
3367
3368#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3369pub struct InstallerMarker;
3370
3371impl fidl::endpoints::ProtocolMarker for InstallerMarker {
3372    type Proxy = InstallerProxy;
3373    type RequestStream = InstallerRequestStream;
3374    #[cfg(target_os = "fuchsia")]
3375    type SynchronousProxy = InstallerSynchronousProxy;
3376
3377    const DEBUG_NAME: &'static str = "fuchsia.net.interfaces.admin.Installer";
3378}
3379impl fidl::endpoints::DiscoverableProtocolMarker for InstallerMarker {}
3380
3381pub trait InstallerProxyInterface: Send + Sync {
3382    fn r#install_device(
3383        &self,
3384        device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3385        device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
3386    ) -> Result<(), fidl::Error>;
3387    fn r#install_blackhole_interface(
3388        &self,
3389        interface: fidl::endpoints::ServerEnd<ControlMarker>,
3390        options: Options,
3391    ) -> Result<(), fidl::Error>;
3392}
3393#[derive(Debug)]
3394#[cfg(target_os = "fuchsia")]
3395pub struct InstallerSynchronousProxy {
3396    client: fidl::client::sync::Client,
3397}
3398
3399#[cfg(target_os = "fuchsia")]
3400impl fidl::endpoints::SynchronousProxy for InstallerSynchronousProxy {
3401    type Proxy = InstallerProxy;
3402    type Protocol = InstallerMarker;
3403
3404    fn from_channel(inner: fidl::Channel) -> Self {
3405        Self::new(inner)
3406    }
3407
3408    fn into_channel(self) -> fidl::Channel {
3409        self.client.into_channel()
3410    }
3411
3412    fn as_channel(&self) -> &fidl::Channel {
3413        self.client.as_channel()
3414    }
3415}
3416
3417#[cfg(target_os = "fuchsia")]
3418impl InstallerSynchronousProxy {
3419    pub fn new(channel: fidl::Channel) -> Self {
3420        let protocol_name = <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3421        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3422    }
3423
3424    pub fn into_channel(self) -> fidl::Channel {
3425        self.client.into_channel()
3426    }
3427
3428    /// Waits until an event arrives and returns it. It is safe for other
3429    /// threads to make concurrent requests while waiting for an event.
3430    pub fn wait_for_event(
3431        &self,
3432        deadline: zx::MonotonicInstant,
3433    ) -> Result<InstallerEvent, fidl::Error> {
3434        InstallerEvent::decode(self.client.wait_for_event(deadline)?)
3435    }
3436
3437    /// Installs a device on the network stack.
3438    ///
3439    /// + request `device` the device to install on the network stack.
3440    /// + request `device_control` grants access to the installed device.
3441    pub fn r#install_device(
3442        &self,
3443        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3444        mut device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
3445    ) -> Result<(), fidl::Error> {
3446        self.client.send::<InstallerInstallDeviceRequest>(
3447            (device, device_control),
3448            0x3e84524dcecab23a,
3449            fidl::encoding::DynamicFlags::empty(),
3450        )
3451    }
3452
3453    /// Installs a blackhole interface on the network stack.
3454    ///
3455    /// A "blackhole" interface is an interface that drops any outbound traffic
3456    /// transmitted through it, and never receives any inbound traffic.
3457    ///
3458    /// + request `interface` grants access to the installed interface.
3459    pub fn r#install_blackhole_interface(
3460        &self,
3461        mut interface: fidl::endpoints::ServerEnd<ControlMarker>,
3462        mut options: Options,
3463    ) -> Result<(), fidl::Error> {
3464        self.client.send::<InstallerInstallBlackholeInterfaceRequest>(
3465            (interface, &mut options),
3466            0x2ce57e87cdbcb809,
3467            fidl::encoding::DynamicFlags::empty(),
3468        )
3469    }
3470}
3471
3472#[cfg(target_os = "fuchsia")]
3473impl From<InstallerSynchronousProxy> for zx::Handle {
3474    fn from(value: InstallerSynchronousProxy) -> Self {
3475        value.into_channel().into()
3476    }
3477}
3478
3479#[cfg(target_os = "fuchsia")]
3480impl From<fidl::Channel> for InstallerSynchronousProxy {
3481    fn from(value: fidl::Channel) -> Self {
3482        Self::new(value)
3483    }
3484}
3485
3486#[derive(Debug, Clone)]
3487pub struct InstallerProxy {
3488    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3489}
3490
3491impl fidl::endpoints::Proxy for InstallerProxy {
3492    type Protocol = InstallerMarker;
3493
3494    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3495        Self::new(inner)
3496    }
3497
3498    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3499        self.client.into_channel().map_err(|client| Self { client })
3500    }
3501
3502    fn as_channel(&self) -> &::fidl::AsyncChannel {
3503        self.client.as_channel()
3504    }
3505}
3506
3507impl InstallerProxy {
3508    /// Create a new Proxy for fuchsia.net.interfaces.admin/Installer.
3509    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3510        let protocol_name = <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3511        Self { client: fidl::client::Client::new(channel, protocol_name) }
3512    }
3513
3514    /// Get a Stream of events from the remote end of the protocol.
3515    ///
3516    /// # Panics
3517    ///
3518    /// Panics if the event stream was already taken.
3519    pub fn take_event_stream(&self) -> InstallerEventStream {
3520        InstallerEventStream { event_receiver: self.client.take_event_receiver() }
3521    }
3522
3523    /// Installs a device on the network stack.
3524    ///
3525    /// + request `device` the device to install on the network stack.
3526    /// + request `device_control` grants access to the installed device.
3527    pub fn r#install_device(
3528        &self,
3529        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3530        mut device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
3531    ) -> Result<(), fidl::Error> {
3532        InstallerProxyInterface::r#install_device(self, device, device_control)
3533    }
3534
3535    /// Installs a blackhole interface on the network stack.
3536    ///
3537    /// A "blackhole" interface is an interface that drops any outbound traffic
3538    /// transmitted through it, and never receives any inbound traffic.
3539    ///
3540    /// + request `interface` grants access to the installed interface.
3541    pub fn r#install_blackhole_interface(
3542        &self,
3543        mut interface: fidl::endpoints::ServerEnd<ControlMarker>,
3544        mut options: Options,
3545    ) -> Result<(), fidl::Error> {
3546        InstallerProxyInterface::r#install_blackhole_interface(self, interface, options)
3547    }
3548}
3549
3550impl InstallerProxyInterface for InstallerProxy {
3551    fn r#install_device(
3552        &self,
3553        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3554        mut device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
3555    ) -> Result<(), fidl::Error> {
3556        self.client.send::<InstallerInstallDeviceRequest>(
3557            (device, device_control),
3558            0x3e84524dcecab23a,
3559            fidl::encoding::DynamicFlags::empty(),
3560        )
3561    }
3562
3563    fn r#install_blackhole_interface(
3564        &self,
3565        mut interface: fidl::endpoints::ServerEnd<ControlMarker>,
3566        mut options: Options,
3567    ) -> Result<(), fidl::Error> {
3568        self.client.send::<InstallerInstallBlackholeInterfaceRequest>(
3569            (interface, &mut options),
3570            0x2ce57e87cdbcb809,
3571            fidl::encoding::DynamicFlags::empty(),
3572        )
3573    }
3574}
3575
3576pub struct InstallerEventStream {
3577    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3578}
3579
3580impl std::marker::Unpin for InstallerEventStream {}
3581
3582impl futures::stream::FusedStream for InstallerEventStream {
3583    fn is_terminated(&self) -> bool {
3584        self.event_receiver.is_terminated()
3585    }
3586}
3587
3588impl futures::Stream for InstallerEventStream {
3589    type Item = Result<InstallerEvent, fidl::Error>;
3590
3591    fn poll_next(
3592        mut self: std::pin::Pin<&mut Self>,
3593        cx: &mut std::task::Context<'_>,
3594    ) -> std::task::Poll<Option<Self::Item>> {
3595        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3596            &mut self.event_receiver,
3597            cx
3598        )?) {
3599            Some(buf) => std::task::Poll::Ready(Some(InstallerEvent::decode(buf))),
3600            None => std::task::Poll::Ready(None),
3601        }
3602    }
3603}
3604
3605#[derive(Debug)]
3606pub enum InstallerEvent {}
3607
3608impl InstallerEvent {
3609    /// Decodes a message buffer as a [`InstallerEvent`].
3610    fn decode(
3611        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3612    ) -> Result<InstallerEvent, fidl::Error> {
3613        let (bytes, _handles) = buf.split_mut();
3614        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3615        debug_assert_eq!(tx_header.tx_id, 0);
3616        match tx_header.ordinal {
3617            _ => Err(fidl::Error::UnknownOrdinal {
3618                ordinal: tx_header.ordinal,
3619                protocol_name: <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3620            }),
3621        }
3622    }
3623}
3624
3625/// A Stream of incoming requests for fuchsia.net.interfaces.admin/Installer.
3626pub struct InstallerRequestStream {
3627    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3628    is_terminated: bool,
3629}
3630
3631impl std::marker::Unpin for InstallerRequestStream {}
3632
3633impl futures::stream::FusedStream for InstallerRequestStream {
3634    fn is_terminated(&self) -> bool {
3635        self.is_terminated
3636    }
3637}
3638
3639impl fidl::endpoints::RequestStream for InstallerRequestStream {
3640    type Protocol = InstallerMarker;
3641    type ControlHandle = InstallerControlHandle;
3642
3643    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3644        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3645    }
3646
3647    fn control_handle(&self) -> Self::ControlHandle {
3648        InstallerControlHandle { inner: self.inner.clone() }
3649    }
3650
3651    fn into_inner(
3652        self,
3653    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3654    {
3655        (self.inner, self.is_terminated)
3656    }
3657
3658    fn from_inner(
3659        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3660        is_terminated: bool,
3661    ) -> Self {
3662        Self { inner, is_terminated }
3663    }
3664}
3665
3666impl futures::Stream for InstallerRequestStream {
3667    type Item = Result<InstallerRequest, fidl::Error>;
3668
3669    fn poll_next(
3670        mut self: std::pin::Pin<&mut Self>,
3671        cx: &mut std::task::Context<'_>,
3672    ) -> std::task::Poll<Option<Self::Item>> {
3673        let this = &mut *self;
3674        if this.inner.check_shutdown(cx) {
3675            this.is_terminated = true;
3676            return std::task::Poll::Ready(None);
3677        }
3678        if this.is_terminated {
3679            panic!("polled InstallerRequestStream after completion");
3680        }
3681        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3682            |bytes, handles| {
3683                match this.inner.channel().read_etc(cx, bytes, handles) {
3684                    std::task::Poll::Ready(Ok(())) => {}
3685                    std::task::Poll::Pending => return std::task::Poll::Pending,
3686                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3687                        this.is_terminated = true;
3688                        return std::task::Poll::Ready(None);
3689                    }
3690                    std::task::Poll::Ready(Err(e)) => {
3691                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3692                            e.into(),
3693                        ))))
3694                    }
3695                }
3696
3697                // A message has been received from the channel
3698                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3699
3700                std::task::Poll::Ready(Some(match header.ordinal {
3701                    0x3e84524dcecab23a => {
3702                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3703                        let mut req = fidl::new_empty!(
3704                            InstallerInstallDeviceRequest,
3705                            fidl::encoding::DefaultFuchsiaResourceDialect
3706                        );
3707                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerInstallDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
3708                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
3709                        Ok(InstallerRequest::InstallDevice {
3710                            device: req.device,
3711                            device_control: req.device_control,
3712
3713                            control_handle,
3714                        })
3715                    }
3716                    0x2ce57e87cdbcb809 => {
3717                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3718                        let mut req = fidl::new_empty!(
3719                            InstallerInstallBlackholeInterfaceRequest,
3720                            fidl::encoding::DefaultFuchsiaResourceDialect
3721                        );
3722                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerInstallBlackholeInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
3723                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
3724                        Ok(InstallerRequest::InstallBlackholeInterface {
3725                            interface: req.interface,
3726                            options: req.options,
3727
3728                            control_handle,
3729                        })
3730                    }
3731                    _ => Err(fidl::Error::UnknownOrdinal {
3732                        ordinal: header.ordinal,
3733                        protocol_name:
3734                            <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3735                    }),
3736                }))
3737            },
3738        )
3739    }
3740}
3741
3742/// Installs devices on the network stack.
3743#[derive(Debug)]
3744pub enum InstallerRequest {
3745    /// Installs a device on the network stack.
3746    ///
3747    /// + request `device` the device to install on the network stack.
3748    /// + request `device_control` grants access to the installed device.
3749    InstallDevice {
3750        device: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3751        device_control: fidl::endpoints::ServerEnd<DeviceControlMarker>,
3752        control_handle: InstallerControlHandle,
3753    },
3754    /// Installs a blackhole interface on the network stack.
3755    ///
3756    /// A "blackhole" interface is an interface that drops any outbound traffic
3757    /// transmitted through it, and never receives any inbound traffic.
3758    ///
3759    /// + request `interface` grants access to the installed interface.
3760    InstallBlackholeInterface {
3761        interface: fidl::endpoints::ServerEnd<ControlMarker>,
3762        options: Options,
3763        control_handle: InstallerControlHandle,
3764    },
3765}
3766
3767impl InstallerRequest {
3768    #[allow(irrefutable_let_patterns)]
3769    pub fn into_install_device(
3770        self,
3771    ) -> Option<(
3772        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
3773        fidl::endpoints::ServerEnd<DeviceControlMarker>,
3774        InstallerControlHandle,
3775    )> {
3776        if let InstallerRequest::InstallDevice { device, device_control, control_handle } = self {
3777            Some((device, device_control, control_handle))
3778        } else {
3779            None
3780        }
3781    }
3782
3783    #[allow(irrefutable_let_patterns)]
3784    pub fn into_install_blackhole_interface(
3785        self,
3786    ) -> Option<(fidl::endpoints::ServerEnd<ControlMarker>, Options, InstallerControlHandle)> {
3787        if let InstallerRequest::InstallBlackholeInterface { interface, options, control_handle } =
3788            self
3789        {
3790            Some((interface, options, control_handle))
3791        } else {
3792            None
3793        }
3794    }
3795
3796    /// Name of the method defined in FIDL
3797    pub fn method_name(&self) -> &'static str {
3798        match *self {
3799            InstallerRequest::InstallDevice { .. } => "install_device",
3800            InstallerRequest::InstallBlackholeInterface { .. } => "install_blackhole_interface",
3801        }
3802    }
3803}
3804
3805#[derive(Debug, Clone)]
3806pub struct InstallerControlHandle {
3807    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3808}
3809
3810impl fidl::endpoints::ControlHandle for InstallerControlHandle {
3811    fn shutdown(&self) {
3812        self.inner.shutdown()
3813    }
3814    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3815        self.inner.shutdown_with_epitaph(status)
3816    }
3817
3818    fn is_closed(&self) -> bool {
3819        self.inner.channel().is_closed()
3820    }
3821    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3822        self.inner.channel().on_closed()
3823    }
3824
3825    #[cfg(target_os = "fuchsia")]
3826    fn signal_peer(
3827        &self,
3828        clear_mask: zx::Signals,
3829        set_mask: zx::Signals,
3830    ) -> Result<(), zx_status::Status> {
3831        use fidl::Peered;
3832        self.inner.channel().signal_peer(clear_mask, set_mask)
3833    }
3834}
3835
3836impl InstallerControlHandle {}
3837
3838mod internal {
3839    use super::*;
3840
3841    impl fidl::encoding::ResourceTypeMarker for ControlAddAddressRequest {
3842        type Borrowed<'a> = &'a mut Self;
3843        fn take_or_borrow<'a>(
3844            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3845        ) -> Self::Borrowed<'a> {
3846            value
3847        }
3848    }
3849
3850    unsafe impl fidl::encoding::TypeMarker for ControlAddAddressRequest {
3851        type Owned = Self;
3852
3853        #[inline(always)]
3854        fn inline_align(_context: fidl::encoding::Context) -> usize {
3855            8
3856        }
3857
3858        #[inline(always)]
3859        fn inline_size(_context: fidl::encoding::Context) -> usize {
3860            48
3861        }
3862    }
3863
3864    unsafe impl
3865        fidl::encoding::Encode<
3866            ControlAddAddressRequest,
3867            fidl::encoding::DefaultFuchsiaResourceDialect,
3868        > for &mut ControlAddAddressRequest
3869    {
3870        #[inline]
3871        unsafe fn encode(
3872            self,
3873            encoder: &mut fidl::encoding::Encoder<
3874                '_,
3875                fidl::encoding::DefaultFuchsiaResourceDialect,
3876            >,
3877            offset: usize,
3878            _depth: fidl::encoding::Depth,
3879        ) -> fidl::Result<()> {
3880            encoder.debug_check_bounds::<ControlAddAddressRequest>(offset);
3881            // Delegate to tuple encoding.
3882            fidl::encoding::Encode::<
3883                ControlAddAddressRequest,
3884                fidl::encoding::DefaultFuchsiaResourceDialect,
3885            >::encode(
3886                (
3887                    <fidl_fuchsia_net::Subnet as fidl::encoding::ValueTypeMarker>::borrow(
3888                        &self.address,
3889                    ),
3890                    <AddressParameters as fidl::encoding::ValueTypeMarker>::borrow(
3891                        &self.parameters,
3892                    ),
3893                    <fidl::encoding::Endpoint<
3894                        fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
3895                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3896                        &mut self.address_state_provider,
3897                    ),
3898                ),
3899                encoder,
3900                offset,
3901                _depth,
3902            )
3903        }
3904    }
3905    unsafe impl<
3906            T0: fidl::encoding::Encode<
3907                fidl_fuchsia_net::Subnet,
3908                fidl::encoding::DefaultFuchsiaResourceDialect,
3909            >,
3910            T1: fidl::encoding::Encode<
3911                AddressParameters,
3912                fidl::encoding::DefaultFuchsiaResourceDialect,
3913            >,
3914            T2: fidl::encoding::Encode<
3915                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AddressStateProviderMarker>>,
3916                fidl::encoding::DefaultFuchsiaResourceDialect,
3917            >,
3918        >
3919        fidl::encoding::Encode<
3920            ControlAddAddressRequest,
3921            fidl::encoding::DefaultFuchsiaResourceDialect,
3922        > for (T0, T1, T2)
3923    {
3924        #[inline]
3925        unsafe fn encode(
3926            self,
3927            encoder: &mut fidl::encoding::Encoder<
3928                '_,
3929                fidl::encoding::DefaultFuchsiaResourceDialect,
3930            >,
3931            offset: usize,
3932            depth: fidl::encoding::Depth,
3933        ) -> fidl::Result<()> {
3934            encoder.debug_check_bounds::<ControlAddAddressRequest>(offset);
3935            // Zero out padding regions. There's no need to apply masks
3936            // because the unmasked parts will be overwritten by fields.
3937            unsafe {
3938                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
3939                (ptr as *mut u64).write_unaligned(0);
3940            }
3941            // Write the fields.
3942            self.0.encode(encoder, offset + 0, depth)?;
3943            self.1.encode(encoder, offset + 24, depth)?;
3944            self.2.encode(encoder, offset + 40, depth)?;
3945            Ok(())
3946        }
3947    }
3948
3949    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3950        for ControlAddAddressRequest
3951    {
3952        #[inline(always)]
3953        fn new_empty() -> Self {
3954            Self {
3955                address: fidl::new_empty!(
3956                    fidl_fuchsia_net::Subnet,
3957                    fidl::encoding::DefaultFuchsiaResourceDialect
3958                ),
3959                parameters: fidl::new_empty!(
3960                    AddressParameters,
3961                    fidl::encoding::DefaultFuchsiaResourceDialect
3962                ),
3963                address_state_provider: fidl::new_empty!(
3964                    fidl::encoding::Endpoint<
3965                        fidl::endpoints::ServerEnd<AddressStateProviderMarker>,
3966                    >,
3967                    fidl::encoding::DefaultFuchsiaResourceDialect
3968                ),
3969            }
3970        }
3971
3972        #[inline]
3973        unsafe fn decode(
3974            &mut self,
3975            decoder: &mut fidl::encoding::Decoder<
3976                '_,
3977                fidl::encoding::DefaultFuchsiaResourceDialect,
3978            >,
3979            offset: usize,
3980            _depth: fidl::encoding::Depth,
3981        ) -> fidl::Result<()> {
3982            decoder.debug_check_bounds::<Self>(offset);
3983            // Verify that padding bytes are zero.
3984            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
3985            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3986            let mask = 0xffffffff00000000u64;
3987            let maskedval = padval & mask;
3988            if maskedval != 0 {
3989                return Err(fidl::Error::NonZeroPadding {
3990                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
3991                });
3992            }
3993            fidl::decode!(
3994                fidl_fuchsia_net::Subnet,
3995                fidl::encoding::DefaultFuchsiaResourceDialect,
3996                &mut self.address,
3997                decoder,
3998                offset + 0,
3999                _depth
4000            )?;
4001            fidl::decode!(
4002                AddressParameters,
4003                fidl::encoding::DefaultFuchsiaResourceDialect,
4004                &mut self.parameters,
4005                decoder,
4006                offset + 24,
4007                _depth
4008            )?;
4009            fidl::decode!(
4010                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AddressStateProviderMarker>>,
4011                fidl::encoding::DefaultFuchsiaResourceDialect,
4012                &mut self.address_state_provider,
4013                decoder,
4014                offset + 40,
4015                _depth
4016            )?;
4017            Ok(())
4018        }
4019    }
4020
4021    impl fidl::encoding::ResourceTypeMarker for ControlGetAuthorizationForInterfaceResponse {
4022        type Borrowed<'a> = &'a mut Self;
4023        fn take_or_borrow<'a>(
4024            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4025        ) -> Self::Borrowed<'a> {
4026            value
4027        }
4028    }
4029
4030    unsafe impl fidl::encoding::TypeMarker for ControlGetAuthorizationForInterfaceResponse {
4031        type Owned = Self;
4032
4033        #[inline(always)]
4034        fn inline_align(_context: fidl::encoding::Context) -> usize {
4035            8
4036        }
4037
4038        #[inline(always)]
4039        fn inline_size(_context: fidl::encoding::Context) -> usize {
4040            16
4041        }
4042    }
4043
4044    unsafe impl
4045        fidl::encoding::Encode<
4046            ControlGetAuthorizationForInterfaceResponse,
4047            fidl::encoding::DefaultFuchsiaResourceDialect,
4048        > for &mut ControlGetAuthorizationForInterfaceResponse
4049    {
4050        #[inline]
4051        unsafe fn encode(
4052            self,
4053            encoder: &mut fidl::encoding::Encoder<
4054                '_,
4055                fidl::encoding::DefaultFuchsiaResourceDialect,
4056            >,
4057            offset: usize,
4058            _depth: fidl::encoding::Depth,
4059        ) -> fidl::Result<()> {
4060            encoder.debug_check_bounds::<ControlGetAuthorizationForInterfaceResponse>(offset);
4061            // Delegate to tuple encoding.
4062            fidl::encoding::Encode::<ControlGetAuthorizationForInterfaceResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4063                (
4064                    <GrantForInterfaceAuthorization as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.credential),
4065                ),
4066                encoder, offset, _depth
4067            )
4068        }
4069    }
4070    unsafe impl<
4071            T0: fidl::encoding::Encode<
4072                GrantForInterfaceAuthorization,
4073                fidl::encoding::DefaultFuchsiaResourceDialect,
4074            >,
4075        >
4076        fidl::encoding::Encode<
4077            ControlGetAuthorizationForInterfaceResponse,
4078            fidl::encoding::DefaultFuchsiaResourceDialect,
4079        > for (T0,)
4080    {
4081        #[inline]
4082        unsafe fn encode(
4083            self,
4084            encoder: &mut fidl::encoding::Encoder<
4085                '_,
4086                fidl::encoding::DefaultFuchsiaResourceDialect,
4087            >,
4088            offset: usize,
4089            depth: fidl::encoding::Depth,
4090        ) -> fidl::Result<()> {
4091            encoder.debug_check_bounds::<ControlGetAuthorizationForInterfaceResponse>(offset);
4092            // Zero out padding regions. There's no need to apply masks
4093            // because the unmasked parts will be overwritten by fields.
4094            // Write the fields.
4095            self.0.encode(encoder, offset + 0, depth)?;
4096            Ok(())
4097        }
4098    }
4099
4100    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4101        for ControlGetAuthorizationForInterfaceResponse
4102    {
4103        #[inline(always)]
4104        fn new_empty() -> Self {
4105            Self {
4106                credential: fidl::new_empty!(
4107                    GrantForInterfaceAuthorization,
4108                    fidl::encoding::DefaultFuchsiaResourceDialect
4109                ),
4110            }
4111        }
4112
4113        #[inline]
4114        unsafe fn decode(
4115            &mut self,
4116            decoder: &mut fidl::encoding::Decoder<
4117                '_,
4118                fidl::encoding::DefaultFuchsiaResourceDialect,
4119            >,
4120            offset: usize,
4121            _depth: fidl::encoding::Depth,
4122        ) -> fidl::Result<()> {
4123            decoder.debug_check_bounds::<Self>(offset);
4124            // Verify that padding bytes are zero.
4125            fidl::decode!(
4126                GrantForInterfaceAuthorization,
4127                fidl::encoding::DefaultFuchsiaResourceDialect,
4128                &mut self.credential,
4129                decoder,
4130                offset + 0,
4131                _depth
4132            )?;
4133            Ok(())
4134        }
4135    }
4136
4137    impl fidl::encoding::ResourceTypeMarker for DeviceControlCreateInterfaceRequest {
4138        type Borrowed<'a> = &'a mut Self;
4139        fn take_or_borrow<'a>(
4140            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4141        ) -> Self::Borrowed<'a> {
4142            value
4143        }
4144    }
4145
4146    unsafe impl fidl::encoding::TypeMarker for DeviceControlCreateInterfaceRequest {
4147        type Owned = Self;
4148
4149        #[inline(always)]
4150        fn inline_align(_context: fidl::encoding::Context) -> usize {
4151            8
4152        }
4153
4154        #[inline(always)]
4155        fn inline_size(_context: fidl::encoding::Context) -> usize {
4156            24
4157        }
4158    }
4159
4160    unsafe impl
4161        fidl::encoding::Encode<
4162            DeviceControlCreateInterfaceRequest,
4163            fidl::encoding::DefaultFuchsiaResourceDialect,
4164        > for &mut DeviceControlCreateInterfaceRequest
4165    {
4166        #[inline]
4167        unsafe fn encode(
4168            self,
4169            encoder: &mut fidl::encoding::Encoder<
4170                '_,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172            >,
4173            offset: usize,
4174            _depth: fidl::encoding::Depth,
4175        ) -> fidl::Result<()> {
4176            encoder.debug_check_bounds::<DeviceControlCreateInterfaceRequest>(offset);
4177            // Delegate to tuple encoding.
4178            fidl::encoding::Encode::<DeviceControlCreateInterfaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4179                (
4180                    <fidl_fuchsia_hardware_network::PortId as fidl::encoding::ValueTypeMarker>::borrow(&self.port),
4181                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
4182                    <Options as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.options),
4183                ),
4184                encoder, offset, _depth
4185            )
4186        }
4187    }
4188    unsafe impl<
4189            T0: fidl::encoding::Encode<
4190                fidl_fuchsia_hardware_network::PortId,
4191                fidl::encoding::DefaultFuchsiaResourceDialect,
4192            >,
4193            T1: fidl::encoding::Encode<
4194                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4195                fidl::encoding::DefaultFuchsiaResourceDialect,
4196            >,
4197            T2: fidl::encoding::Encode<Options, fidl::encoding::DefaultFuchsiaResourceDialect>,
4198        >
4199        fidl::encoding::Encode<
4200            DeviceControlCreateInterfaceRequest,
4201            fidl::encoding::DefaultFuchsiaResourceDialect,
4202        > for (T0, T1, T2)
4203    {
4204        #[inline]
4205        unsafe fn encode(
4206            self,
4207            encoder: &mut fidl::encoding::Encoder<
4208                '_,
4209                fidl::encoding::DefaultFuchsiaResourceDialect,
4210            >,
4211            offset: usize,
4212            depth: fidl::encoding::Depth,
4213        ) -> fidl::Result<()> {
4214            encoder.debug_check_bounds::<DeviceControlCreateInterfaceRequest>(offset);
4215            // Zero out padding regions. There's no need to apply masks
4216            // because the unmasked parts will be overwritten by fields.
4217            unsafe {
4218                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4219                (ptr as *mut u64).write_unaligned(0);
4220            }
4221            // Write the fields.
4222            self.0.encode(encoder, offset + 0, depth)?;
4223            self.1.encode(encoder, offset + 4, depth)?;
4224            self.2.encode(encoder, offset + 8, depth)?;
4225            Ok(())
4226        }
4227    }
4228
4229    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4230        for DeviceControlCreateInterfaceRequest
4231    {
4232        #[inline(always)]
4233        fn new_empty() -> Self {
4234            Self {
4235                port: fidl::new_empty!(
4236                    fidl_fuchsia_hardware_network::PortId,
4237                    fidl::encoding::DefaultFuchsiaResourceDialect
4238                ),
4239                control: fidl::new_empty!(
4240                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4241                    fidl::encoding::DefaultFuchsiaResourceDialect
4242                ),
4243                options: fidl::new_empty!(Options, fidl::encoding::DefaultFuchsiaResourceDialect),
4244            }
4245        }
4246
4247        #[inline]
4248        unsafe fn decode(
4249            &mut self,
4250            decoder: &mut fidl::encoding::Decoder<
4251                '_,
4252                fidl::encoding::DefaultFuchsiaResourceDialect,
4253            >,
4254            offset: usize,
4255            _depth: fidl::encoding::Depth,
4256        ) -> fidl::Result<()> {
4257            decoder.debug_check_bounds::<Self>(offset);
4258            // Verify that padding bytes are zero.
4259            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4260            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4261            let mask = 0xffff0000u64;
4262            let maskedval = padval & mask;
4263            if maskedval != 0 {
4264                return Err(fidl::Error::NonZeroPadding {
4265                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4266                });
4267            }
4268            fidl::decode!(
4269                fidl_fuchsia_hardware_network::PortId,
4270                fidl::encoding::DefaultFuchsiaResourceDialect,
4271                &mut self.port,
4272                decoder,
4273                offset + 0,
4274                _depth
4275            )?;
4276            fidl::decode!(
4277                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4278                fidl::encoding::DefaultFuchsiaResourceDialect,
4279                &mut self.control,
4280                decoder,
4281                offset + 4,
4282                _depth
4283            )?;
4284            fidl::decode!(
4285                Options,
4286                fidl::encoding::DefaultFuchsiaResourceDialect,
4287                &mut self.options,
4288                decoder,
4289                offset + 8,
4290                _depth
4291            )?;
4292            Ok(())
4293        }
4294    }
4295
4296    impl fidl::encoding::ResourceTypeMarker for GrantForInterfaceAuthorization {
4297        type Borrowed<'a> = &'a mut Self;
4298        fn take_or_borrow<'a>(
4299            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4300        ) -> Self::Borrowed<'a> {
4301            value
4302        }
4303    }
4304
4305    unsafe impl fidl::encoding::TypeMarker for GrantForInterfaceAuthorization {
4306        type Owned = Self;
4307
4308        #[inline(always)]
4309        fn inline_align(_context: fidl::encoding::Context) -> usize {
4310            8
4311        }
4312
4313        #[inline(always)]
4314        fn inline_size(_context: fidl::encoding::Context) -> usize {
4315            16
4316        }
4317    }
4318
4319    unsafe impl
4320        fidl::encoding::Encode<
4321            GrantForInterfaceAuthorization,
4322            fidl::encoding::DefaultFuchsiaResourceDialect,
4323        > for &mut GrantForInterfaceAuthorization
4324    {
4325        #[inline]
4326        unsafe fn encode(
4327            self,
4328            encoder: &mut fidl::encoding::Encoder<
4329                '_,
4330                fidl::encoding::DefaultFuchsiaResourceDialect,
4331            >,
4332            offset: usize,
4333            _depth: fidl::encoding::Depth,
4334        ) -> fidl::Result<()> {
4335            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
4336            // Delegate to tuple encoding.
4337            fidl::encoding::Encode::<
4338                GrantForInterfaceAuthorization,
4339                fidl::encoding::DefaultFuchsiaResourceDialect,
4340            >::encode(
4341                (
4342                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
4343                    <fidl::encoding::HandleType<
4344                        fidl::Event,
4345                        { fidl::ObjectType::EVENT.into_raw() },
4346                        3,
4347                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4348                        &mut self.token
4349                    ),
4350                ),
4351                encoder,
4352                offset,
4353                _depth,
4354            )
4355        }
4356    }
4357    unsafe impl<
4358            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4359            T1: fidl::encoding::Encode<
4360                fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>,
4361                fidl::encoding::DefaultFuchsiaResourceDialect,
4362            >,
4363        >
4364        fidl::encoding::Encode<
4365            GrantForInterfaceAuthorization,
4366            fidl::encoding::DefaultFuchsiaResourceDialect,
4367        > for (T0, T1)
4368    {
4369        #[inline]
4370        unsafe fn encode(
4371            self,
4372            encoder: &mut fidl::encoding::Encoder<
4373                '_,
4374                fidl::encoding::DefaultFuchsiaResourceDialect,
4375            >,
4376            offset: usize,
4377            depth: fidl::encoding::Depth,
4378        ) -> fidl::Result<()> {
4379            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
4380            // Zero out padding regions. There's no need to apply masks
4381            // because the unmasked parts will be overwritten by fields.
4382            unsafe {
4383                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4384                (ptr as *mut u64).write_unaligned(0);
4385            }
4386            // Write the fields.
4387            self.0.encode(encoder, offset + 0, depth)?;
4388            self.1.encode(encoder, offset + 8, depth)?;
4389            Ok(())
4390        }
4391    }
4392
4393    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4394        for GrantForInterfaceAuthorization
4395    {
4396        #[inline(always)]
4397        fn new_empty() -> Self {
4398            Self {
4399                interface_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4400                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect),
4401            }
4402        }
4403
4404        #[inline]
4405        unsafe fn decode(
4406            &mut self,
4407            decoder: &mut fidl::encoding::Decoder<
4408                '_,
4409                fidl::encoding::DefaultFuchsiaResourceDialect,
4410            >,
4411            offset: usize,
4412            _depth: fidl::encoding::Depth,
4413        ) -> fidl::Result<()> {
4414            decoder.debug_check_bounds::<Self>(offset);
4415            // Verify that padding bytes are zero.
4416            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4417            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4418            let mask = 0xffffffff00000000u64;
4419            let maskedval = padval & mask;
4420            if maskedval != 0 {
4421                return Err(fidl::Error::NonZeroPadding {
4422                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4423                });
4424            }
4425            fidl::decode!(
4426                u64,
4427                fidl::encoding::DefaultFuchsiaResourceDialect,
4428                &mut self.interface_id,
4429                decoder,
4430                offset + 0,
4431                _depth
4432            )?;
4433            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 8, _depth)?;
4434            Ok(())
4435        }
4436    }
4437
4438    impl fidl::encoding::ResourceTypeMarker for InstallerInstallBlackholeInterfaceRequest {
4439        type Borrowed<'a> = &'a mut Self;
4440        fn take_or_borrow<'a>(
4441            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4442        ) -> Self::Borrowed<'a> {
4443            value
4444        }
4445    }
4446
4447    unsafe impl fidl::encoding::TypeMarker for InstallerInstallBlackholeInterfaceRequest {
4448        type Owned = Self;
4449
4450        #[inline(always)]
4451        fn inline_align(_context: fidl::encoding::Context) -> usize {
4452            8
4453        }
4454
4455        #[inline(always)]
4456        fn inline_size(_context: fidl::encoding::Context) -> usize {
4457            24
4458        }
4459    }
4460
4461    unsafe impl
4462        fidl::encoding::Encode<
4463            InstallerInstallBlackholeInterfaceRequest,
4464            fidl::encoding::DefaultFuchsiaResourceDialect,
4465        > for &mut InstallerInstallBlackholeInterfaceRequest
4466    {
4467        #[inline]
4468        unsafe fn encode(
4469            self,
4470            encoder: &mut fidl::encoding::Encoder<
4471                '_,
4472                fidl::encoding::DefaultFuchsiaResourceDialect,
4473            >,
4474            offset: usize,
4475            _depth: fidl::encoding::Depth,
4476        ) -> fidl::Result<()> {
4477            encoder.debug_check_bounds::<InstallerInstallBlackholeInterfaceRequest>(offset);
4478            // Delegate to tuple encoding.
4479            fidl::encoding::Encode::<InstallerInstallBlackholeInterfaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4480                (
4481                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.interface),
4482                    <Options as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.options),
4483                ),
4484                encoder, offset, _depth
4485            )
4486        }
4487    }
4488    unsafe impl<
4489            T0: fidl::encoding::Encode<
4490                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4491                fidl::encoding::DefaultFuchsiaResourceDialect,
4492            >,
4493            T1: fidl::encoding::Encode<Options, fidl::encoding::DefaultFuchsiaResourceDialect>,
4494        >
4495        fidl::encoding::Encode<
4496            InstallerInstallBlackholeInterfaceRequest,
4497            fidl::encoding::DefaultFuchsiaResourceDialect,
4498        > for (T0, T1)
4499    {
4500        #[inline]
4501        unsafe fn encode(
4502            self,
4503            encoder: &mut fidl::encoding::Encoder<
4504                '_,
4505                fidl::encoding::DefaultFuchsiaResourceDialect,
4506            >,
4507            offset: usize,
4508            depth: fidl::encoding::Depth,
4509        ) -> fidl::Result<()> {
4510            encoder.debug_check_bounds::<InstallerInstallBlackholeInterfaceRequest>(offset);
4511            // Zero out padding regions. There's no need to apply masks
4512            // because the unmasked parts will be overwritten by fields.
4513            unsafe {
4514                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4515                (ptr as *mut u64).write_unaligned(0);
4516            }
4517            // Write the fields.
4518            self.0.encode(encoder, offset + 0, depth)?;
4519            self.1.encode(encoder, offset + 8, depth)?;
4520            Ok(())
4521        }
4522    }
4523
4524    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4525        for InstallerInstallBlackholeInterfaceRequest
4526    {
4527        #[inline(always)]
4528        fn new_empty() -> Self {
4529            Self {
4530                interface: fidl::new_empty!(
4531                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4532                    fidl::encoding::DefaultFuchsiaResourceDialect
4533                ),
4534                options: fidl::new_empty!(Options, fidl::encoding::DefaultFuchsiaResourceDialect),
4535            }
4536        }
4537
4538        #[inline]
4539        unsafe fn decode(
4540            &mut self,
4541            decoder: &mut fidl::encoding::Decoder<
4542                '_,
4543                fidl::encoding::DefaultFuchsiaResourceDialect,
4544            >,
4545            offset: usize,
4546            _depth: fidl::encoding::Depth,
4547        ) -> fidl::Result<()> {
4548            decoder.debug_check_bounds::<Self>(offset);
4549            // Verify that padding bytes are zero.
4550            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4551            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4552            let mask = 0xffffffff00000000u64;
4553            let maskedval = padval & mask;
4554            if maskedval != 0 {
4555                return Err(fidl::Error::NonZeroPadding {
4556                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4557                });
4558            }
4559            fidl::decode!(
4560                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
4561                fidl::encoding::DefaultFuchsiaResourceDialect,
4562                &mut self.interface,
4563                decoder,
4564                offset + 0,
4565                _depth
4566            )?;
4567            fidl::decode!(
4568                Options,
4569                fidl::encoding::DefaultFuchsiaResourceDialect,
4570                &mut self.options,
4571                decoder,
4572                offset + 8,
4573                _depth
4574            )?;
4575            Ok(())
4576        }
4577    }
4578
4579    impl fidl::encoding::ResourceTypeMarker for InstallerInstallDeviceRequest {
4580        type Borrowed<'a> = &'a mut Self;
4581        fn take_or_borrow<'a>(
4582            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4583        ) -> Self::Borrowed<'a> {
4584            value
4585        }
4586    }
4587
4588    unsafe impl fidl::encoding::TypeMarker for InstallerInstallDeviceRequest {
4589        type Owned = Self;
4590
4591        #[inline(always)]
4592        fn inline_align(_context: fidl::encoding::Context) -> usize {
4593            4
4594        }
4595
4596        #[inline(always)]
4597        fn inline_size(_context: fidl::encoding::Context) -> usize {
4598            8
4599        }
4600    }
4601
4602    unsafe impl
4603        fidl::encoding::Encode<
4604            InstallerInstallDeviceRequest,
4605            fidl::encoding::DefaultFuchsiaResourceDialect,
4606        > for &mut InstallerInstallDeviceRequest
4607    {
4608        #[inline]
4609        unsafe fn encode(
4610            self,
4611            encoder: &mut fidl::encoding::Encoder<
4612                '_,
4613                fidl::encoding::DefaultFuchsiaResourceDialect,
4614            >,
4615            offset: usize,
4616            _depth: fidl::encoding::Depth,
4617        ) -> fidl::Result<()> {
4618            encoder.debug_check_bounds::<InstallerInstallDeviceRequest>(offset);
4619            // Delegate to tuple encoding.
4620            fidl::encoding::Encode::<InstallerInstallDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4621                (
4622                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
4623                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device_control),
4624                ),
4625                encoder, offset, _depth
4626            )
4627        }
4628    }
4629    unsafe impl<
4630            T0: fidl::encoding::Encode<
4631                fidl::encoding::Endpoint<
4632                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4633                >,
4634                fidl::encoding::DefaultFuchsiaResourceDialect,
4635            >,
4636            T1: fidl::encoding::Encode<
4637                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceControlMarker>>,
4638                fidl::encoding::DefaultFuchsiaResourceDialect,
4639            >,
4640        >
4641        fidl::encoding::Encode<
4642            InstallerInstallDeviceRequest,
4643            fidl::encoding::DefaultFuchsiaResourceDialect,
4644        > for (T0, T1)
4645    {
4646        #[inline]
4647        unsafe fn encode(
4648            self,
4649            encoder: &mut fidl::encoding::Encoder<
4650                '_,
4651                fidl::encoding::DefaultFuchsiaResourceDialect,
4652            >,
4653            offset: usize,
4654            depth: fidl::encoding::Depth,
4655        ) -> fidl::Result<()> {
4656            encoder.debug_check_bounds::<InstallerInstallDeviceRequest>(offset);
4657            // Zero out padding regions. There's no need to apply masks
4658            // because the unmasked parts will be overwritten by fields.
4659            // Write the fields.
4660            self.0.encode(encoder, offset + 0, depth)?;
4661            self.1.encode(encoder, offset + 4, depth)?;
4662            Ok(())
4663        }
4664    }
4665
4666    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4667        for InstallerInstallDeviceRequest
4668    {
4669        #[inline(always)]
4670        fn new_empty() -> Self {
4671            Self {
4672                device: fidl::new_empty!(
4673                    fidl::encoding::Endpoint<
4674                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4675                    >,
4676                    fidl::encoding::DefaultFuchsiaResourceDialect
4677                ),
4678                device_control: fidl::new_empty!(
4679                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceControlMarker>>,
4680                    fidl::encoding::DefaultFuchsiaResourceDialect
4681                ),
4682            }
4683        }
4684
4685        #[inline]
4686        unsafe fn decode(
4687            &mut self,
4688            decoder: &mut fidl::encoding::Decoder<
4689                '_,
4690                fidl::encoding::DefaultFuchsiaResourceDialect,
4691            >,
4692            offset: usize,
4693            _depth: fidl::encoding::Depth,
4694        ) -> fidl::Result<()> {
4695            decoder.debug_check_bounds::<Self>(offset);
4696            // Verify that padding bytes are zero.
4697            fidl::decode!(
4698                fidl::encoding::Endpoint<
4699                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4700                >,
4701                fidl::encoding::DefaultFuchsiaResourceDialect,
4702                &mut self.device,
4703                decoder,
4704                offset + 0,
4705                _depth
4706            )?;
4707            fidl::decode!(
4708                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceControlMarker>>,
4709                fidl::encoding::DefaultFuchsiaResourceDialect,
4710                &mut self.device_control,
4711                decoder,
4712                offset + 4,
4713                _depth
4714            )?;
4715            Ok(())
4716        }
4717    }
4718
4719    impl fidl::encoding::ResourceTypeMarker for ProofOfInterfaceAuthorization {
4720        type Borrowed<'a> = &'a mut Self;
4721        fn take_or_borrow<'a>(
4722            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4723        ) -> Self::Borrowed<'a> {
4724            value
4725        }
4726    }
4727
4728    unsafe impl fidl::encoding::TypeMarker for ProofOfInterfaceAuthorization {
4729        type Owned = Self;
4730
4731        #[inline(always)]
4732        fn inline_align(_context: fidl::encoding::Context) -> usize {
4733            8
4734        }
4735
4736        #[inline(always)]
4737        fn inline_size(_context: fidl::encoding::Context) -> usize {
4738            16
4739        }
4740    }
4741
4742    unsafe impl
4743        fidl::encoding::Encode<
4744            ProofOfInterfaceAuthorization,
4745            fidl::encoding::DefaultFuchsiaResourceDialect,
4746        > for &mut ProofOfInterfaceAuthorization
4747    {
4748        #[inline]
4749        unsafe fn encode(
4750            self,
4751            encoder: &mut fidl::encoding::Encoder<
4752                '_,
4753                fidl::encoding::DefaultFuchsiaResourceDialect,
4754            >,
4755            offset: usize,
4756            _depth: fidl::encoding::Depth,
4757        ) -> fidl::Result<()> {
4758            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
4759            // Delegate to tuple encoding.
4760            fidl::encoding::Encode::<
4761                ProofOfInterfaceAuthorization,
4762                fidl::encoding::DefaultFuchsiaResourceDialect,
4763            >::encode(
4764                (
4765                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
4766                    <fidl::encoding::HandleType<
4767                        fidl::Event,
4768                        { fidl::ObjectType::EVENT.into_raw() },
4769                        0,
4770                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4771                        &mut self.token
4772                    ),
4773                ),
4774                encoder,
4775                offset,
4776                _depth,
4777            )
4778        }
4779    }
4780    unsafe impl<
4781            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4782            T1: fidl::encoding::Encode<
4783                fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>,
4784                fidl::encoding::DefaultFuchsiaResourceDialect,
4785            >,
4786        >
4787        fidl::encoding::Encode<
4788            ProofOfInterfaceAuthorization,
4789            fidl::encoding::DefaultFuchsiaResourceDialect,
4790        > for (T0, T1)
4791    {
4792        #[inline]
4793        unsafe fn encode(
4794            self,
4795            encoder: &mut fidl::encoding::Encoder<
4796                '_,
4797                fidl::encoding::DefaultFuchsiaResourceDialect,
4798            >,
4799            offset: usize,
4800            depth: fidl::encoding::Depth,
4801        ) -> fidl::Result<()> {
4802            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
4803            // Zero out padding regions. There's no need to apply masks
4804            // because the unmasked parts will be overwritten by fields.
4805            unsafe {
4806                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4807                (ptr as *mut u64).write_unaligned(0);
4808            }
4809            // Write the fields.
4810            self.0.encode(encoder, offset + 0, depth)?;
4811            self.1.encode(encoder, offset + 8, depth)?;
4812            Ok(())
4813        }
4814    }
4815
4816    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4817        for ProofOfInterfaceAuthorization
4818    {
4819        #[inline(always)]
4820        fn new_empty() -> Self {
4821            Self {
4822                interface_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4823                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>, fidl::encoding::DefaultFuchsiaResourceDialect),
4824            }
4825        }
4826
4827        #[inline]
4828        unsafe fn decode(
4829            &mut self,
4830            decoder: &mut fidl::encoding::Decoder<
4831                '_,
4832                fidl::encoding::DefaultFuchsiaResourceDialect,
4833            >,
4834            offset: usize,
4835            _depth: fidl::encoding::Depth,
4836        ) -> fidl::Result<()> {
4837            decoder.debug_check_bounds::<Self>(offset);
4838            // Verify that padding bytes are zero.
4839            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4840            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4841            let mask = 0xffffffff00000000u64;
4842            let maskedval = padval & mask;
4843            if maskedval != 0 {
4844                return Err(fidl::Error::NonZeroPadding {
4845                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4846                });
4847            }
4848            fidl::decode!(
4849                u64,
4850                fidl::encoding::DefaultFuchsiaResourceDialect,
4851                &mut self.interface_id,
4852                decoder,
4853                offset + 0,
4854                _depth
4855            )?;
4856            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 8, _depth)?;
4857            Ok(())
4858        }
4859    }
4860
4861    impl Options {
4862        #[inline(always)]
4863        fn max_ordinal_present(&self) -> u64 {
4864            if let Some(_) = self.netstack_managed_routes_designation {
4865                return 3;
4866            }
4867            if let Some(_) = self.metric {
4868                return 2;
4869            }
4870            if let Some(_) = self.name {
4871                return 1;
4872            }
4873            0
4874        }
4875    }
4876
4877    impl fidl::encoding::ResourceTypeMarker for Options {
4878        type Borrowed<'a> = &'a mut Self;
4879        fn take_or_borrow<'a>(
4880            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4881        ) -> Self::Borrowed<'a> {
4882            value
4883        }
4884    }
4885
4886    unsafe impl fidl::encoding::TypeMarker for Options {
4887        type Owned = Self;
4888
4889        #[inline(always)]
4890        fn inline_align(_context: fidl::encoding::Context) -> usize {
4891            8
4892        }
4893
4894        #[inline(always)]
4895        fn inline_size(_context: fidl::encoding::Context) -> usize {
4896            16
4897        }
4898    }
4899
4900    unsafe impl fidl::encoding::Encode<Options, fidl::encoding::DefaultFuchsiaResourceDialect>
4901        for &mut Options
4902    {
4903        unsafe fn encode(
4904            self,
4905            encoder: &mut fidl::encoding::Encoder<
4906                '_,
4907                fidl::encoding::DefaultFuchsiaResourceDialect,
4908            >,
4909            offset: usize,
4910            mut depth: fidl::encoding::Depth,
4911        ) -> fidl::Result<()> {
4912            encoder.debug_check_bounds::<Options>(offset);
4913            // Vector header
4914            let max_ordinal: u64 = self.max_ordinal_present();
4915            encoder.write_num(max_ordinal, offset);
4916            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4917            // Calling encoder.out_of_line_offset(0) is not allowed.
4918            if max_ordinal == 0 {
4919                return Ok(());
4920            }
4921            depth.increment()?;
4922            let envelope_size = 8;
4923            let bytes_len = max_ordinal as usize * envelope_size;
4924            #[allow(unused_variables)]
4925            let offset = encoder.out_of_line_offset(bytes_len);
4926            let mut _prev_end_offset: usize = 0;
4927            if 1 > max_ordinal {
4928                return Ok(());
4929            }
4930
4931            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4932            // are envelope_size bytes.
4933            let cur_offset: usize = (1 - 1) * envelope_size;
4934
4935            // Zero reserved fields.
4936            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4937
4938            // Safety:
4939            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4940            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4941            //   envelope_size bytes, there is always sufficient room.
4942            fidl::encoding::encode_in_envelope_optional::<
4943                fidl::encoding::BoundedString<15>,
4944                fidl::encoding::DefaultFuchsiaResourceDialect,
4945            >(
4946                self.name.as_ref().map(
4947                    <fidl::encoding::BoundedString<15> as fidl::encoding::ValueTypeMarker>::borrow,
4948                ),
4949                encoder,
4950                offset + cur_offset,
4951                depth,
4952            )?;
4953
4954            _prev_end_offset = cur_offset + envelope_size;
4955            if 2 > max_ordinal {
4956                return Ok(());
4957            }
4958
4959            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4960            // are envelope_size bytes.
4961            let cur_offset: usize = (2 - 1) * envelope_size;
4962
4963            // Zero reserved fields.
4964            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4965
4966            // Safety:
4967            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4968            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4969            //   envelope_size bytes, there is always sufficient room.
4970            fidl::encoding::encode_in_envelope_optional::<
4971                u32,
4972                fidl::encoding::DefaultFuchsiaResourceDialect,
4973            >(
4974                self.metric.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
4975                encoder,
4976                offset + cur_offset,
4977                depth,
4978            )?;
4979
4980            _prev_end_offset = cur_offset + envelope_size;
4981            if 3 > max_ordinal {
4982                return Ok(());
4983            }
4984
4985            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4986            // are envelope_size bytes.
4987            let cur_offset: usize = (3 - 1) * envelope_size;
4988
4989            // Zero reserved fields.
4990            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4991
4992            // Safety:
4993            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4994            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4995            //   envelope_size bytes, there is always sufficient room.
4996            fidl::encoding::encode_in_envelope_optional::<NetstackManagedRoutesDesignation, fidl::encoding::DefaultFuchsiaResourceDialect>(
4997            self.netstack_managed_routes_designation.as_mut().map(<NetstackManagedRoutesDesignation as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4998            encoder, offset + cur_offset, depth
4999        )?;
5000
5001            _prev_end_offset = cur_offset + envelope_size;
5002
5003            Ok(())
5004        }
5005    }
5006
5007    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Options {
5008        #[inline(always)]
5009        fn new_empty() -> Self {
5010            Self::default()
5011        }
5012
5013        unsafe fn decode(
5014            &mut self,
5015            decoder: &mut fidl::encoding::Decoder<
5016                '_,
5017                fidl::encoding::DefaultFuchsiaResourceDialect,
5018            >,
5019            offset: usize,
5020            mut depth: fidl::encoding::Depth,
5021        ) -> fidl::Result<()> {
5022            decoder.debug_check_bounds::<Self>(offset);
5023            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5024                None => return Err(fidl::Error::NotNullable),
5025                Some(len) => len,
5026            };
5027            // Calling decoder.out_of_line_offset(0) is not allowed.
5028            if len == 0 {
5029                return Ok(());
5030            };
5031            depth.increment()?;
5032            let envelope_size = 8;
5033            let bytes_len = len * envelope_size;
5034            let offset = decoder.out_of_line_offset(bytes_len)?;
5035            // Decode the envelope for each type.
5036            let mut _next_ordinal_to_read = 0;
5037            let mut next_offset = offset;
5038            let end_offset = offset + bytes_len;
5039            _next_ordinal_to_read += 1;
5040            if next_offset >= end_offset {
5041                return Ok(());
5042            }
5043
5044            // Decode unknown envelopes for gaps in ordinals.
5045            while _next_ordinal_to_read < 1 {
5046                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5047                _next_ordinal_to_read += 1;
5048                next_offset += envelope_size;
5049            }
5050
5051            let next_out_of_line = decoder.next_out_of_line();
5052            let handles_before = decoder.remaining_handles();
5053            if let Some((inlined, num_bytes, num_handles)) =
5054                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5055            {
5056                let member_inline_size =
5057                    <fidl::encoding::BoundedString<15> as fidl::encoding::TypeMarker>::inline_size(
5058                        decoder.context,
5059                    );
5060                if inlined != (member_inline_size <= 4) {
5061                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5062                }
5063                let inner_offset;
5064                let mut inner_depth = depth.clone();
5065                if inlined {
5066                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5067                    inner_offset = next_offset;
5068                } else {
5069                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5070                    inner_depth.increment()?;
5071                }
5072                let val_ref = self.name.get_or_insert_with(|| {
5073                    fidl::new_empty!(
5074                        fidl::encoding::BoundedString<15>,
5075                        fidl::encoding::DefaultFuchsiaResourceDialect
5076                    )
5077                });
5078                fidl::decode!(
5079                    fidl::encoding::BoundedString<15>,
5080                    fidl::encoding::DefaultFuchsiaResourceDialect,
5081                    val_ref,
5082                    decoder,
5083                    inner_offset,
5084                    inner_depth
5085                )?;
5086                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5087                {
5088                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5089                }
5090                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5091                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5092                }
5093            }
5094
5095            next_offset += envelope_size;
5096            _next_ordinal_to_read += 1;
5097            if next_offset >= end_offset {
5098                return Ok(());
5099            }
5100
5101            // Decode unknown envelopes for gaps in ordinals.
5102            while _next_ordinal_to_read < 2 {
5103                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5104                _next_ordinal_to_read += 1;
5105                next_offset += envelope_size;
5106            }
5107
5108            let next_out_of_line = decoder.next_out_of_line();
5109            let handles_before = decoder.remaining_handles();
5110            if let Some((inlined, num_bytes, num_handles)) =
5111                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5112            {
5113                let member_inline_size =
5114                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5115                if inlined != (member_inline_size <= 4) {
5116                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5117                }
5118                let inner_offset;
5119                let mut inner_depth = depth.clone();
5120                if inlined {
5121                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5122                    inner_offset = next_offset;
5123                } else {
5124                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5125                    inner_depth.increment()?;
5126                }
5127                let val_ref = self.metric.get_or_insert_with(|| {
5128                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
5129                });
5130                fidl::decode!(
5131                    u32,
5132                    fidl::encoding::DefaultFuchsiaResourceDialect,
5133                    val_ref,
5134                    decoder,
5135                    inner_offset,
5136                    inner_depth
5137                )?;
5138                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5139                {
5140                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5141                }
5142                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5143                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5144                }
5145            }
5146
5147            next_offset += envelope_size;
5148            _next_ordinal_to_read += 1;
5149            if next_offset >= end_offset {
5150                return Ok(());
5151            }
5152
5153            // Decode unknown envelopes for gaps in ordinals.
5154            while _next_ordinal_to_read < 3 {
5155                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5156                _next_ordinal_to_read += 1;
5157                next_offset += envelope_size;
5158            }
5159
5160            let next_out_of_line = decoder.next_out_of_line();
5161            let handles_before = decoder.remaining_handles();
5162            if let Some((inlined, num_bytes, num_handles)) =
5163                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5164            {
5165                let member_inline_size =
5166                    <NetstackManagedRoutesDesignation as fidl::encoding::TypeMarker>::inline_size(
5167                        decoder.context,
5168                    );
5169                if inlined != (member_inline_size <= 4) {
5170                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5171                }
5172                let inner_offset;
5173                let mut inner_depth = depth.clone();
5174                if inlined {
5175                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5176                    inner_offset = next_offset;
5177                } else {
5178                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5179                    inner_depth.increment()?;
5180                }
5181                let val_ref = self.netstack_managed_routes_designation.get_or_insert_with(|| {
5182                    fidl::new_empty!(
5183                        NetstackManagedRoutesDesignation,
5184                        fidl::encoding::DefaultFuchsiaResourceDialect
5185                    )
5186                });
5187                fidl::decode!(
5188                    NetstackManagedRoutesDesignation,
5189                    fidl::encoding::DefaultFuchsiaResourceDialect,
5190                    val_ref,
5191                    decoder,
5192                    inner_offset,
5193                    inner_depth
5194                )?;
5195                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5196                {
5197                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5198                }
5199                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5200                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5201                }
5202            }
5203
5204            next_offset += envelope_size;
5205
5206            // Decode the remaining unknown envelopes.
5207            while next_offset < end_offset {
5208                _next_ordinal_to_read += 1;
5209                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5210                next_offset += envelope_size;
5211            }
5212
5213            Ok(())
5214        }
5215    }
5216
5217    impl fidl::encoding::ResourceTypeMarker for NetstackManagedRoutesDesignation {
5218        type Borrowed<'a> = &'a mut Self;
5219        fn take_or_borrow<'a>(
5220            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5221        ) -> Self::Borrowed<'a> {
5222            value
5223        }
5224    }
5225
5226    unsafe impl fidl::encoding::TypeMarker for NetstackManagedRoutesDesignation {
5227        type Owned = Self;
5228
5229        #[inline(always)]
5230        fn inline_align(_context: fidl::encoding::Context) -> usize {
5231            8
5232        }
5233
5234        #[inline(always)]
5235        fn inline_size(_context: fidl::encoding::Context) -> usize {
5236            16
5237        }
5238    }
5239
5240    unsafe impl
5241        fidl::encoding::Encode<
5242            NetstackManagedRoutesDesignation,
5243            fidl::encoding::DefaultFuchsiaResourceDialect,
5244        > for &mut NetstackManagedRoutesDesignation
5245    {
5246        #[inline]
5247        unsafe fn encode(
5248            self,
5249            encoder: &mut fidl::encoding::Encoder<
5250                '_,
5251                fidl::encoding::DefaultFuchsiaResourceDialect,
5252            >,
5253            offset: usize,
5254            _depth: fidl::encoding::Depth,
5255        ) -> fidl::Result<()> {
5256            encoder.debug_check_bounds::<NetstackManagedRoutesDesignation>(offset);
5257            encoder.write_num::<u64>(self.ordinal(), offset);
5258            match self {
5259                NetstackManagedRoutesDesignation::Main(ref val) => {
5260                    fidl::encoding::encode_in_envelope::<
5261                        Empty,
5262                        fidl::encoding::DefaultFuchsiaResourceDialect,
5263                    >(
5264                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
5265                        encoder,
5266                        offset + 8,
5267                        _depth,
5268                    )
5269                }
5270                NetstackManagedRoutesDesignation::InterfaceLocal(ref val) => {
5271                    fidl::encoding::encode_in_envelope::<
5272                        Empty,
5273                        fidl::encoding::DefaultFuchsiaResourceDialect,
5274                    >(
5275                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
5276                        encoder,
5277                        offset + 8,
5278                        _depth,
5279                    )
5280                }
5281                NetstackManagedRoutesDesignation::__SourceBreaking { .. } => {
5282                    Err(fidl::Error::UnknownUnionTag)
5283                }
5284            }
5285        }
5286    }
5287
5288    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5289        for NetstackManagedRoutesDesignation
5290    {
5291        #[inline(always)]
5292        fn new_empty() -> Self {
5293            Self::__SourceBreaking { unknown_ordinal: 0 }
5294        }
5295
5296        #[inline]
5297        unsafe fn decode(
5298            &mut self,
5299            decoder: &mut fidl::encoding::Decoder<
5300                '_,
5301                fidl::encoding::DefaultFuchsiaResourceDialect,
5302            >,
5303            offset: usize,
5304            mut depth: fidl::encoding::Depth,
5305        ) -> fidl::Result<()> {
5306            decoder.debug_check_bounds::<Self>(offset);
5307            #[allow(unused_variables)]
5308            let next_out_of_line = decoder.next_out_of_line();
5309            let handles_before = decoder.remaining_handles();
5310            let (ordinal, inlined, num_bytes, num_handles) =
5311                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5312
5313            let member_inline_size = match ordinal {
5314                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5315                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5316                0 => return Err(fidl::Error::UnknownUnionTag),
5317                _ => num_bytes as usize,
5318            };
5319
5320            if inlined != (member_inline_size <= 4) {
5321                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5322            }
5323            let _inner_offset;
5324            if inlined {
5325                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5326                _inner_offset = offset + 8;
5327            } else {
5328                depth.increment()?;
5329                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5330            }
5331            match ordinal {
5332                1 => {
5333                    #[allow(irrefutable_let_patterns)]
5334                    if let NetstackManagedRoutesDesignation::Main(_) = self {
5335                        // Do nothing, read the value into the object
5336                    } else {
5337                        // Initialize `self` to the right variant
5338                        *self = NetstackManagedRoutesDesignation::Main(fidl::new_empty!(
5339                            Empty,
5340                            fidl::encoding::DefaultFuchsiaResourceDialect
5341                        ));
5342                    }
5343                    #[allow(irrefutable_let_patterns)]
5344                    if let NetstackManagedRoutesDesignation::Main(ref mut val) = self {
5345                        fidl::decode!(
5346                            Empty,
5347                            fidl::encoding::DefaultFuchsiaResourceDialect,
5348                            val,
5349                            decoder,
5350                            _inner_offset,
5351                            depth
5352                        )?;
5353                    } else {
5354                        unreachable!()
5355                    }
5356                }
5357                2 => {
5358                    #[allow(irrefutable_let_patterns)]
5359                    if let NetstackManagedRoutesDesignation::InterfaceLocal(_) = self {
5360                        // Do nothing, read the value into the object
5361                    } else {
5362                        // Initialize `self` to the right variant
5363                        *self = NetstackManagedRoutesDesignation::InterfaceLocal(fidl::new_empty!(
5364                            Empty,
5365                            fidl::encoding::DefaultFuchsiaResourceDialect
5366                        ));
5367                    }
5368                    #[allow(irrefutable_let_patterns)]
5369                    if let NetstackManagedRoutesDesignation::InterfaceLocal(ref mut val) = self {
5370                        fidl::decode!(
5371                            Empty,
5372                            fidl::encoding::DefaultFuchsiaResourceDialect,
5373                            val,
5374                            decoder,
5375                            _inner_offset,
5376                            depth
5377                        )?;
5378                    } else {
5379                        unreachable!()
5380                    }
5381                }
5382                #[allow(deprecated)]
5383                ordinal => {
5384                    for _ in 0..num_handles {
5385                        decoder.drop_next_handle()?;
5386                    }
5387                    *self = NetstackManagedRoutesDesignation::__SourceBreaking {
5388                        unknown_ordinal: ordinal,
5389                    };
5390                }
5391            }
5392            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5393                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5394            }
5395            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5396                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5397            }
5398            Ok(())
5399        }
5400    }
5401}