Skip to main content

fidl_fuchsia_weave/
fidl_fuchsia_weave.rs

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