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