fidl_fuchsia_power_systemmode__common/
fidl_fuchsia_power_systemmode__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/// Maximum number of [`ModeMatch`] entries that a [`ClientConfig`] may contain.
12///
13/// This value should be set equal to the number of [`SystemMode`] variants, as
14/// that is the number of entries required to support the "worst case" client
15/// configuration ("worst case" means a configuration where a mode match entry
16/// is needed for each of the supported power modes).
17pub const MAX_MODE_MATCHES_PER_CLIENT: u32 = 0;
18
19/// Possible error values returned by [`Requester.Request`].
20#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21pub enum ModeRequestError {
22    /// A generic error has occurred.
23    Generic,
24    #[doc(hidden)]
25    __SourceBreaking { unknown_ordinal: u32 },
26}
27
28/// Pattern that matches an unknown `ModeRequestError` member.
29#[macro_export]
30macro_rules! ModeRequestErrorUnknown {
31    () => {
32        _
33    };
34}
35
36impl ModeRequestError {
37    #[inline]
38    pub fn from_primitive(prim: u32) -> Option<Self> {
39        match prim {
40            1 => Some(Self::Generic),
41            _ => None,
42        }
43    }
44
45    #[inline]
46    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
47        match prim {
48            1 => Self::Generic,
49            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
50        }
51    }
52
53    #[inline]
54    pub fn unknown() -> Self {
55        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
56    }
57
58    #[inline]
59    pub const fn into_primitive(self) -> u32 {
60        match self {
61            Self::Generic => 1,
62            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
63        }
64    }
65
66    #[inline]
67    pub fn is_unknown(&self) -> bool {
68        match self {
69            Self::__SourceBreaking { unknown_ordinal: _ } => true,
70            _ => false,
71        }
72    }
73}
74
75/// Enumerates the supported system power modes.
76///
77/// Power modes in the system are non-exclusive -- more than one could be active
78/// at any given time. They typically define a system-wide low-power state or
79/// power goal, like "battery-saver mode". See the
80/// [README.md](/src/power/power-manager/system_power_mode_config/README.md) for
81/// more details.
82///
83/// Note when adding a new variant: update [`MAX_MODE_MATCHES_PER_CLIENT`] to be
84/// equal to the number of `SystemMode` variants to support the "worst case"
85/// client configuration.
86#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
87pub enum SystemMode {
88    #[doc(hidden)]
89    __SourceBreaking { unknown_ordinal: u32 },
90}
91
92/// Pattern that matches an unknown `SystemMode` member.
93#[macro_export]
94macro_rules! SystemModeUnknown {
95    () => {
96        _
97    };
98}
99
100impl SystemMode {
101    #[inline]
102    pub fn from_primitive(prim: u32) -> Option<Self> {
103        match prim {
104            _ => None,
105        }
106    }
107
108    #[inline]
109    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
110        match prim {
111            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
112        }
113    }
114
115    #[inline]
116    pub fn unknown() -> Self {
117        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
118    }
119
120    #[inline]
121    pub const fn into_primitive(self) -> u32 {
122        match self {
123            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
124        }
125    }
126
127    #[inline]
128    pub fn is_unknown(&self) -> bool {
129        match self {
130            Self::__SourceBreaking { unknown_ordinal: _ } => true,
131        }
132    }
133}
134
135/// Defines the power configuration for a [`ClientType`].
136///
137/// For a client connected with a given [`ClientType`], the PowerManager will
138/// use the configured [`ClientConfig`] for that [`ClientType`] to choose the
139/// appropriate power level based on the currently active system power modes.
140/// The power level selection process is as follows for a given [`ClientType`]:
141///   1. Iterate through the [`ClientConfig.mode_matches`] entries. If the
142///   `mode` value specified by an entry is contained in the currently active
143///   system power modes, then the corresponding `power_level` from that entry
144///   will be selected as this client’s current power level, and iteration for
145///   this client will stop.
146///   2. If no entry in `mode_matches` was matched, then `default_level` will be
147///   selected as the client's current power level.
148#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
149pub struct ClientConfig {
150    pub mode_matches: Vec<ModeMatch>,
151    pub default_level: u64,
152}
153
154impl fidl::Persistable for ClientConfig {}
155
156#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
157pub struct ClientConfiguratorGetRequest {
158    pub client_type: fidl_fuchsia_power_clientlevel__common::ClientType,
159}
160
161impl fidl::Persistable for ClientConfiguratorGetRequest {}
162
163#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
164pub struct ClientConfiguratorGetResponse {
165    pub config: Option<Box<ClientConfig>>,
166}
167
168impl fidl::Persistable for ClientConfiguratorGetResponse {}
169
170#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
171pub struct ClientConfiguratorSetRequest {
172    pub client_type: fidl_fuchsia_power_clientlevel__common::ClientType,
173    pub config: ClientConfig,
174}
175
176impl fidl::Persistable for ClientConfiguratorSetRequest {}
177
178/// Defines the mode-based match criterion for selecting a power level.
179///
180/// The power configuration for a given [`ClientType`] is made up of a
181/// collection of these `ModeMatch` entries. If an entry's specified `mode` is
182/// contained in the currently active system power modes, then its `power_level`
183/// will be selected as the client's power level.
184#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
185pub struct ModeMatch {
186    pub mode: SystemMode,
187    pub power_level: u64,
188}
189
190impl fidl::Persistable for ModeMatch {}
191
192#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
193pub struct RequesterRequestRequest {
194    pub mode: SystemMode,
195    pub set: bool,
196}
197
198impl fidl::Persistable for RequesterRequestRequest {}
199
200mod internal {
201    use super::*;
202    unsafe impl fidl::encoding::TypeMarker for ModeRequestError {
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            false
218        }
219
220        #[inline(always)]
221        fn decode_is_copy() -> bool {
222            false
223        }
224    }
225
226    impl fidl::encoding::ValueTypeMarker for ModeRequestError {
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 ModeRequestError
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> for ModeRequestError {
251        #[inline(always)]
252        fn new_empty() -> Self {
253            Self::unknown()
254        }
255
256        #[inline]
257        unsafe fn decode(
258            &mut self,
259            decoder: &mut fidl::encoding::Decoder<'_, D>,
260            offset: usize,
261            _depth: fidl::encoding::Depth,
262        ) -> fidl::Result<()> {
263            decoder.debug_check_bounds::<Self>(offset);
264            let prim = decoder.read_num::<u32>(offset);
265
266            *self = Self::from_primitive_allow_unknown(prim);
267            Ok(())
268        }
269    }
270    unsafe impl fidl::encoding::TypeMarker for SystemMode {
271        type Owned = Self;
272
273        #[inline(always)]
274        fn inline_align(_context: fidl::encoding::Context) -> usize {
275            std::mem::align_of::<u32>()
276        }
277
278        #[inline(always)]
279        fn inline_size(_context: fidl::encoding::Context) -> usize {
280            std::mem::size_of::<u32>()
281        }
282
283        #[inline(always)]
284        fn encode_is_copy() -> bool {
285            false
286        }
287
288        #[inline(always)]
289        fn decode_is_copy() -> bool {
290            false
291        }
292    }
293
294    impl fidl::encoding::ValueTypeMarker for SystemMode {
295        type Borrowed<'a> = Self;
296        #[inline(always)]
297        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
298            *value
299        }
300    }
301
302    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SystemMode {
303        #[inline]
304        unsafe fn encode(
305            self,
306            encoder: &mut fidl::encoding::Encoder<'_, D>,
307            offset: usize,
308            _depth: fidl::encoding::Depth,
309        ) -> fidl::Result<()> {
310            encoder.debug_check_bounds::<Self>(offset);
311            encoder.write_num(self.into_primitive(), offset);
312            Ok(())
313        }
314    }
315
316    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemMode {
317        #[inline(always)]
318        fn new_empty() -> Self {
319            Self::unknown()
320        }
321
322        #[inline]
323        unsafe fn decode(
324            &mut self,
325            decoder: &mut fidl::encoding::Decoder<'_, D>,
326            offset: usize,
327            _depth: fidl::encoding::Depth,
328        ) -> fidl::Result<()> {
329            decoder.debug_check_bounds::<Self>(offset);
330            let prim = decoder.read_num::<u32>(offset);
331
332            *self = Self::from_primitive_allow_unknown(prim);
333            Ok(())
334        }
335    }
336
337    impl fidl::encoding::ValueTypeMarker for ClientConfig {
338        type Borrowed<'a> = &'a Self;
339        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
340            value
341        }
342    }
343
344    unsafe impl fidl::encoding::TypeMarker for ClientConfig {
345        type Owned = Self;
346
347        #[inline(always)]
348        fn inline_align(_context: fidl::encoding::Context) -> usize {
349            8
350        }
351
352        #[inline(always)]
353        fn inline_size(_context: fidl::encoding::Context) -> usize {
354            24
355        }
356    }
357
358    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ClientConfig, D>
359        for &ClientConfig
360    {
361        #[inline]
362        unsafe fn encode(
363            self,
364            encoder: &mut fidl::encoding::Encoder<'_, D>,
365            offset: usize,
366            _depth: fidl::encoding::Depth,
367        ) -> fidl::Result<()> {
368            encoder.debug_check_bounds::<ClientConfig>(offset);
369            // Delegate to tuple encoding.
370            fidl::encoding::Encode::<ClientConfig, D>::encode(
371                (
372                    <fidl::encoding::Vector<ModeMatch, 0> as fidl::encoding::ValueTypeMarker>::borrow(&self.mode_matches),
373                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.default_level),
374                ),
375                encoder, offset, _depth
376            )
377        }
378    }
379    unsafe impl<
380            D: fidl::encoding::ResourceDialect,
381            T0: fidl::encoding::Encode<fidl::encoding::Vector<ModeMatch, 0>, D>,
382            T1: fidl::encoding::Encode<u64, D>,
383        > fidl::encoding::Encode<ClientConfig, D> for (T0, T1)
384    {
385        #[inline]
386        unsafe fn encode(
387            self,
388            encoder: &mut fidl::encoding::Encoder<'_, D>,
389            offset: usize,
390            depth: fidl::encoding::Depth,
391        ) -> fidl::Result<()> {
392            encoder.debug_check_bounds::<ClientConfig>(offset);
393            // Zero out padding regions. There's no need to apply masks
394            // because the unmasked parts will be overwritten by fields.
395            // Write the fields.
396            self.0.encode(encoder, offset + 0, depth)?;
397            self.1.encode(encoder, offset + 16, depth)?;
398            Ok(())
399        }
400    }
401
402    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ClientConfig {
403        #[inline(always)]
404        fn new_empty() -> Self {
405            Self {
406                mode_matches: fidl::new_empty!(fidl::encoding::Vector<ModeMatch, 0>, D),
407                default_level: fidl::new_empty!(u64, D),
408            }
409        }
410
411        #[inline]
412        unsafe fn decode(
413            &mut self,
414            decoder: &mut fidl::encoding::Decoder<'_, D>,
415            offset: usize,
416            _depth: fidl::encoding::Depth,
417        ) -> fidl::Result<()> {
418            decoder.debug_check_bounds::<Self>(offset);
419            // Verify that padding bytes are zero.
420            fidl::decode!(fidl::encoding::Vector<ModeMatch, 0>, D, &mut self.mode_matches, decoder, offset + 0, _depth)?;
421            fidl::decode!(u64, D, &mut self.default_level, decoder, offset + 16, _depth)?;
422            Ok(())
423        }
424    }
425
426    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorGetRequest {
427        type Borrowed<'a> = &'a Self;
428        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
429            value
430        }
431    }
432
433    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorGetRequest {
434        type Owned = Self;
435
436        #[inline(always)]
437        fn inline_align(_context: fidl::encoding::Context) -> usize {
438            4
439        }
440
441        #[inline(always)]
442        fn inline_size(_context: fidl::encoding::Context) -> usize {
443            4
444        }
445    }
446
447    unsafe impl<D: fidl::encoding::ResourceDialect>
448        fidl::encoding::Encode<ClientConfiguratorGetRequest, D> for &ClientConfiguratorGetRequest
449    {
450        #[inline]
451        unsafe fn encode(
452            self,
453            encoder: &mut fidl::encoding::Encoder<'_, D>,
454            offset: usize,
455            _depth: fidl::encoding::Depth,
456        ) -> fidl::Result<()> {
457            encoder.debug_check_bounds::<ClientConfiguratorGetRequest>(offset);
458            // Delegate to tuple encoding.
459            fidl::encoding::Encode::<ClientConfiguratorGetRequest, D>::encode(
460                (
461                    <fidl_fuchsia_power_clientlevel__common::ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
462                ),
463                encoder, offset, _depth
464            )
465        }
466    }
467    unsafe impl<
468            D: fidl::encoding::ResourceDialect,
469            T0: fidl::encoding::Encode<fidl_fuchsia_power_clientlevel__common::ClientType, D>,
470        > fidl::encoding::Encode<ClientConfiguratorGetRequest, D> for (T0,)
471    {
472        #[inline]
473        unsafe fn encode(
474            self,
475            encoder: &mut fidl::encoding::Encoder<'_, D>,
476            offset: usize,
477            depth: fidl::encoding::Depth,
478        ) -> fidl::Result<()> {
479            encoder.debug_check_bounds::<ClientConfiguratorGetRequest>(offset);
480            // Zero out padding regions. There's no need to apply masks
481            // because the unmasked parts will be overwritten by fields.
482            // Write the fields.
483            self.0.encode(encoder, offset + 0, depth)?;
484            Ok(())
485        }
486    }
487
488    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
489        for ClientConfiguratorGetRequest
490    {
491        #[inline(always)]
492        fn new_empty() -> Self {
493            Self {
494                client_type: fidl::new_empty!(
495                    fidl_fuchsia_power_clientlevel__common::ClientType,
496                    D
497                ),
498            }
499        }
500
501        #[inline]
502        unsafe fn decode(
503            &mut self,
504            decoder: &mut fidl::encoding::Decoder<'_, D>,
505            offset: usize,
506            _depth: fidl::encoding::Depth,
507        ) -> fidl::Result<()> {
508            decoder.debug_check_bounds::<Self>(offset);
509            // Verify that padding bytes are zero.
510            fidl::decode!(
511                fidl_fuchsia_power_clientlevel__common::ClientType,
512                D,
513                &mut self.client_type,
514                decoder,
515                offset + 0,
516                _depth
517            )?;
518            Ok(())
519        }
520    }
521
522    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorGetResponse {
523        type Borrowed<'a> = &'a Self;
524        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
525            value
526        }
527    }
528
529    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorGetResponse {
530        type Owned = Self;
531
532        #[inline(always)]
533        fn inline_align(_context: fidl::encoding::Context) -> usize {
534            8
535        }
536
537        #[inline(always)]
538        fn inline_size(_context: fidl::encoding::Context) -> usize {
539            8
540        }
541    }
542
543    unsafe impl<D: fidl::encoding::ResourceDialect>
544        fidl::encoding::Encode<ClientConfiguratorGetResponse, D>
545        for &ClientConfiguratorGetResponse
546    {
547        #[inline]
548        unsafe fn encode(
549            self,
550            encoder: &mut fidl::encoding::Encoder<'_, D>,
551            offset: usize,
552            _depth: fidl::encoding::Depth,
553        ) -> fidl::Result<()> {
554            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
555            // Delegate to tuple encoding.
556            fidl::encoding::Encode::<ClientConfiguratorGetResponse, D>::encode(
557                (<fidl::encoding::Boxed<ClientConfig> as fidl::encoding::ValueTypeMarker>::borrow(
558                    &self.config,
559                ),),
560                encoder,
561                offset,
562                _depth,
563            )
564        }
565    }
566    unsafe impl<
567            D: fidl::encoding::ResourceDialect,
568            T0: fidl::encoding::Encode<fidl::encoding::Boxed<ClientConfig>, D>,
569        > fidl::encoding::Encode<ClientConfiguratorGetResponse, D> for (T0,)
570    {
571        #[inline]
572        unsafe fn encode(
573            self,
574            encoder: &mut fidl::encoding::Encoder<'_, D>,
575            offset: usize,
576            depth: fidl::encoding::Depth,
577        ) -> fidl::Result<()> {
578            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
579            // Zero out padding regions. There's no need to apply masks
580            // because the unmasked parts will be overwritten by fields.
581            // Write the fields.
582            self.0.encode(encoder, offset + 0, depth)?;
583            Ok(())
584        }
585    }
586
587    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
588        for ClientConfiguratorGetResponse
589    {
590        #[inline(always)]
591        fn new_empty() -> Self {
592            Self { config: fidl::new_empty!(fidl::encoding::Boxed<ClientConfig>, D) }
593        }
594
595        #[inline]
596        unsafe fn decode(
597            &mut self,
598            decoder: &mut fidl::encoding::Decoder<'_, D>,
599            offset: usize,
600            _depth: fidl::encoding::Depth,
601        ) -> fidl::Result<()> {
602            decoder.debug_check_bounds::<Self>(offset);
603            // Verify that padding bytes are zero.
604            fidl::decode!(
605                fidl::encoding::Boxed<ClientConfig>,
606                D,
607                &mut self.config,
608                decoder,
609                offset + 0,
610                _depth
611            )?;
612            Ok(())
613        }
614    }
615
616    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorSetRequest {
617        type Borrowed<'a> = &'a Self;
618        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
619            value
620        }
621    }
622
623    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorSetRequest {
624        type Owned = Self;
625
626        #[inline(always)]
627        fn inline_align(_context: fidl::encoding::Context) -> usize {
628            8
629        }
630
631        #[inline(always)]
632        fn inline_size(_context: fidl::encoding::Context) -> usize {
633            32
634        }
635    }
636
637    unsafe impl<D: fidl::encoding::ResourceDialect>
638        fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for &ClientConfiguratorSetRequest
639    {
640        #[inline]
641        unsafe fn encode(
642            self,
643            encoder: &mut fidl::encoding::Encoder<'_, D>,
644            offset: usize,
645            _depth: fidl::encoding::Depth,
646        ) -> fidl::Result<()> {
647            encoder.debug_check_bounds::<ClientConfiguratorSetRequest>(offset);
648            // Delegate to tuple encoding.
649            fidl::encoding::Encode::<ClientConfiguratorSetRequest, D>::encode(
650                (
651                    <fidl_fuchsia_power_clientlevel__common::ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
652                    <ClientConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
653                ),
654                encoder, offset, _depth
655            )
656        }
657    }
658    unsafe impl<
659            D: fidl::encoding::ResourceDialect,
660            T0: fidl::encoding::Encode<fidl_fuchsia_power_clientlevel__common::ClientType, D>,
661            T1: fidl::encoding::Encode<ClientConfig, D>,
662        > fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for (T0, T1)
663    {
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::<ClientConfiguratorSetRequest>(offset);
672            // Zero out padding regions. There's no need to apply masks
673            // because the unmasked parts will be overwritten by fields.
674            unsafe {
675                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
676                (ptr as *mut u64).write_unaligned(0);
677            }
678            // Write the fields.
679            self.0.encode(encoder, offset + 0, depth)?;
680            self.1.encode(encoder, offset + 8, depth)?;
681            Ok(())
682        }
683    }
684
685    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
686        for ClientConfiguratorSetRequest
687    {
688        #[inline(always)]
689        fn new_empty() -> Self {
690            Self {
691                client_type: fidl::new_empty!(
692                    fidl_fuchsia_power_clientlevel__common::ClientType,
693                    D
694                ),
695                config: fidl::new_empty!(ClientConfig, D),
696            }
697        }
698
699        #[inline]
700        unsafe fn decode(
701            &mut self,
702            decoder: &mut fidl::encoding::Decoder<'_, D>,
703            offset: usize,
704            _depth: fidl::encoding::Depth,
705        ) -> fidl::Result<()> {
706            decoder.debug_check_bounds::<Self>(offset);
707            // Verify that padding bytes are zero.
708            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
709            let padval = unsafe { (ptr as *const u64).read_unaligned() };
710            let mask = 0xffffffff00000000u64;
711            let maskedval = padval & mask;
712            if maskedval != 0 {
713                return Err(fidl::Error::NonZeroPadding {
714                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
715                });
716            }
717            fidl::decode!(
718                fidl_fuchsia_power_clientlevel__common::ClientType,
719                D,
720                &mut self.client_type,
721                decoder,
722                offset + 0,
723                _depth
724            )?;
725            fidl::decode!(ClientConfig, D, &mut self.config, decoder, offset + 8, _depth)?;
726            Ok(())
727        }
728    }
729
730    impl fidl::encoding::ValueTypeMarker for ModeMatch {
731        type Borrowed<'a> = &'a Self;
732        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
733            value
734        }
735    }
736
737    unsafe impl fidl::encoding::TypeMarker for ModeMatch {
738        type Owned = Self;
739
740        #[inline(always)]
741        fn inline_align(_context: fidl::encoding::Context) -> usize {
742            8
743        }
744
745        #[inline(always)]
746        fn inline_size(_context: fidl::encoding::Context) -> usize {
747            16
748        }
749    }
750
751    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ModeMatch, D>
752        for &ModeMatch
753    {
754        #[inline]
755        unsafe fn encode(
756            self,
757            encoder: &mut fidl::encoding::Encoder<'_, D>,
758            offset: usize,
759            _depth: fidl::encoding::Depth,
760        ) -> fidl::Result<()> {
761            encoder.debug_check_bounds::<ModeMatch>(offset);
762            // Delegate to tuple encoding.
763            fidl::encoding::Encode::<ModeMatch, D>::encode(
764                (
765                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
766                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.power_level),
767                ),
768                encoder,
769                offset,
770                _depth,
771            )
772        }
773    }
774    unsafe impl<
775            D: fidl::encoding::ResourceDialect,
776            T0: fidl::encoding::Encode<SystemMode, D>,
777            T1: fidl::encoding::Encode<u64, D>,
778        > fidl::encoding::Encode<ModeMatch, D> for (T0, T1)
779    {
780        #[inline]
781        unsafe fn encode(
782            self,
783            encoder: &mut fidl::encoding::Encoder<'_, D>,
784            offset: usize,
785            depth: fidl::encoding::Depth,
786        ) -> fidl::Result<()> {
787            encoder.debug_check_bounds::<ModeMatch>(offset);
788            // Zero out padding regions. There's no need to apply masks
789            // because the unmasked parts will be overwritten by fields.
790            unsafe {
791                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
792                (ptr as *mut u64).write_unaligned(0);
793            }
794            // Write the fields.
795            self.0.encode(encoder, offset + 0, depth)?;
796            self.1.encode(encoder, offset + 8, depth)?;
797            Ok(())
798        }
799    }
800
801    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeMatch {
802        #[inline(always)]
803        fn new_empty() -> Self {
804            Self { mode: fidl::new_empty!(SystemMode, D), power_level: fidl::new_empty!(u64, D) }
805        }
806
807        #[inline]
808        unsafe fn decode(
809            &mut self,
810            decoder: &mut fidl::encoding::Decoder<'_, D>,
811            offset: usize,
812            _depth: fidl::encoding::Depth,
813        ) -> fidl::Result<()> {
814            decoder.debug_check_bounds::<Self>(offset);
815            // Verify that padding bytes are zero.
816            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
817            let padval = unsafe { (ptr as *const u64).read_unaligned() };
818            let mask = 0xffffffff00000000u64;
819            let maskedval = padval & mask;
820            if maskedval != 0 {
821                return Err(fidl::Error::NonZeroPadding {
822                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
823                });
824            }
825            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
826            fidl::decode!(u64, D, &mut self.power_level, decoder, offset + 8, _depth)?;
827            Ok(())
828        }
829    }
830
831    impl fidl::encoding::ValueTypeMarker for RequesterRequestRequest {
832        type Borrowed<'a> = &'a Self;
833        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
834            value
835        }
836    }
837
838    unsafe impl fidl::encoding::TypeMarker for RequesterRequestRequest {
839        type Owned = Self;
840
841        #[inline(always)]
842        fn inline_align(_context: fidl::encoding::Context) -> usize {
843            4
844        }
845
846        #[inline(always)]
847        fn inline_size(_context: fidl::encoding::Context) -> usize {
848            8
849        }
850    }
851
852    unsafe impl<D: fidl::encoding::ResourceDialect>
853        fidl::encoding::Encode<RequesterRequestRequest, D> for &RequesterRequestRequest
854    {
855        #[inline]
856        unsafe fn encode(
857            self,
858            encoder: &mut fidl::encoding::Encoder<'_, D>,
859            offset: usize,
860            _depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            encoder.debug_check_bounds::<RequesterRequestRequest>(offset);
863            // Delegate to tuple encoding.
864            fidl::encoding::Encode::<RequesterRequestRequest, D>::encode(
865                (
866                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
867                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.set),
868                ),
869                encoder,
870                offset,
871                _depth,
872            )
873        }
874    }
875    unsafe impl<
876            D: fidl::encoding::ResourceDialect,
877            T0: fidl::encoding::Encode<SystemMode, D>,
878            T1: fidl::encoding::Encode<bool, D>,
879        > fidl::encoding::Encode<RequesterRequestRequest, D> for (T0, T1)
880    {
881        #[inline]
882        unsafe fn encode(
883            self,
884            encoder: &mut fidl::encoding::Encoder<'_, D>,
885            offset: usize,
886            depth: fidl::encoding::Depth,
887        ) -> fidl::Result<()> {
888            encoder.debug_check_bounds::<RequesterRequestRequest>(offset);
889            // Zero out padding regions. There's no need to apply masks
890            // because the unmasked parts will be overwritten by fields.
891            unsafe {
892                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
893                (ptr as *mut u32).write_unaligned(0);
894            }
895            // Write the fields.
896            self.0.encode(encoder, offset + 0, depth)?;
897            self.1.encode(encoder, offset + 4, depth)?;
898            Ok(())
899        }
900    }
901
902    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
903        for RequesterRequestRequest
904    {
905        #[inline(always)]
906        fn new_empty() -> Self {
907            Self { mode: fidl::new_empty!(SystemMode, D), set: fidl::new_empty!(bool, D) }
908        }
909
910        #[inline]
911        unsafe fn decode(
912            &mut self,
913            decoder: &mut fidl::encoding::Decoder<'_, D>,
914            offset: usize,
915            _depth: fidl::encoding::Depth,
916        ) -> fidl::Result<()> {
917            decoder.debug_check_bounds::<Self>(offset);
918            // Verify that padding bytes are zero.
919            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
920            let padval = unsafe { (ptr as *const u32).read_unaligned() };
921            let mask = 0xffffff00u32;
922            let maskedval = padval & mask;
923            if maskedval != 0 {
924                return Err(fidl::Error::NonZeroPadding {
925                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
926                });
927            }
928            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
929            fidl::decode!(bool, D, &mut self.set, decoder, offset + 4, _depth)?;
930            Ok(())
931        }
932    }
933}