fidl_fuchsia_power_broker__common/
fidl_fuchsia_power_broker__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/// Used to describe the power level of an element.
12/// Could extend this further to support additional types of power
13/// levels, such as ACPI.
14pub type PowerLevel = u8;
15
16pub const MAX_DEPENDENCIES_IN_ADD_ELEMENT: u16 = 128;
17
18pub const MAX_ELEMENT_NAME_LEN: u8 = 64;
19
20/// PowerLevel name lengths are limited to reduce Inspect space usage
21pub const MAX_LEVEL_NAME_LEN: u16 = 16;
22
23pub const MAX_TOKENS_IN_ADD_ELEMENT: u16 = 128;
24
25pub const MAX_VALID_POWER_LEVELS: u16 = 256;
26
27bitflags! {
28    /// Element Permissions
29    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
30    pub struct Permissions: u32 {
31        const MODIFY_ASSERTIVE_DEPENDENT = 1;
32        const MODIFY_OPPORTUNISTIC_DEPENDENT = 2;
33        const MODIFY_DEPENDENCY = 4;
34    }
35}
36
37impl Permissions {}
38
39#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
40pub enum AddElementError {
41    Invalid,
42    NotAuthorized,
43    #[doc(hidden)]
44    __SourceBreaking {
45        unknown_ordinal: u32,
46    },
47}
48
49/// Pattern that matches an unknown `AddElementError` member.
50#[macro_export]
51macro_rules! AddElementErrorUnknown {
52    () => {
53        _
54    };
55}
56
57impl AddElementError {
58    #[inline]
59    pub fn from_primitive(prim: u32) -> Option<Self> {
60        match prim {
61            1 => Some(Self::Invalid),
62            2 => Some(Self::NotAuthorized),
63            _ => None,
64        }
65    }
66
67    #[inline]
68    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
69        match prim {
70            1 => Self::Invalid,
71            2 => Self::NotAuthorized,
72            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
73        }
74    }
75
76    #[inline]
77    pub fn unknown() -> Self {
78        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
79    }
80
81    #[inline]
82    pub const fn into_primitive(self) -> u32 {
83        match self {
84            Self::Invalid => 1,
85            Self::NotAuthorized => 2,
86            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
87        }
88    }
89
90    #[inline]
91    pub fn is_unknown(&self) -> bool {
92        match self {
93            Self::__SourceBreaking { unknown_ordinal: _ } => true,
94            _ => false,
95        }
96    }
97}
98
99/// BinaryPowerLevel is a well-known set of PowerLevels with only two
100/// states: OFF and ON.
101#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
102#[repr(u8)]
103pub enum BinaryPowerLevel {
104    Off = 0,
105    On = 1,
106}
107
108impl BinaryPowerLevel {
109    #[inline]
110    pub fn from_primitive(prim: u8) -> Option<Self> {
111        match prim {
112            0 => Some(Self::Off),
113            1 => Some(Self::On),
114            _ => None,
115        }
116    }
117
118    #[inline]
119    pub const fn into_primitive(self) -> u8 {
120        self as u8
121    }
122}
123
124#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
125pub enum CurrentLevelError {
126    NotAuthorized,
127    #[doc(hidden)]
128    __SourceBreaking {
129        unknown_ordinal: u32,
130    },
131}
132
133/// Pattern that matches an unknown `CurrentLevelError` member.
134#[macro_export]
135macro_rules! CurrentLevelErrorUnknown {
136    () => {
137        _
138    };
139}
140
141impl CurrentLevelError {
142    #[inline]
143    pub fn from_primitive(prim: u32) -> Option<Self> {
144        match prim {
145            1 => Some(Self::NotAuthorized),
146            _ => None,
147        }
148    }
149
150    #[inline]
151    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
152        match prim {
153            1 => Self::NotAuthorized,
154            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
155        }
156    }
157
158    #[inline]
159    pub fn unknown() -> Self {
160        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
161    }
162
163    #[inline]
164    pub const fn into_primitive(self) -> u32 {
165        match self {
166            Self::NotAuthorized => 1,
167            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
168        }
169    }
170
171    #[inline]
172    pub fn is_unknown(&self) -> bool {
173        match self {
174            Self::__SourceBreaking { unknown_ordinal: _ } => true,
175            _ => false,
176        }
177    }
178}
179
180/// An assertive dependency is strongly-fulfilled and orderly-on-termination.
181/// An opportunistic dependency is weakly-fulfilled but still orderly-on-termination.
182///
183/// See https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0250_power_topology#dependency_types
184/// for more details on these definitions.
185#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
186pub enum DependencyType {
187    Assertive,
188    Opportunistic,
189    #[doc(hidden)]
190    __SourceBreaking {
191        unknown_ordinal: u32,
192    },
193}
194
195/// Pattern that matches an unknown `DependencyType` member.
196#[macro_export]
197macro_rules! DependencyTypeUnknown {
198    () => {
199        _
200    };
201}
202
203impl DependencyType {
204    #[inline]
205    pub fn from_primitive(prim: u32) -> Option<Self> {
206        match prim {
207            1 => Some(Self::Assertive),
208            2 => Some(Self::Opportunistic),
209            _ => None,
210        }
211    }
212
213    #[inline]
214    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
215        match prim {
216            1 => Self::Assertive,
217            2 => Self::Opportunistic,
218            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
219        }
220    }
221
222    #[inline]
223    pub fn unknown() -> Self {
224        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
225    }
226
227    #[inline]
228    pub const fn into_primitive(self) -> u32 {
229        match self {
230            Self::Assertive => 1,
231            Self::Opportunistic => 2,
232            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
233        }
234    }
235
236    #[inline]
237    pub fn is_unknown(&self) -> bool {
238        match self {
239            Self::__SourceBreaking { unknown_ordinal: _ } => true,
240            _ => false,
241        }
242    }
243}
244
245#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
246pub enum ElementInfoProviderError {
247    Unknown,
248    Failed,
249    #[doc(hidden)]
250    __SourceBreaking {
251        unknown_ordinal: u32,
252    },
253}
254
255/// Pattern that matches an unknown `ElementInfoProviderError` member.
256#[macro_export]
257macro_rules! ElementInfoProviderErrorUnknown {
258    () => {
259        _
260    };
261}
262
263impl ElementInfoProviderError {
264    #[inline]
265    pub fn from_primitive(prim: u32) -> Option<Self> {
266        match prim {
267            0 => Some(Self::Unknown),
268            1 => Some(Self::Failed),
269            _ => None,
270        }
271    }
272
273    #[inline]
274    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
275        match prim {
276            0 => Self::Unknown,
277            1 => Self::Failed,
278            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
279        }
280    }
281
282    #[inline]
283    pub fn unknown() -> Self {
284        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
285    }
286
287    #[inline]
288    pub const fn into_primitive(self) -> u32 {
289        match self {
290            Self::Unknown => 0,
291            Self::Failed => 1,
292            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
293        }
294    }
295
296    #[inline]
297    pub fn is_unknown(&self) -> bool {
298        match self {
299            Self::__SourceBreaking { unknown_ordinal: _ } => true,
300            _ => false,
301        }
302    }
303}
304
305#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
306pub enum LeaseError {
307    Internal,
308    NotAuthorized,
309    InvalidLevel,
310    #[doc(hidden)]
311    __SourceBreaking {
312        unknown_ordinal: u32,
313    },
314}
315
316/// Pattern that matches an unknown `LeaseError` member.
317#[macro_export]
318macro_rules! LeaseErrorUnknown {
319    () => {
320        _
321    };
322}
323
324impl LeaseError {
325    #[inline]
326    pub fn from_primitive(prim: u32) -> Option<Self> {
327        match prim {
328            1 => Some(Self::Internal),
329            2 => Some(Self::NotAuthorized),
330            3 => Some(Self::InvalidLevel),
331            _ => None,
332        }
333    }
334
335    #[inline]
336    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
337        match prim {
338            1 => Self::Internal,
339            2 => Self::NotAuthorized,
340            3 => Self::InvalidLevel,
341            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
342        }
343    }
344
345    #[inline]
346    pub fn unknown() -> Self {
347        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
348    }
349
350    #[inline]
351    pub const fn into_primitive(self) -> u32 {
352        match self {
353            Self::Internal => 1,
354            Self::NotAuthorized => 2,
355            Self::InvalidLevel => 3,
356            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
357        }
358    }
359
360    #[inline]
361    pub fn is_unknown(&self) -> bool {
362        match self {
363            Self::__SourceBreaking { unknown_ordinal: _ } => true,
364            _ => false,
365        }
366    }
367}
368
369#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
370pub enum LeaseStatus {
371    Unknown,
372    /// The dependencies of the leased `PowerLevel` are not at their required
373    /// levels.
374    Pending,
375    /// The `PowerElement` is **not** necessarily at the `PowerLevel` leased,
376    /// but the `PowerElement`s requried by the leased `PowerLevel`' are at
377    /// their required `PowerLevel`s.
378    Satisfied,
379    #[doc(hidden)]
380    __SourceBreaking {
381        unknown_ordinal: u32,
382    },
383}
384
385/// Pattern that matches an unknown `LeaseStatus` member.
386#[macro_export]
387macro_rules! LeaseStatusUnknown {
388    () => {
389        _
390    };
391}
392
393impl LeaseStatus {
394    #[inline]
395    pub fn from_primitive(prim: u32) -> Option<Self> {
396        match prim {
397            0 => Some(Self::Unknown),
398            1 => Some(Self::Pending),
399            2 => Some(Self::Satisfied),
400            _ => None,
401        }
402    }
403
404    #[inline]
405    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
406        match prim {
407            0 => Self::Unknown,
408            1 => Self::Pending,
409            2 => Self::Satisfied,
410            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
411        }
412    }
413
414    #[inline]
415    pub fn unknown() -> Self {
416        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
417    }
418
419    #[inline]
420    pub const fn into_primitive(self) -> u32 {
421        match self {
422            Self::Unknown => 0,
423            Self::Pending => 1,
424            Self::Satisfied => 2,
425            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
426        }
427    }
428
429    #[inline]
430    pub fn is_unknown(&self) -> bool {
431        match self {
432            Self::__SourceBreaking { unknown_ordinal: _ } => true,
433            _ => false,
434        }
435    }
436}
437
438#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
439pub enum ModifyDependencyError {
440    AlreadyExists,
441    Invalid,
442    NotAuthorized,
443    NotFound,
444    #[doc(hidden)]
445    __SourceBreaking {
446        unknown_ordinal: u32,
447    },
448}
449
450/// Pattern that matches an unknown `ModifyDependencyError` member.
451#[macro_export]
452macro_rules! ModifyDependencyErrorUnknown {
453    () => {
454        _
455    };
456}
457
458impl ModifyDependencyError {
459    #[inline]
460    pub fn from_primitive(prim: u32) -> Option<Self> {
461        match prim {
462            1 => Some(Self::AlreadyExists),
463            2 => Some(Self::Invalid),
464            3 => Some(Self::NotAuthorized),
465            4 => Some(Self::NotFound),
466            _ => None,
467        }
468    }
469
470    #[inline]
471    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
472        match prim {
473            1 => Self::AlreadyExists,
474            2 => Self::Invalid,
475            3 => Self::NotAuthorized,
476            4 => Self::NotFound,
477            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
478        }
479    }
480
481    #[inline]
482    pub fn unknown() -> Self {
483        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
484    }
485
486    #[inline]
487    pub const fn into_primitive(self) -> u32 {
488        match self {
489            Self::AlreadyExists => 1,
490            Self::Invalid => 2,
491            Self::NotAuthorized => 3,
492            Self::NotFound => 4,
493            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
494        }
495    }
496
497    #[inline]
498    pub fn is_unknown(&self) -> bool {
499        match self {
500            Self::__SourceBreaking { unknown_ordinal: _ } => true,
501            _ => false,
502        }
503    }
504}
505
506#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
507pub enum RegisterDependencyTokenError {
508    AlreadyInUse,
509    Internal,
510    #[doc(hidden)]
511    __SourceBreaking {
512        unknown_ordinal: u32,
513    },
514}
515
516/// Pattern that matches an unknown `RegisterDependencyTokenError` member.
517#[macro_export]
518macro_rules! RegisterDependencyTokenErrorUnknown {
519    () => {
520        _
521    };
522}
523
524impl RegisterDependencyTokenError {
525    #[inline]
526    pub fn from_primitive(prim: u32) -> Option<Self> {
527        match prim {
528            1 => Some(Self::AlreadyInUse),
529            2 => Some(Self::Internal),
530            _ => None,
531        }
532    }
533
534    #[inline]
535    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
536        match prim {
537            1 => Self::AlreadyInUse,
538            2 => Self::Internal,
539            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
540        }
541    }
542
543    #[inline]
544    pub fn unknown() -> Self {
545        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
546    }
547
548    #[inline]
549    pub const fn into_primitive(self) -> u32 {
550        match self {
551            Self::AlreadyInUse => 1,
552            Self::Internal => 2,
553            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
554        }
555    }
556
557    #[inline]
558    pub fn is_unknown(&self) -> bool {
559        match self {
560            Self::__SourceBreaking { unknown_ordinal: _ } => true,
561            _ => false,
562        }
563    }
564}
565
566#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
567pub enum RequiredLevelError {
568    Internal,
569    NotAuthorized,
570    Unknown,
571    #[doc(hidden)]
572    __SourceBreaking {
573        unknown_ordinal: u32,
574    },
575}
576
577/// Pattern that matches an unknown `RequiredLevelError` member.
578#[macro_export]
579macro_rules! RequiredLevelErrorUnknown {
580    () => {
581        _
582    };
583}
584
585impl RequiredLevelError {
586    #[inline]
587    pub fn from_primitive(prim: u32) -> Option<Self> {
588        match prim {
589            1 => Some(Self::Internal),
590            2 => Some(Self::NotAuthorized),
591            3 => Some(Self::Unknown),
592            _ => None,
593        }
594    }
595
596    #[inline]
597    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
598        match prim {
599            1 => Self::Internal,
600            2 => Self::NotAuthorized,
601            3 => Self::Unknown,
602            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
603        }
604    }
605
606    #[inline]
607    pub fn unknown() -> Self {
608        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
609    }
610
611    #[inline]
612    pub const fn into_primitive(self) -> u32 {
613        match self {
614            Self::Internal => 1,
615            Self::NotAuthorized => 2,
616            Self::Unknown => 3,
617            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
618        }
619    }
620
621    #[inline]
622    pub fn is_unknown(&self) -> bool {
623        match self {
624            Self::__SourceBreaking { unknown_ordinal: _ } => true,
625            _ => false,
626        }
627    }
628}
629
630#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
631pub enum StatusError {
632    Unknown,
633    #[doc(hidden)]
634    __SourceBreaking {
635        unknown_ordinal: u32,
636    },
637}
638
639/// Pattern that matches an unknown `StatusError` member.
640#[macro_export]
641macro_rules! StatusErrorUnknown {
642    () => {
643        _
644    };
645}
646
647impl StatusError {
648    #[inline]
649    pub fn from_primitive(prim: u32) -> Option<Self> {
650        match prim {
651            1 => Some(Self::Unknown),
652            _ => None,
653        }
654    }
655
656    #[inline]
657    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
658        match prim {
659            1 => Self::Unknown,
660            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
661        }
662    }
663
664    #[inline]
665    pub fn unknown() -> Self {
666        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
667    }
668
669    #[inline]
670    pub const fn into_primitive(self) -> u32 {
671        match self {
672            Self::Unknown => 1,
673            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
674        }
675    }
676
677    #[inline]
678    pub fn is_unknown(&self) -> bool {
679        match self {
680            Self::__SourceBreaking { unknown_ordinal: _ } => true,
681            _ => false,
682        }
683    }
684}
685
686#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
687pub enum UnregisterDependencyTokenError {
688    NotAuthorized,
689    NotFound,
690    #[doc(hidden)]
691    __SourceBreaking {
692        unknown_ordinal: u32,
693    },
694}
695
696/// Pattern that matches an unknown `UnregisterDependencyTokenError` member.
697#[macro_export]
698macro_rules! UnregisterDependencyTokenErrorUnknown {
699    () => {
700        _
701    };
702}
703
704impl UnregisterDependencyTokenError {
705    #[inline]
706    pub fn from_primitive(prim: u32) -> Option<Self> {
707        match prim {
708            1 => Some(Self::NotAuthorized),
709            2 => Some(Self::NotFound),
710            _ => None,
711        }
712    }
713
714    #[inline]
715    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
716        match prim {
717            1 => Self::NotAuthorized,
718            2 => Self::NotFound,
719            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
720        }
721    }
722
723    #[inline]
724    pub fn unknown() -> Self {
725        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
726    }
727
728    #[inline]
729    pub const fn into_primitive(self) -> u32 {
730        match self {
731            Self::NotAuthorized => 1,
732            Self::NotFound => 2,
733            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
734        }
735    }
736
737    #[inline]
738    pub fn is_unknown(&self) -> bool {
739        match self {
740            Self::__SourceBreaking { unknown_ordinal: _ } => true,
741            _ => false,
742        }
743    }
744}
745
746#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
747#[repr(C)]
748pub struct ElementRunnerSetLevelRequest {
749    pub level: u8,
750}
751
752impl fidl::Persistable for ElementRunnerSetLevelRequest {}
753
754#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
755pub struct LeaseControlWatchStatusRequest {
756    pub last_status: LeaseStatus,
757}
758
759impl fidl::Persistable for LeaseControlWatchStatusRequest {}
760
761#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
762pub struct LeaseControlWatchStatusResponse {
763    pub status: LeaseStatus,
764}
765
766impl fidl::Persistable for LeaseControlWatchStatusResponse {}
767
768/// Mapping of a vector of [`fuchsia.power.broker/PowerLevelName`] to a Power Element via
769/// its plaintext name. Names are expected to be unique between elements and persistent
770/// across reboots of the same build, but consistency is not guaranteed between different builds.
771#[derive(Clone, Debug, Default, PartialEq)]
772pub struct ElementPowerLevelNames {
773    pub identifier: Option<String>,
774    pub levels: Option<Vec<PowerLevelName>>,
775    #[doc(hidden)]
776    pub __source_breaking: fidl::marker::SourceBreaking,
777}
778
779impl fidl::Persistable for ElementPowerLevelNames {}
780
781/// Mapping of a plaintext name to a PowerLevel. Names are expected to be unique between
782/// elements and persistent across reboots of the same build, but consistency is not
783/// guaranteed between different builds.
784#[derive(Clone, Debug, Default, PartialEq)]
785pub struct PowerLevelName {
786    pub level: Option<u8>,
787    pub name: Option<String>,
788    #[doc(hidden)]
789    pub __source_breaking: fidl::marker::SourceBreaking,
790}
791
792impl fidl::Persistable for PowerLevelName {}
793
794mod internal {
795    use super::*;
796    unsafe impl fidl::encoding::TypeMarker for Permissions {
797        type Owned = Self;
798
799        #[inline(always)]
800        fn inline_align(_context: fidl::encoding::Context) -> usize {
801            4
802        }
803
804        #[inline(always)]
805        fn inline_size(_context: fidl::encoding::Context) -> usize {
806            4
807        }
808    }
809
810    impl fidl::encoding::ValueTypeMarker for Permissions {
811        type Borrowed<'a> = Self;
812        #[inline(always)]
813        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
814            *value
815        }
816    }
817
818    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Permissions {
819        #[inline]
820        unsafe fn encode(
821            self,
822            encoder: &mut fidl::encoding::Encoder<'_, D>,
823            offset: usize,
824            _depth: fidl::encoding::Depth,
825        ) -> fidl::Result<()> {
826            encoder.debug_check_bounds::<Self>(offset);
827            if self.bits() & Self::all().bits() != self.bits() {
828                return Err(fidl::Error::InvalidBitsValue);
829            }
830            encoder.write_num(self.bits(), offset);
831            Ok(())
832        }
833    }
834
835    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Permissions {
836        #[inline(always)]
837        fn new_empty() -> Self {
838            Self::empty()
839        }
840
841        #[inline]
842        unsafe fn decode(
843            &mut self,
844            decoder: &mut fidl::encoding::Decoder<'_, D>,
845            offset: usize,
846            _depth: fidl::encoding::Depth,
847        ) -> fidl::Result<()> {
848            decoder.debug_check_bounds::<Self>(offset);
849            let prim = decoder.read_num::<u32>(offset);
850            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
851            Ok(())
852        }
853    }
854    unsafe impl fidl::encoding::TypeMarker for AddElementError {
855        type Owned = Self;
856
857        #[inline(always)]
858        fn inline_align(_context: fidl::encoding::Context) -> usize {
859            std::mem::align_of::<u32>()
860        }
861
862        #[inline(always)]
863        fn inline_size(_context: fidl::encoding::Context) -> usize {
864            std::mem::size_of::<u32>()
865        }
866
867        #[inline(always)]
868        fn encode_is_copy() -> bool {
869            false
870        }
871
872        #[inline(always)]
873        fn decode_is_copy() -> bool {
874            false
875        }
876    }
877
878    impl fidl::encoding::ValueTypeMarker for AddElementError {
879        type Borrowed<'a> = Self;
880        #[inline(always)]
881        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
882            *value
883        }
884    }
885
886    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
887        for AddElementError
888    {
889        #[inline]
890        unsafe fn encode(
891            self,
892            encoder: &mut fidl::encoding::Encoder<'_, D>,
893            offset: usize,
894            _depth: fidl::encoding::Depth,
895        ) -> fidl::Result<()> {
896            encoder.debug_check_bounds::<Self>(offset);
897            encoder.write_num(self.into_primitive(), offset);
898            Ok(())
899        }
900    }
901
902    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AddElementError {
903        #[inline(always)]
904        fn new_empty() -> Self {
905            Self::unknown()
906        }
907
908        #[inline]
909        unsafe fn decode(
910            &mut self,
911            decoder: &mut fidl::encoding::Decoder<'_, D>,
912            offset: usize,
913            _depth: fidl::encoding::Depth,
914        ) -> fidl::Result<()> {
915            decoder.debug_check_bounds::<Self>(offset);
916            let prim = decoder.read_num::<u32>(offset);
917
918            *self = Self::from_primitive_allow_unknown(prim);
919            Ok(())
920        }
921    }
922    unsafe impl fidl::encoding::TypeMarker for BinaryPowerLevel {
923        type Owned = Self;
924
925        #[inline(always)]
926        fn inline_align(_context: fidl::encoding::Context) -> usize {
927            std::mem::align_of::<u8>()
928        }
929
930        #[inline(always)]
931        fn inline_size(_context: fidl::encoding::Context) -> usize {
932            std::mem::size_of::<u8>()
933        }
934
935        #[inline(always)]
936        fn encode_is_copy() -> bool {
937            true
938        }
939
940        #[inline(always)]
941        fn decode_is_copy() -> bool {
942            false
943        }
944    }
945
946    impl fidl::encoding::ValueTypeMarker for BinaryPowerLevel {
947        type Borrowed<'a> = Self;
948        #[inline(always)]
949        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
950            *value
951        }
952    }
953
954    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
955        for BinaryPowerLevel
956    {
957        #[inline]
958        unsafe fn encode(
959            self,
960            encoder: &mut fidl::encoding::Encoder<'_, D>,
961            offset: usize,
962            _depth: fidl::encoding::Depth,
963        ) -> fidl::Result<()> {
964            encoder.debug_check_bounds::<Self>(offset);
965            encoder.write_num(self.into_primitive(), offset);
966            Ok(())
967        }
968    }
969
970    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BinaryPowerLevel {
971        #[inline(always)]
972        fn new_empty() -> Self {
973            Self::Off
974        }
975
976        #[inline]
977        unsafe fn decode(
978            &mut self,
979            decoder: &mut fidl::encoding::Decoder<'_, D>,
980            offset: usize,
981            _depth: fidl::encoding::Depth,
982        ) -> fidl::Result<()> {
983            decoder.debug_check_bounds::<Self>(offset);
984            let prim = decoder.read_num::<u8>(offset);
985
986            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
987            Ok(())
988        }
989    }
990    unsafe impl fidl::encoding::TypeMarker for CurrentLevelError {
991        type Owned = Self;
992
993        #[inline(always)]
994        fn inline_align(_context: fidl::encoding::Context) -> usize {
995            std::mem::align_of::<u32>()
996        }
997
998        #[inline(always)]
999        fn inline_size(_context: fidl::encoding::Context) -> usize {
1000            std::mem::size_of::<u32>()
1001        }
1002
1003        #[inline(always)]
1004        fn encode_is_copy() -> bool {
1005            false
1006        }
1007
1008        #[inline(always)]
1009        fn decode_is_copy() -> bool {
1010            false
1011        }
1012    }
1013
1014    impl fidl::encoding::ValueTypeMarker for CurrentLevelError {
1015        type Borrowed<'a> = Self;
1016        #[inline(always)]
1017        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1018            *value
1019        }
1020    }
1021
1022    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1023        for CurrentLevelError
1024    {
1025        #[inline]
1026        unsafe fn encode(
1027            self,
1028            encoder: &mut fidl::encoding::Encoder<'_, D>,
1029            offset: usize,
1030            _depth: fidl::encoding::Depth,
1031        ) -> fidl::Result<()> {
1032            encoder.debug_check_bounds::<Self>(offset);
1033            encoder.write_num(self.into_primitive(), offset);
1034            Ok(())
1035        }
1036    }
1037
1038    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CurrentLevelError {
1039        #[inline(always)]
1040        fn new_empty() -> Self {
1041            Self::unknown()
1042        }
1043
1044        #[inline]
1045        unsafe fn decode(
1046            &mut self,
1047            decoder: &mut fidl::encoding::Decoder<'_, D>,
1048            offset: usize,
1049            _depth: fidl::encoding::Depth,
1050        ) -> fidl::Result<()> {
1051            decoder.debug_check_bounds::<Self>(offset);
1052            let prim = decoder.read_num::<u32>(offset);
1053
1054            *self = Self::from_primitive_allow_unknown(prim);
1055            Ok(())
1056        }
1057    }
1058    unsafe impl fidl::encoding::TypeMarker for DependencyType {
1059        type Owned = Self;
1060
1061        #[inline(always)]
1062        fn inline_align(_context: fidl::encoding::Context) -> usize {
1063            std::mem::align_of::<u32>()
1064        }
1065
1066        #[inline(always)]
1067        fn inline_size(_context: fidl::encoding::Context) -> usize {
1068            std::mem::size_of::<u32>()
1069        }
1070
1071        #[inline(always)]
1072        fn encode_is_copy() -> bool {
1073            false
1074        }
1075
1076        #[inline(always)]
1077        fn decode_is_copy() -> bool {
1078            false
1079        }
1080    }
1081
1082    impl fidl::encoding::ValueTypeMarker for DependencyType {
1083        type Borrowed<'a> = Self;
1084        #[inline(always)]
1085        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1086            *value
1087        }
1088    }
1089
1090    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DependencyType {
1091        #[inline]
1092        unsafe fn encode(
1093            self,
1094            encoder: &mut fidl::encoding::Encoder<'_, D>,
1095            offset: usize,
1096            _depth: fidl::encoding::Depth,
1097        ) -> fidl::Result<()> {
1098            encoder.debug_check_bounds::<Self>(offset);
1099            encoder.write_num(self.into_primitive(), offset);
1100            Ok(())
1101        }
1102    }
1103
1104    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DependencyType {
1105        #[inline(always)]
1106        fn new_empty() -> Self {
1107            Self::unknown()
1108        }
1109
1110        #[inline]
1111        unsafe fn decode(
1112            &mut self,
1113            decoder: &mut fidl::encoding::Decoder<'_, D>,
1114            offset: usize,
1115            _depth: fidl::encoding::Depth,
1116        ) -> fidl::Result<()> {
1117            decoder.debug_check_bounds::<Self>(offset);
1118            let prim = decoder.read_num::<u32>(offset);
1119
1120            *self = Self::from_primitive_allow_unknown(prim);
1121            Ok(())
1122        }
1123    }
1124    unsafe impl fidl::encoding::TypeMarker for ElementInfoProviderError {
1125        type Owned = Self;
1126
1127        #[inline(always)]
1128        fn inline_align(_context: fidl::encoding::Context) -> usize {
1129            std::mem::align_of::<u32>()
1130        }
1131
1132        #[inline(always)]
1133        fn inline_size(_context: fidl::encoding::Context) -> usize {
1134            std::mem::size_of::<u32>()
1135        }
1136
1137        #[inline(always)]
1138        fn encode_is_copy() -> bool {
1139            false
1140        }
1141
1142        #[inline(always)]
1143        fn decode_is_copy() -> bool {
1144            false
1145        }
1146    }
1147
1148    impl fidl::encoding::ValueTypeMarker for ElementInfoProviderError {
1149        type Borrowed<'a> = Self;
1150        #[inline(always)]
1151        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1152            *value
1153        }
1154    }
1155
1156    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1157        for ElementInfoProviderError
1158    {
1159        #[inline]
1160        unsafe fn encode(
1161            self,
1162            encoder: &mut fidl::encoding::Encoder<'_, D>,
1163            offset: usize,
1164            _depth: fidl::encoding::Depth,
1165        ) -> fidl::Result<()> {
1166            encoder.debug_check_bounds::<Self>(offset);
1167            encoder.write_num(self.into_primitive(), offset);
1168            Ok(())
1169        }
1170    }
1171
1172    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1173        for ElementInfoProviderError
1174    {
1175        #[inline(always)]
1176        fn new_empty() -> Self {
1177            Self::unknown()
1178        }
1179
1180        #[inline]
1181        unsafe fn decode(
1182            &mut self,
1183            decoder: &mut fidl::encoding::Decoder<'_, D>,
1184            offset: usize,
1185            _depth: fidl::encoding::Depth,
1186        ) -> fidl::Result<()> {
1187            decoder.debug_check_bounds::<Self>(offset);
1188            let prim = decoder.read_num::<u32>(offset);
1189
1190            *self = Self::from_primitive_allow_unknown(prim);
1191            Ok(())
1192        }
1193    }
1194    unsafe impl fidl::encoding::TypeMarker for LeaseError {
1195        type Owned = Self;
1196
1197        #[inline(always)]
1198        fn inline_align(_context: fidl::encoding::Context) -> usize {
1199            std::mem::align_of::<u32>()
1200        }
1201
1202        #[inline(always)]
1203        fn inline_size(_context: fidl::encoding::Context) -> usize {
1204            std::mem::size_of::<u32>()
1205        }
1206
1207        #[inline(always)]
1208        fn encode_is_copy() -> bool {
1209            false
1210        }
1211
1212        #[inline(always)]
1213        fn decode_is_copy() -> bool {
1214            false
1215        }
1216    }
1217
1218    impl fidl::encoding::ValueTypeMarker for LeaseError {
1219        type Borrowed<'a> = Self;
1220        #[inline(always)]
1221        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1222            *value
1223        }
1224    }
1225
1226    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LeaseError {
1227        #[inline]
1228        unsafe fn encode(
1229            self,
1230            encoder: &mut fidl::encoding::Encoder<'_, D>,
1231            offset: usize,
1232            _depth: fidl::encoding::Depth,
1233        ) -> fidl::Result<()> {
1234            encoder.debug_check_bounds::<Self>(offset);
1235            encoder.write_num(self.into_primitive(), offset);
1236            Ok(())
1237        }
1238    }
1239
1240    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LeaseError {
1241        #[inline(always)]
1242        fn new_empty() -> Self {
1243            Self::unknown()
1244        }
1245
1246        #[inline]
1247        unsafe fn decode(
1248            &mut self,
1249            decoder: &mut fidl::encoding::Decoder<'_, D>,
1250            offset: usize,
1251            _depth: fidl::encoding::Depth,
1252        ) -> fidl::Result<()> {
1253            decoder.debug_check_bounds::<Self>(offset);
1254            let prim = decoder.read_num::<u32>(offset);
1255
1256            *self = Self::from_primitive_allow_unknown(prim);
1257            Ok(())
1258        }
1259    }
1260    unsafe impl fidl::encoding::TypeMarker for LeaseStatus {
1261        type Owned = Self;
1262
1263        #[inline(always)]
1264        fn inline_align(_context: fidl::encoding::Context) -> usize {
1265            std::mem::align_of::<u32>()
1266        }
1267
1268        #[inline(always)]
1269        fn inline_size(_context: fidl::encoding::Context) -> usize {
1270            std::mem::size_of::<u32>()
1271        }
1272
1273        #[inline(always)]
1274        fn encode_is_copy() -> bool {
1275            false
1276        }
1277
1278        #[inline(always)]
1279        fn decode_is_copy() -> bool {
1280            false
1281        }
1282    }
1283
1284    impl fidl::encoding::ValueTypeMarker for LeaseStatus {
1285        type Borrowed<'a> = Self;
1286        #[inline(always)]
1287        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1288            *value
1289        }
1290    }
1291
1292    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LeaseStatus {
1293        #[inline]
1294        unsafe fn encode(
1295            self,
1296            encoder: &mut fidl::encoding::Encoder<'_, D>,
1297            offset: usize,
1298            _depth: fidl::encoding::Depth,
1299        ) -> fidl::Result<()> {
1300            encoder.debug_check_bounds::<Self>(offset);
1301            encoder.write_num(self.into_primitive(), offset);
1302            Ok(())
1303        }
1304    }
1305
1306    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LeaseStatus {
1307        #[inline(always)]
1308        fn new_empty() -> Self {
1309            Self::unknown()
1310        }
1311
1312        #[inline]
1313        unsafe fn decode(
1314            &mut self,
1315            decoder: &mut fidl::encoding::Decoder<'_, D>,
1316            offset: usize,
1317            _depth: fidl::encoding::Depth,
1318        ) -> fidl::Result<()> {
1319            decoder.debug_check_bounds::<Self>(offset);
1320            let prim = decoder.read_num::<u32>(offset);
1321
1322            *self = Self::from_primitive_allow_unknown(prim);
1323            Ok(())
1324        }
1325    }
1326    unsafe impl fidl::encoding::TypeMarker for ModifyDependencyError {
1327        type Owned = Self;
1328
1329        #[inline(always)]
1330        fn inline_align(_context: fidl::encoding::Context) -> usize {
1331            std::mem::align_of::<u32>()
1332        }
1333
1334        #[inline(always)]
1335        fn inline_size(_context: fidl::encoding::Context) -> usize {
1336            std::mem::size_of::<u32>()
1337        }
1338
1339        #[inline(always)]
1340        fn encode_is_copy() -> bool {
1341            false
1342        }
1343
1344        #[inline(always)]
1345        fn decode_is_copy() -> bool {
1346            false
1347        }
1348    }
1349
1350    impl fidl::encoding::ValueTypeMarker for ModifyDependencyError {
1351        type Borrowed<'a> = Self;
1352        #[inline(always)]
1353        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1354            *value
1355        }
1356    }
1357
1358    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1359        for ModifyDependencyError
1360    {
1361        #[inline]
1362        unsafe fn encode(
1363            self,
1364            encoder: &mut fidl::encoding::Encoder<'_, D>,
1365            offset: usize,
1366            _depth: fidl::encoding::Depth,
1367        ) -> fidl::Result<()> {
1368            encoder.debug_check_bounds::<Self>(offset);
1369            encoder.write_num(self.into_primitive(), offset);
1370            Ok(())
1371        }
1372    }
1373
1374    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModifyDependencyError {
1375        #[inline(always)]
1376        fn new_empty() -> Self {
1377            Self::unknown()
1378        }
1379
1380        #[inline]
1381        unsafe fn decode(
1382            &mut self,
1383            decoder: &mut fidl::encoding::Decoder<'_, D>,
1384            offset: usize,
1385            _depth: fidl::encoding::Depth,
1386        ) -> fidl::Result<()> {
1387            decoder.debug_check_bounds::<Self>(offset);
1388            let prim = decoder.read_num::<u32>(offset);
1389
1390            *self = Self::from_primitive_allow_unknown(prim);
1391            Ok(())
1392        }
1393    }
1394    unsafe impl fidl::encoding::TypeMarker for RegisterDependencyTokenError {
1395        type Owned = Self;
1396
1397        #[inline(always)]
1398        fn inline_align(_context: fidl::encoding::Context) -> usize {
1399            std::mem::align_of::<u32>()
1400        }
1401
1402        #[inline(always)]
1403        fn inline_size(_context: fidl::encoding::Context) -> usize {
1404            std::mem::size_of::<u32>()
1405        }
1406
1407        #[inline(always)]
1408        fn encode_is_copy() -> bool {
1409            false
1410        }
1411
1412        #[inline(always)]
1413        fn decode_is_copy() -> bool {
1414            false
1415        }
1416    }
1417
1418    impl fidl::encoding::ValueTypeMarker for RegisterDependencyTokenError {
1419        type Borrowed<'a> = Self;
1420        #[inline(always)]
1421        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1422            *value
1423        }
1424    }
1425
1426    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1427        for RegisterDependencyTokenError
1428    {
1429        #[inline]
1430        unsafe fn encode(
1431            self,
1432            encoder: &mut fidl::encoding::Encoder<'_, D>,
1433            offset: usize,
1434            _depth: fidl::encoding::Depth,
1435        ) -> fidl::Result<()> {
1436            encoder.debug_check_bounds::<Self>(offset);
1437            encoder.write_num(self.into_primitive(), offset);
1438            Ok(())
1439        }
1440    }
1441
1442    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1443        for RegisterDependencyTokenError
1444    {
1445        #[inline(always)]
1446        fn new_empty() -> Self {
1447            Self::unknown()
1448        }
1449
1450        #[inline]
1451        unsafe fn decode(
1452            &mut self,
1453            decoder: &mut fidl::encoding::Decoder<'_, D>,
1454            offset: usize,
1455            _depth: fidl::encoding::Depth,
1456        ) -> fidl::Result<()> {
1457            decoder.debug_check_bounds::<Self>(offset);
1458            let prim = decoder.read_num::<u32>(offset);
1459
1460            *self = Self::from_primitive_allow_unknown(prim);
1461            Ok(())
1462        }
1463    }
1464    unsafe impl fidl::encoding::TypeMarker for RequiredLevelError {
1465        type Owned = Self;
1466
1467        #[inline(always)]
1468        fn inline_align(_context: fidl::encoding::Context) -> usize {
1469            std::mem::align_of::<u32>()
1470        }
1471
1472        #[inline(always)]
1473        fn inline_size(_context: fidl::encoding::Context) -> usize {
1474            std::mem::size_of::<u32>()
1475        }
1476
1477        #[inline(always)]
1478        fn encode_is_copy() -> bool {
1479            false
1480        }
1481
1482        #[inline(always)]
1483        fn decode_is_copy() -> bool {
1484            false
1485        }
1486    }
1487
1488    impl fidl::encoding::ValueTypeMarker for RequiredLevelError {
1489        type Borrowed<'a> = Self;
1490        #[inline(always)]
1491        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1492            *value
1493        }
1494    }
1495
1496    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1497        for RequiredLevelError
1498    {
1499        #[inline]
1500        unsafe fn encode(
1501            self,
1502            encoder: &mut fidl::encoding::Encoder<'_, D>,
1503            offset: usize,
1504            _depth: fidl::encoding::Depth,
1505        ) -> fidl::Result<()> {
1506            encoder.debug_check_bounds::<Self>(offset);
1507            encoder.write_num(self.into_primitive(), offset);
1508            Ok(())
1509        }
1510    }
1511
1512    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RequiredLevelError {
1513        #[inline(always)]
1514        fn new_empty() -> Self {
1515            Self::unknown()
1516        }
1517
1518        #[inline]
1519        unsafe fn decode(
1520            &mut self,
1521            decoder: &mut fidl::encoding::Decoder<'_, D>,
1522            offset: usize,
1523            _depth: fidl::encoding::Depth,
1524        ) -> fidl::Result<()> {
1525            decoder.debug_check_bounds::<Self>(offset);
1526            let prim = decoder.read_num::<u32>(offset);
1527
1528            *self = Self::from_primitive_allow_unknown(prim);
1529            Ok(())
1530        }
1531    }
1532    unsafe impl fidl::encoding::TypeMarker for StatusError {
1533        type Owned = Self;
1534
1535        #[inline(always)]
1536        fn inline_align(_context: fidl::encoding::Context) -> usize {
1537            std::mem::align_of::<u32>()
1538        }
1539
1540        #[inline(always)]
1541        fn inline_size(_context: fidl::encoding::Context) -> usize {
1542            std::mem::size_of::<u32>()
1543        }
1544
1545        #[inline(always)]
1546        fn encode_is_copy() -> bool {
1547            false
1548        }
1549
1550        #[inline(always)]
1551        fn decode_is_copy() -> bool {
1552            false
1553        }
1554    }
1555
1556    impl fidl::encoding::ValueTypeMarker for StatusError {
1557        type Borrowed<'a> = Self;
1558        #[inline(always)]
1559        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1560            *value
1561        }
1562    }
1563
1564    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StatusError {
1565        #[inline]
1566        unsafe fn encode(
1567            self,
1568            encoder: &mut fidl::encoding::Encoder<'_, D>,
1569            offset: usize,
1570            _depth: fidl::encoding::Depth,
1571        ) -> fidl::Result<()> {
1572            encoder.debug_check_bounds::<Self>(offset);
1573            encoder.write_num(self.into_primitive(), offset);
1574            Ok(())
1575        }
1576    }
1577
1578    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatusError {
1579        #[inline(always)]
1580        fn new_empty() -> Self {
1581            Self::unknown()
1582        }
1583
1584        #[inline]
1585        unsafe fn decode(
1586            &mut self,
1587            decoder: &mut fidl::encoding::Decoder<'_, D>,
1588            offset: usize,
1589            _depth: fidl::encoding::Depth,
1590        ) -> fidl::Result<()> {
1591            decoder.debug_check_bounds::<Self>(offset);
1592            let prim = decoder.read_num::<u32>(offset);
1593
1594            *self = Self::from_primitive_allow_unknown(prim);
1595            Ok(())
1596        }
1597    }
1598    unsafe impl fidl::encoding::TypeMarker for UnregisterDependencyTokenError {
1599        type Owned = Self;
1600
1601        #[inline(always)]
1602        fn inline_align(_context: fidl::encoding::Context) -> usize {
1603            std::mem::align_of::<u32>()
1604        }
1605
1606        #[inline(always)]
1607        fn inline_size(_context: fidl::encoding::Context) -> usize {
1608            std::mem::size_of::<u32>()
1609        }
1610
1611        #[inline(always)]
1612        fn encode_is_copy() -> bool {
1613            false
1614        }
1615
1616        #[inline(always)]
1617        fn decode_is_copy() -> bool {
1618            false
1619        }
1620    }
1621
1622    impl fidl::encoding::ValueTypeMarker for UnregisterDependencyTokenError {
1623        type Borrowed<'a> = Self;
1624        #[inline(always)]
1625        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1626            *value
1627        }
1628    }
1629
1630    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1631        for UnregisterDependencyTokenError
1632    {
1633        #[inline]
1634        unsafe fn encode(
1635            self,
1636            encoder: &mut fidl::encoding::Encoder<'_, D>,
1637            offset: usize,
1638            _depth: fidl::encoding::Depth,
1639        ) -> fidl::Result<()> {
1640            encoder.debug_check_bounds::<Self>(offset);
1641            encoder.write_num(self.into_primitive(), offset);
1642            Ok(())
1643        }
1644    }
1645
1646    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1647        for UnregisterDependencyTokenError
1648    {
1649        #[inline(always)]
1650        fn new_empty() -> Self {
1651            Self::unknown()
1652        }
1653
1654        #[inline]
1655        unsafe fn decode(
1656            &mut self,
1657            decoder: &mut fidl::encoding::Decoder<'_, D>,
1658            offset: usize,
1659            _depth: fidl::encoding::Depth,
1660        ) -> fidl::Result<()> {
1661            decoder.debug_check_bounds::<Self>(offset);
1662            let prim = decoder.read_num::<u32>(offset);
1663
1664            *self = Self::from_primitive_allow_unknown(prim);
1665            Ok(())
1666        }
1667    }
1668
1669    impl fidl::encoding::ValueTypeMarker for ElementRunnerSetLevelRequest {
1670        type Borrowed<'a> = &'a Self;
1671        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1672            value
1673        }
1674    }
1675
1676    unsafe impl fidl::encoding::TypeMarker for ElementRunnerSetLevelRequest {
1677        type Owned = Self;
1678
1679        #[inline(always)]
1680        fn inline_align(_context: fidl::encoding::Context) -> usize {
1681            1
1682        }
1683
1684        #[inline(always)]
1685        fn inline_size(_context: fidl::encoding::Context) -> usize {
1686            1
1687        }
1688        #[inline(always)]
1689        fn encode_is_copy() -> bool {
1690            true
1691        }
1692
1693        #[inline(always)]
1694        fn decode_is_copy() -> bool {
1695            true
1696        }
1697    }
1698
1699    unsafe impl<D: fidl::encoding::ResourceDialect>
1700        fidl::encoding::Encode<ElementRunnerSetLevelRequest, D> for &ElementRunnerSetLevelRequest
1701    {
1702        #[inline]
1703        unsafe fn encode(
1704            self,
1705            encoder: &mut fidl::encoding::Encoder<'_, D>,
1706            offset: usize,
1707            _depth: fidl::encoding::Depth,
1708        ) -> fidl::Result<()> {
1709            encoder.debug_check_bounds::<ElementRunnerSetLevelRequest>(offset);
1710            unsafe {
1711                // Copy the object into the buffer.
1712                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1713                (buf_ptr as *mut ElementRunnerSetLevelRequest)
1714                    .write_unaligned((self as *const ElementRunnerSetLevelRequest).read());
1715                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1716                // done second because the memcpy will write garbage to these bytes.
1717            }
1718            Ok(())
1719        }
1720    }
1721    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
1722        fidl::encoding::Encode<ElementRunnerSetLevelRequest, D> for (T0,)
1723    {
1724        #[inline]
1725        unsafe fn encode(
1726            self,
1727            encoder: &mut fidl::encoding::Encoder<'_, D>,
1728            offset: usize,
1729            depth: fidl::encoding::Depth,
1730        ) -> fidl::Result<()> {
1731            encoder.debug_check_bounds::<ElementRunnerSetLevelRequest>(offset);
1732            // Zero out padding regions. There's no need to apply masks
1733            // because the unmasked parts will be overwritten by fields.
1734            // Write the fields.
1735            self.0.encode(encoder, offset + 0, depth)?;
1736            Ok(())
1737        }
1738    }
1739
1740    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1741        for ElementRunnerSetLevelRequest
1742    {
1743        #[inline(always)]
1744        fn new_empty() -> Self {
1745            Self { level: fidl::new_empty!(u8, D) }
1746        }
1747
1748        #[inline]
1749        unsafe fn decode(
1750            &mut self,
1751            decoder: &mut fidl::encoding::Decoder<'_, D>,
1752            offset: usize,
1753            _depth: fidl::encoding::Depth,
1754        ) -> fidl::Result<()> {
1755            decoder.debug_check_bounds::<Self>(offset);
1756            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1757            // Verify that padding bytes are zero.
1758            // Copy from the buffer into the object.
1759            unsafe {
1760                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
1761            }
1762            Ok(())
1763        }
1764    }
1765
1766    impl fidl::encoding::ValueTypeMarker for LeaseControlWatchStatusRequest {
1767        type Borrowed<'a> = &'a Self;
1768        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1769            value
1770        }
1771    }
1772
1773    unsafe impl fidl::encoding::TypeMarker for LeaseControlWatchStatusRequest {
1774        type Owned = Self;
1775
1776        #[inline(always)]
1777        fn inline_align(_context: fidl::encoding::Context) -> usize {
1778            4
1779        }
1780
1781        #[inline(always)]
1782        fn inline_size(_context: fidl::encoding::Context) -> usize {
1783            4
1784        }
1785    }
1786
1787    unsafe impl<D: fidl::encoding::ResourceDialect>
1788        fidl::encoding::Encode<LeaseControlWatchStatusRequest, D>
1789        for &LeaseControlWatchStatusRequest
1790    {
1791        #[inline]
1792        unsafe fn encode(
1793            self,
1794            encoder: &mut fidl::encoding::Encoder<'_, D>,
1795            offset: usize,
1796            _depth: fidl::encoding::Depth,
1797        ) -> fidl::Result<()> {
1798            encoder.debug_check_bounds::<LeaseControlWatchStatusRequest>(offset);
1799            // Delegate to tuple encoding.
1800            fidl::encoding::Encode::<LeaseControlWatchStatusRequest, D>::encode(
1801                (<LeaseStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.last_status),),
1802                encoder,
1803                offset,
1804                _depth,
1805            )
1806        }
1807    }
1808    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<LeaseStatus, D>>
1809        fidl::encoding::Encode<LeaseControlWatchStatusRequest, D> for (T0,)
1810    {
1811        #[inline]
1812        unsafe fn encode(
1813            self,
1814            encoder: &mut fidl::encoding::Encoder<'_, D>,
1815            offset: usize,
1816            depth: fidl::encoding::Depth,
1817        ) -> fidl::Result<()> {
1818            encoder.debug_check_bounds::<LeaseControlWatchStatusRequest>(offset);
1819            // Zero out padding regions. There's no need to apply masks
1820            // because the unmasked parts will be overwritten by fields.
1821            // Write the fields.
1822            self.0.encode(encoder, offset + 0, depth)?;
1823            Ok(())
1824        }
1825    }
1826
1827    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1828        for LeaseControlWatchStatusRequest
1829    {
1830        #[inline(always)]
1831        fn new_empty() -> Self {
1832            Self { last_status: fidl::new_empty!(LeaseStatus, D) }
1833        }
1834
1835        #[inline]
1836        unsafe fn decode(
1837            &mut self,
1838            decoder: &mut fidl::encoding::Decoder<'_, D>,
1839            offset: usize,
1840            _depth: fidl::encoding::Depth,
1841        ) -> fidl::Result<()> {
1842            decoder.debug_check_bounds::<Self>(offset);
1843            // Verify that padding bytes are zero.
1844            fidl::decode!(LeaseStatus, D, &mut self.last_status, decoder, offset + 0, _depth)?;
1845            Ok(())
1846        }
1847    }
1848
1849    impl fidl::encoding::ValueTypeMarker for LeaseControlWatchStatusResponse {
1850        type Borrowed<'a> = &'a Self;
1851        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1852            value
1853        }
1854    }
1855
1856    unsafe impl fidl::encoding::TypeMarker for LeaseControlWatchStatusResponse {
1857        type Owned = Self;
1858
1859        #[inline(always)]
1860        fn inline_align(_context: fidl::encoding::Context) -> usize {
1861            4
1862        }
1863
1864        #[inline(always)]
1865        fn inline_size(_context: fidl::encoding::Context) -> usize {
1866            4
1867        }
1868    }
1869
1870    unsafe impl<D: fidl::encoding::ResourceDialect>
1871        fidl::encoding::Encode<LeaseControlWatchStatusResponse, D>
1872        for &LeaseControlWatchStatusResponse
1873    {
1874        #[inline]
1875        unsafe fn encode(
1876            self,
1877            encoder: &mut fidl::encoding::Encoder<'_, D>,
1878            offset: usize,
1879            _depth: fidl::encoding::Depth,
1880        ) -> fidl::Result<()> {
1881            encoder.debug_check_bounds::<LeaseControlWatchStatusResponse>(offset);
1882            // Delegate to tuple encoding.
1883            fidl::encoding::Encode::<LeaseControlWatchStatusResponse, D>::encode(
1884                (<LeaseStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1885                encoder,
1886                offset,
1887                _depth,
1888            )
1889        }
1890    }
1891    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<LeaseStatus, D>>
1892        fidl::encoding::Encode<LeaseControlWatchStatusResponse, D> for (T0,)
1893    {
1894        #[inline]
1895        unsafe fn encode(
1896            self,
1897            encoder: &mut fidl::encoding::Encoder<'_, D>,
1898            offset: usize,
1899            depth: fidl::encoding::Depth,
1900        ) -> fidl::Result<()> {
1901            encoder.debug_check_bounds::<LeaseControlWatchStatusResponse>(offset);
1902            // Zero out padding regions. There's no need to apply masks
1903            // because the unmasked parts will be overwritten by fields.
1904            // Write the fields.
1905            self.0.encode(encoder, offset + 0, depth)?;
1906            Ok(())
1907        }
1908    }
1909
1910    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1911        for LeaseControlWatchStatusResponse
1912    {
1913        #[inline(always)]
1914        fn new_empty() -> Self {
1915            Self { status: fidl::new_empty!(LeaseStatus, D) }
1916        }
1917
1918        #[inline]
1919        unsafe fn decode(
1920            &mut self,
1921            decoder: &mut fidl::encoding::Decoder<'_, D>,
1922            offset: usize,
1923            _depth: fidl::encoding::Depth,
1924        ) -> fidl::Result<()> {
1925            decoder.debug_check_bounds::<Self>(offset);
1926            // Verify that padding bytes are zero.
1927            fidl::decode!(LeaseStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1928            Ok(())
1929        }
1930    }
1931
1932    impl ElementPowerLevelNames {
1933        #[inline(always)]
1934        fn max_ordinal_present(&self) -> u64 {
1935            if let Some(_) = self.levels {
1936                return 2;
1937            }
1938            if let Some(_) = self.identifier {
1939                return 1;
1940            }
1941            0
1942        }
1943    }
1944
1945    impl fidl::encoding::ValueTypeMarker for ElementPowerLevelNames {
1946        type Borrowed<'a> = &'a Self;
1947        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1948            value
1949        }
1950    }
1951
1952    unsafe impl fidl::encoding::TypeMarker for ElementPowerLevelNames {
1953        type Owned = Self;
1954
1955        #[inline(always)]
1956        fn inline_align(_context: fidl::encoding::Context) -> usize {
1957            8
1958        }
1959
1960        #[inline(always)]
1961        fn inline_size(_context: fidl::encoding::Context) -> usize {
1962            16
1963        }
1964    }
1965
1966    unsafe impl<D: fidl::encoding::ResourceDialect>
1967        fidl::encoding::Encode<ElementPowerLevelNames, D> for &ElementPowerLevelNames
1968    {
1969        unsafe fn encode(
1970            self,
1971            encoder: &mut fidl::encoding::Encoder<'_, D>,
1972            offset: usize,
1973            mut depth: fidl::encoding::Depth,
1974        ) -> fidl::Result<()> {
1975            encoder.debug_check_bounds::<ElementPowerLevelNames>(offset);
1976            // Vector header
1977            let max_ordinal: u64 = self.max_ordinal_present();
1978            encoder.write_num(max_ordinal, offset);
1979            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1980            // Calling encoder.out_of_line_offset(0) is not allowed.
1981            if max_ordinal == 0 {
1982                return Ok(());
1983            }
1984            depth.increment()?;
1985            let envelope_size = 8;
1986            let bytes_len = max_ordinal as usize * envelope_size;
1987            #[allow(unused_variables)]
1988            let offset = encoder.out_of_line_offset(bytes_len);
1989            let mut _prev_end_offset: usize = 0;
1990            if 1 > max_ordinal {
1991                return Ok(());
1992            }
1993
1994            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1995            // are envelope_size bytes.
1996            let cur_offset: usize = (1 - 1) * envelope_size;
1997
1998            // Zero reserved fields.
1999            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2000
2001            // Safety:
2002            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2003            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2004            //   envelope_size bytes, there is always sufficient room.
2005            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<64>, D>(
2006                self.identifier.as_ref().map(
2007                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
2008                ),
2009                encoder,
2010                offset + cur_offset,
2011                depth,
2012            )?;
2013
2014            _prev_end_offset = cur_offset + envelope_size;
2015            if 2 > max_ordinal {
2016                return Ok(());
2017            }
2018
2019            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2020            // are envelope_size bytes.
2021            let cur_offset: usize = (2 - 1) * envelope_size;
2022
2023            // Zero reserved fields.
2024            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2025
2026            // Safety:
2027            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2028            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2029            //   envelope_size bytes, there is always sufficient room.
2030            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<PowerLevelName, 256>, D>(
2031            self.levels.as_ref().map(<fidl::encoding::Vector<PowerLevelName, 256> as fidl::encoding::ValueTypeMarker>::borrow),
2032            encoder, offset + cur_offset, depth
2033        )?;
2034
2035            _prev_end_offset = cur_offset + envelope_size;
2036
2037            Ok(())
2038        }
2039    }
2040
2041    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2042        for ElementPowerLevelNames
2043    {
2044        #[inline(always)]
2045        fn new_empty() -> Self {
2046            Self::default()
2047        }
2048
2049        unsafe fn decode(
2050            &mut self,
2051            decoder: &mut fidl::encoding::Decoder<'_, D>,
2052            offset: usize,
2053            mut depth: fidl::encoding::Depth,
2054        ) -> fidl::Result<()> {
2055            decoder.debug_check_bounds::<Self>(offset);
2056            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2057                None => return Err(fidl::Error::NotNullable),
2058                Some(len) => len,
2059            };
2060            // Calling decoder.out_of_line_offset(0) is not allowed.
2061            if len == 0 {
2062                return Ok(());
2063            };
2064            depth.increment()?;
2065            let envelope_size = 8;
2066            let bytes_len = len * envelope_size;
2067            let offset = decoder.out_of_line_offset(bytes_len)?;
2068            // Decode the envelope for each type.
2069            let mut _next_ordinal_to_read = 0;
2070            let mut next_offset = offset;
2071            let end_offset = offset + bytes_len;
2072            _next_ordinal_to_read += 1;
2073            if next_offset >= end_offset {
2074                return Ok(());
2075            }
2076
2077            // Decode unknown envelopes for gaps in ordinals.
2078            while _next_ordinal_to_read < 1 {
2079                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2080                _next_ordinal_to_read += 1;
2081                next_offset += envelope_size;
2082            }
2083
2084            let next_out_of_line = decoder.next_out_of_line();
2085            let handles_before = decoder.remaining_handles();
2086            if let Some((inlined, num_bytes, num_handles)) =
2087                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2088            {
2089                let member_inline_size =
2090                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
2091                        decoder.context,
2092                    );
2093                if inlined != (member_inline_size <= 4) {
2094                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2095                }
2096                let inner_offset;
2097                let mut inner_depth = depth.clone();
2098                if inlined {
2099                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2100                    inner_offset = next_offset;
2101                } else {
2102                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2103                    inner_depth.increment()?;
2104                }
2105                let val_ref = self
2106                    .identifier
2107                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<64>, D));
2108                fidl::decode!(
2109                    fidl::encoding::BoundedString<64>,
2110                    D,
2111                    val_ref,
2112                    decoder,
2113                    inner_offset,
2114                    inner_depth
2115                )?;
2116                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2117                {
2118                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2119                }
2120                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2121                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2122                }
2123            }
2124
2125            next_offset += envelope_size;
2126            _next_ordinal_to_read += 1;
2127            if next_offset >= end_offset {
2128                return Ok(());
2129            }
2130
2131            // Decode unknown envelopes for gaps in ordinals.
2132            while _next_ordinal_to_read < 2 {
2133                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2134                _next_ordinal_to_read += 1;
2135                next_offset += envelope_size;
2136            }
2137
2138            let next_out_of_line = decoder.next_out_of_line();
2139            let handles_before = decoder.remaining_handles();
2140            if let Some((inlined, num_bytes, num_handles)) =
2141                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2142            {
2143                let member_inline_size = <fidl::encoding::Vector<PowerLevelName, 256> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2144                if inlined != (member_inline_size <= 4) {
2145                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2146                }
2147                let inner_offset;
2148                let mut inner_depth = depth.clone();
2149                if inlined {
2150                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2151                    inner_offset = next_offset;
2152                } else {
2153                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2154                    inner_depth.increment()?;
2155                }
2156                let val_ref = self.levels.get_or_insert_with(
2157                    || fidl::new_empty!(fidl::encoding::Vector<PowerLevelName, 256>, D),
2158                );
2159                fidl::decode!(fidl::encoding::Vector<PowerLevelName, 256>, D, val_ref, decoder, inner_offset, inner_depth)?;
2160                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2161                {
2162                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2163                }
2164                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2165                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2166                }
2167            }
2168
2169            next_offset += envelope_size;
2170
2171            // Decode the remaining unknown envelopes.
2172            while next_offset < end_offset {
2173                _next_ordinal_to_read += 1;
2174                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2175                next_offset += envelope_size;
2176            }
2177
2178            Ok(())
2179        }
2180    }
2181
2182    impl PowerLevelName {
2183        #[inline(always)]
2184        fn max_ordinal_present(&self) -> u64 {
2185            if let Some(_) = self.name {
2186                return 2;
2187            }
2188            if let Some(_) = self.level {
2189                return 1;
2190            }
2191            0
2192        }
2193    }
2194
2195    impl fidl::encoding::ValueTypeMarker for PowerLevelName {
2196        type Borrowed<'a> = &'a Self;
2197        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2198            value
2199        }
2200    }
2201
2202    unsafe impl fidl::encoding::TypeMarker for PowerLevelName {
2203        type Owned = Self;
2204
2205        #[inline(always)]
2206        fn inline_align(_context: fidl::encoding::Context) -> usize {
2207            8
2208        }
2209
2210        #[inline(always)]
2211        fn inline_size(_context: fidl::encoding::Context) -> usize {
2212            16
2213        }
2214    }
2215
2216    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PowerLevelName, D>
2217        for &PowerLevelName
2218    {
2219        unsafe fn encode(
2220            self,
2221            encoder: &mut fidl::encoding::Encoder<'_, D>,
2222            offset: usize,
2223            mut depth: fidl::encoding::Depth,
2224        ) -> fidl::Result<()> {
2225            encoder.debug_check_bounds::<PowerLevelName>(offset);
2226            // Vector header
2227            let max_ordinal: u64 = self.max_ordinal_present();
2228            encoder.write_num(max_ordinal, offset);
2229            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2230            // Calling encoder.out_of_line_offset(0) is not allowed.
2231            if max_ordinal == 0 {
2232                return Ok(());
2233            }
2234            depth.increment()?;
2235            let envelope_size = 8;
2236            let bytes_len = max_ordinal as usize * envelope_size;
2237            #[allow(unused_variables)]
2238            let offset = encoder.out_of_line_offset(bytes_len);
2239            let mut _prev_end_offset: usize = 0;
2240            if 1 > max_ordinal {
2241                return Ok(());
2242            }
2243
2244            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2245            // are envelope_size bytes.
2246            let cur_offset: usize = (1 - 1) * envelope_size;
2247
2248            // Zero reserved fields.
2249            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2250
2251            // Safety:
2252            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2253            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2254            //   envelope_size bytes, there is always sufficient room.
2255            fidl::encoding::encode_in_envelope_optional::<u8, D>(
2256                self.level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
2257                encoder,
2258                offset + cur_offset,
2259                depth,
2260            )?;
2261
2262            _prev_end_offset = cur_offset + envelope_size;
2263            if 2 > max_ordinal {
2264                return Ok(());
2265            }
2266
2267            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2268            // are envelope_size bytes.
2269            let cur_offset: usize = (2 - 1) * envelope_size;
2270
2271            // Zero reserved fields.
2272            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2273
2274            // Safety:
2275            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2276            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2277            //   envelope_size bytes, there is always sufficient room.
2278            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<16>, D>(
2279                self.name.as_ref().map(
2280                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow,
2281                ),
2282                encoder,
2283                offset + cur_offset,
2284                depth,
2285            )?;
2286
2287            _prev_end_offset = cur_offset + envelope_size;
2288
2289            Ok(())
2290        }
2291    }
2292
2293    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PowerLevelName {
2294        #[inline(always)]
2295        fn new_empty() -> Self {
2296            Self::default()
2297        }
2298
2299        unsafe fn decode(
2300            &mut self,
2301            decoder: &mut fidl::encoding::Decoder<'_, D>,
2302            offset: usize,
2303            mut depth: fidl::encoding::Depth,
2304        ) -> fidl::Result<()> {
2305            decoder.debug_check_bounds::<Self>(offset);
2306            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2307                None => return Err(fidl::Error::NotNullable),
2308                Some(len) => len,
2309            };
2310            // Calling decoder.out_of_line_offset(0) is not allowed.
2311            if len == 0 {
2312                return Ok(());
2313            };
2314            depth.increment()?;
2315            let envelope_size = 8;
2316            let bytes_len = len * envelope_size;
2317            let offset = decoder.out_of_line_offset(bytes_len)?;
2318            // Decode the envelope for each type.
2319            let mut _next_ordinal_to_read = 0;
2320            let mut next_offset = offset;
2321            let end_offset = offset + bytes_len;
2322            _next_ordinal_to_read += 1;
2323            if next_offset >= end_offset {
2324                return Ok(());
2325            }
2326
2327            // Decode unknown envelopes for gaps in ordinals.
2328            while _next_ordinal_to_read < 1 {
2329                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2330                _next_ordinal_to_read += 1;
2331                next_offset += envelope_size;
2332            }
2333
2334            let next_out_of_line = decoder.next_out_of_line();
2335            let handles_before = decoder.remaining_handles();
2336            if let Some((inlined, num_bytes, num_handles)) =
2337                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2338            {
2339                let member_inline_size =
2340                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2341                if inlined != (member_inline_size <= 4) {
2342                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2343                }
2344                let inner_offset;
2345                let mut inner_depth = depth.clone();
2346                if inlined {
2347                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2348                    inner_offset = next_offset;
2349                } else {
2350                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2351                    inner_depth.increment()?;
2352                }
2353                let val_ref = self.level.get_or_insert_with(|| fidl::new_empty!(u8, D));
2354                fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
2355                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2356                {
2357                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2358                }
2359                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2360                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2361                }
2362            }
2363
2364            next_offset += envelope_size;
2365            _next_ordinal_to_read += 1;
2366            if next_offset >= end_offset {
2367                return Ok(());
2368            }
2369
2370            // Decode unknown envelopes for gaps in ordinals.
2371            while _next_ordinal_to_read < 2 {
2372                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2373                _next_ordinal_to_read += 1;
2374                next_offset += envelope_size;
2375            }
2376
2377            let next_out_of_line = decoder.next_out_of_line();
2378            let handles_before = decoder.remaining_handles();
2379            if let Some((inlined, num_bytes, num_handles)) =
2380                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2381            {
2382                let member_inline_size =
2383                    <fidl::encoding::BoundedString<16> as fidl::encoding::TypeMarker>::inline_size(
2384                        decoder.context,
2385                    );
2386                if inlined != (member_inline_size <= 4) {
2387                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2388                }
2389                let inner_offset;
2390                let mut inner_depth = depth.clone();
2391                if inlined {
2392                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2393                    inner_offset = next_offset;
2394                } else {
2395                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2396                    inner_depth.increment()?;
2397                }
2398                let val_ref = self
2399                    .name
2400                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<16>, D));
2401                fidl::decode!(
2402                    fidl::encoding::BoundedString<16>,
2403                    D,
2404                    val_ref,
2405                    decoder,
2406                    inner_offset,
2407                    inner_depth
2408                )?;
2409                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2410                {
2411                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2412                }
2413                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2414                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2415                }
2416            }
2417
2418            next_offset += envelope_size;
2419
2420            // Decode the remaining unknown envelopes.
2421            while next_offset < end_offset {
2422                _next_ordinal_to_read += 1;
2423                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2424                next_offset += envelope_size;
2425            }
2426
2427            Ok(())
2428        }
2429    }
2430}