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_power_internal_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CollaborativeRebootSchedulerScheduleRebootRequest {
16 pub reason: CollaborativeRebootReason,
17 pub cancel: Option<fidl::EventPair>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for CollaborativeRebootSchedulerScheduleRebootRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct CollaborativeRebootSchedulerMarker;
27
28impl fidl::endpoints::ProtocolMarker for CollaborativeRebootSchedulerMarker {
29 type Proxy = CollaborativeRebootSchedulerProxy;
30 type RequestStream = CollaborativeRebootSchedulerRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = CollaborativeRebootSchedulerSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "fuchsia.power.internal.CollaborativeRebootScheduler";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for CollaborativeRebootSchedulerMarker {}
37
38pub trait CollaborativeRebootSchedulerProxyInterface: Send + Sync {
39 type ScheduleRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
40 fn r#schedule_reboot(
41 &self,
42 reason: CollaborativeRebootReason,
43 cancel: Option<fidl::EventPair>,
44 ) -> Self::ScheduleRebootResponseFut;
45}
46#[derive(Debug)]
47#[cfg(target_os = "fuchsia")]
48pub struct CollaborativeRebootSchedulerSynchronousProxy {
49 client: fidl::client::sync::Client,
50}
51
52#[cfg(target_os = "fuchsia")]
53impl fidl::endpoints::SynchronousProxy for CollaborativeRebootSchedulerSynchronousProxy {
54 type Proxy = CollaborativeRebootSchedulerProxy;
55 type Protocol = CollaborativeRebootSchedulerMarker;
56
57 fn from_channel(inner: fidl::Channel) -> Self {
58 Self::new(inner)
59 }
60
61 fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 fn as_channel(&self) -> &fidl::Channel {
66 self.client.as_channel()
67 }
68}
69
70#[cfg(target_os = "fuchsia")]
71impl CollaborativeRebootSchedulerSynchronousProxy {
72 pub fn new(channel: fidl::Channel) -> Self {
73 let protocol_name =
74 <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76 }
77
78 pub fn into_channel(self) -> fidl::Channel {
79 self.client.into_channel()
80 }
81
82 pub fn wait_for_event(
85 &self,
86 deadline: zx::MonotonicInstant,
87 ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
88 CollaborativeRebootSchedulerEvent::decode(self.client.wait_for_event(deadline)?)
89 }
90
91 pub fn r#schedule_reboot(
112 &self,
113 mut reason: CollaborativeRebootReason,
114 mut cancel: Option<fidl::EventPair>,
115 ___deadline: zx::MonotonicInstant,
116 ) -> Result<(), fidl::Error> {
117 let _response = self.client.send_query::<
118 CollaborativeRebootSchedulerScheduleRebootRequest,
119 fidl::encoding::EmptyPayload,
120 >(
121 (reason, cancel,),
122 0x439c89c2c4b101ab,
123 fidl::encoding::DynamicFlags::empty(),
124 ___deadline,
125 )?;
126 Ok(_response)
127 }
128}
129
130#[derive(Debug, Clone)]
131pub struct CollaborativeRebootSchedulerProxy {
132 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
133}
134
135impl fidl::endpoints::Proxy for CollaborativeRebootSchedulerProxy {
136 type Protocol = CollaborativeRebootSchedulerMarker;
137
138 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
139 Self::new(inner)
140 }
141
142 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
143 self.client.into_channel().map_err(|client| Self { client })
144 }
145
146 fn as_channel(&self) -> &::fidl::AsyncChannel {
147 self.client.as_channel()
148 }
149}
150
151impl CollaborativeRebootSchedulerProxy {
152 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
154 let protocol_name =
155 <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156 Self { client: fidl::client::Client::new(channel, protocol_name) }
157 }
158
159 pub fn take_event_stream(&self) -> CollaborativeRebootSchedulerEventStream {
165 CollaborativeRebootSchedulerEventStream {
166 event_receiver: self.client.take_event_receiver(),
167 }
168 }
169
170 pub fn r#schedule_reboot(
191 &self,
192 mut reason: CollaborativeRebootReason,
193 mut cancel: Option<fidl::EventPair>,
194 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
195 CollaborativeRebootSchedulerProxyInterface::r#schedule_reboot(self, reason, cancel)
196 }
197}
198
199impl CollaborativeRebootSchedulerProxyInterface for CollaborativeRebootSchedulerProxy {
200 type ScheduleRebootResponseFut =
201 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
202 fn r#schedule_reboot(
203 &self,
204 mut reason: CollaborativeRebootReason,
205 mut cancel: Option<fidl::EventPair>,
206 ) -> Self::ScheduleRebootResponseFut {
207 fn _decode(
208 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
209 ) -> Result<(), fidl::Error> {
210 let _response = fidl::client::decode_transaction_body::<
211 fidl::encoding::EmptyPayload,
212 fidl::encoding::DefaultFuchsiaResourceDialect,
213 0x439c89c2c4b101ab,
214 >(_buf?)?;
215 Ok(_response)
216 }
217 self.client.send_query_and_decode::<CollaborativeRebootSchedulerScheduleRebootRequest, ()>(
218 (reason, cancel),
219 0x439c89c2c4b101ab,
220 fidl::encoding::DynamicFlags::empty(),
221 _decode,
222 )
223 }
224}
225
226pub struct CollaborativeRebootSchedulerEventStream {
227 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
228}
229
230impl std::marker::Unpin for CollaborativeRebootSchedulerEventStream {}
231
232impl futures::stream::FusedStream for CollaborativeRebootSchedulerEventStream {
233 fn is_terminated(&self) -> bool {
234 self.event_receiver.is_terminated()
235 }
236}
237
238impl futures::Stream for CollaborativeRebootSchedulerEventStream {
239 type Item = Result<CollaborativeRebootSchedulerEvent, fidl::Error>;
240
241 fn poll_next(
242 mut self: std::pin::Pin<&mut Self>,
243 cx: &mut std::task::Context<'_>,
244 ) -> std::task::Poll<Option<Self::Item>> {
245 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
246 &mut self.event_receiver,
247 cx
248 )?) {
249 Some(buf) => {
250 std::task::Poll::Ready(Some(CollaborativeRebootSchedulerEvent::decode(buf)))
251 }
252 None => std::task::Poll::Ready(None),
253 }
254 }
255}
256
257#[derive(Debug)]
258pub enum CollaborativeRebootSchedulerEvent {}
259
260impl CollaborativeRebootSchedulerEvent {
261 fn decode(
263 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
264 ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
265 let (bytes, _handles) = buf.split_mut();
266 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
267 debug_assert_eq!(tx_header.tx_id, 0);
268 match tx_header.ordinal {
269 _ => Err(fidl::Error::UnknownOrdinal {
270 ordinal: tx_header.ordinal,
271 protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
272 })
273 }
274 }
275}
276
277pub struct CollaborativeRebootSchedulerRequestStream {
279 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
280 is_terminated: bool,
281}
282
283impl std::marker::Unpin for CollaborativeRebootSchedulerRequestStream {}
284
285impl futures::stream::FusedStream for CollaborativeRebootSchedulerRequestStream {
286 fn is_terminated(&self) -> bool {
287 self.is_terminated
288 }
289}
290
291impl fidl::endpoints::RequestStream for CollaborativeRebootSchedulerRequestStream {
292 type Protocol = CollaborativeRebootSchedulerMarker;
293 type ControlHandle = CollaborativeRebootSchedulerControlHandle;
294
295 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
296 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
297 }
298
299 fn control_handle(&self) -> Self::ControlHandle {
300 CollaborativeRebootSchedulerControlHandle { inner: self.inner.clone() }
301 }
302
303 fn into_inner(
304 self,
305 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
306 {
307 (self.inner, self.is_terminated)
308 }
309
310 fn from_inner(
311 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
312 is_terminated: bool,
313 ) -> Self {
314 Self { inner, is_terminated }
315 }
316}
317
318impl futures::Stream for CollaborativeRebootSchedulerRequestStream {
319 type Item = Result<CollaborativeRebootSchedulerRequest, fidl::Error>;
320
321 fn poll_next(
322 mut self: std::pin::Pin<&mut Self>,
323 cx: &mut std::task::Context<'_>,
324 ) -> std::task::Poll<Option<Self::Item>> {
325 let this = &mut *self;
326 if this.inner.check_shutdown(cx) {
327 this.is_terminated = true;
328 return std::task::Poll::Ready(None);
329 }
330 if this.is_terminated {
331 panic!("polled CollaborativeRebootSchedulerRequestStream after completion");
332 }
333 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
334 |bytes, handles| {
335 match this.inner.channel().read_etc(cx, bytes, handles) {
336 std::task::Poll::Ready(Ok(())) => {}
337 std::task::Poll::Pending => return std::task::Poll::Pending,
338 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
339 this.is_terminated = true;
340 return std::task::Poll::Ready(None);
341 }
342 std::task::Poll::Ready(Err(e)) => {
343 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
344 e.into(),
345 ))))
346 }
347 }
348
349 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
351
352 std::task::Poll::Ready(Some(match header.ordinal {
353 0x439c89c2c4b101ab => {
354 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
355 let mut req = fidl::new_empty!(CollaborativeRebootSchedulerScheduleRebootRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
356 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollaborativeRebootSchedulerScheduleRebootRequest>(&header, _body_bytes, handles, &mut req)?;
357 let control_handle = CollaborativeRebootSchedulerControlHandle {
358 inner: this.inner.clone(),
359 };
360 Ok(CollaborativeRebootSchedulerRequest::ScheduleReboot {reason: req.reason,
361cancel: req.cancel,
362
363 responder: CollaborativeRebootSchedulerScheduleRebootResponder {
364 control_handle: std::mem::ManuallyDrop::new(control_handle),
365 tx_id: header.tx_id,
366 },
367 })
368 }
369 _ => Err(fidl::Error::UnknownOrdinal {
370 ordinal: header.ordinal,
371 protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
372 }),
373 }))
374 },
375 )
376 }
377}
378
379#[derive(Debug)]
400pub enum CollaborativeRebootSchedulerRequest {
401 ScheduleReboot {
422 reason: CollaborativeRebootReason,
423 cancel: Option<fidl::EventPair>,
424 responder: CollaborativeRebootSchedulerScheduleRebootResponder,
425 },
426}
427
428impl CollaborativeRebootSchedulerRequest {
429 #[allow(irrefutable_let_patterns)]
430 pub fn into_schedule_reboot(
431 self,
432 ) -> Option<(
433 CollaborativeRebootReason,
434 Option<fidl::EventPair>,
435 CollaborativeRebootSchedulerScheduleRebootResponder,
436 )> {
437 if let CollaborativeRebootSchedulerRequest::ScheduleReboot { reason, cancel, responder } =
438 self
439 {
440 Some((reason, cancel, responder))
441 } else {
442 None
443 }
444 }
445
446 pub fn method_name(&self) -> &'static str {
448 match *self {
449 CollaborativeRebootSchedulerRequest::ScheduleReboot { .. } => "schedule_reboot",
450 }
451 }
452}
453
454#[derive(Debug, Clone)]
455pub struct CollaborativeRebootSchedulerControlHandle {
456 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
457}
458
459impl fidl::endpoints::ControlHandle for CollaborativeRebootSchedulerControlHandle {
460 fn shutdown(&self) {
461 self.inner.shutdown()
462 }
463 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
464 self.inner.shutdown_with_epitaph(status)
465 }
466
467 fn is_closed(&self) -> bool {
468 self.inner.channel().is_closed()
469 }
470 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
471 self.inner.channel().on_closed()
472 }
473
474 #[cfg(target_os = "fuchsia")]
475 fn signal_peer(
476 &self,
477 clear_mask: zx::Signals,
478 set_mask: zx::Signals,
479 ) -> Result<(), zx_status::Status> {
480 use fidl::Peered;
481 self.inner.channel().signal_peer(clear_mask, set_mask)
482 }
483}
484
485impl CollaborativeRebootSchedulerControlHandle {}
486
487#[must_use = "FIDL methods require a response to be sent"]
488#[derive(Debug)]
489pub struct CollaborativeRebootSchedulerScheduleRebootResponder {
490 control_handle: std::mem::ManuallyDrop<CollaborativeRebootSchedulerControlHandle>,
491 tx_id: u32,
492}
493
494impl std::ops::Drop for CollaborativeRebootSchedulerScheduleRebootResponder {
498 fn drop(&mut self) {
499 self.control_handle.shutdown();
500 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
502 }
503}
504
505impl fidl::endpoints::Responder for CollaborativeRebootSchedulerScheduleRebootResponder {
506 type ControlHandle = CollaborativeRebootSchedulerControlHandle;
507
508 fn control_handle(&self) -> &CollaborativeRebootSchedulerControlHandle {
509 &self.control_handle
510 }
511
512 fn drop_without_shutdown(mut self) {
513 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
515 std::mem::forget(self);
517 }
518}
519
520impl CollaborativeRebootSchedulerScheduleRebootResponder {
521 pub fn send(self) -> Result<(), fidl::Error> {
525 let _result = self.send_raw();
526 if _result.is_err() {
527 self.control_handle.shutdown();
528 }
529 self.drop_without_shutdown();
530 _result
531 }
532
533 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
535 let _result = self.send_raw();
536 self.drop_without_shutdown();
537 _result
538 }
539
540 fn send_raw(&self) -> Result<(), fidl::Error> {
541 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
542 (),
543 self.tx_id,
544 0x439c89c2c4b101ab,
545 fidl::encoding::DynamicFlags::empty(),
546 )
547 }
548}
549
550mod internal {
551 use super::*;
552
553 impl fidl::encoding::ResourceTypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
554 type Borrowed<'a> = &'a mut Self;
555 fn take_or_borrow<'a>(
556 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
557 ) -> Self::Borrowed<'a> {
558 value
559 }
560 }
561
562 unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
563 type Owned = Self;
564
565 #[inline(always)]
566 fn inline_align(_context: fidl::encoding::Context) -> usize {
567 4
568 }
569
570 #[inline(always)]
571 fn inline_size(_context: fidl::encoding::Context) -> usize {
572 8
573 }
574 }
575
576 unsafe impl
577 fidl::encoding::Encode<
578 CollaborativeRebootSchedulerScheduleRebootRequest,
579 fidl::encoding::DefaultFuchsiaResourceDialect,
580 > for &mut CollaborativeRebootSchedulerScheduleRebootRequest
581 {
582 #[inline]
583 unsafe fn encode(
584 self,
585 encoder: &mut fidl::encoding::Encoder<
586 '_,
587 fidl::encoding::DefaultFuchsiaResourceDialect,
588 >,
589 offset: usize,
590 _depth: fidl::encoding::Depth,
591 ) -> fidl::Result<()> {
592 encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
593 fidl::encoding::Encode::<
595 CollaborativeRebootSchedulerScheduleRebootRequest,
596 fidl::encoding::DefaultFuchsiaResourceDialect,
597 >::encode(
598 (
599 <CollaborativeRebootReason as fidl::encoding::ValueTypeMarker>::borrow(
600 &self.reason,
601 ),
602 <fidl::encoding::Optional<
603 fidl::encoding::HandleType<
604 fidl::EventPair,
605 { fidl::ObjectType::EVENTPAIR.into_raw() },
606 16384,
607 >,
608 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
609 &mut self.cancel
610 ),
611 ),
612 encoder,
613 offset,
614 _depth,
615 )
616 }
617 }
618 unsafe impl<
619 T0: fidl::encoding::Encode<
620 CollaborativeRebootReason,
621 fidl::encoding::DefaultFuchsiaResourceDialect,
622 >,
623 T1: fidl::encoding::Encode<
624 fidl::encoding::Optional<
625 fidl::encoding::HandleType<
626 fidl::EventPair,
627 { fidl::ObjectType::EVENTPAIR.into_raw() },
628 16384,
629 >,
630 >,
631 fidl::encoding::DefaultFuchsiaResourceDialect,
632 >,
633 >
634 fidl::encoding::Encode<
635 CollaborativeRebootSchedulerScheduleRebootRequest,
636 fidl::encoding::DefaultFuchsiaResourceDialect,
637 > for (T0, T1)
638 {
639 #[inline]
640 unsafe fn encode(
641 self,
642 encoder: &mut fidl::encoding::Encoder<
643 '_,
644 fidl::encoding::DefaultFuchsiaResourceDialect,
645 >,
646 offset: usize,
647 depth: fidl::encoding::Depth,
648 ) -> fidl::Result<()> {
649 encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
650 self.0.encode(encoder, offset + 0, depth)?;
654 self.1.encode(encoder, offset + 4, depth)?;
655 Ok(())
656 }
657 }
658
659 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
660 for CollaborativeRebootSchedulerScheduleRebootRequest
661 {
662 #[inline(always)]
663 fn new_empty() -> Self {
664 Self {
665 reason: fidl::new_empty!(
666 CollaborativeRebootReason,
667 fidl::encoding::DefaultFuchsiaResourceDialect
668 ),
669 cancel: fidl::new_empty!(
670 fidl::encoding::Optional<
671 fidl::encoding::HandleType<
672 fidl::EventPair,
673 { fidl::ObjectType::EVENTPAIR.into_raw() },
674 16384,
675 >,
676 >,
677 fidl::encoding::DefaultFuchsiaResourceDialect
678 ),
679 }
680 }
681
682 #[inline]
683 unsafe fn decode(
684 &mut self,
685 decoder: &mut fidl::encoding::Decoder<
686 '_,
687 fidl::encoding::DefaultFuchsiaResourceDialect,
688 >,
689 offset: usize,
690 _depth: fidl::encoding::Depth,
691 ) -> fidl::Result<()> {
692 decoder.debug_check_bounds::<Self>(offset);
693 fidl::decode!(
695 CollaborativeRebootReason,
696 fidl::encoding::DefaultFuchsiaResourceDialect,
697 &mut self.reason,
698 decoder,
699 offset + 0,
700 _depth
701 )?;
702 fidl::decode!(
703 fidl::encoding::Optional<
704 fidl::encoding::HandleType<
705 fidl::EventPair,
706 { fidl::ObjectType::EVENTPAIR.into_raw() },
707 16384,
708 >,
709 >,
710 fidl::encoding::DefaultFuchsiaResourceDialect,
711 &mut self.cancel,
712 decoder,
713 offset + 4,
714 _depth
715 )?;
716 Ok(())
717 }
718 }
719}