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#[derive(Debug, Clone)]
126pub struct DebugProxy {
127 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
128}
129
130impl fidl::endpoints::Proxy for DebugProxy {
131 type Protocol = DebugMarker;
132
133 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
134 Self::new(inner)
135 }
136
137 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
138 self.client.into_channel().map_err(|client| Self { client })
139 }
140
141 fn as_channel(&self) -> &::fidl::AsyncChannel {
142 self.client.as_channel()
143 }
144}
145
146impl DebugProxy {
147 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
149 let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150 Self { client: fidl::client::Client::new(channel, protocol_name) }
151 }
152
153 pub fn take_event_stream(&self) -> DebugEventStream {
159 DebugEventStream { event_receiver: self.client.take_event_receiver() }
160 }
161
162 pub fn r#message(
186 &self,
187 mut node_name: &str,
188 mut command: &str,
189 mut args: &[String],
190 ) -> fidl::client::QueryResponseFut<
191 DebugMessageResult,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 > {
194 DebugProxyInterface::r#message(self, node_name, command, args)
195 }
196}
197
198impl DebugProxyInterface for DebugProxy {
199 type MessageResponseFut = fidl::client::QueryResponseFut<
200 DebugMessageResult,
201 fidl::encoding::DefaultFuchsiaResourceDialect,
202 >;
203 fn r#message(
204 &self,
205 mut node_name: &str,
206 mut command: &str,
207 mut args: &[String],
208 ) -> Self::MessageResponseFut {
209 fn _decode(
210 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
211 ) -> Result<DebugMessageResult, fidl::Error> {
212 let _response = fidl::client::decode_transaction_body::<
213 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, MessageError>,
214 fidl::encoding::DefaultFuchsiaResourceDialect,
215 0x3a1d992128e015da,
216 >(_buf?)?;
217 Ok(_response.map(|x| x))
218 }
219 self.client.send_query_and_decode::<DebugMessageRequest, DebugMessageResult>(
220 (node_name, command, args),
221 0x3a1d992128e015da,
222 fidl::encoding::DynamicFlags::empty(),
223 _decode,
224 )
225 }
226}
227
228pub struct DebugEventStream {
229 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
230}
231
232impl std::marker::Unpin for DebugEventStream {}
233
234impl futures::stream::FusedStream for DebugEventStream {
235 fn is_terminated(&self) -> bool {
236 self.event_receiver.is_terminated()
237 }
238}
239
240impl futures::Stream for DebugEventStream {
241 type Item = Result<DebugEvent, fidl::Error>;
242
243 fn poll_next(
244 mut self: std::pin::Pin<&mut Self>,
245 cx: &mut std::task::Context<'_>,
246 ) -> std::task::Poll<Option<Self::Item>> {
247 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
248 &mut self.event_receiver,
249 cx
250 )?) {
251 Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
252 None => std::task::Poll::Ready(None),
253 }
254 }
255}
256
257#[derive(Debug)]
258pub enum DebugEvent {}
259
260impl DebugEvent {
261 fn decode(
263 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
264 ) -> Result<DebugEvent, 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: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
272 }),
273 }
274 }
275}
276
277pub struct DebugRequestStream {
279 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
280 is_terminated: bool,
281}
282
283impl std::marker::Unpin for DebugRequestStream {}
284
285impl futures::stream::FusedStream for DebugRequestStream {
286 fn is_terminated(&self) -> bool {
287 self.is_terminated
288 }
289}
290
291impl fidl::endpoints::RequestStream for DebugRequestStream {
292 type Protocol = DebugMarker;
293 type ControlHandle = DebugControlHandle;
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 DebugControlHandle { 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 DebugRequestStream {
319 type Item = Result<DebugRequest, 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 DebugRequestStream 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 0x3a1d992128e015da => {
354 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
355 let mut req = fidl::new_empty!(
356 DebugMessageRequest,
357 fidl::encoding::DefaultFuchsiaResourceDialect
358 );
359 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugMessageRequest>(&header, _body_bytes, handles, &mut req)?;
360 let control_handle = DebugControlHandle { inner: this.inner.clone() };
361 Ok(DebugRequest::Message {
362 node_name: req.node_name,
363 command: req.command,
364 args: req.args,
365
366 responder: DebugMessageResponder {
367 control_handle: std::mem::ManuallyDrop::new(control_handle),
368 tx_id: header.tx_id,
369 },
370 })
371 }
372 _ => Err(fidl::Error::UnknownOrdinal {
373 ordinal: header.ordinal,
374 protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
375 }),
376 }))
377 },
378 )
379 }
380}
381
382#[derive(Debug)]
384pub enum DebugRequest {
385 Message {
409 node_name: String,
410 command: String,
411 args: Vec<String>,
412 responder: DebugMessageResponder,
413 },
414}
415
416impl DebugRequest {
417 #[allow(irrefutable_let_patterns)]
418 pub fn into_message(self) -> Option<(String, String, Vec<String>, DebugMessageResponder)> {
419 if let DebugRequest::Message { node_name, command, args, responder } = self {
420 Some((node_name, command, args, responder))
421 } else {
422 None
423 }
424 }
425
426 pub fn method_name(&self) -> &'static str {
428 match *self {
429 DebugRequest::Message { .. } => "message",
430 }
431 }
432}
433
434#[derive(Debug, Clone)]
435pub struct DebugControlHandle {
436 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
437}
438
439impl fidl::endpoints::ControlHandle for DebugControlHandle {
440 fn shutdown(&self) {
441 self.inner.shutdown()
442 }
443 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
444 self.inner.shutdown_with_epitaph(status)
445 }
446
447 fn is_closed(&self) -> bool {
448 self.inner.channel().is_closed()
449 }
450 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
451 self.inner.channel().on_closed()
452 }
453
454 #[cfg(target_os = "fuchsia")]
455 fn signal_peer(
456 &self,
457 clear_mask: zx::Signals,
458 set_mask: zx::Signals,
459 ) -> Result<(), zx_status::Status> {
460 use fidl::Peered;
461 self.inner.channel().signal_peer(clear_mask, set_mask)
462 }
463}
464
465impl DebugControlHandle {}
466
467#[must_use = "FIDL methods require a response to be sent"]
468#[derive(Debug)]
469pub struct DebugMessageResponder {
470 control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
471 tx_id: u32,
472}
473
474impl std::ops::Drop for DebugMessageResponder {
478 fn drop(&mut self) {
479 self.control_handle.shutdown();
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 }
483}
484
485impl fidl::endpoints::Responder for DebugMessageResponder {
486 type ControlHandle = DebugControlHandle;
487
488 fn control_handle(&self) -> &DebugControlHandle {
489 &self.control_handle
490 }
491
492 fn drop_without_shutdown(mut self) {
493 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
495 std::mem::forget(self);
497 }
498}
499
500impl DebugMessageResponder {
501 pub fn send(self, mut result: Result<(), MessageError>) -> Result<(), fidl::Error> {
505 let _result = self.send_raw(result);
506 if _result.is_err() {
507 self.control_handle.shutdown();
508 }
509 self.drop_without_shutdown();
510 _result
511 }
512
513 pub fn send_no_shutdown_on_err(
515 self,
516 mut result: Result<(), MessageError>,
517 ) -> Result<(), fidl::Error> {
518 let _result = self.send_raw(result);
519 self.drop_without_shutdown();
520 _result
521 }
522
523 fn send_raw(&self, mut result: Result<(), MessageError>) -> Result<(), fidl::Error> {
524 self.control_handle.inner.send::<fidl::encoding::ResultType<
525 fidl::encoding::EmptyStruct,
526 MessageError,
527 >>(
528 result,
529 self.tx_id,
530 0x3a1d992128e015da,
531 fidl::encoding::DynamicFlags::empty(),
532 )
533 }
534}
535
536mod internal {
537 use super::*;
538}