fidl_fuchsia_power_cpu_manager/
fidl_fuchsia_power_cpu_manager.rs1#![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_cpu_manager__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct BoostMarker;
16
17impl fidl::endpoints::ProtocolMarker for BoostMarker {
18 type Proxy = BoostProxy;
19 type RequestStream = BoostRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = BoostSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.power.cpu.manager.Boost";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for BoostMarker {}
26pub type BoostSetBoostResult = Result<(), SetBoostError>;
27
28pub trait BoostProxyInterface: Send + Sync {
29 type SetBoostResponseFut: std::future::Future<Output = Result<BoostSetBoostResult, fidl::Error>>
30 + Send;
31 fn r#set_boost(&self, enable: bool) -> Self::SetBoostResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct BoostSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for BoostSynchronousProxy {
41 type Proxy = BoostProxy;
42 type Protocol = BoostMarker;
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 BoostSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 let protocol_name = <BoostMarker 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<BoostEvent, fidl::Error> {
74 BoostEvent::decode(self.client.wait_for_event(deadline)?)
75 }
76
77 pub fn r#set_boost(
78 &self,
79 mut enable: bool,
80 ___deadline: zx::MonotonicInstant,
81 ) -> Result<BoostSetBoostResult, fidl::Error> {
82 let _response = self.client.send_query::<
83 BoostSetBoostRequest,
84 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, SetBoostError>,
85 >(
86 (enable,),
87 0x22c73b207ffdf433,
88 fidl::encoding::DynamicFlags::FLEXIBLE,
89 ___deadline,
90 )?
91 .into_result::<BoostMarker>("set_boost")?;
92 Ok(_response.map(|x| x))
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl From<BoostSynchronousProxy> for zx::Handle {
98 fn from(value: BoostSynchronousProxy) -> Self {
99 value.into_channel().into()
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<fidl::Channel> for BoostSynchronousProxy {
105 fn from(value: fidl::Channel) -> Self {
106 Self::new(value)
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl fidl::endpoints::FromClient for BoostSynchronousProxy {
112 type Protocol = BoostMarker;
113
114 fn from_client(value: fidl::endpoints::ClientEnd<BoostMarker>) -> Self {
115 Self::new(value.into_channel())
116 }
117}
118
119#[derive(Debug, Clone)]
120pub struct BoostProxy {
121 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
122}
123
124impl fidl::endpoints::Proxy for BoostProxy {
125 type Protocol = BoostMarker;
126
127 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
128 Self::new(inner)
129 }
130
131 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
132 self.client.into_channel().map_err(|client| Self { client })
133 }
134
135 fn as_channel(&self) -> &::fidl::AsyncChannel {
136 self.client.as_channel()
137 }
138}
139
140impl BoostProxy {
141 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
143 let protocol_name = <BoostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144 Self { client: fidl::client::Client::new(channel, protocol_name) }
145 }
146
147 pub fn take_event_stream(&self) -> BoostEventStream {
153 BoostEventStream { event_receiver: self.client.take_event_receiver() }
154 }
155
156 pub fn r#set_boost(
157 &self,
158 mut enable: bool,
159 ) -> fidl::client::QueryResponseFut<
160 BoostSetBoostResult,
161 fidl::encoding::DefaultFuchsiaResourceDialect,
162 > {
163 BoostProxyInterface::r#set_boost(self, enable)
164 }
165}
166
167impl BoostProxyInterface for BoostProxy {
168 type SetBoostResponseFut = fidl::client::QueryResponseFut<
169 BoostSetBoostResult,
170 fidl::encoding::DefaultFuchsiaResourceDialect,
171 >;
172 fn r#set_boost(&self, mut enable: bool) -> Self::SetBoostResponseFut {
173 fn _decode(
174 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
175 ) -> Result<BoostSetBoostResult, fidl::Error> {
176 let _response = fidl::client::decode_transaction_body::<
177 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, SetBoostError>,
178 fidl::encoding::DefaultFuchsiaResourceDialect,
179 0x22c73b207ffdf433,
180 >(_buf?)?
181 .into_result::<BoostMarker>("set_boost")?;
182 Ok(_response.map(|x| x))
183 }
184 self.client.send_query_and_decode::<BoostSetBoostRequest, BoostSetBoostResult>(
185 (enable,),
186 0x22c73b207ffdf433,
187 fidl::encoding::DynamicFlags::FLEXIBLE,
188 _decode,
189 )
190 }
191}
192
193pub struct BoostEventStream {
194 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
195}
196
197impl std::marker::Unpin for BoostEventStream {}
198
199impl futures::stream::FusedStream for BoostEventStream {
200 fn is_terminated(&self) -> bool {
201 self.event_receiver.is_terminated()
202 }
203}
204
205impl futures::Stream for BoostEventStream {
206 type Item = Result<BoostEvent, fidl::Error>;
207
208 fn poll_next(
209 mut self: std::pin::Pin<&mut Self>,
210 cx: &mut std::task::Context<'_>,
211 ) -> std::task::Poll<Option<Self::Item>> {
212 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
213 &mut self.event_receiver,
214 cx
215 )?) {
216 Some(buf) => std::task::Poll::Ready(Some(BoostEvent::decode(buf))),
217 None => std::task::Poll::Ready(None),
218 }
219 }
220}
221
222#[derive(Debug)]
223pub enum BoostEvent {
224 #[non_exhaustive]
225 _UnknownEvent {
226 ordinal: u64,
228 },
229}
230
231impl BoostEvent {
232 fn decode(
234 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
235 ) -> Result<BoostEvent, fidl::Error> {
236 let (bytes, _handles) = buf.split_mut();
237 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
238 debug_assert_eq!(tx_header.tx_id, 0);
239 match tx_header.ordinal {
240 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
241 Ok(BoostEvent::_UnknownEvent { ordinal: tx_header.ordinal })
242 }
243 _ => Err(fidl::Error::UnknownOrdinal {
244 ordinal: tx_header.ordinal,
245 protocol_name: <BoostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
246 }),
247 }
248 }
249}
250
251pub struct BoostRequestStream {
253 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
254 is_terminated: bool,
255}
256
257impl std::marker::Unpin for BoostRequestStream {}
258
259impl futures::stream::FusedStream for BoostRequestStream {
260 fn is_terminated(&self) -> bool {
261 self.is_terminated
262 }
263}
264
265impl fidl::endpoints::RequestStream for BoostRequestStream {
266 type Protocol = BoostMarker;
267 type ControlHandle = BoostControlHandle;
268
269 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
270 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
271 }
272
273 fn control_handle(&self) -> Self::ControlHandle {
274 BoostControlHandle { inner: self.inner.clone() }
275 }
276
277 fn into_inner(
278 self,
279 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
280 {
281 (self.inner, self.is_terminated)
282 }
283
284 fn from_inner(
285 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
286 is_terminated: bool,
287 ) -> Self {
288 Self { inner, is_terminated }
289 }
290}
291
292impl futures::Stream for BoostRequestStream {
293 type Item = Result<BoostRequest, fidl::Error>;
294
295 fn poll_next(
296 mut self: std::pin::Pin<&mut Self>,
297 cx: &mut std::task::Context<'_>,
298 ) -> std::task::Poll<Option<Self::Item>> {
299 let this = &mut *self;
300 if this.inner.check_shutdown(cx) {
301 this.is_terminated = true;
302 return std::task::Poll::Ready(None);
303 }
304 if this.is_terminated {
305 panic!("polled BoostRequestStream after completion");
306 }
307 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
308 |bytes, handles| {
309 match this.inner.channel().read_etc(cx, bytes, handles) {
310 std::task::Poll::Ready(Ok(())) => {}
311 std::task::Poll::Pending => return std::task::Poll::Pending,
312 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
313 this.is_terminated = true;
314 return std::task::Poll::Ready(None);
315 }
316 std::task::Poll::Ready(Err(e)) => {
317 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
318 e.into(),
319 ))));
320 }
321 }
322
323 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
325
326 std::task::Poll::Ready(Some(match header.ordinal {
327 0x22c73b207ffdf433 => {
328 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
329 let mut req = fidl::new_empty!(
330 BoostSetBoostRequest,
331 fidl::encoding::DefaultFuchsiaResourceDialect
332 );
333 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BoostSetBoostRequest>(&header, _body_bytes, handles, &mut req)?;
334 let control_handle = BoostControlHandle { inner: this.inner.clone() };
335 Ok(BoostRequest::SetBoost {
336 enable: req.enable,
337
338 responder: BoostSetBoostResponder {
339 control_handle: std::mem::ManuallyDrop::new(control_handle),
340 tx_id: header.tx_id,
341 },
342 })
343 }
344 _ if header.tx_id == 0
345 && header
346 .dynamic_flags()
347 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
348 {
349 Ok(BoostRequest::_UnknownMethod {
350 ordinal: header.ordinal,
351 control_handle: BoostControlHandle { inner: this.inner.clone() },
352 method_type: fidl::MethodType::OneWay,
353 })
354 }
355 _ if header
356 .dynamic_flags()
357 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
358 {
359 this.inner.send_framework_err(
360 fidl::encoding::FrameworkErr::UnknownMethod,
361 header.tx_id,
362 header.ordinal,
363 header.dynamic_flags(),
364 (bytes, handles),
365 )?;
366 Ok(BoostRequest::_UnknownMethod {
367 ordinal: header.ordinal,
368 control_handle: BoostControlHandle { inner: this.inner.clone() },
369 method_type: fidl::MethodType::TwoWay,
370 })
371 }
372 _ => Err(fidl::Error::UnknownOrdinal {
373 ordinal: header.ordinal,
374 protocol_name: <BoostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
375 }),
376 }))
377 },
378 )
379 }
380}
381
382#[derive(Debug)]
383pub enum BoostRequest {
384 SetBoost {
385 enable: bool,
386 responder: BoostSetBoostResponder,
387 },
388 #[non_exhaustive]
390 _UnknownMethod {
391 ordinal: u64,
393 control_handle: BoostControlHandle,
394 method_type: fidl::MethodType,
395 },
396}
397
398impl BoostRequest {
399 #[allow(irrefutable_let_patterns)]
400 pub fn into_set_boost(self) -> Option<(bool, BoostSetBoostResponder)> {
401 if let BoostRequest::SetBoost { enable, responder } = self {
402 Some((enable, responder))
403 } else {
404 None
405 }
406 }
407
408 pub fn method_name(&self) -> &'static str {
410 match *self {
411 BoostRequest::SetBoost { .. } => "set_boost",
412 BoostRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
413 "unknown one-way method"
414 }
415 BoostRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
416 "unknown two-way method"
417 }
418 }
419 }
420}
421
422#[derive(Debug, Clone)]
423pub struct BoostControlHandle {
424 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
425}
426
427impl fidl::endpoints::ControlHandle for BoostControlHandle {
428 fn shutdown(&self) {
429 self.inner.shutdown()
430 }
431 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
432 self.inner.shutdown_with_epitaph(status)
433 }
434
435 fn is_closed(&self) -> bool {
436 self.inner.channel().is_closed()
437 }
438 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
439 self.inner.channel().on_closed()
440 }
441
442 #[cfg(target_os = "fuchsia")]
443 fn signal_peer(
444 &self,
445 clear_mask: zx::Signals,
446 set_mask: zx::Signals,
447 ) -> Result<(), zx_status::Status> {
448 use fidl::Peered;
449 self.inner.channel().signal_peer(clear_mask, set_mask)
450 }
451}
452
453impl BoostControlHandle {}
454
455#[must_use = "FIDL methods require a response to be sent"]
456#[derive(Debug)]
457pub struct BoostSetBoostResponder {
458 control_handle: std::mem::ManuallyDrop<BoostControlHandle>,
459 tx_id: u32,
460}
461
462impl std::ops::Drop for BoostSetBoostResponder {
466 fn drop(&mut self) {
467 self.control_handle.shutdown();
468 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
470 }
471}
472
473impl fidl::endpoints::Responder for BoostSetBoostResponder {
474 type ControlHandle = BoostControlHandle;
475
476 fn control_handle(&self) -> &BoostControlHandle {
477 &self.control_handle
478 }
479
480 fn drop_without_shutdown(mut self) {
481 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
483 std::mem::forget(self);
485 }
486}
487
488impl BoostSetBoostResponder {
489 pub fn send(self, mut result: Result<(), SetBoostError>) -> Result<(), fidl::Error> {
493 let _result = self.send_raw(result);
494 if _result.is_err() {
495 self.control_handle.shutdown();
496 }
497 self.drop_without_shutdown();
498 _result
499 }
500
501 pub fn send_no_shutdown_on_err(
503 self,
504 mut result: Result<(), SetBoostError>,
505 ) -> Result<(), fidl::Error> {
506 let _result = self.send_raw(result);
507 self.drop_without_shutdown();
508 _result
509 }
510
511 fn send_raw(&self, mut result: Result<(), SetBoostError>) -> Result<(), fidl::Error> {
512 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
513 fidl::encoding::EmptyStruct,
514 SetBoostError,
515 >>(
516 fidl::encoding::FlexibleResult::new(result),
517 self.tx_id,
518 0x22c73b207ffdf433,
519 fidl::encoding::DynamicFlags::FLEXIBLE,
520 )
521 }
522}
523
524mod internal {
525 use super::*;
526}