1#![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_bootstrap_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ThreadImportSettingsRequest {
16 pub thread_settings_json: fidl_fuchsia_mem::Buffer,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for ThreadImportSettingsRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct ThreadMarker;
26
27impl fidl::endpoints::ProtocolMarker for ThreadMarker {
28 type Proxy = ThreadProxy;
29 type RequestStream = ThreadRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = ThreadSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.lowpan.bootstrap.Thread";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for ThreadMarker {}
36
37pub trait ThreadProxyInterface: Send + Sync {
38 type ImportSettingsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
39 fn r#import_settings(
40 &self,
41 thread_settings_json: fidl_fuchsia_mem::Buffer,
42 ) -> Self::ImportSettingsResponseFut;
43}
44#[derive(Debug)]
45#[cfg(target_os = "fuchsia")]
46pub struct ThreadSynchronousProxy {
47 client: fidl::client::sync::Client,
48}
49
50#[cfg(target_os = "fuchsia")]
51impl fidl::endpoints::SynchronousProxy for ThreadSynchronousProxy {
52 type Proxy = ThreadProxy;
53 type Protocol = ThreadMarker;
54
55 fn from_channel(inner: fidl::Channel) -> Self {
56 Self::new(inner)
57 }
58
59 fn into_channel(self) -> fidl::Channel {
60 self.client.into_channel()
61 }
62
63 fn as_channel(&self) -> &fidl::Channel {
64 self.client.as_channel()
65 }
66}
67
68#[cfg(target_os = "fuchsia")]
69impl ThreadSynchronousProxy {
70 pub fn new(channel: fidl::Channel) -> Self {
71 let protocol_name = <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
72 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
73 }
74
75 pub fn into_channel(self) -> fidl::Channel {
76 self.client.into_channel()
77 }
78
79 pub fn wait_for_event(
82 &self,
83 deadline: zx::MonotonicInstant,
84 ) -> Result<ThreadEvent, fidl::Error> {
85 ThreadEvent::decode(self.client.wait_for_event(deadline)?)
86 }
87
88 pub fn r#import_settings(
118 &self,
119 mut thread_settings_json: fidl_fuchsia_mem::Buffer,
120 ___deadline: zx::MonotonicInstant,
121 ) -> Result<(), fidl::Error> {
122 let _response =
123 self.client.send_query::<ThreadImportSettingsRequest, fidl::encoding::EmptyPayload>(
124 (&mut thread_settings_json,),
125 0x5ac61a4908e85bbd,
126 fidl::encoding::DynamicFlags::empty(),
127 ___deadline,
128 )?;
129 Ok(_response)
130 }
131}
132
133#[derive(Debug, Clone)]
134pub struct ThreadProxy {
135 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
136}
137
138impl fidl::endpoints::Proxy for ThreadProxy {
139 type Protocol = ThreadMarker;
140
141 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
142 Self::new(inner)
143 }
144
145 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
146 self.client.into_channel().map_err(|client| Self { client })
147 }
148
149 fn as_channel(&self) -> &::fidl::AsyncChannel {
150 self.client.as_channel()
151 }
152}
153
154impl ThreadProxy {
155 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
157 let protocol_name = <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
158 Self { client: fidl::client::Client::new(channel, protocol_name) }
159 }
160
161 pub fn take_event_stream(&self) -> ThreadEventStream {
167 ThreadEventStream { event_receiver: self.client.take_event_receiver() }
168 }
169
170 pub fn r#import_settings(
200 &self,
201 mut thread_settings_json: fidl_fuchsia_mem::Buffer,
202 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
203 ThreadProxyInterface::r#import_settings(self, thread_settings_json)
204 }
205}
206
207impl ThreadProxyInterface for ThreadProxy {
208 type ImportSettingsResponseFut =
209 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
210 fn r#import_settings(
211 &self,
212 mut thread_settings_json: fidl_fuchsia_mem::Buffer,
213 ) -> Self::ImportSettingsResponseFut {
214 fn _decode(
215 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
216 ) -> Result<(), fidl::Error> {
217 let _response = fidl::client::decode_transaction_body::<
218 fidl::encoding::EmptyPayload,
219 fidl::encoding::DefaultFuchsiaResourceDialect,
220 0x5ac61a4908e85bbd,
221 >(_buf?)?;
222 Ok(_response)
223 }
224 self.client.send_query_and_decode::<ThreadImportSettingsRequest, ()>(
225 (&mut thread_settings_json,),
226 0x5ac61a4908e85bbd,
227 fidl::encoding::DynamicFlags::empty(),
228 _decode,
229 )
230 }
231}
232
233pub struct ThreadEventStream {
234 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
235}
236
237impl std::marker::Unpin for ThreadEventStream {}
238
239impl futures::stream::FusedStream for ThreadEventStream {
240 fn is_terminated(&self) -> bool {
241 self.event_receiver.is_terminated()
242 }
243}
244
245impl futures::Stream for ThreadEventStream {
246 type Item = Result<ThreadEvent, fidl::Error>;
247
248 fn poll_next(
249 mut self: std::pin::Pin<&mut Self>,
250 cx: &mut std::task::Context<'_>,
251 ) -> std::task::Poll<Option<Self::Item>> {
252 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
253 &mut self.event_receiver,
254 cx
255 )?) {
256 Some(buf) => std::task::Poll::Ready(Some(ThreadEvent::decode(buf))),
257 None => std::task::Poll::Ready(None),
258 }
259 }
260}
261
262#[derive(Debug)]
263pub enum ThreadEvent {}
264
265impl ThreadEvent {
266 fn decode(
268 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
269 ) -> Result<ThreadEvent, fidl::Error> {
270 let (bytes, _handles) = buf.split_mut();
271 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
272 debug_assert_eq!(tx_header.tx_id, 0);
273 match tx_header.ordinal {
274 _ => Err(fidl::Error::UnknownOrdinal {
275 ordinal: tx_header.ordinal,
276 protocol_name: <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
277 }),
278 }
279 }
280}
281
282pub struct ThreadRequestStream {
284 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
285 is_terminated: bool,
286}
287
288impl std::marker::Unpin for ThreadRequestStream {}
289
290impl futures::stream::FusedStream for ThreadRequestStream {
291 fn is_terminated(&self) -> bool {
292 self.is_terminated
293 }
294}
295
296impl fidl::endpoints::RequestStream for ThreadRequestStream {
297 type Protocol = ThreadMarker;
298 type ControlHandle = ThreadControlHandle;
299
300 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
301 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
302 }
303
304 fn control_handle(&self) -> Self::ControlHandle {
305 ThreadControlHandle { inner: self.inner.clone() }
306 }
307
308 fn into_inner(
309 self,
310 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
311 {
312 (self.inner, self.is_terminated)
313 }
314
315 fn from_inner(
316 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
317 is_terminated: bool,
318 ) -> Self {
319 Self { inner, is_terminated }
320 }
321}
322
323impl futures::Stream for ThreadRequestStream {
324 type Item = Result<ThreadRequest, fidl::Error>;
325
326 fn poll_next(
327 mut self: std::pin::Pin<&mut Self>,
328 cx: &mut std::task::Context<'_>,
329 ) -> std::task::Poll<Option<Self::Item>> {
330 let this = &mut *self;
331 if this.inner.check_shutdown(cx) {
332 this.is_terminated = true;
333 return std::task::Poll::Ready(None);
334 }
335 if this.is_terminated {
336 panic!("polled ThreadRequestStream after completion");
337 }
338 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
339 |bytes, handles| {
340 match this.inner.channel().read_etc(cx, bytes, handles) {
341 std::task::Poll::Ready(Ok(())) => {}
342 std::task::Poll::Pending => return std::task::Poll::Pending,
343 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
344 this.is_terminated = true;
345 return std::task::Poll::Ready(None);
346 }
347 std::task::Poll::Ready(Err(e)) => {
348 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
349 e.into(),
350 ))))
351 }
352 }
353
354 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
356
357 std::task::Poll::Ready(Some(match header.ordinal {
358 0x5ac61a4908e85bbd => {
359 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
360 let mut req = fidl::new_empty!(
361 ThreadImportSettingsRequest,
362 fidl::encoding::DefaultFuchsiaResourceDialect
363 );
364 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ThreadImportSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
365 let control_handle = ThreadControlHandle { inner: this.inner.clone() };
366 Ok(ThreadRequest::ImportSettings {
367 thread_settings_json: req.thread_settings_json,
368
369 responder: ThreadImportSettingsResponder {
370 control_handle: std::mem::ManuallyDrop::new(control_handle),
371 tx_id: header.tx_id,
372 },
373 })
374 }
375 _ => Err(fidl::Error::UnknownOrdinal {
376 ordinal: header.ordinal,
377 protocol_name:
378 <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
379 }),
380 }))
381 },
382 )
383 }
384}
385
386#[derive(Debug)]
390pub enum ThreadRequest {
391 ImportSettings {
421 thread_settings_json: fidl_fuchsia_mem::Buffer,
422 responder: ThreadImportSettingsResponder,
423 },
424}
425
426impl ThreadRequest {
427 #[allow(irrefutable_let_patterns)]
428 pub fn into_import_settings(
429 self,
430 ) -> Option<(fidl_fuchsia_mem::Buffer, ThreadImportSettingsResponder)> {
431 if let ThreadRequest::ImportSettings { thread_settings_json, responder } = self {
432 Some((thread_settings_json, responder))
433 } else {
434 None
435 }
436 }
437
438 pub fn method_name(&self) -> &'static str {
440 match *self {
441 ThreadRequest::ImportSettings { .. } => "import_settings",
442 }
443 }
444}
445
446#[derive(Debug, Clone)]
447pub struct ThreadControlHandle {
448 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
449}
450
451impl fidl::endpoints::ControlHandle for ThreadControlHandle {
452 fn shutdown(&self) {
453 self.inner.shutdown()
454 }
455 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
456 self.inner.shutdown_with_epitaph(status)
457 }
458
459 fn is_closed(&self) -> bool {
460 self.inner.channel().is_closed()
461 }
462 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
463 self.inner.channel().on_closed()
464 }
465
466 #[cfg(target_os = "fuchsia")]
467 fn signal_peer(
468 &self,
469 clear_mask: zx::Signals,
470 set_mask: zx::Signals,
471 ) -> Result<(), zx_status::Status> {
472 use fidl::Peered;
473 self.inner.channel().signal_peer(clear_mask, set_mask)
474 }
475}
476
477impl ThreadControlHandle {}
478
479#[must_use = "FIDL methods require a response to be sent"]
480#[derive(Debug)]
481pub struct ThreadImportSettingsResponder {
482 control_handle: std::mem::ManuallyDrop<ThreadControlHandle>,
483 tx_id: u32,
484}
485
486impl std::ops::Drop for ThreadImportSettingsResponder {
490 fn drop(&mut self) {
491 self.control_handle.shutdown();
492 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
494 }
495}
496
497impl fidl::endpoints::Responder for ThreadImportSettingsResponder {
498 type ControlHandle = ThreadControlHandle;
499
500 fn control_handle(&self) -> &ThreadControlHandle {
501 &self.control_handle
502 }
503
504 fn drop_without_shutdown(mut self) {
505 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
507 std::mem::forget(self);
509 }
510}
511
512impl ThreadImportSettingsResponder {
513 pub fn send(self) -> Result<(), fidl::Error> {
517 let _result = self.send_raw();
518 if _result.is_err() {
519 self.control_handle.shutdown();
520 }
521 self.drop_without_shutdown();
522 _result
523 }
524
525 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
527 let _result = self.send_raw();
528 self.drop_without_shutdown();
529 _result
530 }
531
532 fn send_raw(&self) -> Result<(), fidl::Error> {
533 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
534 (),
535 self.tx_id,
536 0x5ac61a4908e85bbd,
537 fidl::encoding::DynamicFlags::empty(),
538 )
539 }
540}
541
542mod internal {
543 use super::*;
544
545 impl fidl::encoding::ResourceTypeMarker for ThreadImportSettingsRequest {
546 type Borrowed<'a> = &'a mut Self;
547 fn take_or_borrow<'a>(
548 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
549 ) -> Self::Borrowed<'a> {
550 value
551 }
552 }
553
554 unsafe impl fidl::encoding::TypeMarker for ThreadImportSettingsRequest {
555 type Owned = Self;
556
557 #[inline(always)]
558 fn inline_align(_context: fidl::encoding::Context) -> usize {
559 8
560 }
561
562 #[inline(always)]
563 fn inline_size(_context: fidl::encoding::Context) -> usize {
564 16
565 }
566 }
567
568 unsafe impl
569 fidl::encoding::Encode<
570 ThreadImportSettingsRequest,
571 fidl::encoding::DefaultFuchsiaResourceDialect,
572 > for &mut ThreadImportSettingsRequest
573 {
574 #[inline]
575 unsafe fn encode(
576 self,
577 encoder: &mut fidl::encoding::Encoder<
578 '_,
579 fidl::encoding::DefaultFuchsiaResourceDialect,
580 >,
581 offset: usize,
582 _depth: fidl::encoding::Depth,
583 ) -> fidl::Result<()> {
584 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
585 fidl::encoding::Encode::<
587 ThreadImportSettingsRequest,
588 fidl::encoding::DefaultFuchsiaResourceDialect,
589 >::encode(
590 (<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
591 &mut self.thread_settings_json,
592 ),),
593 encoder,
594 offset,
595 _depth,
596 )
597 }
598 }
599 unsafe impl<
600 T0: fidl::encoding::Encode<
601 fidl_fuchsia_mem::Buffer,
602 fidl::encoding::DefaultFuchsiaResourceDialect,
603 >,
604 >
605 fidl::encoding::Encode<
606 ThreadImportSettingsRequest,
607 fidl::encoding::DefaultFuchsiaResourceDialect,
608 > for (T0,)
609 {
610 #[inline]
611 unsafe fn encode(
612 self,
613 encoder: &mut fidl::encoding::Encoder<
614 '_,
615 fidl::encoding::DefaultFuchsiaResourceDialect,
616 >,
617 offset: usize,
618 depth: fidl::encoding::Depth,
619 ) -> fidl::Result<()> {
620 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
621 self.0.encode(encoder, offset + 0, depth)?;
625 Ok(())
626 }
627 }
628
629 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
630 for ThreadImportSettingsRequest
631 {
632 #[inline(always)]
633 fn new_empty() -> Self {
634 Self {
635 thread_settings_json: fidl::new_empty!(
636 fidl_fuchsia_mem::Buffer,
637 fidl::encoding::DefaultFuchsiaResourceDialect
638 ),
639 }
640 }
641
642 #[inline]
643 unsafe fn decode(
644 &mut self,
645 decoder: &mut fidl::encoding::Decoder<
646 '_,
647 fidl::encoding::DefaultFuchsiaResourceDialect,
648 >,
649 offset: usize,
650 _depth: fidl::encoding::Depth,
651 ) -> fidl::Result<()> {
652 decoder.debug_check_bounds::<Self>(offset);
653 fidl::decode!(
655 fidl_fuchsia_mem::Buffer,
656 fidl::encoding::DefaultFuchsiaResourceDialect,
657 &mut self.thread_settings_json,
658 decoder,
659 offset + 0,
660 _depth
661 )?;
662 Ok(())
663 }
664 }
665}