Skip to main content

fidl_fuchsia_net_dhcpv6/
fidl_fuchsia_net_dhcpv6.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_dhcpv6_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ClientProviderNewClientRequest {
16    pub params: NewClientParams,
17    pub request: fidl::endpoints::ServerEnd<ClientMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ClientProviderNewClientRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct ClientWatchAddressResponse {
27    pub address: fidl_fuchsia_net::Subnet,
28    pub address_parameters: fidl_fuchsia_net_interfaces_admin::AddressParameters,
29    pub address_state_provider:
30        fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker>,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for ClientWatchAddressResponse
35{
36}
37
38#[derive(Debug, PartialEq)]
39pub struct PrefixProviderAcquirePrefixRequest {
40    pub config: AcquirePrefixConfig,
41    pub prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for PrefixProviderAcquirePrefixRequest
46{
47}
48
49#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
50pub struct ClientMarker;
51
52impl fidl::endpoints::ProtocolMarker for ClientMarker {
53    type Proxy = ClientProxy;
54    type RequestStream = ClientRequestStream;
55    #[cfg(target_os = "fuchsia")]
56    type SynchronousProxy = ClientSynchronousProxy;
57
58    const DEBUG_NAME: &'static str = "(anonymous) Client";
59}
60pub type ClientShutdownResult = Result<(), i32>;
61
62pub trait ClientProxyInterface: Send + Sync {
63    type WatchServersResponseFut: std::future::Future<Output = Result<Vec<fidl_fuchsia_net_name::DnsServer_>, fidl::Error>>
64        + Send;
65    fn r#watch_servers(&self) -> Self::WatchServersResponseFut;
66    type WatchAddressResponseFut: std::future::Future<
67            Output = Result<
68                (
69                    fidl_fuchsia_net::Subnet,
70                    fidl_fuchsia_net_interfaces_admin::AddressParameters,
71                    fidl::endpoints::ServerEnd<
72                        fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
73                    >,
74                ),
75                fidl::Error,
76            >,
77        > + Send;
78    fn r#watch_address(&self) -> Self::WatchAddressResponseFut;
79    type WatchPrefixesResponseFut: std::future::Future<Output = Result<Vec<Prefix>, fidl::Error>>
80        + Send;
81    fn r#watch_prefixes(&self) -> Self::WatchPrefixesResponseFut;
82    type ShutdownResponseFut: std::future::Future<Output = Result<ClientShutdownResult, fidl::Error>>
83        + Send;
84    fn r#shutdown(&self) -> Self::ShutdownResponseFut;
85}
86#[derive(Debug)]
87#[cfg(target_os = "fuchsia")]
88pub struct ClientSynchronousProxy {
89    client: fidl::client::sync::Client,
90}
91
92#[cfg(target_os = "fuchsia")]
93impl fidl::endpoints::SynchronousProxy for ClientSynchronousProxy {
94    type Proxy = ClientProxy;
95    type Protocol = ClientMarker;
96
97    fn from_channel(inner: fidl::Channel) -> Self {
98        Self::new(inner)
99    }
100
101    fn into_channel(self) -> fidl::Channel {
102        self.client.into_channel()
103    }
104
105    fn as_channel(&self) -> &fidl::Channel {
106        self.client.as_channel()
107    }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl ClientSynchronousProxy {
112    pub fn new(channel: fidl::Channel) -> Self {
113        Self { client: fidl::client::sync::Client::new(channel) }
114    }
115
116    pub fn into_channel(self) -> fidl::Channel {
117        self.client.into_channel()
118    }
119
120    /// Waits until an event arrives and returns it. It is safe for other
121    /// threads to make concurrent requests while waiting for an event.
122    pub fn wait_for_event(
123        &self,
124        deadline: zx::MonotonicInstant,
125    ) -> Result<ClientEvent, fidl::Error> {
126        ClientEvent::decode(self.client.wait_for_event::<ClientMarker>(deadline)?)
127    }
128
129    /// Returns a list of DNS servers.
130    ///
131    /// First call always returns a snapshot of the current list of servers or blocks if an empty
132    /// list would be returned. Subsequent calls will block until the list of servers changes.
133    ///
134    /// The list of servers changes over time by configuration or network topology changes,
135    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
136    /// returned `servers` with new ones to avoid using stale or expired entries.
137    ///
138    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
139    /// server end of the protocol to be closed.
140    ///
141    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
142    pub fn r#watch_servers(
143        &self,
144        ___deadline: zx::MonotonicInstant,
145    ) -> Result<Vec<fidl_fuchsia_net_name::DnsServer_>, fidl::Error> {
146        let _response = self.client.send_query::<
147            fidl::encoding::EmptyPayload,
148            fidl_fuchsia_net_name::DnsServerWatcherWatchServersResponse,
149            ClientMarker,
150        >(
151            (),
152            0x5748907e7f11b632,
153            fidl::encoding::DynamicFlags::empty(),
154            ___deadline,
155        )?;
156        Ok(_response.servers)
157    }
158
159    /// Returns an address and its parameters.
160    ///
161    /// Yields a value for every address acquired by the client.
162    ///
163    /// It is invalid to call this method while a previous call is pending.
164    /// Doing so will cause the server end of the protocol to be closed.
165    ///
166    /// - response `address` the assigned address.
167    /// - response `address_parameters` the parameters of the address.
168    /// - response `address_state_provider` provides address assignment state
169    ///     and enables updating address properties; client end is closed if
170    ///     the address becomes invalid (its valid lifetime expires and Renew
171    ///     and Rebind fail).
172    pub fn r#watch_address(
173        &self,
174        ___deadline: zx::MonotonicInstant,
175    ) -> Result<
176        (
177            fidl_fuchsia_net::Subnet,
178            fidl_fuchsia_net_interfaces_admin::AddressParameters,
179            fidl::endpoints::ServerEnd<
180                fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
181            >,
182        ),
183        fidl::Error,
184    > {
185        let _response = self
186            .client
187            .send_query::<fidl::encoding::EmptyPayload, ClientWatchAddressResponse, ClientMarker>(
188                (),
189                0x942e6f66f63721c,
190                fidl::encoding::DynamicFlags::empty(),
191                ___deadline,
192            )?;
193        Ok((_response.address, _response.address_parameters, _response.address_state_provider))
194    }
195
196    /// Hanging get for prefix leases.
197    ///
198    /// The first call to this method will return when there is at least
199    /// one lease to report (the first call is guaranteed to return with a
200    /// non-empty vector). Subsequent calls will return immediately if there
201    /// is a change to report, or block until a change occurs.
202    ///
203    /// It is invalid to call this method while a previous call is pending.
204    /// Doing so will cause the server end of the protocol to be closed.
205    ///
206    /// - response `prefixes` the assigned prefixes and their lifetimes.
207    pub fn r#watch_prefixes(
208        &self,
209        ___deadline: zx::MonotonicInstant,
210    ) -> Result<Vec<Prefix>, fidl::Error> {
211        let _response = self
212            .client
213            .send_query::<fidl::encoding::EmptyPayload, ClientWatchPrefixesResponse, ClientMarker>(
214                (),
215                0x3b7908cc71ae2a5e,
216                fidl::encoding::DynamicFlags::empty(),
217                ___deadline,
218            )?;
219        Ok(_response.prefixes)
220    }
221
222    /// Gracefully tears down the underlying object.
223    ///
224    /// Blocks until any held addresses are gracefully released, as described in
225    /// [RFC 8415, Section 18.2.7](https://tools.ietf.org/html/rfc8415#section-18.2.7).
226    ///
227    /// The server end of the protocol is closed after this method returns.
228    ///
229    /// * error a `zx.Status` if any of the addresses were not gracefully
230    ///     released, e.g. the client times out waiting for Reply to Release,
231    ///     or the interface is down and sending Release fails.
232    pub fn r#shutdown(
233        &self,
234        ___deadline: zx::MonotonicInstant,
235    ) -> Result<ClientShutdownResult, fidl::Error> {
236        let _response = self.client.send_query::<
237            fidl::encoding::EmptyPayload,
238            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
239            ClientMarker,
240        >(
241            (),
242            0x6da95f1bcd43fa11,
243            fidl::encoding::DynamicFlags::empty(),
244            ___deadline,
245        )?;
246        Ok(_response.map(|x| x))
247    }
248}
249
250#[cfg(target_os = "fuchsia")]
251impl From<ClientSynchronousProxy> for zx::NullableHandle {
252    fn from(value: ClientSynchronousProxy) -> Self {
253        value.into_channel().into()
254    }
255}
256
257#[cfg(target_os = "fuchsia")]
258impl From<fidl::Channel> for ClientSynchronousProxy {
259    fn from(value: fidl::Channel) -> Self {
260        Self::new(value)
261    }
262}
263
264#[cfg(target_os = "fuchsia")]
265impl fidl::endpoints::FromClient for ClientSynchronousProxy {
266    type Protocol = ClientMarker;
267
268    fn from_client(value: fidl::endpoints::ClientEnd<ClientMarker>) -> Self {
269        Self::new(value.into_channel())
270    }
271}
272
273#[derive(Debug, Clone)]
274pub struct ClientProxy {
275    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
276}
277
278impl fidl::endpoints::Proxy for ClientProxy {
279    type Protocol = ClientMarker;
280
281    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
282        Self::new(inner)
283    }
284
285    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
286        self.client.into_channel().map_err(|client| Self { client })
287    }
288
289    fn as_channel(&self) -> &::fidl::AsyncChannel {
290        self.client.as_channel()
291    }
292}
293
294impl ClientProxy {
295    /// Create a new Proxy for fuchsia.net.dhcpv6/Client.
296    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
297        let protocol_name = <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
298        Self { client: fidl::client::Client::new(channel, protocol_name) }
299    }
300
301    /// Get a Stream of events from the remote end of the protocol.
302    ///
303    /// # Panics
304    ///
305    /// Panics if the event stream was already taken.
306    pub fn take_event_stream(&self) -> ClientEventStream {
307        ClientEventStream { event_receiver: self.client.take_event_receiver() }
308    }
309
310    /// Returns a list of DNS servers.
311    ///
312    /// First call always returns a snapshot of the current list of servers or blocks if an empty
313    /// list would be returned. Subsequent calls will block until the list of servers changes.
314    ///
315    /// The list of servers changes over time by configuration or network topology changes,
316    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
317    /// returned `servers` with new ones to avoid using stale or expired entries.
318    ///
319    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
320    /// server end of the protocol to be closed.
321    ///
322    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
323    pub fn r#watch_servers(
324        &self,
325    ) -> fidl::client::QueryResponseFut<
326        Vec<fidl_fuchsia_net_name::DnsServer_>,
327        fidl::encoding::DefaultFuchsiaResourceDialect,
328    > {
329        ClientProxyInterface::r#watch_servers(self)
330    }
331
332    /// Returns an address and its parameters.
333    ///
334    /// Yields a value for every address acquired by the client.
335    ///
336    /// It is invalid to call this method while a previous call is pending.
337    /// Doing so will cause the server end of the protocol to be closed.
338    ///
339    /// - response `address` the assigned address.
340    /// - response `address_parameters` the parameters of the address.
341    /// - response `address_state_provider` provides address assignment state
342    ///     and enables updating address properties; client end is closed if
343    ///     the address becomes invalid (its valid lifetime expires and Renew
344    ///     and Rebind fail).
345    pub fn r#watch_address(
346        &self,
347    ) -> fidl::client::QueryResponseFut<
348        (
349            fidl_fuchsia_net::Subnet,
350            fidl_fuchsia_net_interfaces_admin::AddressParameters,
351            fidl::endpoints::ServerEnd<
352                fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
353            >,
354        ),
355        fidl::encoding::DefaultFuchsiaResourceDialect,
356    > {
357        ClientProxyInterface::r#watch_address(self)
358    }
359
360    /// Hanging get for prefix leases.
361    ///
362    /// The first call to this method will return when there is at least
363    /// one lease to report (the first call is guaranteed to return with a
364    /// non-empty vector). Subsequent calls will return immediately if there
365    /// is a change to report, or block until a change occurs.
366    ///
367    /// It is invalid to call this method while a previous call is pending.
368    /// Doing so will cause the server end of the protocol to be closed.
369    ///
370    /// - response `prefixes` the assigned prefixes and their lifetimes.
371    pub fn r#watch_prefixes(
372        &self,
373    ) -> fidl::client::QueryResponseFut<Vec<Prefix>, fidl::encoding::DefaultFuchsiaResourceDialect>
374    {
375        ClientProxyInterface::r#watch_prefixes(self)
376    }
377
378    /// Gracefully tears down the underlying object.
379    ///
380    /// Blocks until any held addresses are gracefully released, as described in
381    /// [RFC 8415, Section 18.2.7](https://tools.ietf.org/html/rfc8415#section-18.2.7).
382    ///
383    /// The server end of the protocol is closed after this method returns.
384    ///
385    /// * error a `zx.Status` if any of the addresses were not gracefully
386    ///     released, e.g. the client times out waiting for Reply to Release,
387    ///     or the interface is down and sending Release fails.
388    pub fn r#shutdown(
389        &self,
390    ) -> fidl::client::QueryResponseFut<
391        ClientShutdownResult,
392        fidl::encoding::DefaultFuchsiaResourceDialect,
393    > {
394        ClientProxyInterface::r#shutdown(self)
395    }
396}
397
398impl ClientProxyInterface for ClientProxy {
399    type WatchServersResponseFut = fidl::client::QueryResponseFut<
400        Vec<fidl_fuchsia_net_name::DnsServer_>,
401        fidl::encoding::DefaultFuchsiaResourceDialect,
402    >;
403    fn r#watch_servers(&self) -> Self::WatchServersResponseFut {
404        fn _decode(
405            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
406        ) -> Result<Vec<fidl_fuchsia_net_name::DnsServer_>, fidl::Error> {
407            let _response = fidl::client::decode_transaction_body::<
408                fidl_fuchsia_net_name::DnsServerWatcherWatchServersResponse,
409                fidl::encoding::DefaultFuchsiaResourceDialect,
410                0x5748907e7f11b632,
411            >(_buf?)?;
412            Ok(_response.servers)
413        }
414        self.client.send_query_and_decode::<
415            fidl::encoding::EmptyPayload,
416            Vec<fidl_fuchsia_net_name::DnsServer_>,
417        >(
418            (),
419            0x5748907e7f11b632,
420            fidl::encoding::DynamicFlags::empty(),
421            _decode,
422        )
423    }
424
425    type WatchAddressResponseFut = fidl::client::QueryResponseFut<
426        (
427            fidl_fuchsia_net::Subnet,
428            fidl_fuchsia_net_interfaces_admin::AddressParameters,
429            fidl::endpoints::ServerEnd<
430                fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
431            >,
432        ),
433        fidl::encoding::DefaultFuchsiaResourceDialect,
434    >;
435    fn r#watch_address(&self) -> Self::WatchAddressResponseFut {
436        fn _decode(
437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
438        ) -> Result<
439            (
440                fidl_fuchsia_net::Subnet,
441                fidl_fuchsia_net_interfaces_admin::AddressParameters,
442                fidl::endpoints::ServerEnd<
443                    fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
444                >,
445            ),
446            fidl::Error,
447        > {
448            let _response = fidl::client::decode_transaction_body::<
449                ClientWatchAddressResponse,
450                fidl::encoding::DefaultFuchsiaResourceDialect,
451                0x942e6f66f63721c,
452            >(_buf?)?;
453            Ok((_response.address, _response.address_parameters, _response.address_state_provider))
454        }
455        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (
456            fidl_fuchsia_net::Subnet,
457            fidl_fuchsia_net_interfaces_admin::AddressParameters,
458            fidl::endpoints::ServerEnd<
459                fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
460            >,
461        )>((), 0x942e6f66f63721c, fidl::encoding::DynamicFlags::empty(), _decode)
462    }
463
464    type WatchPrefixesResponseFut =
465        fidl::client::QueryResponseFut<Vec<Prefix>, fidl::encoding::DefaultFuchsiaResourceDialect>;
466    fn r#watch_prefixes(&self) -> Self::WatchPrefixesResponseFut {
467        fn _decode(
468            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
469        ) -> Result<Vec<Prefix>, fidl::Error> {
470            let _response = fidl::client::decode_transaction_body::<
471                ClientWatchPrefixesResponse,
472                fidl::encoding::DefaultFuchsiaResourceDialect,
473                0x3b7908cc71ae2a5e,
474            >(_buf?)?;
475            Ok(_response.prefixes)
476        }
477        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Prefix>>(
478            (),
479            0x3b7908cc71ae2a5e,
480            fidl::encoding::DynamicFlags::empty(),
481            _decode,
482        )
483    }
484
485    type ShutdownResponseFut = fidl::client::QueryResponseFut<
486        ClientShutdownResult,
487        fidl::encoding::DefaultFuchsiaResourceDialect,
488    >;
489    fn r#shutdown(&self) -> Self::ShutdownResponseFut {
490        fn _decode(
491            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
492        ) -> Result<ClientShutdownResult, fidl::Error> {
493            let _response = fidl::client::decode_transaction_body::<
494                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
495                fidl::encoding::DefaultFuchsiaResourceDialect,
496                0x6da95f1bcd43fa11,
497            >(_buf?)?;
498            Ok(_response.map(|x| x))
499        }
500        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ClientShutdownResult>(
501            (),
502            0x6da95f1bcd43fa11,
503            fidl::encoding::DynamicFlags::empty(),
504            _decode,
505        )
506    }
507}
508
509pub struct ClientEventStream {
510    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
511}
512
513impl std::marker::Unpin for ClientEventStream {}
514
515impl futures::stream::FusedStream for ClientEventStream {
516    fn is_terminated(&self) -> bool {
517        self.event_receiver.is_terminated()
518    }
519}
520
521impl futures::Stream for ClientEventStream {
522    type Item = Result<ClientEvent, fidl::Error>;
523
524    fn poll_next(
525        mut self: std::pin::Pin<&mut Self>,
526        cx: &mut std::task::Context<'_>,
527    ) -> std::task::Poll<Option<Self::Item>> {
528        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
529            &mut self.event_receiver,
530            cx
531        )?) {
532            Some(buf) => std::task::Poll::Ready(Some(ClientEvent::decode(buf))),
533            None => std::task::Poll::Ready(None),
534        }
535    }
536}
537
538#[derive(Debug)]
539pub enum ClientEvent {}
540
541impl ClientEvent {
542    /// Decodes a message buffer as a [`ClientEvent`].
543    fn decode(
544        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
545    ) -> Result<ClientEvent, fidl::Error> {
546        let (bytes, _handles) = buf.split_mut();
547        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
548        debug_assert_eq!(tx_header.tx_id, 0);
549        match tx_header.ordinal {
550            _ => Err(fidl::Error::UnknownOrdinal {
551                ordinal: tx_header.ordinal,
552                protocol_name: <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
553            }),
554        }
555    }
556}
557
558/// A Stream of incoming requests for fuchsia.net.dhcpv6/Client.
559pub struct ClientRequestStream {
560    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
561    is_terminated: bool,
562}
563
564impl std::marker::Unpin for ClientRequestStream {}
565
566impl futures::stream::FusedStream for ClientRequestStream {
567    fn is_terminated(&self) -> bool {
568        self.is_terminated
569    }
570}
571
572impl fidl::endpoints::RequestStream for ClientRequestStream {
573    type Protocol = ClientMarker;
574    type ControlHandle = ClientControlHandle;
575
576    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
577        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
578    }
579
580    fn control_handle(&self) -> Self::ControlHandle {
581        ClientControlHandle { inner: self.inner.clone() }
582    }
583
584    fn into_inner(
585        self,
586    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
587    {
588        (self.inner, self.is_terminated)
589    }
590
591    fn from_inner(
592        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
593        is_terminated: bool,
594    ) -> Self {
595        Self { inner, is_terminated }
596    }
597}
598
599impl futures::Stream for ClientRequestStream {
600    type Item = Result<ClientRequest, fidl::Error>;
601
602    fn poll_next(
603        mut self: std::pin::Pin<&mut Self>,
604        cx: &mut std::task::Context<'_>,
605    ) -> std::task::Poll<Option<Self::Item>> {
606        let this = &mut *self;
607        if this.inner.check_shutdown(cx) {
608            this.is_terminated = true;
609            return std::task::Poll::Ready(None);
610        }
611        if this.is_terminated {
612            panic!("polled ClientRequestStream after completion");
613        }
614        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
615            |bytes, handles| {
616                match this.inner.channel().read_etc(cx, bytes, handles) {
617                    std::task::Poll::Ready(Ok(())) => {}
618                    std::task::Poll::Pending => return std::task::Poll::Pending,
619                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
620                        this.is_terminated = true;
621                        return std::task::Poll::Ready(None);
622                    }
623                    std::task::Poll::Ready(Err(e)) => {
624                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
625                            e.into(),
626                        ))));
627                    }
628                }
629
630                // A message has been received from the channel
631                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
632
633                std::task::Poll::Ready(Some(match header.ordinal {
634                    0x5748907e7f11b632 => {
635                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
636                        let mut req = fidl::new_empty!(
637                            fidl::encoding::EmptyPayload,
638                            fidl::encoding::DefaultFuchsiaResourceDialect
639                        );
640                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
641                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
642                        Ok(ClientRequest::WatchServers {
643                            responder: ClientWatchServersResponder {
644                                control_handle: std::mem::ManuallyDrop::new(control_handle),
645                                tx_id: header.tx_id,
646                            },
647                        })
648                    }
649                    0x942e6f66f63721c => {
650                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
651                        let mut req = fidl::new_empty!(
652                            fidl::encoding::EmptyPayload,
653                            fidl::encoding::DefaultFuchsiaResourceDialect
654                        );
655                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
656                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
657                        Ok(ClientRequest::WatchAddress {
658                            responder: ClientWatchAddressResponder {
659                                control_handle: std::mem::ManuallyDrop::new(control_handle),
660                                tx_id: header.tx_id,
661                            },
662                        })
663                    }
664                    0x3b7908cc71ae2a5e => {
665                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
666                        let mut req = fidl::new_empty!(
667                            fidl::encoding::EmptyPayload,
668                            fidl::encoding::DefaultFuchsiaResourceDialect
669                        );
670                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
671                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
672                        Ok(ClientRequest::WatchPrefixes {
673                            responder: ClientWatchPrefixesResponder {
674                                control_handle: std::mem::ManuallyDrop::new(control_handle),
675                                tx_id: header.tx_id,
676                            },
677                        })
678                    }
679                    0x6da95f1bcd43fa11 => {
680                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
681                        let mut req = fidl::new_empty!(
682                            fidl::encoding::EmptyPayload,
683                            fidl::encoding::DefaultFuchsiaResourceDialect
684                        );
685                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
686                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
687                        Ok(ClientRequest::Shutdown {
688                            responder: ClientShutdownResponder {
689                                control_handle: std::mem::ManuallyDrop::new(control_handle),
690                                tx_id: header.tx_id,
691                            },
692                        })
693                    }
694                    _ => Err(fidl::Error::UnknownOrdinal {
695                        ordinal: header.ordinal,
696                        protocol_name:
697                            <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
698                    }),
699                }))
700            },
701        )
702    }
703}
704
705/// Provides methods to watch for discovered network configurations.
706///
707/// This protocol encodes the underlying object's lifetime in both directions;
708/// the underlying object is alive iff both ends of the protocol are open. That
709/// is:
710///
711/// - Closing the client end causes the object to be destroyed.
712/// - Observing a closure of the server end indicates the object no longer
713///   exists.
714#[derive(Debug)]
715pub enum ClientRequest {
716    /// Returns a list of DNS servers.
717    ///
718    /// First call always returns a snapshot of the current list of servers or blocks if an empty
719    /// list would be returned. Subsequent calls will block until the list of servers changes.
720    ///
721    /// The list of servers changes over time by configuration or network topology changes,
722    /// expiration, etc. Callers must repeatedly call `WatchServers` and replace any previously
723    /// returned `servers` with new ones to avoid using stale or expired entries.
724    ///
725    /// It is invalid to call this method while a previous call is pending. Doing so will cause the
726    /// server end of the protocol to be closed.
727    ///
728    /// - response `servers` The list of servers to use for DNS resolution, in priority order.
729    WatchServers { responder: ClientWatchServersResponder },
730    /// Returns an address and its parameters.
731    ///
732    /// Yields a value for every address acquired by the client.
733    ///
734    /// It is invalid to call this method while a previous call is pending.
735    /// Doing so will cause the server end of the protocol to be closed.
736    ///
737    /// - response `address` the assigned address.
738    /// - response `address_parameters` the parameters of the address.
739    /// - response `address_state_provider` provides address assignment state
740    ///     and enables updating address properties; client end is closed if
741    ///     the address becomes invalid (its valid lifetime expires and Renew
742    ///     and Rebind fail).
743    WatchAddress { responder: ClientWatchAddressResponder },
744    /// Hanging get for prefix leases.
745    ///
746    /// The first call to this method will return when there is at least
747    /// one lease to report (the first call is guaranteed to return with a
748    /// non-empty vector). Subsequent calls will return immediately if there
749    /// is a change to report, or block until a change occurs.
750    ///
751    /// It is invalid to call this method while a previous call is pending.
752    /// Doing so will cause the server end of the protocol to be closed.
753    ///
754    /// - response `prefixes` the assigned prefixes and their lifetimes.
755    WatchPrefixes { responder: ClientWatchPrefixesResponder },
756    /// Gracefully tears down the underlying object.
757    ///
758    /// Blocks until any held addresses are gracefully released, as described in
759    /// [RFC 8415, Section 18.2.7](https://tools.ietf.org/html/rfc8415#section-18.2.7).
760    ///
761    /// The server end of the protocol is closed after this method returns.
762    ///
763    /// * error a `zx.Status` if any of the addresses were not gracefully
764    ///     released, e.g. the client times out waiting for Reply to Release,
765    ///     or the interface is down and sending Release fails.
766    Shutdown { responder: ClientShutdownResponder },
767}
768
769impl ClientRequest {
770    #[allow(irrefutable_let_patterns)]
771    pub fn into_watch_servers(self) -> Option<(ClientWatchServersResponder)> {
772        if let ClientRequest::WatchServers { responder } = self { Some((responder)) } else { None }
773    }
774
775    #[allow(irrefutable_let_patterns)]
776    pub fn into_watch_address(self) -> Option<(ClientWatchAddressResponder)> {
777        if let ClientRequest::WatchAddress { responder } = self { Some((responder)) } else { None }
778    }
779
780    #[allow(irrefutable_let_patterns)]
781    pub fn into_watch_prefixes(self) -> Option<(ClientWatchPrefixesResponder)> {
782        if let ClientRequest::WatchPrefixes { responder } = self { Some((responder)) } else { None }
783    }
784
785    #[allow(irrefutable_let_patterns)]
786    pub fn into_shutdown(self) -> Option<(ClientShutdownResponder)> {
787        if let ClientRequest::Shutdown { responder } = self { Some((responder)) } else { None }
788    }
789
790    /// Name of the method defined in FIDL
791    pub fn method_name(&self) -> &'static str {
792        match *self {
793            ClientRequest::WatchServers { .. } => "watch_servers",
794            ClientRequest::WatchAddress { .. } => "watch_address",
795            ClientRequest::WatchPrefixes { .. } => "watch_prefixes",
796            ClientRequest::Shutdown { .. } => "shutdown",
797        }
798    }
799}
800
801#[derive(Debug, Clone)]
802pub struct ClientControlHandle {
803    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
804}
805
806impl ClientControlHandle {
807    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
808        self.inner.shutdown_with_epitaph(status.into())
809    }
810}
811
812impl fidl::endpoints::ControlHandle for ClientControlHandle {
813    fn shutdown(&self) {
814        self.inner.shutdown()
815    }
816
817    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
818        self.inner.shutdown_with_epitaph(status)
819    }
820
821    fn is_closed(&self) -> bool {
822        self.inner.channel().is_closed()
823    }
824    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
825        self.inner.channel().on_closed()
826    }
827
828    #[cfg(target_os = "fuchsia")]
829    fn signal_peer(
830        &self,
831        clear_mask: zx::Signals,
832        set_mask: zx::Signals,
833    ) -> Result<(), zx_status::Status> {
834        use fidl::Peered;
835        self.inner.channel().signal_peer(clear_mask, set_mask)
836    }
837}
838
839impl ClientControlHandle {}
840
841#[must_use = "FIDL methods require a response to be sent"]
842#[derive(Debug)]
843pub struct ClientWatchServersResponder {
844    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
845    tx_id: u32,
846}
847
848/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
849/// if the responder is dropped without sending a response, so that the client
850/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
851impl std::ops::Drop for ClientWatchServersResponder {
852    fn drop(&mut self) {
853        self.control_handle.shutdown();
854        // Safety: drops once, never accessed again
855        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
856    }
857}
858
859impl fidl::endpoints::Responder for ClientWatchServersResponder {
860    type ControlHandle = ClientControlHandle;
861
862    fn control_handle(&self) -> &ClientControlHandle {
863        &self.control_handle
864    }
865
866    fn drop_without_shutdown(mut self) {
867        // Safety: drops once, never accessed again due to mem::forget
868        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
869        // Prevent Drop from running (which would shut down the channel)
870        std::mem::forget(self);
871    }
872}
873
874impl ClientWatchServersResponder {
875    /// Sends a response to the FIDL transaction.
876    ///
877    /// Sets the channel to shutdown if an error occurs.
878    pub fn send(
879        self,
880        mut servers: &[fidl_fuchsia_net_name::DnsServer_],
881    ) -> Result<(), fidl::Error> {
882        let _result = self.send_raw(servers);
883        if _result.is_err() {
884            self.control_handle.shutdown();
885        }
886        self.drop_without_shutdown();
887        _result
888    }
889
890    /// Similar to "send" but does not shutdown the channel if an error occurs.
891    pub fn send_no_shutdown_on_err(
892        self,
893        mut servers: &[fidl_fuchsia_net_name::DnsServer_],
894    ) -> Result<(), fidl::Error> {
895        let _result = self.send_raw(servers);
896        self.drop_without_shutdown();
897        _result
898    }
899
900    fn send_raw(
901        &self,
902        mut servers: &[fidl_fuchsia_net_name::DnsServer_],
903    ) -> Result<(), fidl::Error> {
904        self.control_handle
905            .inner
906            .send::<fidl_fuchsia_net_name::DnsServerWatcherWatchServersResponse>(
907                (servers,),
908                self.tx_id,
909                0x5748907e7f11b632,
910                fidl::encoding::DynamicFlags::empty(),
911            )
912    }
913}
914
915#[must_use = "FIDL methods require a response to be sent"]
916#[derive(Debug)]
917pub struct ClientWatchAddressResponder {
918    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
919    tx_id: u32,
920}
921
922/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
923/// if the responder is dropped without sending a response, so that the client
924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
925impl std::ops::Drop for ClientWatchAddressResponder {
926    fn drop(&mut self) {
927        self.control_handle.shutdown();
928        // Safety: drops once, never accessed again
929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
930    }
931}
932
933impl fidl::endpoints::Responder for ClientWatchAddressResponder {
934    type ControlHandle = ClientControlHandle;
935
936    fn control_handle(&self) -> &ClientControlHandle {
937        &self.control_handle
938    }
939
940    fn drop_without_shutdown(mut self) {
941        // Safety: drops once, never accessed again due to mem::forget
942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
943        // Prevent Drop from running (which would shut down the channel)
944        std::mem::forget(self);
945    }
946}
947
948impl ClientWatchAddressResponder {
949    /// Sends a response to the FIDL transaction.
950    ///
951    /// Sets the channel to shutdown if an error occurs.
952    pub fn send(
953        self,
954        mut address: &fidl_fuchsia_net::Subnet,
955        mut address_parameters: &fidl_fuchsia_net_interfaces_admin::AddressParameters,
956        mut address_state_provider: fidl::endpoints::ServerEnd<
957            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
958        >,
959    ) -> Result<(), fidl::Error> {
960        let _result = self.send_raw(address, address_parameters, address_state_provider);
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(
970        self,
971        mut address: &fidl_fuchsia_net::Subnet,
972        mut address_parameters: &fidl_fuchsia_net_interfaces_admin::AddressParameters,
973        mut address_state_provider: fidl::endpoints::ServerEnd<
974            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
975        >,
976    ) -> Result<(), fidl::Error> {
977        let _result = self.send_raw(address, address_parameters, address_state_provider);
978        self.drop_without_shutdown();
979        _result
980    }
981
982    fn send_raw(
983        &self,
984        mut address: &fidl_fuchsia_net::Subnet,
985        mut address_parameters: &fidl_fuchsia_net_interfaces_admin::AddressParameters,
986        mut address_state_provider: fidl::endpoints::ServerEnd<
987            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
988        >,
989    ) -> Result<(), fidl::Error> {
990        self.control_handle.inner.send::<ClientWatchAddressResponse>(
991            (address, address_parameters, address_state_provider),
992            self.tx_id,
993            0x942e6f66f63721c,
994            fidl::encoding::DynamicFlags::empty(),
995        )
996    }
997}
998
999#[must_use = "FIDL methods require a response to be sent"]
1000#[derive(Debug)]
1001pub struct ClientWatchPrefixesResponder {
1002    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
1003    tx_id: u32,
1004}
1005
1006/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
1007/// if the responder is dropped without sending a response, so that the client
1008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1009impl std::ops::Drop for ClientWatchPrefixesResponder {
1010    fn drop(&mut self) {
1011        self.control_handle.shutdown();
1012        // Safety: drops once, never accessed again
1013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1014    }
1015}
1016
1017impl fidl::endpoints::Responder for ClientWatchPrefixesResponder {
1018    type ControlHandle = ClientControlHandle;
1019
1020    fn control_handle(&self) -> &ClientControlHandle {
1021        &self.control_handle
1022    }
1023
1024    fn drop_without_shutdown(mut self) {
1025        // Safety: drops once, never accessed again due to mem::forget
1026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1027        // Prevent Drop from running (which would shut down the channel)
1028        std::mem::forget(self);
1029    }
1030}
1031
1032impl ClientWatchPrefixesResponder {
1033    /// Sends a response to the FIDL transaction.
1034    ///
1035    /// Sets the channel to shutdown if an error occurs.
1036    pub fn send(self, mut prefixes: &[Prefix]) -> Result<(), fidl::Error> {
1037        let _result = self.send_raw(prefixes);
1038        if _result.is_err() {
1039            self.control_handle.shutdown();
1040        }
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    /// Similar to "send" but does not shutdown the channel if an error occurs.
1046    pub fn send_no_shutdown_on_err(self, mut prefixes: &[Prefix]) -> Result<(), fidl::Error> {
1047        let _result = self.send_raw(prefixes);
1048        self.drop_without_shutdown();
1049        _result
1050    }
1051
1052    fn send_raw(&self, mut prefixes: &[Prefix]) -> Result<(), fidl::Error> {
1053        self.control_handle.inner.send::<ClientWatchPrefixesResponse>(
1054            (prefixes,),
1055            self.tx_id,
1056            0x3b7908cc71ae2a5e,
1057            fidl::encoding::DynamicFlags::empty(),
1058        )
1059    }
1060}
1061
1062#[must_use = "FIDL methods require a response to be sent"]
1063#[derive(Debug)]
1064pub struct ClientShutdownResponder {
1065    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
1066    tx_id: u32,
1067}
1068
1069/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
1070/// if the responder is dropped without sending a response, so that the client
1071/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1072impl std::ops::Drop for ClientShutdownResponder {
1073    fn drop(&mut self) {
1074        self.control_handle.shutdown();
1075        // Safety: drops once, never accessed again
1076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1077    }
1078}
1079
1080impl fidl::endpoints::Responder for ClientShutdownResponder {
1081    type ControlHandle = ClientControlHandle;
1082
1083    fn control_handle(&self) -> &ClientControlHandle {
1084        &self.control_handle
1085    }
1086
1087    fn drop_without_shutdown(mut self) {
1088        // Safety: drops once, never accessed again due to mem::forget
1089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1090        // Prevent Drop from running (which would shut down the channel)
1091        std::mem::forget(self);
1092    }
1093}
1094
1095impl ClientShutdownResponder {
1096    /// Sends a response to the FIDL transaction.
1097    ///
1098    /// Sets the channel to shutdown if an error occurs.
1099    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1100        let _result = self.send_raw(result);
1101        if _result.is_err() {
1102            self.control_handle.shutdown();
1103        }
1104        self.drop_without_shutdown();
1105        _result
1106    }
1107
1108    /// Similar to "send" but does not shutdown the channel if an error occurs.
1109    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1110        let _result = self.send_raw(result);
1111        self.drop_without_shutdown();
1112        _result
1113    }
1114
1115    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1116        self.control_handle
1117            .inner
1118            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1119                result,
1120                self.tx_id,
1121                0x6da95f1bcd43fa11,
1122                fidl::encoding::DynamicFlags::empty(),
1123            )
1124    }
1125}
1126
1127#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1128pub struct ClientProviderMarker;
1129
1130impl fidl::endpoints::ProtocolMarker for ClientProviderMarker {
1131    type Proxy = ClientProviderProxy;
1132    type RequestStream = ClientProviderRequestStream;
1133    #[cfg(target_os = "fuchsia")]
1134    type SynchronousProxy = ClientProviderSynchronousProxy;
1135
1136    const DEBUG_NAME: &'static str = "fuchsia.net.dhcpv6.ClientProvider";
1137}
1138impl fidl::endpoints::DiscoverableProtocolMarker for ClientProviderMarker {}
1139
1140pub trait ClientProviderProxyInterface: Send + Sync {
1141    fn r#new_client(
1142        &self,
1143        params: &NewClientParams,
1144        request: fidl::endpoints::ServerEnd<ClientMarker>,
1145    ) -> Result<(), fidl::Error>;
1146}
1147#[derive(Debug)]
1148#[cfg(target_os = "fuchsia")]
1149pub struct ClientProviderSynchronousProxy {
1150    client: fidl::client::sync::Client,
1151}
1152
1153#[cfg(target_os = "fuchsia")]
1154impl fidl::endpoints::SynchronousProxy for ClientProviderSynchronousProxy {
1155    type Proxy = ClientProviderProxy;
1156    type Protocol = ClientProviderMarker;
1157
1158    fn from_channel(inner: fidl::Channel) -> Self {
1159        Self::new(inner)
1160    }
1161
1162    fn into_channel(self) -> fidl::Channel {
1163        self.client.into_channel()
1164    }
1165
1166    fn as_channel(&self) -> &fidl::Channel {
1167        self.client.as_channel()
1168    }
1169}
1170
1171#[cfg(target_os = "fuchsia")]
1172impl ClientProviderSynchronousProxy {
1173    pub fn new(channel: fidl::Channel) -> Self {
1174        Self { client: fidl::client::sync::Client::new(channel) }
1175    }
1176
1177    pub fn into_channel(self) -> fidl::Channel {
1178        self.client.into_channel()
1179    }
1180
1181    /// Waits until an event arrives and returns it. It is safe for other
1182    /// threads to make concurrent requests while waiting for an event.
1183    pub fn wait_for_event(
1184        &self,
1185        deadline: zx::MonotonicInstant,
1186    ) -> Result<ClientProviderEvent, fidl::Error> {
1187        ClientProviderEvent::decode(self.client.wait_for_event::<ClientProviderMarker>(deadline)?)
1188    }
1189
1190    /// Provides a DHCPv6 client.
1191    ///
1192    /// + request `params` the parameters to create the client with.
1193    /// + request `request` grants control over the client. Closed with an
1194    ///     epitaph if the client cannot be created.
1195    pub fn r#new_client(
1196        &self,
1197        mut params: &NewClientParams,
1198        mut request: fidl::endpoints::ServerEnd<ClientMarker>,
1199    ) -> Result<(), fidl::Error> {
1200        self.client.send::<ClientProviderNewClientRequest>(
1201            (params, request),
1202            0x269268c97d062419,
1203            fidl::encoding::DynamicFlags::empty(),
1204        )
1205    }
1206}
1207
1208#[cfg(target_os = "fuchsia")]
1209impl From<ClientProviderSynchronousProxy> for zx::NullableHandle {
1210    fn from(value: ClientProviderSynchronousProxy) -> Self {
1211        value.into_channel().into()
1212    }
1213}
1214
1215#[cfg(target_os = "fuchsia")]
1216impl From<fidl::Channel> for ClientProviderSynchronousProxy {
1217    fn from(value: fidl::Channel) -> Self {
1218        Self::new(value)
1219    }
1220}
1221
1222#[cfg(target_os = "fuchsia")]
1223impl fidl::endpoints::FromClient for ClientProviderSynchronousProxy {
1224    type Protocol = ClientProviderMarker;
1225
1226    fn from_client(value: fidl::endpoints::ClientEnd<ClientProviderMarker>) -> Self {
1227        Self::new(value.into_channel())
1228    }
1229}
1230
1231#[derive(Debug, Clone)]
1232pub struct ClientProviderProxy {
1233    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1234}
1235
1236impl fidl::endpoints::Proxy for ClientProviderProxy {
1237    type Protocol = ClientProviderMarker;
1238
1239    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1240        Self::new(inner)
1241    }
1242
1243    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1244        self.client.into_channel().map_err(|client| Self { client })
1245    }
1246
1247    fn as_channel(&self) -> &::fidl::AsyncChannel {
1248        self.client.as_channel()
1249    }
1250}
1251
1252impl ClientProviderProxy {
1253    /// Create a new Proxy for fuchsia.net.dhcpv6/ClientProvider.
1254    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1255        let protocol_name = <ClientProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1256        Self { client: fidl::client::Client::new(channel, protocol_name) }
1257    }
1258
1259    /// Get a Stream of events from the remote end of the protocol.
1260    ///
1261    /// # Panics
1262    ///
1263    /// Panics if the event stream was already taken.
1264    pub fn take_event_stream(&self) -> ClientProviderEventStream {
1265        ClientProviderEventStream { event_receiver: self.client.take_event_receiver() }
1266    }
1267
1268    /// Provides a DHCPv6 client.
1269    ///
1270    /// + request `params` the parameters to create the client with.
1271    /// + request `request` grants control over the client. Closed with an
1272    ///     epitaph if the client cannot be created.
1273    pub fn r#new_client(
1274        &self,
1275        mut params: &NewClientParams,
1276        mut request: fidl::endpoints::ServerEnd<ClientMarker>,
1277    ) -> Result<(), fidl::Error> {
1278        ClientProviderProxyInterface::r#new_client(self, params, request)
1279    }
1280}
1281
1282impl ClientProviderProxyInterface for ClientProviderProxy {
1283    fn r#new_client(
1284        &self,
1285        mut params: &NewClientParams,
1286        mut request: fidl::endpoints::ServerEnd<ClientMarker>,
1287    ) -> Result<(), fidl::Error> {
1288        self.client.send::<ClientProviderNewClientRequest>(
1289            (params, request),
1290            0x269268c97d062419,
1291            fidl::encoding::DynamicFlags::empty(),
1292        )
1293    }
1294}
1295
1296pub struct ClientProviderEventStream {
1297    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1298}
1299
1300impl std::marker::Unpin for ClientProviderEventStream {}
1301
1302impl futures::stream::FusedStream for ClientProviderEventStream {
1303    fn is_terminated(&self) -> bool {
1304        self.event_receiver.is_terminated()
1305    }
1306}
1307
1308impl futures::Stream for ClientProviderEventStream {
1309    type Item = Result<ClientProviderEvent, fidl::Error>;
1310
1311    fn poll_next(
1312        mut self: std::pin::Pin<&mut Self>,
1313        cx: &mut std::task::Context<'_>,
1314    ) -> std::task::Poll<Option<Self::Item>> {
1315        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1316            &mut self.event_receiver,
1317            cx
1318        )?) {
1319            Some(buf) => std::task::Poll::Ready(Some(ClientProviderEvent::decode(buf))),
1320            None => std::task::Poll::Ready(None),
1321        }
1322    }
1323}
1324
1325#[derive(Debug)]
1326pub enum ClientProviderEvent {}
1327
1328impl ClientProviderEvent {
1329    /// Decodes a message buffer as a [`ClientProviderEvent`].
1330    fn decode(
1331        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1332    ) -> Result<ClientProviderEvent, fidl::Error> {
1333        let (bytes, _handles) = buf.split_mut();
1334        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1335        debug_assert_eq!(tx_header.tx_id, 0);
1336        match tx_header.ordinal {
1337            _ => Err(fidl::Error::UnknownOrdinal {
1338                ordinal: tx_header.ordinal,
1339                protocol_name:
1340                    <ClientProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1341            }),
1342        }
1343    }
1344}
1345
1346/// A Stream of incoming requests for fuchsia.net.dhcpv6/ClientProvider.
1347pub struct ClientProviderRequestStream {
1348    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1349    is_terminated: bool,
1350}
1351
1352impl std::marker::Unpin for ClientProviderRequestStream {}
1353
1354impl futures::stream::FusedStream for ClientProviderRequestStream {
1355    fn is_terminated(&self) -> bool {
1356        self.is_terminated
1357    }
1358}
1359
1360impl fidl::endpoints::RequestStream for ClientProviderRequestStream {
1361    type Protocol = ClientProviderMarker;
1362    type ControlHandle = ClientProviderControlHandle;
1363
1364    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1365        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1366    }
1367
1368    fn control_handle(&self) -> Self::ControlHandle {
1369        ClientProviderControlHandle { inner: self.inner.clone() }
1370    }
1371
1372    fn into_inner(
1373        self,
1374    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1375    {
1376        (self.inner, self.is_terminated)
1377    }
1378
1379    fn from_inner(
1380        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1381        is_terminated: bool,
1382    ) -> Self {
1383        Self { inner, is_terminated }
1384    }
1385}
1386
1387impl futures::Stream for ClientProviderRequestStream {
1388    type Item = Result<ClientProviderRequest, fidl::Error>;
1389
1390    fn poll_next(
1391        mut self: std::pin::Pin<&mut Self>,
1392        cx: &mut std::task::Context<'_>,
1393    ) -> std::task::Poll<Option<Self::Item>> {
1394        let this = &mut *self;
1395        if this.inner.check_shutdown(cx) {
1396            this.is_terminated = true;
1397            return std::task::Poll::Ready(None);
1398        }
1399        if this.is_terminated {
1400            panic!("polled ClientProviderRequestStream after completion");
1401        }
1402        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1403            |bytes, handles| {
1404                match this.inner.channel().read_etc(cx, bytes, handles) {
1405                    std::task::Poll::Ready(Ok(())) => {}
1406                    std::task::Poll::Pending => return std::task::Poll::Pending,
1407                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1408                        this.is_terminated = true;
1409                        return std::task::Poll::Ready(None);
1410                    }
1411                    std::task::Poll::Ready(Err(e)) => {
1412                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1413                            e.into(),
1414                        ))));
1415                    }
1416                }
1417
1418                // A message has been received from the channel
1419                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1420
1421                std::task::Poll::Ready(Some(match header.ordinal {
1422                    0x269268c97d062419 => {
1423                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1424                        let mut req = fidl::new_empty!(
1425                            ClientProviderNewClientRequest,
1426                            fidl::encoding::DefaultFuchsiaResourceDialect
1427                        );
1428                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientProviderNewClientRequest>(&header, _body_bytes, handles, &mut req)?;
1429                        let control_handle =
1430                            ClientProviderControlHandle { inner: this.inner.clone() };
1431                        Ok(ClientProviderRequest::NewClient {
1432                            params: req.params,
1433                            request: req.request,
1434
1435                            control_handle,
1436                        })
1437                    }
1438                    _ => Err(fidl::Error::UnknownOrdinal {
1439                        ordinal: header.ordinal,
1440                        protocol_name:
1441                            <ClientProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1442                    }),
1443                }))
1444            },
1445        )
1446    }
1447}
1448
1449/// Provides a method to create new clients.
1450#[derive(Debug)]
1451pub enum ClientProviderRequest {
1452    /// Provides a DHCPv6 client.
1453    ///
1454    /// + request `params` the parameters to create the client with.
1455    /// + request `request` grants control over the client. Closed with an
1456    ///     epitaph if the client cannot be created.
1457    NewClient {
1458        params: NewClientParams,
1459        request: fidl::endpoints::ServerEnd<ClientMarker>,
1460        control_handle: ClientProviderControlHandle,
1461    },
1462}
1463
1464impl ClientProviderRequest {
1465    #[allow(irrefutable_let_patterns)]
1466    pub fn into_new_client(
1467        self,
1468    ) -> Option<(
1469        NewClientParams,
1470        fidl::endpoints::ServerEnd<ClientMarker>,
1471        ClientProviderControlHandle,
1472    )> {
1473        if let ClientProviderRequest::NewClient { params, request, control_handle } = self {
1474            Some((params, request, control_handle))
1475        } else {
1476            None
1477        }
1478    }
1479
1480    /// Name of the method defined in FIDL
1481    pub fn method_name(&self) -> &'static str {
1482        match *self {
1483            ClientProviderRequest::NewClient { .. } => "new_client",
1484        }
1485    }
1486}
1487
1488#[derive(Debug, Clone)]
1489pub struct ClientProviderControlHandle {
1490    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1491}
1492
1493impl ClientProviderControlHandle {
1494    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1495        self.inner.shutdown_with_epitaph(status.into())
1496    }
1497}
1498
1499impl fidl::endpoints::ControlHandle for ClientProviderControlHandle {
1500    fn shutdown(&self) {
1501        self.inner.shutdown()
1502    }
1503
1504    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1505        self.inner.shutdown_with_epitaph(status)
1506    }
1507
1508    fn is_closed(&self) -> bool {
1509        self.inner.channel().is_closed()
1510    }
1511    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1512        self.inner.channel().on_closed()
1513    }
1514
1515    #[cfg(target_os = "fuchsia")]
1516    fn signal_peer(
1517        &self,
1518        clear_mask: zx::Signals,
1519        set_mask: zx::Signals,
1520    ) -> Result<(), zx_status::Status> {
1521        use fidl::Peered;
1522        self.inner.channel().signal_peer(clear_mask, set_mask)
1523    }
1524}
1525
1526impl ClientProviderControlHandle {}
1527
1528#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1529pub struct PrefixControlMarker;
1530
1531impl fidl::endpoints::ProtocolMarker for PrefixControlMarker {
1532    type Proxy = PrefixControlProxy;
1533    type RequestStream = PrefixControlRequestStream;
1534    #[cfg(target_os = "fuchsia")]
1535    type SynchronousProxy = PrefixControlSynchronousProxy;
1536
1537    const DEBUG_NAME: &'static str = "(anonymous) PrefixControl";
1538}
1539
1540pub trait PrefixControlProxyInterface: Send + Sync {
1541    type WatchPrefixResponseFut: std::future::Future<Output = Result<PrefixEvent, fidl::Error>>
1542        + Send;
1543    fn r#watch_prefix(&self) -> Self::WatchPrefixResponseFut;
1544    fn r#stop(&self) -> Result<(), fidl::Error>;
1545}
1546#[derive(Debug)]
1547#[cfg(target_os = "fuchsia")]
1548pub struct PrefixControlSynchronousProxy {
1549    client: fidl::client::sync::Client,
1550}
1551
1552#[cfg(target_os = "fuchsia")]
1553impl fidl::endpoints::SynchronousProxy for PrefixControlSynchronousProxy {
1554    type Proxy = PrefixControlProxy;
1555    type Protocol = PrefixControlMarker;
1556
1557    fn from_channel(inner: fidl::Channel) -> Self {
1558        Self::new(inner)
1559    }
1560
1561    fn into_channel(self) -> fidl::Channel {
1562        self.client.into_channel()
1563    }
1564
1565    fn as_channel(&self) -> &fidl::Channel {
1566        self.client.as_channel()
1567    }
1568}
1569
1570#[cfg(target_os = "fuchsia")]
1571impl PrefixControlSynchronousProxy {
1572    pub fn new(channel: fidl::Channel) -> Self {
1573        Self { client: fidl::client::sync::Client::new(channel) }
1574    }
1575
1576    pub fn into_channel(self) -> fidl::Channel {
1577        self.client.into_channel()
1578    }
1579
1580    /// Waits until an event arrives and returns it. It is safe for other
1581    /// threads to make concurrent requests while waiting for an event.
1582    pub fn wait_for_event(
1583        &self,
1584        deadline: zx::MonotonicInstant,
1585    ) -> Result<PrefixControlEvent, fidl::Error> {
1586        PrefixControlEvent::decode(self.client.wait_for_event::<PrefixControlMarker>(deadline)?)
1587    }
1588
1589    /// Hanging get for the prefix and its lifetimes.
1590    ///
1591    /// The first call to this method is guaranteed to return
1592    /// [`PrefixEvent.assigned`], and will occur when there is a prefix
1593    /// to report. Subsequent calls will return immediately if there is a
1594    /// change to report, or block until a change occurs.
1595    ///
1596    /// It is invalid to call this method while a previous call is pending.
1597    /// Doing so will cause the server end of the protocol to be closed with
1598    /// the terminal event [`PrefixControlExitReason.DOUBLE_WATCH`].
1599    ///
1600    /// - response `event` an optional prefix.
1601    pub fn r#watch_prefix(
1602        &self,
1603        ___deadline: zx::MonotonicInstant,
1604    ) -> Result<PrefixEvent, fidl::Error> {
1605        let _response = self.client.send_query::<
1606            fidl::encoding::EmptyPayload,
1607            PrefixControlWatchPrefixResponse,
1608            PrefixControlMarker,
1609        >(
1610            (),
1611            0x1f5c40d4d1e84d84,
1612            fidl::encoding::DynamicFlags::empty(),
1613            ___deadline,
1614        )?;
1615        Ok(_response.event)
1616    }
1617
1618    /// Requests prefix acquisition to stop.
1619    ///
1620    /// When called, the server tears down active DHCPv6 client PD on the
1621    /// upstream interface, cleans up internal state, emits [`OnExit`] with
1622    /// [`PrefixControlExitReason.STOPPED`], and closes the server channel.
1623    pub fn r#stop(&self) -> Result<(), fidl::Error> {
1624        self.client.send::<fidl::encoding::EmptyPayload>(
1625            (),
1626            0x13acc61ec17d8dd6,
1627            fidl::encoding::DynamicFlags::empty(),
1628        )
1629    }
1630}
1631
1632#[cfg(target_os = "fuchsia")]
1633impl From<PrefixControlSynchronousProxy> for zx::NullableHandle {
1634    fn from(value: PrefixControlSynchronousProxy) -> Self {
1635        value.into_channel().into()
1636    }
1637}
1638
1639#[cfg(target_os = "fuchsia")]
1640impl From<fidl::Channel> for PrefixControlSynchronousProxy {
1641    fn from(value: fidl::Channel) -> Self {
1642        Self::new(value)
1643    }
1644}
1645
1646#[cfg(target_os = "fuchsia")]
1647impl fidl::endpoints::FromClient for PrefixControlSynchronousProxy {
1648    type Protocol = PrefixControlMarker;
1649
1650    fn from_client(value: fidl::endpoints::ClientEnd<PrefixControlMarker>) -> Self {
1651        Self::new(value.into_channel())
1652    }
1653}
1654
1655#[derive(Debug, Clone)]
1656pub struct PrefixControlProxy {
1657    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1658}
1659
1660impl fidl::endpoints::Proxy for PrefixControlProxy {
1661    type Protocol = PrefixControlMarker;
1662
1663    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1664        Self::new(inner)
1665    }
1666
1667    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1668        self.client.into_channel().map_err(|client| Self { client })
1669    }
1670
1671    fn as_channel(&self) -> &::fidl::AsyncChannel {
1672        self.client.as_channel()
1673    }
1674}
1675
1676impl PrefixControlProxy {
1677    /// Create a new Proxy for fuchsia.net.dhcpv6/PrefixControl.
1678    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1679        let protocol_name = <PrefixControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1680        Self { client: fidl::client::Client::new(channel, protocol_name) }
1681    }
1682
1683    /// Get a Stream of events from the remote end of the protocol.
1684    ///
1685    /// # Panics
1686    ///
1687    /// Panics if the event stream was already taken.
1688    pub fn take_event_stream(&self) -> PrefixControlEventStream {
1689        PrefixControlEventStream { event_receiver: self.client.take_event_receiver() }
1690    }
1691
1692    /// Hanging get for the prefix and its lifetimes.
1693    ///
1694    /// The first call to this method is guaranteed to return
1695    /// [`PrefixEvent.assigned`], and will occur when there is a prefix
1696    /// to report. Subsequent calls will return immediately if there is a
1697    /// change to report, or block until a change occurs.
1698    ///
1699    /// It is invalid to call this method while a previous call is pending.
1700    /// Doing so will cause the server end of the protocol to be closed with
1701    /// the terminal event [`PrefixControlExitReason.DOUBLE_WATCH`].
1702    ///
1703    /// - response `event` an optional prefix.
1704    pub fn r#watch_prefix(
1705        &self,
1706    ) -> fidl::client::QueryResponseFut<PrefixEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
1707    {
1708        PrefixControlProxyInterface::r#watch_prefix(self)
1709    }
1710
1711    /// Requests prefix acquisition to stop.
1712    ///
1713    /// When called, the server tears down active DHCPv6 client PD on the
1714    /// upstream interface, cleans up internal state, emits [`OnExit`] with
1715    /// [`PrefixControlExitReason.STOPPED`], and closes the server channel.
1716    pub fn r#stop(&self) -> Result<(), fidl::Error> {
1717        PrefixControlProxyInterface::r#stop(self)
1718    }
1719}
1720
1721impl PrefixControlProxyInterface for PrefixControlProxy {
1722    type WatchPrefixResponseFut =
1723        fidl::client::QueryResponseFut<PrefixEvent, fidl::encoding::DefaultFuchsiaResourceDialect>;
1724    fn r#watch_prefix(&self) -> Self::WatchPrefixResponseFut {
1725        fn _decode(
1726            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1727        ) -> Result<PrefixEvent, fidl::Error> {
1728            let _response = fidl::client::decode_transaction_body::<
1729                PrefixControlWatchPrefixResponse,
1730                fidl::encoding::DefaultFuchsiaResourceDialect,
1731                0x1f5c40d4d1e84d84,
1732            >(_buf?)?;
1733            Ok(_response.event)
1734        }
1735        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PrefixEvent>(
1736            (),
1737            0x1f5c40d4d1e84d84,
1738            fidl::encoding::DynamicFlags::empty(),
1739            _decode,
1740        )
1741    }
1742
1743    fn r#stop(&self) -> Result<(), fidl::Error> {
1744        self.client.send::<fidl::encoding::EmptyPayload>(
1745            (),
1746            0x13acc61ec17d8dd6,
1747            fidl::encoding::DynamicFlags::empty(),
1748        )
1749    }
1750}
1751
1752pub struct PrefixControlEventStream {
1753    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1754}
1755
1756impl std::marker::Unpin for PrefixControlEventStream {}
1757
1758impl futures::stream::FusedStream for PrefixControlEventStream {
1759    fn is_terminated(&self) -> bool {
1760        self.event_receiver.is_terminated()
1761    }
1762}
1763
1764impl futures::Stream for PrefixControlEventStream {
1765    type Item = Result<PrefixControlEvent, fidl::Error>;
1766
1767    fn poll_next(
1768        mut self: std::pin::Pin<&mut Self>,
1769        cx: &mut std::task::Context<'_>,
1770    ) -> std::task::Poll<Option<Self::Item>> {
1771        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1772            &mut self.event_receiver,
1773            cx
1774        )?) {
1775            Some(buf) => std::task::Poll::Ready(Some(PrefixControlEvent::decode(buf))),
1776            None => std::task::Poll::Ready(None),
1777        }
1778    }
1779}
1780
1781#[derive(Debug)]
1782pub enum PrefixControlEvent {
1783    OnExit { reason: PrefixControlExitReason },
1784}
1785
1786impl PrefixControlEvent {
1787    #[allow(irrefutable_let_patterns)]
1788    pub fn into_on_exit(self) -> Option<PrefixControlExitReason> {
1789        if let PrefixControlEvent::OnExit { reason } = self { Some((reason)) } else { None }
1790    }
1791
1792    /// Decodes a message buffer as a [`PrefixControlEvent`].
1793    fn decode(
1794        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1795    ) -> Result<PrefixControlEvent, fidl::Error> {
1796        let (bytes, _handles) = buf.split_mut();
1797        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1798        debug_assert_eq!(tx_header.tx_id, 0);
1799        match tx_header.ordinal {
1800            0x353b8c435cbe08f9 => {
1801                let mut out = fidl::new_empty!(
1802                    PrefixControlOnExitRequest,
1803                    fidl::encoding::DefaultFuchsiaResourceDialect
1804                );
1805                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrefixControlOnExitRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1806                Ok((PrefixControlEvent::OnExit { reason: out.reason }))
1807            }
1808            _ => Err(fidl::Error::UnknownOrdinal {
1809                ordinal: tx_header.ordinal,
1810                protocol_name: <PrefixControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1811            }),
1812        }
1813    }
1814}
1815
1816/// A Stream of incoming requests for fuchsia.net.dhcpv6/PrefixControl.
1817pub struct PrefixControlRequestStream {
1818    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1819    is_terminated: bool,
1820}
1821
1822impl std::marker::Unpin for PrefixControlRequestStream {}
1823
1824impl futures::stream::FusedStream for PrefixControlRequestStream {
1825    fn is_terminated(&self) -> bool {
1826        self.is_terminated
1827    }
1828}
1829
1830impl fidl::endpoints::RequestStream for PrefixControlRequestStream {
1831    type Protocol = PrefixControlMarker;
1832    type ControlHandle = PrefixControlControlHandle;
1833
1834    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1835        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1836    }
1837
1838    fn control_handle(&self) -> Self::ControlHandle {
1839        PrefixControlControlHandle { inner: self.inner.clone() }
1840    }
1841
1842    fn into_inner(
1843        self,
1844    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1845    {
1846        (self.inner, self.is_terminated)
1847    }
1848
1849    fn from_inner(
1850        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1851        is_terminated: bool,
1852    ) -> Self {
1853        Self { inner, is_terminated }
1854    }
1855}
1856
1857impl futures::Stream for PrefixControlRequestStream {
1858    type Item = Result<PrefixControlRequest, fidl::Error>;
1859
1860    fn poll_next(
1861        mut self: std::pin::Pin<&mut Self>,
1862        cx: &mut std::task::Context<'_>,
1863    ) -> std::task::Poll<Option<Self::Item>> {
1864        let this = &mut *self;
1865        if this.inner.check_shutdown(cx) {
1866            this.is_terminated = true;
1867            return std::task::Poll::Ready(None);
1868        }
1869        if this.is_terminated {
1870            panic!("polled PrefixControlRequestStream after completion");
1871        }
1872        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1873            |bytes, handles| {
1874                match this.inner.channel().read_etc(cx, bytes, handles) {
1875                    std::task::Poll::Ready(Ok(())) => {}
1876                    std::task::Poll::Pending => return std::task::Poll::Pending,
1877                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1878                        this.is_terminated = true;
1879                        return std::task::Poll::Ready(None);
1880                    }
1881                    std::task::Poll::Ready(Err(e)) => {
1882                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1883                            e.into(),
1884                        ))));
1885                    }
1886                }
1887
1888                // A message has been received from the channel
1889                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1890
1891                std::task::Poll::Ready(Some(match header.ordinal {
1892                    0x1f5c40d4d1e84d84 => {
1893                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1894                        let mut req = fidl::new_empty!(
1895                            fidl::encoding::EmptyPayload,
1896                            fidl::encoding::DefaultFuchsiaResourceDialect
1897                        );
1898                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1899                        let control_handle =
1900                            PrefixControlControlHandle { inner: this.inner.clone() };
1901                        Ok(PrefixControlRequest::WatchPrefix {
1902                            responder: PrefixControlWatchPrefixResponder {
1903                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1904                                tx_id: header.tx_id,
1905                            },
1906                        })
1907                    }
1908                    0x13acc61ec17d8dd6 => {
1909                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1910                        let mut req = fidl::new_empty!(
1911                            fidl::encoding::EmptyPayload,
1912                            fidl::encoding::DefaultFuchsiaResourceDialect
1913                        );
1914                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1915                        let control_handle =
1916                            PrefixControlControlHandle { inner: this.inner.clone() };
1917                        Ok(PrefixControlRequest::Stop { control_handle })
1918                    }
1919                    _ => Err(fidl::Error::UnknownOrdinal {
1920                        ordinal: header.ordinal,
1921                        protocol_name:
1922                            <PrefixControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1923                    }),
1924                }))
1925            },
1926        )
1927    }
1928}
1929
1930/// Provides control over prefix acquisition.
1931///
1932/// If the client end is closed, prefix acquisition will stop. This means that
1933/// a best effort will be made to release leases back to the server, and no
1934/// further attempt will be made to acquire any of the prefixes this protocol
1935/// was configured to acquire.
1936#[derive(Debug)]
1937pub enum PrefixControlRequest {
1938    /// Hanging get for the prefix and its lifetimes.
1939    ///
1940    /// The first call to this method is guaranteed to return
1941    /// [`PrefixEvent.assigned`], and will occur when there is a prefix
1942    /// to report. Subsequent calls will return immediately if there is a
1943    /// change to report, or block until a change occurs.
1944    ///
1945    /// It is invalid to call this method while a previous call is pending.
1946    /// Doing so will cause the server end of the protocol to be closed with
1947    /// the terminal event [`PrefixControlExitReason.DOUBLE_WATCH`].
1948    ///
1949    /// - response `event` an optional prefix.
1950    WatchPrefix { responder: PrefixControlWatchPrefixResponder },
1951    /// Requests prefix acquisition to stop.
1952    ///
1953    /// When called, the server tears down active DHCPv6 client PD on the
1954    /// upstream interface, cleans up internal state, emits [`OnExit`] with
1955    /// [`PrefixControlExitReason.STOPPED`], and closes the server channel.
1956    Stop { control_handle: PrefixControlControlHandle },
1957}
1958
1959impl PrefixControlRequest {
1960    #[allow(irrefutable_let_patterns)]
1961    pub fn into_watch_prefix(self) -> Option<(PrefixControlWatchPrefixResponder)> {
1962        if let PrefixControlRequest::WatchPrefix { responder } = self {
1963            Some((responder))
1964        } else {
1965            None
1966        }
1967    }
1968
1969    #[allow(irrefutable_let_patterns)]
1970    pub fn into_stop(self) -> Option<(PrefixControlControlHandle)> {
1971        if let PrefixControlRequest::Stop { control_handle } = self {
1972            Some((control_handle))
1973        } else {
1974            None
1975        }
1976    }
1977
1978    /// Name of the method defined in FIDL
1979    pub fn method_name(&self) -> &'static str {
1980        match *self {
1981            PrefixControlRequest::WatchPrefix { .. } => "watch_prefix",
1982            PrefixControlRequest::Stop { .. } => "stop",
1983        }
1984    }
1985}
1986
1987#[derive(Debug, Clone)]
1988pub struct PrefixControlControlHandle {
1989    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1990}
1991
1992impl PrefixControlControlHandle {
1993    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1994        self.inner.shutdown_with_epitaph(status.into())
1995    }
1996}
1997
1998impl fidl::endpoints::ControlHandle for PrefixControlControlHandle {
1999    fn shutdown(&self) {
2000        self.inner.shutdown()
2001    }
2002
2003    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2004        self.inner.shutdown_with_epitaph(status)
2005    }
2006
2007    fn is_closed(&self) -> bool {
2008        self.inner.channel().is_closed()
2009    }
2010    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2011        self.inner.channel().on_closed()
2012    }
2013
2014    #[cfg(target_os = "fuchsia")]
2015    fn signal_peer(
2016        &self,
2017        clear_mask: zx::Signals,
2018        set_mask: zx::Signals,
2019    ) -> Result<(), zx_status::Status> {
2020        use fidl::Peered;
2021        self.inner.channel().signal_peer(clear_mask, set_mask)
2022    }
2023}
2024
2025impl PrefixControlControlHandle {
2026    pub fn send_on_exit(&self, mut reason: PrefixControlExitReason) -> Result<(), fidl::Error> {
2027        self.inner.send::<PrefixControlOnExitRequest>(
2028            (reason,),
2029            0,
2030            0x353b8c435cbe08f9,
2031            fidl::encoding::DynamicFlags::empty(),
2032        )
2033    }
2034}
2035
2036#[must_use = "FIDL methods require a response to be sent"]
2037#[derive(Debug)]
2038pub struct PrefixControlWatchPrefixResponder {
2039    control_handle: std::mem::ManuallyDrop<PrefixControlControlHandle>,
2040    tx_id: u32,
2041}
2042
2043/// Set the the channel to be shutdown (see [`PrefixControlControlHandle::shutdown`])
2044/// if the responder is dropped without sending a response, so that the client
2045/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2046impl std::ops::Drop for PrefixControlWatchPrefixResponder {
2047    fn drop(&mut self) {
2048        self.control_handle.shutdown();
2049        // Safety: drops once, never accessed again
2050        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2051    }
2052}
2053
2054impl fidl::endpoints::Responder for PrefixControlWatchPrefixResponder {
2055    type ControlHandle = PrefixControlControlHandle;
2056
2057    fn control_handle(&self) -> &PrefixControlControlHandle {
2058        &self.control_handle
2059    }
2060
2061    fn drop_without_shutdown(mut self) {
2062        // Safety: drops once, never accessed again due to mem::forget
2063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2064        // Prevent Drop from running (which would shut down the channel)
2065        std::mem::forget(self);
2066    }
2067}
2068
2069impl PrefixControlWatchPrefixResponder {
2070    /// Sends a response to the FIDL transaction.
2071    ///
2072    /// Sets the channel to shutdown if an error occurs.
2073    pub fn send(self, mut event: &PrefixEvent) -> Result<(), fidl::Error> {
2074        let _result = self.send_raw(event);
2075        if _result.is_err() {
2076            self.control_handle.shutdown();
2077        }
2078        self.drop_without_shutdown();
2079        _result
2080    }
2081
2082    /// Similar to "send" but does not shutdown the channel if an error occurs.
2083    pub fn send_no_shutdown_on_err(self, mut event: &PrefixEvent) -> Result<(), fidl::Error> {
2084        let _result = self.send_raw(event);
2085        self.drop_without_shutdown();
2086        _result
2087    }
2088
2089    fn send_raw(&self, mut event: &PrefixEvent) -> Result<(), fidl::Error> {
2090        self.control_handle.inner.send::<PrefixControlWatchPrefixResponse>(
2091            (event,),
2092            self.tx_id,
2093            0x1f5c40d4d1e84d84,
2094            fidl::encoding::DynamicFlags::empty(),
2095        )
2096    }
2097}
2098
2099#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2100pub struct PrefixProviderMarker;
2101
2102impl fidl::endpoints::ProtocolMarker for PrefixProviderMarker {
2103    type Proxy = PrefixProviderProxy;
2104    type RequestStream = PrefixProviderRequestStream;
2105    #[cfg(target_os = "fuchsia")]
2106    type SynchronousProxy = PrefixProviderSynchronousProxy;
2107
2108    const DEBUG_NAME: &'static str = "fuchsia.net.dhcpv6.PrefixProvider";
2109}
2110impl fidl::endpoints::DiscoverableProtocolMarker for PrefixProviderMarker {}
2111
2112pub trait PrefixProviderProxyInterface: Send + Sync {
2113    fn r#acquire_prefix(
2114        &self,
2115        config: &AcquirePrefixConfig,
2116        prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
2117    ) -> Result<(), fidl::Error>;
2118}
2119#[derive(Debug)]
2120#[cfg(target_os = "fuchsia")]
2121pub struct PrefixProviderSynchronousProxy {
2122    client: fidl::client::sync::Client,
2123}
2124
2125#[cfg(target_os = "fuchsia")]
2126impl fidl::endpoints::SynchronousProxy for PrefixProviderSynchronousProxy {
2127    type Proxy = PrefixProviderProxy;
2128    type Protocol = PrefixProviderMarker;
2129
2130    fn from_channel(inner: fidl::Channel) -> Self {
2131        Self::new(inner)
2132    }
2133
2134    fn into_channel(self) -> fidl::Channel {
2135        self.client.into_channel()
2136    }
2137
2138    fn as_channel(&self) -> &fidl::Channel {
2139        self.client.as_channel()
2140    }
2141}
2142
2143#[cfg(target_os = "fuchsia")]
2144impl PrefixProviderSynchronousProxy {
2145    pub fn new(channel: fidl::Channel) -> Self {
2146        Self { client: fidl::client::sync::Client::new(channel) }
2147    }
2148
2149    pub fn into_channel(self) -> fidl::Channel {
2150        self.client.into_channel()
2151    }
2152
2153    /// Waits until an event arrives and returns it. It is safe for other
2154    /// threads to make concurrent requests while waiting for an event.
2155    pub fn wait_for_event(
2156        &self,
2157        deadline: zx::MonotonicInstant,
2158    ) -> Result<PrefixProviderEvent, fidl::Error> {
2159        PrefixProviderEvent::decode(self.client.wait_for_event::<PrefixProviderMarker>(deadline)?)
2160    }
2161
2162    /// Acquire an IPv6 prefix via Prefix Delegation.
2163    ///
2164    /// If this method is called with invalid parameters, a terminal event
2165    /// containing a reason detailing why will be sent via
2166    /// [`PrefixControl.OnExit`] and the server end of [`PrefixControl`]
2167    /// will be closed.
2168    ///
2169    /// + request `config` prefix acquisition configuration.
2170    /// + request `prefix` provides control over prefix acquisition.
2171    pub fn r#acquire_prefix(
2172        &self,
2173        mut config: &AcquirePrefixConfig,
2174        mut prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
2175    ) -> Result<(), fidl::Error> {
2176        self.client.send::<PrefixProviderAcquirePrefixRequest>(
2177            (config, prefix),
2178            0x24eff9a5ce404cf8,
2179            fidl::encoding::DynamicFlags::empty(),
2180        )
2181    }
2182}
2183
2184#[cfg(target_os = "fuchsia")]
2185impl From<PrefixProviderSynchronousProxy> for zx::NullableHandle {
2186    fn from(value: PrefixProviderSynchronousProxy) -> Self {
2187        value.into_channel().into()
2188    }
2189}
2190
2191#[cfg(target_os = "fuchsia")]
2192impl From<fidl::Channel> for PrefixProviderSynchronousProxy {
2193    fn from(value: fidl::Channel) -> Self {
2194        Self::new(value)
2195    }
2196}
2197
2198#[cfg(target_os = "fuchsia")]
2199impl fidl::endpoints::FromClient for PrefixProviderSynchronousProxy {
2200    type Protocol = PrefixProviderMarker;
2201
2202    fn from_client(value: fidl::endpoints::ClientEnd<PrefixProviderMarker>) -> Self {
2203        Self::new(value.into_channel())
2204    }
2205}
2206
2207#[derive(Debug, Clone)]
2208pub struct PrefixProviderProxy {
2209    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2210}
2211
2212impl fidl::endpoints::Proxy for PrefixProviderProxy {
2213    type Protocol = PrefixProviderMarker;
2214
2215    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2216        Self::new(inner)
2217    }
2218
2219    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2220        self.client.into_channel().map_err(|client| Self { client })
2221    }
2222
2223    fn as_channel(&self) -> &::fidl::AsyncChannel {
2224        self.client.as_channel()
2225    }
2226}
2227
2228impl PrefixProviderProxy {
2229    /// Create a new Proxy for fuchsia.net.dhcpv6/PrefixProvider.
2230    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2231        let protocol_name = <PrefixProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2232        Self { client: fidl::client::Client::new(channel, protocol_name) }
2233    }
2234
2235    /// Get a Stream of events from the remote end of the protocol.
2236    ///
2237    /// # Panics
2238    ///
2239    /// Panics if the event stream was already taken.
2240    pub fn take_event_stream(&self) -> PrefixProviderEventStream {
2241        PrefixProviderEventStream { event_receiver: self.client.take_event_receiver() }
2242    }
2243
2244    /// Acquire an IPv6 prefix via Prefix Delegation.
2245    ///
2246    /// If this method is called with invalid parameters, a terminal event
2247    /// containing a reason detailing why will be sent via
2248    /// [`PrefixControl.OnExit`] and the server end of [`PrefixControl`]
2249    /// will be closed.
2250    ///
2251    /// + request `config` prefix acquisition configuration.
2252    /// + request `prefix` provides control over prefix acquisition.
2253    pub fn r#acquire_prefix(
2254        &self,
2255        mut config: &AcquirePrefixConfig,
2256        mut prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
2257    ) -> Result<(), fidl::Error> {
2258        PrefixProviderProxyInterface::r#acquire_prefix(self, config, prefix)
2259    }
2260}
2261
2262impl PrefixProviderProxyInterface for PrefixProviderProxy {
2263    fn r#acquire_prefix(
2264        &self,
2265        mut config: &AcquirePrefixConfig,
2266        mut prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
2267    ) -> Result<(), fidl::Error> {
2268        self.client.send::<PrefixProviderAcquirePrefixRequest>(
2269            (config, prefix),
2270            0x24eff9a5ce404cf8,
2271            fidl::encoding::DynamicFlags::empty(),
2272        )
2273    }
2274}
2275
2276pub struct PrefixProviderEventStream {
2277    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2278}
2279
2280impl std::marker::Unpin for PrefixProviderEventStream {}
2281
2282impl futures::stream::FusedStream for PrefixProviderEventStream {
2283    fn is_terminated(&self) -> bool {
2284        self.event_receiver.is_terminated()
2285    }
2286}
2287
2288impl futures::Stream for PrefixProviderEventStream {
2289    type Item = Result<PrefixProviderEvent, fidl::Error>;
2290
2291    fn poll_next(
2292        mut self: std::pin::Pin<&mut Self>,
2293        cx: &mut std::task::Context<'_>,
2294    ) -> std::task::Poll<Option<Self::Item>> {
2295        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2296            &mut self.event_receiver,
2297            cx
2298        )?) {
2299            Some(buf) => std::task::Poll::Ready(Some(PrefixProviderEvent::decode(buf))),
2300            None => std::task::Poll::Ready(None),
2301        }
2302    }
2303}
2304
2305#[derive(Debug)]
2306pub enum PrefixProviderEvent {}
2307
2308impl PrefixProviderEvent {
2309    /// Decodes a message buffer as a [`PrefixProviderEvent`].
2310    fn decode(
2311        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2312    ) -> Result<PrefixProviderEvent, fidl::Error> {
2313        let (bytes, _handles) = buf.split_mut();
2314        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2315        debug_assert_eq!(tx_header.tx_id, 0);
2316        match tx_header.ordinal {
2317            _ => Err(fidl::Error::UnknownOrdinal {
2318                ordinal: tx_header.ordinal,
2319                protocol_name:
2320                    <PrefixProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2321            }),
2322        }
2323    }
2324}
2325
2326/// A Stream of incoming requests for fuchsia.net.dhcpv6/PrefixProvider.
2327pub struct PrefixProviderRequestStream {
2328    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2329    is_terminated: bool,
2330}
2331
2332impl std::marker::Unpin for PrefixProviderRequestStream {}
2333
2334impl futures::stream::FusedStream for PrefixProviderRequestStream {
2335    fn is_terminated(&self) -> bool {
2336        self.is_terminated
2337    }
2338}
2339
2340impl fidl::endpoints::RequestStream for PrefixProviderRequestStream {
2341    type Protocol = PrefixProviderMarker;
2342    type ControlHandle = PrefixProviderControlHandle;
2343
2344    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2345        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2346    }
2347
2348    fn control_handle(&self) -> Self::ControlHandle {
2349        PrefixProviderControlHandle { inner: self.inner.clone() }
2350    }
2351
2352    fn into_inner(
2353        self,
2354    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2355    {
2356        (self.inner, self.is_terminated)
2357    }
2358
2359    fn from_inner(
2360        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2361        is_terminated: bool,
2362    ) -> Self {
2363        Self { inner, is_terminated }
2364    }
2365}
2366
2367impl futures::Stream for PrefixProviderRequestStream {
2368    type Item = Result<PrefixProviderRequest, fidl::Error>;
2369
2370    fn poll_next(
2371        mut self: std::pin::Pin<&mut Self>,
2372        cx: &mut std::task::Context<'_>,
2373    ) -> std::task::Poll<Option<Self::Item>> {
2374        let this = &mut *self;
2375        if this.inner.check_shutdown(cx) {
2376            this.is_terminated = true;
2377            return std::task::Poll::Ready(None);
2378        }
2379        if this.is_terminated {
2380            panic!("polled PrefixProviderRequestStream after completion");
2381        }
2382        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2383            |bytes, handles| {
2384                match this.inner.channel().read_etc(cx, bytes, handles) {
2385                    std::task::Poll::Ready(Ok(())) => {}
2386                    std::task::Poll::Pending => return std::task::Poll::Pending,
2387                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2388                        this.is_terminated = true;
2389                        return std::task::Poll::Ready(None);
2390                    }
2391                    std::task::Poll::Ready(Err(e)) => {
2392                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2393                            e.into(),
2394                        ))));
2395                    }
2396                }
2397
2398                // A message has been received from the channel
2399                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2400
2401                std::task::Poll::Ready(Some(match header.ordinal {
2402                    0x24eff9a5ce404cf8 => {
2403                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2404                        let mut req = fidl::new_empty!(
2405                            PrefixProviderAcquirePrefixRequest,
2406                            fidl::encoding::DefaultFuchsiaResourceDialect
2407                        );
2408                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrefixProviderAcquirePrefixRequest>(&header, _body_bytes, handles, &mut req)?;
2409                        let control_handle =
2410                            PrefixProviderControlHandle { inner: this.inner.clone() };
2411                        Ok(PrefixProviderRequest::AcquirePrefix {
2412                            config: req.config,
2413                            prefix: req.prefix,
2414
2415                            control_handle,
2416                        })
2417                    }
2418                    _ => Err(fidl::Error::UnknownOrdinal {
2419                        ordinal: header.ordinal,
2420                        protocol_name:
2421                            <PrefixProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2422                    }),
2423                }))
2424            },
2425        )
2426    }
2427}
2428
2429/// Provides IPv6 prefixes acquired via Prefix delegation.
2430#[derive(Debug)]
2431pub enum PrefixProviderRequest {
2432    /// Acquire an IPv6 prefix via Prefix Delegation.
2433    ///
2434    /// If this method is called with invalid parameters, a terminal event
2435    /// containing a reason detailing why will be sent via
2436    /// [`PrefixControl.OnExit`] and the server end of [`PrefixControl`]
2437    /// will be closed.
2438    ///
2439    /// + request `config` prefix acquisition configuration.
2440    /// + request `prefix` provides control over prefix acquisition.
2441    AcquirePrefix {
2442        config: AcquirePrefixConfig,
2443        prefix: fidl::endpoints::ServerEnd<PrefixControlMarker>,
2444        control_handle: PrefixProviderControlHandle,
2445    },
2446}
2447
2448impl PrefixProviderRequest {
2449    #[allow(irrefutable_let_patterns)]
2450    pub fn into_acquire_prefix(
2451        self,
2452    ) -> Option<(
2453        AcquirePrefixConfig,
2454        fidl::endpoints::ServerEnd<PrefixControlMarker>,
2455        PrefixProviderControlHandle,
2456    )> {
2457        if let PrefixProviderRequest::AcquirePrefix { config, prefix, control_handle } = self {
2458            Some((config, prefix, control_handle))
2459        } else {
2460            None
2461        }
2462    }
2463
2464    /// Name of the method defined in FIDL
2465    pub fn method_name(&self) -> &'static str {
2466        match *self {
2467            PrefixProviderRequest::AcquirePrefix { .. } => "acquire_prefix",
2468        }
2469    }
2470}
2471
2472#[derive(Debug, Clone)]
2473pub struct PrefixProviderControlHandle {
2474    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2475}
2476
2477impl PrefixProviderControlHandle {
2478    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2479        self.inner.shutdown_with_epitaph(status.into())
2480    }
2481}
2482
2483impl fidl::endpoints::ControlHandle for PrefixProviderControlHandle {
2484    fn shutdown(&self) {
2485        self.inner.shutdown()
2486    }
2487
2488    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2489        self.inner.shutdown_with_epitaph(status)
2490    }
2491
2492    fn is_closed(&self) -> bool {
2493        self.inner.channel().is_closed()
2494    }
2495    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2496        self.inner.channel().on_closed()
2497    }
2498
2499    #[cfg(target_os = "fuchsia")]
2500    fn signal_peer(
2501        &self,
2502        clear_mask: zx::Signals,
2503        set_mask: zx::Signals,
2504    ) -> Result<(), zx_status::Status> {
2505        use fidl::Peered;
2506        self.inner.channel().signal_peer(clear_mask, set_mask)
2507    }
2508}
2509
2510impl PrefixProviderControlHandle {}
2511
2512mod internal {
2513    use super::*;
2514
2515    impl fidl::encoding::ResourceTypeMarker for ClientProviderNewClientRequest {
2516        type Borrowed<'a> = &'a mut Self;
2517        fn take_or_borrow<'a>(
2518            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2519        ) -> Self::Borrowed<'a> {
2520            value
2521        }
2522    }
2523
2524    unsafe impl fidl::encoding::TypeMarker for ClientProviderNewClientRequest {
2525        type Owned = Self;
2526
2527        #[inline(always)]
2528        fn inline_align(_context: fidl::encoding::Context) -> usize {
2529            8
2530        }
2531
2532        #[inline(always)]
2533        fn inline_size(_context: fidl::encoding::Context) -> usize {
2534            24
2535        }
2536    }
2537
2538    unsafe impl
2539        fidl::encoding::Encode<
2540            ClientProviderNewClientRequest,
2541            fidl::encoding::DefaultFuchsiaResourceDialect,
2542        > for &mut ClientProviderNewClientRequest
2543    {
2544        #[inline]
2545        unsafe fn encode(
2546            self,
2547            encoder: &mut fidl::encoding::Encoder<
2548                '_,
2549                fidl::encoding::DefaultFuchsiaResourceDialect,
2550            >,
2551            offset: usize,
2552            _depth: fidl::encoding::Depth,
2553        ) -> fidl::Result<()> {
2554            encoder.debug_check_bounds::<ClientProviderNewClientRequest>(offset);
2555            // Delegate to tuple encoding.
2556            fidl::encoding::Encode::<ClientProviderNewClientRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2557                (
2558                    <NewClientParams as fidl::encoding::ValueTypeMarker>::borrow(&self.params),
2559                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
2560                ),
2561                encoder, offset, _depth
2562            )
2563        }
2564    }
2565    unsafe impl<
2566        T0: fidl::encoding::Encode<NewClientParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
2567        T1: fidl::encoding::Encode<
2568                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientMarker>>,
2569                fidl::encoding::DefaultFuchsiaResourceDialect,
2570            >,
2571    >
2572        fidl::encoding::Encode<
2573            ClientProviderNewClientRequest,
2574            fidl::encoding::DefaultFuchsiaResourceDialect,
2575        > for (T0, T1)
2576    {
2577        #[inline]
2578        unsafe fn encode(
2579            self,
2580            encoder: &mut fidl::encoding::Encoder<
2581                '_,
2582                fidl::encoding::DefaultFuchsiaResourceDialect,
2583            >,
2584            offset: usize,
2585            depth: fidl::encoding::Depth,
2586        ) -> fidl::Result<()> {
2587            encoder.debug_check_bounds::<ClientProviderNewClientRequest>(offset);
2588            // Zero out padding regions. There's no need to apply masks
2589            // because the unmasked parts will be overwritten by fields.
2590            unsafe {
2591                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2592                (ptr as *mut u64).write_unaligned(0);
2593            }
2594            // Write the fields.
2595            self.0.encode(encoder, offset + 0, depth)?;
2596            self.1.encode(encoder, offset + 16, depth)?;
2597            Ok(())
2598        }
2599    }
2600
2601    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2602        for ClientProviderNewClientRequest
2603    {
2604        #[inline(always)]
2605        fn new_empty() -> Self {
2606            Self {
2607                params: fidl::new_empty!(
2608                    NewClientParams,
2609                    fidl::encoding::DefaultFuchsiaResourceDialect
2610                ),
2611                request: fidl::new_empty!(
2612                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientMarker>>,
2613                    fidl::encoding::DefaultFuchsiaResourceDialect
2614                ),
2615            }
2616        }
2617
2618        #[inline]
2619        unsafe fn decode(
2620            &mut self,
2621            decoder: &mut fidl::encoding::Decoder<
2622                '_,
2623                fidl::encoding::DefaultFuchsiaResourceDialect,
2624            >,
2625            offset: usize,
2626            _depth: fidl::encoding::Depth,
2627        ) -> fidl::Result<()> {
2628            decoder.debug_check_bounds::<Self>(offset);
2629            // Verify that padding bytes are zero.
2630            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2631            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2632            let mask = 0xffffffff00000000u64;
2633            let maskedval = padval & mask;
2634            if maskedval != 0 {
2635                return Err(fidl::Error::NonZeroPadding {
2636                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2637                });
2638            }
2639            fidl::decode!(
2640                NewClientParams,
2641                fidl::encoding::DefaultFuchsiaResourceDialect,
2642                &mut self.params,
2643                decoder,
2644                offset + 0,
2645                _depth
2646            )?;
2647            fidl::decode!(
2648                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientMarker>>,
2649                fidl::encoding::DefaultFuchsiaResourceDialect,
2650                &mut self.request,
2651                decoder,
2652                offset + 16,
2653                _depth
2654            )?;
2655            Ok(())
2656        }
2657    }
2658
2659    impl fidl::encoding::ResourceTypeMarker for ClientWatchAddressResponse {
2660        type Borrowed<'a> = &'a mut Self;
2661        fn take_or_borrow<'a>(
2662            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2663        ) -> Self::Borrowed<'a> {
2664            value
2665        }
2666    }
2667
2668    unsafe impl fidl::encoding::TypeMarker for ClientWatchAddressResponse {
2669        type Owned = Self;
2670
2671        #[inline(always)]
2672        fn inline_align(_context: fidl::encoding::Context) -> usize {
2673            8
2674        }
2675
2676        #[inline(always)]
2677        fn inline_size(_context: fidl::encoding::Context) -> usize {
2678            48
2679        }
2680    }
2681
2682    unsafe impl
2683        fidl::encoding::Encode<
2684            ClientWatchAddressResponse,
2685            fidl::encoding::DefaultFuchsiaResourceDialect,
2686        > for &mut ClientWatchAddressResponse
2687    {
2688        #[inline]
2689        unsafe fn encode(
2690            self,
2691            encoder: &mut fidl::encoding::Encoder<
2692                '_,
2693                fidl::encoding::DefaultFuchsiaResourceDialect,
2694            >,
2695            offset: usize,
2696            _depth: fidl::encoding::Depth,
2697        ) -> fidl::Result<()> {
2698            encoder.debug_check_bounds::<ClientWatchAddressResponse>(offset);
2699            // Delegate to tuple encoding.
2700            fidl::encoding::Encode::<ClientWatchAddressResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2701                (
2702                    <fidl_fuchsia_net::Subnet as fidl::encoding::ValueTypeMarker>::borrow(&self.address),
2703                    <fidl_fuchsia_net_interfaces_admin::AddressParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.address_parameters),
2704                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.address_state_provider),
2705                ),
2706                encoder, offset, _depth
2707            )
2708        }
2709    }
2710    unsafe impl<
2711        T0: fidl::encoding::Encode<
2712                fidl_fuchsia_net::Subnet,
2713                fidl::encoding::DefaultFuchsiaResourceDialect,
2714            >,
2715        T1: fidl::encoding::Encode<
2716                fidl_fuchsia_net_interfaces_admin::AddressParameters,
2717                fidl::encoding::DefaultFuchsiaResourceDialect,
2718            >,
2719        T2: fidl::encoding::Encode<
2720                fidl::encoding::Endpoint<
2721                    fidl::endpoints::ServerEnd<
2722                        fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
2723                    >,
2724                >,
2725                fidl::encoding::DefaultFuchsiaResourceDialect,
2726            >,
2727    >
2728        fidl::encoding::Encode<
2729            ClientWatchAddressResponse,
2730            fidl::encoding::DefaultFuchsiaResourceDialect,
2731        > for (T0, T1, T2)
2732    {
2733        #[inline]
2734        unsafe fn encode(
2735            self,
2736            encoder: &mut fidl::encoding::Encoder<
2737                '_,
2738                fidl::encoding::DefaultFuchsiaResourceDialect,
2739            >,
2740            offset: usize,
2741            depth: fidl::encoding::Depth,
2742        ) -> fidl::Result<()> {
2743            encoder.debug_check_bounds::<ClientWatchAddressResponse>(offset);
2744            // Zero out padding regions. There's no need to apply masks
2745            // because the unmasked parts will be overwritten by fields.
2746            unsafe {
2747                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
2748                (ptr as *mut u64).write_unaligned(0);
2749            }
2750            // Write the fields.
2751            self.0.encode(encoder, offset + 0, depth)?;
2752            self.1.encode(encoder, offset + 24, depth)?;
2753            self.2.encode(encoder, offset + 40, depth)?;
2754            Ok(())
2755        }
2756    }
2757
2758    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2759        for ClientWatchAddressResponse
2760    {
2761        #[inline(always)]
2762        fn new_empty() -> Self {
2763            Self {
2764                address: fidl::new_empty!(
2765                    fidl_fuchsia_net::Subnet,
2766                    fidl::encoding::DefaultFuchsiaResourceDialect
2767                ),
2768                address_parameters: fidl::new_empty!(
2769                    fidl_fuchsia_net_interfaces_admin::AddressParameters,
2770                    fidl::encoding::DefaultFuchsiaResourceDialect
2771                ),
2772                address_state_provider: fidl::new_empty!(
2773                    fidl::encoding::Endpoint<
2774                        fidl::endpoints::ServerEnd<
2775                            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
2776                        >,
2777                    >,
2778                    fidl::encoding::DefaultFuchsiaResourceDialect
2779                ),
2780            }
2781        }
2782
2783        #[inline]
2784        unsafe fn decode(
2785            &mut self,
2786            decoder: &mut fidl::encoding::Decoder<
2787                '_,
2788                fidl::encoding::DefaultFuchsiaResourceDialect,
2789            >,
2790            offset: usize,
2791            _depth: fidl::encoding::Depth,
2792        ) -> fidl::Result<()> {
2793            decoder.debug_check_bounds::<Self>(offset);
2794            // Verify that padding bytes are zero.
2795            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
2796            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2797            let mask = 0xffffffff00000000u64;
2798            let maskedval = padval & mask;
2799            if maskedval != 0 {
2800                return Err(fidl::Error::NonZeroPadding {
2801                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
2802                });
2803            }
2804            fidl::decode!(
2805                fidl_fuchsia_net::Subnet,
2806                fidl::encoding::DefaultFuchsiaResourceDialect,
2807                &mut self.address,
2808                decoder,
2809                offset + 0,
2810                _depth
2811            )?;
2812            fidl::decode!(
2813                fidl_fuchsia_net_interfaces_admin::AddressParameters,
2814                fidl::encoding::DefaultFuchsiaResourceDialect,
2815                &mut self.address_parameters,
2816                decoder,
2817                offset + 24,
2818                _depth
2819            )?;
2820            fidl::decode!(
2821                fidl::encoding::Endpoint<
2822                    fidl::endpoints::ServerEnd<
2823                        fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
2824                    >,
2825                >,
2826                fidl::encoding::DefaultFuchsiaResourceDialect,
2827                &mut self.address_state_provider,
2828                decoder,
2829                offset + 40,
2830                _depth
2831            )?;
2832            Ok(())
2833        }
2834    }
2835
2836    impl fidl::encoding::ResourceTypeMarker for PrefixProviderAcquirePrefixRequest {
2837        type Borrowed<'a> = &'a mut Self;
2838        fn take_or_borrow<'a>(
2839            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2840        ) -> Self::Borrowed<'a> {
2841            value
2842        }
2843    }
2844
2845    unsafe impl fidl::encoding::TypeMarker for PrefixProviderAcquirePrefixRequest {
2846        type Owned = Self;
2847
2848        #[inline(always)]
2849        fn inline_align(_context: fidl::encoding::Context) -> usize {
2850            8
2851        }
2852
2853        #[inline(always)]
2854        fn inline_size(_context: fidl::encoding::Context) -> usize {
2855            24
2856        }
2857    }
2858
2859    unsafe impl
2860        fidl::encoding::Encode<
2861            PrefixProviderAcquirePrefixRequest,
2862            fidl::encoding::DefaultFuchsiaResourceDialect,
2863        > for &mut PrefixProviderAcquirePrefixRequest
2864    {
2865        #[inline]
2866        unsafe fn encode(
2867            self,
2868            encoder: &mut fidl::encoding::Encoder<
2869                '_,
2870                fidl::encoding::DefaultFuchsiaResourceDialect,
2871            >,
2872            offset: usize,
2873            _depth: fidl::encoding::Depth,
2874        ) -> fidl::Result<()> {
2875            encoder.debug_check_bounds::<PrefixProviderAcquirePrefixRequest>(offset);
2876            // Delegate to tuple encoding.
2877            fidl::encoding::Encode::<PrefixProviderAcquirePrefixRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2878                (
2879                    <AcquirePrefixConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
2880                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrefixControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.prefix),
2881                ),
2882                encoder, offset, _depth
2883            )
2884        }
2885    }
2886    unsafe impl<
2887        T0: fidl::encoding::Encode<AcquirePrefixConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
2888        T1: fidl::encoding::Encode<
2889                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrefixControlMarker>>,
2890                fidl::encoding::DefaultFuchsiaResourceDialect,
2891            >,
2892    >
2893        fidl::encoding::Encode<
2894            PrefixProviderAcquirePrefixRequest,
2895            fidl::encoding::DefaultFuchsiaResourceDialect,
2896        > for (T0, T1)
2897    {
2898        #[inline]
2899        unsafe fn encode(
2900            self,
2901            encoder: &mut fidl::encoding::Encoder<
2902                '_,
2903                fidl::encoding::DefaultFuchsiaResourceDialect,
2904            >,
2905            offset: usize,
2906            depth: fidl::encoding::Depth,
2907        ) -> fidl::Result<()> {
2908            encoder.debug_check_bounds::<PrefixProviderAcquirePrefixRequest>(offset);
2909            // Zero out padding regions. There's no need to apply masks
2910            // because the unmasked parts will be overwritten by fields.
2911            unsafe {
2912                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2913                (ptr as *mut u64).write_unaligned(0);
2914            }
2915            // Write the fields.
2916            self.0.encode(encoder, offset + 0, depth)?;
2917            self.1.encode(encoder, offset + 16, depth)?;
2918            Ok(())
2919        }
2920    }
2921
2922    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2923        for PrefixProviderAcquirePrefixRequest
2924    {
2925        #[inline(always)]
2926        fn new_empty() -> Self {
2927            Self {
2928                config: fidl::new_empty!(
2929                    AcquirePrefixConfig,
2930                    fidl::encoding::DefaultFuchsiaResourceDialect
2931                ),
2932                prefix: fidl::new_empty!(
2933                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrefixControlMarker>>,
2934                    fidl::encoding::DefaultFuchsiaResourceDialect
2935                ),
2936            }
2937        }
2938
2939        #[inline]
2940        unsafe fn decode(
2941            &mut self,
2942            decoder: &mut fidl::encoding::Decoder<
2943                '_,
2944                fidl::encoding::DefaultFuchsiaResourceDialect,
2945            >,
2946            offset: usize,
2947            _depth: fidl::encoding::Depth,
2948        ) -> fidl::Result<()> {
2949            decoder.debug_check_bounds::<Self>(offset);
2950            // Verify that padding bytes are zero.
2951            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2952            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2953            let mask = 0xffffffff00000000u64;
2954            let maskedval = padval & mask;
2955            if maskedval != 0 {
2956                return Err(fidl::Error::NonZeroPadding {
2957                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2958                });
2959            }
2960            fidl::decode!(
2961                AcquirePrefixConfig,
2962                fidl::encoding::DefaultFuchsiaResourceDialect,
2963                &mut self.config,
2964                decoder,
2965                offset + 0,
2966                _depth
2967            )?;
2968            fidl::decode!(
2969                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrefixControlMarker>>,
2970                fidl::encoding::DefaultFuchsiaResourceDialect,
2971                &mut self.prefix,
2972                decoder,
2973                offset + 16,
2974                _depth
2975            )?;
2976            Ok(())
2977        }
2978    }
2979}