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