fidl_fuchsia_update__common/
fidl_fuchsia_update__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/// This is the maximum length of a version string that will be returned by the
12/// protocol
13pub const MAX_VERSION_STRING_SIZE: u32 = 128;
14
15/// This is the set of values that are returned by an request to immediately
16/// check for an update.
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
18#[repr(u32)]
19pub enum CheckNotStartedReason {
20    /// There was an internal error in starting the update check.  The client
21    /// is not expected to be able to do something meaningful about this error,
22    /// except to try again later (after an appropriate delay and back-off in
23    /// the event of multiple errors.
24    Internal = 1,
25    /// If there are required arguments or options (or option values in
26    /// conflict), provided via the CheckOptions table to CheckNow, this error
27    /// will be returned.
28    InvalidOptions = 2,
29    /// There was already another update check in progress when this request was
30    /// made.  A new update check will not be started.
31    AlreadyInProgress = 3,
32    /// The update check was not started, because too many requests to check for
33    /// updates have been made by clients in a short period of time.
34    ///
35    /// **NOTE:** Clients MUST NOT attempt to cause background update checks to
36    /// happen at a more frequent rate than the fuchsia.update.Manager will do
37    /// them.
38    ///
39    /// If a client attempts to abuse this, it will be throttled.
40    Throttled = 4,
41}
42
43impl CheckNotStartedReason {
44    #[inline]
45    pub fn from_primitive(prim: u32) -> Option<Self> {
46        match prim {
47            1 => Some(Self::Internal),
48            2 => Some(Self::InvalidOptions),
49            3 => Some(Self::AlreadyInProgress),
50            4 => Some(Self::Throttled),
51            _ => None,
52        }
53    }
54
55    #[inline]
56    pub const fn into_primitive(self) -> u32 {
57        self as u32
58    }
59}
60
61/// Who or what initiated the update check.
62#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
63#[repr(u32)]
64pub enum Initiator {
65    /// The update check was initiated by an interactive user, or the user is
66    /// otherwise blocked and waiting for the result of this update check.  This
67    /// SHOULD only be used when there is a UI element or flow that a user has
68    /// interacted with which has initiated this update check.
69    User = 1,
70    /// The update check was initiated by a service, not a user-facing aspect
71    /// of the system.
72    Service = 2,
73}
74
75impl Initiator {
76    #[inline]
77    pub fn from_primitive(prim: u32) -> Option<Self> {
78        match prim {
79            1 => Some(Self::User),
80            2 => Some(Self::Service),
81            _ => None,
82        }
83    }
84
85    #[inline]
86    pub const fn into_primitive(self) -> u32 {
87        self as u32
88    }
89}
90
91/// This is the set of values that are provided when an update installation
92/// is deferred.
93#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
94pub enum InstallationDeferralReason {
95    /// The update was not installed because the currently booted system is not
96    /// committed. Consumers are encouraged to use the [`CommitStatusProvider`]
97    /// to determine when to retry the update check such that the update will
98    /// be installed.
99    CurrentSystemNotCommitted,
100    #[doc(hidden)]
101    __SourceBreaking { unknown_ordinal: u32 },
102}
103
104/// Pattern that matches an unknown `InstallationDeferralReason` member.
105#[macro_export]
106macro_rules! InstallationDeferralReasonUnknown {
107    () => {
108        _
109    };
110}
111
112impl InstallationDeferralReason {
113    #[inline]
114    pub fn from_primitive(prim: u32) -> Option<Self> {
115        match prim {
116            1 => Some(Self::CurrentSystemNotCommitted),
117            _ => None,
118        }
119    }
120
121    #[inline]
122    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
123        match prim {
124            1 => Self::CurrentSystemNotCommitted,
125            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
126        }
127    }
128
129    #[inline]
130    pub fn unknown() -> Self {
131        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
132    }
133
134    #[inline]
135    pub const fn into_primitive(self) -> u32 {
136        match self {
137            Self::CurrentSystemNotCommitted => 1,
138            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
139        }
140    }
141
142    #[inline]
143    pub fn is_unknown(&self) -> bool {
144        match self {
145            Self::__SourceBreaking { unknown_ordinal: _ } => true,
146            _ => false,
147        }
148    }
149}
150
151#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152pub struct ManagerPerformPendingRebootResponse {
153    pub rebooting: bool,
154}
155
156impl fidl::Persistable for ManagerPerformPendingRebootResponse {}
157
158#[derive(Clone, Debug, PartialEq)]
159pub struct MonitorOnStateRequest {
160    pub state: State,
161}
162
163impl fidl::Persistable for MonitorOnStateRequest {}
164
165/// Details for an update attempt monitor.
166#[derive(Clone, Debug, Default, PartialEq)]
167pub struct AttemptOptions {
168    /// Who or what initiated this update attempt.  This may influence how the
169    /// update check is performed.
170    pub initiator: Option<Initiator>,
171    #[doc(hidden)]
172    pub __source_breaking: fidl::marker::SourceBreaking,
173}
174
175impl fidl::Persistable for AttemptOptions {}
176
177/// Configuration options for an update check.
178#[derive(Clone, Debug, Default, PartialEq)]
179pub struct CheckOptions {
180    /// Who or what initiated this update attempt.  This is taken as input to
181    /// Policy, and may influence how the update check is performed.
182    ///
183    /// **This is a required field.**
184    pub initiator: Option<Initiator>,
185    /// If an update check is already in progress, it's acceptable to instead
186    /// attach a Monitor to that in-progress update instead of failing this
187    /// request to check for updates.  This may convert situations that would
188    /// have resulted in the ALREADY_IN_PROGRESS to be treated as non-error
189    /// cases.
190    pub allow_attaching_to_existing_update_check: Option<bool>,
191    #[doc(hidden)]
192    pub __source_breaking: fidl::marker::SourceBreaking,
193}
194
195impl fidl::Persistable for CheckOptions {}
196
197/// This is the set of data associated with `checking_for_updates`.
198/// (currently none)
199#[derive(Clone, Debug, Default, PartialEq)]
200pub struct CheckingForUpdatesData {
201    #[doc(hidden)]
202    pub __source_breaking: fidl::marker::SourceBreaking,
203}
204
205impl fidl::Persistable for CheckingForUpdatesData {}
206
207/// This is the set of data associated with the `error_checking_for_update`
208/// state.
209/// (currently none)
210#[derive(Clone, Debug, Default, PartialEq)]
211pub struct ErrorCheckingForUpdateData {
212    #[doc(hidden)]
213    pub __source_breaking: fidl::marker::SourceBreaking,
214}
215
216impl fidl::Persistable for ErrorCheckingForUpdateData {}
217
218/// This is the set of data associated with the
219/// `installation_deferred_by_policy` state.
220#[derive(Clone, Debug, Default, PartialEq)]
221pub struct InstallationDeferredData {
222    pub update: Option<UpdateInfo>,
223    pub deferral_reason: Option<InstallationDeferralReason>,
224    #[doc(hidden)]
225    pub __source_breaking: fidl::marker::SourceBreaking,
226}
227
228impl fidl::Persistable for InstallationDeferredData {}
229
230/// This is the set of data associated with the `installation_error` state.
231/// (currently none)
232#[derive(Clone, Debug, Default, PartialEq)]
233pub struct InstallationErrorData {
234    pub update: Option<UpdateInfo>,
235    pub installation_progress: Option<InstallationProgress>,
236    #[doc(hidden)]
237    pub __source_breaking: fidl::marker::SourceBreaking,
238}
239
240impl fidl::Persistable for InstallationErrorData {}
241
242/// This describes the progress installing the update that has been made so far.
243#[derive(Clone, Debug, Default, PartialEq)]
244pub struct InstallationProgress {
245    /// The fraction [0-1.0f] of the installation that has been completed.
246    pub fraction_completed: Option<f32>,
247    #[doc(hidden)]
248    pub __source_breaking: fidl::marker::SourceBreaking,
249}
250
251impl fidl::Persistable for InstallationProgress {}
252
253/// This is the set of data associated with the states involved with installing
254/// an update:
255/// * `installing_update`
256/// * `waiting_for_reboot`
257#[derive(Clone, Debug, Default, PartialEq)]
258pub struct InstallingData {
259    pub update: Option<UpdateInfo>,
260    pub installation_progress: Option<InstallationProgress>,
261    #[doc(hidden)]
262    pub __source_breaking: fidl::marker::SourceBreaking,
263}
264
265impl fidl::Persistable for InstallingData {}
266
267/// This is the set of data associated with the `no_update_available` state.
268/// (currently none)
269#[derive(Clone, Debug, Default, PartialEq)]
270pub struct NoUpdateAvailableData {
271    #[doc(hidden)]
272    pub __source_breaking: fidl::marker::SourceBreaking,
273}
274
275impl fidl::Persistable for NoUpdateAvailableData {}
276
277/// This describes the update that is available to be installed.
278#[derive(Clone, Debug, Default, PartialEq)]
279pub struct UpdateInfo {
280    /// A string that describes the version that is available.  This may be
281    /// either a semantic version (A.B.C.D) or an opaque hash.  Clients MUST
282    /// not attempt to inspect this value, it is for display purposes only.
283    pub version_available: Option<String>,
284    /// The total number of bytes that may be downloaded to apply this update.
285    pub download_size: Option<u64>,
286    /// Whether the update was marked as urgent. Default is false.
287    pub urgent: Option<bool>,
288    #[doc(hidden)]
289    pub __source_breaking: fidl::marker::SourceBreaking,
290}
291
292impl fidl::Persistable for UpdateInfo {}
293
294/// The set of states that a [`Monitor`] can receive during an update check.
295///
296/// An update check ends when it enters a terminal state, denoted below as the
297/// states on the right-hand side of the diagram with no arrows leading out of
298/// them.
299///
300/// # State Machine Diagram
301///
302/// ```
303///     +----------------------+     +---------------------------------+
304///     | checking_for_updates |---->|    error_checking_for_update    |
305///     +----------------------+     +---------------------------------+
306///                |
307///                |                 +---------------------------------+
308///                +---------------->|       no_update_available       |
309///                |                 +---------------------------------+
310///                |
311///                |                 +---------------------------------+
312///                +---------------->| installation_deferred_by_policy |
313///                |                 +---------------------------------+
314///                v
315///     +----------------------+     +---------------------------------+
316///     |  installing_update   |---->|       installation_error        |
317///     +----------------------+     +---------------------------------+
318///                |
319///                |                 +---------------------------------+
320///                +---------------->|       waiting_for_reboot        |
321///                                  +---------------------------------+
322/// ```
323#[derive(Clone, Debug, PartialEq)]
324pub enum State {
325    /// The Manager is currently checking for an update.
326    ///
327    /// Next states:
328    /// * `installing_update` update is available and allowed by policy
329    /// * `error_checking_for_update` on error
330    /// * `update_deferred_by_policy` update is available but deferred by policy
331    CheckingForUpdates(CheckingForUpdatesData),
332    /// The Manager encountered an error while checking for the existence of a
333    /// a new update.
334    ///
335    /// **This is a terminal state**
336    ErrorCheckingForUpdate(ErrorCheckingForUpdateData),
337    /// There is not update available at this time.
338    ///
339    /// **This is a terminal state**
340    NoUpdateAvailable(NoUpdateAvailableData),
341    /// The Manager has found an available update but is not acting on it at
342    /// this time due to policy restrictions.
343    ///
344    /// **This is a terminal state**
345    InstallationDeferredByPolicy(InstallationDeferredData),
346    /// The Manager is installing the available update.
347    ///
348    /// Next states:
349    /// * `waiting_for_reboot` on success
350    /// * `installation_error` on error
351    InstallingUpdate(InstallingData),
352    /// The update has been installed, and the device is waiting to be rebooted.
353    ///
354    /// Next states:
355    /// * (none, the device reboots)
356    ///
357    /// **This is a terminal state**
358    WaitingForReboot(InstallingData),
359    /// The Manager encountered an update in the installation of the update.
360    ///
361    /// **This is a terminal state**
362    InstallationError(InstallationErrorData),
363}
364
365impl State {
366    #[inline]
367    pub fn ordinal(&self) -> u64 {
368        match *self {
369            Self::CheckingForUpdates(_) => 1,
370            Self::ErrorCheckingForUpdate(_) => 2,
371            Self::NoUpdateAvailable(_) => 3,
372            Self::InstallationDeferredByPolicy(_) => 4,
373            Self::InstallingUpdate(_) => 5,
374            Self::WaitingForReboot(_) => 6,
375            Self::InstallationError(_) => 7,
376        }
377    }
378}
379
380impl fidl::Persistable for State {}
381
382pub mod attempts_monitor_ordinals {
383    pub const ON_START: u64 = 0x75ea6bddd64d0714;
384}
385
386pub mod commit_status_provider_ordinals {
387    pub const IS_CURRENT_SYSTEM_COMMITTED: u64 = 0x4d49226840f25db1;
388}
389
390pub mod listener_ordinals {
391    pub const WAIT_FOR_FIRST_UPDATE_CHECK_TO_COMPLETE: u64 = 0x58c9beba5d88b008;
392}
393
394pub mod manager_ordinals {
395    pub const CHECK_NOW: u64 = 0x4a5a2327156c3ba8;
396    pub const PERFORM_PENDING_REBOOT: u64 = 0x69b7d3c620b0879d;
397    pub const MONITOR_ALL_UPDATE_CHECKS: u64 = 0x436bcf0efab3158b;
398}
399
400pub mod monitor_ordinals {
401    pub const ON_STATE: u64 = 0x6d3cf4cbb1e41734;
402}
403
404mod internal {
405    use super::*;
406    unsafe impl fidl::encoding::TypeMarker for CheckNotStartedReason {
407        type Owned = Self;
408
409        #[inline(always)]
410        fn inline_align(_context: fidl::encoding::Context) -> usize {
411            std::mem::align_of::<u32>()
412        }
413
414        #[inline(always)]
415        fn inline_size(_context: fidl::encoding::Context) -> usize {
416            std::mem::size_of::<u32>()
417        }
418
419        #[inline(always)]
420        fn encode_is_copy() -> bool {
421            true
422        }
423
424        #[inline(always)]
425        fn decode_is_copy() -> bool {
426            false
427        }
428    }
429
430    impl fidl::encoding::ValueTypeMarker for CheckNotStartedReason {
431        type Borrowed<'a> = Self;
432        #[inline(always)]
433        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
434            *value
435        }
436    }
437
438    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
439        for CheckNotStartedReason
440    {
441        #[inline]
442        unsafe fn encode(
443            self,
444            encoder: &mut fidl::encoding::Encoder<'_, D>,
445            offset: usize,
446            _depth: fidl::encoding::Depth,
447        ) -> fidl::Result<()> {
448            encoder.debug_check_bounds::<Self>(offset);
449            encoder.write_num(self.into_primitive(), offset);
450            Ok(())
451        }
452    }
453
454    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CheckNotStartedReason {
455        #[inline(always)]
456        fn new_empty() -> Self {
457            Self::Internal
458        }
459
460        #[inline]
461        unsafe fn decode(
462            &mut self,
463            decoder: &mut fidl::encoding::Decoder<'_, D>,
464            offset: usize,
465            _depth: fidl::encoding::Depth,
466        ) -> fidl::Result<()> {
467            decoder.debug_check_bounds::<Self>(offset);
468            let prim = decoder.read_num::<u32>(offset);
469
470            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
471            Ok(())
472        }
473    }
474    unsafe impl fidl::encoding::TypeMarker for Initiator {
475        type Owned = Self;
476
477        #[inline(always)]
478        fn inline_align(_context: fidl::encoding::Context) -> usize {
479            std::mem::align_of::<u32>()
480        }
481
482        #[inline(always)]
483        fn inline_size(_context: fidl::encoding::Context) -> usize {
484            std::mem::size_of::<u32>()
485        }
486
487        #[inline(always)]
488        fn encode_is_copy() -> bool {
489            true
490        }
491
492        #[inline(always)]
493        fn decode_is_copy() -> bool {
494            false
495        }
496    }
497
498    impl fidl::encoding::ValueTypeMarker for Initiator {
499        type Borrowed<'a> = Self;
500        #[inline(always)]
501        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
502            *value
503        }
504    }
505
506    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Initiator {
507        #[inline]
508        unsafe fn encode(
509            self,
510            encoder: &mut fidl::encoding::Encoder<'_, D>,
511            offset: usize,
512            _depth: fidl::encoding::Depth,
513        ) -> fidl::Result<()> {
514            encoder.debug_check_bounds::<Self>(offset);
515            encoder.write_num(self.into_primitive(), offset);
516            Ok(())
517        }
518    }
519
520    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Initiator {
521        #[inline(always)]
522        fn new_empty() -> Self {
523            Self::User
524        }
525
526        #[inline]
527        unsafe fn decode(
528            &mut self,
529            decoder: &mut fidl::encoding::Decoder<'_, D>,
530            offset: usize,
531            _depth: fidl::encoding::Depth,
532        ) -> fidl::Result<()> {
533            decoder.debug_check_bounds::<Self>(offset);
534            let prim = decoder.read_num::<u32>(offset);
535
536            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
537            Ok(())
538        }
539    }
540    unsafe impl fidl::encoding::TypeMarker for InstallationDeferralReason {
541        type Owned = Self;
542
543        #[inline(always)]
544        fn inline_align(_context: fidl::encoding::Context) -> usize {
545            std::mem::align_of::<u32>()
546        }
547
548        #[inline(always)]
549        fn inline_size(_context: fidl::encoding::Context) -> usize {
550            std::mem::size_of::<u32>()
551        }
552
553        #[inline(always)]
554        fn encode_is_copy() -> bool {
555            false
556        }
557
558        #[inline(always)]
559        fn decode_is_copy() -> bool {
560            false
561        }
562    }
563
564    impl fidl::encoding::ValueTypeMarker for InstallationDeferralReason {
565        type Borrowed<'a> = Self;
566        #[inline(always)]
567        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
568            *value
569        }
570    }
571
572    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
573        for InstallationDeferralReason
574    {
575        #[inline]
576        unsafe fn encode(
577            self,
578            encoder: &mut fidl::encoding::Encoder<'_, D>,
579            offset: usize,
580            _depth: fidl::encoding::Depth,
581        ) -> fidl::Result<()> {
582            encoder.debug_check_bounds::<Self>(offset);
583            encoder.write_num(self.into_primitive(), offset);
584            Ok(())
585        }
586    }
587
588    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
589        for InstallationDeferralReason
590    {
591        #[inline(always)]
592        fn new_empty() -> Self {
593            Self::unknown()
594        }
595
596        #[inline]
597        unsafe fn decode(
598            &mut self,
599            decoder: &mut fidl::encoding::Decoder<'_, D>,
600            offset: usize,
601            _depth: fidl::encoding::Depth,
602        ) -> fidl::Result<()> {
603            decoder.debug_check_bounds::<Self>(offset);
604            let prim = decoder.read_num::<u32>(offset);
605
606            *self = Self::from_primitive_allow_unknown(prim);
607            Ok(())
608        }
609    }
610
611    impl fidl::encoding::ValueTypeMarker for ManagerPerformPendingRebootResponse {
612        type Borrowed<'a> = &'a Self;
613        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
614            value
615        }
616    }
617
618    unsafe impl fidl::encoding::TypeMarker for ManagerPerformPendingRebootResponse {
619        type Owned = Self;
620
621        #[inline(always)]
622        fn inline_align(_context: fidl::encoding::Context) -> usize {
623            1
624        }
625
626        #[inline(always)]
627        fn inline_size(_context: fidl::encoding::Context) -> usize {
628            1
629        }
630    }
631
632    unsafe impl<D: fidl::encoding::ResourceDialect>
633        fidl::encoding::Encode<ManagerPerformPendingRebootResponse, D>
634        for &ManagerPerformPendingRebootResponse
635    {
636        #[inline]
637        unsafe fn encode(
638            self,
639            encoder: &mut fidl::encoding::Encoder<'_, D>,
640            offset: usize,
641            _depth: fidl::encoding::Depth,
642        ) -> fidl::Result<()> {
643            encoder.debug_check_bounds::<ManagerPerformPendingRebootResponse>(offset);
644            // Delegate to tuple encoding.
645            fidl::encoding::Encode::<ManagerPerformPendingRebootResponse, D>::encode(
646                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.rebooting),),
647                encoder,
648                offset,
649                _depth,
650            )
651        }
652    }
653    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
654        fidl::encoding::Encode<ManagerPerformPendingRebootResponse, D> for (T0,)
655    {
656        #[inline]
657        unsafe fn encode(
658            self,
659            encoder: &mut fidl::encoding::Encoder<'_, D>,
660            offset: usize,
661            depth: fidl::encoding::Depth,
662        ) -> fidl::Result<()> {
663            encoder.debug_check_bounds::<ManagerPerformPendingRebootResponse>(offset);
664            // Zero out padding regions. There's no need to apply masks
665            // because the unmasked parts will be overwritten by fields.
666            // Write the fields.
667            self.0.encode(encoder, offset + 0, depth)?;
668            Ok(())
669        }
670    }
671
672    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
673        for ManagerPerformPendingRebootResponse
674    {
675        #[inline(always)]
676        fn new_empty() -> Self {
677            Self { rebooting: fidl::new_empty!(bool, D) }
678        }
679
680        #[inline]
681        unsafe fn decode(
682            &mut self,
683            decoder: &mut fidl::encoding::Decoder<'_, D>,
684            offset: usize,
685            _depth: fidl::encoding::Depth,
686        ) -> fidl::Result<()> {
687            decoder.debug_check_bounds::<Self>(offset);
688            // Verify that padding bytes are zero.
689            fidl::decode!(bool, D, &mut self.rebooting, decoder, offset + 0, _depth)?;
690            Ok(())
691        }
692    }
693
694    impl fidl::encoding::ValueTypeMarker for MonitorOnStateRequest {
695        type Borrowed<'a> = &'a Self;
696        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
697            value
698        }
699    }
700
701    unsafe impl fidl::encoding::TypeMarker for MonitorOnStateRequest {
702        type Owned = Self;
703
704        #[inline(always)]
705        fn inline_align(_context: fidl::encoding::Context) -> usize {
706            8
707        }
708
709        #[inline(always)]
710        fn inline_size(_context: fidl::encoding::Context) -> usize {
711            16
712        }
713    }
714
715    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MonitorOnStateRequest, D>
716        for &MonitorOnStateRequest
717    {
718        #[inline]
719        unsafe fn encode(
720            self,
721            encoder: &mut fidl::encoding::Encoder<'_, D>,
722            offset: usize,
723            _depth: fidl::encoding::Depth,
724        ) -> fidl::Result<()> {
725            encoder.debug_check_bounds::<MonitorOnStateRequest>(offset);
726            // Delegate to tuple encoding.
727            fidl::encoding::Encode::<MonitorOnStateRequest, D>::encode(
728                (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
729                encoder,
730                offset,
731                _depth,
732            )
733        }
734    }
735    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<State, D>>
736        fidl::encoding::Encode<MonitorOnStateRequest, D> for (T0,)
737    {
738        #[inline]
739        unsafe fn encode(
740            self,
741            encoder: &mut fidl::encoding::Encoder<'_, D>,
742            offset: usize,
743            depth: fidl::encoding::Depth,
744        ) -> fidl::Result<()> {
745            encoder.debug_check_bounds::<MonitorOnStateRequest>(offset);
746            // Zero out padding regions. There's no need to apply masks
747            // because the unmasked parts will be overwritten by fields.
748            // Write the fields.
749            self.0.encode(encoder, offset + 0, depth)?;
750            Ok(())
751        }
752    }
753
754    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MonitorOnStateRequest {
755        #[inline(always)]
756        fn new_empty() -> Self {
757            Self { state: fidl::new_empty!(State, D) }
758        }
759
760        #[inline]
761        unsafe fn decode(
762            &mut self,
763            decoder: &mut fidl::encoding::Decoder<'_, D>,
764            offset: usize,
765            _depth: fidl::encoding::Depth,
766        ) -> fidl::Result<()> {
767            decoder.debug_check_bounds::<Self>(offset);
768            // Verify that padding bytes are zero.
769            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
770            Ok(())
771        }
772    }
773
774    impl AttemptOptions {
775        #[inline(always)]
776        fn max_ordinal_present(&self) -> u64 {
777            if let Some(_) = self.initiator {
778                return 1;
779            }
780            0
781        }
782    }
783
784    impl fidl::encoding::ValueTypeMarker for AttemptOptions {
785        type Borrowed<'a> = &'a Self;
786        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
787            value
788        }
789    }
790
791    unsafe impl fidl::encoding::TypeMarker for AttemptOptions {
792        type Owned = Self;
793
794        #[inline(always)]
795        fn inline_align(_context: fidl::encoding::Context) -> usize {
796            8
797        }
798
799        #[inline(always)]
800        fn inline_size(_context: fidl::encoding::Context) -> usize {
801            16
802        }
803    }
804
805    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AttemptOptions, D>
806        for &AttemptOptions
807    {
808        unsafe fn encode(
809            self,
810            encoder: &mut fidl::encoding::Encoder<'_, D>,
811            offset: usize,
812            mut depth: fidl::encoding::Depth,
813        ) -> fidl::Result<()> {
814            encoder.debug_check_bounds::<AttemptOptions>(offset);
815            // Vector header
816            let max_ordinal: u64 = self.max_ordinal_present();
817            encoder.write_num(max_ordinal, offset);
818            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
819            // Calling encoder.out_of_line_offset(0) is not allowed.
820            if max_ordinal == 0 {
821                return Ok(());
822            }
823            depth.increment()?;
824            let envelope_size = 8;
825            let bytes_len = max_ordinal as usize * envelope_size;
826            #[allow(unused_variables)]
827            let offset = encoder.out_of_line_offset(bytes_len);
828            let mut _prev_end_offset: usize = 0;
829            if 1 > max_ordinal {
830                return Ok(());
831            }
832
833            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
834            // are envelope_size bytes.
835            let cur_offset: usize = (1 - 1) * envelope_size;
836
837            // Zero reserved fields.
838            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
839
840            // Safety:
841            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
842            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
843            //   envelope_size bytes, there is always sufficient room.
844            fidl::encoding::encode_in_envelope_optional::<Initiator, D>(
845                self.initiator.as_ref().map(<Initiator as fidl::encoding::ValueTypeMarker>::borrow),
846                encoder,
847                offset + cur_offset,
848                depth,
849            )?;
850
851            _prev_end_offset = cur_offset + envelope_size;
852
853            Ok(())
854        }
855    }
856
857    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AttemptOptions {
858        #[inline(always)]
859        fn new_empty() -> Self {
860            Self::default()
861        }
862
863        unsafe fn decode(
864            &mut self,
865            decoder: &mut fidl::encoding::Decoder<'_, D>,
866            offset: usize,
867            mut depth: fidl::encoding::Depth,
868        ) -> fidl::Result<()> {
869            decoder.debug_check_bounds::<Self>(offset);
870            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
871                None => return Err(fidl::Error::NotNullable),
872                Some(len) => len,
873            };
874            // Calling decoder.out_of_line_offset(0) is not allowed.
875            if len == 0 {
876                return Ok(());
877            };
878            depth.increment()?;
879            let envelope_size = 8;
880            let bytes_len = len * envelope_size;
881            let offset = decoder.out_of_line_offset(bytes_len)?;
882            // Decode the envelope for each type.
883            let mut _next_ordinal_to_read = 0;
884            let mut next_offset = offset;
885            let end_offset = offset + bytes_len;
886            _next_ordinal_to_read += 1;
887            if next_offset >= end_offset {
888                return Ok(());
889            }
890
891            // Decode unknown envelopes for gaps in ordinals.
892            while _next_ordinal_to_read < 1 {
893                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
894                _next_ordinal_to_read += 1;
895                next_offset += envelope_size;
896            }
897
898            let next_out_of_line = decoder.next_out_of_line();
899            let handles_before = decoder.remaining_handles();
900            if let Some((inlined, num_bytes, num_handles)) =
901                fidl::encoding::decode_envelope_header(decoder, next_offset)?
902            {
903                let member_inline_size =
904                    <Initiator as fidl::encoding::TypeMarker>::inline_size(decoder.context);
905                if inlined != (member_inline_size <= 4) {
906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
907                }
908                let inner_offset;
909                let mut inner_depth = depth.clone();
910                if inlined {
911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
912                    inner_offset = next_offset;
913                } else {
914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
915                    inner_depth.increment()?;
916                }
917                let val_ref = self.initiator.get_or_insert_with(|| fidl::new_empty!(Initiator, D));
918                fidl::decode!(Initiator, D, val_ref, decoder, inner_offset, inner_depth)?;
919                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
920                {
921                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
922                }
923                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
924                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
925                }
926            }
927
928            next_offset += envelope_size;
929
930            // Decode the remaining unknown envelopes.
931            while next_offset < end_offset {
932                _next_ordinal_to_read += 1;
933                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
934                next_offset += envelope_size;
935            }
936
937            Ok(())
938        }
939    }
940
941    impl CheckOptions {
942        #[inline(always)]
943        fn max_ordinal_present(&self) -> u64 {
944            if let Some(_) = self.allow_attaching_to_existing_update_check {
945                return 2;
946            }
947            if let Some(_) = self.initiator {
948                return 1;
949            }
950            0
951        }
952    }
953
954    impl fidl::encoding::ValueTypeMarker for CheckOptions {
955        type Borrowed<'a> = &'a Self;
956        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
957            value
958        }
959    }
960
961    unsafe impl fidl::encoding::TypeMarker for CheckOptions {
962        type Owned = Self;
963
964        #[inline(always)]
965        fn inline_align(_context: fidl::encoding::Context) -> usize {
966            8
967        }
968
969        #[inline(always)]
970        fn inline_size(_context: fidl::encoding::Context) -> usize {
971            16
972        }
973    }
974
975    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CheckOptions, D>
976        for &CheckOptions
977    {
978        unsafe fn encode(
979            self,
980            encoder: &mut fidl::encoding::Encoder<'_, D>,
981            offset: usize,
982            mut depth: fidl::encoding::Depth,
983        ) -> fidl::Result<()> {
984            encoder.debug_check_bounds::<CheckOptions>(offset);
985            // Vector header
986            let max_ordinal: u64 = self.max_ordinal_present();
987            encoder.write_num(max_ordinal, offset);
988            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
989            // Calling encoder.out_of_line_offset(0) is not allowed.
990            if max_ordinal == 0 {
991                return Ok(());
992            }
993            depth.increment()?;
994            let envelope_size = 8;
995            let bytes_len = max_ordinal as usize * envelope_size;
996            #[allow(unused_variables)]
997            let offset = encoder.out_of_line_offset(bytes_len);
998            let mut _prev_end_offset: usize = 0;
999            if 1 > max_ordinal {
1000                return Ok(());
1001            }
1002
1003            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1004            // are envelope_size bytes.
1005            let cur_offset: usize = (1 - 1) * envelope_size;
1006
1007            // Zero reserved fields.
1008            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1009
1010            // Safety:
1011            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1012            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1013            //   envelope_size bytes, there is always sufficient room.
1014            fidl::encoding::encode_in_envelope_optional::<Initiator, D>(
1015                self.initiator.as_ref().map(<Initiator as fidl::encoding::ValueTypeMarker>::borrow),
1016                encoder,
1017                offset + cur_offset,
1018                depth,
1019            )?;
1020
1021            _prev_end_offset = cur_offset + envelope_size;
1022            if 2 > max_ordinal {
1023                return Ok(());
1024            }
1025
1026            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1027            // are envelope_size bytes.
1028            let cur_offset: usize = (2 - 1) * envelope_size;
1029
1030            // Zero reserved fields.
1031            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1032
1033            // Safety:
1034            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1035            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1036            //   envelope_size bytes, there is always sufficient room.
1037            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1038                self.allow_attaching_to_existing_update_check
1039                    .as_ref()
1040                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1041                encoder,
1042                offset + cur_offset,
1043                depth,
1044            )?;
1045
1046            _prev_end_offset = cur_offset + envelope_size;
1047
1048            Ok(())
1049        }
1050    }
1051
1052    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CheckOptions {
1053        #[inline(always)]
1054        fn new_empty() -> Self {
1055            Self::default()
1056        }
1057
1058        unsafe fn decode(
1059            &mut self,
1060            decoder: &mut fidl::encoding::Decoder<'_, D>,
1061            offset: usize,
1062            mut depth: fidl::encoding::Depth,
1063        ) -> fidl::Result<()> {
1064            decoder.debug_check_bounds::<Self>(offset);
1065            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1066                None => return Err(fidl::Error::NotNullable),
1067                Some(len) => len,
1068            };
1069            // Calling decoder.out_of_line_offset(0) is not allowed.
1070            if len == 0 {
1071                return Ok(());
1072            };
1073            depth.increment()?;
1074            let envelope_size = 8;
1075            let bytes_len = len * envelope_size;
1076            let offset = decoder.out_of_line_offset(bytes_len)?;
1077            // Decode the envelope for each type.
1078            let mut _next_ordinal_to_read = 0;
1079            let mut next_offset = offset;
1080            let end_offset = offset + bytes_len;
1081            _next_ordinal_to_read += 1;
1082            if next_offset >= end_offset {
1083                return Ok(());
1084            }
1085
1086            // Decode unknown envelopes for gaps in ordinals.
1087            while _next_ordinal_to_read < 1 {
1088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1089                _next_ordinal_to_read += 1;
1090                next_offset += envelope_size;
1091            }
1092
1093            let next_out_of_line = decoder.next_out_of_line();
1094            let handles_before = decoder.remaining_handles();
1095            if let Some((inlined, num_bytes, num_handles)) =
1096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1097            {
1098                let member_inline_size =
1099                    <Initiator as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1100                if inlined != (member_inline_size <= 4) {
1101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1102                }
1103                let inner_offset;
1104                let mut inner_depth = depth.clone();
1105                if inlined {
1106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1107                    inner_offset = next_offset;
1108                } else {
1109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1110                    inner_depth.increment()?;
1111                }
1112                let val_ref = self.initiator.get_or_insert_with(|| fidl::new_empty!(Initiator, D));
1113                fidl::decode!(Initiator, D, val_ref, decoder, inner_offset, inner_depth)?;
1114                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1115                {
1116                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1117                }
1118                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1119                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1120                }
1121            }
1122
1123            next_offset += envelope_size;
1124            _next_ordinal_to_read += 1;
1125            if next_offset >= end_offset {
1126                return Ok(());
1127            }
1128
1129            // Decode unknown envelopes for gaps in ordinals.
1130            while _next_ordinal_to_read < 2 {
1131                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1132                _next_ordinal_to_read += 1;
1133                next_offset += envelope_size;
1134            }
1135
1136            let next_out_of_line = decoder.next_out_of_line();
1137            let handles_before = decoder.remaining_handles();
1138            if let Some((inlined, num_bytes, num_handles)) =
1139                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1140            {
1141                let member_inline_size =
1142                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1143                if inlined != (member_inline_size <= 4) {
1144                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1145                }
1146                let inner_offset;
1147                let mut inner_depth = depth.clone();
1148                if inlined {
1149                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1150                    inner_offset = next_offset;
1151                } else {
1152                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1153                    inner_depth.increment()?;
1154                }
1155                let val_ref = self
1156                    .allow_attaching_to_existing_update_check
1157                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
1158                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1159                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1160                {
1161                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1162                }
1163                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1164                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1165                }
1166            }
1167
1168            next_offset += envelope_size;
1169
1170            // Decode the remaining unknown envelopes.
1171            while next_offset < end_offset {
1172                _next_ordinal_to_read += 1;
1173                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1174                next_offset += envelope_size;
1175            }
1176
1177            Ok(())
1178        }
1179    }
1180
1181    impl CheckingForUpdatesData {
1182        #[inline(always)]
1183        fn max_ordinal_present(&self) -> u64 {
1184            0
1185        }
1186    }
1187
1188    impl fidl::encoding::ValueTypeMarker for CheckingForUpdatesData {
1189        type Borrowed<'a> = &'a Self;
1190        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1191            value
1192        }
1193    }
1194
1195    unsafe impl fidl::encoding::TypeMarker for CheckingForUpdatesData {
1196        type Owned = Self;
1197
1198        #[inline(always)]
1199        fn inline_align(_context: fidl::encoding::Context) -> usize {
1200            8
1201        }
1202
1203        #[inline(always)]
1204        fn inline_size(_context: fidl::encoding::Context) -> usize {
1205            16
1206        }
1207    }
1208
1209    unsafe impl<D: fidl::encoding::ResourceDialect>
1210        fidl::encoding::Encode<CheckingForUpdatesData, D> for &CheckingForUpdatesData
1211    {
1212        unsafe fn encode(
1213            self,
1214            encoder: &mut fidl::encoding::Encoder<'_, D>,
1215            offset: usize,
1216            mut depth: fidl::encoding::Depth,
1217        ) -> fidl::Result<()> {
1218            encoder.debug_check_bounds::<CheckingForUpdatesData>(offset);
1219            // Vector header
1220            let max_ordinal: u64 = self.max_ordinal_present();
1221            encoder.write_num(max_ordinal, offset);
1222            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1223            // Calling encoder.out_of_line_offset(0) is not allowed.
1224            if max_ordinal == 0 {
1225                return Ok(());
1226            }
1227            depth.increment()?;
1228            let envelope_size = 8;
1229            let bytes_len = max_ordinal as usize * envelope_size;
1230            #[allow(unused_variables)]
1231            let offset = encoder.out_of_line_offset(bytes_len);
1232            let mut _prev_end_offset: usize = 0;
1233
1234            Ok(())
1235        }
1236    }
1237
1238    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1239        for CheckingForUpdatesData
1240    {
1241        #[inline(always)]
1242        fn new_empty() -> Self {
1243            Self::default()
1244        }
1245
1246        unsafe fn decode(
1247            &mut self,
1248            decoder: &mut fidl::encoding::Decoder<'_, D>,
1249            offset: usize,
1250            mut depth: fidl::encoding::Depth,
1251        ) -> fidl::Result<()> {
1252            decoder.debug_check_bounds::<Self>(offset);
1253            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1254                None => return Err(fidl::Error::NotNullable),
1255                Some(len) => len,
1256            };
1257            // Calling decoder.out_of_line_offset(0) is not allowed.
1258            if len == 0 {
1259                return Ok(());
1260            };
1261            depth.increment()?;
1262            let envelope_size = 8;
1263            let bytes_len = len * envelope_size;
1264            let offset = decoder.out_of_line_offset(bytes_len)?;
1265            // Decode the envelope for each type.
1266            let mut _next_ordinal_to_read = 0;
1267            let mut next_offset = offset;
1268            let end_offset = offset + bytes_len;
1269
1270            // Decode the remaining unknown envelopes.
1271            while next_offset < end_offset {
1272                _next_ordinal_to_read += 1;
1273                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1274                next_offset += envelope_size;
1275            }
1276
1277            Ok(())
1278        }
1279    }
1280
1281    impl ErrorCheckingForUpdateData {
1282        #[inline(always)]
1283        fn max_ordinal_present(&self) -> u64 {
1284            0
1285        }
1286    }
1287
1288    impl fidl::encoding::ValueTypeMarker for ErrorCheckingForUpdateData {
1289        type Borrowed<'a> = &'a Self;
1290        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1291            value
1292        }
1293    }
1294
1295    unsafe impl fidl::encoding::TypeMarker for ErrorCheckingForUpdateData {
1296        type Owned = Self;
1297
1298        #[inline(always)]
1299        fn inline_align(_context: fidl::encoding::Context) -> usize {
1300            8
1301        }
1302
1303        #[inline(always)]
1304        fn inline_size(_context: fidl::encoding::Context) -> usize {
1305            16
1306        }
1307    }
1308
1309    unsafe impl<D: fidl::encoding::ResourceDialect>
1310        fidl::encoding::Encode<ErrorCheckingForUpdateData, D> for &ErrorCheckingForUpdateData
1311    {
1312        unsafe fn encode(
1313            self,
1314            encoder: &mut fidl::encoding::Encoder<'_, D>,
1315            offset: usize,
1316            mut depth: fidl::encoding::Depth,
1317        ) -> fidl::Result<()> {
1318            encoder.debug_check_bounds::<ErrorCheckingForUpdateData>(offset);
1319            // Vector header
1320            let max_ordinal: u64 = self.max_ordinal_present();
1321            encoder.write_num(max_ordinal, offset);
1322            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1323            // Calling encoder.out_of_line_offset(0) is not allowed.
1324            if max_ordinal == 0 {
1325                return Ok(());
1326            }
1327            depth.increment()?;
1328            let envelope_size = 8;
1329            let bytes_len = max_ordinal as usize * envelope_size;
1330            #[allow(unused_variables)]
1331            let offset = encoder.out_of_line_offset(bytes_len);
1332            let mut _prev_end_offset: usize = 0;
1333
1334            Ok(())
1335        }
1336    }
1337
1338    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1339        for ErrorCheckingForUpdateData
1340    {
1341        #[inline(always)]
1342        fn new_empty() -> Self {
1343            Self::default()
1344        }
1345
1346        unsafe fn decode(
1347            &mut self,
1348            decoder: &mut fidl::encoding::Decoder<'_, D>,
1349            offset: usize,
1350            mut depth: fidl::encoding::Depth,
1351        ) -> fidl::Result<()> {
1352            decoder.debug_check_bounds::<Self>(offset);
1353            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1354                None => return Err(fidl::Error::NotNullable),
1355                Some(len) => len,
1356            };
1357            // Calling decoder.out_of_line_offset(0) is not allowed.
1358            if len == 0 {
1359                return Ok(());
1360            };
1361            depth.increment()?;
1362            let envelope_size = 8;
1363            let bytes_len = len * envelope_size;
1364            let offset = decoder.out_of_line_offset(bytes_len)?;
1365            // Decode the envelope for each type.
1366            let mut _next_ordinal_to_read = 0;
1367            let mut next_offset = offset;
1368            let end_offset = offset + bytes_len;
1369
1370            // Decode the remaining unknown envelopes.
1371            while next_offset < end_offset {
1372                _next_ordinal_to_read += 1;
1373                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1374                next_offset += envelope_size;
1375            }
1376
1377            Ok(())
1378        }
1379    }
1380
1381    impl InstallationDeferredData {
1382        #[inline(always)]
1383        fn max_ordinal_present(&self) -> u64 {
1384            if let Some(_) = self.deferral_reason {
1385                return 2;
1386            }
1387            if let Some(_) = self.update {
1388                return 1;
1389            }
1390            0
1391        }
1392    }
1393
1394    impl fidl::encoding::ValueTypeMarker for InstallationDeferredData {
1395        type Borrowed<'a> = &'a Self;
1396        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1397            value
1398        }
1399    }
1400
1401    unsafe impl fidl::encoding::TypeMarker for InstallationDeferredData {
1402        type Owned = Self;
1403
1404        #[inline(always)]
1405        fn inline_align(_context: fidl::encoding::Context) -> usize {
1406            8
1407        }
1408
1409        #[inline(always)]
1410        fn inline_size(_context: fidl::encoding::Context) -> usize {
1411            16
1412        }
1413    }
1414
1415    unsafe impl<D: fidl::encoding::ResourceDialect>
1416        fidl::encoding::Encode<InstallationDeferredData, D> for &InstallationDeferredData
1417    {
1418        unsafe fn encode(
1419            self,
1420            encoder: &mut fidl::encoding::Encoder<'_, D>,
1421            offset: usize,
1422            mut depth: fidl::encoding::Depth,
1423        ) -> fidl::Result<()> {
1424            encoder.debug_check_bounds::<InstallationDeferredData>(offset);
1425            // Vector header
1426            let max_ordinal: u64 = self.max_ordinal_present();
1427            encoder.write_num(max_ordinal, offset);
1428            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1429            // Calling encoder.out_of_line_offset(0) is not allowed.
1430            if max_ordinal == 0 {
1431                return Ok(());
1432            }
1433            depth.increment()?;
1434            let envelope_size = 8;
1435            let bytes_len = max_ordinal as usize * envelope_size;
1436            #[allow(unused_variables)]
1437            let offset = encoder.out_of_line_offset(bytes_len);
1438            let mut _prev_end_offset: usize = 0;
1439            if 1 > max_ordinal {
1440                return Ok(());
1441            }
1442
1443            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1444            // are envelope_size bytes.
1445            let cur_offset: usize = (1 - 1) * envelope_size;
1446
1447            // Zero reserved fields.
1448            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1449
1450            // Safety:
1451            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1452            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1453            //   envelope_size bytes, there is always sufficient room.
1454            fidl::encoding::encode_in_envelope_optional::<UpdateInfo, D>(
1455                self.update.as_ref().map(<UpdateInfo as fidl::encoding::ValueTypeMarker>::borrow),
1456                encoder,
1457                offset + cur_offset,
1458                depth,
1459            )?;
1460
1461            _prev_end_offset = cur_offset + envelope_size;
1462            if 2 > max_ordinal {
1463                return Ok(());
1464            }
1465
1466            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1467            // are envelope_size bytes.
1468            let cur_offset: usize = (2 - 1) * envelope_size;
1469
1470            // Zero reserved fields.
1471            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1472
1473            // Safety:
1474            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1475            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1476            //   envelope_size bytes, there is always sufficient room.
1477            fidl::encoding::encode_in_envelope_optional::<InstallationDeferralReason, D>(
1478                self.deferral_reason
1479                    .as_ref()
1480                    .map(<InstallationDeferralReason as fidl::encoding::ValueTypeMarker>::borrow),
1481                encoder,
1482                offset + cur_offset,
1483                depth,
1484            )?;
1485
1486            _prev_end_offset = cur_offset + envelope_size;
1487
1488            Ok(())
1489        }
1490    }
1491
1492    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1493        for InstallationDeferredData
1494    {
1495        #[inline(always)]
1496        fn new_empty() -> Self {
1497            Self::default()
1498        }
1499
1500        unsafe fn decode(
1501            &mut self,
1502            decoder: &mut fidl::encoding::Decoder<'_, D>,
1503            offset: usize,
1504            mut depth: fidl::encoding::Depth,
1505        ) -> fidl::Result<()> {
1506            decoder.debug_check_bounds::<Self>(offset);
1507            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1508                None => return Err(fidl::Error::NotNullable),
1509                Some(len) => len,
1510            };
1511            // Calling decoder.out_of_line_offset(0) is not allowed.
1512            if len == 0 {
1513                return Ok(());
1514            };
1515            depth.increment()?;
1516            let envelope_size = 8;
1517            let bytes_len = len * envelope_size;
1518            let offset = decoder.out_of_line_offset(bytes_len)?;
1519            // Decode the envelope for each type.
1520            let mut _next_ordinal_to_read = 0;
1521            let mut next_offset = offset;
1522            let end_offset = offset + bytes_len;
1523            _next_ordinal_to_read += 1;
1524            if next_offset >= end_offset {
1525                return Ok(());
1526            }
1527
1528            // Decode unknown envelopes for gaps in ordinals.
1529            while _next_ordinal_to_read < 1 {
1530                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1531                _next_ordinal_to_read += 1;
1532                next_offset += envelope_size;
1533            }
1534
1535            let next_out_of_line = decoder.next_out_of_line();
1536            let handles_before = decoder.remaining_handles();
1537            if let Some((inlined, num_bytes, num_handles)) =
1538                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1539            {
1540                let member_inline_size =
1541                    <UpdateInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1542                if inlined != (member_inline_size <= 4) {
1543                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1544                }
1545                let inner_offset;
1546                let mut inner_depth = depth.clone();
1547                if inlined {
1548                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1549                    inner_offset = next_offset;
1550                } else {
1551                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1552                    inner_depth.increment()?;
1553                }
1554                let val_ref = self.update.get_or_insert_with(|| fidl::new_empty!(UpdateInfo, D));
1555                fidl::decode!(UpdateInfo, D, val_ref, decoder, inner_offset, inner_depth)?;
1556                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1557                {
1558                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1559                }
1560                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1561                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1562                }
1563            }
1564
1565            next_offset += envelope_size;
1566            _next_ordinal_to_read += 1;
1567            if next_offset >= end_offset {
1568                return Ok(());
1569            }
1570
1571            // Decode unknown envelopes for gaps in ordinals.
1572            while _next_ordinal_to_read < 2 {
1573                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1574                _next_ordinal_to_read += 1;
1575                next_offset += envelope_size;
1576            }
1577
1578            let next_out_of_line = decoder.next_out_of_line();
1579            let handles_before = decoder.remaining_handles();
1580            if let Some((inlined, num_bytes, num_handles)) =
1581                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1582            {
1583                let member_inline_size =
1584                    <InstallationDeferralReason as fidl::encoding::TypeMarker>::inline_size(
1585                        decoder.context,
1586                    );
1587                if inlined != (member_inline_size <= 4) {
1588                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1589                }
1590                let inner_offset;
1591                let mut inner_depth = depth.clone();
1592                if inlined {
1593                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1594                    inner_offset = next_offset;
1595                } else {
1596                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1597                    inner_depth.increment()?;
1598                }
1599                let val_ref = self
1600                    .deferral_reason
1601                    .get_or_insert_with(|| fidl::new_empty!(InstallationDeferralReason, D));
1602                fidl::decode!(
1603                    InstallationDeferralReason,
1604                    D,
1605                    val_ref,
1606                    decoder,
1607                    inner_offset,
1608                    inner_depth
1609                )?;
1610                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1611                {
1612                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1613                }
1614                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1615                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1616                }
1617            }
1618
1619            next_offset += envelope_size;
1620
1621            // Decode the remaining unknown envelopes.
1622            while next_offset < end_offset {
1623                _next_ordinal_to_read += 1;
1624                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1625                next_offset += envelope_size;
1626            }
1627
1628            Ok(())
1629        }
1630    }
1631
1632    impl InstallationErrorData {
1633        #[inline(always)]
1634        fn max_ordinal_present(&self) -> u64 {
1635            if let Some(_) = self.installation_progress {
1636                return 2;
1637            }
1638            if let Some(_) = self.update {
1639                return 1;
1640            }
1641            0
1642        }
1643    }
1644
1645    impl fidl::encoding::ValueTypeMarker for InstallationErrorData {
1646        type Borrowed<'a> = &'a Self;
1647        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1648            value
1649        }
1650    }
1651
1652    unsafe impl fidl::encoding::TypeMarker for InstallationErrorData {
1653        type Owned = Self;
1654
1655        #[inline(always)]
1656        fn inline_align(_context: fidl::encoding::Context) -> usize {
1657            8
1658        }
1659
1660        #[inline(always)]
1661        fn inline_size(_context: fidl::encoding::Context) -> usize {
1662            16
1663        }
1664    }
1665
1666    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InstallationErrorData, D>
1667        for &InstallationErrorData
1668    {
1669        unsafe fn encode(
1670            self,
1671            encoder: &mut fidl::encoding::Encoder<'_, D>,
1672            offset: usize,
1673            mut depth: fidl::encoding::Depth,
1674        ) -> fidl::Result<()> {
1675            encoder.debug_check_bounds::<InstallationErrorData>(offset);
1676            // Vector header
1677            let max_ordinal: u64 = self.max_ordinal_present();
1678            encoder.write_num(max_ordinal, offset);
1679            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1680            // Calling encoder.out_of_line_offset(0) is not allowed.
1681            if max_ordinal == 0 {
1682                return Ok(());
1683            }
1684            depth.increment()?;
1685            let envelope_size = 8;
1686            let bytes_len = max_ordinal as usize * envelope_size;
1687            #[allow(unused_variables)]
1688            let offset = encoder.out_of_line_offset(bytes_len);
1689            let mut _prev_end_offset: usize = 0;
1690            if 1 > max_ordinal {
1691                return Ok(());
1692            }
1693
1694            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1695            // are envelope_size bytes.
1696            let cur_offset: usize = (1 - 1) * envelope_size;
1697
1698            // Zero reserved fields.
1699            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1700
1701            // Safety:
1702            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1703            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1704            //   envelope_size bytes, there is always sufficient room.
1705            fidl::encoding::encode_in_envelope_optional::<UpdateInfo, D>(
1706                self.update.as_ref().map(<UpdateInfo as fidl::encoding::ValueTypeMarker>::borrow),
1707                encoder,
1708                offset + cur_offset,
1709                depth,
1710            )?;
1711
1712            _prev_end_offset = cur_offset + envelope_size;
1713            if 2 > max_ordinal {
1714                return Ok(());
1715            }
1716
1717            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1718            // are envelope_size bytes.
1719            let cur_offset: usize = (2 - 1) * envelope_size;
1720
1721            // Zero reserved fields.
1722            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1723
1724            // Safety:
1725            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1726            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1727            //   envelope_size bytes, there is always sufficient room.
1728            fidl::encoding::encode_in_envelope_optional::<InstallationProgress, D>(
1729                self.installation_progress
1730                    .as_ref()
1731                    .map(<InstallationProgress as fidl::encoding::ValueTypeMarker>::borrow),
1732                encoder,
1733                offset + cur_offset,
1734                depth,
1735            )?;
1736
1737            _prev_end_offset = cur_offset + envelope_size;
1738
1739            Ok(())
1740        }
1741    }
1742
1743    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InstallationErrorData {
1744        #[inline(always)]
1745        fn new_empty() -> Self {
1746            Self::default()
1747        }
1748
1749        unsafe fn decode(
1750            &mut self,
1751            decoder: &mut fidl::encoding::Decoder<'_, D>,
1752            offset: usize,
1753            mut depth: fidl::encoding::Depth,
1754        ) -> fidl::Result<()> {
1755            decoder.debug_check_bounds::<Self>(offset);
1756            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1757                None => return Err(fidl::Error::NotNullable),
1758                Some(len) => len,
1759            };
1760            // Calling decoder.out_of_line_offset(0) is not allowed.
1761            if len == 0 {
1762                return Ok(());
1763            };
1764            depth.increment()?;
1765            let envelope_size = 8;
1766            let bytes_len = len * envelope_size;
1767            let offset = decoder.out_of_line_offset(bytes_len)?;
1768            // Decode the envelope for each type.
1769            let mut _next_ordinal_to_read = 0;
1770            let mut next_offset = offset;
1771            let end_offset = offset + bytes_len;
1772            _next_ordinal_to_read += 1;
1773            if next_offset >= end_offset {
1774                return Ok(());
1775            }
1776
1777            // Decode unknown envelopes for gaps in ordinals.
1778            while _next_ordinal_to_read < 1 {
1779                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1780                _next_ordinal_to_read += 1;
1781                next_offset += envelope_size;
1782            }
1783
1784            let next_out_of_line = decoder.next_out_of_line();
1785            let handles_before = decoder.remaining_handles();
1786            if let Some((inlined, num_bytes, num_handles)) =
1787                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1788            {
1789                let member_inline_size =
1790                    <UpdateInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1791                if inlined != (member_inline_size <= 4) {
1792                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1793                }
1794                let inner_offset;
1795                let mut inner_depth = depth.clone();
1796                if inlined {
1797                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1798                    inner_offset = next_offset;
1799                } else {
1800                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1801                    inner_depth.increment()?;
1802                }
1803                let val_ref = self.update.get_or_insert_with(|| fidl::new_empty!(UpdateInfo, D));
1804                fidl::decode!(UpdateInfo, D, val_ref, decoder, inner_offset, inner_depth)?;
1805                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1806                {
1807                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1808                }
1809                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1810                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1811                }
1812            }
1813
1814            next_offset += envelope_size;
1815            _next_ordinal_to_read += 1;
1816            if next_offset >= end_offset {
1817                return Ok(());
1818            }
1819
1820            // Decode unknown envelopes for gaps in ordinals.
1821            while _next_ordinal_to_read < 2 {
1822                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1823                _next_ordinal_to_read += 1;
1824                next_offset += envelope_size;
1825            }
1826
1827            let next_out_of_line = decoder.next_out_of_line();
1828            let handles_before = decoder.remaining_handles();
1829            if let Some((inlined, num_bytes, num_handles)) =
1830                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1831            {
1832                let member_inline_size =
1833                    <InstallationProgress as fidl::encoding::TypeMarker>::inline_size(
1834                        decoder.context,
1835                    );
1836                if inlined != (member_inline_size <= 4) {
1837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1838                }
1839                let inner_offset;
1840                let mut inner_depth = depth.clone();
1841                if inlined {
1842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1843                    inner_offset = next_offset;
1844                } else {
1845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1846                    inner_depth.increment()?;
1847                }
1848                let val_ref = self
1849                    .installation_progress
1850                    .get_or_insert_with(|| fidl::new_empty!(InstallationProgress, D));
1851                fidl::decode!(
1852                    InstallationProgress,
1853                    D,
1854                    val_ref,
1855                    decoder,
1856                    inner_offset,
1857                    inner_depth
1858                )?;
1859                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1860                {
1861                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1862                }
1863                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1864                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1865                }
1866            }
1867
1868            next_offset += envelope_size;
1869
1870            // Decode the remaining unknown envelopes.
1871            while next_offset < end_offset {
1872                _next_ordinal_to_read += 1;
1873                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1874                next_offset += envelope_size;
1875            }
1876
1877            Ok(())
1878        }
1879    }
1880
1881    impl InstallationProgress {
1882        #[inline(always)]
1883        fn max_ordinal_present(&self) -> u64 {
1884            if let Some(_) = self.fraction_completed {
1885                return 1;
1886            }
1887            0
1888        }
1889    }
1890
1891    impl fidl::encoding::ValueTypeMarker for InstallationProgress {
1892        type Borrowed<'a> = &'a Self;
1893        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1894            value
1895        }
1896    }
1897
1898    unsafe impl fidl::encoding::TypeMarker for InstallationProgress {
1899        type Owned = Self;
1900
1901        #[inline(always)]
1902        fn inline_align(_context: fidl::encoding::Context) -> usize {
1903            8
1904        }
1905
1906        #[inline(always)]
1907        fn inline_size(_context: fidl::encoding::Context) -> usize {
1908            16
1909        }
1910    }
1911
1912    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InstallationProgress, D>
1913        for &InstallationProgress
1914    {
1915        unsafe fn encode(
1916            self,
1917            encoder: &mut fidl::encoding::Encoder<'_, D>,
1918            offset: usize,
1919            mut depth: fidl::encoding::Depth,
1920        ) -> fidl::Result<()> {
1921            encoder.debug_check_bounds::<InstallationProgress>(offset);
1922            // Vector header
1923            let max_ordinal: u64 = self.max_ordinal_present();
1924            encoder.write_num(max_ordinal, offset);
1925            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1926            // Calling encoder.out_of_line_offset(0) is not allowed.
1927            if max_ordinal == 0 {
1928                return Ok(());
1929            }
1930            depth.increment()?;
1931            let envelope_size = 8;
1932            let bytes_len = max_ordinal as usize * envelope_size;
1933            #[allow(unused_variables)]
1934            let offset = encoder.out_of_line_offset(bytes_len);
1935            let mut _prev_end_offset: usize = 0;
1936            if 1 > max_ordinal {
1937                return Ok(());
1938            }
1939
1940            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1941            // are envelope_size bytes.
1942            let cur_offset: usize = (1 - 1) * envelope_size;
1943
1944            // Zero reserved fields.
1945            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1946
1947            // Safety:
1948            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1949            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1950            //   envelope_size bytes, there is always sufficient room.
1951            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1952                self.fraction_completed
1953                    .as_ref()
1954                    .map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1955                encoder,
1956                offset + cur_offset,
1957                depth,
1958            )?;
1959
1960            _prev_end_offset = cur_offset + envelope_size;
1961
1962            Ok(())
1963        }
1964    }
1965
1966    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InstallationProgress {
1967        #[inline(always)]
1968        fn new_empty() -> Self {
1969            Self::default()
1970        }
1971
1972        unsafe fn decode(
1973            &mut self,
1974            decoder: &mut fidl::encoding::Decoder<'_, D>,
1975            offset: usize,
1976            mut depth: fidl::encoding::Depth,
1977        ) -> fidl::Result<()> {
1978            decoder.debug_check_bounds::<Self>(offset);
1979            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1980                None => return Err(fidl::Error::NotNullable),
1981                Some(len) => len,
1982            };
1983            // Calling decoder.out_of_line_offset(0) is not allowed.
1984            if len == 0 {
1985                return Ok(());
1986            };
1987            depth.increment()?;
1988            let envelope_size = 8;
1989            let bytes_len = len * envelope_size;
1990            let offset = decoder.out_of_line_offset(bytes_len)?;
1991            // Decode the envelope for each type.
1992            let mut _next_ordinal_to_read = 0;
1993            let mut next_offset = offset;
1994            let end_offset = offset + bytes_len;
1995            _next_ordinal_to_read += 1;
1996            if next_offset >= end_offset {
1997                return Ok(());
1998            }
1999
2000            // Decode unknown envelopes for gaps in ordinals.
2001            while _next_ordinal_to_read < 1 {
2002                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2003                _next_ordinal_to_read += 1;
2004                next_offset += envelope_size;
2005            }
2006
2007            let next_out_of_line = decoder.next_out_of_line();
2008            let handles_before = decoder.remaining_handles();
2009            if let Some((inlined, num_bytes, num_handles)) =
2010                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2011            {
2012                let member_inline_size =
2013                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2014                if inlined != (member_inline_size <= 4) {
2015                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2016                }
2017                let inner_offset;
2018                let mut inner_depth = depth.clone();
2019                if inlined {
2020                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2021                    inner_offset = next_offset;
2022                } else {
2023                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2024                    inner_depth.increment()?;
2025                }
2026                let val_ref =
2027                    self.fraction_completed.get_or_insert_with(|| fidl::new_empty!(f32, D));
2028                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
2029                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2030                {
2031                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2032                }
2033                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2034                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2035                }
2036            }
2037
2038            next_offset += envelope_size;
2039
2040            // Decode the remaining unknown envelopes.
2041            while next_offset < end_offset {
2042                _next_ordinal_to_read += 1;
2043                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2044                next_offset += envelope_size;
2045            }
2046
2047            Ok(())
2048        }
2049    }
2050
2051    impl InstallingData {
2052        #[inline(always)]
2053        fn max_ordinal_present(&self) -> u64 {
2054            if let Some(_) = self.installation_progress {
2055                return 2;
2056            }
2057            if let Some(_) = self.update {
2058                return 1;
2059            }
2060            0
2061        }
2062    }
2063
2064    impl fidl::encoding::ValueTypeMarker for InstallingData {
2065        type Borrowed<'a> = &'a Self;
2066        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2067            value
2068        }
2069    }
2070
2071    unsafe impl fidl::encoding::TypeMarker for InstallingData {
2072        type Owned = Self;
2073
2074        #[inline(always)]
2075        fn inline_align(_context: fidl::encoding::Context) -> usize {
2076            8
2077        }
2078
2079        #[inline(always)]
2080        fn inline_size(_context: fidl::encoding::Context) -> usize {
2081            16
2082        }
2083    }
2084
2085    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InstallingData, D>
2086        for &InstallingData
2087    {
2088        unsafe fn encode(
2089            self,
2090            encoder: &mut fidl::encoding::Encoder<'_, D>,
2091            offset: usize,
2092            mut depth: fidl::encoding::Depth,
2093        ) -> fidl::Result<()> {
2094            encoder.debug_check_bounds::<InstallingData>(offset);
2095            // Vector header
2096            let max_ordinal: u64 = self.max_ordinal_present();
2097            encoder.write_num(max_ordinal, offset);
2098            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2099            // Calling encoder.out_of_line_offset(0) is not allowed.
2100            if max_ordinal == 0 {
2101                return Ok(());
2102            }
2103            depth.increment()?;
2104            let envelope_size = 8;
2105            let bytes_len = max_ordinal as usize * envelope_size;
2106            #[allow(unused_variables)]
2107            let offset = encoder.out_of_line_offset(bytes_len);
2108            let mut _prev_end_offset: usize = 0;
2109            if 1 > max_ordinal {
2110                return Ok(());
2111            }
2112
2113            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2114            // are envelope_size bytes.
2115            let cur_offset: usize = (1 - 1) * envelope_size;
2116
2117            // Zero reserved fields.
2118            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2119
2120            // Safety:
2121            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2122            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2123            //   envelope_size bytes, there is always sufficient room.
2124            fidl::encoding::encode_in_envelope_optional::<UpdateInfo, D>(
2125                self.update.as_ref().map(<UpdateInfo as fidl::encoding::ValueTypeMarker>::borrow),
2126                encoder,
2127                offset + cur_offset,
2128                depth,
2129            )?;
2130
2131            _prev_end_offset = cur_offset + envelope_size;
2132            if 2 > max_ordinal {
2133                return Ok(());
2134            }
2135
2136            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2137            // are envelope_size bytes.
2138            let cur_offset: usize = (2 - 1) * envelope_size;
2139
2140            // Zero reserved fields.
2141            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2142
2143            // Safety:
2144            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2145            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2146            //   envelope_size bytes, there is always sufficient room.
2147            fidl::encoding::encode_in_envelope_optional::<InstallationProgress, D>(
2148                self.installation_progress
2149                    .as_ref()
2150                    .map(<InstallationProgress as fidl::encoding::ValueTypeMarker>::borrow),
2151                encoder,
2152                offset + cur_offset,
2153                depth,
2154            )?;
2155
2156            _prev_end_offset = cur_offset + envelope_size;
2157
2158            Ok(())
2159        }
2160    }
2161
2162    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InstallingData {
2163        #[inline(always)]
2164        fn new_empty() -> Self {
2165            Self::default()
2166        }
2167
2168        unsafe fn decode(
2169            &mut self,
2170            decoder: &mut fidl::encoding::Decoder<'_, D>,
2171            offset: usize,
2172            mut depth: fidl::encoding::Depth,
2173        ) -> fidl::Result<()> {
2174            decoder.debug_check_bounds::<Self>(offset);
2175            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2176                None => return Err(fidl::Error::NotNullable),
2177                Some(len) => len,
2178            };
2179            // Calling decoder.out_of_line_offset(0) is not allowed.
2180            if len == 0 {
2181                return Ok(());
2182            };
2183            depth.increment()?;
2184            let envelope_size = 8;
2185            let bytes_len = len * envelope_size;
2186            let offset = decoder.out_of_line_offset(bytes_len)?;
2187            // Decode the envelope for each type.
2188            let mut _next_ordinal_to_read = 0;
2189            let mut next_offset = offset;
2190            let end_offset = offset + bytes_len;
2191            _next_ordinal_to_read += 1;
2192            if next_offset >= end_offset {
2193                return Ok(());
2194            }
2195
2196            // Decode unknown envelopes for gaps in ordinals.
2197            while _next_ordinal_to_read < 1 {
2198                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2199                _next_ordinal_to_read += 1;
2200                next_offset += envelope_size;
2201            }
2202
2203            let next_out_of_line = decoder.next_out_of_line();
2204            let handles_before = decoder.remaining_handles();
2205            if let Some((inlined, num_bytes, num_handles)) =
2206                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2207            {
2208                let member_inline_size =
2209                    <UpdateInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2210                if inlined != (member_inline_size <= 4) {
2211                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2212                }
2213                let inner_offset;
2214                let mut inner_depth = depth.clone();
2215                if inlined {
2216                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2217                    inner_offset = next_offset;
2218                } else {
2219                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2220                    inner_depth.increment()?;
2221                }
2222                let val_ref = self.update.get_or_insert_with(|| fidl::new_empty!(UpdateInfo, D));
2223                fidl::decode!(UpdateInfo, D, val_ref, decoder, inner_offset, inner_depth)?;
2224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2225                {
2226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2227                }
2228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2230                }
2231            }
2232
2233            next_offset += envelope_size;
2234            _next_ordinal_to_read += 1;
2235            if next_offset >= end_offset {
2236                return Ok(());
2237            }
2238
2239            // Decode unknown envelopes for gaps in ordinals.
2240            while _next_ordinal_to_read < 2 {
2241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2242                _next_ordinal_to_read += 1;
2243                next_offset += envelope_size;
2244            }
2245
2246            let next_out_of_line = decoder.next_out_of_line();
2247            let handles_before = decoder.remaining_handles();
2248            if let Some((inlined, num_bytes, num_handles)) =
2249                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2250            {
2251                let member_inline_size =
2252                    <InstallationProgress as fidl::encoding::TypeMarker>::inline_size(
2253                        decoder.context,
2254                    );
2255                if inlined != (member_inline_size <= 4) {
2256                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2257                }
2258                let inner_offset;
2259                let mut inner_depth = depth.clone();
2260                if inlined {
2261                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2262                    inner_offset = next_offset;
2263                } else {
2264                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2265                    inner_depth.increment()?;
2266                }
2267                let val_ref = self
2268                    .installation_progress
2269                    .get_or_insert_with(|| fidl::new_empty!(InstallationProgress, D));
2270                fidl::decode!(
2271                    InstallationProgress,
2272                    D,
2273                    val_ref,
2274                    decoder,
2275                    inner_offset,
2276                    inner_depth
2277                )?;
2278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2279                {
2280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2281                }
2282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2284                }
2285            }
2286
2287            next_offset += envelope_size;
2288
2289            // Decode the remaining unknown envelopes.
2290            while next_offset < end_offset {
2291                _next_ordinal_to_read += 1;
2292                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2293                next_offset += envelope_size;
2294            }
2295
2296            Ok(())
2297        }
2298    }
2299
2300    impl NoUpdateAvailableData {
2301        #[inline(always)]
2302        fn max_ordinal_present(&self) -> u64 {
2303            0
2304        }
2305    }
2306
2307    impl fidl::encoding::ValueTypeMarker for NoUpdateAvailableData {
2308        type Borrowed<'a> = &'a Self;
2309        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2310            value
2311        }
2312    }
2313
2314    unsafe impl fidl::encoding::TypeMarker for NoUpdateAvailableData {
2315        type Owned = Self;
2316
2317        #[inline(always)]
2318        fn inline_align(_context: fidl::encoding::Context) -> usize {
2319            8
2320        }
2321
2322        #[inline(always)]
2323        fn inline_size(_context: fidl::encoding::Context) -> usize {
2324            16
2325        }
2326    }
2327
2328    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NoUpdateAvailableData, D>
2329        for &NoUpdateAvailableData
2330    {
2331        unsafe fn encode(
2332            self,
2333            encoder: &mut fidl::encoding::Encoder<'_, D>,
2334            offset: usize,
2335            mut depth: fidl::encoding::Depth,
2336        ) -> fidl::Result<()> {
2337            encoder.debug_check_bounds::<NoUpdateAvailableData>(offset);
2338            // Vector header
2339            let max_ordinal: u64 = self.max_ordinal_present();
2340            encoder.write_num(max_ordinal, offset);
2341            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2342            // Calling encoder.out_of_line_offset(0) is not allowed.
2343            if max_ordinal == 0 {
2344                return Ok(());
2345            }
2346            depth.increment()?;
2347            let envelope_size = 8;
2348            let bytes_len = max_ordinal as usize * envelope_size;
2349            #[allow(unused_variables)]
2350            let offset = encoder.out_of_line_offset(bytes_len);
2351            let mut _prev_end_offset: usize = 0;
2352
2353            Ok(())
2354        }
2355    }
2356
2357    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NoUpdateAvailableData {
2358        #[inline(always)]
2359        fn new_empty() -> Self {
2360            Self::default()
2361        }
2362
2363        unsafe fn decode(
2364            &mut self,
2365            decoder: &mut fidl::encoding::Decoder<'_, D>,
2366            offset: usize,
2367            mut depth: fidl::encoding::Depth,
2368        ) -> fidl::Result<()> {
2369            decoder.debug_check_bounds::<Self>(offset);
2370            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2371                None => return Err(fidl::Error::NotNullable),
2372                Some(len) => len,
2373            };
2374            // Calling decoder.out_of_line_offset(0) is not allowed.
2375            if len == 0 {
2376                return Ok(());
2377            };
2378            depth.increment()?;
2379            let envelope_size = 8;
2380            let bytes_len = len * envelope_size;
2381            let offset = decoder.out_of_line_offset(bytes_len)?;
2382            // Decode the envelope for each type.
2383            let mut _next_ordinal_to_read = 0;
2384            let mut next_offset = offset;
2385            let end_offset = offset + bytes_len;
2386
2387            // Decode the remaining unknown envelopes.
2388            while next_offset < end_offset {
2389                _next_ordinal_to_read += 1;
2390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2391                next_offset += envelope_size;
2392            }
2393
2394            Ok(())
2395        }
2396    }
2397
2398    impl UpdateInfo {
2399        #[inline(always)]
2400        fn max_ordinal_present(&self) -> u64 {
2401            if let Some(_) = self.urgent {
2402                return 3;
2403            }
2404            if let Some(_) = self.download_size {
2405                return 2;
2406            }
2407            if let Some(_) = self.version_available {
2408                return 1;
2409            }
2410            0
2411        }
2412    }
2413
2414    impl fidl::encoding::ValueTypeMarker for UpdateInfo {
2415        type Borrowed<'a> = &'a Self;
2416        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2417            value
2418        }
2419    }
2420
2421    unsafe impl fidl::encoding::TypeMarker for UpdateInfo {
2422        type Owned = Self;
2423
2424        #[inline(always)]
2425        fn inline_align(_context: fidl::encoding::Context) -> usize {
2426            8
2427        }
2428
2429        #[inline(always)]
2430        fn inline_size(_context: fidl::encoding::Context) -> usize {
2431            16
2432        }
2433    }
2434
2435    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UpdateInfo, D>
2436        for &UpdateInfo
2437    {
2438        unsafe fn encode(
2439            self,
2440            encoder: &mut fidl::encoding::Encoder<'_, D>,
2441            offset: usize,
2442            mut depth: fidl::encoding::Depth,
2443        ) -> fidl::Result<()> {
2444            encoder.debug_check_bounds::<UpdateInfo>(offset);
2445            // Vector header
2446            let max_ordinal: u64 = self.max_ordinal_present();
2447            encoder.write_num(max_ordinal, offset);
2448            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2449            // Calling encoder.out_of_line_offset(0) is not allowed.
2450            if max_ordinal == 0 {
2451                return Ok(());
2452            }
2453            depth.increment()?;
2454            let envelope_size = 8;
2455            let bytes_len = max_ordinal as usize * envelope_size;
2456            #[allow(unused_variables)]
2457            let offset = encoder.out_of_line_offset(bytes_len);
2458            let mut _prev_end_offset: usize = 0;
2459            if 1 > max_ordinal {
2460                return Ok(());
2461            }
2462
2463            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2464            // are envelope_size bytes.
2465            let cur_offset: usize = (1 - 1) * envelope_size;
2466
2467            // Zero reserved fields.
2468            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2469
2470            // Safety:
2471            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2472            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2473            //   envelope_size bytes, there is always sufficient room.
2474            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
2475                self.version_available.as_ref().map(
2476                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
2477                ),
2478                encoder,
2479                offset + cur_offset,
2480                depth,
2481            )?;
2482
2483            _prev_end_offset = cur_offset + envelope_size;
2484            if 2 > max_ordinal {
2485                return Ok(());
2486            }
2487
2488            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2489            // are envelope_size bytes.
2490            let cur_offset: usize = (2 - 1) * envelope_size;
2491
2492            // Zero reserved fields.
2493            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2494
2495            // Safety:
2496            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2497            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2498            //   envelope_size bytes, there is always sufficient room.
2499            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2500                self.download_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2501                encoder,
2502                offset + cur_offset,
2503                depth,
2504            )?;
2505
2506            _prev_end_offset = cur_offset + envelope_size;
2507            if 3 > max_ordinal {
2508                return Ok(());
2509            }
2510
2511            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2512            // are envelope_size bytes.
2513            let cur_offset: usize = (3 - 1) * envelope_size;
2514
2515            // Zero reserved fields.
2516            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2517
2518            // Safety:
2519            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2520            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2521            //   envelope_size bytes, there is always sufficient room.
2522            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2523                self.urgent.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2524                encoder,
2525                offset + cur_offset,
2526                depth,
2527            )?;
2528
2529            _prev_end_offset = cur_offset + envelope_size;
2530
2531            Ok(())
2532        }
2533    }
2534
2535    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UpdateInfo {
2536        #[inline(always)]
2537        fn new_empty() -> Self {
2538            Self::default()
2539        }
2540
2541        unsafe fn decode(
2542            &mut self,
2543            decoder: &mut fidl::encoding::Decoder<'_, D>,
2544            offset: usize,
2545            mut depth: fidl::encoding::Depth,
2546        ) -> fidl::Result<()> {
2547            decoder.debug_check_bounds::<Self>(offset);
2548            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2549                None => return Err(fidl::Error::NotNullable),
2550                Some(len) => len,
2551            };
2552            // Calling decoder.out_of_line_offset(0) is not allowed.
2553            if len == 0 {
2554                return Ok(());
2555            };
2556            depth.increment()?;
2557            let envelope_size = 8;
2558            let bytes_len = len * envelope_size;
2559            let offset = decoder.out_of_line_offset(bytes_len)?;
2560            // Decode the envelope for each type.
2561            let mut _next_ordinal_to_read = 0;
2562            let mut next_offset = offset;
2563            let end_offset = offset + bytes_len;
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 < 1 {
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 =
2582                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
2583                        decoder.context,
2584                    );
2585                if inlined != (member_inline_size <= 4) {
2586                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2587                }
2588                let inner_offset;
2589                let mut inner_depth = depth.clone();
2590                if inlined {
2591                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2592                    inner_offset = next_offset;
2593                } else {
2594                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2595                    inner_depth.increment()?;
2596                }
2597                let val_ref = self
2598                    .version_available
2599                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
2600                fidl::decode!(
2601                    fidl::encoding::BoundedString<128>,
2602                    D,
2603                    val_ref,
2604                    decoder,
2605                    inner_offset,
2606                    inner_depth
2607                )?;
2608                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2609                {
2610                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2611                }
2612                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2613                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2614                }
2615            }
2616
2617            next_offset += envelope_size;
2618            _next_ordinal_to_read += 1;
2619            if next_offset >= end_offset {
2620                return Ok(());
2621            }
2622
2623            // Decode unknown envelopes for gaps in ordinals.
2624            while _next_ordinal_to_read < 2 {
2625                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2626                _next_ordinal_to_read += 1;
2627                next_offset += envelope_size;
2628            }
2629
2630            let next_out_of_line = decoder.next_out_of_line();
2631            let handles_before = decoder.remaining_handles();
2632            if let Some((inlined, num_bytes, num_handles)) =
2633                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2634            {
2635                let member_inline_size =
2636                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2637                if inlined != (member_inline_size <= 4) {
2638                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2639                }
2640                let inner_offset;
2641                let mut inner_depth = depth.clone();
2642                if inlined {
2643                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2644                    inner_offset = next_offset;
2645                } else {
2646                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2647                    inner_depth.increment()?;
2648                }
2649                let val_ref = self.download_size.get_or_insert_with(|| fidl::new_empty!(u64, D));
2650                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2651                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2652                {
2653                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2654                }
2655                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2656                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2657                }
2658            }
2659
2660            next_offset += envelope_size;
2661            _next_ordinal_to_read += 1;
2662            if next_offset >= end_offset {
2663                return Ok(());
2664            }
2665
2666            // Decode unknown envelopes for gaps in ordinals.
2667            while _next_ordinal_to_read < 3 {
2668                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2669                _next_ordinal_to_read += 1;
2670                next_offset += envelope_size;
2671            }
2672
2673            let next_out_of_line = decoder.next_out_of_line();
2674            let handles_before = decoder.remaining_handles();
2675            if let Some((inlined, num_bytes, num_handles)) =
2676                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2677            {
2678                let member_inline_size =
2679                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2680                if inlined != (member_inline_size <= 4) {
2681                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2682                }
2683                let inner_offset;
2684                let mut inner_depth = depth.clone();
2685                if inlined {
2686                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2687                    inner_offset = next_offset;
2688                } else {
2689                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2690                    inner_depth.increment()?;
2691                }
2692                let val_ref = self.urgent.get_or_insert_with(|| fidl::new_empty!(bool, D));
2693                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2694                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2695                {
2696                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2697                }
2698                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2699                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2700                }
2701            }
2702
2703            next_offset += envelope_size;
2704
2705            // Decode the remaining unknown envelopes.
2706            while next_offset < end_offset {
2707                _next_ordinal_to_read += 1;
2708                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2709                next_offset += envelope_size;
2710            }
2711
2712            Ok(())
2713        }
2714    }
2715
2716    impl fidl::encoding::ValueTypeMarker for State {
2717        type Borrowed<'a> = &'a Self;
2718        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2719            value
2720        }
2721    }
2722
2723    unsafe impl fidl::encoding::TypeMarker for State {
2724        type Owned = Self;
2725
2726        #[inline(always)]
2727        fn inline_align(_context: fidl::encoding::Context) -> usize {
2728            8
2729        }
2730
2731        #[inline(always)]
2732        fn inline_size(_context: fidl::encoding::Context) -> usize {
2733            16
2734        }
2735    }
2736
2737    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<State, D> for &State {
2738        #[inline]
2739        unsafe fn encode(
2740            self,
2741            encoder: &mut fidl::encoding::Encoder<'_, D>,
2742            offset: usize,
2743            _depth: fidl::encoding::Depth,
2744        ) -> fidl::Result<()> {
2745            encoder.debug_check_bounds::<State>(offset);
2746            encoder.write_num::<u64>(self.ordinal(), offset);
2747            match self {
2748                State::CheckingForUpdates(ref val) => {
2749                    fidl::encoding::encode_in_envelope::<CheckingForUpdatesData, D>(
2750                        <CheckingForUpdatesData as fidl::encoding::ValueTypeMarker>::borrow(val),
2751                        encoder,
2752                        offset + 8,
2753                        _depth,
2754                    )
2755                }
2756                State::ErrorCheckingForUpdate(ref val) => fidl::encoding::encode_in_envelope::<
2757                    ErrorCheckingForUpdateData,
2758                    D,
2759                >(
2760                    <ErrorCheckingForUpdateData as fidl::encoding::ValueTypeMarker>::borrow(val),
2761                    encoder,
2762                    offset + 8,
2763                    _depth,
2764                ),
2765                State::NoUpdateAvailable(ref val) => {
2766                    fidl::encoding::encode_in_envelope::<NoUpdateAvailableData, D>(
2767                        <NoUpdateAvailableData as fidl::encoding::ValueTypeMarker>::borrow(val),
2768                        encoder,
2769                        offset + 8,
2770                        _depth,
2771                    )
2772                }
2773                State::InstallationDeferredByPolicy(ref val) => {
2774                    fidl::encoding::encode_in_envelope::<InstallationDeferredData, D>(
2775                        <InstallationDeferredData as fidl::encoding::ValueTypeMarker>::borrow(val),
2776                        encoder,
2777                        offset + 8,
2778                        _depth,
2779                    )
2780                }
2781                State::InstallingUpdate(ref val) => {
2782                    fidl::encoding::encode_in_envelope::<InstallingData, D>(
2783                        <InstallingData as fidl::encoding::ValueTypeMarker>::borrow(val),
2784                        encoder,
2785                        offset + 8,
2786                        _depth,
2787                    )
2788                }
2789                State::WaitingForReboot(ref val) => {
2790                    fidl::encoding::encode_in_envelope::<InstallingData, D>(
2791                        <InstallingData as fidl::encoding::ValueTypeMarker>::borrow(val),
2792                        encoder,
2793                        offset + 8,
2794                        _depth,
2795                    )
2796                }
2797                State::InstallationError(ref val) => {
2798                    fidl::encoding::encode_in_envelope::<InstallationErrorData, D>(
2799                        <InstallationErrorData as fidl::encoding::ValueTypeMarker>::borrow(val),
2800                        encoder,
2801                        offset + 8,
2802                        _depth,
2803                    )
2804                }
2805            }
2806        }
2807    }
2808
2809    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
2810        #[inline(always)]
2811        fn new_empty() -> Self {
2812            Self::CheckingForUpdates(fidl::new_empty!(CheckingForUpdatesData, D))
2813        }
2814
2815        #[inline]
2816        unsafe fn decode(
2817            &mut self,
2818            decoder: &mut fidl::encoding::Decoder<'_, D>,
2819            offset: usize,
2820            mut depth: fidl::encoding::Depth,
2821        ) -> fidl::Result<()> {
2822            decoder.debug_check_bounds::<Self>(offset);
2823            #[allow(unused_variables)]
2824            let next_out_of_line = decoder.next_out_of_line();
2825            let handles_before = decoder.remaining_handles();
2826            let (ordinal, inlined, num_bytes, num_handles) =
2827                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2828
2829            let member_inline_size = match ordinal {
2830                1 => <CheckingForUpdatesData as fidl::encoding::TypeMarker>::inline_size(
2831                    decoder.context,
2832                ),
2833                2 => <ErrorCheckingForUpdateData as fidl::encoding::TypeMarker>::inline_size(
2834                    decoder.context,
2835                ),
2836                3 => <NoUpdateAvailableData as fidl::encoding::TypeMarker>::inline_size(
2837                    decoder.context,
2838                ),
2839                4 => <InstallationDeferredData as fidl::encoding::TypeMarker>::inline_size(
2840                    decoder.context,
2841                ),
2842                5 => <InstallingData as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2843                6 => <InstallingData as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2844                7 => <InstallationErrorData as fidl::encoding::TypeMarker>::inline_size(
2845                    decoder.context,
2846                ),
2847                _ => return Err(fidl::Error::UnknownUnionTag),
2848            };
2849
2850            if inlined != (member_inline_size <= 4) {
2851                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2852            }
2853            let _inner_offset;
2854            if inlined {
2855                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2856                _inner_offset = offset + 8;
2857            } else {
2858                depth.increment()?;
2859                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2860            }
2861            match ordinal {
2862                1 => {
2863                    #[allow(irrefutable_let_patterns)]
2864                    if let State::CheckingForUpdates(_) = self {
2865                        // Do nothing, read the value into the object
2866                    } else {
2867                        // Initialize `self` to the right variant
2868                        *self =
2869                            State::CheckingForUpdates(fidl::new_empty!(CheckingForUpdatesData, D));
2870                    }
2871                    #[allow(irrefutable_let_patterns)]
2872                    if let State::CheckingForUpdates(ref mut val) = self {
2873                        fidl::decode!(
2874                            CheckingForUpdatesData,
2875                            D,
2876                            val,
2877                            decoder,
2878                            _inner_offset,
2879                            depth
2880                        )?;
2881                    } else {
2882                        unreachable!()
2883                    }
2884                }
2885                2 => {
2886                    #[allow(irrefutable_let_patterns)]
2887                    if let State::ErrorCheckingForUpdate(_) = self {
2888                        // Do nothing, read the value into the object
2889                    } else {
2890                        // Initialize `self` to the right variant
2891                        *self = State::ErrorCheckingForUpdate(fidl::new_empty!(
2892                            ErrorCheckingForUpdateData,
2893                            D
2894                        ));
2895                    }
2896                    #[allow(irrefutable_let_patterns)]
2897                    if let State::ErrorCheckingForUpdate(ref mut val) = self {
2898                        fidl::decode!(
2899                            ErrorCheckingForUpdateData,
2900                            D,
2901                            val,
2902                            decoder,
2903                            _inner_offset,
2904                            depth
2905                        )?;
2906                    } else {
2907                        unreachable!()
2908                    }
2909                }
2910                3 => {
2911                    #[allow(irrefutable_let_patterns)]
2912                    if let State::NoUpdateAvailable(_) = self {
2913                        // Do nothing, read the value into the object
2914                    } else {
2915                        // Initialize `self` to the right variant
2916                        *self =
2917                            State::NoUpdateAvailable(fidl::new_empty!(NoUpdateAvailableData, D));
2918                    }
2919                    #[allow(irrefutable_let_patterns)]
2920                    if let State::NoUpdateAvailable(ref mut val) = self {
2921                        fidl::decode!(
2922                            NoUpdateAvailableData,
2923                            D,
2924                            val,
2925                            decoder,
2926                            _inner_offset,
2927                            depth
2928                        )?;
2929                    } else {
2930                        unreachable!()
2931                    }
2932                }
2933                4 => {
2934                    #[allow(irrefutable_let_patterns)]
2935                    if let State::InstallationDeferredByPolicy(_) = self {
2936                        // Do nothing, read the value into the object
2937                    } else {
2938                        // Initialize `self` to the right variant
2939                        *self = State::InstallationDeferredByPolicy(fidl::new_empty!(
2940                            InstallationDeferredData,
2941                            D
2942                        ));
2943                    }
2944                    #[allow(irrefutable_let_patterns)]
2945                    if let State::InstallationDeferredByPolicy(ref mut val) = self {
2946                        fidl::decode!(
2947                            InstallationDeferredData,
2948                            D,
2949                            val,
2950                            decoder,
2951                            _inner_offset,
2952                            depth
2953                        )?;
2954                    } else {
2955                        unreachable!()
2956                    }
2957                }
2958                5 => {
2959                    #[allow(irrefutable_let_patterns)]
2960                    if let State::InstallingUpdate(_) = self {
2961                        // Do nothing, read the value into the object
2962                    } else {
2963                        // Initialize `self` to the right variant
2964                        *self = State::InstallingUpdate(fidl::new_empty!(InstallingData, D));
2965                    }
2966                    #[allow(irrefutable_let_patterns)]
2967                    if let State::InstallingUpdate(ref mut val) = self {
2968                        fidl::decode!(InstallingData, D, val, decoder, _inner_offset, depth)?;
2969                    } else {
2970                        unreachable!()
2971                    }
2972                }
2973                6 => {
2974                    #[allow(irrefutable_let_patterns)]
2975                    if let State::WaitingForReboot(_) = self {
2976                        // Do nothing, read the value into the object
2977                    } else {
2978                        // Initialize `self` to the right variant
2979                        *self = State::WaitingForReboot(fidl::new_empty!(InstallingData, D));
2980                    }
2981                    #[allow(irrefutable_let_patterns)]
2982                    if let State::WaitingForReboot(ref mut val) = self {
2983                        fidl::decode!(InstallingData, D, val, decoder, _inner_offset, depth)?;
2984                    } else {
2985                        unreachable!()
2986                    }
2987                }
2988                7 => {
2989                    #[allow(irrefutable_let_patterns)]
2990                    if let State::InstallationError(_) = self {
2991                        // Do nothing, read the value into the object
2992                    } else {
2993                        // Initialize `self` to the right variant
2994                        *self =
2995                            State::InstallationError(fidl::new_empty!(InstallationErrorData, D));
2996                    }
2997                    #[allow(irrefutable_let_patterns)]
2998                    if let State::InstallationError(ref mut val) = self {
2999                        fidl::decode!(
3000                            InstallationErrorData,
3001                            D,
3002                            val,
3003                            decoder,
3004                            _inner_offset,
3005                            depth
3006                        )?;
3007                    } else {
3008                        unreachable!()
3009                    }
3010                }
3011                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3012            }
3013            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3014                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3015            }
3016            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3017                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3018            }
3019            Ok(())
3020        }
3021    }
3022}