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 Self { client: fidl::client::sync::Client::new(channel) }
74 }
75
76 pub fn into_channel(self) -> fidl::Channel {
77 self.client.into_channel()
78 }
79
80 pub fn wait_for_event(
83 &self,
84 deadline: zx::MonotonicInstant,
85 ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
86 CollaborativeRebootSchedulerEvent::decode(
87 self.client.wait_for_event::<CollaborativeRebootSchedulerMarker>(deadline)?,
88 )
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 CollaborativeRebootSchedulerMarker,
121 >(
122 (reason, cancel,),
123 0x439c89c2c4b101ab,
124 fidl::encoding::DynamicFlags::empty(),
125 ___deadline,
126 )?;
127 Ok(_response)
128 }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl From<CollaborativeRebootSchedulerSynchronousProxy> for zx::NullableHandle {
133 fn from(value: CollaborativeRebootSchedulerSynchronousProxy) -> Self {
134 value.into_channel().into()
135 }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl From<fidl::Channel> for CollaborativeRebootSchedulerSynchronousProxy {
140 fn from(value: fidl::Channel) -> Self {
141 Self::new(value)
142 }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl fidl::endpoints::FromClient for CollaborativeRebootSchedulerSynchronousProxy {
147 type Protocol = CollaborativeRebootSchedulerMarker;
148
149 fn from_client(value: fidl::endpoints::ClientEnd<CollaborativeRebootSchedulerMarker>) -> Self {
150 Self::new(value.into_channel())
151 }
152}
153
154#[derive(Debug, Clone)]
155pub struct CollaborativeRebootSchedulerProxy {
156 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
157}
158
159impl fidl::endpoints::Proxy for CollaborativeRebootSchedulerProxy {
160 type Protocol = CollaborativeRebootSchedulerMarker;
161
162 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
163 Self::new(inner)
164 }
165
166 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
167 self.client.into_channel().map_err(|client| Self { client })
168 }
169
170 fn as_channel(&self) -> &::fidl::AsyncChannel {
171 self.client.as_channel()
172 }
173}
174
175impl CollaborativeRebootSchedulerProxy {
176 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
178 let protocol_name =
179 <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
180 Self { client: fidl::client::Client::new(channel, protocol_name) }
181 }
182
183 pub fn take_event_stream(&self) -> CollaborativeRebootSchedulerEventStream {
189 CollaborativeRebootSchedulerEventStream {
190 event_receiver: self.client.take_event_receiver(),
191 }
192 }
193
194 pub fn r#schedule_reboot(
215 &self,
216 mut reason: CollaborativeRebootReason,
217 mut cancel: Option<fidl::EventPair>,
218 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
219 CollaborativeRebootSchedulerProxyInterface::r#schedule_reboot(self, reason, cancel)
220 }
221}
222
223impl CollaborativeRebootSchedulerProxyInterface for CollaborativeRebootSchedulerProxy {
224 type ScheduleRebootResponseFut =
225 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
226 fn r#schedule_reboot(
227 &self,
228 mut reason: CollaborativeRebootReason,
229 mut cancel: Option<fidl::EventPair>,
230 ) -> Self::ScheduleRebootResponseFut {
231 fn _decode(
232 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
233 ) -> Result<(), fidl::Error> {
234 let _response = fidl::client::decode_transaction_body::<
235 fidl::encoding::EmptyPayload,
236 fidl::encoding::DefaultFuchsiaResourceDialect,
237 0x439c89c2c4b101ab,
238 >(_buf?)?;
239 Ok(_response)
240 }
241 self.client.send_query_and_decode::<CollaborativeRebootSchedulerScheduleRebootRequest, ()>(
242 (reason, cancel),
243 0x439c89c2c4b101ab,
244 fidl::encoding::DynamicFlags::empty(),
245 _decode,
246 )
247 }
248}
249
250pub struct CollaborativeRebootSchedulerEventStream {
251 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
252}
253
254impl std::marker::Unpin for CollaborativeRebootSchedulerEventStream {}
255
256impl futures::stream::FusedStream for CollaborativeRebootSchedulerEventStream {
257 fn is_terminated(&self) -> bool {
258 self.event_receiver.is_terminated()
259 }
260}
261
262impl futures::Stream for CollaborativeRebootSchedulerEventStream {
263 type Item = Result<CollaborativeRebootSchedulerEvent, fidl::Error>;
264
265 fn poll_next(
266 mut self: std::pin::Pin<&mut Self>,
267 cx: &mut std::task::Context<'_>,
268 ) -> std::task::Poll<Option<Self::Item>> {
269 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
270 &mut self.event_receiver,
271 cx
272 )?) {
273 Some(buf) => {
274 std::task::Poll::Ready(Some(CollaborativeRebootSchedulerEvent::decode(buf)))
275 }
276 None => std::task::Poll::Ready(None),
277 }
278 }
279}
280
281#[derive(Debug)]
282pub enum CollaborativeRebootSchedulerEvent {}
283
284impl CollaborativeRebootSchedulerEvent {
285 fn decode(
287 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
288 ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
289 let (bytes, _handles) = buf.split_mut();
290 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
291 debug_assert_eq!(tx_header.tx_id, 0);
292 match tx_header.ordinal {
293 _ => Err(fidl::Error::UnknownOrdinal {
294 ordinal: tx_header.ordinal,
295 protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
296 })
297 }
298 }
299}
300
301pub struct CollaborativeRebootSchedulerRequestStream {
303 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
304 is_terminated: bool,
305}
306
307impl std::marker::Unpin for CollaborativeRebootSchedulerRequestStream {}
308
309impl futures::stream::FusedStream for CollaborativeRebootSchedulerRequestStream {
310 fn is_terminated(&self) -> bool {
311 self.is_terminated
312 }
313}
314
315impl fidl::endpoints::RequestStream for CollaborativeRebootSchedulerRequestStream {
316 type Protocol = CollaborativeRebootSchedulerMarker;
317 type ControlHandle = CollaborativeRebootSchedulerControlHandle;
318
319 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
320 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
321 }
322
323 fn control_handle(&self) -> Self::ControlHandle {
324 CollaborativeRebootSchedulerControlHandle { inner: self.inner.clone() }
325 }
326
327 fn into_inner(
328 self,
329 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
330 {
331 (self.inner, self.is_terminated)
332 }
333
334 fn from_inner(
335 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
336 is_terminated: bool,
337 ) -> Self {
338 Self { inner, is_terminated }
339 }
340}
341
342impl futures::Stream for CollaborativeRebootSchedulerRequestStream {
343 type Item = Result<CollaborativeRebootSchedulerRequest, fidl::Error>;
344
345 fn poll_next(
346 mut self: std::pin::Pin<&mut Self>,
347 cx: &mut std::task::Context<'_>,
348 ) -> std::task::Poll<Option<Self::Item>> {
349 let this = &mut *self;
350 if this.inner.check_shutdown(cx) {
351 this.is_terminated = true;
352 return std::task::Poll::Ready(None);
353 }
354 if this.is_terminated {
355 panic!("polled CollaborativeRebootSchedulerRequestStream after completion");
356 }
357 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
358 |bytes, handles| {
359 match this.inner.channel().read_etc(cx, bytes, handles) {
360 std::task::Poll::Ready(Ok(())) => {}
361 std::task::Poll::Pending => return std::task::Poll::Pending,
362 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
363 this.is_terminated = true;
364 return std::task::Poll::Ready(None);
365 }
366 std::task::Poll::Ready(Err(e)) => {
367 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
368 e.into(),
369 ))));
370 }
371 }
372
373 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
375
376 std::task::Poll::Ready(Some(match header.ordinal {
377 0x439c89c2c4b101ab => {
378 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
379 let mut req = fidl::new_empty!(CollaborativeRebootSchedulerScheduleRebootRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
380 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollaborativeRebootSchedulerScheduleRebootRequest>(&header, _body_bytes, handles, &mut req)?;
381 let control_handle = CollaborativeRebootSchedulerControlHandle {
382 inner: this.inner.clone(),
383 };
384 Ok(CollaborativeRebootSchedulerRequest::ScheduleReboot {reason: req.reason,
385cancel: req.cancel,
386
387 responder: CollaborativeRebootSchedulerScheduleRebootResponder {
388 control_handle: std::mem::ManuallyDrop::new(control_handle),
389 tx_id: header.tx_id,
390 },
391 })
392 }
393 _ => Err(fidl::Error::UnknownOrdinal {
394 ordinal: header.ordinal,
395 protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
396 }),
397 }))
398 },
399 )
400 }
401}
402
403#[derive(Debug)]
424pub enum CollaborativeRebootSchedulerRequest {
425 ScheduleReboot {
446 reason: CollaborativeRebootReason,
447 cancel: Option<fidl::EventPair>,
448 responder: CollaborativeRebootSchedulerScheduleRebootResponder,
449 },
450}
451
452impl CollaborativeRebootSchedulerRequest {
453 #[allow(irrefutable_let_patterns)]
454 pub fn into_schedule_reboot(
455 self,
456 ) -> Option<(
457 CollaborativeRebootReason,
458 Option<fidl::EventPair>,
459 CollaborativeRebootSchedulerScheduleRebootResponder,
460 )> {
461 if let CollaborativeRebootSchedulerRequest::ScheduleReboot { reason, cancel, responder } =
462 self
463 {
464 Some((reason, cancel, responder))
465 } else {
466 None
467 }
468 }
469
470 pub fn method_name(&self) -> &'static str {
472 match *self {
473 CollaborativeRebootSchedulerRequest::ScheduleReboot { .. } => "schedule_reboot",
474 }
475 }
476}
477
478#[derive(Debug, Clone)]
479pub struct CollaborativeRebootSchedulerControlHandle {
480 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481}
482
483impl fidl::endpoints::ControlHandle for CollaborativeRebootSchedulerControlHandle {
484 fn shutdown(&self) {
485 self.inner.shutdown()
486 }
487
488 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
489 self.inner.shutdown_with_epitaph(status)
490 }
491
492 fn is_closed(&self) -> bool {
493 self.inner.channel().is_closed()
494 }
495 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
496 self.inner.channel().on_closed()
497 }
498
499 #[cfg(target_os = "fuchsia")]
500 fn signal_peer(
501 &self,
502 clear_mask: zx::Signals,
503 set_mask: zx::Signals,
504 ) -> Result<(), zx_status::Status> {
505 use fidl::Peered;
506 self.inner.channel().signal_peer(clear_mask, set_mask)
507 }
508}
509
510impl CollaborativeRebootSchedulerControlHandle {}
511
512#[must_use = "FIDL methods require a response to be sent"]
513#[derive(Debug)]
514pub struct CollaborativeRebootSchedulerScheduleRebootResponder {
515 control_handle: std::mem::ManuallyDrop<CollaborativeRebootSchedulerControlHandle>,
516 tx_id: u32,
517}
518
519impl std::ops::Drop for CollaborativeRebootSchedulerScheduleRebootResponder {
523 fn drop(&mut self) {
524 self.control_handle.shutdown();
525 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
527 }
528}
529
530impl fidl::endpoints::Responder for CollaborativeRebootSchedulerScheduleRebootResponder {
531 type ControlHandle = CollaborativeRebootSchedulerControlHandle;
532
533 fn control_handle(&self) -> &CollaborativeRebootSchedulerControlHandle {
534 &self.control_handle
535 }
536
537 fn drop_without_shutdown(mut self) {
538 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
540 std::mem::forget(self);
542 }
543}
544
545impl CollaborativeRebootSchedulerScheduleRebootResponder {
546 pub fn send(self) -> Result<(), fidl::Error> {
550 let _result = self.send_raw();
551 if _result.is_err() {
552 self.control_handle.shutdown();
553 }
554 self.drop_without_shutdown();
555 _result
556 }
557
558 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
560 let _result = self.send_raw();
561 self.drop_without_shutdown();
562 _result
563 }
564
565 fn send_raw(&self) -> Result<(), fidl::Error> {
566 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
567 (),
568 self.tx_id,
569 0x439c89c2c4b101ab,
570 fidl::encoding::DynamicFlags::empty(),
571 )
572 }
573}
574
575mod internal {
576 use super::*;
577
578 impl fidl::encoding::ResourceTypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
579 type Borrowed<'a> = &'a mut Self;
580 fn take_or_borrow<'a>(
581 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
582 ) -> Self::Borrowed<'a> {
583 value
584 }
585 }
586
587 unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
588 type Owned = Self;
589
590 #[inline(always)]
591 fn inline_align(_context: fidl::encoding::Context) -> usize {
592 4
593 }
594
595 #[inline(always)]
596 fn inline_size(_context: fidl::encoding::Context) -> usize {
597 8
598 }
599 }
600
601 unsafe impl
602 fidl::encoding::Encode<
603 CollaborativeRebootSchedulerScheduleRebootRequest,
604 fidl::encoding::DefaultFuchsiaResourceDialect,
605 > for &mut CollaborativeRebootSchedulerScheduleRebootRequest
606 {
607 #[inline]
608 unsafe fn encode(
609 self,
610 encoder: &mut fidl::encoding::Encoder<
611 '_,
612 fidl::encoding::DefaultFuchsiaResourceDialect,
613 >,
614 offset: usize,
615 _depth: fidl::encoding::Depth,
616 ) -> fidl::Result<()> {
617 encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
618 fidl::encoding::Encode::<
620 CollaborativeRebootSchedulerScheduleRebootRequest,
621 fidl::encoding::DefaultFuchsiaResourceDialect,
622 >::encode(
623 (
624 <CollaborativeRebootReason as fidl::encoding::ValueTypeMarker>::borrow(
625 &self.reason,
626 ),
627 <fidl::encoding::Optional<
628 fidl::encoding::HandleType<
629 fidl::EventPair,
630 { fidl::ObjectType::EVENTPAIR.into_raw() },
631 16384,
632 >,
633 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
634 &mut self.cancel
635 ),
636 ),
637 encoder,
638 offset,
639 _depth,
640 )
641 }
642 }
643 unsafe impl<
644 T0: fidl::encoding::Encode<
645 CollaborativeRebootReason,
646 fidl::encoding::DefaultFuchsiaResourceDialect,
647 >,
648 T1: fidl::encoding::Encode<
649 fidl::encoding::Optional<
650 fidl::encoding::HandleType<
651 fidl::EventPair,
652 { fidl::ObjectType::EVENTPAIR.into_raw() },
653 16384,
654 >,
655 >,
656 fidl::encoding::DefaultFuchsiaResourceDialect,
657 >,
658 >
659 fidl::encoding::Encode<
660 CollaborativeRebootSchedulerScheduleRebootRequest,
661 fidl::encoding::DefaultFuchsiaResourceDialect,
662 > for (T0, T1)
663 {
664 #[inline]
665 unsafe fn encode(
666 self,
667 encoder: &mut fidl::encoding::Encoder<
668 '_,
669 fidl::encoding::DefaultFuchsiaResourceDialect,
670 >,
671 offset: usize,
672 depth: fidl::encoding::Depth,
673 ) -> fidl::Result<()> {
674 encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
675 self.0.encode(encoder, offset + 0, depth)?;
679 self.1.encode(encoder, offset + 4, depth)?;
680 Ok(())
681 }
682 }
683
684 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
685 for CollaborativeRebootSchedulerScheduleRebootRequest
686 {
687 #[inline(always)]
688 fn new_empty() -> Self {
689 Self {
690 reason: fidl::new_empty!(
691 CollaborativeRebootReason,
692 fidl::encoding::DefaultFuchsiaResourceDialect
693 ),
694 cancel: fidl::new_empty!(
695 fidl::encoding::Optional<
696 fidl::encoding::HandleType<
697 fidl::EventPair,
698 { fidl::ObjectType::EVENTPAIR.into_raw() },
699 16384,
700 >,
701 >,
702 fidl::encoding::DefaultFuchsiaResourceDialect
703 ),
704 }
705 }
706
707 #[inline]
708 unsafe fn decode(
709 &mut self,
710 decoder: &mut fidl::encoding::Decoder<
711 '_,
712 fidl::encoding::DefaultFuchsiaResourceDialect,
713 >,
714 offset: usize,
715 _depth: fidl::encoding::Depth,
716 ) -> fidl::Result<()> {
717 decoder.debug_check_bounds::<Self>(offset);
718 fidl::decode!(
720 CollaborativeRebootReason,
721 fidl::encoding::DefaultFuchsiaResourceDialect,
722 &mut self.reason,
723 decoder,
724 offset + 0,
725 _depth
726 )?;
727 fidl::decode!(
728 fidl::encoding::Optional<
729 fidl::encoding::HandleType<
730 fidl::EventPair,
731 { fidl::ObjectType::EVENTPAIR.into_raw() },
732 16384,
733 >,
734 >,
735 fidl::encoding::DefaultFuchsiaResourceDialect,
736 &mut self.cancel,
737 decoder,
738 offset + 4,
739 _depth
740 )?;
741 Ok(())
742 }
743 }
744}