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_bluetooth_power__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ReporterReportRequest {
16 pub info: Information,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ReporterReportRequest {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct ReporterMarker;
23
24impl fidl::endpoints::ProtocolMarker for ReporterMarker {
25 type Proxy = ReporterProxy;
26 type RequestStream = ReporterRequestStream;
27 #[cfg(target_os = "fuchsia")]
28 type SynchronousProxy = ReporterSynchronousProxy;
29
30 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.power.Reporter";
31}
32impl fidl::endpoints::DiscoverableProtocolMarker for ReporterMarker {}
33pub type ReporterReportResult = Result<(), i32>;
34
35pub trait ReporterProxyInterface: Send + Sync {
36 type ReportResponseFut: std::future::Future<Output = Result<ReporterReportResult, fidl::Error>>
37 + Send;
38 fn r#report(&self, info: &Information) -> Self::ReportResponseFut;
39}
40#[derive(Debug)]
41#[cfg(target_os = "fuchsia")]
42pub struct ReporterSynchronousProxy {
43 client: fidl::client::sync::Client,
44}
45
46#[cfg(target_os = "fuchsia")]
47impl fidl::endpoints::SynchronousProxy for ReporterSynchronousProxy {
48 type Proxy = ReporterProxy;
49 type Protocol = ReporterMarker;
50
51 fn from_channel(inner: fidl::Channel) -> Self {
52 Self::new(inner)
53 }
54
55 fn into_channel(self) -> fidl::Channel {
56 self.client.into_channel()
57 }
58
59 fn as_channel(&self) -> &fidl::Channel {
60 self.client.as_channel()
61 }
62}
63
64#[cfg(target_os = "fuchsia")]
65impl ReporterSynchronousProxy {
66 pub fn new(channel: fidl::Channel) -> Self {
67 let protocol_name = <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
68 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
69 }
70
71 pub fn into_channel(self) -> fidl::Channel {
72 self.client.into_channel()
73 }
74
75 pub fn wait_for_event(
78 &self,
79 deadline: zx::MonotonicInstant,
80 ) -> Result<ReporterEvent, fidl::Error> {
81 ReporterEvent::decode(self.client.wait_for_event(deadline)?)
82 }
83
84 pub fn r#report(
93 &self,
94 mut info: &Information,
95 ___deadline: zx::MonotonicInstant,
96 ) -> Result<ReporterReportResult, fidl::Error> {
97 let _response = self.client.send_query::<
98 ReporterReportRequest,
99 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
100 >(
101 (info,),
102 0x282927fd7363f17f,
103 fidl::encoding::DynamicFlags::empty(),
104 ___deadline,
105 )?;
106 Ok(_response.map(|x| x))
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<ReporterSynchronousProxy> for zx::NullableHandle {
112 fn from(value: ReporterSynchronousProxy) -> Self {
113 value.into_channel().into()
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl From<fidl::Channel> for ReporterSynchronousProxy {
119 fn from(value: fidl::Channel) -> Self {
120 Self::new(value)
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl fidl::endpoints::FromClient for ReporterSynchronousProxy {
126 type Protocol = ReporterMarker;
127
128 fn from_client(value: fidl::endpoints::ClientEnd<ReporterMarker>) -> Self {
129 Self::new(value.into_channel())
130 }
131}
132
133#[derive(Debug, Clone)]
134pub struct ReporterProxy {
135 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
136}
137
138impl fidl::endpoints::Proxy for ReporterProxy {
139 type Protocol = ReporterMarker;
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 ReporterProxy {
155 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
157 let protocol_name = <ReporterMarker 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) -> ReporterEventStream {
167 ReporterEventStream { event_receiver: self.client.take_event_receiver() }
168 }
169
170 pub fn r#report(
179 &self,
180 mut info: &Information,
181 ) -> fidl::client::QueryResponseFut<
182 ReporterReportResult,
183 fidl::encoding::DefaultFuchsiaResourceDialect,
184 > {
185 ReporterProxyInterface::r#report(self, info)
186 }
187}
188
189impl ReporterProxyInterface for ReporterProxy {
190 type ReportResponseFut = fidl::client::QueryResponseFut<
191 ReporterReportResult,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 >;
194 fn r#report(&self, mut info: &Information) -> Self::ReportResponseFut {
195 fn _decode(
196 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
197 ) -> Result<ReporterReportResult, fidl::Error> {
198 let _response = fidl::client::decode_transaction_body::<
199 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
200 fidl::encoding::DefaultFuchsiaResourceDialect,
201 0x282927fd7363f17f,
202 >(_buf?)?;
203 Ok(_response.map(|x| x))
204 }
205 self.client.send_query_and_decode::<ReporterReportRequest, ReporterReportResult>(
206 (info,),
207 0x282927fd7363f17f,
208 fidl::encoding::DynamicFlags::empty(),
209 _decode,
210 )
211 }
212}
213
214pub struct ReporterEventStream {
215 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
216}
217
218impl std::marker::Unpin for ReporterEventStream {}
219
220impl futures::stream::FusedStream for ReporterEventStream {
221 fn is_terminated(&self) -> bool {
222 self.event_receiver.is_terminated()
223 }
224}
225
226impl futures::Stream for ReporterEventStream {
227 type Item = Result<ReporterEvent, fidl::Error>;
228
229 fn poll_next(
230 mut self: std::pin::Pin<&mut Self>,
231 cx: &mut std::task::Context<'_>,
232 ) -> std::task::Poll<Option<Self::Item>> {
233 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
234 &mut self.event_receiver,
235 cx
236 )?) {
237 Some(buf) => std::task::Poll::Ready(Some(ReporterEvent::decode(buf))),
238 None => std::task::Poll::Ready(None),
239 }
240 }
241}
242
243#[derive(Debug)]
244pub enum ReporterEvent {}
245
246impl ReporterEvent {
247 fn decode(
249 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
250 ) -> Result<ReporterEvent, fidl::Error> {
251 let (bytes, _handles) = buf.split_mut();
252 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
253 debug_assert_eq!(tx_header.tx_id, 0);
254 match tx_header.ordinal {
255 _ => Err(fidl::Error::UnknownOrdinal {
256 ordinal: tx_header.ordinal,
257 protocol_name: <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
258 }),
259 }
260 }
261}
262
263pub struct ReporterRequestStream {
265 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
266 is_terminated: bool,
267}
268
269impl std::marker::Unpin for ReporterRequestStream {}
270
271impl futures::stream::FusedStream for ReporterRequestStream {
272 fn is_terminated(&self) -> bool {
273 self.is_terminated
274 }
275}
276
277impl fidl::endpoints::RequestStream for ReporterRequestStream {
278 type Protocol = ReporterMarker;
279 type ControlHandle = ReporterControlHandle;
280
281 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
282 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
283 }
284
285 fn control_handle(&self) -> Self::ControlHandle {
286 ReporterControlHandle { inner: self.inner.clone() }
287 }
288
289 fn into_inner(
290 self,
291 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
292 {
293 (self.inner, self.is_terminated)
294 }
295
296 fn from_inner(
297 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
298 is_terminated: bool,
299 ) -> Self {
300 Self { inner, is_terminated }
301 }
302}
303
304impl futures::Stream for ReporterRequestStream {
305 type Item = Result<ReporterRequest, fidl::Error>;
306
307 fn poll_next(
308 mut self: std::pin::Pin<&mut Self>,
309 cx: &mut std::task::Context<'_>,
310 ) -> std::task::Poll<Option<Self::Item>> {
311 let this = &mut *self;
312 if this.inner.check_shutdown(cx) {
313 this.is_terminated = true;
314 return std::task::Poll::Ready(None);
315 }
316 if this.is_terminated {
317 panic!("polled ReporterRequestStream after completion");
318 }
319 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
320 |bytes, handles| {
321 match this.inner.channel().read_etc(cx, bytes, handles) {
322 std::task::Poll::Ready(Ok(())) => {}
323 std::task::Poll::Pending => return std::task::Poll::Pending,
324 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
325 this.is_terminated = true;
326 return std::task::Poll::Ready(None);
327 }
328 std::task::Poll::Ready(Err(e)) => {
329 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
330 e.into(),
331 ))));
332 }
333 }
334
335 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
337
338 std::task::Poll::Ready(Some(match header.ordinal {
339 0x282927fd7363f17f => {
340 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
341 let mut req = fidl::new_empty!(
342 ReporterReportRequest,
343 fidl::encoding::DefaultFuchsiaResourceDialect
344 );
345 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReporterReportRequest>(&header, _body_bytes, handles, &mut req)?;
346 let control_handle = ReporterControlHandle { inner: this.inner.clone() };
347 Ok(ReporterRequest::Report {
348 info: req.info,
349
350 responder: ReporterReportResponder {
351 control_handle: std::mem::ManuallyDrop::new(control_handle),
352 tx_id: header.tx_id,
353 },
354 })
355 }
356 _ => Err(fidl::Error::UnknownOrdinal {
357 ordinal: header.ordinal,
358 protocol_name:
359 <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
360 }),
361 }))
362 },
363 )
364 }
365}
366
367#[derive(Debug)]
369pub enum ReporterRequest {
370 Report { info: Information, responder: ReporterReportResponder },
379}
380
381impl ReporterRequest {
382 #[allow(irrefutable_let_patterns)]
383 pub fn into_report(self) -> Option<(Information, ReporterReportResponder)> {
384 if let ReporterRequest::Report { info, responder } = self {
385 Some((info, responder))
386 } else {
387 None
388 }
389 }
390
391 pub fn method_name(&self) -> &'static str {
393 match *self {
394 ReporterRequest::Report { .. } => "report",
395 }
396 }
397}
398
399#[derive(Debug, Clone)]
400pub struct ReporterControlHandle {
401 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
402}
403
404impl fidl::endpoints::ControlHandle for ReporterControlHandle {
405 fn shutdown(&self) {
406 self.inner.shutdown()
407 }
408
409 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
410 self.inner.shutdown_with_epitaph(status)
411 }
412
413 fn is_closed(&self) -> bool {
414 self.inner.channel().is_closed()
415 }
416 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
417 self.inner.channel().on_closed()
418 }
419
420 #[cfg(target_os = "fuchsia")]
421 fn signal_peer(
422 &self,
423 clear_mask: zx::Signals,
424 set_mask: zx::Signals,
425 ) -> Result<(), zx_status::Status> {
426 use fidl::Peered;
427 self.inner.channel().signal_peer(clear_mask, set_mask)
428 }
429}
430
431impl ReporterControlHandle {}
432
433#[must_use = "FIDL methods require a response to be sent"]
434#[derive(Debug)]
435pub struct ReporterReportResponder {
436 control_handle: std::mem::ManuallyDrop<ReporterControlHandle>,
437 tx_id: u32,
438}
439
440impl std::ops::Drop for ReporterReportResponder {
444 fn drop(&mut self) {
445 self.control_handle.shutdown();
446 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
448 }
449}
450
451impl fidl::endpoints::Responder for ReporterReportResponder {
452 type ControlHandle = ReporterControlHandle;
453
454 fn control_handle(&self) -> &ReporterControlHandle {
455 &self.control_handle
456 }
457
458 fn drop_without_shutdown(mut self) {
459 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
461 std::mem::forget(self);
463 }
464}
465
466impl ReporterReportResponder {
467 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
471 let _result = self.send_raw(result);
472 if _result.is_err() {
473 self.control_handle.shutdown();
474 }
475 self.drop_without_shutdown();
476 _result
477 }
478
479 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
481 let _result = self.send_raw(result);
482 self.drop_without_shutdown();
483 _result
484 }
485
486 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
487 self.control_handle
488 .inner
489 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
490 result,
491 self.tx_id,
492 0x282927fd7363f17f,
493 fidl::encoding::DynamicFlags::empty(),
494 )
495 }
496}
497
498#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
499pub struct WatcherMarker;
500
501impl fidl::endpoints::ProtocolMarker for WatcherMarker {
502 type Proxy = WatcherProxy;
503 type RequestStream = WatcherRequestStream;
504 #[cfg(target_os = "fuchsia")]
505 type SynchronousProxy = WatcherSynchronousProxy;
506
507 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.power.Watcher";
508}
509impl fidl::endpoints::DiscoverableProtocolMarker for WatcherMarker {}
510
511pub trait WatcherProxyInterface: Send + Sync {
512 type WatchResponseFut: std::future::Future<Output = Result<Vec<Information>, fidl::Error>>
513 + Send;
514 fn r#watch(&self, ids: &[Identifier]) -> Self::WatchResponseFut;
515}
516#[derive(Debug)]
517#[cfg(target_os = "fuchsia")]
518pub struct WatcherSynchronousProxy {
519 client: fidl::client::sync::Client,
520}
521
522#[cfg(target_os = "fuchsia")]
523impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
524 type Proxy = WatcherProxy;
525 type Protocol = WatcherMarker;
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 WatcherSynchronousProxy {
542 pub fn new(channel: fidl::Channel) -> Self {
543 let protocol_name = <WatcherMarker 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 pub fn wait_for_event(
554 &self,
555 deadline: zx::MonotonicInstant,
556 ) -> Result<WatcherEvent, fidl::Error> {
557 WatcherEvent::decode(self.client.wait_for_event(deadline)?)
558 }
559
560 pub fn r#watch(
571 &self,
572 mut ids: &[Identifier],
573 ___deadline: zx::MonotonicInstant,
574 ) -> Result<Vec<Information>, fidl::Error> {
575 let _response = self.client.send_query::<WatcherWatchRequest, WatcherWatchResponse>(
576 (ids,),
577 0x7cc4d24741dddb85,
578 fidl::encoding::DynamicFlags::empty(),
579 ___deadline,
580 )?;
581 Ok(_response.peripherals)
582 }
583}
584
585#[cfg(target_os = "fuchsia")]
586impl From<WatcherSynchronousProxy> for zx::NullableHandle {
587 fn from(value: WatcherSynchronousProxy) -> Self {
588 value.into_channel().into()
589 }
590}
591
592#[cfg(target_os = "fuchsia")]
593impl From<fidl::Channel> for WatcherSynchronousProxy {
594 fn from(value: fidl::Channel) -> Self {
595 Self::new(value)
596 }
597}
598
599#[cfg(target_os = "fuchsia")]
600impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
601 type Protocol = WatcherMarker;
602
603 fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
604 Self::new(value.into_channel())
605 }
606}
607
608#[derive(Debug, Clone)]
609pub struct WatcherProxy {
610 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
611}
612
613impl fidl::endpoints::Proxy for WatcherProxy {
614 type Protocol = WatcherMarker;
615
616 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
617 Self::new(inner)
618 }
619
620 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
621 self.client.into_channel().map_err(|client| Self { client })
622 }
623
624 fn as_channel(&self) -> &::fidl::AsyncChannel {
625 self.client.as_channel()
626 }
627}
628
629impl WatcherProxy {
630 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
632 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
633 Self { client: fidl::client::Client::new(channel, protocol_name) }
634 }
635
636 pub fn take_event_stream(&self) -> WatcherEventStream {
642 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
643 }
644
645 pub fn r#watch(
656 &self,
657 mut ids: &[Identifier],
658 ) -> fidl::client::QueryResponseFut<
659 Vec<Information>,
660 fidl::encoding::DefaultFuchsiaResourceDialect,
661 > {
662 WatcherProxyInterface::r#watch(self, ids)
663 }
664}
665
666impl WatcherProxyInterface for WatcherProxy {
667 type WatchResponseFut = fidl::client::QueryResponseFut<
668 Vec<Information>,
669 fidl::encoding::DefaultFuchsiaResourceDialect,
670 >;
671 fn r#watch(&self, mut ids: &[Identifier]) -> Self::WatchResponseFut {
672 fn _decode(
673 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
674 ) -> Result<Vec<Information>, fidl::Error> {
675 let _response = fidl::client::decode_transaction_body::<
676 WatcherWatchResponse,
677 fidl::encoding::DefaultFuchsiaResourceDialect,
678 0x7cc4d24741dddb85,
679 >(_buf?)?;
680 Ok(_response.peripherals)
681 }
682 self.client.send_query_and_decode::<WatcherWatchRequest, Vec<Information>>(
683 (ids,),
684 0x7cc4d24741dddb85,
685 fidl::encoding::DynamicFlags::empty(),
686 _decode,
687 )
688 }
689}
690
691pub struct WatcherEventStream {
692 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
693}
694
695impl std::marker::Unpin for WatcherEventStream {}
696
697impl futures::stream::FusedStream for WatcherEventStream {
698 fn is_terminated(&self) -> bool {
699 self.event_receiver.is_terminated()
700 }
701}
702
703impl futures::Stream for WatcherEventStream {
704 type Item = Result<WatcherEvent, fidl::Error>;
705
706 fn poll_next(
707 mut self: std::pin::Pin<&mut Self>,
708 cx: &mut std::task::Context<'_>,
709 ) -> std::task::Poll<Option<Self::Item>> {
710 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
711 &mut self.event_receiver,
712 cx
713 )?) {
714 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
715 None => std::task::Poll::Ready(None),
716 }
717 }
718}
719
720#[derive(Debug)]
721pub enum WatcherEvent {}
722
723impl WatcherEvent {
724 fn decode(
726 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
727 ) -> Result<WatcherEvent, fidl::Error> {
728 let (bytes, _handles) = buf.split_mut();
729 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
730 debug_assert_eq!(tx_header.tx_id, 0);
731 match tx_header.ordinal {
732 _ => Err(fidl::Error::UnknownOrdinal {
733 ordinal: tx_header.ordinal,
734 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
735 }),
736 }
737 }
738}
739
740pub struct WatcherRequestStream {
742 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
743 is_terminated: bool,
744}
745
746impl std::marker::Unpin for WatcherRequestStream {}
747
748impl futures::stream::FusedStream for WatcherRequestStream {
749 fn is_terminated(&self) -> bool {
750 self.is_terminated
751 }
752}
753
754impl fidl::endpoints::RequestStream for WatcherRequestStream {
755 type Protocol = WatcherMarker;
756 type ControlHandle = WatcherControlHandle;
757
758 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
759 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
760 }
761
762 fn control_handle(&self) -> Self::ControlHandle {
763 WatcherControlHandle { inner: self.inner.clone() }
764 }
765
766 fn into_inner(
767 self,
768 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
769 {
770 (self.inner, self.is_terminated)
771 }
772
773 fn from_inner(
774 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
775 is_terminated: bool,
776 ) -> Self {
777 Self { inner, is_terminated }
778 }
779}
780
781impl futures::Stream for WatcherRequestStream {
782 type Item = Result<WatcherRequest, fidl::Error>;
783
784 fn poll_next(
785 mut self: std::pin::Pin<&mut Self>,
786 cx: &mut std::task::Context<'_>,
787 ) -> std::task::Poll<Option<Self::Item>> {
788 let this = &mut *self;
789 if this.inner.check_shutdown(cx) {
790 this.is_terminated = true;
791 return std::task::Poll::Ready(None);
792 }
793 if this.is_terminated {
794 panic!("polled WatcherRequestStream after completion");
795 }
796 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
797 |bytes, handles| {
798 match this.inner.channel().read_etc(cx, bytes, handles) {
799 std::task::Poll::Ready(Ok(())) => {}
800 std::task::Poll::Pending => return std::task::Poll::Pending,
801 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
802 this.is_terminated = true;
803 return std::task::Poll::Ready(None);
804 }
805 std::task::Poll::Ready(Err(e)) => {
806 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
807 e.into(),
808 ))));
809 }
810 }
811
812 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
814
815 std::task::Poll::Ready(Some(match header.ordinal {
816 0x7cc4d24741dddb85 => {
817 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
818 let mut req = fidl::new_empty!(
819 WatcherWatchRequest,
820 fidl::encoding::DefaultFuchsiaResourceDialect
821 );
822 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WatcherWatchRequest>(&header, _body_bytes, handles, &mut req)?;
823 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
824 Ok(WatcherRequest::Watch {
825 ids: req.ids,
826
827 responder: WatcherWatchResponder {
828 control_handle: std::mem::ManuallyDrop::new(control_handle),
829 tx_id: header.tx_id,
830 },
831 })
832 }
833 _ => Err(fidl::Error::UnknownOrdinal {
834 ordinal: header.ordinal,
835 protocol_name:
836 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
837 }),
838 }))
839 },
840 )
841 }
842}
843
844#[derive(Debug)]
846pub enum WatcherRequest {
847 Watch { ids: Vec<Identifier>, responder: WatcherWatchResponder },
858}
859
860impl WatcherRequest {
861 #[allow(irrefutable_let_patterns)]
862 pub fn into_watch(self) -> Option<(Vec<Identifier>, WatcherWatchResponder)> {
863 if let WatcherRequest::Watch { ids, responder } = self {
864 Some((ids, responder))
865 } else {
866 None
867 }
868 }
869
870 pub fn method_name(&self) -> &'static str {
872 match *self {
873 WatcherRequest::Watch { .. } => "watch",
874 }
875 }
876}
877
878#[derive(Debug, Clone)]
879pub struct WatcherControlHandle {
880 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
881}
882
883impl fidl::endpoints::ControlHandle for WatcherControlHandle {
884 fn shutdown(&self) {
885 self.inner.shutdown()
886 }
887
888 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
889 self.inner.shutdown_with_epitaph(status)
890 }
891
892 fn is_closed(&self) -> bool {
893 self.inner.channel().is_closed()
894 }
895 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
896 self.inner.channel().on_closed()
897 }
898
899 #[cfg(target_os = "fuchsia")]
900 fn signal_peer(
901 &self,
902 clear_mask: zx::Signals,
903 set_mask: zx::Signals,
904 ) -> Result<(), zx_status::Status> {
905 use fidl::Peered;
906 self.inner.channel().signal_peer(clear_mask, set_mask)
907 }
908}
909
910impl WatcherControlHandle {}
911
912#[must_use = "FIDL methods require a response to be sent"]
913#[derive(Debug)]
914pub struct WatcherWatchResponder {
915 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
916 tx_id: u32,
917}
918
919impl std::ops::Drop for WatcherWatchResponder {
923 fn drop(&mut self) {
924 self.control_handle.shutdown();
925 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
927 }
928}
929
930impl fidl::endpoints::Responder for WatcherWatchResponder {
931 type ControlHandle = WatcherControlHandle;
932
933 fn control_handle(&self) -> &WatcherControlHandle {
934 &self.control_handle
935 }
936
937 fn drop_without_shutdown(mut self) {
938 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
940 std::mem::forget(self);
942 }
943}
944
945impl WatcherWatchResponder {
946 pub fn send(self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
950 let _result = self.send_raw(peripherals);
951 if _result.is_err() {
952 self.control_handle.shutdown();
953 }
954 self.drop_without_shutdown();
955 _result
956 }
957
958 pub fn send_no_shutdown_on_err(
960 self,
961 mut peripherals: &[Information],
962 ) -> Result<(), fidl::Error> {
963 let _result = self.send_raw(peripherals);
964 self.drop_without_shutdown();
965 _result
966 }
967
968 fn send_raw(&self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
969 self.control_handle.inner.send::<WatcherWatchResponse>(
970 (peripherals,),
971 self.tx_id,
972 0x7cc4d24741dddb85,
973 fidl::encoding::DynamicFlags::empty(),
974 )
975 }
976}
977
978mod internal {
979 use super::*;
980
981 impl fidl::encoding::ResourceTypeMarker for ReporterReportRequest {
982 type Borrowed<'a> = &'a mut Self;
983 fn take_or_borrow<'a>(
984 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
985 ) -> Self::Borrowed<'a> {
986 value
987 }
988 }
989
990 unsafe impl fidl::encoding::TypeMarker for ReporterReportRequest {
991 type Owned = Self;
992
993 #[inline(always)]
994 fn inline_align(_context: fidl::encoding::Context) -> usize {
995 8
996 }
997
998 #[inline(always)]
999 fn inline_size(_context: fidl::encoding::Context) -> usize {
1000 16
1001 }
1002 }
1003
1004 unsafe impl
1005 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1006 for &mut ReporterReportRequest
1007 {
1008 #[inline]
1009 unsafe fn encode(
1010 self,
1011 encoder: &mut fidl::encoding::Encoder<
1012 '_,
1013 fidl::encoding::DefaultFuchsiaResourceDialect,
1014 >,
1015 offset: usize,
1016 _depth: fidl::encoding::Depth,
1017 ) -> fidl::Result<()> {
1018 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
1019 fidl::encoding::Encode::<
1021 ReporterReportRequest,
1022 fidl::encoding::DefaultFuchsiaResourceDialect,
1023 >::encode(
1024 (<Information as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
1025 encoder,
1026 offset,
1027 _depth,
1028 )
1029 }
1030 }
1031 unsafe impl<
1032 T0: fidl::encoding::Encode<Information, fidl::encoding::DefaultFuchsiaResourceDialect>,
1033 >
1034 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1035 for (T0,)
1036 {
1037 #[inline]
1038 unsafe fn encode(
1039 self,
1040 encoder: &mut fidl::encoding::Encoder<
1041 '_,
1042 fidl::encoding::DefaultFuchsiaResourceDialect,
1043 >,
1044 offset: usize,
1045 depth: fidl::encoding::Depth,
1046 ) -> fidl::Result<()> {
1047 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
1048 self.0.encode(encoder, offset + 0, depth)?;
1052 Ok(())
1053 }
1054 }
1055
1056 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1057 for ReporterReportRequest
1058 {
1059 #[inline(always)]
1060 fn new_empty() -> Self {
1061 Self {
1062 info: fidl::new_empty!(Information, fidl::encoding::DefaultFuchsiaResourceDialect),
1063 }
1064 }
1065
1066 #[inline]
1067 unsafe fn decode(
1068 &mut self,
1069 decoder: &mut fidl::encoding::Decoder<
1070 '_,
1071 fidl::encoding::DefaultFuchsiaResourceDialect,
1072 >,
1073 offset: usize,
1074 _depth: fidl::encoding::Depth,
1075 ) -> fidl::Result<()> {
1076 decoder.debug_check_bounds::<Self>(offset);
1077 fidl::decode!(
1079 Information,
1080 fidl::encoding::DefaultFuchsiaResourceDialect,
1081 &mut self.info,
1082 decoder,
1083 offset + 0,
1084 _depth
1085 )?;
1086 Ok(())
1087 }
1088 }
1089}