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