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!(
504                    fidl_fuchsia_power_clientlevel__common::ClientType,
505                    D
506                ),
507            }
508        }
509
510        #[inline]
511        unsafe fn decode(
512            &mut self,
513            decoder: &mut fidl::encoding::Decoder<'_, D>,
514            offset: usize,
515            _depth: fidl::encoding::Depth,
516        ) -> fidl::Result<()> {
517            decoder.debug_check_bounds::<Self>(offset);
518            // Verify that padding bytes are zero.
519            fidl::decode!(
520                fidl_fuchsia_power_clientlevel__common::ClientType,
521                D,
522                &mut self.client_type,
523                decoder,
524                offset + 0,
525                _depth
526            )?;
527            Ok(())
528        }
529    }
530
531    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorGetResponse {
532        type Borrowed<'a> = &'a Self;
533        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
534            value
535        }
536    }
537
538    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorGetResponse {
539        type Owned = Self;
540
541        #[inline(always)]
542        fn inline_align(_context: fidl::encoding::Context) -> usize {
543            8
544        }
545
546        #[inline(always)]
547        fn inline_size(_context: fidl::encoding::Context) -> usize {
548            8
549        }
550    }
551
552    unsafe impl<D: fidl::encoding::ResourceDialect>
553        fidl::encoding::Encode<ClientConfiguratorGetResponse, D>
554        for &ClientConfiguratorGetResponse
555    {
556        #[inline]
557        unsafe fn encode(
558            self,
559            encoder: &mut fidl::encoding::Encoder<'_, D>,
560            offset: usize,
561            _depth: fidl::encoding::Depth,
562        ) -> fidl::Result<()> {
563            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
564            // Delegate to tuple encoding.
565            fidl::encoding::Encode::<ClientConfiguratorGetResponse, D>::encode(
566                (<fidl::encoding::Boxed<ClientConfig> as fidl::encoding::ValueTypeMarker>::borrow(
567                    &self.config,
568                ),),
569                encoder,
570                offset,
571                _depth,
572            )
573        }
574    }
575    unsafe impl<
576            D: fidl::encoding::ResourceDialect,
577            T0: fidl::encoding::Encode<fidl::encoding::Boxed<ClientConfig>, D>,
578        > fidl::encoding::Encode<ClientConfiguratorGetResponse, D> for (T0,)
579    {
580        #[inline]
581        unsafe fn encode(
582            self,
583            encoder: &mut fidl::encoding::Encoder<'_, D>,
584            offset: usize,
585            depth: fidl::encoding::Depth,
586        ) -> fidl::Result<()> {
587            encoder.debug_check_bounds::<ClientConfiguratorGetResponse>(offset);
588            // Zero out padding regions. There's no need to apply masks
589            // because the unmasked parts will be overwritten by fields.
590            // Write the fields.
591            self.0.encode(encoder, offset + 0, depth)?;
592            Ok(())
593        }
594    }
595
596    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
597        for ClientConfiguratorGetResponse
598    {
599        #[inline(always)]
600        fn new_empty() -> Self {
601            Self { config: fidl::new_empty!(fidl::encoding::Boxed<ClientConfig>, D) }
602        }
603
604        #[inline]
605        unsafe fn decode(
606            &mut self,
607            decoder: &mut fidl::encoding::Decoder<'_, D>,
608            offset: usize,
609            _depth: fidl::encoding::Depth,
610        ) -> fidl::Result<()> {
611            decoder.debug_check_bounds::<Self>(offset);
612            // Verify that padding bytes are zero.
613            fidl::decode!(
614                fidl::encoding::Boxed<ClientConfig>,
615                D,
616                &mut self.config,
617                decoder,
618                offset + 0,
619                _depth
620            )?;
621            Ok(())
622        }
623    }
624
625    impl fidl::encoding::ValueTypeMarker for ClientConfiguratorSetRequest {
626        type Borrowed<'a> = &'a Self;
627        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
628            value
629        }
630    }
631
632    unsafe impl fidl::encoding::TypeMarker for ClientConfiguratorSetRequest {
633        type Owned = Self;
634
635        #[inline(always)]
636        fn inline_align(_context: fidl::encoding::Context) -> usize {
637            8
638        }
639
640        #[inline(always)]
641        fn inline_size(_context: fidl::encoding::Context) -> usize {
642            32
643        }
644    }
645
646    unsafe impl<D: fidl::encoding::ResourceDialect>
647        fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for &ClientConfiguratorSetRequest
648    {
649        #[inline]
650        unsafe fn encode(
651            self,
652            encoder: &mut fidl::encoding::Encoder<'_, D>,
653            offset: usize,
654            _depth: fidl::encoding::Depth,
655        ) -> fidl::Result<()> {
656            encoder.debug_check_bounds::<ClientConfiguratorSetRequest>(offset);
657            // Delegate to tuple encoding.
658            fidl::encoding::Encode::<ClientConfiguratorSetRequest, D>::encode(
659                (
660                    <fidl_fuchsia_power_clientlevel__common::ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
661                    <ClientConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
662                ),
663                encoder, offset, _depth
664            )
665        }
666    }
667    unsafe impl<
668            D: fidl::encoding::ResourceDialect,
669            T0: fidl::encoding::Encode<fidl_fuchsia_power_clientlevel__common::ClientType, D>,
670            T1: fidl::encoding::Encode<ClientConfig, D>,
671        > fidl::encoding::Encode<ClientConfiguratorSetRequest, D> for (T0, T1)
672    {
673        #[inline]
674        unsafe fn encode(
675            self,
676            encoder: &mut fidl::encoding::Encoder<'_, D>,
677            offset: usize,
678            depth: fidl::encoding::Depth,
679        ) -> fidl::Result<()> {
680            encoder.debug_check_bounds::<ClientConfiguratorSetRequest>(offset);
681            // Zero out padding regions. There's no need to apply masks
682            // because the unmasked parts will be overwritten by fields.
683            unsafe {
684                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
685                (ptr as *mut u64).write_unaligned(0);
686            }
687            // Write the fields.
688            self.0.encode(encoder, offset + 0, depth)?;
689            self.1.encode(encoder, offset + 8, depth)?;
690            Ok(())
691        }
692    }
693
694    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
695        for ClientConfiguratorSetRequest
696    {
697        #[inline(always)]
698        fn new_empty() -> Self {
699            Self {
700                client_type: fidl::new_empty!(
701                    fidl_fuchsia_power_clientlevel__common::ClientType,
702                    D
703                ),
704                config: fidl::new_empty!(ClientConfig, D),
705            }
706        }
707
708        #[inline]
709        unsafe fn decode(
710            &mut self,
711            decoder: &mut fidl::encoding::Decoder<'_, D>,
712            offset: usize,
713            _depth: fidl::encoding::Depth,
714        ) -> fidl::Result<()> {
715            decoder.debug_check_bounds::<Self>(offset);
716            // Verify that padding bytes are zero.
717            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
718            let padval = unsafe { (ptr as *const u64).read_unaligned() };
719            let mask = 0xffffffff00000000u64;
720            let maskedval = padval & mask;
721            if maskedval != 0 {
722                return Err(fidl::Error::NonZeroPadding {
723                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
724                });
725            }
726            fidl::decode!(
727                fidl_fuchsia_power_clientlevel__common::ClientType,
728                D,
729                &mut self.client_type,
730                decoder,
731                offset + 0,
732                _depth
733            )?;
734            fidl::decode!(ClientConfig, D, &mut self.config, decoder, offset + 8, _depth)?;
735            Ok(())
736        }
737    }
738
739    impl fidl::encoding::ValueTypeMarker for ModeMatch {
740        type Borrowed<'a> = &'a Self;
741        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
742            value
743        }
744    }
745
746    unsafe impl fidl::encoding::TypeMarker for ModeMatch {
747        type Owned = Self;
748
749        #[inline(always)]
750        fn inline_align(_context: fidl::encoding::Context) -> usize {
751            8
752        }
753
754        #[inline(always)]
755        fn inline_size(_context: fidl::encoding::Context) -> usize {
756            16
757        }
758    }
759
760    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ModeMatch, D>
761        for &ModeMatch
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::<ModeMatch>(offset);
771            // Delegate to tuple encoding.
772            fidl::encoding::Encode::<ModeMatch, D>::encode(
773                (
774                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
775                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.power_level),
776                ),
777                encoder,
778                offset,
779                _depth,
780            )
781        }
782    }
783    unsafe impl<
784            D: fidl::encoding::ResourceDialect,
785            T0: fidl::encoding::Encode<SystemMode, D>,
786            T1: fidl::encoding::Encode<u64, D>,
787        > fidl::encoding::Encode<ModeMatch, D> for (T0, T1)
788    {
789        #[inline]
790        unsafe fn encode(
791            self,
792            encoder: &mut fidl::encoding::Encoder<'_, D>,
793            offset: usize,
794            depth: fidl::encoding::Depth,
795        ) -> fidl::Result<()> {
796            encoder.debug_check_bounds::<ModeMatch>(offset);
797            // Zero out padding regions. There's no need to apply masks
798            // because the unmasked parts will be overwritten by fields.
799            unsafe {
800                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
801                (ptr as *mut u64).write_unaligned(0);
802            }
803            // Write the fields.
804            self.0.encode(encoder, offset + 0, depth)?;
805            self.1.encode(encoder, offset + 8, depth)?;
806            Ok(())
807        }
808    }
809
810    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ModeMatch {
811        #[inline(always)]
812        fn new_empty() -> Self {
813            Self { mode: fidl::new_empty!(SystemMode, D), power_level: 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            // Verify that padding bytes are zero.
825            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
826            let padval = unsafe { (ptr as *const u64).read_unaligned() };
827            let mask = 0xffffffff00000000u64;
828            let maskedval = padval & mask;
829            if maskedval != 0 {
830                return Err(fidl::Error::NonZeroPadding {
831                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
832                });
833            }
834            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
835            fidl::decode!(u64, D, &mut self.power_level, decoder, offset + 8, _depth)?;
836            Ok(())
837        }
838    }
839
840    impl fidl::encoding::ValueTypeMarker for RequesterRequestRequest {
841        type Borrowed<'a> = &'a Self;
842        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
843            value
844        }
845    }
846
847    unsafe impl fidl::encoding::TypeMarker for RequesterRequestRequest {
848        type Owned = Self;
849
850        #[inline(always)]
851        fn inline_align(_context: fidl::encoding::Context) -> usize {
852            4
853        }
854
855        #[inline(always)]
856        fn inline_size(_context: fidl::encoding::Context) -> usize {
857            8
858        }
859    }
860
861    unsafe impl<D: fidl::encoding::ResourceDialect>
862        fidl::encoding::Encode<RequesterRequestRequest, D> for &RequesterRequestRequest
863    {
864        #[inline]
865        unsafe fn encode(
866            self,
867            encoder: &mut fidl::encoding::Encoder<'_, D>,
868            offset: usize,
869            _depth: fidl::encoding::Depth,
870        ) -> fidl::Result<()> {
871            encoder.debug_check_bounds::<RequesterRequestRequest>(offset);
872            // Delegate to tuple encoding.
873            fidl::encoding::Encode::<RequesterRequestRequest, D>::encode(
874                (
875                    <SystemMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
876                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.set),
877                ),
878                encoder,
879                offset,
880                _depth,
881            )
882        }
883    }
884    unsafe impl<
885            D: fidl::encoding::ResourceDialect,
886            T0: fidl::encoding::Encode<SystemMode, D>,
887            T1: fidl::encoding::Encode<bool, D>,
888        > fidl::encoding::Encode<RequesterRequestRequest, D> for (T0, T1)
889    {
890        #[inline]
891        unsafe fn encode(
892            self,
893            encoder: &mut fidl::encoding::Encoder<'_, D>,
894            offset: usize,
895            depth: fidl::encoding::Depth,
896        ) -> fidl::Result<()> {
897            encoder.debug_check_bounds::<RequesterRequestRequest>(offset);
898            // Zero out padding regions. There's no need to apply masks
899            // because the unmasked parts will be overwritten by fields.
900            unsafe {
901                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
902                (ptr as *mut u32).write_unaligned(0);
903            }
904            // Write the fields.
905            self.0.encode(encoder, offset + 0, depth)?;
906            self.1.encode(encoder, offset + 4, depth)?;
907            Ok(())
908        }
909    }
910
911    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
912        for RequesterRequestRequest
913    {
914        #[inline(always)]
915        fn new_empty() -> Self {
916            Self { mode: fidl::new_empty!(SystemMode, D), set: fidl::new_empty!(bool, D) }
917        }
918
919        #[inline]
920        unsafe fn decode(
921            &mut self,
922            decoder: &mut fidl::encoding::Decoder<'_, D>,
923            offset: usize,
924            _depth: fidl::encoding::Depth,
925        ) -> fidl::Result<()> {
926            decoder.debug_check_bounds::<Self>(offset);
927            // Verify that padding bytes are zero.
928            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
929            let padval = unsafe { (ptr as *const u32).read_unaligned() };
930            let mask = 0xffffff00u32;
931            let maskedval = padval & mask;
932            if maskedval != 0 {
933                return Err(fidl::Error::NonZeroPadding {
934                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
935                });
936            }
937            fidl::decode!(SystemMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
938            fidl::decode!(bool, D, &mut self.set, decoder, offset + 4, _depth)?;
939            Ok(())
940        }
941    }
942}