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#[derive(Debug, Clone)]
125pub struct ReporterProxy {
126 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
127}
128
129impl fidl::endpoints::Proxy for ReporterProxy {
130 type Protocol = ReporterMarker;
131
132 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
133 Self::new(inner)
134 }
135
136 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
137 self.client.into_channel().map_err(|client| Self { client })
138 }
139
140 fn as_channel(&self) -> &::fidl::AsyncChannel {
141 self.client.as_channel()
142 }
143}
144
145impl ReporterProxy {
146 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
148 let protocol_name = <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
149 Self { client: fidl::client::Client::new(channel, protocol_name) }
150 }
151
152 pub fn take_event_stream(&self) -> ReporterEventStream {
158 ReporterEventStream { event_receiver: self.client.take_event_receiver() }
159 }
160
161 pub fn r#report(
170 &self,
171 mut info: &Information,
172 ) -> fidl::client::QueryResponseFut<
173 ReporterReportResult,
174 fidl::encoding::DefaultFuchsiaResourceDialect,
175 > {
176 ReporterProxyInterface::r#report(self, info)
177 }
178}
179
180impl ReporterProxyInterface for ReporterProxy {
181 type ReportResponseFut = fidl::client::QueryResponseFut<
182 ReporterReportResult,
183 fidl::encoding::DefaultFuchsiaResourceDialect,
184 >;
185 fn r#report(&self, mut info: &Information) -> Self::ReportResponseFut {
186 fn _decode(
187 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
188 ) -> Result<ReporterReportResult, fidl::Error> {
189 let _response = fidl::client::decode_transaction_body::<
190 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
191 fidl::encoding::DefaultFuchsiaResourceDialect,
192 0x282927fd7363f17f,
193 >(_buf?)?;
194 Ok(_response.map(|x| x))
195 }
196 self.client.send_query_and_decode::<ReporterReportRequest, ReporterReportResult>(
197 (info,),
198 0x282927fd7363f17f,
199 fidl::encoding::DynamicFlags::empty(),
200 _decode,
201 )
202 }
203}
204
205pub struct ReporterEventStream {
206 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
207}
208
209impl std::marker::Unpin for ReporterEventStream {}
210
211impl futures::stream::FusedStream for ReporterEventStream {
212 fn is_terminated(&self) -> bool {
213 self.event_receiver.is_terminated()
214 }
215}
216
217impl futures::Stream for ReporterEventStream {
218 type Item = Result<ReporterEvent, fidl::Error>;
219
220 fn poll_next(
221 mut self: std::pin::Pin<&mut Self>,
222 cx: &mut std::task::Context<'_>,
223 ) -> std::task::Poll<Option<Self::Item>> {
224 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
225 &mut self.event_receiver,
226 cx
227 )?) {
228 Some(buf) => std::task::Poll::Ready(Some(ReporterEvent::decode(buf))),
229 None => std::task::Poll::Ready(None),
230 }
231 }
232}
233
234#[derive(Debug)]
235pub enum ReporterEvent {}
236
237impl ReporterEvent {
238 fn decode(
240 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
241 ) -> Result<ReporterEvent, fidl::Error> {
242 let (bytes, _handles) = buf.split_mut();
243 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
244 debug_assert_eq!(tx_header.tx_id, 0);
245 match tx_header.ordinal {
246 _ => Err(fidl::Error::UnknownOrdinal {
247 ordinal: tx_header.ordinal,
248 protocol_name: <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
249 }),
250 }
251 }
252}
253
254pub struct ReporterRequestStream {
256 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
257 is_terminated: bool,
258}
259
260impl std::marker::Unpin for ReporterRequestStream {}
261
262impl futures::stream::FusedStream for ReporterRequestStream {
263 fn is_terminated(&self) -> bool {
264 self.is_terminated
265 }
266}
267
268impl fidl::endpoints::RequestStream for ReporterRequestStream {
269 type Protocol = ReporterMarker;
270 type ControlHandle = ReporterControlHandle;
271
272 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
273 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
274 }
275
276 fn control_handle(&self) -> Self::ControlHandle {
277 ReporterControlHandle { inner: self.inner.clone() }
278 }
279
280 fn into_inner(
281 self,
282 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
283 {
284 (self.inner, self.is_terminated)
285 }
286
287 fn from_inner(
288 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
289 is_terminated: bool,
290 ) -> Self {
291 Self { inner, is_terminated }
292 }
293}
294
295impl futures::Stream for ReporterRequestStream {
296 type Item = Result<ReporterRequest, fidl::Error>;
297
298 fn poll_next(
299 mut self: std::pin::Pin<&mut Self>,
300 cx: &mut std::task::Context<'_>,
301 ) -> std::task::Poll<Option<Self::Item>> {
302 let this = &mut *self;
303 if this.inner.check_shutdown(cx) {
304 this.is_terminated = true;
305 return std::task::Poll::Ready(None);
306 }
307 if this.is_terminated {
308 panic!("polled ReporterRequestStream after completion");
309 }
310 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
311 |bytes, handles| {
312 match this.inner.channel().read_etc(cx, bytes, handles) {
313 std::task::Poll::Ready(Ok(())) => {}
314 std::task::Poll::Pending => return std::task::Poll::Pending,
315 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
316 this.is_terminated = true;
317 return std::task::Poll::Ready(None);
318 }
319 std::task::Poll::Ready(Err(e)) => {
320 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
321 e.into(),
322 ))))
323 }
324 }
325
326 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
328
329 std::task::Poll::Ready(Some(match header.ordinal {
330 0x282927fd7363f17f => {
331 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
332 let mut req = fidl::new_empty!(
333 ReporterReportRequest,
334 fidl::encoding::DefaultFuchsiaResourceDialect
335 );
336 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReporterReportRequest>(&header, _body_bytes, handles, &mut req)?;
337 let control_handle = ReporterControlHandle { inner: this.inner.clone() };
338 Ok(ReporterRequest::Report {
339 info: req.info,
340
341 responder: ReporterReportResponder {
342 control_handle: std::mem::ManuallyDrop::new(control_handle),
343 tx_id: header.tx_id,
344 },
345 })
346 }
347 _ => Err(fidl::Error::UnknownOrdinal {
348 ordinal: header.ordinal,
349 protocol_name:
350 <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
351 }),
352 }))
353 },
354 )
355 }
356}
357
358#[derive(Debug)]
360pub enum ReporterRequest {
361 Report { info: Information, responder: ReporterReportResponder },
370}
371
372impl ReporterRequest {
373 #[allow(irrefutable_let_patterns)]
374 pub fn into_report(self) -> Option<(Information, ReporterReportResponder)> {
375 if let ReporterRequest::Report { info, responder } = self {
376 Some((info, responder))
377 } else {
378 None
379 }
380 }
381
382 pub fn method_name(&self) -> &'static str {
384 match *self {
385 ReporterRequest::Report { .. } => "report",
386 }
387 }
388}
389
390#[derive(Debug, Clone)]
391pub struct ReporterControlHandle {
392 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
393}
394
395impl fidl::endpoints::ControlHandle for ReporterControlHandle {
396 fn shutdown(&self) {
397 self.inner.shutdown()
398 }
399 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
400 self.inner.shutdown_with_epitaph(status)
401 }
402
403 fn is_closed(&self) -> bool {
404 self.inner.channel().is_closed()
405 }
406 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
407 self.inner.channel().on_closed()
408 }
409
410 #[cfg(target_os = "fuchsia")]
411 fn signal_peer(
412 &self,
413 clear_mask: zx::Signals,
414 set_mask: zx::Signals,
415 ) -> Result<(), zx_status::Status> {
416 use fidl::Peered;
417 self.inner.channel().signal_peer(clear_mask, set_mask)
418 }
419}
420
421impl ReporterControlHandle {}
422
423#[must_use = "FIDL methods require a response to be sent"]
424#[derive(Debug)]
425pub struct ReporterReportResponder {
426 control_handle: std::mem::ManuallyDrop<ReporterControlHandle>,
427 tx_id: u32,
428}
429
430impl std::ops::Drop for ReporterReportResponder {
434 fn drop(&mut self) {
435 self.control_handle.shutdown();
436 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
438 }
439}
440
441impl fidl::endpoints::Responder for ReporterReportResponder {
442 type ControlHandle = ReporterControlHandle;
443
444 fn control_handle(&self) -> &ReporterControlHandle {
445 &self.control_handle
446 }
447
448 fn drop_without_shutdown(mut self) {
449 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
451 std::mem::forget(self);
453 }
454}
455
456impl ReporterReportResponder {
457 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
461 let _result = self.send_raw(result);
462 if _result.is_err() {
463 self.control_handle.shutdown();
464 }
465 self.drop_without_shutdown();
466 _result
467 }
468
469 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
471 let _result = self.send_raw(result);
472 self.drop_without_shutdown();
473 _result
474 }
475
476 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
477 self.control_handle
478 .inner
479 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
480 result,
481 self.tx_id,
482 0x282927fd7363f17f,
483 fidl::encoding::DynamicFlags::empty(),
484 )
485 }
486}
487
488#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
489pub struct WatcherMarker;
490
491impl fidl::endpoints::ProtocolMarker for WatcherMarker {
492 type Proxy = WatcherProxy;
493 type RequestStream = WatcherRequestStream;
494 #[cfg(target_os = "fuchsia")]
495 type SynchronousProxy = WatcherSynchronousProxy;
496
497 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.power.Watcher";
498}
499impl fidl::endpoints::DiscoverableProtocolMarker for WatcherMarker {}
500
501pub trait WatcherProxyInterface: Send + Sync {
502 type WatchResponseFut: std::future::Future<Output = Result<Vec<Information>, fidl::Error>>
503 + Send;
504 fn r#watch(&self, ids: &[Identifier]) -> Self::WatchResponseFut;
505}
506#[derive(Debug)]
507#[cfg(target_os = "fuchsia")]
508pub struct WatcherSynchronousProxy {
509 client: fidl::client::sync::Client,
510}
511
512#[cfg(target_os = "fuchsia")]
513impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
514 type Proxy = WatcherProxy;
515 type Protocol = WatcherMarker;
516
517 fn from_channel(inner: fidl::Channel) -> Self {
518 Self::new(inner)
519 }
520
521 fn into_channel(self) -> fidl::Channel {
522 self.client.into_channel()
523 }
524
525 fn as_channel(&self) -> &fidl::Channel {
526 self.client.as_channel()
527 }
528}
529
530#[cfg(target_os = "fuchsia")]
531impl WatcherSynchronousProxy {
532 pub fn new(channel: fidl::Channel) -> Self {
533 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
534 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
535 }
536
537 pub fn into_channel(self) -> fidl::Channel {
538 self.client.into_channel()
539 }
540
541 pub fn wait_for_event(
544 &self,
545 deadline: zx::MonotonicInstant,
546 ) -> Result<WatcherEvent, fidl::Error> {
547 WatcherEvent::decode(self.client.wait_for_event(deadline)?)
548 }
549
550 pub fn r#watch(
561 &self,
562 mut ids: &[Identifier],
563 ___deadline: zx::MonotonicInstant,
564 ) -> Result<Vec<Information>, fidl::Error> {
565 let _response = self.client.send_query::<WatcherWatchRequest, WatcherWatchResponse>(
566 (ids,),
567 0x7cc4d24741dddb85,
568 fidl::encoding::DynamicFlags::empty(),
569 ___deadline,
570 )?;
571 Ok(_response.peripherals)
572 }
573}
574
575#[cfg(target_os = "fuchsia")]
576impl From<WatcherSynchronousProxy> for zx::Handle {
577 fn from(value: WatcherSynchronousProxy) -> Self {
578 value.into_channel().into()
579 }
580}
581
582#[cfg(target_os = "fuchsia")]
583impl From<fidl::Channel> for WatcherSynchronousProxy {
584 fn from(value: fidl::Channel) -> Self {
585 Self::new(value)
586 }
587}
588
589#[derive(Debug, Clone)]
590pub struct WatcherProxy {
591 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
592}
593
594impl fidl::endpoints::Proxy for WatcherProxy {
595 type Protocol = WatcherMarker;
596
597 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
598 Self::new(inner)
599 }
600
601 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
602 self.client.into_channel().map_err(|client| Self { client })
603 }
604
605 fn as_channel(&self) -> &::fidl::AsyncChannel {
606 self.client.as_channel()
607 }
608}
609
610impl WatcherProxy {
611 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
613 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
614 Self { client: fidl::client::Client::new(channel, protocol_name) }
615 }
616
617 pub fn take_event_stream(&self) -> WatcherEventStream {
623 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
624 }
625
626 pub fn r#watch(
637 &self,
638 mut ids: &[Identifier],
639 ) -> fidl::client::QueryResponseFut<
640 Vec<Information>,
641 fidl::encoding::DefaultFuchsiaResourceDialect,
642 > {
643 WatcherProxyInterface::r#watch(self, ids)
644 }
645}
646
647impl WatcherProxyInterface for WatcherProxy {
648 type WatchResponseFut = fidl::client::QueryResponseFut<
649 Vec<Information>,
650 fidl::encoding::DefaultFuchsiaResourceDialect,
651 >;
652 fn r#watch(&self, mut ids: &[Identifier]) -> Self::WatchResponseFut {
653 fn _decode(
654 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
655 ) -> Result<Vec<Information>, fidl::Error> {
656 let _response = fidl::client::decode_transaction_body::<
657 WatcherWatchResponse,
658 fidl::encoding::DefaultFuchsiaResourceDialect,
659 0x7cc4d24741dddb85,
660 >(_buf?)?;
661 Ok(_response.peripherals)
662 }
663 self.client.send_query_and_decode::<WatcherWatchRequest, Vec<Information>>(
664 (ids,),
665 0x7cc4d24741dddb85,
666 fidl::encoding::DynamicFlags::empty(),
667 _decode,
668 )
669 }
670}
671
672pub struct WatcherEventStream {
673 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
674}
675
676impl std::marker::Unpin for WatcherEventStream {}
677
678impl futures::stream::FusedStream for WatcherEventStream {
679 fn is_terminated(&self) -> bool {
680 self.event_receiver.is_terminated()
681 }
682}
683
684impl futures::Stream for WatcherEventStream {
685 type Item = Result<WatcherEvent, fidl::Error>;
686
687 fn poll_next(
688 mut self: std::pin::Pin<&mut Self>,
689 cx: &mut std::task::Context<'_>,
690 ) -> std::task::Poll<Option<Self::Item>> {
691 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
692 &mut self.event_receiver,
693 cx
694 )?) {
695 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
696 None => std::task::Poll::Ready(None),
697 }
698 }
699}
700
701#[derive(Debug)]
702pub enum WatcherEvent {}
703
704impl WatcherEvent {
705 fn decode(
707 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
708 ) -> Result<WatcherEvent, fidl::Error> {
709 let (bytes, _handles) = buf.split_mut();
710 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
711 debug_assert_eq!(tx_header.tx_id, 0);
712 match tx_header.ordinal {
713 _ => Err(fidl::Error::UnknownOrdinal {
714 ordinal: tx_header.ordinal,
715 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
716 }),
717 }
718 }
719}
720
721pub struct WatcherRequestStream {
723 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
724 is_terminated: bool,
725}
726
727impl std::marker::Unpin for WatcherRequestStream {}
728
729impl futures::stream::FusedStream for WatcherRequestStream {
730 fn is_terminated(&self) -> bool {
731 self.is_terminated
732 }
733}
734
735impl fidl::endpoints::RequestStream for WatcherRequestStream {
736 type Protocol = WatcherMarker;
737 type ControlHandle = WatcherControlHandle;
738
739 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
740 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
741 }
742
743 fn control_handle(&self) -> Self::ControlHandle {
744 WatcherControlHandle { inner: self.inner.clone() }
745 }
746
747 fn into_inner(
748 self,
749 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
750 {
751 (self.inner, self.is_terminated)
752 }
753
754 fn from_inner(
755 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
756 is_terminated: bool,
757 ) -> Self {
758 Self { inner, is_terminated }
759 }
760}
761
762impl futures::Stream for WatcherRequestStream {
763 type Item = Result<WatcherRequest, fidl::Error>;
764
765 fn poll_next(
766 mut self: std::pin::Pin<&mut Self>,
767 cx: &mut std::task::Context<'_>,
768 ) -> std::task::Poll<Option<Self::Item>> {
769 let this = &mut *self;
770 if this.inner.check_shutdown(cx) {
771 this.is_terminated = true;
772 return std::task::Poll::Ready(None);
773 }
774 if this.is_terminated {
775 panic!("polled WatcherRequestStream after completion");
776 }
777 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
778 |bytes, handles| {
779 match this.inner.channel().read_etc(cx, bytes, handles) {
780 std::task::Poll::Ready(Ok(())) => {}
781 std::task::Poll::Pending => return std::task::Poll::Pending,
782 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
783 this.is_terminated = true;
784 return std::task::Poll::Ready(None);
785 }
786 std::task::Poll::Ready(Err(e)) => {
787 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
788 e.into(),
789 ))))
790 }
791 }
792
793 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
795
796 std::task::Poll::Ready(Some(match header.ordinal {
797 0x7cc4d24741dddb85 => {
798 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
799 let mut req = fidl::new_empty!(
800 WatcherWatchRequest,
801 fidl::encoding::DefaultFuchsiaResourceDialect
802 );
803 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WatcherWatchRequest>(&header, _body_bytes, handles, &mut req)?;
804 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
805 Ok(WatcherRequest::Watch {
806 ids: req.ids,
807
808 responder: WatcherWatchResponder {
809 control_handle: std::mem::ManuallyDrop::new(control_handle),
810 tx_id: header.tx_id,
811 },
812 })
813 }
814 _ => Err(fidl::Error::UnknownOrdinal {
815 ordinal: header.ordinal,
816 protocol_name:
817 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
818 }),
819 }))
820 },
821 )
822 }
823}
824
825#[derive(Debug)]
827pub enum WatcherRequest {
828 Watch { ids: Vec<Identifier>, responder: WatcherWatchResponder },
839}
840
841impl WatcherRequest {
842 #[allow(irrefutable_let_patterns)]
843 pub fn into_watch(self) -> Option<(Vec<Identifier>, WatcherWatchResponder)> {
844 if let WatcherRequest::Watch { ids, responder } = self {
845 Some((ids, responder))
846 } else {
847 None
848 }
849 }
850
851 pub fn method_name(&self) -> &'static str {
853 match *self {
854 WatcherRequest::Watch { .. } => "watch",
855 }
856 }
857}
858
859#[derive(Debug, Clone)]
860pub struct WatcherControlHandle {
861 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
862}
863
864impl fidl::endpoints::ControlHandle for WatcherControlHandle {
865 fn shutdown(&self) {
866 self.inner.shutdown()
867 }
868 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
869 self.inner.shutdown_with_epitaph(status)
870 }
871
872 fn is_closed(&self) -> bool {
873 self.inner.channel().is_closed()
874 }
875 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
876 self.inner.channel().on_closed()
877 }
878
879 #[cfg(target_os = "fuchsia")]
880 fn signal_peer(
881 &self,
882 clear_mask: zx::Signals,
883 set_mask: zx::Signals,
884 ) -> Result<(), zx_status::Status> {
885 use fidl::Peered;
886 self.inner.channel().signal_peer(clear_mask, set_mask)
887 }
888}
889
890impl WatcherControlHandle {}
891
892#[must_use = "FIDL methods require a response to be sent"]
893#[derive(Debug)]
894pub struct WatcherWatchResponder {
895 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
896 tx_id: u32,
897}
898
899impl std::ops::Drop for WatcherWatchResponder {
903 fn drop(&mut self) {
904 self.control_handle.shutdown();
905 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
907 }
908}
909
910impl fidl::endpoints::Responder for WatcherWatchResponder {
911 type ControlHandle = WatcherControlHandle;
912
913 fn control_handle(&self) -> &WatcherControlHandle {
914 &self.control_handle
915 }
916
917 fn drop_without_shutdown(mut self) {
918 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
920 std::mem::forget(self);
922 }
923}
924
925impl WatcherWatchResponder {
926 pub fn send(self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
930 let _result = self.send_raw(peripherals);
931 if _result.is_err() {
932 self.control_handle.shutdown();
933 }
934 self.drop_without_shutdown();
935 _result
936 }
937
938 pub fn send_no_shutdown_on_err(
940 self,
941 mut peripherals: &[Information],
942 ) -> Result<(), fidl::Error> {
943 let _result = self.send_raw(peripherals);
944 self.drop_without_shutdown();
945 _result
946 }
947
948 fn send_raw(&self, mut peripherals: &[Information]) -> Result<(), fidl::Error> {
949 self.control_handle.inner.send::<WatcherWatchResponse>(
950 (peripherals,),
951 self.tx_id,
952 0x7cc4d24741dddb85,
953 fidl::encoding::DynamicFlags::empty(),
954 )
955 }
956}
957
958mod internal {
959 use super::*;
960
961 impl fidl::encoding::ResourceTypeMarker for ReporterReportRequest {
962 type Borrowed<'a> = &'a mut Self;
963 fn take_or_borrow<'a>(
964 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
965 ) -> Self::Borrowed<'a> {
966 value
967 }
968 }
969
970 unsafe impl fidl::encoding::TypeMarker for ReporterReportRequest {
971 type Owned = Self;
972
973 #[inline(always)]
974 fn inline_align(_context: fidl::encoding::Context) -> usize {
975 8
976 }
977
978 #[inline(always)]
979 fn inline_size(_context: fidl::encoding::Context) -> usize {
980 16
981 }
982 }
983
984 unsafe impl
985 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
986 for &mut ReporterReportRequest
987 {
988 #[inline]
989 unsafe fn encode(
990 self,
991 encoder: &mut fidl::encoding::Encoder<
992 '_,
993 fidl::encoding::DefaultFuchsiaResourceDialect,
994 >,
995 offset: usize,
996 _depth: fidl::encoding::Depth,
997 ) -> fidl::Result<()> {
998 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
999 fidl::encoding::Encode::<
1001 ReporterReportRequest,
1002 fidl::encoding::DefaultFuchsiaResourceDialect,
1003 >::encode(
1004 (<Information as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
1005 encoder,
1006 offset,
1007 _depth,
1008 )
1009 }
1010 }
1011 unsafe impl<
1012 T0: fidl::encoding::Encode<Information, fidl::encoding::DefaultFuchsiaResourceDialect>,
1013 >
1014 fidl::encoding::Encode<ReporterReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1015 for (T0,)
1016 {
1017 #[inline]
1018 unsafe fn encode(
1019 self,
1020 encoder: &mut fidl::encoding::Encoder<
1021 '_,
1022 fidl::encoding::DefaultFuchsiaResourceDialect,
1023 >,
1024 offset: usize,
1025 depth: fidl::encoding::Depth,
1026 ) -> fidl::Result<()> {
1027 encoder.debug_check_bounds::<ReporterReportRequest>(offset);
1028 self.0.encode(encoder, offset + 0, depth)?;
1032 Ok(())
1033 }
1034 }
1035
1036 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1037 for ReporterReportRequest
1038 {
1039 #[inline(always)]
1040 fn new_empty() -> Self {
1041 Self {
1042 info: fidl::new_empty!(Information, fidl::encoding::DefaultFuchsiaResourceDialect),
1043 }
1044 }
1045
1046 #[inline]
1047 unsafe fn decode(
1048 &mut self,
1049 decoder: &mut fidl::encoding::Decoder<
1050 '_,
1051 fidl::encoding::DefaultFuchsiaResourceDialect,
1052 >,
1053 offset: usize,
1054 _depth: fidl::encoding::Depth,
1055 ) -> fidl::Result<()> {
1056 decoder.debug_check_bounds::<Self>(offset);
1057 fidl::decode!(
1059 Information,
1060 fidl::encoding::DefaultFuchsiaResourceDialect,
1061 &mut self.info,
1062 decoder,
1063 offset + 0,
1064 _depth
1065 )?;
1066 Ok(())
1067 }
1068 }
1069}