fidl_inspect_selfprofile_test/
fidl_inspect_selfprofile_test.rs

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