Skip to main content

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
200pub mod client_configurator_ordinals {
201    pub const GET: u64 = 0x1e37597b4d247d7b;
202    pub const SET: u64 = 0x2204fb91b32f6435;
203}
204
205pub mod requester_ordinals {
206    pub const REQUEST: u64 = 0x5603afcd4421f425;
207}
208
209mod internal {
210    use super::*;
211    unsafe impl fidl::encoding::TypeMarker for ModeRequestError {
212        type Owned = Self;
213
214        #[inline(always)]
215        fn inline_align(_context: fidl::encoding::Context) -> usize {
216            std::mem::align_of::<u32>()
217        }
218
219        #[inline(always)]
220        fn inline_size(_context: fidl::encoding::Context) -> usize {
221            std::mem::size_of::<u32>()
222        }
223
224        #[inline(always)]
225        fn encode_is_copy() -> bool {
226            false
227        }
228
229        #[inline(always)]
230        fn decode_is_copy() -> bool {
231            false
232        }
233    }
234
235    impl fidl::encoding::ValueTypeMarker for ModeRequestError {
236        type Borrowed<'a> = Self;
237        #[inline(always)]
238        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
239            *value
240        }
241    }
242
243    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
244        for ModeRequestError
245    {
246        #[inline]
247        unsafe fn encode(
248            self,
249            encoder: &mut fidl::encoding::Encoder<'_, D>,
250            offset: usize,
251            _depth: fidl::encoding::Depth,
252        ) -> fidl::Result<()> {
253            encoder.debug_check_bounds::<Self>(offset);
254            encoder.write_num(self.into_primitive(), offset);
255            Ok(())
256        }
257    }
258
259    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeRequestError {
260        #[inline(always)]
261        fn new_empty() -> Self {
262            Self::unknown()
263        }
264
265        #[inline]
266        unsafe fn decode(
267            &mut self,
268            decoder: &mut fidl::encoding::Decoder<'_, D>,
269            offset: usize,
270            _depth: fidl::encoding::Depth,
271        ) -> fidl::Result<()> {
272            decoder.debug_check_bounds::<Self>(offset);
273            let prim = decoder.read_num::<u32>(offset);
274
275            *self = Self::from_primitive_allow_unknown(prim);
276            Ok(())
277        }
278    }
279    unsafe impl fidl::encoding::TypeMarker for SystemMode {
280        type Owned = Self;
281
282        #[inline(always)]
283        fn inline_align(_context: fidl::encoding::Context) -> usize {
284            std::mem::align_of::<u32>()
285        }
286
287        #[inline(always)]
288        fn inline_size(_context: fidl::encoding::Context) -> usize {
289            std::mem::size_of::<u32>()
290        }
291
292        #[inline(always)]
293        fn encode_is_copy() -> bool {
294            false
295        }
296
297        #[inline(always)]
298        fn decode_is_copy() -> bool {
299            false
300        }
301    }
302
303    impl fidl::encoding::ValueTypeMarker for SystemMode {
304        type Borrowed<'a> = Self;
305        #[inline(always)]
306        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
307            *value
308        }
309    }
310
311    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SystemMode {
312        #[inline]
313        unsafe fn encode(
314            self,
315            encoder: &mut fidl::encoding::Encoder<'_, D>,
316            offset: usize,
317            _depth: fidl::encoding::Depth,
318        ) -> fidl::Result<()> {
319            encoder.debug_check_bounds::<Self>(offset);
320            encoder.write_num(self.into_primitive(), offset);
321            Ok(())
322        }
323    }
324
325    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemMode {
326        #[inline(always)]
327        fn new_empty() -> Self {
328            Self::unknown()
329        }
330
331        #[inline]
332        unsafe fn decode(
333            &mut self,
334            decoder: &mut fidl::encoding::Decoder<'_, D>,
335            offset: usize,
336            _depth: fidl::encoding::Depth,
337        ) -> fidl::Result<()> {
338            decoder.debug_check_bounds::<Self>(offset);
339            let prim = decoder.read_num::<u32>(offset);
340
341            *self = Self::from_primitive_allow_unknown(prim);
342            Ok(())
343        }
344    }
345
346    impl fidl::encoding::ValueTypeMarker for ClientConfig {
347        type Borrowed<'a> = &'a Self;
348        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
349            value
350        }
351    }
352
353    unsafe impl fidl::encoding::TypeMarker for ClientConfig {
354        type Owned = Self;
355
356        #[inline(always)]
357        fn inline_align(_context: fidl::encoding::Context) -> usize {
358            8
359        }
360
361        #[inline(always)]
362        fn inline_size(_context: fidl::encoding::Context) -> usize {
363            24
364        }
365    }
366
367    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ClientConfig, D>
368        for &ClientConfig
369    {
370        #[inline]
371        unsafe fn encode(
372            self,
373            encoder: &mut fidl::encoding::Encoder<'_, D>,
374            offset: usize,
375            _depth: fidl::encoding::Depth,
376        ) -> fidl::Result<()> {
377            encoder.debug_check_bounds::<ClientConfig>(offset);
378            // Delegate to tuple encoding.
379            fidl::encoding::Encode::<ClientConfig, D>::encode(
380                (
381                    <fidl::encoding::Vector<ModeMatch, 0> as fidl::encoding::ValueTypeMarker>::borrow(&self.mode_matches),
382                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.default_level),
383                ),
384                encoder, offset, _depth
385            )
386        }
387    }
388    unsafe impl<
389        D: fidl::encoding::ResourceDialect,
390        T0: fidl::encoding::Encode<fidl::encoding::Vector<ModeMatch, 0>, D>,
391        T1: fidl::encoding::Encode<u64, D>,
392    > fidl::encoding::Encode<ClientConfig, D> for (T0, T1)
393    {
394        #[inline]
395        unsafe fn encode(
396            self,
397            encoder: &mut fidl::encoding::Encoder<'_, D>,
398            offset: usize,
399            depth: fidl::encoding::Depth,
400        ) -> fidl::Result<()> {
401            encoder.debug_check_bounds::<ClientConfig>(offset);
402            // Zero out padding regions. There's no need to apply masks
403            // because the unmasked parts will be overwritten by fields.
404            // Write the fields.
405            self.0.encode(encoder, offset + 0, depth)?;
406            self.1.encode(encoder, offset + 16, depth)?;
407            Ok(())
408        }
409    }
410
411    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ClientConfig {
412        #[inline(always)]
413        fn new_empty() -> Self {
414            Self {
415                mode_matches: fidl::new_empty!(fidl::encoding::Vector<ModeMatch, 0>, D),
416                default_level: fidl::new_empty!(u64, D),
417            }
418        }
419
420        #[inline]
421        unsafe fn decode(
422            &mut self,
423            decoder: &mut fidl::encoding::Decoder<'_, D>,
424            offset: usize,
425            _depth: fidl::encoding::Depth,
426        ) -> fidl::Result<()> {
427            decoder.debug_check_bounds::<Self>(offset);
428            // Verify that padding bytes are zero.
429            fidl::decode!(fidl::encoding::Vector<ModeMatch, 0>, D, &mut self.mode_matches, decoder, offset + 0, _depth)?;
430            fidl::decode!(u64, D, &mut self.default_level, decoder, offset + 16, _depth)?;
431            Ok(())
432        }
433    }
434
435    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorGetRequest {
436        type Borrowed<'a> = &'a Self;
437        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
438            value
439        }
440    }
441
442    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorGetRequest {
443        type Owned = Self;
444
445        #[inline(always)]
446        fn inline_align(_context: fidl::encoding::Context) -> usize {
447            4
448        }
449
450        #[inline(always)]
451        fn inline_size(_context: fidl::encoding::Context) -> usize {
452            4
453        }
454    }
455
456    unsafe impl<D: fidl::encoding::ResourceDialect>
457        fidl::encoding::Encode<ClientConfiguratorGetRequest, D> for &ClientConfiguratorGetRequest
458    {
459        #[inline]
460        unsafe fn encode(
461            self,
462            encoder: &mut fidl::encoding::Encoder<'_, D>,
463            offset: usize,
464            _depth: fidl::encoding::Depth,
465        ) -> fidl::Result<()> {
466            encoder.debug_check_bounds::<ClientConfiguratorGetRequest>(offset);
467            // Delegate to tuple encoding.
468            fidl::encoding::Encode::<ClientConfiguratorGetRequest, D>::encode(
469                (
470                    <fidl_fuchsia_power_clientlevel_common::ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
471                ),
472                encoder, offset, _depth
473            )
474        }
475    }
476    unsafe impl<
477        D: fidl::encoding::ResourceDialect,
478        T0: fidl::encoding::Encode<fidl_fuchsia_power_clientlevel_common::ClientType, D>,
479    > fidl::encoding::Encode<ClientConfiguratorGetRequest, D> for (T0,)
480    {
481        #[inline]
482        unsafe fn encode(
483            self,
484            encoder: &mut fidl::encoding::Encoder<'_, D>,
485            offset: usize,
486            depth: fidl::encoding::Depth,
487        ) -> fidl::Result<()> {
488            encoder.debug_check_bounds::<ClientConfiguratorGetRequest>(offset);
489            // Zero out padding regions. There's no need to apply masks
490            // because the unmasked parts will be overwritten by fields.
491            // Write the fields.
492            self.0.encode(encoder, offset + 0, depth)?;
493            Ok(())
494        }
495    }
496
497    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
498        for ClientConfiguratorGetRequest
499    {
500        #[inline(always)]
501        fn new_empty() -> Self {
502            Self {
503                client_type: fidl::new_empty!(fidl_fuchsia_power_clientlevel_common::ClientType, D),
504            }
505        }
506
507        #[inline]
508        unsafe fn decode(
509            &mut self,
510            decoder: &mut fidl::encoding::Decoder<'_, D>,
511            offset: usize,
512            _depth: fidl::encoding::Depth,
513        ) -> fidl::Result<()> {
514            decoder.debug_check_bounds::<Self>(offset);
515            // Verify that padding bytes are zero.
516            fidl::decode!(
517                fidl_fuchsia_power_clientlevel_common::ClientType,
518                D,
519                &mut self.client_type,
520                decoder,
521                offset + 0,
522                _depth
523            )?;
524            Ok(())
525        }
526    }
527
528    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorGetResponse {
529        type Borrowed<'a> = &'a Self;
530        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
531            value
532        }
533    }
534
535    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorGetResponse {
536        type Owned = Self;
537
538        #[inline(always)]
539        fn inline_align(_context: fidl::encoding::Context) -> usize {
540            8
541        }
542
543        #[inline(always)]
544        fn inline_size(_context: fidl::encoding::Context) -> usize {
545            8
546        }
547    }
548
549    unsafe impl<D: fidl::encoding::ResourceDialect>
550        fidl::encoding::Encode<ClientConfiguratorGetResponse, D>
551        for &ClientConfiguratorGetResponse
552    {
553        #[inline]
554        unsafe fn encode(
555            self,
556            encoder: &mut fidl::encoding::Encoder<'_, D>,
557            offset: usize,
558            _depth: fidl::encoding::Depth,
559        ) -> fidl::Result<()> {
560            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
561            // Delegate to tuple encoding.
562            fidl::encoding::Encode::<ClientConfiguratorGetResponse, D>::encode(
563                (<fidl::encoding::Boxed<ClientConfig> as fidl::encoding::ValueTypeMarker>::borrow(
564                    &self.config,
565                ),),
566                encoder,
567                offset,
568                _depth,
569            )
570        }
571    }
572    unsafe impl<
573        D: fidl::encoding::ResourceDialect,
574        T0: fidl::encoding::Encode<fidl::encoding::Boxed<ClientConfig>, D>,
575    > fidl::encoding::Encode<ClientConfiguratorGetResponse, D> for (T0,)
576    {
577        #[inline]
578        unsafe fn encode(
579            self,
580            encoder: &mut fidl::encoding::Encoder<'_, D>,
581            offset: usize,
582            depth: fidl::encoding::Depth,
583        ) -> fidl::Result<()> {
584            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
585            // Zero out padding regions. There's no need to apply masks
586            // because the unmasked parts will be overwritten by fields.
587            // Write the fields.
588            self.0.encode(encoder, offset + 0, depth)?;
589            Ok(())
590        }
591    }
592
593    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
594        for ClientConfiguratorGetResponse
595    {
596        #[inline(always)]
597        fn new_empty() -> Self {
598            Self { config: fidl::new_empty!(fidl::encoding::Boxed<ClientConfig>, D) }
599        }
600
601        #[inline]
602        unsafe fn decode(
603            &mut self,
604            decoder: &mut fidl::encoding::Decoder<'_, D>,
605            offset: usize,
606            _depth: fidl::encoding::Depth,
607        ) -> fidl::Result<()> {
608            decoder.debug_check_bounds::<Self>(offset);
609            // Verify that padding bytes are zero.
610            fidl::decode!(
611                fidl::encoding::Boxed<ClientConfig>,
612                D,
613                &mut self.config,
614                decoder,
615                offset + 0,
616                _depth
617            )?;
618            Ok(())
619        }
620    }
621
622    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorSetRequest {
623        type Borrowed<'a> = &'a Self;
624        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
625            value
626        }
627    }
628
629    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorSetRequest {
630        type Owned = Self;
631
632        #[inline(always)]
633        fn inline_align(_context: fidl::encoding::Context) -> usize {
634            8
635        }
636
637        #[inline(always)]
638        fn inline_size(_context: fidl::encoding::Context) -> usize {
639            32
640        }
641    }
642
643    unsafe impl<D: fidl::encoding::ResourceDialect>
644        fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for &ClientConfiguratorSetRequest
645    {
646        #[inline]
647        unsafe fn encode(
648            self,
649            encoder: &mut fidl::encoding::Encoder<'_, D>,
650            offset: usize,
651            _depth: fidl::encoding::Depth,
652        ) -> fidl::Result<()> {
653            encoder.debug_check_bounds::<ClientConfiguratorSetRequest>(offset);
654            // Delegate to tuple encoding.
655            fidl::encoding::Encode::<ClientConfiguratorSetRequest, D>::encode(
656                (
657                    <fidl_fuchsia_power_clientlevel_common::ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
658                    <ClientConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
659                ),
660                encoder, offset, _depth
661            )
662        }
663    }
664    unsafe impl<
665        D: fidl::encoding::ResourceDialect,
666        T0: fidl::encoding::Encode<fidl_fuchsia_power_clientlevel_common::ClientType, D>,
667        T1: fidl::encoding::Encode<ClientConfig, D>,
668    > fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for (T0, T1)
669    {
670        #[inline]
671        unsafe fn encode(
672            self,
673            encoder: &mut fidl::encoding::Encoder<'_, D>,
674            offset: usize,
675            depth: fidl::encoding::Depth,
676        ) -> fidl::Result<()> {
677            encoder.debug_check_bounds::<ClientConfiguratorSetRequest>(offset);
678            // Zero out padding regions. There's no need to apply masks
679            // because the unmasked parts will be overwritten by fields.
680            unsafe {
681                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
682                (ptr as *mut u64).write_unaligned(0);
683            }
684            // Write the fields.
685            self.0.encode(encoder, offset + 0, depth)?;
686            self.1.encode(encoder, offset + 8, depth)?;
687            Ok(())
688        }
689    }
690
691    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
692        for ClientConfiguratorSetRequest
693    {
694        #[inline(always)]
695        fn new_empty() -> Self {
696            Self {
697                client_type: fidl::new_empty!(fidl_fuchsia_power_clientlevel_common::ClientType, D),
698                config: fidl::new_empty!(ClientConfig, D),
699            }
700        }
701
702        #[inline]
703        unsafe fn decode(
704            &mut self,
705            decoder: &mut fidl::encoding::Decoder<'_, D>,
706            offset: usize,
707            _depth: fidl::encoding::Depth,
708        ) -> fidl::Result<()> {
709            decoder.debug_check_bounds::<Self>(offset);
710            // Verify that padding bytes are zero.
711            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
712            let padval = unsafe { (ptr as *const u64).read_unaligned() };
713            let mask = 0xffffffff00000000u64;
714            let maskedval = padval & mask;
715            if maskedval != 0 {
716                return Err(fidl::Error::NonZeroPadding {
717                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
718                });
719            }
720            fidl::decode!(
721                fidl_fuchsia_power_clientlevel_common::ClientType,
722                D,
723                &mut self.client_type,
724                decoder,
725                offset + 0,
726                _depth
727            )?;
728            fidl::decode!(ClientConfig, D, &mut self.config, decoder, offset + 8, _depth)?;
729            Ok(())
730        }
731    }
732
733    impl fidl::encoding::ValueTypeMarker for ModeMatch {
734        type Borrowed<'a> = &'a Self;
735        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
736            value
737        }
738    }
739
740    unsafe impl fidl::encoding::TypeMarker for ModeMatch {
741        type Owned = Self;
742
743        #[inline(always)]
744        fn inline_align(_context: fidl::encoding::Context) -> usize {
745            8
746        }
747
748        #[inline(always)]
749        fn inline_size(_context: fidl::encoding::Context) -> usize {
750            16
751        }
752    }
753
754    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ModeMatch, D>
755        for &ModeMatch
756    {
757        #[inline]
758        unsafe fn encode(
759            self,
760            encoder: &mut fidl::encoding::Encoder<'_, D>,
761            offset: usize,
762            _depth: fidl::encoding::Depth,
763        ) -> fidl::Result<()> {
764            encoder.debug_check_bounds::<ModeMatch>(offset);
765            // Delegate to tuple encoding.
766            fidl::encoding::Encode::<ModeMatch, D>::encode(
767                (
768                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
769                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.power_level),
770                ),
771                encoder,
772                offset,
773                _depth,
774            )
775        }
776    }
777    unsafe impl<
778        D: fidl::encoding::ResourceDialect,
779        T0: fidl::encoding::Encode<SystemMode, D>,
780        T1: fidl::encoding::Encode<u64, D>,
781    > fidl::encoding::Encode<ModeMatch, D> for (T0, T1)
782    {
783        #[inline]
784        unsafe fn encode(
785            self,
786            encoder: &mut fidl::encoding::Encoder<'_, D>,
787            offset: usize,
788            depth: fidl::encoding::Depth,
789        ) -> fidl::Result<()> {
790            encoder.debug_check_bounds::<ModeMatch>(offset);
791            // Zero out padding regions. There's no need to apply masks
792            // because the unmasked parts will be overwritten by fields.
793            unsafe {
794                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
795                (ptr as *mut u64).write_unaligned(0);
796            }
797            // Write the fields.
798            self.0.encode(encoder, offset + 0, depth)?;
799            self.1.encode(encoder, offset + 8, depth)?;
800            Ok(())
801        }
802    }
803
804    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeMatch {
805        #[inline(always)]
806        fn new_empty() -> Self {
807            Self { mode: fidl::new_empty!(SystemMode, D), power_level: fidl::new_empty!(u64, D) }
808        }
809
810        #[inline]
811        unsafe fn decode(
812            &mut self,
813            decoder: &mut fidl::encoding::Decoder<'_, D>,
814            offset: usize,
815            _depth: fidl::encoding::Depth,
816        ) -> fidl::Result<()> {
817            decoder.debug_check_bounds::<Self>(offset);
818            // Verify that padding bytes are zero.
819            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
820            let padval = unsafe { (ptr as *const u64).read_unaligned() };
821            let mask = 0xffffffff00000000u64;
822            let maskedval = padval & mask;
823            if maskedval != 0 {
824                return Err(fidl::Error::NonZeroPadding {
825                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
826                });
827            }
828            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
829            fidl::decode!(u64, D, &mut self.power_level, decoder, offset + 8, _depth)?;
830            Ok(())
831        }
832    }
833
834    impl fidl::encoding::ValueTypeMarker for RequesterRequestRequest {
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 RequesterRequestRequest {
842        type Owned = Self;
843
844        #[inline(always)]
845        fn inline_align(_context: fidl::encoding::Context) -> usize {
846            4
847        }
848
849        #[inline(always)]
850        fn inline_size(_context: fidl::encoding::Context) -> usize {
851            8
852        }
853    }
854
855    unsafe impl<D: fidl::encoding::ResourceDialect>
856        fidl::encoding::Encode<RequesterRequestRequest, D> for &RequesterRequestRequest
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::<RequesterRequestRequest>(offset);
866            // Delegate to tuple encoding.
867            fidl::encoding::Encode::<RequesterRequestRequest, D>::encode(
868                (
869                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
870                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.set),
871                ),
872                encoder,
873                offset,
874                _depth,
875            )
876        }
877    }
878    unsafe impl<
879        D: fidl::encoding::ResourceDialect,
880        T0: fidl::encoding::Encode<SystemMode, D>,
881        T1: fidl::encoding::Encode<bool, D>,
882    > fidl::encoding::Encode<RequesterRequestRequest, D> for (T0, T1)
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::<RequesterRequestRequest>(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(4);
896                (ptr as *mut u32).write_unaligned(0);
897            }
898            // Write the fields.
899            self.0.encode(encoder, offset + 0, depth)?;
900            self.1.encode(encoder, offset + 4, depth)?;
901            Ok(())
902        }
903    }
904
905    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
906        for RequesterRequestRequest
907    {
908        #[inline(always)]
909        fn new_empty() -> Self {
910            Self { mode: fidl::new_empty!(SystemMode, D), set: fidl::new_empty!(bool, D) }
911        }
912
913        #[inline]
914        unsafe fn decode(
915            &mut self,
916            decoder: &mut fidl::encoding::Decoder<'_, D>,
917            offset: usize,
918            _depth: fidl::encoding::Depth,
919        ) -> fidl::Result<()> {
920            decoder.debug_check_bounds::<Self>(offset);
921            // Verify that padding bytes are zero.
922            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
923            let padval = unsafe { (ptr as *const u32).read_unaligned() };
924            let mask = 0xffffff00u32;
925            let maskedval = padval & mask;
926            if maskedval != 0 {
927                return Err(fidl::Error::NonZeroPadding {
928                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
929                });
930            }
931            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
932            fidl::decode!(bool, D, &mut self.set, decoder, offset + 4, _depth)?;
933            Ok(())
934        }
935    }
936}