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