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_ui_display_singleton_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DisplayPowerMarker;
16
17impl fidl::endpoints::ProtocolMarker for DisplayPowerMarker {
18 type Proxy = DisplayPowerProxy;
19 type RequestStream = DisplayPowerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DisplayPowerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.DisplayPower";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DisplayPowerMarker {}
26pub type DisplayPowerSetDisplayPowerResult = Result<(), i32>;
27
28pub trait DisplayPowerProxyInterface: Send + Sync {
29 type SetDisplayPowerResponseFut: std::future::Future<Output = Result<DisplayPowerSetDisplayPowerResult, fidl::Error>>
30 + Send;
31 fn r#set_display_power(&self, power_on: bool) -> Self::SetDisplayPowerResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct DisplayPowerSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for DisplayPowerSynchronousProxy {
41 type Proxy = DisplayPowerProxy;
42 type Protocol = DisplayPowerMarker;
43
44 fn from_channel(inner: fidl::Channel) -> Self {
45 Self::new(inner)
46 }
47
48 fn into_channel(self) -> fidl::Channel {
49 self.client.into_channel()
50 }
51
52 fn as_channel(&self) -> &fidl::Channel {
53 self.client.as_channel()
54 }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl DisplayPowerSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 let protocol_name = <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
61 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
62 }
63
64 pub fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 pub fn wait_for_event(
71 &self,
72 deadline: zx::MonotonicInstant,
73 ) -> Result<DisplayPowerEvent, fidl::Error> {
74 DisplayPowerEvent::decode(self.client.wait_for_event(deadline)?)
75 }
76
77 pub fn r#set_display_power(
88 &self,
89 mut power_on: bool,
90 ___deadline: zx::MonotonicInstant,
91 ) -> Result<DisplayPowerSetDisplayPowerResult, fidl::Error> {
92 let _response = self.client.send_query::<
93 DisplayPowerSetDisplayPowerRequest,
94 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
95 >(
96 (power_on,),
97 0x59f31b10e74ce66f,
98 fidl::encoding::DynamicFlags::empty(),
99 ___deadline,
100 )?;
101 Ok(_response.map(|x| x))
102 }
103}
104
105#[derive(Debug, Clone)]
106pub struct DisplayPowerProxy {
107 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
108}
109
110impl fidl::endpoints::Proxy for DisplayPowerProxy {
111 type Protocol = DisplayPowerMarker;
112
113 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
114 Self::new(inner)
115 }
116
117 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
118 self.client.into_channel().map_err(|client| Self { client })
119 }
120
121 fn as_channel(&self) -> &::fidl::AsyncChannel {
122 self.client.as_channel()
123 }
124}
125
126impl DisplayPowerProxy {
127 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
129 let protocol_name = <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130 Self { client: fidl::client::Client::new(channel, protocol_name) }
131 }
132
133 pub fn take_event_stream(&self) -> DisplayPowerEventStream {
139 DisplayPowerEventStream { event_receiver: self.client.take_event_receiver() }
140 }
141
142 pub fn r#set_display_power(
153 &self,
154 mut power_on: bool,
155 ) -> fidl::client::QueryResponseFut<
156 DisplayPowerSetDisplayPowerResult,
157 fidl::encoding::DefaultFuchsiaResourceDialect,
158 > {
159 DisplayPowerProxyInterface::r#set_display_power(self, power_on)
160 }
161}
162
163impl DisplayPowerProxyInterface for DisplayPowerProxy {
164 type SetDisplayPowerResponseFut = fidl::client::QueryResponseFut<
165 DisplayPowerSetDisplayPowerResult,
166 fidl::encoding::DefaultFuchsiaResourceDialect,
167 >;
168 fn r#set_display_power(&self, mut power_on: bool) -> Self::SetDisplayPowerResponseFut {
169 fn _decode(
170 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
171 ) -> Result<DisplayPowerSetDisplayPowerResult, fidl::Error> {
172 let _response = fidl::client::decode_transaction_body::<
173 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
174 fidl::encoding::DefaultFuchsiaResourceDialect,
175 0x59f31b10e74ce66f,
176 >(_buf?)?;
177 Ok(_response.map(|x| x))
178 }
179 self.client.send_query_and_decode::<
180 DisplayPowerSetDisplayPowerRequest,
181 DisplayPowerSetDisplayPowerResult,
182 >(
183 (power_on,),
184 0x59f31b10e74ce66f,
185 fidl::encoding::DynamicFlags::empty(),
186 _decode,
187 )
188 }
189}
190
191pub struct DisplayPowerEventStream {
192 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
193}
194
195impl std::marker::Unpin for DisplayPowerEventStream {}
196
197impl futures::stream::FusedStream for DisplayPowerEventStream {
198 fn is_terminated(&self) -> bool {
199 self.event_receiver.is_terminated()
200 }
201}
202
203impl futures::Stream for DisplayPowerEventStream {
204 type Item = Result<DisplayPowerEvent, fidl::Error>;
205
206 fn poll_next(
207 mut self: std::pin::Pin<&mut Self>,
208 cx: &mut std::task::Context<'_>,
209 ) -> std::task::Poll<Option<Self::Item>> {
210 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
211 &mut self.event_receiver,
212 cx
213 )?) {
214 Some(buf) => std::task::Poll::Ready(Some(DisplayPowerEvent::decode(buf))),
215 None => std::task::Poll::Ready(None),
216 }
217 }
218}
219
220#[derive(Debug)]
221pub enum DisplayPowerEvent {
222 #[non_exhaustive]
223 _UnknownEvent {
224 ordinal: u64,
226 },
227}
228
229impl DisplayPowerEvent {
230 fn decode(
232 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233 ) -> Result<DisplayPowerEvent, fidl::Error> {
234 let (bytes, _handles) = buf.split_mut();
235 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236 debug_assert_eq!(tx_header.tx_id, 0);
237 match tx_header.ordinal {
238 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
239 Ok(DisplayPowerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
240 }
241 _ => Err(fidl::Error::UnknownOrdinal {
242 ordinal: tx_header.ordinal,
243 protocol_name: <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
244 }),
245 }
246 }
247}
248
249pub struct DisplayPowerRequestStream {
251 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252 is_terminated: bool,
253}
254
255impl std::marker::Unpin for DisplayPowerRequestStream {}
256
257impl futures::stream::FusedStream for DisplayPowerRequestStream {
258 fn is_terminated(&self) -> bool {
259 self.is_terminated
260 }
261}
262
263impl fidl::endpoints::RequestStream for DisplayPowerRequestStream {
264 type Protocol = DisplayPowerMarker;
265 type ControlHandle = DisplayPowerControlHandle;
266
267 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
268 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
269 }
270
271 fn control_handle(&self) -> Self::ControlHandle {
272 DisplayPowerControlHandle { inner: self.inner.clone() }
273 }
274
275 fn into_inner(
276 self,
277 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
278 {
279 (self.inner, self.is_terminated)
280 }
281
282 fn from_inner(
283 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
284 is_terminated: bool,
285 ) -> Self {
286 Self { inner, is_terminated }
287 }
288}
289
290impl futures::Stream for DisplayPowerRequestStream {
291 type Item = Result<DisplayPowerRequest, fidl::Error>;
292
293 fn poll_next(
294 mut self: std::pin::Pin<&mut Self>,
295 cx: &mut std::task::Context<'_>,
296 ) -> std::task::Poll<Option<Self::Item>> {
297 let this = &mut *self;
298 if this.inner.check_shutdown(cx) {
299 this.is_terminated = true;
300 return std::task::Poll::Ready(None);
301 }
302 if this.is_terminated {
303 panic!("polled DisplayPowerRequestStream after completion");
304 }
305 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
306 |bytes, handles| {
307 match this.inner.channel().read_etc(cx, bytes, handles) {
308 std::task::Poll::Ready(Ok(())) => {}
309 std::task::Poll::Pending => return std::task::Poll::Pending,
310 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
311 this.is_terminated = true;
312 return std::task::Poll::Ready(None);
313 }
314 std::task::Poll::Ready(Err(e)) => {
315 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
316 e.into(),
317 ))))
318 }
319 }
320
321 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323
324 std::task::Poll::Ready(Some(match header.ordinal {
325 0x59f31b10e74ce66f => {
326 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
327 let mut req = fidl::new_empty!(
328 DisplayPowerSetDisplayPowerRequest,
329 fidl::encoding::DefaultFuchsiaResourceDialect
330 );
331 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayPowerSetDisplayPowerRequest>(&header, _body_bytes, handles, &mut req)?;
332 let control_handle =
333 DisplayPowerControlHandle { inner: this.inner.clone() };
334 Ok(DisplayPowerRequest::SetDisplayPower {
335 power_on: req.power_on,
336
337 responder: DisplayPowerSetDisplayPowerResponder {
338 control_handle: std::mem::ManuallyDrop::new(control_handle),
339 tx_id: header.tx_id,
340 },
341 })
342 }
343 _ if header.tx_id == 0
344 && header
345 .dynamic_flags()
346 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
347 {
348 Ok(DisplayPowerRequest::_UnknownMethod {
349 ordinal: header.ordinal,
350 control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
351 method_type: fidl::MethodType::OneWay,
352 })
353 }
354 _ if header
355 .dynamic_flags()
356 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
357 {
358 this.inner.send_framework_err(
359 fidl::encoding::FrameworkErr::UnknownMethod,
360 header.tx_id,
361 header.ordinal,
362 header.dynamic_flags(),
363 (bytes, handles),
364 )?;
365 Ok(DisplayPowerRequest::_UnknownMethod {
366 ordinal: header.ordinal,
367 control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
368 method_type: fidl::MethodType::TwoWay,
369 })
370 }
371 _ => Err(fidl::Error::UnknownOrdinal {
372 ordinal: header.ordinal,
373 protocol_name:
374 <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
375 }),
376 }))
377 },
378 )
379 }
380}
381
382#[derive(Debug)]
384pub enum DisplayPowerRequest {
385 SetDisplayPower { power_on: bool, responder: DisplayPowerSetDisplayPowerResponder },
396 #[non_exhaustive]
398 _UnknownMethod {
399 ordinal: u64,
401 control_handle: DisplayPowerControlHandle,
402 method_type: fidl::MethodType,
403 },
404}
405
406impl DisplayPowerRequest {
407 #[allow(irrefutable_let_patterns)]
408 pub fn into_set_display_power(self) -> Option<(bool, DisplayPowerSetDisplayPowerResponder)> {
409 if let DisplayPowerRequest::SetDisplayPower { power_on, responder } = self {
410 Some((power_on, responder))
411 } else {
412 None
413 }
414 }
415
416 pub fn method_name(&self) -> &'static str {
418 match *self {
419 DisplayPowerRequest::SetDisplayPower { .. } => "set_display_power",
420 DisplayPowerRequest::_UnknownMethod {
421 method_type: fidl::MethodType::OneWay, ..
422 } => "unknown one-way method",
423 DisplayPowerRequest::_UnknownMethod {
424 method_type: fidl::MethodType::TwoWay, ..
425 } => "unknown two-way method",
426 }
427 }
428}
429
430#[derive(Debug, Clone)]
431pub struct DisplayPowerControlHandle {
432 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
433}
434
435impl fidl::endpoints::ControlHandle for DisplayPowerControlHandle {
436 fn shutdown(&self) {
437 self.inner.shutdown()
438 }
439 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
440 self.inner.shutdown_with_epitaph(status)
441 }
442
443 fn is_closed(&self) -> bool {
444 self.inner.channel().is_closed()
445 }
446 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
447 self.inner.channel().on_closed()
448 }
449
450 #[cfg(target_os = "fuchsia")]
451 fn signal_peer(
452 &self,
453 clear_mask: zx::Signals,
454 set_mask: zx::Signals,
455 ) -> Result<(), zx_status::Status> {
456 use fidl::Peered;
457 self.inner.channel().signal_peer(clear_mask, set_mask)
458 }
459}
460
461impl DisplayPowerControlHandle {}
462
463#[must_use = "FIDL methods require a response to be sent"]
464#[derive(Debug)]
465pub struct DisplayPowerSetDisplayPowerResponder {
466 control_handle: std::mem::ManuallyDrop<DisplayPowerControlHandle>,
467 tx_id: u32,
468}
469
470impl std::ops::Drop for DisplayPowerSetDisplayPowerResponder {
474 fn drop(&mut self) {
475 self.control_handle.shutdown();
476 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
478 }
479}
480
481impl fidl::endpoints::Responder for DisplayPowerSetDisplayPowerResponder {
482 type ControlHandle = DisplayPowerControlHandle;
483
484 fn control_handle(&self) -> &DisplayPowerControlHandle {
485 &self.control_handle
486 }
487
488 fn drop_without_shutdown(mut self) {
489 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
491 std::mem::forget(self);
493 }
494}
495
496impl DisplayPowerSetDisplayPowerResponder {
497 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
501 let _result = self.send_raw(result);
502 if _result.is_err() {
503 self.control_handle.shutdown();
504 }
505 self.drop_without_shutdown();
506 _result
507 }
508
509 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
511 let _result = self.send_raw(result);
512 self.drop_without_shutdown();
513 _result
514 }
515
516 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
517 self.control_handle
518 .inner
519 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
520 result,
521 self.tx_id,
522 0x59f31b10e74ce66f,
523 fidl::encoding::DynamicFlags::empty(),
524 )
525 }
526}
527
528#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
529pub struct InfoMarker;
530
531impl fidl::endpoints::ProtocolMarker for InfoMarker {
532 type Proxy = InfoProxy;
533 type RequestStream = InfoRequestStream;
534 #[cfg(target_os = "fuchsia")]
535 type SynchronousProxy = InfoSynchronousProxy;
536
537 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.Info";
538}
539impl fidl::endpoints::DiscoverableProtocolMarker for InfoMarker {}
540
541pub trait InfoProxyInterface: Send + Sync {
542 type GetMetricsResponseFut: std::future::Future<Output = Result<Metrics, fidl::Error>> + Send;
543 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut;
544}
545#[derive(Debug)]
546#[cfg(target_os = "fuchsia")]
547pub struct InfoSynchronousProxy {
548 client: fidl::client::sync::Client,
549}
550
551#[cfg(target_os = "fuchsia")]
552impl fidl::endpoints::SynchronousProxy for InfoSynchronousProxy {
553 type Proxy = InfoProxy;
554 type Protocol = InfoMarker;
555
556 fn from_channel(inner: fidl::Channel) -> Self {
557 Self::new(inner)
558 }
559
560 fn into_channel(self) -> fidl::Channel {
561 self.client.into_channel()
562 }
563
564 fn as_channel(&self) -> &fidl::Channel {
565 self.client.as_channel()
566 }
567}
568
569#[cfg(target_os = "fuchsia")]
570impl InfoSynchronousProxy {
571 pub fn new(channel: fidl::Channel) -> Self {
572 let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
573 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
574 }
575
576 pub fn into_channel(self) -> fidl::Channel {
577 self.client.into_channel()
578 }
579
580 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<InfoEvent, fidl::Error> {
583 InfoEvent::decode(self.client.wait_for_event(deadline)?)
584 }
585
586 pub fn r#get_metrics(&self, ___deadline: zx::MonotonicInstant) -> Result<Metrics, fidl::Error> {
587 let _response =
588 self.client.send_query::<fidl::encoding::EmptyPayload, InfoGetMetricsResponse>(
589 (),
590 0x6d631353834698be,
591 fidl::encoding::DynamicFlags::empty(),
592 ___deadline,
593 )?;
594 Ok(_response.info)
595 }
596}
597
598#[derive(Debug, Clone)]
599pub struct InfoProxy {
600 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
601}
602
603impl fidl::endpoints::Proxy for InfoProxy {
604 type Protocol = InfoMarker;
605
606 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
607 Self::new(inner)
608 }
609
610 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
611 self.client.into_channel().map_err(|client| Self { client })
612 }
613
614 fn as_channel(&self) -> &::fidl::AsyncChannel {
615 self.client.as_channel()
616 }
617}
618
619impl InfoProxy {
620 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
622 let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
623 Self { client: fidl::client::Client::new(channel, protocol_name) }
624 }
625
626 pub fn take_event_stream(&self) -> InfoEventStream {
632 InfoEventStream { event_receiver: self.client.take_event_receiver() }
633 }
634
635 pub fn r#get_metrics(
636 &self,
637 ) -> fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>
638 {
639 InfoProxyInterface::r#get_metrics(self)
640 }
641}
642
643impl InfoProxyInterface for InfoProxy {
644 type GetMetricsResponseFut =
645 fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>;
646 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut {
647 fn _decode(
648 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
649 ) -> Result<Metrics, fidl::Error> {
650 let _response = fidl::client::decode_transaction_body::<
651 InfoGetMetricsResponse,
652 fidl::encoding::DefaultFuchsiaResourceDialect,
653 0x6d631353834698be,
654 >(_buf?)?;
655 Ok(_response.info)
656 }
657 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Metrics>(
658 (),
659 0x6d631353834698be,
660 fidl::encoding::DynamicFlags::empty(),
661 _decode,
662 )
663 }
664}
665
666pub struct InfoEventStream {
667 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
668}
669
670impl std::marker::Unpin for InfoEventStream {}
671
672impl futures::stream::FusedStream for InfoEventStream {
673 fn is_terminated(&self) -> bool {
674 self.event_receiver.is_terminated()
675 }
676}
677
678impl futures::Stream for InfoEventStream {
679 type Item = Result<InfoEvent, fidl::Error>;
680
681 fn poll_next(
682 mut self: std::pin::Pin<&mut Self>,
683 cx: &mut std::task::Context<'_>,
684 ) -> std::task::Poll<Option<Self::Item>> {
685 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
686 &mut self.event_receiver,
687 cx
688 )?) {
689 Some(buf) => std::task::Poll::Ready(Some(InfoEvent::decode(buf))),
690 None => std::task::Poll::Ready(None),
691 }
692 }
693}
694
695#[derive(Debug)]
696pub enum InfoEvent {}
697
698impl InfoEvent {
699 fn decode(
701 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
702 ) -> Result<InfoEvent, fidl::Error> {
703 let (bytes, _handles) = buf.split_mut();
704 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
705 debug_assert_eq!(tx_header.tx_id, 0);
706 match tx_header.ordinal {
707 _ => Err(fidl::Error::UnknownOrdinal {
708 ordinal: tx_header.ordinal,
709 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
710 }),
711 }
712 }
713}
714
715pub struct InfoRequestStream {
717 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
718 is_terminated: bool,
719}
720
721impl std::marker::Unpin for InfoRequestStream {}
722
723impl futures::stream::FusedStream for InfoRequestStream {
724 fn is_terminated(&self) -> bool {
725 self.is_terminated
726 }
727}
728
729impl fidl::endpoints::RequestStream for InfoRequestStream {
730 type Protocol = InfoMarker;
731 type ControlHandle = InfoControlHandle;
732
733 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
734 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
735 }
736
737 fn control_handle(&self) -> Self::ControlHandle {
738 InfoControlHandle { inner: self.inner.clone() }
739 }
740
741 fn into_inner(
742 self,
743 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
744 {
745 (self.inner, self.is_terminated)
746 }
747
748 fn from_inner(
749 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
750 is_terminated: bool,
751 ) -> Self {
752 Self { inner, is_terminated }
753 }
754}
755
756impl futures::Stream for InfoRequestStream {
757 type Item = Result<InfoRequest, fidl::Error>;
758
759 fn poll_next(
760 mut self: std::pin::Pin<&mut Self>,
761 cx: &mut std::task::Context<'_>,
762 ) -> std::task::Poll<Option<Self::Item>> {
763 let this = &mut *self;
764 if this.inner.check_shutdown(cx) {
765 this.is_terminated = true;
766 return std::task::Poll::Ready(None);
767 }
768 if this.is_terminated {
769 panic!("polled InfoRequestStream after completion");
770 }
771 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
772 |bytes, handles| {
773 match this.inner.channel().read_etc(cx, bytes, handles) {
774 std::task::Poll::Ready(Ok(())) => {}
775 std::task::Poll::Pending => return std::task::Poll::Pending,
776 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
777 this.is_terminated = true;
778 return std::task::Poll::Ready(None);
779 }
780 std::task::Poll::Ready(Err(e)) => {
781 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
782 e.into(),
783 ))))
784 }
785 }
786
787 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
789
790 std::task::Poll::Ready(Some(match header.ordinal {
791 0x6d631353834698be => {
792 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
793 let mut req = fidl::new_empty!(
794 fidl::encoding::EmptyPayload,
795 fidl::encoding::DefaultFuchsiaResourceDialect
796 );
797 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
798 let control_handle = InfoControlHandle { inner: this.inner.clone() };
799 Ok(InfoRequest::GetMetrics {
800 responder: InfoGetMetricsResponder {
801 control_handle: std::mem::ManuallyDrop::new(control_handle),
802 tx_id: header.tx_id,
803 },
804 })
805 }
806 _ => Err(fidl::Error::UnknownOrdinal {
807 ordinal: header.ordinal,
808 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
809 }),
810 }))
811 },
812 )
813 }
814}
815
816#[derive(Debug)]
818pub enum InfoRequest {
819 GetMetrics { responder: InfoGetMetricsResponder },
820}
821
822impl InfoRequest {
823 #[allow(irrefutable_let_patterns)]
824 pub fn into_get_metrics(self) -> Option<(InfoGetMetricsResponder)> {
825 if let InfoRequest::GetMetrics { responder } = self {
826 Some((responder))
827 } else {
828 None
829 }
830 }
831
832 pub fn method_name(&self) -> &'static str {
834 match *self {
835 InfoRequest::GetMetrics { .. } => "get_metrics",
836 }
837 }
838}
839
840#[derive(Debug, Clone)]
841pub struct InfoControlHandle {
842 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
843}
844
845impl fidl::endpoints::ControlHandle for InfoControlHandle {
846 fn shutdown(&self) {
847 self.inner.shutdown()
848 }
849 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
850 self.inner.shutdown_with_epitaph(status)
851 }
852
853 fn is_closed(&self) -> bool {
854 self.inner.channel().is_closed()
855 }
856 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
857 self.inner.channel().on_closed()
858 }
859
860 #[cfg(target_os = "fuchsia")]
861 fn signal_peer(
862 &self,
863 clear_mask: zx::Signals,
864 set_mask: zx::Signals,
865 ) -> Result<(), zx_status::Status> {
866 use fidl::Peered;
867 self.inner.channel().signal_peer(clear_mask, set_mask)
868 }
869}
870
871impl InfoControlHandle {}
872
873#[must_use = "FIDL methods require a response to be sent"]
874#[derive(Debug)]
875pub struct InfoGetMetricsResponder {
876 control_handle: std::mem::ManuallyDrop<InfoControlHandle>,
877 tx_id: u32,
878}
879
880impl std::ops::Drop for InfoGetMetricsResponder {
884 fn drop(&mut self) {
885 self.control_handle.shutdown();
886 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
888 }
889}
890
891impl fidl::endpoints::Responder for InfoGetMetricsResponder {
892 type ControlHandle = InfoControlHandle;
893
894 fn control_handle(&self) -> &InfoControlHandle {
895 &self.control_handle
896 }
897
898 fn drop_without_shutdown(mut self) {
899 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
901 std::mem::forget(self);
903 }
904}
905
906impl InfoGetMetricsResponder {
907 pub fn send(self, mut info: &Metrics) -> Result<(), fidl::Error> {
911 let _result = self.send_raw(info);
912 if _result.is_err() {
913 self.control_handle.shutdown();
914 }
915 self.drop_without_shutdown();
916 _result
917 }
918
919 pub fn send_no_shutdown_on_err(self, mut info: &Metrics) -> Result<(), fidl::Error> {
921 let _result = self.send_raw(info);
922 self.drop_without_shutdown();
923 _result
924 }
925
926 fn send_raw(&self, mut info: &Metrics) -> Result<(), fidl::Error> {
927 self.control_handle.inner.send::<InfoGetMetricsResponse>(
928 (info,),
929 self.tx_id,
930 0x6d631353834698be,
931 fidl::encoding::DynamicFlags::empty(),
932 )
933 }
934}
935
936mod internal {
937 use super::*;
938}