fidl_fuchsia_session/
fidl_fuchsia_session.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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// An error that occurs when launching a session.
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub enum LaunchError {
16    /// The session's `LaunchConfiguration` is malformed.
17    InvalidArgs,
18    /// There was an error resolving the session's component URL.
19    NotFound,
20    /// The session component could not be destroyed.
21    DestroyComponentFailed,
22    /// The session component could not be created.
23    CreateComponentFailed,
24    #[doc(hidden)]
25    __SourceBreaking { unknown_ordinal: u32 },
26}
27
28/// Pattern that matches an unknown `LaunchError` member.
29#[macro_export]
30macro_rules! LaunchErrorUnknown {
31    () => {
32        _
33    };
34}
35
36impl LaunchError {
37    #[inline]
38    pub fn from_primitive(prim: u32) -> Option<Self> {
39        match prim {
40            1 => Some(Self::InvalidArgs),
41            2 => Some(Self::NotFound),
42            3 => Some(Self::DestroyComponentFailed),
43            4 => Some(Self::CreateComponentFailed),
44            _ => None,
45        }
46    }
47
48    #[inline]
49    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
50        match prim {
51            1 => Self::InvalidArgs,
52            2 => Self::NotFound,
53            3 => Self::DestroyComponentFailed,
54            4 => Self::CreateComponentFailed,
55            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
56        }
57    }
58
59    #[inline]
60    pub fn unknown() -> Self {
61        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
62    }
63
64    #[inline]
65    pub const fn into_primitive(self) -> u32 {
66        match self {
67            Self::InvalidArgs => 1,
68            Self::NotFound => 2,
69            Self::DestroyComponentFailed => 3,
70            Self::CreateComponentFailed => 4,
71            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
72        }
73    }
74
75    #[inline]
76    pub fn is_unknown(&self) -> bool {
77        match self {
78            Self::__SourceBreaking { unknown_ordinal: _ } => true,
79            _ => false,
80        }
81    }
82}
83
84/// An error that occurs when updating the lifecycle a session.
85#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
86pub enum LifecycleError {
87    /// The session has not been started or there is no default session URL configured.
88    NotFound,
89    /// The session has already been started.
90    AlreadyStarted,
91    /// The session component could not be resolved.
92    ResolveComponentFailed,
93    /// The session component could not be created.
94    CreateComponentFailed,
95    /// The session component could not be destroyed.
96    DestroyComponentFailed,
97    #[doc(hidden)]
98    __SourceBreaking { unknown_ordinal: u32 },
99}
100
101/// Pattern that matches an unknown `LifecycleError` member.
102#[macro_export]
103macro_rules! LifecycleErrorUnknown {
104    () => {
105        _
106    };
107}
108
109impl LifecycleError {
110    #[inline]
111    pub fn from_primitive(prim: u32) -> Option<Self> {
112        match prim {
113            1 => Some(Self::NotFound),
114            2 => Some(Self::AlreadyStarted),
115            3 => Some(Self::ResolveComponentFailed),
116            4 => Some(Self::CreateComponentFailed),
117            5 => Some(Self::DestroyComponentFailed),
118            _ => None,
119        }
120    }
121
122    #[inline]
123    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
124        match prim {
125            1 => Self::NotFound,
126            2 => Self::AlreadyStarted,
127            3 => Self::ResolveComponentFailed,
128            4 => Self::CreateComponentFailed,
129            5 => Self::DestroyComponentFailed,
130            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
131        }
132    }
133
134    #[inline]
135    pub fn unknown() -> Self {
136        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
137    }
138
139    #[inline]
140    pub const fn into_primitive(self) -> u32 {
141        match self {
142            Self::NotFound => 1,
143            Self::AlreadyStarted => 2,
144            Self::ResolveComponentFailed => 3,
145            Self::CreateComponentFailed => 4,
146            Self::DestroyComponentFailed => 5,
147            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
148        }
149    }
150
151    #[inline]
152    pub fn is_unknown(&self) -> bool {
153        match self {
154            Self::__SourceBreaking { unknown_ordinal: _ } => true,
155            _ => false,
156        }
157    }
158}
159
160/// An error that occurs when restarting a session.
161#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
162pub enum RestartError {
163    /// There is no currently running session to restart.
164    NotRunning,
165    /// There was an error resolving the session's component URL.
166    NotFound,
167    /// The session component could not be destroyed.
168    DestroyComponentFailed,
169    /// The session component could not be created.
170    CreateComponentFailed,
171    #[doc(hidden)]
172    __SourceBreaking { unknown_ordinal: u32 },
173}
174
175/// Pattern that matches an unknown `RestartError` member.
176#[macro_export]
177macro_rules! RestartErrorUnknown {
178    () => {
179        _
180    };
181}
182
183impl RestartError {
184    #[inline]
185    pub fn from_primitive(prim: u32) -> Option<Self> {
186        match prim {
187            1 => Some(Self::NotRunning),
188            2 => Some(Self::NotFound),
189            3 => Some(Self::DestroyComponentFailed),
190            4 => Some(Self::CreateComponentFailed),
191            _ => None,
192        }
193    }
194
195    #[inline]
196    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
197        match prim {
198            1 => Self::NotRunning,
199            2 => Self::NotFound,
200            3 => Self::DestroyComponentFailed,
201            4 => Self::CreateComponentFailed,
202            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
203        }
204    }
205
206    #[inline]
207    pub fn unknown() -> Self {
208        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
209    }
210
211    #[inline]
212    pub const fn into_primitive(self) -> u32 {
213        match self {
214            Self::NotRunning => 1,
215            Self::NotFound => 2,
216            Self::DestroyComponentFailed => 3,
217            Self::CreateComponentFailed => 4,
218            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
219        }
220    }
221
222    #[inline]
223    pub fn is_unknown(&self) -> bool {
224        match self {
225            Self::__SourceBreaking { unknown_ordinal: _ } => true,
226            _ => false,
227        }
228    }
229}
230
231#[derive(Clone, Debug, PartialEq)]
232pub struct LauncherLaunchRequest {
233    pub configuration: LaunchConfiguration,
234}
235
236impl fidl::Persistable for LauncherLaunchRequest {}
237
238/// Describes a session to launch.
239#[derive(Clone, Debug, Default, PartialEq)]
240pub struct LaunchConfiguration {
241    /// The component URL of the session.
242    pub session_url: Option<String>,
243    /// Configuration capabilities that will be offered to the session.
244    ///
245    /// In the intended use case, the session component would use a particular
246    /// configuration capability with `transitional` availability. When such a
247    /// transitional capability is not offered to the session, the config value
248    /// from the package will be used. When it is offered using
249    /// `config_capabilities`, then the config value specified here will be
250    /// used. As such, one may override config values of the session component
251    /// that are set up following this pattern.
252    pub config_capabilities: Option<Vec<fidl_fuchsia_component_decl::Configuration>>,
253    #[doc(hidden)]
254    pub __source_breaking: fidl::marker::SourceBreaking,
255}
256
257impl fidl::Persistable for LaunchConfiguration {}
258
259#[derive(Clone, Debug, Default, PartialEq)]
260pub struct LifecycleStartRequest {
261    /// The component URL of the session.
262    ///
263    /// Optional. If omitted, uses the default configured session URL, if available.
264    pub session_url: Option<String>,
265    #[doc(hidden)]
266    pub __source_breaking: fidl::marker::SourceBreaking,
267}
268
269impl fidl::Persistable for LifecycleStartRequest {}
270
271#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
272pub struct LauncherMarker;
273
274impl fidl::endpoints::ProtocolMarker for LauncherMarker {
275    type Proxy = LauncherProxy;
276    type RequestStream = LauncherRequestStream;
277    #[cfg(target_os = "fuchsia")]
278    type SynchronousProxy = LauncherSynchronousProxy;
279
280    const DEBUG_NAME: &'static str = "fuchsia.session.Launcher";
281}
282impl fidl::endpoints::DiscoverableProtocolMarker for LauncherMarker {}
283pub type LauncherLaunchResult = Result<(), LaunchError>;
284
285pub trait LauncherProxyInterface: Send + Sync {
286    type LaunchResponseFut: std::future::Future<Output = Result<LauncherLaunchResult, fidl::Error>>
287        + Send;
288    fn r#launch(&self, configuration: &LaunchConfiguration) -> Self::LaunchResponseFut;
289}
290#[derive(Debug)]
291#[cfg(target_os = "fuchsia")]
292pub struct LauncherSynchronousProxy {
293    client: fidl::client::sync::Client,
294}
295
296#[cfg(target_os = "fuchsia")]
297impl fidl::endpoints::SynchronousProxy for LauncherSynchronousProxy {
298    type Proxy = LauncherProxy;
299    type Protocol = LauncherMarker;
300
301    fn from_channel(inner: fidl::Channel) -> Self {
302        Self::new(inner)
303    }
304
305    fn into_channel(self) -> fidl::Channel {
306        self.client.into_channel()
307    }
308
309    fn as_channel(&self) -> &fidl::Channel {
310        self.client.as_channel()
311    }
312}
313
314#[cfg(target_os = "fuchsia")]
315impl LauncherSynchronousProxy {
316    pub fn new(channel: fidl::Channel) -> Self {
317        let protocol_name = <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
318        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
319    }
320
321    pub fn into_channel(self) -> fidl::Channel {
322        self.client.into_channel()
323    }
324
325    /// Waits until an event arrives and returns it. It is safe for other
326    /// threads to make concurrent requests while waiting for an event.
327    pub fn wait_for_event(
328        &self,
329        deadline: zx::MonotonicInstant,
330    ) -> Result<LauncherEvent, fidl::Error> {
331        LauncherEvent::decode(self.client.wait_for_event(deadline)?)
332    }
333
334    /// Launches the session detailed in `configuration`.
335    ///
336    /// If a session is currently running, the component associated with the running
337    /// session will be destroyed.
338    ///
339    /// + `configuration` describes the session to launch.
340    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
341    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
342    ///   could not be resolved.
343    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
344    ///   could not be destroyed. The existing session remains running at this point.
345    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
346    ///   could not be started. No session will be running at this point.
347    pub fn r#launch(
348        &self,
349        mut configuration: &LaunchConfiguration,
350        ___deadline: zx::MonotonicInstant,
351    ) -> Result<LauncherLaunchResult, fidl::Error> {
352        let _response = self.client.send_query::<
353            LauncherLaunchRequest,
354            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LaunchError>,
355        >(
356            (configuration,),
357            0x7674a4287f8a385a,
358            fidl::encoding::DynamicFlags::empty(),
359            ___deadline,
360        )?;
361        Ok(_response.map(|x| x))
362    }
363}
364
365#[derive(Debug, Clone)]
366pub struct LauncherProxy {
367    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
368}
369
370impl fidl::endpoints::Proxy for LauncherProxy {
371    type Protocol = LauncherMarker;
372
373    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
374        Self::new(inner)
375    }
376
377    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
378        self.client.into_channel().map_err(|client| Self { client })
379    }
380
381    fn as_channel(&self) -> &::fidl::AsyncChannel {
382        self.client.as_channel()
383    }
384}
385
386impl LauncherProxy {
387    /// Create a new Proxy for fuchsia.session/Launcher.
388    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
389        let protocol_name = <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
390        Self { client: fidl::client::Client::new(channel, protocol_name) }
391    }
392
393    /// Get a Stream of events from the remote end of the protocol.
394    ///
395    /// # Panics
396    ///
397    /// Panics if the event stream was already taken.
398    pub fn take_event_stream(&self) -> LauncherEventStream {
399        LauncherEventStream { event_receiver: self.client.take_event_receiver() }
400    }
401
402    /// Launches the session detailed in `configuration`.
403    ///
404    /// If a session is currently running, the component associated with the running
405    /// session will be destroyed.
406    ///
407    /// + `configuration` describes the session to launch.
408    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
409    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
410    ///   could not be resolved.
411    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
412    ///   could not be destroyed. The existing session remains running at this point.
413    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
414    ///   could not be started. No session will be running at this point.
415    pub fn r#launch(
416        &self,
417        mut configuration: &LaunchConfiguration,
418    ) -> fidl::client::QueryResponseFut<
419        LauncherLaunchResult,
420        fidl::encoding::DefaultFuchsiaResourceDialect,
421    > {
422        LauncherProxyInterface::r#launch(self, configuration)
423    }
424}
425
426impl LauncherProxyInterface for LauncherProxy {
427    type LaunchResponseFut = fidl::client::QueryResponseFut<
428        LauncherLaunchResult,
429        fidl::encoding::DefaultFuchsiaResourceDialect,
430    >;
431    fn r#launch(&self, mut configuration: &LaunchConfiguration) -> Self::LaunchResponseFut {
432        fn _decode(
433            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
434        ) -> Result<LauncherLaunchResult, fidl::Error> {
435            let _response = fidl::client::decode_transaction_body::<
436                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LaunchError>,
437                fidl::encoding::DefaultFuchsiaResourceDialect,
438                0x7674a4287f8a385a,
439            >(_buf?)?;
440            Ok(_response.map(|x| x))
441        }
442        self.client.send_query_and_decode::<LauncherLaunchRequest, LauncherLaunchResult>(
443            (configuration,),
444            0x7674a4287f8a385a,
445            fidl::encoding::DynamicFlags::empty(),
446            _decode,
447        )
448    }
449}
450
451pub struct LauncherEventStream {
452    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
453}
454
455impl std::marker::Unpin for LauncherEventStream {}
456
457impl futures::stream::FusedStream for LauncherEventStream {
458    fn is_terminated(&self) -> bool {
459        self.event_receiver.is_terminated()
460    }
461}
462
463impl futures::Stream for LauncherEventStream {
464    type Item = Result<LauncherEvent, fidl::Error>;
465
466    fn poll_next(
467        mut self: std::pin::Pin<&mut Self>,
468        cx: &mut std::task::Context<'_>,
469    ) -> std::task::Poll<Option<Self::Item>> {
470        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
471            &mut self.event_receiver,
472            cx
473        )?) {
474            Some(buf) => std::task::Poll::Ready(Some(LauncherEvent::decode(buf))),
475            None => std::task::Poll::Ready(None),
476        }
477    }
478}
479
480#[derive(Debug)]
481pub enum LauncherEvent {}
482
483impl LauncherEvent {
484    /// Decodes a message buffer as a [`LauncherEvent`].
485    fn decode(
486        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
487    ) -> Result<LauncherEvent, fidl::Error> {
488        let (bytes, _handles) = buf.split_mut();
489        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
490        debug_assert_eq!(tx_header.tx_id, 0);
491        match tx_header.ordinal {
492            _ => Err(fidl::Error::UnknownOrdinal {
493                ordinal: tx_header.ordinal,
494                protocol_name: <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
495            }),
496        }
497    }
498}
499
500/// A Stream of incoming requests for fuchsia.session/Launcher.
501pub struct LauncherRequestStream {
502    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
503    is_terminated: bool,
504}
505
506impl std::marker::Unpin for LauncherRequestStream {}
507
508impl futures::stream::FusedStream for LauncherRequestStream {
509    fn is_terminated(&self) -> bool {
510        self.is_terminated
511    }
512}
513
514impl fidl::endpoints::RequestStream for LauncherRequestStream {
515    type Protocol = LauncherMarker;
516    type ControlHandle = LauncherControlHandle;
517
518    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
519        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
520    }
521
522    fn control_handle(&self) -> Self::ControlHandle {
523        LauncherControlHandle { inner: self.inner.clone() }
524    }
525
526    fn into_inner(
527        self,
528    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
529    {
530        (self.inner, self.is_terminated)
531    }
532
533    fn from_inner(
534        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
535        is_terminated: bool,
536    ) -> Self {
537        Self { inner, is_terminated }
538    }
539}
540
541impl futures::Stream for LauncherRequestStream {
542    type Item = Result<LauncherRequest, fidl::Error>;
543
544    fn poll_next(
545        mut self: std::pin::Pin<&mut Self>,
546        cx: &mut std::task::Context<'_>,
547    ) -> std::task::Poll<Option<Self::Item>> {
548        let this = &mut *self;
549        if this.inner.check_shutdown(cx) {
550            this.is_terminated = true;
551            return std::task::Poll::Ready(None);
552        }
553        if this.is_terminated {
554            panic!("polled LauncherRequestStream after completion");
555        }
556        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
557            |bytes, handles| {
558                match this.inner.channel().read_etc(cx, bytes, handles) {
559                    std::task::Poll::Ready(Ok(())) => {}
560                    std::task::Poll::Pending => return std::task::Poll::Pending,
561                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
562                        this.is_terminated = true;
563                        return std::task::Poll::Ready(None);
564                    }
565                    std::task::Poll::Ready(Err(e)) => {
566                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
567                            e.into(),
568                        ))))
569                    }
570                }
571
572                // A message has been received from the channel
573                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
574
575                std::task::Poll::Ready(Some(match header.ordinal {
576                    0x7674a4287f8a385a => {
577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
578                        let mut req = fidl::new_empty!(
579                            LauncherLaunchRequest,
580                            fidl::encoding::DefaultFuchsiaResourceDialect
581                        );
582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LauncherLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
583                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
584                        Ok(LauncherRequest::Launch {
585                            configuration: req.configuration,
586
587                            responder: LauncherLaunchResponder {
588                                control_handle: std::mem::ManuallyDrop::new(control_handle),
589                                tx_id: header.tx_id,
590                            },
591                        })
592                    }
593                    _ => Err(fidl::Error::UnknownOrdinal {
594                        ordinal: header.ordinal,
595                        protocol_name:
596                            <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
597                    }),
598                }))
599            },
600        )
601    }
602}
603
604/// A protocol used to launch sessions.
605#[derive(Debug)]
606pub enum LauncherRequest {
607    /// Launches the session detailed in `configuration`.
608    ///
609    /// If a session is currently running, the component associated with the running
610    /// session will be destroyed.
611    ///
612    /// + `configuration` describes the session to launch.
613    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
614    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
615    ///   could not be resolved.
616    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
617    ///   could not be destroyed. The existing session remains running at this point.
618    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
619    ///   could not be started. No session will be running at this point.
620    Launch { configuration: LaunchConfiguration, responder: LauncherLaunchResponder },
621}
622
623impl LauncherRequest {
624    #[allow(irrefutable_let_patterns)]
625    pub fn into_launch(self) -> Option<(LaunchConfiguration, LauncherLaunchResponder)> {
626        if let LauncherRequest::Launch { configuration, responder } = self {
627            Some((configuration, responder))
628        } else {
629            None
630        }
631    }
632
633    /// Name of the method defined in FIDL
634    pub fn method_name(&self) -> &'static str {
635        match *self {
636            LauncherRequest::Launch { .. } => "launch",
637        }
638    }
639}
640
641#[derive(Debug, Clone)]
642pub struct LauncherControlHandle {
643    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
644}
645
646impl fidl::endpoints::ControlHandle for LauncherControlHandle {
647    fn shutdown(&self) {
648        self.inner.shutdown()
649    }
650    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
651        self.inner.shutdown_with_epitaph(status)
652    }
653
654    fn is_closed(&self) -> bool {
655        self.inner.channel().is_closed()
656    }
657    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
658        self.inner.channel().on_closed()
659    }
660
661    #[cfg(target_os = "fuchsia")]
662    fn signal_peer(
663        &self,
664        clear_mask: zx::Signals,
665        set_mask: zx::Signals,
666    ) -> Result<(), zx_status::Status> {
667        use fidl::Peered;
668        self.inner.channel().signal_peer(clear_mask, set_mask)
669    }
670}
671
672impl LauncherControlHandle {}
673
674#[must_use = "FIDL methods require a response to be sent"]
675#[derive(Debug)]
676pub struct LauncherLaunchResponder {
677    control_handle: std::mem::ManuallyDrop<LauncherControlHandle>,
678    tx_id: u32,
679}
680
681/// Set the the channel to be shutdown (see [`LauncherControlHandle::shutdown`])
682/// if the responder is dropped without sending a response, so that the client
683/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
684impl std::ops::Drop for LauncherLaunchResponder {
685    fn drop(&mut self) {
686        self.control_handle.shutdown();
687        // Safety: drops once, never accessed again
688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
689    }
690}
691
692impl fidl::endpoints::Responder for LauncherLaunchResponder {
693    type ControlHandle = LauncherControlHandle;
694
695    fn control_handle(&self) -> &LauncherControlHandle {
696        &self.control_handle
697    }
698
699    fn drop_without_shutdown(mut self) {
700        // Safety: drops once, never accessed again due to mem::forget
701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
702        // Prevent Drop from running (which would shut down the channel)
703        std::mem::forget(self);
704    }
705}
706
707impl LauncherLaunchResponder {
708    /// Sends a response to the FIDL transaction.
709    ///
710    /// Sets the channel to shutdown if an error occurs.
711    pub fn send(self, mut result: Result<(), LaunchError>) -> Result<(), fidl::Error> {
712        let _result = self.send_raw(result);
713        if _result.is_err() {
714            self.control_handle.shutdown();
715        }
716        self.drop_without_shutdown();
717        _result
718    }
719
720    /// Similar to "send" but does not shutdown the channel if an error occurs.
721    pub fn send_no_shutdown_on_err(
722        self,
723        mut result: Result<(), LaunchError>,
724    ) -> Result<(), fidl::Error> {
725        let _result = self.send_raw(result);
726        self.drop_without_shutdown();
727        _result
728    }
729
730    fn send_raw(&self, mut result: Result<(), LaunchError>) -> Result<(), fidl::Error> {
731        self.control_handle.inner.send::<fidl::encoding::ResultType<
732            fidl::encoding::EmptyStruct,
733            LaunchError,
734        >>(
735            result,
736            self.tx_id,
737            0x7674a4287f8a385a,
738            fidl::encoding::DynamicFlags::empty(),
739        )
740    }
741}
742
743#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
744pub struct LifecycleMarker;
745
746impl fidl::endpoints::ProtocolMarker for LifecycleMarker {
747    type Proxy = LifecycleProxy;
748    type RequestStream = LifecycleRequestStream;
749    #[cfg(target_os = "fuchsia")]
750    type SynchronousProxy = LifecycleSynchronousProxy;
751
752    const DEBUG_NAME: &'static str = "fuchsia.session.Lifecycle";
753}
754impl fidl::endpoints::DiscoverableProtocolMarker for LifecycleMarker {}
755pub type LifecycleStartResult = Result<(), LifecycleError>;
756pub type LifecycleStopResult = Result<(), LifecycleError>;
757pub type LifecycleRestartResult = Result<(), LifecycleError>;
758
759pub trait LifecycleProxyInterface: Send + Sync {
760    type StartResponseFut: std::future::Future<Output = Result<LifecycleStartResult, fidl::Error>>
761        + Send;
762    fn r#start(&self, payload: &LifecycleStartRequest) -> Self::StartResponseFut;
763    type StopResponseFut: std::future::Future<Output = Result<LifecycleStopResult, fidl::Error>>
764        + Send;
765    fn r#stop(&self) -> Self::StopResponseFut;
766    type RestartResponseFut: std::future::Future<Output = Result<LifecycleRestartResult, fidl::Error>>
767        + Send;
768    fn r#restart(&self) -> Self::RestartResponseFut;
769}
770#[derive(Debug)]
771#[cfg(target_os = "fuchsia")]
772pub struct LifecycleSynchronousProxy {
773    client: fidl::client::sync::Client,
774}
775
776#[cfg(target_os = "fuchsia")]
777impl fidl::endpoints::SynchronousProxy for LifecycleSynchronousProxy {
778    type Proxy = LifecycleProxy;
779    type Protocol = LifecycleMarker;
780
781    fn from_channel(inner: fidl::Channel) -> Self {
782        Self::new(inner)
783    }
784
785    fn into_channel(self) -> fidl::Channel {
786        self.client.into_channel()
787    }
788
789    fn as_channel(&self) -> &fidl::Channel {
790        self.client.as_channel()
791    }
792}
793
794#[cfg(target_os = "fuchsia")]
795impl LifecycleSynchronousProxy {
796    pub fn new(channel: fidl::Channel) -> Self {
797        let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
798        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
799    }
800
801    pub fn into_channel(self) -> fidl::Channel {
802        self.client.into_channel()
803    }
804
805    /// Waits until an event arrives and returns it. It is safe for other
806    /// threads to make concurrent requests while waiting for an event.
807    pub fn wait_for_event(
808        &self,
809        deadline: zx::MonotonicInstant,
810    ) -> Result<LifecycleEvent, fidl::Error> {
811        LifecycleEvent::decode(self.client.wait_for_event(deadline)?)
812    }
813
814    /// Starts the session.
815    ///
816    /// Returns after the session component has been created and started.
817    ///
818    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
819    ///   and there is no configured default session URL.
820    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
821    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
822    ///   resolved to a component.
823    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
824    ///   could not be destroyed. The existing session remains running at this point.
825    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
826    ///   could not be started. No session will be running at this point.
827    pub fn r#start(
828        &self,
829        mut payload: &LifecycleStartRequest,
830        ___deadline: zx::MonotonicInstant,
831    ) -> Result<LifecycleStartResult, fidl::Error> {
832        let _response = self.client.send_query::<
833            LifecycleStartRequest,
834            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
835        >(
836            payload,
837            0x2fda381d2cc41ce0,
838            fidl::encoding::DynamicFlags::FLEXIBLE,
839            ___deadline,
840        )?
841        .into_result::<LifecycleMarker>("start")?;
842        Ok(_response.map(|x| x))
843    }
844
845    /// Stops the session.
846    ///
847    /// Returns after the session component has been destroyed.
848    ///
849    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
850    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
851    ///   could not be destroyed. The previous session will continue to exist at
852    ///   this point and the component may be running.
853    pub fn r#stop(
854        &self,
855        ___deadline: zx::MonotonicInstant,
856    ) -> Result<LifecycleStopResult, fidl::Error> {
857        let _response = self.client.send_query::<
858            fidl::encoding::EmptyPayload,
859            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
860        >(
861            (),
862            0x453a9158431b4a2,
863            fidl::encoding::DynamicFlags::FLEXIBLE,
864            ___deadline,
865        )?
866        .into_result::<LifecycleMarker>("stop")?;
867        Ok(_response.map(|x| x))
868    }
869
870    /// Restarts the session.
871    ///
872    /// This stops the existing session and starts a new session with the same
873    /// session URL as the previous one.
874    ///
875    /// Returns once the new session component has been created and started.
876    ///
877    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
878    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
879    ///   could not be resolved to a component.
880    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
881    ///   could not be destroyed. The previous session will continue to exist at
882    ///   this point and the component may be running.
883    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
884    ///   could not be started. No session will be running at this point.
885    pub fn r#restart(
886        &self,
887        ___deadline: zx::MonotonicInstant,
888    ) -> Result<LifecycleRestartResult, fidl::Error> {
889        let _response = self.client.send_query::<
890            fidl::encoding::EmptyPayload,
891            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
892        >(
893            (),
894            0x31faeac257bf1abb,
895            fidl::encoding::DynamicFlags::FLEXIBLE,
896            ___deadline,
897        )?
898        .into_result::<LifecycleMarker>("restart")?;
899        Ok(_response.map(|x| x))
900    }
901}
902
903#[derive(Debug, Clone)]
904pub struct LifecycleProxy {
905    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
906}
907
908impl fidl::endpoints::Proxy for LifecycleProxy {
909    type Protocol = LifecycleMarker;
910
911    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
912        Self::new(inner)
913    }
914
915    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
916        self.client.into_channel().map_err(|client| Self { client })
917    }
918
919    fn as_channel(&self) -> &::fidl::AsyncChannel {
920        self.client.as_channel()
921    }
922}
923
924impl LifecycleProxy {
925    /// Create a new Proxy for fuchsia.session/Lifecycle.
926    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
927        let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
928        Self { client: fidl::client::Client::new(channel, protocol_name) }
929    }
930
931    /// Get a Stream of events from the remote end of the protocol.
932    ///
933    /// # Panics
934    ///
935    /// Panics if the event stream was already taken.
936    pub fn take_event_stream(&self) -> LifecycleEventStream {
937        LifecycleEventStream { event_receiver: self.client.take_event_receiver() }
938    }
939
940    /// Starts the session.
941    ///
942    /// Returns after the session component has been created and started.
943    ///
944    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
945    ///   and there is no configured default session URL.
946    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
947    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
948    ///   resolved to a component.
949    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
950    ///   could not be destroyed. The existing session remains running at this point.
951    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
952    ///   could not be started. No session will be running at this point.
953    pub fn r#start(
954        &self,
955        mut payload: &LifecycleStartRequest,
956    ) -> fidl::client::QueryResponseFut<
957        LifecycleStartResult,
958        fidl::encoding::DefaultFuchsiaResourceDialect,
959    > {
960        LifecycleProxyInterface::r#start(self, payload)
961    }
962
963    /// Stops the session.
964    ///
965    /// Returns after the session component has been destroyed.
966    ///
967    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
968    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
969    ///   could not be destroyed. The previous session will continue to exist at
970    ///   this point and the component may be running.
971    pub fn r#stop(
972        &self,
973    ) -> fidl::client::QueryResponseFut<
974        LifecycleStopResult,
975        fidl::encoding::DefaultFuchsiaResourceDialect,
976    > {
977        LifecycleProxyInterface::r#stop(self)
978    }
979
980    /// Restarts the session.
981    ///
982    /// This stops the existing session and starts a new session with the same
983    /// session URL as the previous one.
984    ///
985    /// Returns once the new session component has been created and started.
986    ///
987    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
988    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
989    ///   could not be resolved to a component.
990    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
991    ///   could not be destroyed. The previous session will continue to exist at
992    ///   this point and the component may be running.
993    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
994    ///   could not be started. No session will be running at this point.
995    pub fn r#restart(
996        &self,
997    ) -> fidl::client::QueryResponseFut<
998        LifecycleRestartResult,
999        fidl::encoding::DefaultFuchsiaResourceDialect,
1000    > {
1001        LifecycleProxyInterface::r#restart(self)
1002    }
1003}
1004
1005impl LifecycleProxyInterface for LifecycleProxy {
1006    type StartResponseFut = fidl::client::QueryResponseFut<
1007        LifecycleStartResult,
1008        fidl::encoding::DefaultFuchsiaResourceDialect,
1009    >;
1010    fn r#start(&self, mut payload: &LifecycleStartRequest) -> Self::StartResponseFut {
1011        fn _decode(
1012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1013        ) -> Result<LifecycleStartResult, fidl::Error> {
1014            let _response = fidl::client::decode_transaction_body::<
1015                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017                0x2fda381d2cc41ce0,
1018            >(_buf?)?
1019            .into_result::<LifecycleMarker>("start")?;
1020            Ok(_response.map(|x| x))
1021        }
1022        self.client.send_query_and_decode::<LifecycleStartRequest, LifecycleStartResult>(
1023            payload,
1024            0x2fda381d2cc41ce0,
1025            fidl::encoding::DynamicFlags::FLEXIBLE,
1026            _decode,
1027        )
1028    }
1029
1030    type StopResponseFut = fidl::client::QueryResponseFut<
1031        LifecycleStopResult,
1032        fidl::encoding::DefaultFuchsiaResourceDialect,
1033    >;
1034    fn r#stop(&self) -> Self::StopResponseFut {
1035        fn _decode(
1036            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1037        ) -> Result<LifecycleStopResult, fidl::Error> {
1038            let _response = fidl::client::decode_transaction_body::<
1039                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
1040                fidl::encoding::DefaultFuchsiaResourceDialect,
1041                0x453a9158431b4a2,
1042            >(_buf?)?
1043            .into_result::<LifecycleMarker>("stop")?;
1044            Ok(_response.map(|x| x))
1045        }
1046        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LifecycleStopResult>(
1047            (),
1048            0x453a9158431b4a2,
1049            fidl::encoding::DynamicFlags::FLEXIBLE,
1050            _decode,
1051        )
1052    }
1053
1054    type RestartResponseFut = fidl::client::QueryResponseFut<
1055        LifecycleRestartResult,
1056        fidl::encoding::DefaultFuchsiaResourceDialect,
1057    >;
1058    fn r#restart(&self) -> Self::RestartResponseFut {
1059        fn _decode(
1060            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1061        ) -> Result<LifecycleRestartResult, fidl::Error> {
1062            let _response = fidl::client::decode_transaction_body::<
1063                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
1064                fidl::encoding::DefaultFuchsiaResourceDialect,
1065                0x31faeac257bf1abb,
1066            >(_buf?)?
1067            .into_result::<LifecycleMarker>("restart")?;
1068            Ok(_response.map(|x| x))
1069        }
1070        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LifecycleRestartResult>(
1071            (),
1072            0x31faeac257bf1abb,
1073            fidl::encoding::DynamicFlags::FLEXIBLE,
1074            _decode,
1075        )
1076    }
1077}
1078
1079pub struct LifecycleEventStream {
1080    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1081}
1082
1083impl std::marker::Unpin for LifecycleEventStream {}
1084
1085impl futures::stream::FusedStream for LifecycleEventStream {
1086    fn is_terminated(&self) -> bool {
1087        self.event_receiver.is_terminated()
1088    }
1089}
1090
1091impl futures::Stream for LifecycleEventStream {
1092    type Item = Result<LifecycleEvent, fidl::Error>;
1093
1094    fn poll_next(
1095        mut self: std::pin::Pin<&mut Self>,
1096        cx: &mut std::task::Context<'_>,
1097    ) -> std::task::Poll<Option<Self::Item>> {
1098        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1099            &mut self.event_receiver,
1100            cx
1101        )?) {
1102            Some(buf) => std::task::Poll::Ready(Some(LifecycleEvent::decode(buf))),
1103            None => std::task::Poll::Ready(None),
1104        }
1105    }
1106}
1107
1108#[derive(Debug)]
1109pub enum LifecycleEvent {
1110    #[non_exhaustive]
1111    _UnknownEvent {
1112        /// Ordinal of the event that was sent.
1113        ordinal: u64,
1114    },
1115}
1116
1117impl LifecycleEvent {
1118    /// Decodes a message buffer as a [`LifecycleEvent`].
1119    fn decode(
1120        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1121    ) -> Result<LifecycleEvent, fidl::Error> {
1122        let (bytes, _handles) = buf.split_mut();
1123        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1124        debug_assert_eq!(tx_header.tx_id, 0);
1125        match tx_header.ordinal {
1126            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1127                Ok(LifecycleEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1128            }
1129            _ => Err(fidl::Error::UnknownOrdinal {
1130                ordinal: tx_header.ordinal,
1131                protocol_name: <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1132            }),
1133        }
1134    }
1135}
1136
1137/// A Stream of incoming requests for fuchsia.session/Lifecycle.
1138pub struct LifecycleRequestStream {
1139    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1140    is_terminated: bool,
1141}
1142
1143impl std::marker::Unpin for LifecycleRequestStream {}
1144
1145impl futures::stream::FusedStream for LifecycleRequestStream {
1146    fn is_terminated(&self) -> bool {
1147        self.is_terminated
1148    }
1149}
1150
1151impl fidl::endpoints::RequestStream for LifecycleRequestStream {
1152    type Protocol = LifecycleMarker;
1153    type ControlHandle = LifecycleControlHandle;
1154
1155    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1156        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1157    }
1158
1159    fn control_handle(&self) -> Self::ControlHandle {
1160        LifecycleControlHandle { inner: self.inner.clone() }
1161    }
1162
1163    fn into_inner(
1164        self,
1165    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1166    {
1167        (self.inner, self.is_terminated)
1168    }
1169
1170    fn from_inner(
1171        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1172        is_terminated: bool,
1173    ) -> Self {
1174        Self { inner, is_terminated }
1175    }
1176}
1177
1178impl futures::Stream for LifecycleRequestStream {
1179    type Item = Result<LifecycleRequest, fidl::Error>;
1180
1181    fn poll_next(
1182        mut self: std::pin::Pin<&mut Self>,
1183        cx: &mut std::task::Context<'_>,
1184    ) -> std::task::Poll<Option<Self::Item>> {
1185        let this = &mut *self;
1186        if this.inner.check_shutdown(cx) {
1187            this.is_terminated = true;
1188            return std::task::Poll::Ready(None);
1189        }
1190        if this.is_terminated {
1191            panic!("polled LifecycleRequestStream after completion");
1192        }
1193        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1194            |bytes, handles| {
1195                match this.inner.channel().read_etc(cx, bytes, handles) {
1196                    std::task::Poll::Ready(Ok(())) => {}
1197                    std::task::Poll::Pending => return std::task::Poll::Pending,
1198                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1199                        this.is_terminated = true;
1200                        return std::task::Poll::Ready(None);
1201                    }
1202                    std::task::Poll::Ready(Err(e)) => {
1203                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1204                            e.into(),
1205                        ))))
1206                    }
1207                }
1208
1209                // A message has been received from the channel
1210                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1211
1212                std::task::Poll::Ready(Some(match header.ordinal {
1213                    0x2fda381d2cc41ce0 => {
1214                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1215                        let mut req = fidl::new_empty!(
1216                            LifecycleStartRequest,
1217                            fidl::encoding::DefaultFuchsiaResourceDialect
1218                        );
1219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleStartRequest>(&header, _body_bytes, handles, &mut req)?;
1220                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1221                        Ok(LifecycleRequest::Start {
1222                            payload: req,
1223                            responder: LifecycleStartResponder {
1224                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1225                                tx_id: header.tx_id,
1226                            },
1227                        })
1228                    }
1229                    0x453a9158431b4a2 => {
1230                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1231                        let mut req = fidl::new_empty!(
1232                            fidl::encoding::EmptyPayload,
1233                            fidl::encoding::DefaultFuchsiaResourceDialect
1234                        );
1235                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1236                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1237                        Ok(LifecycleRequest::Stop {
1238                            responder: LifecycleStopResponder {
1239                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1240                                tx_id: header.tx_id,
1241                            },
1242                        })
1243                    }
1244                    0x31faeac257bf1abb => {
1245                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1246                        let mut req = fidl::new_empty!(
1247                            fidl::encoding::EmptyPayload,
1248                            fidl::encoding::DefaultFuchsiaResourceDialect
1249                        );
1250                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1251                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1252                        Ok(LifecycleRequest::Restart {
1253                            responder: LifecycleRestartResponder {
1254                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1255                                tx_id: header.tx_id,
1256                            },
1257                        })
1258                    }
1259                    _ if header.tx_id == 0
1260                        && header
1261                            .dynamic_flags()
1262                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1263                    {
1264                        Ok(LifecycleRequest::_UnknownMethod {
1265                            ordinal: header.ordinal,
1266                            control_handle: LifecycleControlHandle { inner: this.inner.clone() },
1267                            method_type: fidl::MethodType::OneWay,
1268                        })
1269                    }
1270                    _ if header
1271                        .dynamic_flags()
1272                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1273                    {
1274                        this.inner.send_framework_err(
1275                            fidl::encoding::FrameworkErr::UnknownMethod,
1276                            header.tx_id,
1277                            header.ordinal,
1278                            header.dynamic_flags(),
1279                            (bytes, handles),
1280                        )?;
1281                        Ok(LifecycleRequest::_UnknownMethod {
1282                            ordinal: header.ordinal,
1283                            control_handle: LifecycleControlHandle { inner: this.inner.clone() },
1284                            method_type: fidl::MethodType::TwoWay,
1285                        })
1286                    }
1287                    _ => Err(fidl::Error::UnknownOrdinal {
1288                        ordinal: header.ordinal,
1289                        protocol_name:
1290                            <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1291                    }),
1292                }))
1293            },
1294        )
1295    }
1296}
1297
1298/// A protocol used to control the session's lifecycle.
1299#[derive(Debug)]
1300pub enum LifecycleRequest {
1301    /// Starts the session.
1302    ///
1303    /// Returns after the session component has been created and started.
1304    ///
1305    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
1306    ///   and there is no configured default session URL.
1307    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
1308    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
1309    ///   resolved to a component.
1310    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
1311    ///   could not be destroyed. The existing session remains running at this point.
1312    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
1313    ///   could not be started. No session will be running at this point.
1314    Start { payload: LifecycleStartRequest, responder: LifecycleStartResponder },
1315    /// Stops the session.
1316    ///
1317    /// Returns after the session component has been destroyed.
1318    ///
1319    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
1320    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
1321    ///   could not be destroyed. The previous session will continue to exist at
1322    ///   this point and the component may be running.
1323    Stop { responder: LifecycleStopResponder },
1324    /// Restarts the session.
1325    ///
1326    /// This stops the existing session and starts a new session with the same
1327    /// session URL as the previous one.
1328    ///
1329    /// Returns once the new session component has been created and started.
1330    ///
1331    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
1332    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
1333    ///   could not be resolved to a component.
1334    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
1335    ///   could not be destroyed. The previous session will continue to exist at
1336    ///   this point and the component may be running.
1337    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
1338    ///   could not be started. No session will be running at this point.
1339    Restart { responder: LifecycleRestartResponder },
1340    /// An interaction was received which does not match any known method.
1341    #[non_exhaustive]
1342    _UnknownMethod {
1343        /// Ordinal of the method that was called.
1344        ordinal: u64,
1345        control_handle: LifecycleControlHandle,
1346        method_type: fidl::MethodType,
1347    },
1348}
1349
1350impl LifecycleRequest {
1351    #[allow(irrefutable_let_patterns)]
1352    pub fn into_start(self) -> Option<(LifecycleStartRequest, LifecycleStartResponder)> {
1353        if let LifecycleRequest::Start { payload, responder } = self {
1354            Some((payload, responder))
1355        } else {
1356            None
1357        }
1358    }
1359
1360    #[allow(irrefutable_let_patterns)]
1361    pub fn into_stop(self) -> Option<(LifecycleStopResponder)> {
1362        if let LifecycleRequest::Stop { responder } = self {
1363            Some((responder))
1364        } else {
1365            None
1366        }
1367    }
1368
1369    #[allow(irrefutable_let_patterns)]
1370    pub fn into_restart(self) -> Option<(LifecycleRestartResponder)> {
1371        if let LifecycleRequest::Restart { responder } = self {
1372            Some((responder))
1373        } else {
1374            None
1375        }
1376    }
1377
1378    /// Name of the method defined in FIDL
1379    pub fn method_name(&self) -> &'static str {
1380        match *self {
1381            LifecycleRequest::Start { .. } => "start",
1382            LifecycleRequest::Stop { .. } => "stop",
1383            LifecycleRequest::Restart { .. } => "restart",
1384            LifecycleRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1385                "unknown one-way method"
1386            }
1387            LifecycleRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1388                "unknown two-way method"
1389            }
1390        }
1391    }
1392}
1393
1394#[derive(Debug, Clone)]
1395pub struct LifecycleControlHandle {
1396    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1397}
1398
1399impl fidl::endpoints::ControlHandle for LifecycleControlHandle {
1400    fn shutdown(&self) {
1401        self.inner.shutdown()
1402    }
1403    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1404        self.inner.shutdown_with_epitaph(status)
1405    }
1406
1407    fn is_closed(&self) -> bool {
1408        self.inner.channel().is_closed()
1409    }
1410    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1411        self.inner.channel().on_closed()
1412    }
1413
1414    #[cfg(target_os = "fuchsia")]
1415    fn signal_peer(
1416        &self,
1417        clear_mask: zx::Signals,
1418        set_mask: zx::Signals,
1419    ) -> Result<(), zx_status::Status> {
1420        use fidl::Peered;
1421        self.inner.channel().signal_peer(clear_mask, set_mask)
1422    }
1423}
1424
1425impl LifecycleControlHandle {}
1426
1427#[must_use = "FIDL methods require a response to be sent"]
1428#[derive(Debug)]
1429pub struct LifecycleStartResponder {
1430    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1431    tx_id: u32,
1432}
1433
1434/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1435/// if the responder is dropped without sending a response, so that the client
1436/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1437impl std::ops::Drop for LifecycleStartResponder {
1438    fn drop(&mut self) {
1439        self.control_handle.shutdown();
1440        // Safety: drops once, never accessed again
1441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1442    }
1443}
1444
1445impl fidl::endpoints::Responder for LifecycleStartResponder {
1446    type ControlHandle = LifecycleControlHandle;
1447
1448    fn control_handle(&self) -> &LifecycleControlHandle {
1449        &self.control_handle
1450    }
1451
1452    fn drop_without_shutdown(mut self) {
1453        // Safety: drops once, never accessed again due to mem::forget
1454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1455        // Prevent Drop from running (which would shut down the channel)
1456        std::mem::forget(self);
1457    }
1458}
1459
1460impl LifecycleStartResponder {
1461    /// Sends a response to the FIDL transaction.
1462    ///
1463    /// Sets the channel to shutdown if an error occurs.
1464    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1465        let _result = self.send_raw(result);
1466        if _result.is_err() {
1467            self.control_handle.shutdown();
1468        }
1469        self.drop_without_shutdown();
1470        _result
1471    }
1472
1473    /// Similar to "send" but does not shutdown the channel if an error occurs.
1474    pub fn send_no_shutdown_on_err(
1475        self,
1476        mut result: Result<(), LifecycleError>,
1477    ) -> Result<(), fidl::Error> {
1478        let _result = self.send_raw(result);
1479        self.drop_without_shutdown();
1480        _result
1481    }
1482
1483    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1484        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1485            fidl::encoding::EmptyStruct,
1486            LifecycleError,
1487        >>(
1488            fidl::encoding::FlexibleResult::new(result),
1489            self.tx_id,
1490            0x2fda381d2cc41ce0,
1491            fidl::encoding::DynamicFlags::FLEXIBLE,
1492        )
1493    }
1494}
1495
1496#[must_use = "FIDL methods require a response to be sent"]
1497#[derive(Debug)]
1498pub struct LifecycleStopResponder {
1499    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1500    tx_id: u32,
1501}
1502
1503/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1504/// if the responder is dropped without sending a response, so that the client
1505/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1506impl std::ops::Drop for LifecycleStopResponder {
1507    fn drop(&mut self) {
1508        self.control_handle.shutdown();
1509        // Safety: drops once, never accessed again
1510        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1511    }
1512}
1513
1514impl fidl::endpoints::Responder for LifecycleStopResponder {
1515    type ControlHandle = LifecycleControlHandle;
1516
1517    fn control_handle(&self) -> &LifecycleControlHandle {
1518        &self.control_handle
1519    }
1520
1521    fn drop_without_shutdown(mut self) {
1522        // Safety: drops once, never accessed again due to mem::forget
1523        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1524        // Prevent Drop from running (which would shut down the channel)
1525        std::mem::forget(self);
1526    }
1527}
1528
1529impl LifecycleStopResponder {
1530    /// Sends a response to the FIDL transaction.
1531    ///
1532    /// Sets the channel to shutdown if an error occurs.
1533    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1534        let _result = self.send_raw(result);
1535        if _result.is_err() {
1536            self.control_handle.shutdown();
1537        }
1538        self.drop_without_shutdown();
1539        _result
1540    }
1541
1542    /// Similar to "send" but does not shutdown the channel if an error occurs.
1543    pub fn send_no_shutdown_on_err(
1544        self,
1545        mut result: Result<(), LifecycleError>,
1546    ) -> Result<(), fidl::Error> {
1547        let _result = self.send_raw(result);
1548        self.drop_without_shutdown();
1549        _result
1550    }
1551
1552    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1553        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1554            fidl::encoding::EmptyStruct,
1555            LifecycleError,
1556        >>(
1557            fidl::encoding::FlexibleResult::new(result),
1558            self.tx_id,
1559            0x453a9158431b4a2,
1560            fidl::encoding::DynamicFlags::FLEXIBLE,
1561        )
1562    }
1563}
1564
1565#[must_use = "FIDL methods require a response to be sent"]
1566#[derive(Debug)]
1567pub struct LifecycleRestartResponder {
1568    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1569    tx_id: u32,
1570}
1571
1572/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1573/// if the responder is dropped without sending a response, so that the client
1574/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1575impl std::ops::Drop for LifecycleRestartResponder {
1576    fn drop(&mut self) {
1577        self.control_handle.shutdown();
1578        // Safety: drops once, never accessed again
1579        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1580    }
1581}
1582
1583impl fidl::endpoints::Responder for LifecycleRestartResponder {
1584    type ControlHandle = LifecycleControlHandle;
1585
1586    fn control_handle(&self) -> &LifecycleControlHandle {
1587        &self.control_handle
1588    }
1589
1590    fn drop_without_shutdown(mut self) {
1591        // Safety: drops once, never accessed again due to mem::forget
1592        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1593        // Prevent Drop from running (which would shut down the channel)
1594        std::mem::forget(self);
1595    }
1596}
1597
1598impl LifecycleRestartResponder {
1599    /// Sends a response to the FIDL transaction.
1600    ///
1601    /// Sets the channel to shutdown if an error occurs.
1602    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1603        let _result = self.send_raw(result);
1604        if _result.is_err() {
1605            self.control_handle.shutdown();
1606        }
1607        self.drop_without_shutdown();
1608        _result
1609    }
1610
1611    /// Similar to "send" but does not shutdown the channel if an error occurs.
1612    pub fn send_no_shutdown_on_err(
1613        self,
1614        mut result: Result<(), LifecycleError>,
1615    ) -> Result<(), fidl::Error> {
1616        let _result = self.send_raw(result);
1617        self.drop_without_shutdown();
1618        _result
1619    }
1620
1621    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1622        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1623            fidl::encoding::EmptyStruct,
1624            LifecycleError,
1625        >>(
1626            fidl::encoding::FlexibleResult::new(result),
1627            self.tx_id,
1628            0x31faeac257bf1abb,
1629            fidl::encoding::DynamicFlags::FLEXIBLE,
1630        )
1631    }
1632}
1633
1634#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1635pub struct RestarterMarker;
1636
1637impl fidl::endpoints::ProtocolMarker for RestarterMarker {
1638    type Proxy = RestarterProxy;
1639    type RequestStream = RestarterRequestStream;
1640    #[cfg(target_os = "fuchsia")]
1641    type SynchronousProxy = RestarterSynchronousProxy;
1642
1643    const DEBUG_NAME: &'static str = "fuchsia.session.Restarter";
1644}
1645impl fidl::endpoints::DiscoverableProtocolMarker for RestarterMarker {}
1646pub type RestarterRestartResult = Result<(), RestartError>;
1647
1648pub trait RestarterProxyInterface: Send + Sync {
1649    type RestartResponseFut: std::future::Future<Output = Result<RestarterRestartResult, fidl::Error>>
1650        + Send;
1651    fn r#restart(&self) -> Self::RestartResponseFut;
1652}
1653#[derive(Debug)]
1654#[cfg(target_os = "fuchsia")]
1655pub struct RestarterSynchronousProxy {
1656    client: fidl::client::sync::Client,
1657}
1658
1659#[cfg(target_os = "fuchsia")]
1660impl fidl::endpoints::SynchronousProxy for RestarterSynchronousProxy {
1661    type Proxy = RestarterProxy;
1662    type Protocol = RestarterMarker;
1663
1664    fn from_channel(inner: fidl::Channel) -> Self {
1665        Self::new(inner)
1666    }
1667
1668    fn into_channel(self) -> fidl::Channel {
1669        self.client.into_channel()
1670    }
1671
1672    fn as_channel(&self) -> &fidl::Channel {
1673        self.client.as_channel()
1674    }
1675}
1676
1677#[cfg(target_os = "fuchsia")]
1678impl RestarterSynchronousProxy {
1679    pub fn new(channel: fidl::Channel) -> Self {
1680        let protocol_name = <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1681        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1682    }
1683
1684    pub fn into_channel(self) -> fidl::Channel {
1685        self.client.into_channel()
1686    }
1687
1688    /// Waits until an event arrives and returns it. It is safe for other
1689    /// threads to make concurrent requests while waiting for an event.
1690    pub fn wait_for_event(
1691        &self,
1692        deadline: zx::MonotonicInstant,
1693    ) -> Result<RestarterEvent, fidl::Error> {
1694        RestarterEvent::decode(self.client.wait_for_event(deadline)?)
1695    }
1696
1697    /// Restarts the session.
1698    ///
1699    /// * error `RestartError.NOT_RUNNING` if there is no
1700    ///   currently running session to restart.
1701    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1702    ///   could not be destroyed. The existing session remains running at this point.
1703    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1704    ///   could not be started. No session will be running at this point.
1705    pub fn r#restart(
1706        &self,
1707        ___deadline: zx::MonotonicInstant,
1708    ) -> Result<RestarterRestartResult, fidl::Error> {
1709        let _response = self.client.send_query::<
1710            fidl::encoding::EmptyPayload,
1711            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RestartError>,
1712        >(
1713            (),
1714            0x50cd09e53189e5ae,
1715            fidl::encoding::DynamicFlags::empty(),
1716            ___deadline,
1717        )?;
1718        Ok(_response.map(|x| x))
1719    }
1720}
1721
1722#[derive(Debug, Clone)]
1723pub struct RestarterProxy {
1724    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1725}
1726
1727impl fidl::endpoints::Proxy for RestarterProxy {
1728    type Protocol = RestarterMarker;
1729
1730    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1731        Self::new(inner)
1732    }
1733
1734    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1735        self.client.into_channel().map_err(|client| Self { client })
1736    }
1737
1738    fn as_channel(&self) -> &::fidl::AsyncChannel {
1739        self.client.as_channel()
1740    }
1741}
1742
1743impl RestarterProxy {
1744    /// Create a new Proxy for fuchsia.session/Restarter.
1745    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1746        let protocol_name = <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1747        Self { client: fidl::client::Client::new(channel, protocol_name) }
1748    }
1749
1750    /// Get a Stream of events from the remote end of the protocol.
1751    ///
1752    /// # Panics
1753    ///
1754    /// Panics if the event stream was already taken.
1755    pub fn take_event_stream(&self) -> RestarterEventStream {
1756        RestarterEventStream { event_receiver: self.client.take_event_receiver() }
1757    }
1758
1759    /// Restarts the session.
1760    ///
1761    /// * error `RestartError.NOT_RUNNING` if there is no
1762    ///   currently running session to restart.
1763    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1764    ///   could not be destroyed. The existing session remains running at this point.
1765    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1766    ///   could not be started. No session will be running at this point.
1767    pub fn r#restart(
1768        &self,
1769    ) -> fidl::client::QueryResponseFut<
1770        RestarterRestartResult,
1771        fidl::encoding::DefaultFuchsiaResourceDialect,
1772    > {
1773        RestarterProxyInterface::r#restart(self)
1774    }
1775}
1776
1777impl RestarterProxyInterface for RestarterProxy {
1778    type RestartResponseFut = fidl::client::QueryResponseFut<
1779        RestarterRestartResult,
1780        fidl::encoding::DefaultFuchsiaResourceDialect,
1781    >;
1782    fn r#restart(&self) -> Self::RestartResponseFut {
1783        fn _decode(
1784            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1785        ) -> Result<RestarterRestartResult, fidl::Error> {
1786            let _response = fidl::client::decode_transaction_body::<
1787                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RestartError>,
1788                fidl::encoding::DefaultFuchsiaResourceDialect,
1789                0x50cd09e53189e5ae,
1790            >(_buf?)?;
1791            Ok(_response.map(|x| x))
1792        }
1793        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, RestarterRestartResult>(
1794            (),
1795            0x50cd09e53189e5ae,
1796            fidl::encoding::DynamicFlags::empty(),
1797            _decode,
1798        )
1799    }
1800}
1801
1802pub struct RestarterEventStream {
1803    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1804}
1805
1806impl std::marker::Unpin for RestarterEventStream {}
1807
1808impl futures::stream::FusedStream for RestarterEventStream {
1809    fn is_terminated(&self) -> bool {
1810        self.event_receiver.is_terminated()
1811    }
1812}
1813
1814impl futures::Stream for RestarterEventStream {
1815    type Item = Result<RestarterEvent, fidl::Error>;
1816
1817    fn poll_next(
1818        mut self: std::pin::Pin<&mut Self>,
1819        cx: &mut std::task::Context<'_>,
1820    ) -> std::task::Poll<Option<Self::Item>> {
1821        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1822            &mut self.event_receiver,
1823            cx
1824        )?) {
1825            Some(buf) => std::task::Poll::Ready(Some(RestarterEvent::decode(buf))),
1826            None => std::task::Poll::Ready(None),
1827        }
1828    }
1829}
1830
1831#[derive(Debug)]
1832pub enum RestarterEvent {}
1833
1834impl RestarterEvent {
1835    /// Decodes a message buffer as a [`RestarterEvent`].
1836    fn decode(
1837        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1838    ) -> Result<RestarterEvent, fidl::Error> {
1839        let (bytes, _handles) = buf.split_mut();
1840        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1841        debug_assert_eq!(tx_header.tx_id, 0);
1842        match tx_header.ordinal {
1843            _ => Err(fidl::Error::UnknownOrdinal {
1844                ordinal: tx_header.ordinal,
1845                protocol_name: <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1846            }),
1847        }
1848    }
1849}
1850
1851/// A Stream of incoming requests for fuchsia.session/Restarter.
1852pub struct RestarterRequestStream {
1853    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1854    is_terminated: bool,
1855}
1856
1857impl std::marker::Unpin for RestarterRequestStream {}
1858
1859impl futures::stream::FusedStream for RestarterRequestStream {
1860    fn is_terminated(&self) -> bool {
1861        self.is_terminated
1862    }
1863}
1864
1865impl fidl::endpoints::RequestStream for RestarterRequestStream {
1866    type Protocol = RestarterMarker;
1867    type ControlHandle = RestarterControlHandle;
1868
1869    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1870        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1871    }
1872
1873    fn control_handle(&self) -> Self::ControlHandle {
1874        RestarterControlHandle { inner: self.inner.clone() }
1875    }
1876
1877    fn into_inner(
1878        self,
1879    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1880    {
1881        (self.inner, self.is_terminated)
1882    }
1883
1884    fn from_inner(
1885        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1886        is_terminated: bool,
1887    ) -> Self {
1888        Self { inner, is_terminated }
1889    }
1890}
1891
1892impl futures::Stream for RestarterRequestStream {
1893    type Item = Result<RestarterRequest, fidl::Error>;
1894
1895    fn poll_next(
1896        mut self: std::pin::Pin<&mut Self>,
1897        cx: &mut std::task::Context<'_>,
1898    ) -> std::task::Poll<Option<Self::Item>> {
1899        let this = &mut *self;
1900        if this.inner.check_shutdown(cx) {
1901            this.is_terminated = true;
1902            return std::task::Poll::Ready(None);
1903        }
1904        if this.is_terminated {
1905            panic!("polled RestarterRequestStream after completion");
1906        }
1907        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1908            |bytes, handles| {
1909                match this.inner.channel().read_etc(cx, bytes, handles) {
1910                    std::task::Poll::Ready(Ok(())) => {}
1911                    std::task::Poll::Pending => return std::task::Poll::Pending,
1912                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1913                        this.is_terminated = true;
1914                        return std::task::Poll::Ready(None);
1915                    }
1916                    std::task::Poll::Ready(Err(e)) => {
1917                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1918                            e.into(),
1919                        ))))
1920                    }
1921                }
1922
1923                // A message has been received from the channel
1924                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1925
1926                std::task::Poll::Ready(Some(match header.ordinal {
1927                    0x50cd09e53189e5ae => {
1928                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1929                        let mut req = fidl::new_empty!(
1930                            fidl::encoding::EmptyPayload,
1931                            fidl::encoding::DefaultFuchsiaResourceDialect
1932                        );
1933                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1934                        let control_handle = RestarterControlHandle { inner: this.inner.clone() };
1935                        Ok(RestarterRequest::Restart {
1936                            responder: RestarterRestartResponder {
1937                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1938                                tx_id: header.tx_id,
1939                            },
1940                        })
1941                    }
1942                    _ => Err(fidl::Error::UnknownOrdinal {
1943                        ordinal: header.ordinal,
1944                        protocol_name:
1945                            <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1946                    }),
1947                }))
1948            },
1949        )
1950    }
1951}
1952
1953/// A protocol used to restart the currently running session.
1954#[derive(Debug)]
1955pub enum RestarterRequest {
1956    /// Restarts the session.
1957    ///
1958    /// * error `RestartError.NOT_RUNNING` if there is no
1959    ///   currently running session to restart.
1960    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1961    ///   could not be destroyed. The existing session remains running at this point.
1962    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1963    ///   could not be started. No session will be running at this point.
1964    Restart { responder: RestarterRestartResponder },
1965}
1966
1967impl RestarterRequest {
1968    #[allow(irrefutable_let_patterns)]
1969    pub fn into_restart(self) -> Option<(RestarterRestartResponder)> {
1970        if let RestarterRequest::Restart { responder } = self {
1971            Some((responder))
1972        } else {
1973            None
1974        }
1975    }
1976
1977    /// Name of the method defined in FIDL
1978    pub fn method_name(&self) -> &'static str {
1979        match *self {
1980            RestarterRequest::Restart { .. } => "restart",
1981        }
1982    }
1983}
1984
1985#[derive(Debug, Clone)]
1986pub struct RestarterControlHandle {
1987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1988}
1989
1990impl fidl::endpoints::ControlHandle for RestarterControlHandle {
1991    fn shutdown(&self) {
1992        self.inner.shutdown()
1993    }
1994    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1995        self.inner.shutdown_with_epitaph(status)
1996    }
1997
1998    fn is_closed(&self) -> bool {
1999        self.inner.channel().is_closed()
2000    }
2001    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2002        self.inner.channel().on_closed()
2003    }
2004
2005    #[cfg(target_os = "fuchsia")]
2006    fn signal_peer(
2007        &self,
2008        clear_mask: zx::Signals,
2009        set_mask: zx::Signals,
2010    ) -> Result<(), zx_status::Status> {
2011        use fidl::Peered;
2012        self.inner.channel().signal_peer(clear_mask, set_mask)
2013    }
2014}
2015
2016impl RestarterControlHandle {}
2017
2018#[must_use = "FIDL methods require a response to be sent"]
2019#[derive(Debug)]
2020pub struct RestarterRestartResponder {
2021    control_handle: std::mem::ManuallyDrop<RestarterControlHandle>,
2022    tx_id: u32,
2023}
2024
2025/// Set the the channel to be shutdown (see [`RestarterControlHandle::shutdown`])
2026/// if the responder is dropped without sending a response, so that the client
2027/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2028impl std::ops::Drop for RestarterRestartResponder {
2029    fn drop(&mut self) {
2030        self.control_handle.shutdown();
2031        // Safety: drops once, never accessed again
2032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2033    }
2034}
2035
2036impl fidl::endpoints::Responder for RestarterRestartResponder {
2037    type ControlHandle = RestarterControlHandle;
2038
2039    fn control_handle(&self) -> &RestarterControlHandle {
2040        &self.control_handle
2041    }
2042
2043    fn drop_without_shutdown(mut self) {
2044        // Safety: drops once, never accessed again due to mem::forget
2045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2046        // Prevent Drop from running (which would shut down the channel)
2047        std::mem::forget(self);
2048    }
2049}
2050
2051impl RestarterRestartResponder {
2052    /// Sends a response to the FIDL transaction.
2053    ///
2054    /// Sets the channel to shutdown if an error occurs.
2055    pub fn send(self, mut result: Result<(), RestartError>) -> Result<(), fidl::Error> {
2056        let _result = self.send_raw(result);
2057        if _result.is_err() {
2058            self.control_handle.shutdown();
2059        }
2060        self.drop_without_shutdown();
2061        _result
2062    }
2063
2064    /// Similar to "send" but does not shutdown the channel if an error occurs.
2065    pub fn send_no_shutdown_on_err(
2066        self,
2067        mut result: Result<(), RestartError>,
2068    ) -> Result<(), fidl::Error> {
2069        let _result = self.send_raw(result);
2070        self.drop_without_shutdown();
2071        _result
2072    }
2073
2074    fn send_raw(&self, mut result: Result<(), RestartError>) -> Result<(), fidl::Error> {
2075        self.control_handle.inner.send::<fidl::encoding::ResultType<
2076            fidl::encoding::EmptyStruct,
2077            RestartError,
2078        >>(
2079            result,
2080            self.tx_id,
2081            0x50cd09e53189e5ae,
2082            fidl::encoding::DynamicFlags::empty(),
2083        )
2084    }
2085}
2086
2087mod internal {
2088    use super::*;
2089    unsafe impl fidl::encoding::TypeMarker for LaunchError {
2090        type Owned = Self;
2091
2092        #[inline(always)]
2093        fn inline_align(_context: fidl::encoding::Context) -> usize {
2094            std::mem::align_of::<u32>()
2095        }
2096
2097        #[inline(always)]
2098        fn inline_size(_context: fidl::encoding::Context) -> usize {
2099            std::mem::size_of::<u32>()
2100        }
2101
2102        #[inline(always)]
2103        fn encode_is_copy() -> bool {
2104            false
2105        }
2106
2107        #[inline(always)]
2108        fn decode_is_copy() -> bool {
2109            false
2110        }
2111    }
2112
2113    impl fidl::encoding::ValueTypeMarker for LaunchError {
2114        type Borrowed<'a> = Self;
2115        #[inline(always)]
2116        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2117            *value
2118        }
2119    }
2120
2121    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LaunchError {
2122        #[inline]
2123        unsafe fn encode(
2124            self,
2125            encoder: &mut fidl::encoding::Encoder<'_, D>,
2126            offset: usize,
2127            _depth: fidl::encoding::Depth,
2128        ) -> fidl::Result<()> {
2129            encoder.debug_check_bounds::<Self>(offset);
2130            encoder.write_num(self.into_primitive(), offset);
2131            Ok(())
2132        }
2133    }
2134
2135    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchError {
2136        #[inline(always)]
2137        fn new_empty() -> Self {
2138            Self::unknown()
2139        }
2140
2141        #[inline]
2142        unsafe fn decode(
2143            &mut self,
2144            decoder: &mut fidl::encoding::Decoder<'_, D>,
2145            offset: usize,
2146            _depth: fidl::encoding::Depth,
2147        ) -> fidl::Result<()> {
2148            decoder.debug_check_bounds::<Self>(offset);
2149            let prim = decoder.read_num::<u32>(offset);
2150
2151            *self = Self::from_primitive_allow_unknown(prim);
2152            Ok(())
2153        }
2154    }
2155    unsafe impl fidl::encoding::TypeMarker for LifecycleError {
2156        type Owned = Self;
2157
2158        #[inline(always)]
2159        fn inline_align(_context: fidl::encoding::Context) -> usize {
2160            std::mem::align_of::<u32>()
2161        }
2162
2163        #[inline(always)]
2164        fn inline_size(_context: fidl::encoding::Context) -> usize {
2165            std::mem::size_of::<u32>()
2166        }
2167
2168        #[inline(always)]
2169        fn encode_is_copy() -> bool {
2170            false
2171        }
2172
2173        #[inline(always)]
2174        fn decode_is_copy() -> bool {
2175            false
2176        }
2177    }
2178
2179    impl fidl::encoding::ValueTypeMarker for LifecycleError {
2180        type Borrowed<'a> = Self;
2181        #[inline(always)]
2182        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2183            *value
2184        }
2185    }
2186
2187    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LifecycleError {
2188        #[inline]
2189        unsafe fn encode(
2190            self,
2191            encoder: &mut fidl::encoding::Encoder<'_, D>,
2192            offset: usize,
2193            _depth: fidl::encoding::Depth,
2194        ) -> fidl::Result<()> {
2195            encoder.debug_check_bounds::<Self>(offset);
2196            encoder.write_num(self.into_primitive(), offset);
2197            Ok(())
2198        }
2199    }
2200
2201    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LifecycleError {
2202        #[inline(always)]
2203        fn new_empty() -> Self {
2204            Self::unknown()
2205        }
2206
2207        #[inline]
2208        unsafe fn decode(
2209            &mut self,
2210            decoder: &mut fidl::encoding::Decoder<'_, D>,
2211            offset: usize,
2212            _depth: fidl::encoding::Depth,
2213        ) -> fidl::Result<()> {
2214            decoder.debug_check_bounds::<Self>(offset);
2215            let prim = decoder.read_num::<u32>(offset);
2216
2217            *self = Self::from_primitive_allow_unknown(prim);
2218            Ok(())
2219        }
2220    }
2221    unsafe impl fidl::encoding::TypeMarker for RestartError {
2222        type Owned = Self;
2223
2224        #[inline(always)]
2225        fn inline_align(_context: fidl::encoding::Context) -> usize {
2226            std::mem::align_of::<u32>()
2227        }
2228
2229        #[inline(always)]
2230        fn inline_size(_context: fidl::encoding::Context) -> usize {
2231            std::mem::size_of::<u32>()
2232        }
2233
2234        #[inline(always)]
2235        fn encode_is_copy() -> bool {
2236            false
2237        }
2238
2239        #[inline(always)]
2240        fn decode_is_copy() -> bool {
2241            false
2242        }
2243    }
2244
2245    impl fidl::encoding::ValueTypeMarker for RestartError {
2246        type Borrowed<'a> = Self;
2247        #[inline(always)]
2248        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2249            *value
2250        }
2251    }
2252
2253    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RestartError {
2254        #[inline]
2255        unsafe fn encode(
2256            self,
2257            encoder: &mut fidl::encoding::Encoder<'_, D>,
2258            offset: usize,
2259            _depth: fidl::encoding::Depth,
2260        ) -> fidl::Result<()> {
2261            encoder.debug_check_bounds::<Self>(offset);
2262            encoder.write_num(self.into_primitive(), offset);
2263            Ok(())
2264        }
2265    }
2266
2267    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RestartError {
2268        #[inline(always)]
2269        fn new_empty() -> Self {
2270            Self::unknown()
2271        }
2272
2273        #[inline]
2274        unsafe fn decode(
2275            &mut self,
2276            decoder: &mut fidl::encoding::Decoder<'_, D>,
2277            offset: usize,
2278            _depth: fidl::encoding::Depth,
2279        ) -> fidl::Result<()> {
2280            decoder.debug_check_bounds::<Self>(offset);
2281            let prim = decoder.read_num::<u32>(offset);
2282
2283            *self = Self::from_primitive_allow_unknown(prim);
2284            Ok(())
2285        }
2286    }
2287
2288    impl fidl::encoding::ValueTypeMarker for LauncherLaunchRequest {
2289        type Borrowed<'a> = &'a Self;
2290        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2291            value
2292        }
2293    }
2294
2295    unsafe impl fidl::encoding::TypeMarker for LauncherLaunchRequest {
2296        type Owned = Self;
2297
2298        #[inline(always)]
2299        fn inline_align(_context: fidl::encoding::Context) -> usize {
2300            8
2301        }
2302
2303        #[inline(always)]
2304        fn inline_size(_context: fidl::encoding::Context) -> usize {
2305            16
2306        }
2307    }
2308
2309    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LauncherLaunchRequest, D>
2310        for &LauncherLaunchRequest
2311    {
2312        #[inline]
2313        unsafe fn encode(
2314            self,
2315            encoder: &mut fidl::encoding::Encoder<'_, D>,
2316            offset: usize,
2317            _depth: fidl::encoding::Depth,
2318        ) -> fidl::Result<()> {
2319            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
2320            // Delegate to tuple encoding.
2321            fidl::encoding::Encode::<LauncherLaunchRequest, D>::encode(
2322                (<LaunchConfiguration as fidl::encoding::ValueTypeMarker>::borrow(
2323                    &self.configuration,
2324                ),),
2325                encoder,
2326                offset,
2327                _depth,
2328            )
2329        }
2330    }
2331    unsafe impl<
2332            D: fidl::encoding::ResourceDialect,
2333            T0: fidl::encoding::Encode<LaunchConfiguration, D>,
2334        > fidl::encoding::Encode<LauncherLaunchRequest, D> for (T0,)
2335    {
2336        #[inline]
2337        unsafe fn encode(
2338            self,
2339            encoder: &mut fidl::encoding::Encoder<'_, D>,
2340            offset: usize,
2341            depth: fidl::encoding::Depth,
2342        ) -> fidl::Result<()> {
2343            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
2344            // Zero out padding regions. There's no need to apply masks
2345            // because the unmasked parts will be overwritten by fields.
2346            // Write the fields.
2347            self.0.encode(encoder, offset + 0, depth)?;
2348            Ok(())
2349        }
2350    }
2351
2352    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LauncherLaunchRequest {
2353        #[inline(always)]
2354        fn new_empty() -> Self {
2355            Self { configuration: fidl::new_empty!(LaunchConfiguration, D) }
2356        }
2357
2358        #[inline]
2359        unsafe fn decode(
2360            &mut self,
2361            decoder: &mut fidl::encoding::Decoder<'_, D>,
2362            offset: usize,
2363            _depth: fidl::encoding::Depth,
2364        ) -> fidl::Result<()> {
2365            decoder.debug_check_bounds::<Self>(offset);
2366            // Verify that padding bytes are zero.
2367            fidl::decode!(
2368                LaunchConfiguration,
2369                D,
2370                &mut self.configuration,
2371                decoder,
2372                offset + 0,
2373                _depth
2374            )?;
2375            Ok(())
2376        }
2377    }
2378
2379    impl LaunchConfiguration {
2380        #[inline(always)]
2381        fn max_ordinal_present(&self) -> u64 {
2382            if let Some(_) = self.config_capabilities {
2383                return 2;
2384            }
2385            if let Some(_) = self.session_url {
2386                return 1;
2387            }
2388            0
2389        }
2390    }
2391
2392    impl fidl::encoding::ValueTypeMarker for LaunchConfiguration {
2393        type Borrowed<'a> = &'a Self;
2394        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2395            value
2396        }
2397    }
2398
2399    unsafe impl fidl::encoding::TypeMarker for LaunchConfiguration {
2400        type Owned = Self;
2401
2402        #[inline(always)]
2403        fn inline_align(_context: fidl::encoding::Context) -> usize {
2404            8
2405        }
2406
2407        #[inline(always)]
2408        fn inline_size(_context: fidl::encoding::Context) -> usize {
2409            16
2410        }
2411    }
2412
2413    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LaunchConfiguration, D>
2414        for &LaunchConfiguration
2415    {
2416        unsafe fn encode(
2417            self,
2418            encoder: &mut fidl::encoding::Encoder<'_, D>,
2419            offset: usize,
2420            mut depth: fidl::encoding::Depth,
2421        ) -> fidl::Result<()> {
2422            encoder.debug_check_bounds::<LaunchConfiguration>(offset);
2423            // Vector header
2424            let max_ordinal: u64 = self.max_ordinal_present();
2425            encoder.write_num(max_ordinal, offset);
2426            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2427            // Calling encoder.out_of_line_offset(0) is not allowed.
2428            if max_ordinal == 0 {
2429                return Ok(());
2430            }
2431            depth.increment()?;
2432            let envelope_size = 8;
2433            let bytes_len = max_ordinal as usize * envelope_size;
2434            #[allow(unused_variables)]
2435            let offset = encoder.out_of_line_offset(bytes_len);
2436            let mut _prev_end_offset: usize = 0;
2437            if 1 > max_ordinal {
2438                return Ok(());
2439            }
2440
2441            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2442            // are envelope_size bytes.
2443            let cur_offset: usize = (1 - 1) * envelope_size;
2444
2445            // Zero reserved fields.
2446            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2447
2448            // Safety:
2449            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2450            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2451            //   envelope_size bytes, there is always sufficient room.
2452            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
2453            self.session_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
2454            encoder, offset + cur_offset, depth
2455        )?;
2456
2457            _prev_end_offset = cur_offset + envelope_size;
2458            if 2 > max_ordinal {
2459                return Ok(());
2460            }
2461
2462            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2463            // are envelope_size bytes.
2464            let cur_offset: usize = (2 - 1) * envelope_size;
2465
2466            // Zero reserved fields.
2467            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2468
2469            // Safety:
2470            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2471            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2472            //   envelope_size bytes, there is always sufficient room.
2473            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>, D>(
2474            self.config_capabilities.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration> as fidl::encoding::ValueTypeMarker>::borrow),
2475            encoder, offset + cur_offset, depth
2476        )?;
2477
2478            _prev_end_offset = cur_offset + envelope_size;
2479
2480            Ok(())
2481        }
2482    }
2483
2484    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchConfiguration {
2485        #[inline(always)]
2486        fn new_empty() -> Self {
2487            Self::default()
2488        }
2489
2490        unsafe fn decode(
2491            &mut self,
2492            decoder: &mut fidl::encoding::Decoder<'_, D>,
2493            offset: usize,
2494            mut depth: fidl::encoding::Depth,
2495        ) -> fidl::Result<()> {
2496            decoder.debug_check_bounds::<Self>(offset);
2497            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2498                None => return Err(fidl::Error::NotNullable),
2499                Some(len) => len,
2500            };
2501            // Calling decoder.out_of_line_offset(0) is not allowed.
2502            if len == 0 {
2503                return Ok(());
2504            };
2505            depth.increment()?;
2506            let envelope_size = 8;
2507            let bytes_len = len * envelope_size;
2508            let offset = decoder.out_of_line_offset(bytes_len)?;
2509            // Decode the envelope for each type.
2510            let mut _next_ordinal_to_read = 0;
2511            let mut next_offset = offset;
2512            let end_offset = offset + bytes_len;
2513            _next_ordinal_to_read += 1;
2514            if next_offset >= end_offset {
2515                return Ok(());
2516            }
2517
2518            // Decode unknown envelopes for gaps in ordinals.
2519            while _next_ordinal_to_read < 1 {
2520                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2521                _next_ordinal_to_read += 1;
2522                next_offset += envelope_size;
2523            }
2524
2525            let next_out_of_line = decoder.next_out_of_line();
2526            let handles_before = decoder.remaining_handles();
2527            if let Some((inlined, num_bytes, num_handles)) =
2528                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2529            {
2530                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2531                if inlined != (member_inline_size <= 4) {
2532                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2533                }
2534                let inner_offset;
2535                let mut inner_depth = depth.clone();
2536                if inlined {
2537                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2538                    inner_offset = next_offset;
2539                } else {
2540                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2541                    inner_depth.increment()?;
2542                }
2543                let val_ref = self.session_url.get_or_insert_with(|| {
2544                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
2545                });
2546                fidl::decode!(
2547                    fidl::encoding::BoundedString<4096>,
2548                    D,
2549                    val_ref,
2550                    decoder,
2551                    inner_offset,
2552                    inner_depth
2553                )?;
2554                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2555                {
2556                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2557                }
2558                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2559                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2560                }
2561            }
2562
2563            next_offset += envelope_size;
2564            _next_ordinal_to_read += 1;
2565            if next_offset >= end_offset {
2566                return Ok(());
2567            }
2568
2569            // Decode unknown envelopes for gaps in ordinals.
2570            while _next_ordinal_to_read < 2 {
2571                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2572                _next_ordinal_to_read += 1;
2573                next_offset += envelope_size;
2574            }
2575
2576            let next_out_of_line = decoder.next_out_of_line();
2577            let handles_before = decoder.remaining_handles();
2578            if let Some((inlined, num_bytes, num_handles)) =
2579                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2580            {
2581                let member_inline_size = <fidl::encoding::UnboundedVector<
2582                    fidl_fuchsia_component_decl::Configuration,
2583                > as fidl::encoding::TypeMarker>::inline_size(
2584                    decoder.context
2585                );
2586                if inlined != (member_inline_size <= 4) {
2587                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2588                }
2589                let inner_offset;
2590                let mut inner_depth = depth.clone();
2591                if inlined {
2592                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2593                    inner_offset = next_offset;
2594                } else {
2595                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2596                    inner_depth.increment()?;
2597                }
2598                let val_ref = self.config_capabilities.get_or_insert_with(|| {
2599                    fidl::new_empty!(
2600                        fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>,
2601                        D
2602                    )
2603                });
2604                fidl::decode!(
2605                    fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>,
2606                    D,
2607                    val_ref,
2608                    decoder,
2609                    inner_offset,
2610                    inner_depth
2611                )?;
2612                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2613                {
2614                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2615                }
2616                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2617                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2618                }
2619            }
2620
2621            next_offset += envelope_size;
2622
2623            // Decode the remaining unknown envelopes.
2624            while next_offset < end_offset {
2625                _next_ordinal_to_read += 1;
2626                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2627                next_offset += envelope_size;
2628            }
2629
2630            Ok(())
2631        }
2632    }
2633
2634    impl LifecycleStartRequest {
2635        #[inline(always)]
2636        fn max_ordinal_present(&self) -> u64 {
2637            if let Some(_) = self.session_url {
2638                return 1;
2639            }
2640            0
2641        }
2642    }
2643
2644    impl fidl::encoding::ValueTypeMarker for LifecycleStartRequest {
2645        type Borrowed<'a> = &'a Self;
2646        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2647            value
2648        }
2649    }
2650
2651    unsafe impl fidl::encoding::TypeMarker for LifecycleStartRequest {
2652        type Owned = Self;
2653
2654        #[inline(always)]
2655        fn inline_align(_context: fidl::encoding::Context) -> usize {
2656            8
2657        }
2658
2659        #[inline(always)]
2660        fn inline_size(_context: fidl::encoding::Context) -> usize {
2661            16
2662        }
2663    }
2664
2665    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LifecycleStartRequest, D>
2666        for &LifecycleStartRequest
2667    {
2668        unsafe fn encode(
2669            self,
2670            encoder: &mut fidl::encoding::Encoder<'_, D>,
2671            offset: usize,
2672            mut depth: fidl::encoding::Depth,
2673        ) -> fidl::Result<()> {
2674            encoder.debug_check_bounds::<LifecycleStartRequest>(offset);
2675            // Vector header
2676            let max_ordinal: u64 = self.max_ordinal_present();
2677            encoder.write_num(max_ordinal, offset);
2678            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2679            // Calling encoder.out_of_line_offset(0) is not allowed.
2680            if max_ordinal == 0 {
2681                return Ok(());
2682            }
2683            depth.increment()?;
2684            let envelope_size = 8;
2685            let bytes_len = max_ordinal as usize * envelope_size;
2686            #[allow(unused_variables)]
2687            let offset = encoder.out_of_line_offset(bytes_len);
2688            let mut _prev_end_offset: usize = 0;
2689            if 1 > max_ordinal {
2690                return Ok(());
2691            }
2692
2693            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2694            // are envelope_size bytes.
2695            let cur_offset: usize = (1 - 1) * envelope_size;
2696
2697            // Zero reserved fields.
2698            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2699
2700            // Safety:
2701            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2702            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2703            //   envelope_size bytes, there is always sufficient room.
2704            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
2705            self.session_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
2706            encoder, offset + cur_offset, depth
2707        )?;
2708
2709            _prev_end_offset = cur_offset + envelope_size;
2710
2711            Ok(())
2712        }
2713    }
2714
2715    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LifecycleStartRequest {
2716        #[inline(always)]
2717        fn new_empty() -> Self {
2718            Self::default()
2719        }
2720
2721        unsafe fn decode(
2722            &mut self,
2723            decoder: &mut fidl::encoding::Decoder<'_, D>,
2724            offset: usize,
2725            mut depth: fidl::encoding::Depth,
2726        ) -> fidl::Result<()> {
2727            decoder.debug_check_bounds::<Self>(offset);
2728            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2729                None => return Err(fidl::Error::NotNullable),
2730                Some(len) => len,
2731            };
2732            // Calling decoder.out_of_line_offset(0) is not allowed.
2733            if len == 0 {
2734                return Ok(());
2735            };
2736            depth.increment()?;
2737            let envelope_size = 8;
2738            let bytes_len = len * envelope_size;
2739            let offset = decoder.out_of_line_offset(bytes_len)?;
2740            // Decode the envelope for each type.
2741            let mut _next_ordinal_to_read = 0;
2742            let mut next_offset = offset;
2743            let end_offset = offset + bytes_len;
2744            _next_ordinal_to_read += 1;
2745            if next_offset >= end_offset {
2746                return Ok(());
2747            }
2748
2749            // Decode unknown envelopes for gaps in ordinals.
2750            while _next_ordinal_to_read < 1 {
2751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2752                _next_ordinal_to_read += 1;
2753                next_offset += envelope_size;
2754            }
2755
2756            let next_out_of_line = decoder.next_out_of_line();
2757            let handles_before = decoder.remaining_handles();
2758            if let Some((inlined, num_bytes, num_handles)) =
2759                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2760            {
2761                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2762                if inlined != (member_inline_size <= 4) {
2763                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2764                }
2765                let inner_offset;
2766                let mut inner_depth = depth.clone();
2767                if inlined {
2768                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2769                    inner_offset = next_offset;
2770                } else {
2771                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2772                    inner_depth.increment()?;
2773                }
2774                let val_ref = self.session_url.get_or_insert_with(|| {
2775                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
2776                });
2777                fidl::decode!(
2778                    fidl::encoding::BoundedString<4096>,
2779                    D,
2780                    val_ref,
2781                    decoder,
2782                    inner_offset,
2783                    inner_depth
2784                )?;
2785                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2786                {
2787                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2788                }
2789                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2790                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2791                }
2792            }
2793
2794            next_offset += envelope_size;
2795
2796            // Decode the remaining unknown envelopes.
2797            while next_offset < end_offset {
2798                _next_ordinal_to_read += 1;
2799                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2800                next_offset += envelope_size;
2801            }
2802
2803            Ok(())
2804        }
2805    }
2806}