Skip to main content

fidl_fuchsia_power_topology_test_common/
fidl_fuchsia_power_topology_test_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
11pub type ElementName = String;
12
13pub type PowerLevel = u8;
14
15pub const MAX_DEPENDENCIES: u16 = MAX_VALID_POWER_LEVELS as u16;
16
17pub const MAX_ELEMENTS: u16 = 256;
18
19pub const MAX_ELEMENT_NAME_LEN: u16 = fidl_fuchsia_power_broker_common::MAX_ELEMENT_NAME_LEN as u16;
20
21pub const MAX_VALID_POWER_LEVELS: u16 =
22    fidl_fuchsia_power_broker_common::MAX_VALID_POWER_LEVELS as u16;
23
24/// Errors associated with TopologyControl.Create method.
25#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
26#[repr(u32)]
27pub enum CreateTopologyGraphError {
28    /// Indicates that the request failed due to an internal error.
29    Internal = 1,
30    /// Indicates that the element topology provided in Create command is
31    /// invalid.
32    InvalidTopology = 2,
33}
34
35impl CreateTopologyGraphError {
36    #[inline]
37    pub fn from_primitive(prim: u32) -> Option<Self> {
38        match prim {
39            1 => Some(Self::Internal),
40            2 => Some(Self::InvalidTopology),
41            _ => None,
42        }
43    }
44
45    #[inline]
46    pub const fn into_primitive(self) -> u32 {
47        self as u32
48    }
49}
50
51/// Errors associated with TopologyControl.AcquireLease and
52/// TopologyControl.DropLease methods.
53#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
54#[repr(u32)]
55pub enum LeaseControlError {
56    /// Indicates that the request failed due to an internal error.
57    Internal = 1,
58    /// Indicates that an invalid power element name was provided in
59    /// AcquireLease or DropLease.
60    InvalidElement = 2,
61}
62
63impl LeaseControlError {
64    #[inline]
65    pub fn from_primitive(prim: u32) -> Option<Self> {
66        match prim {
67            1 => Some(Self::Internal),
68            2 => Some(Self::InvalidElement),
69            _ => None,
70        }
71    }
72
73    #[inline]
74    pub const fn into_primitive(self) -> u32 {
75        self as u32
76    }
77}
78
79/// Errors associated with TopologyControl.OpenStatusChannel method.
80#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
81#[repr(u32)]
82pub enum OpenStatusChannelError {
83    /// Indicates that the request failed due to an internal error.
84    Internal = 1,
85    /// Indicates that an invalid power element name was provided in
86    /// OpenStatusChannel
87    InvalidElement = 2,
88}
89
90impl OpenStatusChannelError {
91    #[inline]
92    pub fn from_primitive(prim: u32) -> Option<Self> {
93        match prim {
94            1 => Some(Self::Internal),
95            2 => Some(Self::InvalidElement),
96            _ => None,
97        }
98    }
99
100    #[inline]
101    pub const fn into_primitive(self) -> u32 {
102        self as u32
103    }
104}
105
106/// Errors associated with SystemActivityControl methods.
107#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
108#[repr(u32)]
109pub enum SystemActivityControlError {
110    /// Indicates that the request failed due to an internal error.
111    Internal = 1,
112}
113
114impl SystemActivityControlError {
115    #[inline]
116    pub fn from_primitive(prim: u32) -> Option<Self> {
117        match prim {
118            1 => Some(Self::Internal),
119            _ => None,
120        }
121    }
122
123    #[inline]
124    pub const fn into_primitive(self) -> u32 {
125        self as u32
126    }
127}
128
129/// Passed to TopologyControl.Create to construct power topology.
130#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct Element {
132    pub element_name: String,
133    pub initial_current_level: u8,
134    pub valid_levels: Vec<u8>,
135    pub dependencies: Vec<LevelDependency>,
136}
137
138impl fidl::Persistable for Element {}
139
140/// Power Dependency information in Element. Used by a client to construct power topology.
141#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
142pub struct LevelDependency {
143    pub dependent_level: u8,
144    pub requires_element: String,
145    pub requires_level: u8,
146}
147
148impl fidl::Persistable for LevelDependency {}
149
150#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
151#[repr(C)]
152pub struct SystemActivityControlRestartApplicationActivityRequest {
153    /// The time to wait after dropping the lease but before reclaiming it.
154    pub wait_time_ns: u64,
155}
156
157impl fidl::Persistable for SystemActivityControlRestartApplicationActivityRequest {}
158
159#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
160pub struct TopologyControlAcquireLeaseRequest {
161    pub element_name: String,
162    /// Power level of this element to be raised to.
163    pub level: u8,
164    /// Returns immediately if this is set to Unknown.
165    /// Otherwise, waits for the lease to reach this status before returning.
166    pub wait_for_status: fidl_fuchsia_power_broker_common::LeaseStatus,
167}
168
169impl fidl::Persistable for TopologyControlAcquireLeaseRequest {}
170
171#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
172pub struct TopologyControlCreateRequest {
173    /// List of elements to create.
174    pub elements: Vec<Element>,
175}
176
177impl fidl::Persistable for TopologyControlCreateRequest {}
178
179#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
180pub struct TopologyControlDropLeaseRequest {
181    pub element_name: String,
182}
183
184impl fidl::Persistable for TopologyControlDropLeaseRequest {}
185
186pub mod system_activity_control_ordinals {
187    pub const START_APPLICATION_ACTIVITY: u64 = 0x61de6f5d5285a4e3;
188    pub const STOP_APPLICATION_ACTIVITY: u64 = 0x294ea5c8d0e2e0c0;
189    pub const RESTART_APPLICATION_ACTIVITY: u64 = 0x2881d47bba86f3d4;
190}
191
192pub mod topology_control_ordinals {
193    pub const CREATE: u64 = 0x12033976b88716fa;
194    pub const ACQUIRE_LEASE: u64 = 0x1bedc35d9b68bac8;
195    pub const DROP_LEASE: u64 = 0x7107f8f1080faddc;
196    pub const OPEN_STATUS_CHANNEL: u64 = 0x69fba616c3ee2e90;
197}
198
199mod internal {
200    use super::*;
201    unsafe impl fidl::encoding::TypeMarker for CreateTopologyGraphError {
202        type Owned = Self;
203
204        #[inline(always)]
205        fn inline_align(_context: fidl::encoding::Context) -> usize {
206            std::mem::align_of::<u32>()
207        }
208
209        #[inline(always)]
210        fn inline_size(_context: fidl::encoding::Context) -> usize {
211            std::mem::size_of::<u32>()
212        }
213
214        #[inline(always)]
215        fn encode_is_copy() -> bool {
216            true
217        }
218
219        #[inline(always)]
220        fn decode_is_copy() -> bool {
221            false
222        }
223    }
224
225    impl fidl::encoding::ValueTypeMarker for CreateTopologyGraphError {
226        type Borrowed<'a> = Self;
227        #[inline(always)]
228        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
229            *value
230        }
231    }
232
233    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
234        for CreateTopologyGraphError
235    {
236        #[inline]
237        unsafe fn encode(
238            self,
239            encoder: &mut fidl::encoding::Encoder<'_, D>,
240            offset: usize,
241            _depth: fidl::encoding::Depth,
242        ) -> fidl::Result<()> {
243            encoder.debug_check_bounds::<Self>(offset);
244            encoder.write_num(self.into_primitive(), offset);
245            Ok(())
246        }
247    }
248
249    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
250        for CreateTopologyGraphError
251    {
252        #[inline(always)]
253        fn new_empty() -> Self {
254            Self::Internal
255        }
256
257        #[inline]
258        unsafe fn decode(
259            &mut self,
260            decoder: &mut fidl::encoding::Decoder<'_, D>,
261            offset: usize,
262            _depth: fidl::encoding::Depth,
263        ) -> fidl::Result<()> {
264            decoder.debug_check_bounds::<Self>(offset);
265            let prim = decoder.read_num::<u32>(offset);
266
267            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
268            Ok(())
269        }
270    }
271    unsafe impl fidl::encoding::TypeMarker for LeaseControlError {
272        type Owned = Self;
273
274        #[inline(always)]
275        fn inline_align(_context: fidl::encoding::Context) -> usize {
276            std::mem::align_of::<u32>()
277        }
278
279        #[inline(always)]
280        fn inline_size(_context: fidl::encoding::Context) -> usize {
281            std::mem::size_of::<u32>()
282        }
283
284        #[inline(always)]
285        fn encode_is_copy() -> bool {
286            true
287        }
288
289        #[inline(always)]
290        fn decode_is_copy() -> bool {
291            false
292        }
293    }
294
295    impl fidl::encoding::ValueTypeMarker for LeaseControlError {
296        type Borrowed<'a> = Self;
297        #[inline(always)]
298        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
299            *value
300        }
301    }
302
303    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
304        for LeaseControlError
305    {
306        #[inline]
307        unsafe fn encode(
308            self,
309            encoder: &mut fidl::encoding::Encoder<'_, D>,
310            offset: usize,
311            _depth: fidl::encoding::Depth,
312        ) -> fidl::Result<()> {
313            encoder.debug_check_bounds::<Self>(offset);
314            encoder.write_num(self.into_primitive(), offset);
315            Ok(())
316        }
317    }
318
319    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LeaseControlError {
320        #[inline(always)]
321        fn new_empty() -> Self {
322            Self::Internal
323        }
324
325        #[inline]
326        unsafe fn decode(
327            &mut self,
328            decoder: &mut fidl::encoding::Decoder<'_, D>,
329            offset: usize,
330            _depth: fidl::encoding::Depth,
331        ) -> fidl::Result<()> {
332            decoder.debug_check_bounds::<Self>(offset);
333            let prim = decoder.read_num::<u32>(offset);
334
335            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
336            Ok(())
337        }
338    }
339    unsafe impl fidl::encoding::TypeMarker for OpenStatusChannelError {
340        type Owned = Self;
341
342        #[inline(always)]
343        fn inline_align(_context: fidl::encoding::Context) -> usize {
344            std::mem::align_of::<u32>()
345        }
346
347        #[inline(always)]
348        fn inline_size(_context: fidl::encoding::Context) -> usize {
349            std::mem::size_of::<u32>()
350        }
351
352        #[inline(always)]
353        fn encode_is_copy() -> bool {
354            true
355        }
356
357        #[inline(always)]
358        fn decode_is_copy() -> bool {
359            false
360        }
361    }
362
363    impl fidl::encoding::ValueTypeMarker for OpenStatusChannelError {
364        type Borrowed<'a> = Self;
365        #[inline(always)]
366        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
367            *value
368        }
369    }
370
371    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
372        for OpenStatusChannelError
373    {
374        #[inline]
375        unsafe fn encode(
376            self,
377            encoder: &mut fidl::encoding::Encoder<'_, D>,
378            offset: usize,
379            _depth: fidl::encoding::Depth,
380        ) -> fidl::Result<()> {
381            encoder.debug_check_bounds::<Self>(offset);
382            encoder.write_num(self.into_primitive(), offset);
383            Ok(())
384        }
385    }
386
387    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
388        for OpenStatusChannelError
389    {
390        #[inline(always)]
391        fn new_empty() -> Self {
392            Self::Internal
393        }
394
395        #[inline]
396        unsafe fn decode(
397            &mut self,
398            decoder: &mut fidl::encoding::Decoder<'_, D>,
399            offset: usize,
400            _depth: fidl::encoding::Depth,
401        ) -> fidl::Result<()> {
402            decoder.debug_check_bounds::<Self>(offset);
403            let prim = decoder.read_num::<u32>(offset);
404
405            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
406            Ok(())
407        }
408    }
409    unsafe impl fidl::encoding::TypeMarker for SystemActivityControlError {
410        type Owned = Self;
411
412        #[inline(always)]
413        fn inline_align(_context: fidl::encoding::Context) -> usize {
414            std::mem::align_of::<u32>()
415        }
416
417        #[inline(always)]
418        fn inline_size(_context: fidl::encoding::Context) -> usize {
419            std::mem::size_of::<u32>()
420        }
421
422        #[inline(always)]
423        fn encode_is_copy() -> bool {
424            true
425        }
426
427        #[inline(always)]
428        fn decode_is_copy() -> bool {
429            false
430        }
431    }
432
433    impl fidl::encoding::ValueTypeMarker for SystemActivityControlError {
434        type Borrowed<'a> = Self;
435        #[inline(always)]
436        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
437            *value
438        }
439    }
440
441    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
442        for SystemActivityControlError
443    {
444        #[inline]
445        unsafe fn encode(
446            self,
447            encoder: &mut fidl::encoding::Encoder<'_, D>,
448            offset: usize,
449            _depth: fidl::encoding::Depth,
450        ) -> fidl::Result<()> {
451            encoder.debug_check_bounds::<Self>(offset);
452            encoder.write_num(self.into_primitive(), offset);
453            Ok(())
454        }
455    }
456
457    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
458        for SystemActivityControlError
459    {
460        #[inline(always)]
461        fn new_empty() -> Self {
462            Self::Internal
463        }
464
465        #[inline]
466        unsafe fn decode(
467            &mut self,
468            decoder: &mut fidl::encoding::Decoder<'_, D>,
469            offset: usize,
470            _depth: fidl::encoding::Depth,
471        ) -> fidl::Result<()> {
472            decoder.debug_check_bounds::<Self>(offset);
473            let prim = decoder.read_num::<u32>(offset);
474
475            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
476            Ok(())
477        }
478    }
479
480    impl fidl::encoding::ValueTypeMarker for Element {
481        type Borrowed<'a> = &'a Self;
482        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
483            value
484        }
485    }
486
487    unsafe impl fidl::encoding::TypeMarker for Element {
488        type Owned = Self;
489
490        #[inline(always)]
491        fn inline_align(_context: fidl::encoding::Context) -> usize {
492            8
493        }
494
495        #[inline(always)]
496        fn inline_size(_context: fidl::encoding::Context) -> usize {
497            56
498        }
499    }
500
501    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Element, D> for &Element {
502        #[inline]
503        unsafe fn encode(
504            self,
505            encoder: &mut fidl::encoding::Encoder<'_, D>,
506            offset: usize,
507            _depth: fidl::encoding::Depth,
508        ) -> fidl::Result<()> {
509            encoder.debug_check_bounds::<Element>(offset);
510            // Delegate to tuple encoding.
511            fidl::encoding::Encode::<Element, D>::encode(
512                (
513                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(&self.element_name),
514                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.initial_current_level),
515                    <fidl::encoding::Vector<u8, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.valid_levels),
516                    <fidl::encoding::Vector<LevelDependency, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.dependencies),
517                ),
518                encoder, offset, _depth
519            )
520        }
521    }
522    unsafe impl<
523        D: fidl::encoding::ResourceDialect,
524        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
525        T1: fidl::encoding::Encode<u8, D>,
526        T2: fidl::encoding::Encode<fidl::encoding::Vector<u8, 256>, D>,
527        T3: fidl::encoding::Encode<fidl::encoding::Vector<LevelDependency, 256>, D>,
528    > fidl::encoding::Encode<Element, D> for (T0, T1, T2, T3)
529    {
530        #[inline]
531        unsafe fn encode(
532            self,
533            encoder: &mut fidl::encoding::Encoder<'_, D>,
534            offset: usize,
535            depth: fidl::encoding::Depth,
536        ) -> fidl::Result<()> {
537            encoder.debug_check_bounds::<Element>(offset);
538            // Zero out padding regions. There's no need to apply masks
539            // because the unmasked parts will be overwritten by fields.
540            unsafe {
541                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
542                (ptr as *mut u64).write_unaligned(0);
543            }
544            // Write the fields.
545            self.0.encode(encoder, offset + 0, depth)?;
546            self.1.encode(encoder, offset + 16, depth)?;
547            self.2.encode(encoder, offset + 24, depth)?;
548            self.3.encode(encoder, offset + 40, depth)?;
549            Ok(())
550        }
551    }
552
553    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Element {
554        #[inline(always)]
555        fn new_empty() -> Self {
556            Self {
557                element_name: fidl::new_empty!(fidl::encoding::BoundedString<64>, D),
558                initial_current_level: fidl::new_empty!(u8, D),
559                valid_levels: fidl::new_empty!(fidl::encoding::Vector<u8, 256>, D),
560                dependencies: fidl::new_empty!(fidl::encoding::Vector<LevelDependency, 256>, D),
561            }
562        }
563
564        #[inline]
565        unsafe fn decode(
566            &mut self,
567            decoder: &mut fidl::encoding::Decoder<'_, D>,
568            offset: usize,
569            _depth: fidl::encoding::Depth,
570        ) -> fidl::Result<()> {
571            decoder.debug_check_bounds::<Self>(offset);
572            // Verify that padding bytes are zero.
573            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
574            let padval = unsafe { (ptr as *const u64).read_unaligned() };
575            let mask = 0xffffffffffffff00u64;
576            let maskedval = padval & mask;
577            if maskedval != 0 {
578                return Err(fidl::Error::NonZeroPadding {
579                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
580                });
581            }
582            fidl::decode!(
583                fidl::encoding::BoundedString<64>,
584                D,
585                &mut self.element_name,
586                decoder,
587                offset + 0,
588                _depth
589            )?;
590            fidl::decode!(u8, D, &mut self.initial_current_level, decoder, offset + 16, _depth)?;
591            fidl::decode!(fidl::encoding::Vector<u8, 256>, D, &mut self.valid_levels, decoder, offset + 24, _depth)?;
592            fidl::decode!(fidl::encoding::Vector<LevelDependency, 256>, D, &mut self.dependencies, decoder, offset + 40, _depth)?;
593            Ok(())
594        }
595    }
596
597    impl fidl::encoding::ValueTypeMarker for LevelDependency {
598        type Borrowed<'a> = &'a Self;
599        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
600            value
601        }
602    }
603
604    unsafe impl fidl::encoding::TypeMarker for LevelDependency {
605        type Owned = Self;
606
607        #[inline(always)]
608        fn inline_align(_context: fidl::encoding::Context) -> usize {
609            8
610        }
611
612        #[inline(always)]
613        fn inline_size(_context: fidl::encoding::Context) -> usize {
614            32
615        }
616    }
617
618    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LevelDependency, D>
619        for &LevelDependency
620    {
621        #[inline]
622        unsafe fn encode(
623            self,
624            encoder: &mut fidl::encoding::Encoder<'_, D>,
625            offset: usize,
626            _depth: fidl::encoding::Depth,
627        ) -> fidl::Result<()> {
628            encoder.debug_check_bounds::<LevelDependency>(offset);
629            // Delegate to tuple encoding.
630            fidl::encoding::Encode::<LevelDependency, D>::encode(
631                (
632                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.dependent_level),
633                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
634                        &self.requires_element,
635                    ),
636                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.requires_level),
637                ),
638                encoder,
639                offset,
640                _depth,
641            )
642        }
643    }
644    unsafe impl<
645        D: fidl::encoding::ResourceDialect,
646        T0: fidl::encoding::Encode<u8, D>,
647        T1: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
648        T2: fidl::encoding::Encode<u8, D>,
649    > fidl::encoding::Encode<LevelDependency, D> for (T0, T1, T2)
650    {
651        #[inline]
652        unsafe fn encode(
653            self,
654            encoder: &mut fidl::encoding::Encoder<'_, D>,
655            offset: usize,
656            depth: fidl::encoding::Depth,
657        ) -> fidl::Result<()> {
658            encoder.debug_check_bounds::<LevelDependency>(offset);
659            // Zero out padding regions. There's no need to apply masks
660            // because the unmasked parts will be overwritten by fields.
661            unsafe {
662                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
663                (ptr as *mut u64).write_unaligned(0);
664            }
665            unsafe {
666                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
667                (ptr as *mut u64).write_unaligned(0);
668            }
669            // Write the fields.
670            self.0.encode(encoder, offset + 0, depth)?;
671            self.1.encode(encoder, offset + 8, depth)?;
672            self.2.encode(encoder, offset + 24, depth)?;
673            Ok(())
674        }
675    }
676
677    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LevelDependency {
678        #[inline(always)]
679        fn new_empty() -> Self {
680            Self {
681                dependent_level: fidl::new_empty!(u8, D),
682                requires_element: fidl::new_empty!(fidl::encoding::BoundedString<64>, D),
683                requires_level: fidl::new_empty!(u8, D),
684            }
685        }
686
687        #[inline]
688        unsafe fn decode(
689            &mut self,
690            decoder: &mut fidl::encoding::Decoder<'_, D>,
691            offset: usize,
692            _depth: fidl::encoding::Depth,
693        ) -> fidl::Result<()> {
694            decoder.debug_check_bounds::<Self>(offset);
695            // Verify that padding bytes are zero.
696            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
697            let padval = unsafe { (ptr as *const u64).read_unaligned() };
698            let mask = 0xffffffffffffff00u64;
699            let maskedval = padval & mask;
700            if maskedval != 0 {
701                return Err(fidl::Error::NonZeroPadding {
702                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
703                });
704            }
705            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
706            let padval = unsafe { (ptr as *const u64).read_unaligned() };
707            let mask = 0xffffffffffffff00u64;
708            let maskedval = padval & mask;
709            if maskedval != 0 {
710                return Err(fidl::Error::NonZeroPadding {
711                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
712                });
713            }
714            fidl::decode!(u8, D, &mut self.dependent_level, decoder, offset + 0, _depth)?;
715            fidl::decode!(
716                fidl::encoding::BoundedString<64>,
717                D,
718                &mut self.requires_element,
719                decoder,
720                offset + 8,
721                _depth
722            )?;
723            fidl::decode!(u8, D, &mut self.requires_level, decoder, offset + 24, _depth)?;
724            Ok(())
725        }
726    }
727
728    impl fidl::encoding::ValueTypeMarker for SystemActivityControlRestartApplicationActivityRequest {
729        type Borrowed<'a> = &'a Self;
730        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
731            value
732        }
733    }
734
735    unsafe impl fidl::encoding::TypeMarker for SystemActivityControlRestartApplicationActivityRequest {
736        type Owned = Self;
737
738        #[inline(always)]
739        fn inline_align(_context: fidl::encoding::Context) -> usize {
740            8
741        }
742
743        #[inline(always)]
744        fn inline_size(_context: fidl::encoding::Context) -> usize {
745            8
746        }
747        #[inline(always)]
748        fn encode_is_copy() -> bool {
749            true
750        }
751
752        #[inline(always)]
753        fn decode_is_copy() -> bool {
754            true
755        }
756    }
757
758    unsafe impl<D: fidl::encoding::ResourceDialect>
759        fidl::encoding::Encode<SystemActivityControlRestartApplicationActivityRequest, D>
760        for &SystemActivityControlRestartApplicationActivityRequest
761    {
762        #[inline]
763        unsafe fn encode(
764            self,
765            encoder: &mut fidl::encoding::Encoder<'_, D>,
766            offset: usize,
767            _depth: fidl::encoding::Depth,
768        ) -> fidl::Result<()> {
769            encoder.debug_check_bounds::<SystemActivityControlRestartApplicationActivityRequest>(
770                offset,
771            );
772            unsafe {
773                // Copy the object into the buffer.
774                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
775                (buf_ptr as *mut SystemActivityControlRestartApplicationActivityRequest)
776                    .write_unaligned(
777                        (self as *const SystemActivityControlRestartApplicationActivityRequest)
778                            .read(),
779                    );
780                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
781                // done second because the memcpy will write garbage to these bytes.
782            }
783            Ok(())
784        }
785    }
786    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
787        fidl::encoding::Encode<SystemActivityControlRestartApplicationActivityRequest, D> for (T0,)
788    {
789        #[inline]
790        unsafe fn encode(
791            self,
792            encoder: &mut fidl::encoding::Encoder<'_, D>,
793            offset: usize,
794            depth: fidl::encoding::Depth,
795        ) -> fidl::Result<()> {
796            encoder.debug_check_bounds::<SystemActivityControlRestartApplicationActivityRequest>(
797                offset,
798            );
799            // Zero out padding regions. There's no need to apply masks
800            // because the unmasked parts will be overwritten by fields.
801            // Write the fields.
802            self.0.encode(encoder, offset + 0, depth)?;
803            Ok(())
804        }
805    }
806
807    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
808        for SystemActivityControlRestartApplicationActivityRequest
809    {
810        #[inline(always)]
811        fn new_empty() -> Self {
812            Self { wait_time_ns: fidl::new_empty!(u64, D) }
813        }
814
815        #[inline]
816        unsafe fn decode(
817            &mut self,
818            decoder: &mut fidl::encoding::Decoder<'_, D>,
819            offset: usize,
820            _depth: fidl::encoding::Depth,
821        ) -> fidl::Result<()> {
822            decoder.debug_check_bounds::<Self>(offset);
823            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
824            // Verify that padding bytes are zero.
825            // Copy from the buffer into the object.
826            unsafe {
827                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
828            }
829            Ok(())
830        }
831    }
832
833    impl fidl::encoding::ValueTypeMarker for TopologyControlAcquireLeaseRequest {
834        type Borrowed<'a> = &'a Self;
835        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
836            value
837        }
838    }
839
840    unsafe impl fidl::encoding::TypeMarker for TopologyControlAcquireLeaseRequest {
841        type Owned = Self;
842
843        #[inline(always)]
844        fn inline_align(_context: fidl::encoding::Context) -> usize {
845            8
846        }
847
848        #[inline(always)]
849        fn inline_size(_context: fidl::encoding::Context) -> usize {
850            24
851        }
852    }
853
854    unsafe impl<D: fidl::encoding::ResourceDialect>
855        fidl::encoding::Encode<TopologyControlAcquireLeaseRequest, D>
856        for &TopologyControlAcquireLeaseRequest
857    {
858        #[inline]
859        unsafe fn encode(
860            self,
861            encoder: &mut fidl::encoding::Encoder<'_, D>,
862            offset: usize,
863            _depth: fidl::encoding::Depth,
864        ) -> fidl::Result<()> {
865            encoder.debug_check_bounds::<TopologyControlAcquireLeaseRequest>(offset);
866            // Delegate to tuple encoding.
867            fidl::encoding::Encode::<TopologyControlAcquireLeaseRequest, D>::encode(
868                (
869                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(&self.element_name),
870                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.level),
871                    <fidl_fuchsia_power_broker_common::LeaseStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.wait_for_status),
872                ),
873                encoder, offset, _depth
874            )
875        }
876    }
877    unsafe impl<
878        D: fidl::encoding::ResourceDialect,
879        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
880        T1: fidl::encoding::Encode<u8, D>,
881        T2: fidl::encoding::Encode<fidl_fuchsia_power_broker_common::LeaseStatus, D>,
882    > fidl::encoding::Encode<TopologyControlAcquireLeaseRequest, D> for (T0, T1, T2)
883    {
884        #[inline]
885        unsafe fn encode(
886            self,
887            encoder: &mut fidl::encoding::Encoder<'_, D>,
888            offset: usize,
889            depth: fidl::encoding::Depth,
890        ) -> fidl::Result<()> {
891            encoder.debug_check_bounds::<TopologyControlAcquireLeaseRequest>(offset);
892            // Zero out padding regions. There's no need to apply masks
893            // because the unmasked parts will be overwritten by fields.
894            unsafe {
895                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
896                (ptr as *mut u64).write_unaligned(0);
897            }
898            // Write the fields.
899            self.0.encode(encoder, offset + 0, depth)?;
900            self.1.encode(encoder, offset + 16, depth)?;
901            self.2.encode(encoder, offset + 20, depth)?;
902            Ok(())
903        }
904    }
905
906    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
907        for TopologyControlAcquireLeaseRequest
908    {
909        #[inline(always)]
910        fn new_empty() -> Self {
911            Self {
912                element_name: fidl::new_empty!(fidl::encoding::BoundedString<64>, D),
913                level: fidl::new_empty!(u8, D),
914                wait_for_status: fidl::new_empty!(fidl_fuchsia_power_broker_common::LeaseStatus, D),
915            }
916        }
917
918        #[inline]
919        unsafe fn decode(
920            &mut self,
921            decoder: &mut fidl::encoding::Decoder<'_, D>,
922            offset: usize,
923            _depth: fidl::encoding::Depth,
924        ) -> fidl::Result<()> {
925            decoder.debug_check_bounds::<Self>(offset);
926            // Verify that padding bytes are zero.
927            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
928            let padval = unsafe { (ptr as *const u64).read_unaligned() };
929            let mask = 0xffffff00u64;
930            let maskedval = padval & mask;
931            if maskedval != 0 {
932                return Err(fidl::Error::NonZeroPadding {
933                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
934                });
935            }
936            fidl::decode!(
937                fidl::encoding::BoundedString<64>,
938                D,
939                &mut self.element_name,
940                decoder,
941                offset + 0,
942                _depth
943            )?;
944            fidl::decode!(u8, D, &mut self.level, decoder, offset + 16, _depth)?;
945            fidl::decode!(
946                fidl_fuchsia_power_broker_common::LeaseStatus,
947                D,
948                &mut self.wait_for_status,
949                decoder,
950                offset + 20,
951                _depth
952            )?;
953            Ok(())
954        }
955    }
956
957    impl fidl::encoding::ValueTypeMarker for TopologyControlCreateRequest {
958        type Borrowed<'a> = &'a Self;
959        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
960            value
961        }
962    }
963
964    unsafe impl fidl::encoding::TypeMarker for TopologyControlCreateRequest {
965        type Owned = Self;
966
967        #[inline(always)]
968        fn inline_align(_context: fidl::encoding::Context) -> usize {
969            8
970        }
971
972        #[inline(always)]
973        fn inline_size(_context: fidl::encoding::Context) -> usize {
974            16
975        }
976    }
977
978    unsafe impl<D: fidl::encoding::ResourceDialect>
979        fidl::encoding::Encode<TopologyControlCreateRequest, D> for &TopologyControlCreateRequest
980    {
981        #[inline]
982        unsafe fn encode(
983            self,
984            encoder: &mut fidl::encoding::Encoder<'_, D>,
985            offset: usize,
986            _depth: fidl::encoding::Depth,
987        ) -> fidl::Result<()> {
988            encoder.debug_check_bounds::<TopologyControlCreateRequest>(offset);
989            // Delegate to tuple encoding.
990            fidl::encoding::Encode::<TopologyControlCreateRequest, D>::encode(
991                (
992                    <fidl::encoding::Vector<Element, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.elements),
993                ),
994                encoder, offset, _depth
995            )
996        }
997    }
998    unsafe impl<
999        D: fidl::encoding::ResourceDialect,
1000        T0: fidl::encoding::Encode<fidl::encoding::Vector<Element, 256>, D>,
1001    > fidl::encoding::Encode<TopologyControlCreateRequest, D> for (T0,)
1002    {
1003        #[inline]
1004        unsafe fn encode(
1005            self,
1006            encoder: &mut fidl::encoding::Encoder<'_, D>,
1007            offset: usize,
1008            depth: fidl::encoding::Depth,
1009        ) -> fidl::Result<()> {
1010            encoder.debug_check_bounds::<TopologyControlCreateRequest>(offset);
1011            // Zero out padding regions. There's no need to apply masks
1012            // because the unmasked parts will be overwritten by fields.
1013            // Write the fields.
1014            self.0.encode(encoder, offset + 0, depth)?;
1015            Ok(())
1016        }
1017    }
1018
1019    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1020        for TopologyControlCreateRequest
1021    {
1022        #[inline(always)]
1023        fn new_empty() -> Self {
1024            Self { elements: fidl::new_empty!(fidl::encoding::Vector<Element, 256>, D) }
1025        }
1026
1027        #[inline]
1028        unsafe fn decode(
1029            &mut self,
1030            decoder: &mut fidl::encoding::Decoder<'_, D>,
1031            offset: usize,
1032            _depth: fidl::encoding::Depth,
1033        ) -> fidl::Result<()> {
1034            decoder.debug_check_bounds::<Self>(offset);
1035            // Verify that padding bytes are zero.
1036            fidl::decode!(fidl::encoding::Vector<Element, 256>, D, &mut self.elements, decoder, offset + 0, _depth)?;
1037            Ok(())
1038        }
1039    }
1040
1041    impl fidl::encoding::ValueTypeMarker for TopologyControlDropLeaseRequest {
1042        type Borrowed<'a> = &'a Self;
1043        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1044            value
1045        }
1046    }
1047
1048    unsafe impl fidl::encoding::TypeMarker for TopologyControlDropLeaseRequest {
1049        type Owned = Self;
1050
1051        #[inline(always)]
1052        fn inline_align(_context: fidl::encoding::Context) -> usize {
1053            8
1054        }
1055
1056        #[inline(always)]
1057        fn inline_size(_context: fidl::encoding::Context) -> usize {
1058            16
1059        }
1060    }
1061
1062    unsafe impl<D: fidl::encoding::ResourceDialect>
1063        fidl::encoding::Encode<TopologyControlDropLeaseRequest, D>
1064        for &TopologyControlDropLeaseRequest
1065    {
1066        #[inline]
1067        unsafe fn encode(
1068            self,
1069            encoder: &mut fidl::encoding::Encoder<'_, D>,
1070            offset: usize,
1071            _depth: fidl::encoding::Depth,
1072        ) -> fidl::Result<()> {
1073            encoder.debug_check_bounds::<TopologyControlDropLeaseRequest>(offset);
1074            // Delegate to tuple encoding.
1075            fidl::encoding::Encode::<TopologyControlDropLeaseRequest, D>::encode(
1076                (<fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
1077                    &self.element_name,
1078                ),),
1079                encoder,
1080                offset,
1081                _depth,
1082            )
1083        }
1084    }
1085    unsafe impl<
1086        D: fidl::encoding::ResourceDialect,
1087        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<64>, D>,
1088    > fidl::encoding::Encode<TopologyControlDropLeaseRequest, D> for (T0,)
1089    {
1090        #[inline]
1091        unsafe fn encode(
1092            self,
1093            encoder: &mut fidl::encoding::Encoder<'_, D>,
1094            offset: usize,
1095            depth: fidl::encoding::Depth,
1096        ) -> fidl::Result<()> {
1097            encoder.debug_check_bounds::<TopologyControlDropLeaseRequest>(offset);
1098            // Zero out padding regions. There's no need to apply masks
1099            // because the unmasked parts will be overwritten by fields.
1100            // Write the fields.
1101            self.0.encode(encoder, offset + 0, depth)?;
1102            Ok(())
1103        }
1104    }
1105
1106    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1107        for TopologyControlDropLeaseRequest
1108    {
1109        #[inline(always)]
1110        fn new_empty() -> Self {
1111            Self { element_name: fidl::new_empty!(fidl::encoding::BoundedString<64>, D) }
1112        }
1113
1114        #[inline]
1115        unsafe fn decode(
1116            &mut self,
1117            decoder: &mut fidl::encoding::Decoder<'_, D>,
1118            offset: usize,
1119            _depth: fidl::encoding::Depth,
1120        ) -> fidl::Result<()> {
1121            decoder.debug_check_bounds::<Self>(offset);
1122            // Verify that padding bytes are zero.
1123            fidl::decode!(
1124                fidl::encoding::BoundedString<64>,
1125                D,
1126                &mut self.element_name,
1127                decoder,
1128                offset + 0,
1129                _depth
1130            )?;
1131            Ok(())
1132        }
1133    }
1134}