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#[cfg(target_os = "fuchsia")]
134impl From<ThreadSynchronousProxy> for zx::Handle {
135 fn from(value: ThreadSynchronousProxy) -> Self {
136 value.into_channel().into()
137 }
138}
139
140#[cfg(target_os = "fuchsia")]
141impl From<fidl::Channel> for ThreadSynchronousProxy {
142 fn from(value: fidl::Channel) -> Self {
143 Self::new(value)
144 }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl fidl::endpoints::FromClient for ThreadSynchronousProxy {
149 type Protocol = ThreadMarker;
150
151 fn from_client(value: fidl::endpoints::ClientEnd<ThreadMarker>) -> Self {
152 Self::new(value.into_channel())
153 }
154}
155
156#[derive(Debug, Clone)]
157pub struct ThreadProxy {
158 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
159}
160
161impl fidl::endpoints::Proxy for ThreadProxy {
162 type Protocol = ThreadMarker;
163
164 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
165 Self::new(inner)
166 }
167
168 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
169 self.client.into_channel().map_err(|client| Self { client })
170 }
171
172 fn as_channel(&self) -> &::fidl::AsyncChannel {
173 self.client.as_channel()
174 }
175}
176
177impl ThreadProxy {
178 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
180 let protocol_name = <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
181 Self { client: fidl::client::Client::new(channel, protocol_name) }
182 }
183
184 pub fn take_event_stream(&self) -> ThreadEventStream {
190 ThreadEventStream { event_receiver: self.client.take_event_receiver() }
191 }
192
193 pub fn r#import_settings(
223 &self,
224 mut thread_settings_json: fidl_fuchsia_mem::Buffer,
225 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
226 ThreadProxyInterface::r#import_settings(self, thread_settings_json)
227 }
228}
229
230impl ThreadProxyInterface for ThreadProxy {
231 type ImportSettingsResponseFut =
232 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
233 fn r#import_settings(
234 &self,
235 mut thread_settings_json: fidl_fuchsia_mem::Buffer,
236 ) -> Self::ImportSettingsResponseFut {
237 fn _decode(
238 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
239 ) -> Result<(), fidl::Error> {
240 let _response = fidl::client::decode_transaction_body::<
241 fidl::encoding::EmptyPayload,
242 fidl::encoding::DefaultFuchsiaResourceDialect,
243 0x5ac61a4908e85bbd,
244 >(_buf?)?;
245 Ok(_response)
246 }
247 self.client.send_query_and_decode::<ThreadImportSettingsRequest, ()>(
248 (&mut thread_settings_json,),
249 0x5ac61a4908e85bbd,
250 fidl::encoding::DynamicFlags::empty(),
251 _decode,
252 )
253 }
254}
255
256pub struct ThreadEventStream {
257 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
258}
259
260impl std::marker::Unpin for ThreadEventStream {}
261
262impl futures::stream::FusedStream for ThreadEventStream {
263 fn is_terminated(&self) -> bool {
264 self.event_receiver.is_terminated()
265 }
266}
267
268impl futures::Stream for ThreadEventStream {
269 type Item = Result<ThreadEvent, fidl::Error>;
270
271 fn poll_next(
272 mut self: std::pin::Pin<&mut Self>,
273 cx: &mut std::task::Context<'_>,
274 ) -> std::task::Poll<Option<Self::Item>> {
275 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
276 &mut self.event_receiver,
277 cx
278 )?) {
279 Some(buf) => std::task::Poll::Ready(Some(ThreadEvent::decode(buf))),
280 None => std::task::Poll::Ready(None),
281 }
282 }
283}
284
285#[derive(Debug)]
286pub enum ThreadEvent {}
287
288impl ThreadEvent {
289 fn decode(
291 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
292 ) -> Result<ThreadEvent, fidl::Error> {
293 let (bytes, _handles) = buf.split_mut();
294 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
295 debug_assert_eq!(tx_header.tx_id, 0);
296 match tx_header.ordinal {
297 _ => Err(fidl::Error::UnknownOrdinal {
298 ordinal: tx_header.ordinal,
299 protocol_name: <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
300 }),
301 }
302 }
303}
304
305pub struct ThreadRequestStream {
307 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
308 is_terminated: bool,
309}
310
311impl std::marker::Unpin for ThreadRequestStream {}
312
313impl futures::stream::FusedStream for ThreadRequestStream {
314 fn is_terminated(&self) -> bool {
315 self.is_terminated
316 }
317}
318
319impl fidl::endpoints::RequestStream for ThreadRequestStream {
320 type Protocol = ThreadMarker;
321 type ControlHandle = ThreadControlHandle;
322
323 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
324 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
325 }
326
327 fn control_handle(&self) -> Self::ControlHandle {
328 ThreadControlHandle { inner: self.inner.clone() }
329 }
330
331 fn into_inner(
332 self,
333 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
334 {
335 (self.inner, self.is_terminated)
336 }
337
338 fn from_inner(
339 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
340 is_terminated: bool,
341 ) -> Self {
342 Self { inner, is_terminated }
343 }
344}
345
346impl futures::Stream for ThreadRequestStream {
347 type Item = Result<ThreadRequest, fidl::Error>;
348
349 fn poll_next(
350 mut self: std::pin::Pin<&mut Self>,
351 cx: &mut std::task::Context<'_>,
352 ) -> std::task::Poll<Option<Self::Item>> {
353 let this = &mut *self;
354 if this.inner.check_shutdown(cx) {
355 this.is_terminated = true;
356 return std::task::Poll::Ready(None);
357 }
358 if this.is_terminated {
359 panic!("polled ThreadRequestStream after completion");
360 }
361 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
362 |bytes, handles| {
363 match this.inner.channel().read_etc(cx, bytes, handles) {
364 std::task::Poll::Ready(Ok(())) => {}
365 std::task::Poll::Pending => return std::task::Poll::Pending,
366 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
367 this.is_terminated = true;
368 return std::task::Poll::Ready(None);
369 }
370 std::task::Poll::Ready(Err(e)) => {
371 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
372 e.into(),
373 ))))
374 }
375 }
376
377 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
379
380 std::task::Poll::Ready(Some(match header.ordinal {
381 0x5ac61a4908e85bbd => {
382 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
383 let mut req = fidl::new_empty!(
384 ThreadImportSettingsRequest,
385 fidl::encoding::DefaultFuchsiaResourceDialect
386 );
387 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ThreadImportSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
388 let control_handle = ThreadControlHandle { inner: this.inner.clone() };
389 Ok(ThreadRequest::ImportSettings {
390 thread_settings_json: req.thread_settings_json,
391
392 responder: ThreadImportSettingsResponder {
393 control_handle: std::mem::ManuallyDrop::new(control_handle),
394 tx_id: header.tx_id,
395 },
396 })
397 }
398 _ => Err(fidl::Error::UnknownOrdinal {
399 ordinal: header.ordinal,
400 protocol_name:
401 <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
402 }),
403 }))
404 },
405 )
406 }
407}
408
409#[derive(Debug)]
413pub enum ThreadRequest {
414 ImportSettings {
444 thread_settings_json: fidl_fuchsia_mem::Buffer,
445 responder: ThreadImportSettingsResponder,
446 },
447}
448
449impl ThreadRequest {
450 #[allow(irrefutable_let_patterns)]
451 pub fn into_import_settings(
452 self,
453 ) -> Option<(fidl_fuchsia_mem::Buffer, ThreadImportSettingsResponder)> {
454 if let ThreadRequest::ImportSettings { thread_settings_json, responder } = self {
455 Some((thread_settings_json, responder))
456 } else {
457 None
458 }
459 }
460
461 pub fn method_name(&self) -> &'static str {
463 match *self {
464 ThreadRequest::ImportSettings { .. } => "import_settings",
465 }
466 }
467}
468
469#[derive(Debug, Clone)]
470pub struct ThreadControlHandle {
471 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
472}
473
474impl fidl::endpoints::ControlHandle for ThreadControlHandle {
475 fn shutdown(&self) {
476 self.inner.shutdown()
477 }
478 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
479 self.inner.shutdown_with_epitaph(status)
480 }
481
482 fn is_closed(&self) -> bool {
483 self.inner.channel().is_closed()
484 }
485 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
486 self.inner.channel().on_closed()
487 }
488
489 #[cfg(target_os = "fuchsia")]
490 fn signal_peer(
491 &self,
492 clear_mask: zx::Signals,
493 set_mask: zx::Signals,
494 ) -> Result<(), zx_status::Status> {
495 use fidl::Peered;
496 self.inner.channel().signal_peer(clear_mask, set_mask)
497 }
498}
499
500impl ThreadControlHandle {}
501
502#[must_use = "FIDL methods require a response to be sent"]
503#[derive(Debug)]
504pub struct ThreadImportSettingsResponder {
505 control_handle: std::mem::ManuallyDrop<ThreadControlHandle>,
506 tx_id: u32,
507}
508
509impl std::ops::Drop for ThreadImportSettingsResponder {
513 fn drop(&mut self) {
514 self.control_handle.shutdown();
515 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
517 }
518}
519
520impl fidl::endpoints::Responder for ThreadImportSettingsResponder {
521 type ControlHandle = ThreadControlHandle;
522
523 fn control_handle(&self) -> &ThreadControlHandle {
524 &self.control_handle
525 }
526
527 fn drop_without_shutdown(mut self) {
528 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
530 std::mem::forget(self);
532 }
533}
534
535impl ThreadImportSettingsResponder {
536 pub fn send(self) -> Result<(), fidl::Error> {
540 let _result = self.send_raw();
541 if _result.is_err() {
542 self.control_handle.shutdown();
543 }
544 self.drop_without_shutdown();
545 _result
546 }
547
548 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
550 let _result = self.send_raw();
551 self.drop_without_shutdown();
552 _result
553 }
554
555 fn send_raw(&self) -> Result<(), fidl::Error> {
556 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
557 (),
558 self.tx_id,
559 0x5ac61a4908e85bbd,
560 fidl::encoding::DynamicFlags::empty(),
561 )
562 }
563}
564
565mod internal {
566 use super::*;
567
568 impl fidl::encoding::ResourceTypeMarker for ThreadImportSettingsRequest {
569 type Borrowed<'a> = &'a mut Self;
570 fn take_or_borrow<'a>(
571 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
572 ) -> Self::Borrowed<'a> {
573 value
574 }
575 }
576
577 unsafe impl fidl::encoding::TypeMarker for ThreadImportSettingsRequest {
578 type Owned = Self;
579
580 #[inline(always)]
581 fn inline_align(_context: fidl::encoding::Context) -> usize {
582 8
583 }
584
585 #[inline(always)]
586 fn inline_size(_context: fidl::encoding::Context) -> usize {
587 16
588 }
589 }
590
591 unsafe impl
592 fidl::encoding::Encode<
593 ThreadImportSettingsRequest,
594 fidl::encoding::DefaultFuchsiaResourceDialect,
595 > for &mut ThreadImportSettingsRequest
596 {
597 #[inline]
598 unsafe fn encode(
599 self,
600 encoder: &mut fidl::encoding::Encoder<
601 '_,
602 fidl::encoding::DefaultFuchsiaResourceDialect,
603 >,
604 offset: usize,
605 _depth: fidl::encoding::Depth,
606 ) -> fidl::Result<()> {
607 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
608 fidl::encoding::Encode::<
610 ThreadImportSettingsRequest,
611 fidl::encoding::DefaultFuchsiaResourceDialect,
612 >::encode(
613 (<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
614 &mut self.thread_settings_json,
615 ),),
616 encoder,
617 offset,
618 _depth,
619 )
620 }
621 }
622 unsafe impl<
623 T0: fidl::encoding::Encode<
624 fidl_fuchsia_mem::Buffer,
625 fidl::encoding::DefaultFuchsiaResourceDialect,
626 >,
627 >
628 fidl::encoding::Encode<
629 ThreadImportSettingsRequest,
630 fidl::encoding::DefaultFuchsiaResourceDialect,
631 > for (T0,)
632 {
633 #[inline]
634 unsafe fn encode(
635 self,
636 encoder: &mut fidl::encoding::Encoder<
637 '_,
638 fidl::encoding::DefaultFuchsiaResourceDialect,
639 >,
640 offset: usize,
641 depth: fidl::encoding::Depth,
642 ) -> fidl::Result<()> {
643 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
644 self.0.encode(encoder, offset + 0, depth)?;
648 Ok(())
649 }
650 }
651
652 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
653 for ThreadImportSettingsRequest
654 {
655 #[inline(always)]
656 fn new_empty() -> Self {
657 Self {
658 thread_settings_json: fidl::new_empty!(
659 fidl_fuchsia_mem::Buffer,
660 fidl::encoding::DefaultFuchsiaResourceDialect
661 ),
662 }
663 }
664
665 #[inline]
666 unsafe fn decode(
667 &mut self,
668 decoder: &mut fidl::encoding::Decoder<
669 '_,
670 fidl::encoding::DefaultFuchsiaResourceDialect,
671 >,
672 offset: usize,
673 _depth: fidl::encoding::Depth,
674 ) -> fidl::Result<()> {
675 decoder.debug_check_bounds::<Self>(offset);
676 fidl::decode!(
678 fidl_fuchsia_mem::Buffer,
679 fidl::encoding::DefaultFuchsiaResourceDialect,
680 &mut self.thread_settings_json,
681 decoder,
682 offset + 0,
683 _depth
684 )?;
685 Ok(())
686 }
687 }
688}