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