Skip to main content

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