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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum SetSystemActivityGovernorStateError {
17 NotSupported = 1,
20 Internal = 2,
22}
23
24impl SetSystemActivityGovernorStateError {
25 #[inline]
26 pub fn from_primitive(prim: u32) -> Option<Self> {
27 match prim {
28 1 => Some(Self::NotSupported),
29 2 => Some(Self::Internal),
30 _ => None,
31 }
32 }
33
34 #[inline]
35 pub const fn into_primitive(self) -> u32 {
36 self as u32
37 }
38
39 #[deprecated = "Strict enums should not use `is_unknown`"]
40 #[inline]
41 pub fn is_unknown(&self) -> bool {
42 false
43 }
44}
45
46#[derive(Clone, Debug, Default, PartialEq)]
47pub struct SystemActivityGovernorState {
48 pub execution_state_level: Option<fidl_fuchsia_power_system::ExecutionStateLevel>,
49 pub application_activity_level: Option<fidl_fuchsia_power_system::ApplicationActivityLevel>,
50 #[doc(hidden)]
51 pub __source_breaking: fidl::marker::SourceBreaking,
52}
53
54impl fidl::Persistable for SystemActivityGovernorState {}
55
56#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
57pub struct StateMarker;
58
59impl fidl::endpoints::ProtocolMarker for StateMarker {
60 type Proxy = StateProxy;
61 type RequestStream = StateRequestStream;
62 #[cfg(target_os = "fuchsia")]
63 type SynchronousProxy = StateSynchronousProxy;
64
65 const DEBUG_NAME: &'static str = "test.sagcontrol.State";
66}
67impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
68pub type StateSetResult = Result<(), SetSystemActivityGovernorStateError>;
69
70pub trait StateProxyInterface: Send + Sync {
71 type SetResponseFut: std::future::Future<Output = Result<StateSetResult, fidl::Error>> + Send;
72 fn r#set(&self, payload: &SystemActivityGovernorState) -> Self::SetResponseFut;
73 type GetResponseFut: std::future::Future<Output = Result<SystemActivityGovernorState, fidl::Error>>
74 + Send;
75 fn r#get(&self) -> Self::GetResponseFut;
76 type SetBootCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
77 fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut;
78 type WatchResponseFut: std::future::Future<Output = Result<SystemActivityGovernorState, fidl::Error>>
79 + Send;
80 fn r#watch(&self) -> Self::WatchResponseFut;
81}
82#[derive(Debug)]
83#[cfg(target_os = "fuchsia")]
84pub struct StateSynchronousProxy {
85 client: fidl::client::sync::Client,
86}
87
88#[cfg(target_os = "fuchsia")]
89impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
90 type Proxy = StateProxy;
91 type Protocol = StateMarker;
92
93 fn from_channel(inner: fidl::Channel) -> Self {
94 Self::new(inner)
95 }
96
97 fn into_channel(self) -> fidl::Channel {
98 self.client.into_channel()
99 }
100
101 fn as_channel(&self) -> &fidl::Channel {
102 self.client.as_channel()
103 }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl StateSynchronousProxy {
108 pub fn new(channel: fidl::Channel) -> Self {
109 let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
110 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
111 }
112
113 pub fn into_channel(self) -> fidl::Channel {
114 self.client.into_channel()
115 }
116
117 pub fn wait_for_event(
120 &self,
121 deadline: zx::MonotonicInstant,
122 ) -> Result<StateEvent, fidl::Error> {
123 StateEvent::decode(self.client.wait_for_event(deadline)?)
124 }
125
126 pub fn r#set(
133 &self,
134 mut payload: &SystemActivityGovernorState,
135 ___deadline: zx::MonotonicInstant,
136 ) -> Result<StateSetResult, fidl::Error> {
137 let _response = self
138 .client
139 .send_query::<SystemActivityGovernorState, fidl::encoding::ResultType<
140 fidl::encoding::EmptyStruct,
141 SetSystemActivityGovernorStateError,
142 >>(
143 payload, 0x212842d46b8459f8, fidl::encoding::DynamicFlags::empty(), ___deadline
144 )?;
145 Ok(_response.map(|x| x))
146 }
147
148 pub fn r#get(
150 &self,
151 ___deadline: zx::MonotonicInstant,
152 ) -> Result<SystemActivityGovernorState, fidl::Error> {
153 let _response =
154 self.client.send_query::<fidl::encoding::EmptyPayload, SystemActivityGovernorState>(
155 (),
156 0x65b19621b5644fdb,
157 fidl::encoding::DynamicFlags::empty(),
158 ___deadline,
159 )?;
160 Ok(_response)
161 }
162
163 pub fn r#set_boot_complete(
165 &self,
166 ___deadline: zx::MonotonicInstant,
167 ) -> Result<(), fidl::Error> {
168 let _response =
169 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
170 (),
171 0x7dded2028ad39365,
172 fidl::encoding::DynamicFlags::empty(),
173 ___deadline,
174 )?;
175 Ok(_response)
176 }
177
178 pub fn r#watch(
192 &self,
193 ___deadline: zx::MonotonicInstant,
194 ) -> Result<SystemActivityGovernorState, fidl::Error> {
195 let _response =
196 self.client.send_query::<fidl::encoding::EmptyPayload, SystemActivityGovernorState>(
197 (),
198 0x434b0aa4bbac7965,
199 fidl::encoding::DynamicFlags::empty(),
200 ___deadline,
201 )?;
202 Ok(_response)
203 }
204}
205
206#[derive(Debug, Clone)]
207pub struct StateProxy {
208 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
209}
210
211impl fidl::endpoints::Proxy for StateProxy {
212 type Protocol = StateMarker;
213
214 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
215 Self::new(inner)
216 }
217
218 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
219 self.client.into_channel().map_err(|client| Self { client })
220 }
221
222 fn as_channel(&self) -> &::fidl::AsyncChannel {
223 self.client.as_channel()
224 }
225}
226
227impl StateProxy {
228 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
230 let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
231 Self { client: fidl::client::Client::new(channel, protocol_name) }
232 }
233
234 pub fn take_event_stream(&self) -> StateEventStream {
240 StateEventStream { event_receiver: self.client.take_event_receiver() }
241 }
242
243 pub fn r#set(
250 &self,
251 mut payload: &SystemActivityGovernorState,
252 ) -> fidl::client::QueryResponseFut<StateSetResult, fidl::encoding::DefaultFuchsiaResourceDialect>
253 {
254 StateProxyInterface::r#set(self, payload)
255 }
256
257 pub fn r#get(
259 &self,
260 ) -> fidl::client::QueryResponseFut<
261 SystemActivityGovernorState,
262 fidl::encoding::DefaultFuchsiaResourceDialect,
263 > {
264 StateProxyInterface::r#get(self)
265 }
266
267 pub fn r#set_boot_complete(
269 &self,
270 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
271 StateProxyInterface::r#set_boot_complete(self)
272 }
273
274 pub fn r#watch(
288 &self,
289 ) -> fidl::client::QueryResponseFut<
290 SystemActivityGovernorState,
291 fidl::encoding::DefaultFuchsiaResourceDialect,
292 > {
293 StateProxyInterface::r#watch(self)
294 }
295}
296
297impl StateProxyInterface for StateProxy {
298 type SetResponseFut = fidl::client::QueryResponseFut<
299 StateSetResult,
300 fidl::encoding::DefaultFuchsiaResourceDialect,
301 >;
302 fn r#set(&self, mut payload: &SystemActivityGovernorState) -> Self::SetResponseFut {
303 fn _decode(
304 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
305 ) -> Result<StateSetResult, fidl::Error> {
306 let _response = fidl::client::decode_transaction_body::<
307 fidl::encoding::ResultType<
308 fidl::encoding::EmptyStruct,
309 SetSystemActivityGovernorStateError,
310 >,
311 fidl::encoding::DefaultFuchsiaResourceDialect,
312 0x212842d46b8459f8,
313 >(_buf?)?;
314 Ok(_response.map(|x| x))
315 }
316 self.client.send_query_and_decode::<SystemActivityGovernorState, StateSetResult>(
317 payload,
318 0x212842d46b8459f8,
319 fidl::encoding::DynamicFlags::empty(),
320 _decode,
321 )
322 }
323
324 type GetResponseFut = fidl::client::QueryResponseFut<
325 SystemActivityGovernorState,
326 fidl::encoding::DefaultFuchsiaResourceDialect,
327 >;
328 fn r#get(&self) -> Self::GetResponseFut {
329 fn _decode(
330 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
331 ) -> Result<SystemActivityGovernorState, fidl::Error> {
332 let _response = fidl::client::decode_transaction_body::<
333 SystemActivityGovernorState,
334 fidl::encoding::DefaultFuchsiaResourceDialect,
335 0x65b19621b5644fdb,
336 >(_buf?)?;
337 Ok(_response)
338 }
339 self.client
340 .send_query_and_decode::<fidl::encoding::EmptyPayload, SystemActivityGovernorState>(
341 (),
342 0x65b19621b5644fdb,
343 fidl::encoding::DynamicFlags::empty(),
344 _decode,
345 )
346 }
347
348 type SetBootCompleteResponseFut =
349 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
350 fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut {
351 fn _decode(
352 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
353 ) -> Result<(), fidl::Error> {
354 let _response = fidl::client::decode_transaction_body::<
355 fidl::encoding::EmptyPayload,
356 fidl::encoding::DefaultFuchsiaResourceDialect,
357 0x7dded2028ad39365,
358 >(_buf?)?;
359 Ok(_response)
360 }
361 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
362 (),
363 0x7dded2028ad39365,
364 fidl::encoding::DynamicFlags::empty(),
365 _decode,
366 )
367 }
368
369 type WatchResponseFut = fidl::client::QueryResponseFut<
370 SystemActivityGovernorState,
371 fidl::encoding::DefaultFuchsiaResourceDialect,
372 >;
373 fn r#watch(&self) -> Self::WatchResponseFut {
374 fn _decode(
375 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376 ) -> Result<SystemActivityGovernorState, fidl::Error> {
377 let _response = fidl::client::decode_transaction_body::<
378 SystemActivityGovernorState,
379 fidl::encoding::DefaultFuchsiaResourceDialect,
380 0x434b0aa4bbac7965,
381 >(_buf?)?;
382 Ok(_response)
383 }
384 self.client
385 .send_query_and_decode::<fidl::encoding::EmptyPayload, SystemActivityGovernorState>(
386 (),
387 0x434b0aa4bbac7965,
388 fidl::encoding::DynamicFlags::empty(),
389 _decode,
390 )
391 }
392}
393
394pub struct StateEventStream {
395 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
396}
397
398impl std::marker::Unpin for StateEventStream {}
399
400impl futures::stream::FusedStream for StateEventStream {
401 fn is_terminated(&self) -> bool {
402 self.event_receiver.is_terminated()
403 }
404}
405
406impl futures::Stream for StateEventStream {
407 type Item = Result<StateEvent, fidl::Error>;
408
409 fn poll_next(
410 mut self: std::pin::Pin<&mut Self>,
411 cx: &mut std::task::Context<'_>,
412 ) -> std::task::Poll<Option<Self::Item>> {
413 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
414 &mut self.event_receiver,
415 cx
416 )?) {
417 Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
418 None => std::task::Poll::Ready(None),
419 }
420 }
421}
422
423#[derive(Debug)]
424pub enum StateEvent {
425 #[non_exhaustive]
426 _UnknownEvent {
427 ordinal: u64,
429 },
430}
431
432impl StateEvent {
433 fn decode(
435 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
436 ) -> Result<StateEvent, fidl::Error> {
437 let (bytes, _handles) = buf.split_mut();
438 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
439 debug_assert_eq!(tx_header.tx_id, 0);
440 match tx_header.ordinal {
441 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
442 Ok(StateEvent::_UnknownEvent { ordinal: tx_header.ordinal })
443 }
444 _ => Err(fidl::Error::UnknownOrdinal {
445 ordinal: tx_header.ordinal,
446 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
447 }),
448 }
449 }
450}
451
452pub struct StateRequestStream {
454 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
455 is_terminated: bool,
456}
457
458impl std::marker::Unpin for StateRequestStream {}
459
460impl futures::stream::FusedStream for StateRequestStream {
461 fn is_terminated(&self) -> bool {
462 self.is_terminated
463 }
464}
465
466impl fidl::endpoints::RequestStream for StateRequestStream {
467 type Protocol = StateMarker;
468 type ControlHandle = StateControlHandle;
469
470 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
471 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
472 }
473
474 fn control_handle(&self) -> Self::ControlHandle {
475 StateControlHandle { inner: self.inner.clone() }
476 }
477
478 fn into_inner(
479 self,
480 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
481 {
482 (self.inner, self.is_terminated)
483 }
484
485 fn from_inner(
486 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
487 is_terminated: bool,
488 ) -> Self {
489 Self { inner, is_terminated }
490 }
491}
492
493impl futures::Stream for StateRequestStream {
494 type Item = Result<StateRequest, fidl::Error>;
495
496 fn poll_next(
497 mut self: std::pin::Pin<&mut Self>,
498 cx: &mut std::task::Context<'_>,
499 ) -> std::task::Poll<Option<Self::Item>> {
500 let this = &mut *self;
501 if this.inner.check_shutdown(cx) {
502 this.is_terminated = true;
503 return std::task::Poll::Ready(None);
504 }
505 if this.is_terminated {
506 panic!("polled StateRequestStream after completion");
507 }
508 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
509 |bytes, handles| {
510 match this.inner.channel().read_etc(cx, bytes, handles) {
511 std::task::Poll::Ready(Ok(())) => {}
512 std::task::Poll::Pending => return std::task::Poll::Pending,
513 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
514 this.is_terminated = true;
515 return std::task::Poll::Ready(None);
516 }
517 std::task::Poll::Ready(Err(e)) => {
518 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
519 e.into(),
520 ))))
521 }
522 }
523
524 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
526
527 std::task::Poll::Ready(Some(match header.ordinal {
528 0x212842d46b8459f8 => {
529 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
530 let mut req = fidl::new_empty!(
531 SystemActivityGovernorState,
532 fidl::encoding::DefaultFuchsiaResourceDialect
533 );
534 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SystemActivityGovernorState>(&header, _body_bytes, handles, &mut req)?;
535 let control_handle = StateControlHandle { inner: this.inner.clone() };
536 Ok(StateRequest::Set {
537 payload: req,
538 responder: StateSetResponder {
539 control_handle: std::mem::ManuallyDrop::new(control_handle),
540 tx_id: header.tx_id,
541 },
542 })
543 }
544 0x65b19621b5644fdb => {
545 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
546 let mut req = fidl::new_empty!(
547 fidl::encoding::EmptyPayload,
548 fidl::encoding::DefaultFuchsiaResourceDialect
549 );
550 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
551 let control_handle = StateControlHandle { inner: this.inner.clone() };
552 Ok(StateRequest::Get {
553 responder: StateGetResponder {
554 control_handle: std::mem::ManuallyDrop::new(control_handle),
555 tx_id: header.tx_id,
556 },
557 })
558 }
559 0x7dded2028ad39365 => {
560 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
561 let mut req = fidl::new_empty!(
562 fidl::encoding::EmptyPayload,
563 fidl::encoding::DefaultFuchsiaResourceDialect
564 );
565 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
566 let control_handle = StateControlHandle { inner: this.inner.clone() };
567 Ok(StateRequest::SetBootComplete {
568 responder: StateSetBootCompleteResponder {
569 control_handle: std::mem::ManuallyDrop::new(control_handle),
570 tx_id: header.tx_id,
571 },
572 })
573 }
574 0x434b0aa4bbac7965 => {
575 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
576 let mut req = fidl::new_empty!(
577 fidl::encoding::EmptyPayload,
578 fidl::encoding::DefaultFuchsiaResourceDialect
579 );
580 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
581 let control_handle = StateControlHandle { inner: this.inner.clone() };
582 Ok(StateRequest::Watch {
583 responder: StateWatchResponder {
584 control_handle: std::mem::ManuallyDrop::new(control_handle),
585 tx_id: header.tx_id,
586 },
587 })
588 }
589 _ if header.tx_id == 0
590 && header
591 .dynamic_flags()
592 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
593 {
594 Ok(StateRequest::_UnknownMethod {
595 ordinal: header.ordinal,
596 control_handle: StateControlHandle { inner: this.inner.clone() },
597 method_type: fidl::MethodType::OneWay,
598 })
599 }
600 _ if header
601 .dynamic_flags()
602 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
603 {
604 this.inner.send_framework_err(
605 fidl::encoding::FrameworkErr::UnknownMethod,
606 header.tx_id,
607 header.ordinal,
608 header.dynamic_flags(),
609 (bytes, handles),
610 )?;
611 Ok(StateRequest::_UnknownMethod {
612 ordinal: header.ordinal,
613 control_handle: StateControlHandle { inner: this.inner.clone() },
614 method_type: fidl::MethodType::TwoWay,
615 })
616 }
617 _ => Err(fidl::Error::UnknownOrdinal {
618 ordinal: header.ordinal,
619 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
620 }),
621 }))
622 },
623 )
624 }
625}
626
627#[derive(Debug)]
628pub enum StateRequest {
629 Set { payload: SystemActivityGovernorState, responder: StateSetResponder },
636 Get { responder: StateGetResponder },
638 SetBootComplete { responder: StateSetBootCompleteResponder },
640 Watch { responder: StateWatchResponder },
654 #[non_exhaustive]
656 _UnknownMethod {
657 ordinal: u64,
659 control_handle: StateControlHandle,
660 method_type: fidl::MethodType,
661 },
662}
663
664impl StateRequest {
665 #[allow(irrefutable_let_patterns)]
666 pub fn into_set(self) -> Option<(SystemActivityGovernorState, StateSetResponder)> {
667 if let StateRequest::Set { payload, responder } = self {
668 Some((payload, responder))
669 } else {
670 None
671 }
672 }
673
674 #[allow(irrefutable_let_patterns)]
675 pub fn into_get(self) -> Option<(StateGetResponder)> {
676 if let StateRequest::Get { responder } = self {
677 Some((responder))
678 } else {
679 None
680 }
681 }
682
683 #[allow(irrefutable_let_patterns)]
684 pub fn into_set_boot_complete(self) -> Option<(StateSetBootCompleteResponder)> {
685 if let StateRequest::SetBootComplete { responder } = self {
686 Some((responder))
687 } else {
688 None
689 }
690 }
691
692 #[allow(irrefutable_let_patterns)]
693 pub fn into_watch(self) -> Option<(StateWatchResponder)> {
694 if let StateRequest::Watch { responder } = self {
695 Some((responder))
696 } else {
697 None
698 }
699 }
700
701 pub fn method_name(&self) -> &'static str {
703 match *self {
704 StateRequest::Set { .. } => "set",
705 StateRequest::Get { .. } => "get",
706 StateRequest::SetBootComplete { .. } => "set_boot_complete",
707 StateRequest::Watch { .. } => "watch",
708 StateRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
709 "unknown one-way method"
710 }
711 StateRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
712 "unknown two-way method"
713 }
714 }
715 }
716}
717
718#[derive(Debug, Clone)]
719pub struct StateControlHandle {
720 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
721}
722
723impl fidl::endpoints::ControlHandle for StateControlHandle {
724 fn shutdown(&self) {
725 self.inner.shutdown()
726 }
727 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
728 self.inner.shutdown_with_epitaph(status)
729 }
730
731 fn is_closed(&self) -> bool {
732 self.inner.channel().is_closed()
733 }
734 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
735 self.inner.channel().on_closed()
736 }
737
738 #[cfg(target_os = "fuchsia")]
739 fn signal_peer(
740 &self,
741 clear_mask: zx::Signals,
742 set_mask: zx::Signals,
743 ) -> Result<(), zx_status::Status> {
744 use fidl::Peered;
745 self.inner.channel().signal_peer(clear_mask, set_mask)
746 }
747}
748
749impl StateControlHandle {}
750
751#[must_use = "FIDL methods require a response to be sent"]
752#[derive(Debug)]
753pub struct StateSetResponder {
754 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
755 tx_id: u32,
756}
757
758impl std::ops::Drop for StateSetResponder {
762 fn drop(&mut self) {
763 self.control_handle.shutdown();
764 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
766 }
767}
768
769impl fidl::endpoints::Responder for StateSetResponder {
770 type ControlHandle = StateControlHandle;
771
772 fn control_handle(&self) -> &StateControlHandle {
773 &self.control_handle
774 }
775
776 fn drop_without_shutdown(mut self) {
777 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
779 std::mem::forget(self);
781 }
782}
783
784impl StateSetResponder {
785 pub fn send(
789 self,
790 mut result: Result<(), SetSystemActivityGovernorStateError>,
791 ) -> Result<(), fidl::Error> {
792 let _result = self.send_raw(result);
793 if _result.is_err() {
794 self.control_handle.shutdown();
795 }
796 self.drop_without_shutdown();
797 _result
798 }
799
800 pub fn send_no_shutdown_on_err(
802 self,
803 mut result: Result<(), SetSystemActivityGovernorStateError>,
804 ) -> Result<(), fidl::Error> {
805 let _result = self.send_raw(result);
806 self.drop_without_shutdown();
807 _result
808 }
809
810 fn send_raw(
811 &self,
812 mut result: Result<(), SetSystemActivityGovernorStateError>,
813 ) -> Result<(), fidl::Error> {
814 self.control_handle.inner.send::<fidl::encoding::ResultType<
815 fidl::encoding::EmptyStruct,
816 SetSystemActivityGovernorStateError,
817 >>(
818 result,
819 self.tx_id,
820 0x212842d46b8459f8,
821 fidl::encoding::DynamicFlags::empty(),
822 )
823 }
824}
825
826#[must_use = "FIDL methods require a response to be sent"]
827#[derive(Debug)]
828pub struct StateGetResponder {
829 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
830 tx_id: u32,
831}
832
833impl std::ops::Drop for StateGetResponder {
837 fn drop(&mut self) {
838 self.control_handle.shutdown();
839 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
841 }
842}
843
844impl fidl::endpoints::Responder for StateGetResponder {
845 type ControlHandle = StateControlHandle;
846
847 fn control_handle(&self) -> &StateControlHandle {
848 &self.control_handle
849 }
850
851 fn drop_without_shutdown(mut self) {
852 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
854 std::mem::forget(self);
856 }
857}
858
859impl StateGetResponder {
860 pub fn send(self, mut payload: &SystemActivityGovernorState) -> Result<(), fidl::Error> {
864 let _result = self.send_raw(payload);
865 if _result.is_err() {
866 self.control_handle.shutdown();
867 }
868 self.drop_without_shutdown();
869 _result
870 }
871
872 pub fn send_no_shutdown_on_err(
874 self,
875 mut payload: &SystemActivityGovernorState,
876 ) -> Result<(), fidl::Error> {
877 let _result = self.send_raw(payload);
878 self.drop_without_shutdown();
879 _result
880 }
881
882 fn send_raw(&self, mut payload: &SystemActivityGovernorState) -> Result<(), fidl::Error> {
883 self.control_handle.inner.send::<SystemActivityGovernorState>(
884 payload,
885 self.tx_id,
886 0x65b19621b5644fdb,
887 fidl::encoding::DynamicFlags::empty(),
888 )
889 }
890}
891
892#[must_use = "FIDL methods require a response to be sent"]
893#[derive(Debug)]
894pub struct StateSetBootCompleteResponder {
895 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
896 tx_id: u32,
897}
898
899impl std::ops::Drop for StateSetBootCompleteResponder {
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 StateSetBootCompleteResponder {
911 type ControlHandle = StateControlHandle;
912
913 fn control_handle(&self) -> &StateControlHandle {
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 StateSetBootCompleteResponder {
926 pub fn send(self) -> Result<(), fidl::Error> {
930 let _result = self.send_raw();
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(self) -> Result<(), fidl::Error> {
940 let _result = self.send_raw();
941 self.drop_without_shutdown();
942 _result
943 }
944
945 fn send_raw(&self) -> Result<(), fidl::Error> {
946 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
947 (),
948 self.tx_id,
949 0x7dded2028ad39365,
950 fidl::encoding::DynamicFlags::empty(),
951 )
952 }
953}
954
955#[must_use = "FIDL methods require a response to be sent"]
956#[derive(Debug)]
957pub struct StateWatchResponder {
958 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
959 tx_id: u32,
960}
961
962impl std::ops::Drop for StateWatchResponder {
966 fn drop(&mut self) {
967 self.control_handle.shutdown();
968 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
970 }
971}
972
973impl fidl::endpoints::Responder for StateWatchResponder {
974 type ControlHandle = StateControlHandle;
975
976 fn control_handle(&self) -> &StateControlHandle {
977 &self.control_handle
978 }
979
980 fn drop_without_shutdown(mut self) {
981 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
983 std::mem::forget(self);
985 }
986}
987
988impl StateWatchResponder {
989 pub fn send(self, mut payload: &SystemActivityGovernorState) -> Result<(), fidl::Error> {
993 let _result = self.send_raw(payload);
994 if _result.is_err() {
995 self.control_handle.shutdown();
996 }
997 self.drop_without_shutdown();
998 _result
999 }
1000
1001 pub fn send_no_shutdown_on_err(
1003 self,
1004 mut payload: &SystemActivityGovernorState,
1005 ) -> Result<(), fidl::Error> {
1006 let _result = self.send_raw(payload);
1007 self.drop_without_shutdown();
1008 _result
1009 }
1010
1011 fn send_raw(&self, mut payload: &SystemActivityGovernorState) -> Result<(), fidl::Error> {
1012 self.control_handle.inner.send::<SystemActivityGovernorState>(
1013 payload,
1014 self.tx_id,
1015 0x434b0aa4bbac7965,
1016 fidl::encoding::DynamicFlags::empty(),
1017 )
1018 }
1019}
1020
1021mod internal {
1022 use super::*;
1023 unsafe impl fidl::encoding::TypeMarker for SetSystemActivityGovernorStateError {
1024 type Owned = Self;
1025
1026 #[inline(always)]
1027 fn inline_align(_context: fidl::encoding::Context) -> usize {
1028 std::mem::align_of::<u32>()
1029 }
1030
1031 #[inline(always)]
1032 fn inline_size(_context: fidl::encoding::Context) -> usize {
1033 std::mem::size_of::<u32>()
1034 }
1035
1036 #[inline(always)]
1037 fn encode_is_copy() -> bool {
1038 true
1039 }
1040
1041 #[inline(always)]
1042 fn decode_is_copy() -> bool {
1043 false
1044 }
1045 }
1046
1047 impl fidl::encoding::ValueTypeMarker for SetSystemActivityGovernorStateError {
1048 type Borrowed<'a> = Self;
1049 #[inline(always)]
1050 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1051 *value
1052 }
1053 }
1054
1055 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1056 for SetSystemActivityGovernorStateError
1057 {
1058 #[inline]
1059 unsafe fn encode(
1060 self,
1061 encoder: &mut fidl::encoding::Encoder<'_, D>,
1062 offset: usize,
1063 _depth: fidl::encoding::Depth,
1064 ) -> fidl::Result<()> {
1065 encoder.debug_check_bounds::<Self>(offset);
1066 encoder.write_num(self.into_primitive(), offset);
1067 Ok(())
1068 }
1069 }
1070
1071 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1072 for SetSystemActivityGovernorStateError
1073 {
1074 #[inline(always)]
1075 fn new_empty() -> Self {
1076 Self::NotSupported
1077 }
1078
1079 #[inline]
1080 unsafe fn decode(
1081 &mut self,
1082 decoder: &mut fidl::encoding::Decoder<'_, D>,
1083 offset: usize,
1084 _depth: fidl::encoding::Depth,
1085 ) -> fidl::Result<()> {
1086 decoder.debug_check_bounds::<Self>(offset);
1087 let prim = decoder.read_num::<u32>(offset);
1088
1089 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1090 Ok(())
1091 }
1092 }
1093
1094 impl SystemActivityGovernorState {
1095 #[inline(always)]
1096 fn max_ordinal_present(&self) -> u64 {
1097 if let Some(_) = self.application_activity_level {
1098 return 2;
1099 }
1100 if let Some(_) = self.execution_state_level {
1101 return 1;
1102 }
1103 0
1104 }
1105 }
1106
1107 impl fidl::encoding::ValueTypeMarker for SystemActivityGovernorState {
1108 type Borrowed<'a> = &'a Self;
1109 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1110 value
1111 }
1112 }
1113
1114 unsafe impl fidl::encoding::TypeMarker for SystemActivityGovernorState {
1115 type Owned = Self;
1116
1117 #[inline(always)]
1118 fn inline_align(_context: fidl::encoding::Context) -> usize {
1119 8
1120 }
1121
1122 #[inline(always)]
1123 fn inline_size(_context: fidl::encoding::Context) -> usize {
1124 16
1125 }
1126 }
1127
1128 unsafe impl<D: fidl::encoding::ResourceDialect>
1129 fidl::encoding::Encode<SystemActivityGovernorState, D> for &SystemActivityGovernorState
1130 {
1131 unsafe fn encode(
1132 self,
1133 encoder: &mut fidl::encoding::Encoder<'_, D>,
1134 offset: usize,
1135 mut depth: fidl::encoding::Depth,
1136 ) -> fidl::Result<()> {
1137 encoder.debug_check_bounds::<SystemActivityGovernorState>(offset);
1138 let max_ordinal: u64 = self.max_ordinal_present();
1140 encoder.write_num(max_ordinal, offset);
1141 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1142 if max_ordinal == 0 {
1144 return Ok(());
1145 }
1146 depth.increment()?;
1147 let envelope_size = 8;
1148 let bytes_len = max_ordinal as usize * envelope_size;
1149 #[allow(unused_variables)]
1150 let offset = encoder.out_of_line_offset(bytes_len);
1151 let mut _prev_end_offset: usize = 0;
1152 if 1 > max_ordinal {
1153 return Ok(());
1154 }
1155
1156 let cur_offset: usize = (1 - 1) * envelope_size;
1159
1160 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1162
1163 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_power_system::ExecutionStateLevel, D>(
1168 self.execution_state_level.as_ref().map(<fidl_fuchsia_power_system::ExecutionStateLevel as fidl::encoding::ValueTypeMarker>::borrow),
1169 encoder, offset + cur_offset, depth
1170 )?;
1171
1172 _prev_end_offset = cur_offset + envelope_size;
1173 if 2 > max_ordinal {
1174 return Ok(());
1175 }
1176
1177 let cur_offset: usize = (2 - 1) * envelope_size;
1180
1181 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1183
1184 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_power_system::ApplicationActivityLevel, D>(
1189 self.application_activity_level.as_ref().map(<fidl_fuchsia_power_system::ApplicationActivityLevel as fidl::encoding::ValueTypeMarker>::borrow),
1190 encoder, offset + cur_offset, depth
1191 )?;
1192
1193 _prev_end_offset = cur_offset + envelope_size;
1194
1195 Ok(())
1196 }
1197 }
1198
1199 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1200 for SystemActivityGovernorState
1201 {
1202 #[inline(always)]
1203 fn new_empty() -> Self {
1204 Self::default()
1205 }
1206
1207 unsafe fn decode(
1208 &mut self,
1209 decoder: &mut fidl::encoding::Decoder<'_, D>,
1210 offset: usize,
1211 mut depth: fidl::encoding::Depth,
1212 ) -> fidl::Result<()> {
1213 decoder.debug_check_bounds::<Self>(offset);
1214 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1215 None => return Err(fidl::Error::NotNullable),
1216 Some(len) => len,
1217 };
1218 if len == 0 {
1220 return Ok(());
1221 };
1222 depth.increment()?;
1223 let envelope_size = 8;
1224 let bytes_len = len * envelope_size;
1225 let offset = decoder.out_of_line_offset(bytes_len)?;
1226 let mut _next_ordinal_to_read = 0;
1228 let mut next_offset = offset;
1229 let end_offset = offset + bytes_len;
1230 _next_ordinal_to_read += 1;
1231 if next_offset >= end_offset {
1232 return Ok(());
1233 }
1234
1235 while _next_ordinal_to_read < 1 {
1237 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1238 _next_ordinal_to_read += 1;
1239 next_offset += envelope_size;
1240 }
1241
1242 let next_out_of_line = decoder.next_out_of_line();
1243 let handles_before = decoder.remaining_handles();
1244 if let Some((inlined, num_bytes, num_handles)) =
1245 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1246 {
1247 let member_inline_size = <fidl_fuchsia_power_system::ExecutionStateLevel as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1248 if inlined != (member_inline_size <= 4) {
1249 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1250 }
1251 let inner_offset;
1252 let mut inner_depth = depth.clone();
1253 if inlined {
1254 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1255 inner_offset = next_offset;
1256 } else {
1257 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1258 inner_depth.increment()?;
1259 }
1260 let val_ref = self.execution_state_level.get_or_insert_with(|| {
1261 fidl::new_empty!(fidl_fuchsia_power_system::ExecutionStateLevel, D)
1262 });
1263 fidl::decode!(
1264 fidl_fuchsia_power_system::ExecutionStateLevel,
1265 D,
1266 val_ref,
1267 decoder,
1268 inner_offset,
1269 inner_depth
1270 )?;
1271 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1272 {
1273 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1274 }
1275 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1276 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1277 }
1278 }
1279
1280 next_offset += envelope_size;
1281 _next_ordinal_to_read += 1;
1282 if next_offset >= end_offset {
1283 return Ok(());
1284 }
1285
1286 while _next_ordinal_to_read < 2 {
1288 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1289 _next_ordinal_to_read += 1;
1290 next_offset += envelope_size;
1291 }
1292
1293 let next_out_of_line = decoder.next_out_of_line();
1294 let handles_before = decoder.remaining_handles();
1295 if let Some((inlined, num_bytes, num_handles)) =
1296 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1297 {
1298 let member_inline_size = <fidl_fuchsia_power_system::ApplicationActivityLevel as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1299 if inlined != (member_inline_size <= 4) {
1300 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1301 }
1302 let inner_offset;
1303 let mut inner_depth = depth.clone();
1304 if inlined {
1305 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1306 inner_offset = next_offset;
1307 } else {
1308 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1309 inner_depth.increment()?;
1310 }
1311 let val_ref = self.application_activity_level.get_or_insert_with(|| {
1312 fidl::new_empty!(fidl_fuchsia_power_system::ApplicationActivityLevel, D)
1313 });
1314 fidl::decode!(
1315 fidl_fuchsia_power_system::ApplicationActivityLevel,
1316 D,
1317 val_ref,
1318 decoder,
1319 inner_offset,
1320 inner_depth
1321 )?;
1322 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1323 {
1324 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1325 }
1326 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1327 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1328 }
1329 }
1330
1331 next_offset += envelope_size;
1332
1333 while next_offset < end_offset {
1335 _next_ordinal_to_read += 1;
1336 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1337 next_offset += envelope_size;
1338 }
1339
1340 Ok(())
1341 }
1342 }
1343}