Skip to main content

fidl_fuchsia_system_state/
fidl_fuchsia_system_state.rs

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