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