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