Skip to main content

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