Skip to main content

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