Skip to main content

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