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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
409 self.inner.shutdown_with_epitaph(status)
410 }
411
412 fn is_closed(&self) -> bool {
413 self.inner.channel().is_closed()
414 }
415 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
416 self.inner.channel().on_closed()
417 }
418
419 #[cfg(target_os = "fuchsia")]
420 fn signal_peer(
421 &self,
422 clear_mask: zx::Signals,
423 set_mask: zx::Signals,
424 ) -> Result<(), zx_status::Status> {
425 use fidl::Peered;
426 self.inner.channel().signal_peer(clear_mask, set_mask)
427 }
428}
429
430impl ReporterControlHandle {}
431
432#[must_use = "FIDL methods require a response to be sent"]
433#[derive(Debug)]
434pub struct ReporterReportResponder {
435 control_handle: std::mem::ManuallyDrop<ReporterControlHandle>,
436 tx_id: u32,
437}
438
439impl std::ops::Drop for ReporterReportResponder {
443 fn drop(&mut self) {
444 self.control_handle.shutdown();
445 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
447 }
448}
449
450impl fidl::endpoints::Responder for ReporterReportResponder {
451 type ControlHandle = ReporterControlHandle;
452
453 fn control_handle(&self) -> &ReporterControlHandle {
454 &self.control_handle
455 }
456
457 fn drop_without_shutdown(mut self) {
458 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
460 std::mem::forget(self);
462 }
463}
464
465impl ReporterReportResponder {
466 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
470 let _result = self.send_raw(result);
471 if _result.is_err() {
472 self.control_handle.shutdown();
473 }
474 self.drop_without_shutdown();
475 _result
476 }
477
478 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
480 let _result = self.send_raw(result);
481 self.drop_without_shutdown();
482 _result
483 }
484
485 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
486 self.control_handle
487 .inner
488 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
489 result,
490 self.tx_id,
491 0x282927fd7363f17f,
492 fidl::encoding::DynamicFlags::empty(),
493 )
494 }
495}
496
497#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
498pub struct WatcherMarker;
499
500impl fidl::endpoints::ProtocolMarker for WatcherMarker {
501 type Proxy = WatcherProxy;
502 type RequestStream = WatcherRequestStream;
503 #[cfg(target_os = "fuchsia")]
504 type SynchronousProxy = WatcherSynchronousProxy;
505
506 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.power.Watcher";
507}
508impl fidl::endpoints::DiscoverableProtocolMarker for WatcherMarker {}
509
510pub trait WatcherProxyInterface: Send + Sync {
511 type WatchResponseFut: std::future::Future<Output = Result<Vec<Information>, fidl::Error>>
512 + Send;
513 fn r#watch(&self, ids: &[Identifier]) -> Self::WatchResponseFut;
514}
515#[derive(Debug)]
516#[cfg(target_os = "fuchsia")]
517pub struct WatcherSynchronousProxy {
518 client: fidl::client::sync::Client,
519}
520
521#[cfg(target_os = "fuchsia")]
522impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
523 type Proxy = WatcherProxy;
524 type Protocol = WatcherMarker;
525
526 fn from_channel(inner: fidl::Channel) -> Self {
527 Self::new(inner)
528 }
529
530 fn into_channel(self) -> fidl::Channel {
531 self.client.into_channel()
532 }
533
534 fn as_channel(&self) -> &fidl::Channel {
535 self.client.as_channel()
536 }
537}
538
539#[cfg(target_os = "fuchsia")]
540impl WatcherSynchronousProxy {
541 pub fn new(channel: fidl::Channel) -> Self {
542 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
543 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
544 }
545
546 pub fn into_channel(self) -> fidl::Channel {
547 self.client.into_channel()
548 }
549
550 pub fn wait_for_event(
553 &self,
554 deadline: zx::MonotonicInstant,
555 ) -> Result<WatcherEvent, fidl::Error> {
556 WatcherEvent::decode(self.client.wait_for_event(deadline)?)
557 }
558
559 pub fn r#watch(
570 &self,
571 mut ids: &[Identifier],
572 ___deadline: zx::MonotonicInstant,
573 ) -> Result<Vec<Information>, fidl::Error> {
574 let _response = self.client.send_query::<WatcherWatchRequest, WatcherWatchResponse>(
575 (ids,),
576 0x7cc4d24741dddb85,
577 fidl::encoding::DynamicFlags::empty(),
578 ___deadline,
579 )?;
580 Ok(_response.peripherals)
581 }
582}
583
584#[cfg(target_os = "fuchsia")]
585impl From<WatcherSynchronousProxy> for zx::Handle {
586 fn from(value: WatcherSynchronousProxy) -> Self {
587 value.into_channel().into()
588 }
589}
590
591#[cfg(target_os = "fuchsia")]
592impl From<fidl::Channel> for WatcherSynchronousProxy {
593 fn from(value: fidl::Channel) -> Self {
594 Self::new(value)
595 }
596}
597
598#[cfg(target_os = "fuchsia")]
599impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
600 type Protocol = WatcherMarker;
601
602 fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
603 Self::new(value.into_channel())
604 }
605}
606
607#[derive(Debug, Clone)]
608pub struct WatcherProxy {
609 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
610}
611
612impl fidl::endpoints::Proxy for WatcherProxy {
613 type Protocol = WatcherMarker;
614
615 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
616 Self::new(inner)
617 }
618
619 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
620 self.client.into_channel().map_err(|client| Self { client })
621 }
622
623 fn as_channel(&self) -> &::fidl::AsyncChannel {
624 self.client.as_channel()
625 }
626}
627
628impl WatcherProxy {
629 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
631 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
632 Self { client: fidl::client::Client::new(channel, protocol_name) }
633 }
634
635 pub fn take_event_stream(&self) -> WatcherEventStream {
641 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
642 }
643
644 pub fn r#watch(
655 &self,
656 mut ids: &[Identifier],
657 ) -> fidl::client::QueryResponseFut<
658 Vec<Information>,
659 fidl::encoding::DefaultFuchsiaResourceDialect,
660 > {
661 WatcherProxyInterface::r#watch(self, ids)
662 }
663}
664
665impl WatcherProxyInterface for WatcherProxy {
666 type WatchResponseFut = fidl::client::QueryResponseFut<
667 Vec<Information>,
668 fidl::encoding::DefaultFuchsiaResourceDialect,
669 >;
670 fn r#watch(&self, mut ids: &[Identifier]) -> Self::WatchResponseFut {
671 fn _decode(
672 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
673 ) -> Result<Vec<Information>, fidl::Error> {
674 let _response = fidl::client::decode_transaction_body::<
675 WatcherWatchResponse,
676 fidl::encoding::DefaultFuchsiaResourceDialect,
677 0x7cc4d24741dddb85,
678 >(_buf?)?;
679 Ok(_response.peripherals)
680 }
681 self.client.send_query_and_decode::<WatcherWatchRequest, Vec<Information>>(
682 (ids,),
683 0x7cc4d24741dddb85,
684 fidl::encoding::DynamicFlags::empty(),
685 _decode,
686 )
687 }
688}
689
690pub struct WatcherEventStream {
691 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
692}
693
694impl std::marker::Unpin for WatcherEventStream {}
695
696impl futures::stream::FusedStream for WatcherEventStream {
697 fn is_terminated(&self) -> bool {
698 self.event_receiver.is_terminated()
699 }
700}
701
702impl futures::Stream for WatcherEventStream {
703 type Item = Result<WatcherEvent, fidl::Error>;
704
705 fn poll_next(
706 mut self: std::pin::Pin<&mut Self>,
707 cx: &mut std::task::Context<'_>,
708 ) -> std::task::Poll<Option<Self::Item>> {
709 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
710 &mut self.event_receiver,
711 cx
712 )?) {
713 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
714 None => std::task::Poll::Ready(None),
715 }
716 }
717}
718
719#[derive(Debug)]
720pub enum WatcherEvent {}
721
722impl WatcherEvent {
723 fn decode(
725 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
726 ) -> Result<WatcherEvent, fidl::Error> {
727 let (bytes, _handles) = buf.split_mut();
728 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
729 debug_assert_eq!(tx_header.tx_id, 0);
730 match tx_header.ordinal {
731 _ => Err(fidl::Error::UnknownOrdinal {
732 ordinal: tx_header.ordinal,
733 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
734 }),
735 }
736 }
737}
738
739pub struct WatcherRequestStream {
741 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
742 is_terminated: bool,
743}
744
745impl std::marker::Unpin for WatcherRequestStream {}
746
747impl futures::stream::FusedStream for WatcherRequestStream {
748 fn is_terminated(&self) -> bool {
749 self.is_terminated
750 }
751}
752
753impl fidl::endpoints::RequestStream for WatcherRequestStream {
754 type Protocol = WatcherMarker;
755 type ControlHandle = WatcherControlHandle;
756
757 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
758 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
759 }
760
761 fn control_handle(&self) -> Self::ControlHandle {
762 WatcherControlHandle { inner: self.inner.clone() }
763 }
764
765 fn into_inner(
766 self,
767 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
768 {
769 (self.inner, self.is_terminated)
770 }
771
772 fn from_inner(
773 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
774 is_terminated: bool,
775 ) -> Self {
776 Self { inner, is_terminated }
777 }
778}
779
780impl futures::Stream for WatcherRequestStream {
781 type Item = Result<WatcherRequest, fidl::Error>;
782
783 fn poll_next(
784 mut self: std::pin::Pin<&mut Self>,
785 cx: &mut std::task::Context<'_>,
786 ) -> std::task::Poll<Option<Self::Item>> {
787 let this = &mut *self;
788 if this.inner.check_shutdown(cx) {
789 this.is_terminated = true;
790 return std::task::Poll::Ready(None);
791 }
792 if this.is_terminated {
793 panic!("polled WatcherRequestStream after completion");
794 }
795 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
796 |bytes, handles| {
797 match this.inner.channel().read_etc(cx, bytes, handles) {
798 std::task::Poll::Ready(Ok(())) => {}
799 std::task::Poll::Pending => return std::task::Poll::Pending,
800 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
801 this.is_terminated = true;
802 return std::task::Poll::Ready(None);
803 }
804 std::task::Poll::Ready(Err(e)) => {
805 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
806 e.into(),
807 ))))
808 }
809 }
810
811 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
813
814 std::task::Poll::Ready(Some(match header.ordinal {
815 0x7cc4d24741dddb85 => {
816 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
817 let mut req = fidl::new_empty!(
818 WatcherWatchRequest,
819 fidl::encoding::DefaultFuchsiaResourceDialect
820 );
821 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WatcherWatchRequest>(&header, _body_bytes, handles, &mut req)?;
822 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
823 Ok(WatcherRequest::Watch {
824 ids: req.ids,
825
826 responder: WatcherWatchResponder {
827 control_handle: std::mem::ManuallyDrop::new(control_handle),
828 tx_id: header.tx_id,
829 },
830 })
831 }
832 _ => Err(fidl::Error::UnknownOrdinal {
833 ordinal: header.ordinal,
834 protocol_name:
835 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
836 }),
837 }))
838 },
839 )
840 }
841}
842
843#[derive(Debug)]
845pub enum WatcherRequest {
846 Watch { ids: Vec<Identifier>, responder: WatcherWatchResponder },
857}
858
859impl WatcherRequest {
860 #[allow(irrefutable_let_patterns)]
861 pub fn into_watch(self) -> Option<(Vec<Identifier>, WatcherWatchResponder)> {
862 if let WatcherRequest::Watch { ids, responder } = self {
863 Some((ids, responder))
864 } else {
865 None
866 }
867 }
868
869 pub fn method_name(&self) -> &'static str {
871 match *self {
872 WatcherRequest::Watch { .. } => "watch",
873 }
874 }
875}
876
877#[derive(Debug, Clone)]
878pub struct WatcherControlHandle {
879 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
880}
881
882impl fidl::endpoints::ControlHandle for WatcherControlHandle {
883 fn shutdown(&self) {
884 self.inner.shutdown()
885 }
886 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
887 self.inner.shutdown_with_epitaph(status)
888 }
889
890 fn is_closed(&self) -> bool {
891 self.inner.channel().is_closed()
892 }
893 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
894 self.inner.channel().on_closed()
895 }
896
897 #[cfg(target_os = "fuchsia")]
898 fn signal_peer(
899 &self,
900 clear_mask: zx::Signals,
901 set_mask: zx::Signals,
902 ) -> Result<(), zx_status::Status> {
903 use fidl::Peered;
904 self.inner.channel().signal_peer(clear_mask, set_mask)
905 }
906}
907
908impl WatcherControlHandle {}
909
910#[must_use = "FIDL methods require a response to be sent"]
911#[derive(Debug)]
912pub struct WatcherWatchResponder {
913 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
914 tx_id: u32,
915}
916
917impl std::ops::Drop for WatcherWatchResponder {
921 fn drop(&mut self) {
922 self.control_handle.shutdown();
923 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
925 }
926}
927
928impl fidl::endpoints::Responder for WatcherWatchResponder {
929 type ControlHandle = WatcherControlHandle;
930
931 fn control_handle(&self) -> &WatcherControlHandle {
932 &self.control_handle
933 }
934
935 fn drop_without_shutdown(mut self) {
936 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
938 std::mem::forget(self);
940 }
941}
942
943impl WatcherWatchResponder {
944 pub fn send(self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
948 let _result = self.send_raw(peripherals);
949 if _result.is_err() {
950 self.control_handle.shutdown();
951 }
952 self.drop_without_shutdown();
953 _result
954 }
955
956 pub fn send_no_shutdown_on_err(
958 self,
959 mut peripherals: &[Information],
960 ) -> Result<(), fidl::Error> {
961 let _result = self.send_raw(peripherals);
962 self.drop_without_shutdown();
963 _result
964 }
965
966 fn send_raw(&self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
967 self.control_handle.inner.send::<WatcherWatchResponse>(
968 (peripherals,),
969 self.tx_id,
970 0x7cc4d24741dddb85,
971 fidl::encoding::DynamicFlags::empty(),
972 )
973 }
974}
975
976mod internal {
977 use super::*;
978
979 impl fidl::encoding::ResourceTypeMarker for ReporterReportRequest {
980 type Borrowed<'a> = &'a mut Self;
981 fn take_or_borrow<'a>(
982 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
983 ) -> Self::Borrowed<'a> {
984 value
985 }
986 }
987
988 unsafe impl fidl::encoding::TypeMarker for ReporterReportRequest {
989 type Owned = Self;
990
991 #[inline(always)]
992 fn inline_align(_context: fidl::encoding::Context) -> usize {
993 8
994 }
995
996 #[inline(always)]
997 fn inline_size(_context: fidl::encoding::Context) -> usize {
998 16
999 }
1000 }
1001
1002 unsafe impl
1003 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1004 for &mut ReporterReportRequest
1005 {
1006 #[inline]
1007 unsafe fn encode(
1008 self,
1009 encoder: &mut fidl::encoding::Encoder<
1010 '_,
1011 fidl::encoding::DefaultFuchsiaResourceDialect,
1012 >,
1013 offset: usize,
1014 _depth: fidl::encoding::Depth,
1015 ) -> fidl::Result<()> {
1016 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
1017 fidl::encoding::Encode::<
1019 ReporterReportRequest,
1020 fidl::encoding::DefaultFuchsiaResourceDialect,
1021 >::encode(
1022 (<Information as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
1023 encoder,
1024 offset,
1025 _depth,
1026 )
1027 }
1028 }
1029 unsafe impl<
1030 T0: fidl::encoding::Encode<Information, fidl::encoding::DefaultFuchsiaResourceDialect>,
1031 >
1032 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1033 for (T0,)
1034 {
1035 #[inline]
1036 unsafe fn encode(
1037 self,
1038 encoder: &mut fidl::encoding::Encoder<
1039 '_,
1040 fidl::encoding::DefaultFuchsiaResourceDialect,
1041 >,
1042 offset: usize,
1043 depth: fidl::encoding::Depth,
1044 ) -> fidl::Result<()> {
1045 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
1046 self.0.encode(encoder, offset + 0, depth)?;
1050 Ok(())
1051 }
1052 }
1053
1054 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1055 for ReporterReportRequest
1056 {
1057 #[inline(always)]
1058 fn new_empty() -> Self {
1059 Self {
1060 info: fidl::new_empty!(Information, fidl::encoding::DefaultFuchsiaResourceDialect),
1061 }
1062 }
1063
1064 #[inline]
1065 unsafe fn decode(
1066 &mut self,
1067 decoder: &mut fidl::encoding::Decoder<
1068 '_,
1069 fidl::encoding::DefaultFuchsiaResourceDialect,
1070 >,
1071 offset: usize,
1072 _depth: fidl::encoding::Depth,
1073 ) -> fidl::Result<()> {
1074 decoder.debug_check_bounds::<Self>(offset);
1075 fidl::decode!(
1077 Information,
1078 fidl::encoding::DefaultFuchsiaResourceDialect,
1079 &mut self.info,
1080 decoder,
1081 offset + 0,
1082 _depth
1083 )?;
1084 Ok(())
1085 }
1086 }
1087}