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