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 fidl::endpoints::ControlHandle for SystemStateTransitionControlHandle {
509    fn shutdown(&self) {
510        self.inner.shutdown()
511    }
512
513    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
514        self.inner.shutdown_with_epitaph(status)
515    }
516
517    fn is_closed(&self) -> bool {
518        self.inner.channel().is_closed()
519    }
520    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
521        self.inner.channel().on_closed()
522    }
523
524    #[cfg(target_os = "fuchsia")]
525    fn signal_peer(
526        &self,
527        clear_mask: zx::Signals,
528        set_mask: zx::Signals,
529    ) -> Result<(), zx_status::Status> {
530        use fidl::Peered;
531        self.inner.channel().signal_peer(clear_mask, set_mask)
532    }
533}
534
535impl SystemStateTransitionControlHandle {}
536
537#[must_use = "FIDL methods require a response to be sent"]
538#[derive(Debug)]
539pub struct SystemStateTransitionGetTerminationSystemStateResponder {
540    control_handle: std::mem::ManuallyDrop<SystemStateTransitionControlHandle>,
541    tx_id: u32,
542}
543
544/// Set the the channel to be shutdown (see [`SystemStateTransitionControlHandle::shutdown`])
545/// if the responder is dropped without sending a response, so that the client
546/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
547impl std::ops::Drop for SystemStateTransitionGetTerminationSystemStateResponder {
548    fn drop(&mut self) {
549        self.control_handle.shutdown();
550        // Safety: drops once, never accessed again
551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
552    }
553}
554
555impl fidl::endpoints::Responder for SystemStateTransitionGetTerminationSystemStateResponder {
556    type ControlHandle = SystemStateTransitionControlHandle;
557
558    fn control_handle(&self) -> &SystemStateTransitionControlHandle {
559        &self.control_handle
560    }
561
562    fn drop_without_shutdown(mut self) {
563        // Safety: drops once, never accessed again due to mem::forget
564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565        // Prevent Drop from running (which would shut down the channel)
566        std::mem::forget(self);
567    }
568}
569
570impl SystemStateTransitionGetTerminationSystemStateResponder {
571    /// Sends a response to the FIDL transaction.
572    ///
573    /// Sets the channel to shutdown if an error occurs.
574    pub fn send(self, mut state: SystemPowerState) -> Result<(), fidl::Error> {
575        let _result = self.send_raw(state);
576        if _result.is_err() {
577            self.control_handle.shutdown();
578        }
579        self.drop_without_shutdown();
580        _result
581    }
582
583    /// Similar to "send" but does not shutdown the channel if an error occurs.
584    pub fn send_no_shutdown_on_err(self, mut state: SystemPowerState) -> Result<(), fidl::Error> {
585        let _result = self.send_raw(state);
586        self.drop_without_shutdown();
587        _result
588    }
589
590    fn send_raw(&self, mut state: SystemPowerState) -> Result<(), fidl::Error> {
591        self.control_handle.inner.send::<SystemStateTransitionGetTerminationSystemStateResponse>(
592            (state,),
593            self.tx_id,
594            0x7570e8c601c5e27e,
595            fidl::encoding::DynamicFlags::empty(),
596        )
597    }
598}
599
600#[must_use = "FIDL methods require a response to be sent"]
601#[derive(Debug)]
602pub struct SystemStateTransitionGetMexecZbisResponder {
603    control_handle: std::mem::ManuallyDrop<SystemStateTransitionControlHandle>,
604    tx_id: u32,
605}
606
607/// Set the the channel to be shutdown (see [`SystemStateTransitionControlHandle::shutdown`])
608/// if the responder is dropped without sending a response, so that the client
609/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
610impl std::ops::Drop for SystemStateTransitionGetMexecZbisResponder {
611    fn drop(&mut self) {
612        self.control_handle.shutdown();
613        // Safety: drops once, never accessed again
614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
615    }
616}
617
618impl fidl::endpoints::Responder for SystemStateTransitionGetMexecZbisResponder {
619    type ControlHandle = SystemStateTransitionControlHandle;
620
621    fn control_handle(&self) -> &SystemStateTransitionControlHandle {
622        &self.control_handle
623    }
624
625    fn drop_without_shutdown(mut self) {
626        // Safety: drops once, never accessed again due to mem::forget
627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
628        // Prevent Drop from running (which would shut down the channel)
629        std::mem::forget(self);
630    }
631}
632
633impl SystemStateTransitionGetMexecZbisResponder {
634    /// Sends a response to the FIDL transaction.
635    ///
636    /// Sets the channel to shutdown if an error occurs.
637    pub fn send(self, mut result: Result<(fidl::Vmo, fidl::Vmo), i32>) -> Result<(), fidl::Error> {
638        let _result = self.send_raw(result);
639        if _result.is_err() {
640            self.control_handle.shutdown();
641        }
642        self.drop_without_shutdown();
643        _result
644    }
645
646    /// Similar to "send" but does not shutdown the channel if an error occurs.
647    pub fn send_no_shutdown_on_err(
648        self,
649        mut result: Result<(fidl::Vmo, fidl::Vmo), i32>,
650    ) -> Result<(), fidl::Error> {
651        let _result = self.send_raw(result);
652        self.drop_without_shutdown();
653        _result
654    }
655
656    fn send_raw(&self, mut result: Result<(fidl::Vmo, fidl::Vmo), i32>) -> Result<(), fidl::Error> {
657        self.control_handle.inner.send::<fidl::encoding::ResultType<
658            SystemStateTransitionGetMexecZbisResponse,
659            i32,
660        >>(
661            result,
662            self.tx_id,
663            0x4d5efe452f310fef,
664            fidl::encoding::DynamicFlags::empty(),
665        )
666    }
667}
668
669mod internal {
670    use super::*;
671
672    impl fidl::encoding::ResourceTypeMarker for SystemStateTransitionGetMexecZbisResponse {
673        type Borrowed<'a> = &'a mut Self;
674        fn take_or_borrow<'a>(
675            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
676        ) -> Self::Borrowed<'a> {
677            value
678        }
679    }
680
681    unsafe impl fidl::encoding::TypeMarker for SystemStateTransitionGetMexecZbisResponse {
682        type Owned = Self;
683
684        #[inline(always)]
685        fn inline_align(_context: fidl::encoding::Context) -> usize {
686            4
687        }
688
689        #[inline(always)]
690        fn inline_size(_context: fidl::encoding::Context) -> usize {
691            8
692        }
693    }
694
695    unsafe impl
696        fidl::encoding::Encode<
697            SystemStateTransitionGetMexecZbisResponse,
698            fidl::encoding::DefaultFuchsiaResourceDialect,
699        > for &mut SystemStateTransitionGetMexecZbisResponse
700    {
701        #[inline]
702        unsafe fn encode(
703            self,
704            encoder: &mut fidl::encoding::Encoder<
705                '_,
706                fidl::encoding::DefaultFuchsiaResourceDialect,
707            >,
708            offset: usize,
709            _depth: fidl::encoding::Depth,
710        ) -> fidl::Result<()> {
711            encoder.debug_check_bounds::<SystemStateTransitionGetMexecZbisResponse>(offset);
712            // Delegate to tuple encoding.
713            fidl::encoding::Encode::<
714                SystemStateTransitionGetMexecZbisResponse,
715                fidl::encoding::DefaultFuchsiaResourceDialect,
716            >::encode(
717                (
718                    <fidl::encoding::HandleType<
719                        fidl::Vmo,
720                        { fidl::ObjectType::VMO.into_raw() },
721                        2147483648,
722                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
723                        &mut self.kernel_zbi
724                    ),
725                    <fidl::encoding::HandleType<
726                        fidl::Vmo,
727                        { fidl::ObjectType::VMO.into_raw() },
728                        2147483648,
729                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
730                        &mut self.data_zbi
731                    ),
732                ),
733                encoder,
734                offset,
735                _depth,
736            )
737        }
738    }
739    unsafe impl<
740        T0: fidl::encoding::Encode<
741                fidl::encoding::HandleType<
742                    fidl::Vmo,
743                    { fidl::ObjectType::VMO.into_raw() },
744                    2147483648,
745                >,
746                fidl::encoding::DefaultFuchsiaResourceDialect,
747            >,
748        T1: fidl::encoding::Encode<
749                fidl::encoding::HandleType<
750                    fidl::Vmo,
751                    { fidl::ObjectType::VMO.into_raw() },
752                    2147483648,
753                >,
754                fidl::encoding::DefaultFuchsiaResourceDialect,
755            >,
756    >
757        fidl::encoding::Encode<
758            SystemStateTransitionGetMexecZbisResponse,
759            fidl::encoding::DefaultFuchsiaResourceDialect,
760        > for (T0, T1)
761    {
762        #[inline]
763        unsafe fn encode(
764            self,
765            encoder: &mut fidl::encoding::Encoder<
766                '_,
767                fidl::encoding::DefaultFuchsiaResourceDialect,
768            >,
769            offset: usize,
770            depth: fidl::encoding::Depth,
771        ) -> fidl::Result<()> {
772            encoder.debug_check_bounds::<SystemStateTransitionGetMexecZbisResponse>(offset);
773            // Zero out padding regions. There's no need to apply masks
774            // because the unmasked parts will be overwritten by fields.
775            // Write the fields.
776            self.0.encode(encoder, offset + 0, depth)?;
777            self.1.encode(encoder, offset + 4, depth)?;
778            Ok(())
779        }
780    }
781
782    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
783        for SystemStateTransitionGetMexecZbisResponse
784    {
785        #[inline(always)]
786        fn new_empty() -> Self {
787            Self {
788                kernel_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
789                data_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
790            }
791        }
792
793        #[inline]
794        unsafe fn decode(
795            &mut self,
796            decoder: &mut fidl::encoding::Decoder<
797                '_,
798                fidl::encoding::DefaultFuchsiaResourceDialect,
799            >,
800            offset: usize,
801            _depth: fidl::encoding::Depth,
802        ) -> fidl::Result<()> {
803            decoder.debug_check_bounds::<Self>(offset);
804            // Verify that padding bytes are zero.
805            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.kernel_zbi, decoder, offset + 0, _depth)?;
806            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data_zbi, decoder, offset + 4, _depth)?;
807            Ok(())
808        }
809    }
810}