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::NullableHandle {
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
479 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
480 self.inner.shutdown_with_epitaph(status)
481 }
482
483 fn is_closed(&self) -> bool {
484 self.inner.channel().is_closed()
485 }
486 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
487 self.inner.channel().on_closed()
488 }
489
490 #[cfg(target_os = "fuchsia")]
491 fn signal_peer(
492 &self,
493 clear_mask: zx::Signals,
494 set_mask: zx::Signals,
495 ) -> Result<(), zx_status::Status> {
496 use fidl::Peered;
497 self.inner.channel().signal_peer(clear_mask, set_mask)
498 }
499}
500
501impl ThreadControlHandle {}
502
503#[must_use = "FIDL methods require a response to be sent"]
504#[derive(Debug)]
505pub struct ThreadImportSettingsResponder {
506 control_handle: std::mem::ManuallyDrop<ThreadControlHandle>,
507 tx_id: u32,
508}
509
510impl std::ops::Drop for ThreadImportSettingsResponder {
514 fn drop(&mut self) {
515 self.control_handle.shutdown();
516 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
518 }
519}
520
521impl fidl::endpoints::Responder for ThreadImportSettingsResponder {
522 type ControlHandle = ThreadControlHandle;
523
524 fn control_handle(&self) -> &ThreadControlHandle {
525 &self.control_handle
526 }
527
528 fn drop_without_shutdown(mut self) {
529 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
531 std::mem::forget(self);
533 }
534}
535
536impl ThreadImportSettingsResponder {
537 pub fn send(self) -> Result<(), fidl::Error> {
541 let _result = self.send_raw();
542 if _result.is_err() {
543 self.control_handle.shutdown();
544 }
545 self.drop_without_shutdown();
546 _result
547 }
548
549 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
551 let _result = self.send_raw();
552 self.drop_without_shutdown();
553 _result
554 }
555
556 fn send_raw(&self) -> Result<(), fidl::Error> {
557 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
558 (),
559 self.tx_id,
560 0x5ac61a4908e85bbd,
561 fidl::encoding::DynamicFlags::empty(),
562 )
563 }
564}
565
566mod internal {
567 use super::*;
568
569 impl fidl::encoding::ResourceTypeMarker for ThreadImportSettingsRequest {
570 type Borrowed<'a> = &'a mut Self;
571 fn take_or_borrow<'a>(
572 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
573 ) -> Self::Borrowed<'a> {
574 value
575 }
576 }
577
578 unsafe impl fidl::encoding::TypeMarker for ThreadImportSettingsRequest {
579 type Owned = Self;
580
581 #[inline(always)]
582 fn inline_align(_context: fidl::encoding::Context) -> usize {
583 8
584 }
585
586 #[inline(always)]
587 fn inline_size(_context: fidl::encoding::Context) -> usize {
588 16
589 }
590 }
591
592 unsafe impl
593 fidl::encoding::Encode<
594 ThreadImportSettingsRequest,
595 fidl::encoding::DefaultFuchsiaResourceDialect,
596 > for &mut ThreadImportSettingsRequest
597 {
598 #[inline]
599 unsafe fn encode(
600 self,
601 encoder: &mut fidl::encoding::Encoder<
602 '_,
603 fidl::encoding::DefaultFuchsiaResourceDialect,
604 >,
605 offset: usize,
606 _depth: fidl::encoding::Depth,
607 ) -> fidl::Result<()> {
608 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
609 fidl::encoding::Encode::<
611 ThreadImportSettingsRequest,
612 fidl::encoding::DefaultFuchsiaResourceDialect,
613 >::encode(
614 (<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
615 &mut self.thread_settings_json,
616 ),),
617 encoder,
618 offset,
619 _depth,
620 )
621 }
622 }
623 unsafe impl<
624 T0: fidl::encoding::Encode<
625 fidl_fuchsia_mem::Buffer,
626 fidl::encoding::DefaultFuchsiaResourceDialect,
627 >,
628 >
629 fidl::encoding::Encode<
630 ThreadImportSettingsRequest,
631 fidl::encoding::DefaultFuchsiaResourceDialect,
632 > for (T0,)
633 {
634 #[inline]
635 unsafe fn encode(
636 self,
637 encoder: &mut fidl::encoding::Encoder<
638 '_,
639 fidl::encoding::DefaultFuchsiaResourceDialect,
640 >,
641 offset: usize,
642 depth: fidl::encoding::Depth,
643 ) -> fidl::Result<()> {
644 encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
645 self.0.encode(encoder, offset + 0, depth)?;
649 Ok(())
650 }
651 }
652
653 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
654 for ThreadImportSettingsRequest
655 {
656 #[inline(always)]
657 fn new_empty() -> Self {
658 Self {
659 thread_settings_json: fidl::new_empty!(
660 fidl_fuchsia_mem::Buffer,
661 fidl::encoding::DefaultFuchsiaResourceDialect
662 ),
663 }
664 }
665
666 #[inline]
667 unsafe fn decode(
668 &mut self,
669 decoder: &mut fidl::encoding::Decoder<
670 '_,
671 fidl::encoding::DefaultFuchsiaResourceDialect,
672 >,
673 offset: usize,
674 _depth: fidl::encoding::Depth,
675 ) -> fidl::Result<()> {
676 decoder.debug_check_bounds::<Self>(offset);
677 fidl::decode!(
679 fidl_fuchsia_mem::Buffer,
680 fidl::encoding::DefaultFuchsiaResourceDialect,
681 &mut self.thread_settings_json,
682 decoder,
683 offset + 0,
684 _depth
685 )?;
686 Ok(())
687 }
688 }
689}