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 fidl::endpoints::ControlHandle for DeviceControlHandle {
546    fn shutdown(&self) {
547        self.inner.shutdown()
548    }
549
550    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
551        self.inner.shutdown_with_epitaph(status)
552    }
553
554    fn is_closed(&self) -> bool {
555        self.inner.channel().is_closed()
556    }
557    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
558        self.inner.channel().on_closed()
559    }
560
561    #[cfg(target_os = "fuchsia")]
562    fn signal_peer(
563        &self,
564        clear_mask: zx::Signals,
565        set_mask: zx::Signals,
566    ) -> Result<(), zx_status::Status> {
567        use fidl::Peered;
568        self.inner.channel().signal_peer(clear_mask, set_mask)
569    }
570}
571
572impl DeviceControlHandle {}
573
574#[must_use = "FIDL methods require a response to be sent"]
575#[derive(Debug)]
576pub struct DeviceSetSuspendStatesResponder {
577    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
578    tx_id: u32,
579}
580
581/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
582/// if the responder is dropped without sending a response, so that the client
583/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
584impl std::ops::Drop for DeviceSetSuspendStatesResponder {
585    fn drop(&mut self) {
586        self.control_handle.shutdown();
587        // Safety: drops once, never accessed again
588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
589    }
590}
591
592impl fidl::endpoints::Responder for DeviceSetSuspendStatesResponder {
593    type ControlHandle = DeviceControlHandle;
594
595    fn control_handle(&self) -> &DeviceControlHandle {
596        &self.control_handle
597    }
598
599    fn drop_without_shutdown(mut self) {
600        // Safety: drops once, never accessed again due to mem::forget
601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
602        // Prevent Drop from running (which would shut down the channel)
603        std::mem::forget(self);
604    }
605}
606
607impl DeviceSetSuspendStatesResponder {
608    /// Sends a response to the FIDL transaction.
609    ///
610    /// Sets the channel to shutdown if an error occurs.
611    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
612        let _result = self.send_raw(result);
613        if _result.is_err() {
614            self.control_handle.shutdown();
615        }
616        self.drop_without_shutdown();
617        _result
618    }
619
620    /// Similar to "send" but does not shutdown the channel if an error occurs.
621    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
622        let _result = self.send_raw(result);
623        self.drop_without_shutdown();
624        _result
625    }
626
627    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
628        self.control_handle
629            .inner
630            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
631                result,
632                self.tx_id,
633                0x3d37a51c2955e852,
634                fidl::encoding::DynamicFlags::empty(),
635            )
636    }
637}
638
639#[must_use = "FIDL methods require a response to be sent"]
640#[derive(Debug)]
641pub struct DeviceAwaitSuspendResponder {
642    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
643    tx_id: u32,
644}
645
646/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
647/// if the responder is dropped without sending a response, so that the client
648/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
649impl std::ops::Drop for DeviceAwaitSuspendResponder {
650    fn drop(&mut self) {
651        self.control_handle.shutdown();
652        // Safety: drops once, never accessed again
653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
654    }
655}
656
657impl fidl::endpoints::Responder for DeviceAwaitSuspendResponder {
658    type ControlHandle = DeviceControlHandle;
659
660    fn control_handle(&self) -> &DeviceControlHandle {
661        &self.control_handle
662    }
663
664    fn drop_without_shutdown(mut self) {
665        // Safety: drops once, never accessed again due to mem::forget
666        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
667        // Prevent Drop from running (which would shut down the channel)
668        std::mem::forget(self);
669    }
670}
671
672impl DeviceAwaitSuspendResponder {
673    /// Sends a response to the FIDL transaction.
674    ///
675    /// Sets the channel to shutdown if an error occurs.
676    pub fn send(
677        self,
678        mut result: Result<&DeviceAwaitSuspendResponse, i32>,
679    ) -> Result<(), fidl::Error> {
680        let _result = self.send_raw(result);
681        if _result.is_err() {
682            self.control_handle.shutdown();
683        }
684        self.drop_without_shutdown();
685        _result
686    }
687
688    /// Similar to "send" but does not shutdown the channel if an error occurs.
689    pub fn send_no_shutdown_on_err(
690        self,
691        mut result: Result<&DeviceAwaitSuspendResponse, i32>,
692    ) -> Result<(), fidl::Error> {
693        let _result = self.send_raw(result);
694        self.drop_without_shutdown();
695        _result
696    }
697
698    fn send_raw(
699        &self,
700        mut result: Result<&DeviceAwaitSuspendResponse, i32>,
701    ) -> Result<(), fidl::Error> {
702        self.control_handle
703            .inner
704            .send::<fidl::encoding::ResultType<DeviceAwaitSuspendResponse, i32>>(
705                result,
706                self.tx_id,
707                0x7eb0d662063b347e,
708                fidl::encoding::DynamicFlags::empty(),
709            )
710    }
711}
712
713#[must_use = "FIDL methods require a response to be sent"]
714#[derive(Debug)]
715pub struct DeviceResumeResponder {
716    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
717    tx_id: u32,
718}
719
720/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
721/// if the responder is dropped without sending a response, so that the client
722/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
723impl std::ops::Drop for DeviceResumeResponder {
724    fn drop(&mut self) {
725        self.control_handle.shutdown();
726        // Safety: drops once, never accessed again
727        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
728    }
729}
730
731impl fidl::endpoints::Responder for DeviceResumeResponder {
732    type ControlHandle = DeviceControlHandle;
733
734    fn control_handle(&self) -> &DeviceControlHandle {
735        &self.control_handle
736    }
737
738    fn drop_without_shutdown(mut self) {
739        // Safety: drops once, never accessed again due to mem::forget
740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
741        // Prevent Drop from running (which would shut down the channel)
742        std::mem::forget(self);
743    }
744}
745
746impl DeviceResumeResponder {
747    /// Sends a response to the FIDL transaction.
748    ///
749    /// Sets the channel to shutdown if an error occurs.
750    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
751        let _result = self.send_raw(result);
752        if _result.is_err() {
753            self.control_handle.shutdown();
754        }
755        self.drop_without_shutdown();
756        _result
757    }
758
759    /// Similar to "send" but does not shutdown the channel if an error occurs.
760    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
761        let _result = self.send_raw(result);
762        self.drop_without_shutdown();
763        _result
764    }
765
766    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
767        self.control_handle
768            .inner
769            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
770                result,
771                self.tx_id,
772                0x2deb813cfe9b881e,
773                fidl::encoding::DynamicFlags::empty(),
774            )
775    }
776}
777
778mod internal {
779    use super::*;
780}