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