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__common::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::<
656                fidl::encoding::UnboundedVector<fidl_fuchsia_component_decl__common::Configuration>,
657                D,
658            >(
659                self.config_capabilities.as_ref().map(
660                    <fidl::encoding::UnboundedVector<
661                        fidl_fuchsia_component_decl__common::Configuration,
662                    > as fidl::encoding::ValueTypeMarker>::borrow,
663                ),
664                encoder,
665                offset + cur_offset,
666                depth,
667            )?;
668
669            _prev_end_offset = cur_offset + envelope_size;
670
671            Ok(())
672        }
673    }
674
675    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchConfiguration {
676        #[inline(always)]
677        fn new_empty() -> Self {
678            Self::default()
679        }
680
681        unsafe fn decode(
682            &mut self,
683            decoder: &mut fidl::encoding::Decoder<'_, D>,
684            offset: usize,
685            mut depth: fidl::encoding::Depth,
686        ) -> fidl::Result<()> {
687            decoder.debug_check_bounds::<Self>(offset);
688            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
689                None => return Err(fidl::Error::NotNullable),
690                Some(len) => len,
691            };
692            // Calling decoder.out_of_line_offset(0) is not allowed.
693            if len == 0 {
694                return Ok(());
695            };
696            depth.increment()?;
697            let envelope_size = 8;
698            let bytes_len = len * envelope_size;
699            let offset = decoder.out_of_line_offset(bytes_len)?;
700            // Decode the envelope for each type.
701            let mut _next_ordinal_to_read = 0;
702            let mut next_offset = offset;
703            let end_offset = offset + bytes_len;
704            _next_ordinal_to_read += 1;
705            if next_offset >= end_offset {
706                return Ok(());
707            }
708
709            // Decode unknown envelopes for gaps in ordinals.
710            while _next_ordinal_to_read < 1 {
711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
712                _next_ordinal_to_read += 1;
713                next_offset += envelope_size;
714            }
715
716            let next_out_of_line = decoder.next_out_of_line();
717            let handles_before = decoder.remaining_handles();
718            if let Some((inlined, num_bytes, num_handles)) =
719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
720            {
721                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
722                if inlined != (member_inline_size <= 4) {
723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
724                }
725                let inner_offset;
726                let mut inner_depth = depth.clone();
727                if inlined {
728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
729                    inner_offset = next_offset;
730                } else {
731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
732                    inner_depth.increment()?;
733                }
734                let val_ref = self.session_url.get_or_insert_with(|| {
735                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
736                });
737                fidl::decode!(
738                    fidl::encoding::BoundedString<4096>,
739                    D,
740                    val_ref,
741                    decoder,
742                    inner_offset,
743                    inner_depth
744                )?;
745                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
746                {
747                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
748                }
749                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
750                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
751                }
752            }
753
754            next_offset += envelope_size;
755            _next_ordinal_to_read += 1;
756            if next_offset >= end_offset {
757                return Ok(());
758            }
759
760            // Decode unknown envelopes for gaps in ordinals.
761            while _next_ordinal_to_read < 2 {
762                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
763                _next_ordinal_to_read += 1;
764                next_offset += envelope_size;
765            }
766
767            let next_out_of_line = decoder.next_out_of_line();
768            let handles_before = decoder.remaining_handles();
769            if let Some((inlined, num_bytes, num_handles)) =
770                fidl::encoding::decode_envelope_header(decoder, next_offset)?
771            {
772                let member_inline_size = <fidl::encoding::UnboundedVector<
773                    fidl_fuchsia_component_decl__common::Configuration,
774                > as fidl::encoding::TypeMarker>::inline_size(
775                    decoder.context
776                );
777                if inlined != (member_inline_size <= 4) {
778                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
779                }
780                let inner_offset;
781                let mut inner_depth = depth.clone();
782                if inlined {
783                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
784                    inner_offset = next_offset;
785                } else {
786                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
787                    inner_depth.increment()?;
788                }
789                let val_ref = self.config_capabilities.get_or_insert_with(|| {
790                    fidl::new_empty!(
791                        fidl::encoding::UnboundedVector<
792                            fidl_fuchsia_component_decl__common::Configuration,
793                        >,
794                        D
795                    )
796                });
797                fidl::decode!(
798                    fidl::encoding::UnboundedVector<
799                        fidl_fuchsia_component_decl__common::Configuration,
800                    >,
801                    D,
802                    val_ref,
803                    decoder,
804                    inner_offset,
805                    inner_depth
806                )?;
807                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
808                {
809                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
810                }
811                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
812                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
813                }
814            }
815
816            next_offset += envelope_size;
817
818            // Decode the remaining unknown envelopes.
819            while next_offset < end_offset {
820                _next_ordinal_to_read += 1;
821                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
822                next_offset += envelope_size;
823            }
824
825            Ok(())
826        }
827    }
828
829    impl LifecycleStartRequest {
830        #[inline(always)]
831        fn max_ordinal_present(&self) -> u64 {
832            if let Some(_) = self.session_url {
833                return 1;
834            }
835            0
836        }
837    }
838
839    impl fidl::encoding::ValueTypeMarker for LifecycleStartRequest {
840        type Borrowed<'a> = &'a Self;
841        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
842            value
843        }
844    }
845
846    unsafe impl fidl::encoding::TypeMarker for LifecycleStartRequest {
847        type Owned = Self;
848
849        #[inline(always)]
850        fn inline_align(_context: fidl::encoding::Context) -> usize {
851            8
852        }
853
854        #[inline(always)]
855        fn inline_size(_context: fidl::encoding::Context) -> usize {
856            16
857        }
858    }
859
860    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LifecycleStartRequest, D>
861        for &LifecycleStartRequest
862    {
863        unsafe fn encode(
864            self,
865            encoder: &mut fidl::encoding::Encoder<'_, D>,
866            offset: usize,
867            mut depth: fidl::encoding::Depth,
868        ) -> fidl::Result<()> {
869            encoder.debug_check_bounds::<LifecycleStartRequest>(offset);
870            // Vector header
871            let max_ordinal: u64 = self.max_ordinal_present();
872            encoder.write_num(max_ordinal, offset);
873            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
874            // Calling encoder.out_of_line_offset(0) is not allowed.
875            if max_ordinal == 0 {
876                return Ok(());
877            }
878            depth.increment()?;
879            let envelope_size = 8;
880            let bytes_len = max_ordinal as usize * envelope_size;
881            #[allow(unused_variables)]
882            let offset = encoder.out_of_line_offset(bytes_len);
883            let mut _prev_end_offset: usize = 0;
884            if 1 > max_ordinal {
885                return Ok(());
886            }
887
888            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
889            // are envelope_size bytes.
890            let cur_offset: usize = (1 - 1) * envelope_size;
891
892            // Zero reserved fields.
893            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
894
895            // Safety:
896            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
897            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
898            //   envelope_size bytes, there is always sufficient room.
899            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
900            self.session_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
901            encoder, offset + cur_offset, depth
902        )?;
903
904            _prev_end_offset = cur_offset + envelope_size;
905
906            Ok(())
907        }
908    }
909
910    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LifecycleStartRequest {
911        #[inline(always)]
912        fn new_empty() -> Self {
913            Self::default()
914        }
915
916        unsafe fn decode(
917            &mut self,
918            decoder: &mut fidl::encoding::Decoder<'_, D>,
919            offset: usize,
920            mut depth: fidl::encoding::Depth,
921        ) -> fidl::Result<()> {
922            decoder.debug_check_bounds::<Self>(offset);
923            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
924                None => return Err(fidl::Error::NotNullable),
925                Some(len) => len,
926            };
927            // Calling decoder.out_of_line_offset(0) is not allowed.
928            if len == 0 {
929                return Ok(());
930            };
931            depth.increment()?;
932            let envelope_size = 8;
933            let bytes_len = len * envelope_size;
934            let offset = decoder.out_of_line_offset(bytes_len)?;
935            // Decode the envelope for each type.
936            let mut _next_ordinal_to_read = 0;
937            let mut next_offset = offset;
938            let end_offset = offset + bytes_len;
939            _next_ordinal_to_read += 1;
940            if next_offset >= end_offset {
941                return Ok(());
942            }
943
944            // Decode unknown envelopes for gaps in ordinals.
945            while _next_ordinal_to_read < 1 {
946                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
947                _next_ordinal_to_read += 1;
948                next_offset += envelope_size;
949            }
950
951            let next_out_of_line = decoder.next_out_of_line();
952            let handles_before = decoder.remaining_handles();
953            if let Some((inlined, num_bytes, num_handles)) =
954                fidl::encoding::decode_envelope_header(decoder, next_offset)?
955            {
956                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
957                if inlined != (member_inline_size <= 4) {
958                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
959                }
960                let inner_offset;
961                let mut inner_depth = depth.clone();
962                if inlined {
963                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
964                    inner_offset = next_offset;
965                } else {
966                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
967                    inner_depth.increment()?;
968                }
969                let val_ref = self.session_url.get_or_insert_with(|| {
970                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
971                });
972                fidl::decode!(
973                    fidl::encoding::BoundedString<4096>,
974                    D,
975                    val_ref,
976                    decoder,
977                    inner_offset,
978                    inner_depth
979                )?;
980                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
981                {
982                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
983                }
984                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
985                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
986                }
987            }
988
989            next_offset += envelope_size;
990
991            // Decode the remaining unknown envelopes.
992            while next_offset < end_offset {
993                _next_ordinal_to_read += 1;
994                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
995                next_offset += envelope_size;
996            }
997
998            Ok(())
999        }
1000    }
1001}