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(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub struct PuppetMarker;
15
16impl fidl::endpoints::ProtocolMarker for PuppetMarker {
17 type Proxy = PuppetProxy;
18 type RequestStream = PuppetRequestStream;
19 #[cfg(target_os = "fuchsia")]
20 type SynchronousProxy = PuppetSynchronousProxy;
21
22 const DEBUG_NAME: &'static str = "inspect.selfprofile.test.Puppet";
23}
24impl fidl::endpoints::DiscoverableProtocolMarker for PuppetMarker {}
25
26pub trait PuppetProxyInterface: Send + Sync {
27 type StartProfilingResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
28 fn r#start_profiling(&self) -> Self::StartProfilingResponseFut;
29 type StopProfilingResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
30 fn r#stop_profiling(&self) -> Self::StopProfilingResponseFut;
31 type RunProfiledFunctionResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
32 + Send;
33 fn r#run_profiled_function(&self) -> Self::RunProfiledFunctionResponseFut;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct PuppetSynchronousProxy {
38 client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for PuppetSynchronousProxy {
43 type Proxy = PuppetProxy;
44 type Protocol = PuppetMarker;
45
46 fn from_channel(inner: fidl::Channel) -> Self {
47 Self::new(inner)
48 }
49
50 fn into_channel(self) -> fidl::Channel {
51 self.client.into_channel()
52 }
53
54 fn as_channel(&self) -> &fidl::Channel {
55 self.client.as_channel()
56 }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl PuppetSynchronousProxy {
61 pub fn new(channel: fidl::Channel) -> Self {
62 let protocol_name = <PuppetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64 }
65
66 pub fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 pub fn wait_for_event(
73 &self,
74 deadline: zx::MonotonicInstant,
75 ) -> Result<PuppetEvent, fidl::Error> {
76 PuppetEvent::decode(self.client.wait_for_event(deadline)?)
77 }
78
79 pub fn r#start_profiling(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
80 let _response =
81 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
82 (),
83 0x3fdf927c6e4c8c8d,
84 fidl::encoding::DynamicFlags::empty(),
85 ___deadline,
86 )?;
87 Ok(_response)
88 }
89
90 pub fn r#stop_profiling(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
91 let _response =
92 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
93 (),
94 0x23347e09827a7087,
95 fidl::encoding::DynamicFlags::empty(),
96 ___deadline,
97 )?;
98 Ok(_response)
99 }
100
101 pub fn r#run_profiled_function(
102 &self,
103 ___deadline: zx::MonotonicInstant,
104 ) -> Result<(), fidl::Error> {
105 let _response =
106 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
107 (),
108 0x679bdcc07c2f7065,
109 fidl::encoding::DynamicFlags::empty(),
110 ___deadline,
111 )?;
112 Ok(_response)
113 }
114}
115
116#[derive(Debug, Clone)]
117pub struct PuppetProxy {
118 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
119}
120
121impl fidl::endpoints::Proxy for PuppetProxy {
122 type Protocol = PuppetMarker;
123
124 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
125 Self::new(inner)
126 }
127
128 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
129 self.client.into_channel().map_err(|client| Self { client })
130 }
131
132 fn as_channel(&self) -> &::fidl::AsyncChannel {
133 self.client.as_channel()
134 }
135}
136
137impl PuppetProxy {
138 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
140 let protocol_name = <PuppetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141 Self { client: fidl::client::Client::new(channel, protocol_name) }
142 }
143
144 pub fn take_event_stream(&self) -> PuppetEventStream {
150 PuppetEventStream { event_receiver: self.client.take_event_receiver() }
151 }
152
153 pub fn r#start_profiling(
154 &self,
155 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
156 PuppetProxyInterface::r#start_profiling(self)
157 }
158
159 pub fn r#stop_profiling(
160 &self,
161 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
162 PuppetProxyInterface::r#stop_profiling(self)
163 }
164
165 pub fn r#run_profiled_function(
166 &self,
167 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
168 PuppetProxyInterface::r#run_profiled_function(self)
169 }
170}
171
172impl PuppetProxyInterface for PuppetProxy {
173 type StartProfilingResponseFut =
174 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
175 fn r#start_profiling(&self) -> Self::StartProfilingResponseFut {
176 fn _decode(
177 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
178 ) -> Result<(), fidl::Error> {
179 let _response = fidl::client::decode_transaction_body::<
180 fidl::encoding::EmptyPayload,
181 fidl::encoding::DefaultFuchsiaResourceDialect,
182 0x3fdf927c6e4c8c8d,
183 >(_buf?)?;
184 Ok(_response)
185 }
186 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
187 (),
188 0x3fdf927c6e4c8c8d,
189 fidl::encoding::DynamicFlags::empty(),
190 _decode,
191 )
192 }
193
194 type StopProfilingResponseFut =
195 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
196 fn r#stop_profiling(&self) -> Self::StopProfilingResponseFut {
197 fn _decode(
198 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
199 ) -> Result<(), fidl::Error> {
200 let _response = fidl::client::decode_transaction_body::<
201 fidl::encoding::EmptyPayload,
202 fidl::encoding::DefaultFuchsiaResourceDialect,
203 0x23347e09827a7087,
204 >(_buf?)?;
205 Ok(_response)
206 }
207 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
208 (),
209 0x23347e09827a7087,
210 fidl::encoding::DynamicFlags::empty(),
211 _decode,
212 )
213 }
214
215 type RunProfiledFunctionResponseFut =
216 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
217 fn r#run_profiled_function(&self) -> Self::RunProfiledFunctionResponseFut {
218 fn _decode(
219 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
220 ) -> Result<(), fidl::Error> {
221 let _response = fidl::client::decode_transaction_body::<
222 fidl::encoding::EmptyPayload,
223 fidl::encoding::DefaultFuchsiaResourceDialect,
224 0x679bdcc07c2f7065,
225 >(_buf?)?;
226 Ok(_response)
227 }
228 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
229 (),
230 0x679bdcc07c2f7065,
231 fidl::encoding::DynamicFlags::empty(),
232 _decode,
233 )
234 }
235}
236
237pub struct PuppetEventStream {
238 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
239}
240
241impl std::marker::Unpin for PuppetEventStream {}
242
243impl futures::stream::FusedStream for PuppetEventStream {
244 fn is_terminated(&self) -> bool {
245 self.event_receiver.is_terminated()
246 }
247}
248
249impl futures::Stream for PuppetEventStream {
250 type Item = Result<PuppetEvent, fidl::Error>;
251
252 fn poll_next(
253 mut self: std::pin::Pin<&mut Self>,
254 cx: &mut std::task::Context<'_>,
255 ) -> std::task::Poll<Option<Self::Item>> {
256 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
257 &mut self.event_receiver,
258 cx
259 )?) {
260 Some(buf) => std::task::Poll::Ready(Some(PuppetEvent::decode(buf))),
261 None => std::task::Poll::Ready(None),
262 }
263 }
264}
265
266#[derive(Debug)]
267pub enum PuppetEvent {}
268
269impl PuppetEvent {
270 fn decode(
272 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
273 ) -> Result<PuppetEvent, fidl::Error> {
274 let (bytes, _handles) = buf.split_mut();
275 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
276 debug_assert_eq!(tx_header.tx_id, 0);
277 match tx_header.ordinal {
278 _ => Err(fidl::Error::UnknownOrdinal {
279 ordinal: tx_header.ordinal,
280 protocol_name: <PuppetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
281 }),
282 }
283 }
284}
285
286pub struct PuppetRequestStream {
288 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
289 is_terminated: bool,
290}
291
292impl std::marker::Unpin for PuppetRequestStream {}
293
294impl futures::stream::FusedStream for PuppetRequestStream {
295 fn is_terminated(&self) -> bool {
296 self.is_terminated
297 }
298}
299
300impl fidl::endpoints::RequestStream for PuppetRequestStream {
301 type Protocol = PuppetMarker;
302 type ControlHandle = PuppetControlHandle;
303
304 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
305 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
306 }
307
308 fn control_handle(&self) -> Self::ControlHandle {
309 PuppetControlHandle { inner: self.inner.clone() }
310 }
311
312 fn into_inner(
313 self,
314 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
315 {
316 (self.inner, self.is_terminated)
317 }
318
319 fn from_inner(
320 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
321 is_terminated: bool,
322 ) -> Self {
323 Self { inner, is_terminated }
324 }
325}
326
327impl futures::Stream for PuppetRequestStream {
328 type Item = Result<PuppetRequest, fidl::Error>;
329
330 fn poll_next(
331 mut self: std::pin::Pin<&mut Self>,
332 cx: &mut std::task::Context<'_>,
333 ) -> std::task::Poll<Option<Self::Item>> {
334 let this = &mut *self;
335 if this.inner.check_shutdown(cx) {
336 this.is_terminated = true;
337 return std::task::Poll::Ready(None);
338 }
339 if this.is_terminated {
340 panic!("polled PuppetRequestStream after completion");
341 }
342 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
343 |bytes, handles| {
344 match this.inner.channel().read_etc(cx, bytes, handles) {
345 std::task::Poll::Ready(Ok(())) => {}
346 std::task::Poll::Pending => return std::task::Poll::Pending,
347 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
348 this.is_terminated = true;
349 return std::task::Poll::Ready(None);
350 }
351 std::task::Poll::Ready(Err(e)) => {
352 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
353 e.into(),
354 ))))
355 }
356 }
357
358 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
360
361 std::task::Poll::Ready(Some(match header.ordinal {
362 0x3fdf927c6e4c8c8d => {
363 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
364 let mut req = fidl::new_empty!(
365 fidl::encoding::EmptyPayload,
366 fidl::encoding::DefaultFuchsiaResourceDialect
367 );
368 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
369 let control_handle = PuppetControlHandle { inner: this.inner.clone() };
370 Ok(PuppetRequest::StartProfiling {
371 responder: PuppetStartProfilingResponder {
372 control_handle: std::mem::ManuallyDrop::new(control_handle),
373 tx_id: header.tx_id,
374 },
375 })
376 }
377 0x23347e09827a7087 => {
378 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
379 let mut req = fidl::new_empty!(
380 fidl::encoding::EmptyPayload,
381 fidl::encoding::DefaultFuchsiaResourceDialect
382 );
383 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
384 let control_handle = PuppetControlHandle { inner: this.inner.clone() };
385 Ok(PuppetRequest::StopProfiling {
386 responder: PuppetStopProfilingResponder {
387 control_handle: std::mem::ManuallyDrop::new(control_handle),
388 tx_id: header.tx_id,
389 },
390 })
391 }
392 0x679bdcc07c2f7065 => {
393 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
394 let mut req = fidl::new_empty!(
395 fidl::encoding::EmptyPayload,
396 fidl::encoding::DefaultFuchsiaResourceDialect
397 );
398 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
399 let control_handle = PuppetControlHandle { inner: this.inner.clone() };
400 Ok(PuppetRequest::RunProfiledFunction {
401 responder: PuppetRunProfiledFunctionResponder {
402 control_handle: std::mem::ManuallyDrop::new(control_handle),
403 tx_id: header.tx_id,
404 },
405 })
406 }
407 _ => Err(fidl::Error::UnknownOrdinal {
408 ordinal: header.ordinal,
409 protocol_name:
410 <PuppetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
411 }),
412 }))
413 },
414 )
415 }
416}
417
418#[derive(Debug)]
419pub enum PuppetRequest {
420 StartProfiling { responder: PuppetStartProfilingResponder },
421 StopProfiling { responder: PuppetStopProfilingResponder },
422 RunProfiledFunction { responder: PuppetRunProfiledFunctionResponder },
423}
424
425impl PuppetRequest {
426 #[allow(irrefutable_let_patterns)]
427 pub fn into_start_profiling(self) -> Option<(PuppetStartProfilingResponder)> {
428 if let PuppetRequest::StartProfiling { responder } = self {
429 Some((responder))
430 } else {
431 None
432 }
433 }
434
435 #[allow(irrefutable_let_patterns)]
436 pub fn into_stop_profiling(self) -> Option<(PuppetStopProfilingResponder)> {
437 if let PuppetRequest::StopProfiling { responder } = self {
438 Some((responder))
439 } else {
440 None
441 }
442 }
443
444 #[allow(irrefutable_let_patterns)]
445 pub fn into_run_profiled_function(self) -> Option<(PuppetRunProfiledFunctionResponder)> {
446 if let PuppetRequest::RunProfiledFunction { responder } = self {
447 Some((responder))
448 } else {
449 None
450 }
451 }
452
453 pub fn method_name(&self) -> &'static str {
455 match *self {
456 PuppetRequest::StartProfiling { .. } => "start_profiling",
457 PuppetRequest::StopProfiling { .. } => "stop_profiling",
458 PuppetRequest::RunProfiledFunction { .. } => "run_profiled_function",
459 }
460 }
461}
462
463#[derive(Debug, Clone)]
464pub struct PuppetControlHandle {
465 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
466}
467
468impl fidl::endpoints::ControlHandle for PuppetControlHandle {
469 fn shutdown(&self) {
470 self.inner.shutdown()
471 }
472 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
473 self.inner.shutdown_with_epitaph(status)
474 }
475
476 fn is_closed(&self) -> bool {
477 self.inner.channel().is_closed()
478 }
479 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
480 self.inner.channel().on_closed()
481 }
482
483 #[cfg(target_os = "fuchsia")]
484 fn signal_peer(
485 &self,
486 clear_mask: zx::Signals,
487 set_mask: zx::Signals,
488 ) -> Result<(), zx_status::Status> {
489 use fidl::Peered;
490 self.inner.channel().signal_peer(clear_mask, set_mask)
491 }
492}
493
494impl PuppetControlHandle {}
495
496#[must_use = "FIDL methods require a response to be sent"]
497#[derive(Debug)]
498pub struct PuppetStartProfilingResponder {
499 control_handle: std::mem::ManuallyDrop<PuppetControlHandle>,
500 tx_id: u32,
501}
502
503impl std::ops::Drop for PuppetStartProfilingResponder {
507 fn drop(&mut self) {
508 self.control_handle.shutdown();
509 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
511 }
512}
513
514impl fidl::endpoints::Responder for PuppetStartProfilingResponder {
515 type ControlHandle = PuppetControlHandle;
516
517 fn control_handle(&self) -> &PuppetControlHandle {
518 &self.control_handle
519 }
520
521 fn drop_without_shutdown(mut self) {
522 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
524 std::mem::forget(self);
526 }
527}
528
529impl PuppetStartProfilingResponder {
530 pub fn send(self) -> Result<(), fidl::Error> {
534 let _result = self.send_raw();
535 if _result.is_err() {
536 self.control_handle.shutdown();
537 }
538 self.drop_without_shutdown();
539 _result
540 }
541
542 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
544 let _result = self.send_raw();
545 self.drop_without_shutdown();
546 _result
547 }
548
549 fn send_raw(&self) -> Result<(), fidl::Error> {
550 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
551 (),
552 self.tx_id,
553 0x3fdf927c6e4c8c8d,
554 fidl::encoding::DynamicFlags::empty(),
555 )
556 }
557}
558
559#[must_use = "FIDL methods require a response to be sent"]
560#[derive(Debug)]
561pub struct PuppetStopProfilingResponder {
562 control_handle: std::mem::ManuallyDrop<PuppetControlHandle>,
563 tx_id: u32,
564}
565
566impl std::ops::Drop for PuppetStopProfilingResponder {
570 fn drop(&mut self) {
571 self.control_handle.shutdown();
572 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
574 }
575}
576
577impl fidl::endpoints::Responder for PuppetStopProfilingResponder {
578 type ControlHandle = PuppetControlHandle;
579
580 fn control_handle(&self) -> &PuppetControlHandle {
581 &self.control_handle
582 }
583
584 fn drop_without_shutdown(mut self) {
585 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
587 std::mem::forget(self);
589 }
590}
591
592impl PuppetStopProfilingResponder {
593 pub fn send(self) -> Result<(), fidl::Error> {
597 let _result = self.send_raw();
598 if _result.is_err() {
599 self.control_handle.shutdown();
600 }
601 self.drop_without_shutdown();
602 _result
603 }
604
605 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
607 let _result = self.send_raw();
608 self.drop_without_shutdown();
609 _result
610 }
611
612 fn send_raw(&self) -> Result<(), fidl::Error> {
613 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
614 (),
615 self.tx_id,
616 0x23347e09827a7087,
617 fidl::encoding::DynamicFlags::empty(),
618 )
619 }
620}
621
622#[must_use = "FIDL methods require a response to be sent"]
623#[derive(Debug)]
624pub struct PuppetRunProfiledFunctionResponder {
625 control_handle: std::mem::ManuallyDrop<PuppetControlHandle>,
626 tx_id: u32,
627}
628
629impl std::ops::Drop for PuppetRunProfiledFunctionResponder {
633 fn drop(&mut self) {
634 self.control_handle.shutdown();
635 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
637 }
638}
639
640impl fidl::endpoints::Responder for PuppetRunProfiledFunctionResponder {
641 type ControlHandle = PuppetControlHandle;
642
643 fn control_handle(&self) -> &PuppetControlHandle {
644 &self.control_handle
645 }
646
647 fn drop_without_shutdown(mut self) {
648 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
650 std::mem::forget(self);
652 }
653}
654
655impl PuppetRunProfiledFunctionResponder {
656 pub fn send(self) -> Result<(), fidl::Error> {
660 let _result = self.send_raw();
661 if _result.is_err() {
662 self.control_handle.shutdown();
663 }
664 self.drop_without_shutdown();
665 _result
666 }
667
668 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
670 let _result = self.send_raw();
671 self.drop_without_shutdown();
672 _result
673 }
674
675 fn send_raw(&self) -> Result<(), fidl::Error> {
676 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
677 (),
678 self.tx_id,
679 0x679bdcc07c2f7065,
680 fidl::encoding::DynamicFlags::empty(),
681 )
682 }
683}
684
685mod internal {
686 use super::*;
687}