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_manager_debug__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DebugMarker;
16
17impl fidl::endpoints::ProtocolMarker for DebugMarker {
18 type Proxy = DebugProxy;
19 type RequestStream = DebugRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DebugSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.power.manager.debug.Debug";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DebugMarker {}
26pub type DebugMessageResult = Result<(), MessageError>;
27
28pub trait DebugProxyInterface: Send + Sync {
29 type MessageResponseFut: std::future::Future<Output = Result<DebugMessageResult, fidl::Error>>
30 + Send;
31 fn r#message(
32 &self,
33 node_name: &str,
34 command: &str,
35 args: &[String],
36 ) -> Self::MessageResponseFut;
37}
38#[derive(Debug)]
39#[cfg(target_os = "fuchsia")]
40pub struct DebugSynchronousProxy {
41 client: fidl::client::sync::Client,
42}
43
44#[cfg(target_os = "fuchsia")]
45impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
46 type Proxy = DebugProxy;
47 type Protocol = DebugMarker;
48
49 fn from_channel(inner: fidl::Channel) -> Self {
50 Self::new(inner)
51 }
52
53 fn into_channel(self) -> fidl::Channel {
54 self.client.into_channel()
55 }
56
57 fn as_channel(&self) -> &fidl::Channel {
58 self.client.as_channel()
59 }
60}
61
62#[cfg(target_os = "fuchsia")]
63impl DebugSynchronousProxy {
64 pub fn new(channel: fidl::Channel) -> Self {
65 let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
66 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
67 }
68
69 pub fn into_channel(self) -> fidl::Channel {
70 self.client.into_channel()
71 }
72
73 pub fn wait_for_event(
76 &self,
77 deadline: zx::MonotonicInstant,
78 ) -> Result<DebugEvent, fidl::Error> {
79 DebugEvent::decode(self.client.wait_for_event(deadline)?)
80 }
81
82 pub fn r#message(
106 &self,
107 mut node_name: &str,
108 mut command: &str,
109 mut args: &[String],
110 ___deadline: zx::MonotonicInstant,
111 ) -> Result<DebugMessageResult, fidl::Error> {
112 let _response = self.client.send_query::<DebugMessageRequest, fidl::encoding::ResultType<
113 fidl::encoding::EmptyStruct,
114 MessageError,
115 >>(
116 (node_name, command, args),
117 0x3a1d992128e015da,
118 fidl::encoding::DynamicFlags::empty(),
119 ___deadline,
120 )?;
121 Ok(_response.map(|x| x))
122 }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl From<DebugSynchronousProxy> for zx::Handle {
127 fn from(value: DebugSynchronousProxy) -> Self {
128 value.into_channel().into()
129 }
130}
131
132#[cfg(target_os = "fuchsia")]
133impl From<fidl::Channel> for DebugSynchronousProxy {
134 fn from(value: fidl::Channel) -> Self {
135 Self::new(value)
136 }
137}
138
139#[cfg(target_os = "fuchsia")]
140impl fidl::endpoints::FromClient for DebugSynchronousProxy {
141 type Protocol = DebugMarker;
142
143 fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
144 Self::new(value.into_channel())
145 }
146}
147
148#[derive(Debug, Clone)]
149pub struct DebugProxy {
150 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
151}
152
153impl fidl::endpoints::Proxy for DebugProxy {
154 type Protocol = DebugMarker;
155
156 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
157 Self::new(inner)
158 }
159
160 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
161 self.client.into_channel().map_err(|client| Self { client })
162 }
163
164 fn as_channel(&self) -> &::fidl::AsyncChannel {
165 self.client.as_channel()
166 }
167}
168
169impl DebugProxy {
170 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
172 let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
173 Self { client: fidl::client::Client::new(channel, protocol_name) }
174 }
175
176 pub fn take_event_stream(&self) -> DebugEventStream {
182 DebugEventStream { event_receiver: self.client.take_event_receiver() }
183 }
184
185 pub fn r#message(
209 &self,
210 mut node_name: &str,
211 mut command: &str,
212 mut args: &[String],
213 ) -> fidl::client::QueryResponseFut<
214 DebugMessageResult,
215 fidl::encoding::DefaultFuchsiaResourceDialect,
216 > {
217 DebugProxyInterface::r#message(self, node_name, command, args)
218 }
219}
220
221impl DebugProxyInterface for DebugProxy {
222 type MessageResponseFut = fidl::client::QueryResponseFut<
223 DebugMessageResult,
224 fidl::encoding::DefaultFuchsiaResourceDialect,
225 >;
226 fn r#message(
227 &self,
228 mut node_name: &str,
229 mut command: &str,
230 mut args: &[String],
231 ) -> Self::MessageResponseFut {
232 fn _decode(
233 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
234 ) -> Result<DebugMessageResult, fidl::Error> {
235 let _response = fidl::client::decode_transaction_body::<
236 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, MessageError>,
237 fidl::encoding::DefaultFuchsiaResourceDialect,
238 0x3a1d992128e015da,
239 >(_buf?)?;
240 Ok(_response.map(|x| x))
241 }
242 self.client.send_query_and_decode::<DebugMessageRequest, DebugMessageResult>(
243 (node_name, command, args),
244 0x3a1d992128e015da,
245 fidl::encoding::DynamicFlags::empty(),
246 _decode,
247 )
248 }
249}
250
251pub struct DebugEventStream {
252 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
253}
254
255impl std::marker::Unpin for DebugEventStream {}
256
257impl futures::stream::FusedStream for DebugEventStream {
258 fn is_terminated(&self) -> bool {
259 self.event_receiver.is_terminated()
260 }
261}
262
263impl futures::Stream for DebugEventStream {
264 type Item = Result<DebugEvent, fidl::Error>;
265
266 fn poll_next(
267 mut self: std::pin::Pin<&mut Self>,
268 cx: &mut std::task::Context<'_>,
269 ) -> std::task::Poll<Option<Self::Item>> {
270 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
271 &mut self.event_receiver,
272 cx
273 )?) {
274 Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
275 None => std::task::Poll::Ready(None),
276 }
277 }
278}
279
280#[derive(Debug)]
281pub enum DebugEvent {}
282
283impl DebugEvent {
284 fn decode(
286 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
287 ) -> Result<DebugEvent, fidl::Error> {
288 let (bytes, _handles) = buf.split_mut();
289 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
290 debug_assert_eq!(tx_header.tx_id, 0);
291 match tx_header.ordinal {
292 _ => Err(fidl::Error::UnknownOrdinal {
293 ordinal: tx_header.ordinal,
294 protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295 }),
296 }
297 }
298}
299
300pub struct DebugRequestStream {
302 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303 is_terminated: bool,
304}
305
306impl std::marker::Unpin for DebugRequestStream {}
307
308impl futures::stream::FusedStream for DebugRequestStream {
309 fn is_terminated(&self) -> bool {
310 self.is_terminated
311 }
312}
313
314impl fidl::endpoints::RequestStream for DebugRequestStream {
315 type Protocol = DebugMarker;
316 type ControlHandle = DebugControlHandle;
317
318 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
319 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
320 }
321
322 fn control_handle(&self) -> Self::ControlHandle {
323 DebugControlHandle { inner: self.inner.clone() }
324 }
325
326 fn into_inner(
327 self,
328 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
329 {
330 (self.inner, self.is_terminated)
331 }
332
333 fn from_inner(
334 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335 is_terminated: bool,
336 ) -> Self {
337 Self { inner, is_terminated }
338 }
339}
340
341impl futures::Stream for DebugRequestStream {
342 type Item = Result<DebugRequest, fidl::Error>;
343
344 fn poll_next(
345 mut self: std::pin::Pin<&mut Self>,
346 cx: &mut std::task::Context<'_>,
347 ) -> std::task::Poll<Option<Self::Item>> {
348 let this = &mut *self;
349 if this.inner.check_shutdown(cx) {
350 this.is_terminated = true;
351 return std::task::Poll::Ready(None);
352 }
353 if this.is_terminated {
354 panic!("polled DebugRequestStream after completion");
355 }
356 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
357 |bytes, handles| {
358 match this.inner.channel().read_etc(cx, bytes, handles) {
359 std::task::Poll::Ready(Ok(())) => {}
360 std::task::Poll::Pending => return std::task::Poll::Pending,
361 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
362 this.is_terminated = true;
363 return std::task::Poll::Ready(None);
364 }
365 std::task::Poll::Ready(Err(e)) => {
366 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
367 e.into(),
368 ))))
369 }
370 }
371
372 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375 std::task::Poll::Ready(Some(match header.ordinal {
376 0x3a1d992128e015da => {
377 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
378 let mut req = fidl::new_empty!(
379 DebugMessageRequest,
380 fidl::encoding::DefaultFuchsiaResourceDialect
381 );
382 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugMessageRequest>(&header, _body_bytes, handles, &mut req)?;
383 let control_handle = DebugControlHandle { inner: this.inner.clone() };
384 Ok(DebugRequest::Message {
385 node_name: req.node_name,
386 command: req.command,
387 args: req.args,
388
389 responder: DebugMessageResponder {
390 control_handle: std::mem::ManuallyDrop::new(control_handle),
391 tx_id: header.tx_id,
392 },
393 })
394 }
395 _ => Err(fidl::Error::UnknownOrdinal {
396 ordinal: header.ordinal,
397 protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
398 }),
399 }))
400 },
401 )
402 }
403}
404
405#[derive(Debug)]
407pub enum DebugRequest {
408 Message {
432 node_name: String,
433 command: String,
434 args: Vec<String>,
435 responder: DebugMessageResponder,
436 },
437}
438
439impl DebugRequest {
440 #[allow(irrefutable_let_patterns)]
441 pub fn into_message(self) -> Option<(String, String, Vec<String>, DebugMessageResponder)> {
442 if let DebugRequest::Message { node_name, command, args, responder } = self {
443 Some((node_name, command, args, responder))
444 } else {
445 None
446 }
447 }
448
449 pub fn method_name(&self) -> &'static str {
451 match *self {
452 DebugRequest::Message { .. } => "message",
453 }
454 }
455}
456
457#[derive(Debug, Clone)]
458pub struct DebugControlHandle {
459 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
460}
461
462impl fidl::endpoints::ControlHandle for DebugControlHandle {
463 fn shutdown(&self) {
464 self.inner.shutdown()
465 }
466 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
467 self.inner.shutdown_with_epitaph(status)
468 }
469
470 fn is_closed(&self) -> bool {
471 self.inner.channel().is_closed()
472 }
473 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
474 self.inner.channel().on_closed()
475 }
476
477 #[cfg(target_os = "fuchsia")]
478 fn signal_peer(
479 &self,
480 clear_mask: zx::Signals,
481 set_mask: zx::Signals,
482 ) -> Result<(), zx_status::Status> {
483 use fidl::Peered;
484 self.inner.channel().signal_peer(clear_mask, set_mask)
485 }
486}
487
488impl DebugControlHandle {}
489
490#[must_use = "FIDL methods require a response to be sent"]
491#[derive(Debug)]
492pub struct DebugMessageResponder {
493 control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
494 tx_id: u32,
495}
496
497impl std::ops::Drop for DebugMessageResponder {
501 fn drop(&mut self) {
502 self.control_handle.shutdown();
503 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505 }
506}
507
508impl fidl::endpoints::Responder for DebugMessageResponder {
509 type ControlHandle = DebugControlHandle;
510
511 fn control_handle(&self) -> &DebugControlHandle {
512 &self.control_handle
513 }
514
515 fn drop_without_shutdown(mut self) {
516 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
518 std::mem::forget(self);
520 }
521}
522
523impl DebugMessageResponder {
524 pub fn send(self, mut result: Result<(), MessageError>) -> Result<(), fidl::Error> {
528 let _result = self.send_raw(result);
529 if _result.is_err() {
530 self.control_handle.shutdown();
531 }
532 self.drop_without_shutdown();
533 _result
534 }
535
536 pub fn send_no_shutdown_on_err(
538 self,
539 mut result: Result<(), MessageError>,
540 ) -> Result<(), fidl::Error> {
541 let _result = self.send_raw(result);
542 self.drop_without_shutdown();
543 _result
544 }
545
546 fn send_raw(&self, mut result: Result<(), MessageError>) -> Result<(), fidl::Error> {
547 self.control_handle.inner.send::<fidl::encoding::ResultType<
548 fidl::encoding::EmptyStruct,
549 MessageError,
550 >>(
551 result,
552 self.tx_id,
553 0x3a1d992128e015da,
554 fidl::encoding::DynamicFlags::empty(),
555 )
556 }
557}
558
559mod internal {
560 use super::*;
561}