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