Skip to main content

fidl_next_fuchsia_process_lifecycle/
fidl_next_fuchsia_process_lifecycle.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub mod natural {
6
7    pub use fidl_next_common_fuchsia_process_lifecycle::natural::*;
8
9    #[derive(Debug, Default, PartialEq)]
10    pub struct LifecycleOnEscrowRequest {
11        pub outgoing_dir: ::core::option::Option<
12            ::fidl_next::ServerEnd<
13                ::fidl_next_fuchsia_io::Directory,
14                ::fidl_next::fuchsia::zx::Channel,
15            >,
16        >,
17
18        pub escrowed_dictionary:
19            ::core::option::Option<::fidl_next_fuchsia_component_sandbox::natural::DictionaryRef>,
20
21        pub escrowed_dictionary_handle: ::core::option::Option<::fidl_next::fuchsia::zx::EventPair>,
22
23        pub recoverable_bytes: ::core::option::Option<u64>,
24    }
25
26    impl LifecycleOnEscrowRequest {
27        fn __max_ordinal(&self) -> usize {
28            if self.recoverable_bytes.is_some() {
29                return 4;
30            }
31
32            if self.escrowed_dictionary_handle.is_some() {
33                return 3;
34            }
35
36            if self.escrowed_dictionary.is_some() {
37                return 2;
38            }
39
40            if self.outgoing_dir.is_some() {
41                return 1;
42            }
43
44            0
45        }
46    }
47
48    unsafe impl<___E> ::fidl_next::Encode<crate::wire::LifecycleOnEscrowRequest<'static>, ___E>
49        for LifecycleOnEscrowRequest
50    where
51        ___E: ::fidl_next::Encoder + ?Sized,
52        ___E: ::fidl_next::fuchsia::HandleEncoder,
53    {
54        #[inline]
55        fn encode(
56            mut self,
57            encoder: &mut ___E,
58            out: &mut ::core::mem::MaybeUninit<crate::wire::LifecycleOnEscrowRequest<'static>>,
59            _: (),
60        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
61            ::fidl_next::munge!(let crate::wire::LifecycleOnEscrowRequest { table } = out);
62
63            let max_ord = self.__max_ordinal();
64
65            let mut out = ::core::mem::MaybeUninit::<::fidl_next::wire::Envelope>::uninit();
66            ::fidl_next::Wire::zero_padding(&mut out);
67
68            let mut preallocated = ::fidl_next::EncoderExt::preallocate::<
69                ::fidl_next::wire::Envelope,
70            >(encoder, max_ord);
71
72            for i in 1..=max_ord {
73                match i {
74                    4 => {
75                        if let Some(value) = self.recoverable_bytes.take() {
76                            ::fidl_next::wire::Envelope::encode_value::<
77                                ::fidl_next::wire::Uint64,
78                                ___E,
79                            >(
80                                value, preallocated.encoder, &mut out, ()
81                            )?;
82                        } else {
83                            ::fidl_next::wire::Envelope::encode_zero(&mut out)
84                        }
85                    }
86
87                    3 => {
88                        if let Some(value) = self.escrowed_dictionary_handle.take() {
89                            ::fidl_next::wire::Envelope::encode_value::<
90                                ::fidl_next::wire::fuchsia::EventPair,
91                                ___E,
92                            >(
93                                value, preallocated.encoder, &mut out, ()
94                            )?;
95                        } else {
96                            ::fidl_next::wire::Envelope::encode_zero(&mut out)
97                        }
98                    }
99
100                    2 => {
101                        if let Some(value) = self.escrowed_dictionary.take() {
102                            ::fidl_next::wire::Envelope::encode_value::<
103                                ::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef,
104                                ___E,
105                            >(
106                                value, preallocated.encoder, &mut out, ()
107                            )?;
108                        } else {
109                            ::fidl_next::wire::Envelope::encode_zero(&mut out)
110                        }
111                    }
112
113                    1 => {
114                        if let Some(value) = self.outgoing_dir.take() {
115                            ::fidl_next::wire::Envelope::encode_value::<
116                                ::fidl_next::ServerEnd<
117                                    ::fidl_next_fuchsia_io::Directory,
118                                    ::fidl_next::wire::fuchsia::Channel,
119                                >,
120                                ___E,
121                            >(
122                                value, preallocated.encoder, &mut out, ()
123                            )?;
124                        } else {
125                            ::fidl_next::wire::Envelope::encode_zero(&mut out)
126                        }
127                    }
128
129                    _ => ::fidl_next::wire::Envelope::encode_zero(&mut out),
130                }
131                unsafe {
132                    preallocated.write_next(out.assume_init_ref());
133                }
134            }
135
136            ::fidl_next::wire::Table::encode_len(table, max_ord);
137
138            Ok(())
139        }
140    }
141
142    impl<'de> ::fidl_next::FromWire<crate::wire::LifecycleOnEscrowRequest<'de>>
143        for LifecycleOnEscrowRequest
144    {
145        #[inline]
146        fn from_wire(wire_: crate::wire::LifecycleOnEscrowRequest<'de>) -> Self {
147            let wire_ = ::core::mem::ManuallyDrop::new(wire_);
148
149            let outgoing_dir = wire_.table.get(1);
150
151            let escrowed_dictionary = wire_.table.get(2);
152
153            let escrowed_dictionary_handle = wire_.table.get(3);
154
155            let recoverable_bytes = wire_.table.get(4);
156
157            Self {
158
159
160                outgoing_dir: outgoing_dir.map(|envelope| ::fidl_next::FromWire::from_wire(
161                    unsafe { envelope.read_unchecked::<::fidl_next::ServerEnd<::fidl_next_fuchsia_io::Directory, ::fidl_next::wire::fuchsia::Channel>>() }
162                )),
163
164
165                escrowed_dictionary: escrowed_dictionary.map(|envelope| ::fidl_next::FromWire::from_wire(
166                    unsafe { envelope.read_unchecked::<::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef>() }
167                )),
168
169
170                escrowed_dictionary_handle: escrowed_dictionary_handle.map(|envelope| ::fidl_next::FromWire::from_wire(
171                    unsafe { envelope.read_unchecked::<::fidl_next::wire::fuchsia::EventPair>() }
172                )),
173
174
175                recoverable_bytes: recoverable_bytes.map(|envelope| ::fidl_next::FromWire::from_wire(
176                    unsafe { envelope.read_unchecked::<::fidl_next::wire::Uint64>() }
177                )),
178
179        }
180        }
181    }
182}
183
184pub mod wire {
185
186    pub use fidl_next_common_fuchsia_process_lifecycle::wire::*;
187
188    /// The wire type corresponding to [`LifecycleOnEscrowRequest`].
189    #[repr(C)]
190    pub struct LifecycleOnEscrowRequest<'de> {
191        pub(crate) table: ::fidl_next::wire::Table<'de>,
192    }
193
194    impl<'de> Drop for LifecycleOnEscrowRequest<'de> {
195        fn drop(&mut self) {
196            let _ = self.table.get(1).map(|envelope| unsafe {
197                envelope.read_unchecked::<::fidl_next::ServerEnd<
198                    ::fidl_next_fuchsia_io::Directory,
199                    ::fidl_next::wire::fuchsia::Channel,
200                >>()
201            });
202
203            let _ = self.table.get(2)
204                .map(|envelope| unsafe {
205                    envelope.read_unchecked::<::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef>()
206                });
207
208            let _ = self.table.get(3).map(|envelope| unsafe {
209                envelope.read_unchecked::<::fidl_next::wire::fuchsia::EventPair>()
210            });
211
212            let _ = self
213                .table
214                .get(4)
215                .map(|envelope| unsafe { envelope.read_unchecked::<::fidl_next::wire::Uint64>() });
216        }
217    }
218
219    impl ::fidl_next::Constrained for LifecycleOnEscrowRequest<'_> {
220        type Constraint = ();
221
222        fn validate(
223            _: ::fidl_next::Slot<'_, Self>,
224            _: Self::Constraint,
225        ) -> Result<(), ::fidl_next::ValidationError> {
226            Ok(())
227        }
228    }
229
230    unsafe impl ::fidl_next::Wire for LifecycleOnEscrowRequest<'static> {
231        type Narrowed<'de> = LifecycleOnEscrowRequest<'de>;
232
233        #[inline]
234        fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
235            ::fidl_next::munge!(let Self { table } = out);
236            ::fidl_next::wire::Table::zero_padding(table);
237        }
238    }
239
240    unsafe impl<'de, ___D> ::fidl_next::Decode<___D> for LifecycleOnEscrowRequest<'de>
241    where
242        ___D: ::fidl_next::Decoder<'de> + ?Sized,
243        ___D: ::fidl_next::fuchsia::HandleDecoder,
244    {
245        fn decode(
246            slot: ::fidl_next::Slot<'_, Self>,
247            decoder: &mut ___D,
248            _: (),
249        ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
250            ::fidl_next::munge!(let Self { table } = slot);
251
252            ::fidl_next::wire::Table::decode_with(table, decoder, |ordinal, mut slot, decoder| {
253                match ordinal {
254                    0 => unsafe { ::core::hint::unreachable_unchecked() },
255
256                    1 => {
257                        ::fidl_next::wire::Envelope::decode_as::<
258                            ___D,
259                            ::fidl_next::ServerEnd<
260                                ::fidl_next_fuchsia_io::Directory,
261                                ::fidl_next::wire::fuchsia::Channel,
262                            >,
263                        >(slot.as_mut(), decoder, ())?;
264
265                        Ok(())
266                    }
267
268                    2 => {
269                        ::fidl_next::wire::Envelope::decode_as::<
270                            ___D,
271                            ::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef,
272                        >(slot.as_mut(), decoder, ())?;
273
274                        Ok(())
275                    }
276
277                    3 => {
278                        ::fidl_next::wire::Envelope::decode_as::<
279                            ___D,
280                            ::fidl_next::wire::fuchsia::EventPair,
281                        >(slot.as_mut(), decoder, ())?;
282
283                        Ok(())
284                    }
285
286                    4 => {
287                        ::fidl_next::wire::Envelope::decode_as::<___D, ::fidl_next::wire::Uint64>(
288                            slot.as_mut(),
289                            decoder,
290                            (),
291                        )?;
292
293                        Ok(())
294                    }
295
296                    _ => ::fidl_next::wire::Envelope::decode_unknown(slot, decoder),
297                }
298            })
299        }
300    }
301
302    impl<'de> LifecycleOnEscrowRequest<'de> {
303        pub fn outgoing_dir(
304            &self,
305        ) -> ::core::option::Option<
306            &::fidl_next::ServerEnd<
307                ::fidl_next_fuchsia_io::Directory,
308                ::fidl_next::wire::fuchsia::Channel,
309            >,
310        > {
311            unsafe { Some(self.table.get(1)?.deref_unchecked()) }
312        }
313
314        pub fn take_outgoing_dir(
315            &mut self,
316        ) -> ::core::option::Option<
317            ::fidl_next::ServerEnd<
318                ::fidl_next_fuchsia_io::Directory,
319                ::fidl_next::wire::fuchsia::Channel,
320            >,
321        > {
322            unsafe { Some(self.table.get_mut(1)?.take_unchecked()) }
323        }
324
325        pub fn escrowed_dictionary(
326            &self,
327        ) -> ::core::option::Option<&::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef>
328        {
329            unsafe { Some(self.table.get(2)?.deref_unchecked()) }
330        }
331
332        pub fn take_escrowed_dictionary(
333            &mut self,
334        ) -> ::core::option::Option<::fidl_next_fuchsia_component_sandbox::wire::DictionaryRef>
335        {
336            unsafe { Some(self.table.get_mut(2)?.take_unchecked()) }
337        }
338
339        pub fn escrowed_dictionary_handle(
340            &self,
341        ) -> ::core::option::Option<&::fidl_next::wire::fuchsia::EventPair> {
342            unsafe { Some(self.table.get(3)?.deref_unchecked()) }
343        }
344
345        pub fn take_escrowed_dictionary_handle(
346            &mut self,
347        ) -> ::core::option::Option<::fidl_next::wire::fuchsia::EventPair> {
348            unsafe { Some(self.table.get_mut(3)?.take_unchecked()) }
349        }
350
351        pub fn recoverable_bytes(&self) -> ::core::option::Option<&::fidl_next::wire::Uint64> {
352            unsafe { Some(self.table.get(4)?.deref_unchecked()) }
353        }
354
355        pub fn take_recoverable_bytes(
356            &mut self,
357        ) -> ::core::option::Option<::fidl_next::wire::Uint64> {
358            unsafe { Some(self.table.get_mut(4)?.take_unchecked()) }
359        }
360    }
361
362    impl<'de> ::core::fmt::Debug for LifecycleOnEscrowRequest<'de> {
363        fn fmt(
364            &self,
365            f: &mut ::core::fmt::Formatter<'_>,
366        ) -> ::core::result::Result<(), ::core::fmt::Error> {
367            f.debug_struct("LifecycleOnEscrowRequest")
368                .field("outgoing_dir", &self.outgoing_dir())
369                .field("escrowed_dictionary", &self.escrowed_dictionary())
370                .field("escrowed_dictionary_handle", &self.escrowed_dictionary_handle())
371                .field("recoverable_bytes", &self.recoverable_bytes())
372                .finish()
373        }
374    }
375
376    impl<'de> ::fidl_next::IntoNatural for LifecycleOnEscrowRequest<'de> {
377        type Natural = crate::natural::LifecycleOnEscrowRequest;
378    }
379}
380
381pub mod wire_optional {
382
383    pub use fidl_next_common_fuchsia_process_lifecycle::wire_optional::*;
384}
385
386pub mod generic {
387
388    pub use fidl_next_common_fuchsia_process_lifecycle::generic::*;
389}
390
391pub use self::natural::*;
392
393/// The type corresponding to the Lifecycle protocol.
394#[doc = " A component can implement the Lifecycle protocol to be notified of lifecycle\n events. It can also store some state in the framework, to be redelivered to\n the component the next time it is started (a practice called \"escrowing\").\n\n The ELF Runner uses this protocol to communicate lifecycle changes\n to the component, for more details on how it uses this protocol see:\n https://fuchsia.dev/fuchsia-src/concepts/components/v2/elf_runner#lifecycle\n"]
395#[derive(PartialEq, Debug)]
396pub struct Lifecycle;
397
398#[cfg(target_os = "fuchsia")]
399impl ::fidl_next::HasTransport for Lifecycle {
400    type Transport = ::fidl_next::fuchsia::zx::Channel;
401}
402
403pub mod lifecycle {
404    pub mod prelude {
405        pub use crate::{
406            Lifecycle, LifecycleClientHandler, LifecycleLocalClientHandler,
407            LifecycleLocalServerHandler, LifecycleServerHandler, lifecycle,
408        };
409
410        pub use crate::natural::LifecycleOnEscrowRequest;
411    }
412
413    pub struct Stop;
414
415    impl ::fidl_next::Method for Stop {
416        const ORDINAL: u64 = 7255711254080941845;
417        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
418            ::fidl_next::protocol::Flexibility::Strict;
419
420        type Protocol = crate::Lifecycle;
421
422        type Request = ::fidl_next::wire::EmptyMessageBody;
423    }
424
425    pub struct OnEscrow;
426
427    impl ::fidl_next::Method for OnEscrow {
428        const ORDINAL: u64 = 4461311296548433224;
429        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
430            ::fidl_next::protocol::Flexibility::Strict;
431
432        type Protocol = crate::Lifecycle;
433
434        type Request = crate::wire::LifecycleOnEscrowRequest<'static>;
435    }
436
437    mod ___detail {
438        unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Lifecycle
439        where
440            ___T: ::fidl_next::Transport,
441        {
442            type Client = LifecycleClient<___T>;
443            type Server = LifecycleServer<___T>;
444        }
445
446        /// The client for the `Lifecycle` protocol.
447        #[repr(transparent)]
448        pub struct LifecycleClient<___T: ::fidl_next::Transport> {
449            #[allow(dead_code)]
450            client: ::fidl_next::protocol::Client<___T>,
451        }
452
453        impl<___T> LifecycleClient<___T>
454        where
455            ___T: ::fidl_next::Transport,
456        {
457            #[doc = " The process must clean up its state in preparation for termination, and\n must close the channel hosting the `Lifecycle` protocol when it is\n ready to be terminated. The process should exit after it completes its\n cleanup. At the discretion of the system the process may be terminated\n before it closes the `Lifecycle` channel.\n"]
458            pub fn stop(&self) -> ::fidl_next::SendFuture<'_, ___T> {
459                ::fidl_next::SendFuture::from_untyped(
460                    self.client.send_one_way::<::fidl_next::wire::EmptyMessageBody>(
461                        7255711254080941845,
462                        <super::Stop as ::fidl_next::Method>::FLEXIBILITY,
463                        (),
464                    ),
465                )
466            }
467        }
468
469        /// The server for the `Lifecycle` protocol.
470        #[repr(transparent)]
471        pub struct LifecycleServer<___T: ::fidl_next::Transport> {
472            server: ::fidl_next::protocol::Server<___T>,
473        }
474
475        impl<___T> LifecycleServer<___T>
476        where
477            ___T: ::fidl_next::Transport,
478        {
479            #[doc = " Escrow state shortly before the component exits.\n\n When the ELF runner receives this event, it will arrange with the\n framework to wait until the current execution of the component has\n finished, then start the component again when the `ZX_CHANNEL_READABLE`\n signal is observed on `outgoing_dir`.\n\n Repeated calls will replace the old escrowed value. This is discouraged.\n\n Handles escrowed via `OnEscrow` are always delivered to the next\n execution of the component.\n"]
480
481            pub fn on_escrow_with<___R>(&self, request: ___R) -> ::fidl_next::SendFuture<'_, ___T>
482            where
483                ___R: ::fidl_next::Encode<
484                        <super::OnEscrow as ::fidl_next::Method>::Request,
485                        <___T as ::fidl_next::Transport>::SendBuffer,
486                    >,
487            {
488                ::fidl_next::SendFuture::from_untyped(self.server.send_event(
489                    4461311296548433224,
490                    <super::OnEscrow as ::fidl_next::Method>::FLEXIBILITY,
491                    request,
492                ))
493            }
494        }
495    }
496}
497
498#[diagnostic::on_unimplemented(
499    note = "If {Self} implements the non-local LifecycleClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
500)]
501
502/// A client handler for the Lifecycle protocol.
503///
504/// See [`Lifecycle`] for more details.
505pub trait LifecycleLocalClientHandler<
506    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
507    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
508>
509{
510    #[doc = " Escrow state shortly before the component exits.\n\n When the ELF runner receives this event, it will arrange with the\n framework to wait until the current execution of the component has\n finished, then start the component again when the `ZX_CHANNEL_READABLE`\n signal is observed on `outgoing_dir`.\n\n Repeated calls will replace the old escrowed value. This is discouraged.\n\n Handles escrowed via `OnEscrow` are always delivered to the next\n execution of the component.\n"]
511    fn on_escrow(
512        &mut self,
513
514        request: ::fidl_next::Request<lifecycle::OnEscrow, ___T>,
515    ) -> impl ::core::future::Future<Output = ()>;
516}
517
518impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Lifecycle
519where
520    ___H: LifecycleLocalClientHandler<___T>,
521    ___T: ::fidl_next::Transport,
522    for<'de> crate::wire::LifecycleOnEscrowRequest<'de>: ::fidl_next::Decode<
523            <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
524            Constraint = (),
525        >,
526{
527    async fn on_event(
528        handler: &mut ___H,
529        mut message: ::fidl_next::Message<___T>,
530    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
531        match *message.header().ordinal {
532            4461311296548433224 => match ::fidl_next::AsDecoderExt::into_decoded(message) {
533                Ok(decoded) => {
534                    handler.on_escrow(::fidl_next::Request::from_decoded(decoded)).await;
535                    Ok(())
536                }
537                Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
538                    ordinal: 4461311296548433224,
539                    error,
540                }),
541            },
542
543            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
544        }
545    }
546}
547
548#[diagnostic::on_unimplemented(
549    note = "If {Self} implements the non-local LifecycleServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
550)]
551
552/// A server handler for the Lifecycle protocol.
553///
554/// See [`Lifecycle`] for more details.
555pub trait LifecycleLocalServerHandler<
556    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
557    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
558>
559{
560    #[doc = " The process must clean up its state in preparation for termination, and\n must close the channel hosting the `Lifecycle` protocol when it is\n ready to be terminated. The process should exit after it completes its\n cleanup. At the discretion of the system the process may be terminated\n before it closes the `Lifecycle` channel.\n"]
561    fn stop(&mut self) -> impl ::core::future::Future<Output = ()>;
562}
563
564impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Lifecycle
565where
566    ___H: LifecycleLocalServerHandler<___T>,
567    ___T: ::fidl_next::Transport,
568{
569    async fn on_one_way(
570        handler: &mut ___H,
571        mut message: ::fidl_next::Message<___T>,
572    ) -> ::core::result::Result<
573        (),
574        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
575    > {
576        match *message.header().ordinal {
577            7255711254080941845 => {
578                handler.stop().await;
579                Ok(())
580            }
581
582            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
583        }
584    }
585
586    async fn on_two_way(
587        handler: &mut ___H,
588        mut message: ::fidl_next::Message<___T>,
589        responder: ::fidl_next::protocol::Responder<___T>,
590    ) -> ::core::result::Result<
591        (),
592        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
593    > {
594        match *message.header().ordinal {
595            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
596        }
597    }
598}
599
600/// A client handler for the Lifecycle protocol.
601///
602/// See [`Lifecycle`] for more details.
603pub trait LifecycleClientHandler<
604    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
605    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
606>
607{
608    #[doc = " Escrow state shortly before the component exits.\n\n When the ELF runner receives this event, it will arrange with the\n framework to wait until the current execution of the component has\n finished, then start the component again when the `ZX_CHANNEL_READABLE`\n signal is observed on `outgoing_dir`.\n\n Repeated calls will replace the old escrowed value. This is discouraged.\n\n Handles escrowed via `OnEscrow` are always delivered to the next\n execution of the component.\n"]
609    fn on_escrow(
610        &mut self,
611
612        request: ::fidl_next::Request<lifecycle::OnEscrow, ___T>,
613    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
614}
615
616impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Lifecycle
617where
618    ___H: LifecycleClientHandler<___T> + ::core::marker::Send,
619    ___T: ::fidl_next::Transport,
620    for<'de> crate::wire::LifecycleOnEscrowRequest<'de>: ::fidl_next::Decode<
621            <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
622            Constraint = (),
623        >,
624{
625    async fn on_event(
626        handler: &mut ___H,
627        mut message: ::fidl_next::Message<___T>,
628    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
629        match *message.header().ordinal {
630            4461311296548433224 => match ::fidl_next::AsDecoderExt::into_decoded(message) {
631                Ok(decoded) => {
632                    handler.on_escrow(::fidl_next::Request::from_decoded(decoded)).await;
633                    Ok(())
634                }
635                Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
636                    ordinal: 4461311296548433224,
637                    error,
638                }),
639            },
640
641            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
642        }
643    }
644}
645
646/// A server handler for the Lifecycle protocol.
647///
648/// See [`Lifecycle`] for more details.
649pub trait LifecycleServerHandler<
650    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
651    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
652>
653{
654    #[doc = " The process must clean up its state in preparation for termination, and\n must close the channel hosting the `Lifecycle` protocol when it is\n ready to be terminated. The process should exit after it completes its\n cleanup. At the discretion of the system the process may be terminated\n before it closes the `Lifecycle` channel.\n"]
655    fn stop(&mut self) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
656}
657
658impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Lifecycle
659where
660    ___H: LifecycleServerHandler<___T> + ::core::marker::Send,
661    ___T: ::fidl_next::Transport,
662{
663    async fn on_one_way(
664        handler: &mut ___H,
665        mut message: ::fidl_next::Message<___T>,
666    ) -> ::core::result::Result<
667        (),
668        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
669    > {
670        match *message.header().ordinal {
671            7255711254080941845 => {
672                handler.stop().await;
673                Ok(())
674            }
675
676            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
677        }
678    }
679
680    async fn on_two_way(
681        handler: &mut ___H,
682        mut message: ::fidl_next::Message<___T>,
683        responder: ::fidl_next::protocol::Responder<___T>,
684    ) -> ::core::result::Result<
685        (),
686        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
687    > {
688        match *message.header().ordinal {
689            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
690        }
691    }
692}
693
694impl<___T> LifecycleClientHandler<___T> for ::fidl_next::IgnoreEvents
695where
696    ___T: ::fidl_next::Transport,
697{
698    async fn on_escrow(&mut self, _: ::fidl_next::Request<lifecycle::OnEscrow, ___T>) {}
699}
700
701impl<___H, ___T> LifecycleLocalClientHandler<___T> for ::fidl_next::Local<___H>
702where
703    ___H: LifecycleClientHandler<___T>,
704    ___T: ::fidl_next::Transport,
705{
706    async fn on_escrow(&mut self, request: ::fidl_next::Request<lifecycle::OnEscrow, ___T>) {
707        ___H::on_escrow(&mut self.0, request).await
708    }
709}
710
711impl<___H, ___T> LifecycleLocalServerHandler<___T> for ::fidl_next::Local<___H>
712where
713    ___H: LifecycleServerHandler<___T>,
714    ___T: ::fidl_next::Transport,
715{
716    async fn stop(&mut self) {
717        ___H::stop(&mut self.0).await
718    }
719}
720
721pub use fidl_next_common_fuchsia_process_lifecycle::*;