Skip to main content

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