fidl_fuchsia_session_common/
fidl_fuchsia_session_common.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::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// An error that occurs when launching a session.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum LaunchError {
14    /// The session's `LaunchConfiguration` is malformed.
15    InvalidArgs,
16    /// There was an error resolving the session's component URL.
17    NotFound,
18    /// The session component could not be destroyed.
19    DestroyComponentFailed,
20    /// The session component could not be created.
21    CreateComponentFailed,
22    #[doc(hidden)]
23    __SourceBreaking { unknown_ordinal: u32 },
24}
25
26/// Pattern that matches an unknown `LaunchError` member.
27#[macro_export]
28macro_rules! LaunchErrorUnknown {
29    () => {
30        _
31    };
32}
33
34impl LaunchError {
35    #[inline]
36    pub fn from_primitive(prim: u32) -> Option<Self> {
37        match prim {
38            1 => Some(Self::InvalidArgs),
39            2 => Some(Self::NotFound),
40            3 => Some(Self::DestroyComponentFailed),
41            4 => Some(Self::CreateComponentFailed),
42            _ => None,
43        }
44    }
45
46    #[inline]
47    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
48        match prim {
49            1 => Self::InvalidArgs,
50            2 => Self::NotFound,
51            3 => Self::DestroyComponentFailed,
52            4 => Self::CreateComponentFailed,
53            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
54        }
55    }
56
57    #[inline]
58    pub fn unknown() -> Self {
59        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
60    }
61
62    #[inline]
63    pub const fn into_primitive(self) -> u32 {
64        match self {
65            Self::InvalidArgs => 1,
66            Self::NotFound => 2,
67            Self::DestroyComponentFailed => 3,
68            Self::CreateComponentFailed => 4,
69            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
70        }
71    }
72
73    #[inline]
74    pub fn is_unknown(&self) -> bool {
75        match self {
76            Self::__SourceBreaking { unknown_ordinal: _ } => true,
77            _ => false,
78        }
79    }
80}
81
82/// An error that occurs when updating the lifecycle a session.
83#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
84pub enum LifecycleError {
85    /// The session has not been started or there is no default session URL configured.
86    NotFound,
87    /// The session has already been started.
88    AlreadyStarted,
89    /// The session component could not be resolved.
90    ResolveComponentFailed,
91    /// The session component could not be created.
92    CreateComponentFailed,
93    /// The session component could not be destroyed.
94    DestroyComponentFailed,
95    #[doc(hidden)]
96    __SourceBreaking { unknown_ordinal: u32 },
97}
98
99/// Pattern that matches an unknown `LifecycleError` member.
100#[macro_export]
101macro_rules! LifecycleErrorUnknown {
102    () => {
103        _
104    };
105}
106
107impl LifecycleError {
108    #[inline]
109    pub fn from_primitive(prim: u32) -> Option<Self> {
110        match prim {
111            1 => Some(Self::NotFound),
112            2 => Some(Self::AlreadyStarted),
113            3 => Some(Self::ResolveComponentFailed),
114            4 => Some(Self::CreateComponentFailed),
115            5 => Some(Self::DestroyComponentFailed),
116            _ => None,
117        }
118    }
119
120    #[inline]
121    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
122        match prim {
123            1 => Self::NotFound,
124            2 => Self::AlreadyStarted,
125            3 => Self::ResolveComponentFailed,
126            4 => Self::CreateComponentFailed,
127            5 => Self::DestroyComponentFailed,
128            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
129        }
130    }
131
132    #[inline]
133    pub fn unknown() -> Self {
134        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
135    }
136
137    #[inline]
138    pub const fn into_primitive(self) -> u32 {
139        match self {
140            Self::NotFound => 1,
141            Self::AlreadyStarted => 2,
142            Self::ResolveComponentFailed => 3,
143            Self::CreateComponentFailed => 4,
144            Self::DestroyComponentFailed => 5,
145            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
146        }
147    }
148
149    #[inline]
150    pub fn is_unknown(&self) -> bool {
151        match self {
152            Self::__SourceBreaking { unknown_ordinal: _ } => true,
153            _ => false,
154        }
155    }
156}
157
158/// An error that occurs when restarting a session.
159#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
160pub enum RestartError {
161    /// There is no currently running session to restart.
162    NotRunning,
163    /// There was an error resolving the session's component URL.
164    NotFound,
165    /// The session component could not be destroyed.
166    DestroyComponentFailed,
167    /// The session component could not be created.
168    CreateComponentFailed,
169    #[doc(hidden)]
170    __SourceBreaking { unknown_ordinal: u32 },
171}
172
173/// Pattern that matches an unknown `RestartError` member.
174#[macro_export]
175macro_rules! RestartErrorUnknown {
176    () => {
177        _
178    };
179}
180
181impl RestartError {
182    #[inline]
183    pub fn from_primitive(prim: u32) -> Option<Self> {
184        match prim {
185            1 => Some(Self::NotRunning),
186            2 => Some(Self::NotFound),
187            3 => Some(Self::DestroyComponentFailed),
188            4 => Some(Self::CreateComponentFailed),
189            _ => None,
190        }
191    }
192
193    #[inline]
194    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
195        match prim {
196            1 => Self::NotRunning,
197            2 => Self::NotFound,
198            3 => Self::DestroyComponentFailed,
199            4 => Self::CreateComponentFailed,
200            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
201        }
202    }
203
204    #[inline]
205    pub fn unknown() -> Self {
206        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
207    }
208
209    #[inline]
210    pub const fn into_primitive(self) -> u32 {
211        match self {
212            Self::NotRunning => 1,
213            Self::NotFound => 2,
214            Self::DestroyComponentFailed => 3,
215            Self::CreateComponentFailed => 4,
216            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
217        }
218    }
219
220    #[inline]
221    pub fn is_unknown(&self) -> bool {
222        match self {
223            Self::__SourceBreaking { unknown_ordinal: _ } => true,
224            _ => false,
225        }
226    }
227}
228
229#[derive(Clone, Debug, PartialEq)]
230pub struct LauncherLaunchRequest {
231    pub configuration: LaunchConfiguration,
232}
233
234impl fidl::Persistable for LauncherLaunchRequest {}
235
236/// Describes a session to launch.
237#[derive(Clone, Debug, Default, PartialEq)]
238pub struct LaunchConfiguration {
239    /// The component URL of the session.
240    pub session_url: Option<String>,
241    /// Configuration capabilities that will be offered to the session.
242    ///
243    /// In the intended use case, the session component would use a particular
244    /// configuration capability with `transitional` availability. When such a
245    /// transitional capability is not offered to the session, the config value
246    /// from the package will be used. When it is offered using
247    /// `config_capabilities`, then the config value specified here will be
248    /// used. As such, one may override config values of the session component
249    /// that are set up following this pattern.
250    pub config_capabilities: Option<Vec<fidl_fuchsia_component_decl::Configuration>>,
251    #[doc(hidden)]
252    pub __source_breaking: fidl::marker::SourceBreaking,
253}
254
255impl fidl::Persistable for LaunchConfiguration {}
256
257#[derive(Clone, Debug, Default, PartialEq)]
258pub struct LifecycleStartRequest {
259    /// The component URL of the session.
260    ///
261    /// Optional. If omitted, uses the default configured session URL, if available.
262    pub session_url: Option<String>,
263    #[doc(hidden)]
264    pub __source_breaking: fidl::marker::SourceBreaking,
265}
266
267impl fidl::Persistable for LifecycleStartRequest {}
268
269mod internal {
270    use super::*;
271    unsafe impl fidl::encoding::TypeMarker for LaunchError {
272        type Owned = Self;
273
274        #[inline(always)]
275        fn inline_align(_context: fidl::encoding::Context) -> usize {
276            std::mem::align_of::<u32>()
277        }
278
279        #[inline(always)]
280        fn inline_size(_context: fidl::encoding::Context) -> usize {
281            std::mem::size_of::<u32>()
282        }
283
284        #[inline(always)]
285        fn encode_is_copy() -> bool {
286            false
287        }
288
289        #[inline(always)]
290        fn decode_is_copy() -> bool {
291            false
292        }
293    }
294
295    impl fidl::encoding::ValueTypeMarker for LaunchError {
296        type Borrowed<'a> = Self;
297        #[inline(always)]
298        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
299            *value
300        }
301    }
302
303    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LaunchError {
304        #[inline]
305        unsafe fn encode(
306            self,
307            encoder: &mut fidl::encoding::Encoder<'_, D>,
308            offset: usize,
309            _depth: fidl::encoding::Depth,
310        ) -> fidl::Result<()> {
311            encoder.debug_check_bounds::<Self>(offset);
312            encoder.write_num(self.into_primitive(), offset);
313            Ok(())
314        }
315    }
316
317    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchError {
318        #[inline(always)]
319        fn new_empty() -> Self {
320            Self::unknown()
321        }
322
323        #[inline]
324        unsafe fn decode(
325            &mut self,
326            decoder: &mut fidl::encoding::Decoder<'_, D>,
327            offset: usize,
328            _depth: fidl::encoding::Depth,
329        ) -> fidl::Result<()> {
330            decoder.debug_check_bounds::<Self>(offset);
331            let prim = decoder.read_num::<u32>(offset);
332
333            *self = Self::from_primitive_allow_unknown(prim);
334            Ok(())
335        }
336    }
337    unsafe impl fidl::encoding::TypeMarker for LifecycleError {
338        type Owned = Self;
339
340        #[inline(always)]
341        fn inline_align(_context: fidl::encoding::Context) -> usize {
342            std::mem::align_of::<u32>()
343        }
344
345        #[inline(always)]
346        fn inline_size(_context: fidl::encoding::Context) -> usize {
347            std::mem::size_of::<u32>()
348        }
349
350        #[inline(always)]
351        fn encode_is_copy() -> bool {
352            false
353        }
354
355        #[inline(always)]
356        fn decode_is_copy() -> bool {
357            false
358        }
359    }
360
361    impl fidl::encoding::ValueTypeMarker for LifecycleError {
362        type Borrowed<'a> = Self;
363        #[inline(always)]
364        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
365            *value
366        }
367    }
368
369    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LifecycleError {
370        #[inline]
371        unsafe fn encode(
372            self,
373            encoder: &mut fidl::encoding::Encoder<'_, D>,
374            offset: usize,
375            _depth: fidl::encoding::Depth,
376        ) -> fidl::Result<()> {
377            encoder.debug_check_bounds::<Self>(offset);
378            encoder.write_num(self.into_primitive(), offset);
379            Ok(())
380        }
381    }
382
383    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LifecycleError {
384        #[inline(always)]
385        fn new_empty() -> Self {
386            Self::unknown()
387        }
388
389        #[inline]
390        unsafe fn decode(
391            &mut self,
392            decoder: &mut fidl::encoding::Decoder<'_, D>,
393            offset: usize,
394            _depth: fidl::encoding::Depth,
395        ) -> fidl::Result<()> {
396            decoder.debug_check_bounds::<Self>(offset);
397            let prim = decoder.read_num::<u32>(offset);
398
399            *self = Self::from_primitive_allow_unknown(prim);
400            Ok(())
401        }
402    }
403    unsafe impl fidl::encoding::TypeMarker for RestartError {
404        type Owned = Self;
405
406        #[inline(always)]
407        fn inline_align(_context: fidl::encoding::Context) -> usize {
408            std::mem::align_of::<u32>()
409        }
410
411        #[inline(always)]
412        fn inline_size(_context: fidl::encoding::Context) -> usize {
413            std::mem::size_of::<u32>()
414        }
415
416        #[inline(always)]
417        fn encode_is_copy() -> bool {
418            false
419        }
420
421        #[inline(always)]
422        fn decode_is_copy() -> bool {
423            false
424        }
425    }
426
427    impl fidl::encoding::ValueTypeMarker for RestartError {
428        type Borrowed<'a> = Self;
429        #[inline(always)]
430        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
431            *value
432        }
433    }
434
435    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RestartError {
436        #[inline]
437        unsafe fn encode(
438            self,
439            encoder: &mut fidl::encoding::Encoder<'_, D>,
440            offset: usize,
441            _depth: fidl::encoding::Depth,
442        ) -> fidl::Result<()> {
443            encoder.debug_check_bounds::<Self>(offset);
444            encoder.write_num(self.into_primitive(), offset);
445            Ok(())
446        }
447    }
448
449    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RestartError {
450        #[inline(always)]
451        fn new_empty() -> Self {
452            Self::unknown()
453        }
454
455        #[inline]
456        unsafe fn decode(
457            &mut self,
458            decoder: &mut fidl::encoding::Decoder<'_, D>,
459            offset: usize,
460            _depth: fidl::encoding::Depth,
461        ) -> fidl::Result<()> {
462            decoder.debug_check_bounds::<Self>(offset);
463            let prim = decoder.read_num::<u32>(offset);
464
465            *self = Self::from_primitive_allow_unknown(prim);
466            Ok(())
467        }
468    }
469
470    impl fidl::encoding::ValueTypeMarker for LauncherLaunchRequest {
471        type Borrowed<'a> = &'a Self;
472        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
473            value
474        }
475    }
476
477    unsafe impl fidl::encoding::TypeMarker for LauncherLaunchRequest {
478        type Owned = Self;
479
480        #[inline(always)]
481        fn inline_align(_context: fidl::encoding::Context) -> usize {
482            8
483        }
484
485        #[inline(always)]
486        fn inline_size(_context: fidl::encoding::Context) -> usize {
487            16
488        }
489    }
490
491    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LauncherLaunchRequest, D>
492        for &LauncherLaunchRequest
493    {
494        #[inline]
495        unsafe fn encode(
496            self,
497            encoder: &mut fidl::encoding::Encoder<'_, D>,
498            offset: usize,
499            _depth: fidl::encoding::Depth,
500        ) -> fidl::Result<()> {
501            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
502            // Delegate to tuple encoding.
503            fidl::encoding::Encode::<LauncherLaunchRequest, D>::encode(
504                (<LaunchConfiguration as fidl::encoding::ValueTypeMarker>::borrow(
505                    &self.configuration,
506                ),),
507                encoder,
508                offset,
509                _depth,
510            )
511        }
512    }
513    unsafe impl<
514            D: fidl::encoding::ResourceDialect,
515            T0: fidl::encoding::Encode<LaunchConfiguration, D>,
516        > fidl::encoding::Encode<LauncherLaunchRequest, D> for (T0,)
517    {
518        #[inline]
519        unsafe fn encode(
520            self,
521            encoder: &mut fidl::encoding::Encoder<'_, D>,
522            offset: usize,
523            depth: fidl::encoding::Depth,
524        ) -> fidl::Result<()> {
525            encoder.debug_check_bounds::<LauncherLaunchRequest>(offset);
526            // Zero out padding regions. There's no need to apply masks
527            // because the unmasked parts will be overwritten by fields.
528            // Write the fields.
529            self.0.encode(encoder, offset + 0, depth)?;
530            Ok(())
531        }
532    }
533
534    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LauncherLaunchRequest {
535        #[inline(always)]
536        fn new_empty() -> Self {
537            Self { configuration: fidl::new_empty!(LaunchConfiguration, D) }
538        }
539
540        #[inline]
541        unsafe fn decode(
542            &mut self,
543            decoder: &mut fidl::encoding::Decoder<'_, D>,
544            offset: usize,
545            _depth: fidl::encoding::Depth,
546        ) -> fidl::Result<()> {
547            decoder.debug_check_bounds::<Self>(offset);
548            // Verify that padding bytes are zero.
549            fidl::decode!(
550                LaunchConfiguration,
551                D,
552                &mut self.configuration,
553                decoder,
554                offset + 0,
555                _depth
556            )?;
557            Ok(())
558        }
559    }
560
561    impl LaunchConfiguration {
562        #[inline(always)]
563        fn max_ordinal_present(&self) -> u64 {
564            if let Some(_) = self.config_capabilities {
565                return 2;
566            }
567            if let Some(_) = self.session_url {
568                return 1;
569            }
570            0
571        }
572    }
573
574    impl fidl::encoding::ValueTypeMarker for LaunchConfiguration {
575        type Borrowed<'a> = &'a Self;
576        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
577            value
578        }
579    }
580
581    unsafe impl fidl::encoding::TypeMarker for LaunchConfiguration {
582        type Owned = Self;
583
584        #[inline(always)]
585        fn inline_align(_context: fidl::encoding::Context) -> usize {
586            8
587        }
588
589        #[inline(always)]
590        fn inline_size(_context: fidl::encoding::Context) -> usize {
591            16
592        }
593    }
594
595    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LaunchConfiguration, D>
596        for &LaunchConfiguration
597    {
598        unsafe fn encode(
599            self,
600            encoder: &mut fidl::encoding::Encoder<'_, D>,
601            offset: usize,
602            mut depth: fidl::encoding::Depth,
603        ) -> fidl::Result<()> {
604            encoder.debug_check_bounds::<LaunchConfiguration>(offset);
605            // Vector header
606            let max_ordinal: u64 = self.max_ordinal_present();
607            encoder.write_num(max_ordinal, offset);
608            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
609            // Calling encoder.out_of_line_offset(0) is not allowed.
610            if max_ordinal == 0 {
611                return Ok(());
612            }
613            depth.increment()?;
614            let envelope_size = 8;
615            let bytes_len = max_ordinal as usize * envelope_size;
616            #[allow(unused_variables)]
617            let offset = encoder.out_of_line_offset(bytes_len);
618            let mut _prev_end_offset: usize = 0;
619            if 1 > max_ordinal {
620                return Ok(());
621            }
622
623            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
624            // are envelope_size bytes.
625            let cur_offset: usize = (1 - 1) * envelope_size;
626
627            // Zero reserved fields.
628            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
629
630            // Safety:
631            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
632            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
633            //   envelope_size bytes, there is always sufficient room.
634            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
635            self.session_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
636            encoder, offset + cur_offset, depth
637        )?;
638
639            _prev_end_offset = cur_offset + envelope_size;
640            if 2 > max_ordinal {
641                return Ok(());
642            }
643
644            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
645            // are envelope_size bytes.
646            let cur_offset: usize = (2 - 1) * envelope_size;
647
648            // Zero reserved fields.
649            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
650
651            // Safety:
652            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
653            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
654            //   envelope_size bytes, there is always sufficient room.
655            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>, D>(
656            self.config_capabilities.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration> as fidl::encoding::ValueTypeMarker>::borrow),
657            encoder, offset + cur_offset, depth
658        )?;
659
660            _prev_end_offset = cur_offset + envelope_size;
661
662            Ok(())
663        }
664    }
665
666    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchConfiguration {
667        #[inline(always)]
668        fn new_empty() -> Self {
669            Self::default()
670        }
671
672        unsafe fn decode(
673            &mut self,
674            decoder: &mut fidl::encoding::Decoder<'_, D>,
675            offset: usize,
676            mut depth: fidl::encoding::Depth,
677        ) -> fidl::Result<()> {
678            decoder.debug_check_bounds::<Self>(offset);
679            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
680                None => return Err(fidl::Error::NotNullable),
681                Some(len) => len,
682            };
683            // Calling decoder.out_of_line_offset(0) is not allowed.
684            if len == 0 {
685                return Ok(());
686            };
687            depth.increment()?;
688            let envelope_size = 8;
689            let bytes_len = len * envelope_size;
690            let offset = decoder.out_of_line_offset(bytes_len)?;
691            // Decode the envelope for each type.
692            let mut _next_ordinal_to_read = 0;
693            let mut next_offset = offset;
694            let end_offset = offset + bytes_len;
695            _next_ordinal_to_read += 1;
696            if next_offset >= end_offset {
697                return Ok(());
698            }
699
700            // Decode unknown envelopes for gaps in ordinals.
701            while _next_ordinal_to_read < 1 {
702                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
703                _next_ordinal_to_read += 1;
704                next_offset += envelope_size;
705            }
706
707            let next_out_of_line = decoder.next_out_of_line();
708            let handles_before = decoder.remaining_handles();
709            if let Some((inlined, num_bytes, num_handles)) =
710                fidl::encoding::decode_envelope_header(decoder, next_offset)?
711            {
712                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
713                if inlined != (member_inline_size <= 4) {
714                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
715                }
716                let inner_offset;
717                let mut inner_depth = depth.clone();
718                if inlined {
719                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
720                    inner_offset = next_offset;
721                } else {
722                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
723                    inner_depth.increment()?;
724                }
725                let val_ref = self.session_url.get_or_insert_with(|| {
726                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
727                });
728                fidl::decode!(
729                    fidl::encoding::BoundedString<4096>,
730                    D,
731                    val_ref,
732                    decoder,
733                    inner_offset,
734                    inner_depth
735                )?;
736                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
737                {
738                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
739                }
740                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
741                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
742                }
743            }
744
745            next_offset += envelope_size;
746            _next_ordinal_to_read += 1;
747            if next_offset >= end_offset {
748                return Ok(());
749            }
750
751            // Decode unknown envelopes for gaps in ordinals.
752            while _next_ordinal_to_read < 2 {
753                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
754                _next_ordinal_to_read += 1;
755                next_offset += envelope_size;
756            }
757
758            let next_out_of_line = decoder.next_out_of_line();
759            let handles_before = decoder.remaining_handles();
760            if let Some((inlined, num_bytes, num_handles)) =
761                fidl::encoding::decode_envelope_header(decoder, next_offset)?
762            {
763                let member_inline_size = <fidl::encoding::UnboundedVector<
764                    fidl_fuchsia_component_decl::Configuration,
765                > as fidl::encoding::TypeMarker>::inline_size(
766                    decoder.context
767                );
768                if inlined != (member_inline_size <= 4) {
769                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
770                }
771                let inner_offset;
772                let mut inner_depth = depth.clone();
773                if inlined {
774                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
775                    inner_offset = next_offset;
776                } else {
777                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
778                    inner_depth.increment()?;
779                }
780                let val_ref = self.config_capabilities.get_or_insert_with(|| {
781                    fidl::new_empty!(
782                        fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>,
783                        D
784                    )
785                });
786                fidl::decode!(
787                    fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl::Configuration>,
788                    D,
789                    val_ref,
790                    decoder,
791                    inner_offset,
792                    inner_depth
793                )?;
794                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
795                {
796                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
797                }
798                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
799                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
800                }
801            }
802
803            next_offset += envelope_size;
804
805            // Decode the remaining unknown envelopes.
806            while next_offset < end_offset {
807                _next_ordinal_to_read += 1;
808                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
809                next_offset += envelope_size;
810            }
811
812            Ok(())
813        }
814    }
815
816    impl LifecycleStartRequest {
817        #[inline(always)]
818        fn max_ordinal_present(&self) -> u64 {
819            if let Some(_) = self.session_url {
820                return 1;
821            }
822            0
823        }
824    }
825
826    impl fidl::encoding::ValueTypeMarker for LifecycleStartRequest {
827        type Borrowed<'a> = &'a Self;
828        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
829            value
830        }
831    }
832
833    unsafe impl fidl::encoding::TypeMarker for LifecycleStartRequest {
834        type Owned = Self;
835
836        #[inline(always)]
837        fn inline_align(_context: fidl::encoding::Context) -> usize {
838            8
839        }
840
841        #[inline(always)]
842        fn inline_size(_context: fidl::encoding::Context) -> usize {
843            16
844        }
845    }
846
847    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LifecycleStartRequest, D>
848        for &LifecycleStartRequest
849    {
850        unsafe fn encode(
851            self,
852            encoder: &mut fidl::encoding::Encoder<'_, D>,
853            offset: usize,
854            mut depth: fidl::encoding::Depth,
855        ) -> fidl::Result<()> {
856            encoder.debug_check_bounds::<LifecycleStartRequest>(offset);
857            // Vector header
858            let max_ordinal: u64 = self.max_ordinal_present();
859            encoder.write_num(max_ordinal, offset);
860            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
861            // Calling encoder.out_of_line_offset(0) is not allowed.
862            if max_ordinal == 0 {
863                return Ok(());
864            }
865            depth.increment()?;
866            let envelope_size = 8;
867            let bytes_len = max_ordinal as usize * envelope_size;
868            #[allow(unused_variables)]
869            let offset = encoder.out_of_line_offset(bytes_len);
870            let mut _prev_end_offset: usize = 0;
871            if 1 > max_ordinal {
872                return Ok(());
873            }
874
875            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
876            // are envelope_size bytes.
877            let cur_offset: usize = (1 - 1) * envelope_size;
878
879            // Zero reserved fields.
880            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
881
882            // Safety:
883            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
884            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
885            //   envelope_size bytes, there is always sufficient room.
886            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
887            self.session_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
888            encoder, offset + cur_offset, depth
889        )?;
890
891            _prev_end_offset = cur_offset + envelope_size;
892
893            Ok(())
894        }
895    }
896
897    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LifecycleStartRequest {
898        #[inline(always)]
899        fn new_empty() -> Self {
900            Self::default()
901        }
902
903        unsafe fn decode(
904            &mut self,
905            decoder: &mut fidl::encoding::Decoder<'_, D>,
906            offset: usize,
907            mut depth: fidl::encoding::Depth,
908        ) -> fidl::Result<()> {
909            decoder.debug_check_bounds::<Self>(offset);
910            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
911                None => return Err(fidl::Error::NotNullable),
912                Some(len) => len,
913            };
914            // Calling decoder.out_of_line_offset(0) is not allowed.
915            if len == 0 {
916                return Ok(());
917            };
918            depth.increment()?;
919            let envelope_size = 8;
920            let bytes_len = len * envelope_size;
921            let offset = decoder.out_of_line_offset(bytes_len)?;
922            // Decode the envelope for each type.
923            let mut _next_ordinal_to_read = 0;
924            let mut next_offset = offset;
925            let end_offset = offset + bytes_len;
926            _next_ordinal_to_read += 1;
927            if next_offset >= end_offset {
928                return Ok(());
929            }
930
931            // Decode unknown envelopes for gaps in ordinals.
932            while _next_ordinal_to_read < 1 {
933                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
934                _next_ordinal_to_read += 1;
935                next_offset += envelope_size;
936            }
937
938            let next_out_of_line = decoder.next_out_of_line();
939            let handles_before = decoder.remaining_handles();
940            if let Some((inlined, num_bytes, num_handles)) =
941                fidl::encoding::decode_envelope_header(decoder, next_offset)?
942            {
943                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
944                if inlined != (member_inline_size <= 4) {
945                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
946                }
947                let inner_offset;
948                let mut inner_depth = depth.clone();
949                if inlined {
950                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
951                    inner_offset = next_offset;
952                } else {
953                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
954                    inner_depth.increment()?;
955                }
956                let val_ref = self.session_url.get_or_insert_with(|| {
957                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
958                });
959                fidl::decode!(
960                    fidl::encoding::BoundedString<4096>,
961                    D,
962                    val_ref,
963                    decoder,
964                    inner_offset,
965                    inner_depth
966                )?;
967                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
968                {
969                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
970                }
971                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
972                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
973                }
974            }
975
976            next_offset += envelope_size;
977
978            // Decode the remaining unknown envelopes.
979            while next_offset < end_offset {
980                _next_ordinal_to_read += 1;
981                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
982                next_offset += envelope_size;
983            }
984
985            Ok(())
986        }
987    }
988}