fidl_fuchsia_thermal__common/
fidl_fuchsia_thermal__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/// A string that represents the type of client using the protocol.
12///
13/// `ClientType` is used as a parameter to [`ClientStateConnector.Connect`] to
14/// connect a [`ClientStateWatcher`] to the thermal state of the desired client
15/// type.
16///
17/// A `ClientType` value should describe the type of subsystem a client
18/// represents and must exactly (case-sensitive) match with a client entry found
19/// in the central thermal configuration. Typical examples include "audio",
20/// "wifi", etc.
21pub type ClientType = String;
22
23/// The maximum value of the normalized thermal load. This value bounds the width (and therefore
24/// also the precision) of the normalized thermal limiting range starting from 0. Trip points must
25/// be specified within this range.
26pub const MAX_THERMAL_LOAD: u32 = 100;
27
28/// Errors returned from calls to `SensorManager.ClearTemperatureOverrideError`.
29#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
30pub enum ClearTemperatureOverrideError {
31    Internal,
32    SensorNotFound,
33    #[doc(hidden)]
34    __SourceBreaking {
35        unknown_ordinal: u32,
36    },
37}
38
39/// Pattern that matches an unknown `ClearTemperatureOverrideError` member.
40#[macro_export]
41macro_rules! ClearTemperatureOverrideErrorUnknown {
42    () => {
43        _
44    };
45}
46
47impl ClearTemperatureOverrideError {
48    #[inline]
49    pub fn from_primitive(prim: u32) -> Option<Self> {
50        match prim {
51            1 => Some(Self::Internal),
52            2 => Some(Self::SensorNotFound),
53            _ => None,
54        }
55    }
56
57    #[inline]
58    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
59        match prim {
60            1 => Self::Internal,
61            2 => Self::SensorNotFound,
62            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
63        }
64    }
65
66    #[inline]
67    pub fn unknown() -> Self {
68        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
69    }
70
71    #[inline]
72    pub const fn into_primitive(self) -> u32 {
73        match self {
74            Self::Internal => 1,
75            Self::SensorNotFound => 2,
76            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
77        }
78    }
79
80    #[inline]
81    pub fn is_unknown(&self) -> bool {
82        match self {
83            Self::__SourceBreaking { unknown_ordinal: _ } => true,
84            _ => false,
85        }
86    }
87}
88
89/// Errors returned from calls to `SensorManager.ConnectError`.
90#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
91pub enum ConnectError {
92    Internal,
93    InvalidArguments,
94    SensorNotFound,
95    #[doc(hidden)]
96    __SourceBreaking {
97        unknown_ordinal: u32,
98    },
99}
100
101/// Pattern that matches an unknown `ConnectError` member.
102#[macro_export]
103macro_rules! ConnectErrorUnknown {
104    () => {
105        _
106    };
107}
108
109impl ConnectError {
110    #[inline]
111    pub fn from_primitive(prim: u32) -> Option<Self> {
112        match prim {
113            1 => Some(Self::Internal),
114            2 => Some(Self::InvalidArguments),
115            3 => Some(Self::SensorNotFound),
116            _ => None,
117        }
118    }
119
120    #[inline]
121    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
122        match prim {
123            1 => Self::Internal,
124            2 => Self::InvalidArguments,
125            3 => Self::SensorNotFound,
126            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
127        }
128    }
129
130    #[inline]
131    pub fn unknown() -> Self {
132        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
133    }
134
135    #[inline]
136    pub const fn into_primitive(self) -> u32 {
137        match self {
138            Self::Internal => 1,
139            Self::InvalidArguments => 2,
140            Self::SensorNotFound => 3,
141            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
142        }
143    }
144
145    #[inline]
146    pub fn is_unknown(&self) -> bool {
147        match self {
148            Self::__SourceBreaking { unknown_ordinal: _ } => true,
149            _ => false,
150        }
151    }
152}
153
154/// Errors returned from calls to `SensorManager.SetTemperatureOverride`.
155#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
156pub enum SetTemperatureOverrideError {
157    Internal,
158    SensorNotFound,
159    #[doc(hidden)]
160    __SourceBreaking {
161        unknown_ordinal: u32,
162    },
163}
164
165/// Pattern that matches an unknown `SetTemperatureOverrideError` member.
166#[macro_export]
167macro_rules! SetTemperatureOverrideErrorUnknown {
168    () => {
169        _
170    };
171}
172
173impl SetTemperatureOverrideError {
174    #[inline]
175    pub fn from_primitive(prim: u32) -> Option<Self> {
176        match prim {
177            1 => Some(Self::Internal),
178            2 => Some(Self::SensorNotFound),
179            _ => None,
180        }
181    }
182
183    #[inline]
184    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
185        match prim {
186            1 => Self::Internal,
187            2 => Self::SensorNotFound,
188            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
189        }
190    }
191
192    #[inline]
193    pub fn unknown() -> Self {
194        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
195    }
196
197    #[inline]
198    pub const fn into_primitive(self) -> u32 {
199        match self {
200            Self::Internal => 1,
201            Self::SensorNotFound => 2,
202            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
203        }
204    }
205
206    #[inline]
207    pub fn is_unknown(&self) -> bool {
208        match self {
209            Self::__SourceBreaking { unknown_ordinal: _ } => true,
210            _ => false,
211        }
212    }
213}
214
215#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
216#[repr(C)]
217pub struct ClientStateWatcherWatchResponse {
218    pub state: u64,
219}
220
221impl fidl::Persistable for ClientStateWatcherWatchResponse {}
222
223#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
224pub struct SensorManagerClearTemperatureOverrideRequest {
225    pub name: String,
226}
227
228impl fidl::Persistable for SensorManagerClearTemperatureOverrideRequest {}
229
230#[derive(Clone, Debug, PartialEq, PartialOrd)]
231pub struct SensorManagerSetTemperatureOverrideRequest {
232    pub name: String,
233    pub override_temperature: f32,
234}
235
236impl fidl::Persistable for SensorManagerSetTemperatureOverrideRequest {}
237
238#[derive(Clone, Debug, PartialEq)]
239pub struct SensorManagerListSensorsResponse {
240    pub sensors: Vec<SensorInfo>,
241}
242
243impl fidl::Persistable for SensorManagerListSensorsResponse {}
244
245/// Information about a sensor.
246#[derive(Clone, Debug, Default, PartialEq)]
247pub struct SensorInfo {
248    pub name: Option<String>,
249    #[doc(hidden)]
250    pub __source_breaking: fidl::marker::SourceBreaking,
251}
252
253impl fidl::Persistable for SensorInfo {}
254
255pub mod client_state_connector_ordinals {
256    pub const CONNECT: u64 = 0x65abd3ba57ddaa1d;
257}
258
259pub mod client_state_watcher_ordinals {
260    pub const WATCH: u64 = 0x44831316a9942f7e;
261}
262
263pub mod sensor_manager_ordinals {
264    pub const LIST_SENSORS: u64 = 0x4407236d8bad1a9b;
265    pub const SET_TEMPERATURE_OVERRIDE: u64 = 0x13abb6faff00a238;
266    pub const CLEAR_TEMPERATURE_OVERRIDE: u64 = 0x3ad5b3a009f687cb;
267    pub const CONNECT: u64 = 0x76abcbb8819f26bf;
268}
269
270mod internal {
271    use super::*;
272    unsafe impl fidl::encoding::TypeMarker for ClearTemperatureOverrideError {
273        type Owned = Self;
274
275        #[inline(always)]
276        fn inline_align(_context: fidl::encoding::Context) -> usize {
277            std::mem::align_of::<u32>()
278        }
279
280        #[inline(always)]
281        fn inline_size(_context: fidl::encoding::Context) -> usize {
282            std::mem::size_of::<u32>()
283        }
284
285        #[inline(always)]
286        fn encode_is_copy() -> bool {
287            false
288        }
289
290        #[inline(always)]
291        fn decode_is_copy() -> bool {
292            false
293        }
294    }
295
296    impl fidl::encoding::ValueTypeMarker for ClearTemperatureOverrideError {
297        type Borrowed<'a> = Self;
298        #[inline(always)]
299        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
300            *value
301        }
302    }
303
304    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
305        for ClearTemperatureOverrideError
306    {
307        #[inline]
308        unsafe fn encode(
309            self,
310            encoder: &mut fidl::encoding::Encoder<'_, D>,
311            offset: usize,
312            _depth: fidl::encoding::Depth,
313        ) -> fidl::Result<()> {
314            encoder.debug_check_bounds::<Self>(offset);
315            encoder.write_num(self.into_primitive(), offset);
316            Ok(())
317        }
318    }
319
320    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
321        for ClearTemperatureOverrideError
322    {
323        #[inline(always)]
324        fn new_empty() -> Self {
325            Self::unknown()
326        }
327
328        #[inline]
329        unsafe fn decode(
330            &mut self,
331            decoder: &mut fidl::encoding::Decoder<'_, D>,
332            offset: usize,
333            _depth: fidl::encoding::Depth,
334        ) -> fidl::Result<()> {
335            decoder.debug_check_bounds::<Self>(offset);
336            let prim = decoder.read_num::<u32>(offset);
337
338            *self = Self::from_primitive_allow_unknown(prim);
339            Ok(())
340        }
341    }
342    unsafe impl fidl::encoding::TypeMarker for ConnectError {
343        type Owned = Self;
344
345        #[inline(always)]
346        fn inline_align(_context: fidl::encoding::Context) -> usize {
347            std::mem::align_of::<u32>()
348        }
349
350        #[inline(always)]
351        fn inline_size(_context: fidl::encoding::Context) -> usize {
352            std::mem::size_of::<u32>()
353        }
354
355        #[inline(always)]
356        fn encode_is_copy() -> bool {
357            false
358        }
359
360        #[inline(always)]
361        fn decode_is_copy() -> bool {
362            false
363        }
364    }
365
366    impl fidl::encoding::ValueTypeMarker for ConnectError {
367        type Borrowed<'a> = Self;
368        #[inline(always)]
369        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
370            *value
371        }
372    }
373
374    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ConnectError {
375        #[inline]
376        unsafe fn encode(
377            self,
378            encoder: &mut fidl::encoding::Encoder<'_, D>,
379            offset: usize,
380            _depth: fidl::encoding::Depth,
381        ) -> fidl::Result<()> {
382            encoder.debug_check_bounds::<Self>(offset);
383            encoder.write_num(self.into_primitive(), offset);
384            Ok(())
385        }
386    }
387
388    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectError {
389        #[inline(always)]
390        fn new_empty() -> Self {
391            Self::unknown()
392        }
393
394        #[inline]
395        unsafe fn decode(
396            &mut self,
397            decoder: &mut fidl::encoding::Decoder<'_, D>,
398            offset: usize,
399            _depth: fidl::encoding::Depth,
400        ) -> fidl::Result<()> {
401            decoder.debug_check_bounds::<Self>(offset);
402            let prim = decoder.read_num::<u32>(offset);
403
404            *self = Self::from_primitive_allow_unknown(prim);
405            Ok(())
406        }
407    }
408    unsafe impl fidl::encoding::TypeMarker for SetTemperatureOverrideError {
409        type Owned = Self;
410
411        #[inline(always)]
412        fn inline_align(_context: fidl::encoding::Context) -> usize {
413            std::mem::align_of::<u32>()
414        }
415
416        #[inline(always)]
417        fn inline_size(_context: fidl::encoding::Context) -> usize {
418            std::mem::size_of::<u32>()
419        }
420
421        #[inline(always)]
422        fn encode_is_copy() -> bool {
423            false
424        }
425
426        #[inline(always)]
427        fn decode_is_copy() -> bool {
428            false
429        }
430    }
431
432    impl fidl::encoding::ValueTypeMarker for SetTemperatureOverrideError {
433        type Borrowed<'a> = Self;
434        #[inline(always)]
435        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
436            *value
437        }
438    }
439
440    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
441        for SetTemperatureOverrideError
442    {
443        #[inline]
444        unsafe fn encode(
445            self,
446            encoder: &mut fidl::encoding::Encoder<'_, D>,
447            offset: usize,
448            _depth: fidl::encoding::Depth,
449        ) -> fidl::Result<()> {
450            encoder.debug_check_bounds::<Self>(offset);
451            encoder.write_num(self.into_primitive(), offset);
452            Ok(())
453        }
454    }
455
456    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
457        for SetTemperatureOverrideError
458    {
459        #[inline(always)]
460        fn new_empty() -> Self {
461            Self::unknown()
462        }
463
464        #[inline]
465        unsafe fn decode(
466            &mut self,
467            decoder: &mut fidl::encoding::Decoder<'_, D>,
468            offset: usize,
469            _depth: fidl::encoding::Depth,
470        ) -> fidl::Result<()> {
471            decoder.debug_check_bounds::<Self>(offset);
472            let prim = decoder.read_num::<u32>(offset);
473
474            *self = Self::from_primitive_allow_unknown(prim);
475            Ok(())
476        }
477    }
478
479    impl fidl::encoding::ValueTypeMarker for ClientStateWatcherWatchResponse {
480        type Borrowed<'a> = &'a Self;
481        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
482            value
483        }
484    }
485
486    unsafe impl fidl::encoding::TypeMarker for ClientStateWatcherWatchResponse {
487        type Owned = Self;
488
489        #[inline(always)]
490        fn inline_align(_context: fidl::encoding::Context) -> usize {
491            8
492        }
493
494        #[inline(always)]
495        fn inline_size(_context: fidl::encoding::Context) -> usize {
496            8
497        }
498        #[inline(always)]
499        fn encode_is_copy() -> bool {
500            true
501        }
502
503        #[inline(always)]
504        fn decode_is_copy() -> bool {
505            true
506        }
507    }
508
509    unsafe impl<D: fidl::encoding::ResourceDialect>
510        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D>
511        for &ClientStateWatcherWatchResponse
512    {
513        #[inline]
514        unsafe fn encode(
515            self,
516            encoder: &mut fidl::encoding::Encoder<'_, D>,
517            offset: usize,
518            _depth: fidl::encoding::Depth,
519        ) -> fidl::Result<()> {
520            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
521            unsafe {
522                // Copy the object into the buffer.
523                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
524                (buf_ptr as *mut ClientStateWatcherWatchResponse)
525                    .write_unaligned((self as *const ClientStateWatcherWatchResponse).read());
526                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
527                // done second because the memcpy will write garbage to these bytes.
528            }
529            Ok(())
530        }
531    }
532    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
533        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D> for (T0,)
534    {
535        #[inline]
536        unsafe fn encode(
537            self,
538            encoder: &mut fidl::encoding::Encoder<'_, D>,
539            offset: usize,
540            depth: fidl::encoding::Depth,
541        ) -> fidl::Result<()> {
542            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
543            // Zero out padding regions. There's no need to apply masks
544            // because the unmasked parts will be overwritten by fields.
545            // Write the fields.
546            self.0.encode(encoder, offset + 0, depth)?;
547            Ok(())
548        }
549    }
550
551    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
552        for ClientStateWatcherWatchResponse
553    {
554        #[inline(always)]
555        fn new_empty() -> Self {
556            Self { state: fidl::new_empty!(u64, D) }
557        }
558
559        #[inline]
560        unsafe fn decode(
561            &mut self,
562            decoder: &mut fidl::encoding::Decoder<'_, D>,
563            offset: usize,
564            _depth: fidl::encoding::Depth,
565        ) -> fidl::Result<()> {
566            decoder.debug_check_bounds::<Self>(offset);
567            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
568            // Verify that padding bytes are zero.
569            // Copy from the buffer into the object.
570            unsafe {
571                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
572            }
573            Ok(())
574        }
575    }
576
577    impl fidl::encoding::ValueTypeMarker for SensorManagerClearTemperatureOverrideRequest {
578        type Borrowed<'a> = &'a Self;
579        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
580            value
581        }
582    }
583
584    unsafe impl fidl::encoding::TypeMarker for SensorManagerClearTemperatureOverrideRequest {
585        type Owned = Self;
586
587        #[inline(always)]
588        fn inline_align(_context: fidl::encoding::Context) -> usize {
589            8
590        }
591
592        #[inline(always)]
593        fn inline_size(_context: fidl::encoding::Context) -> usize {
594            16
595        }
596    }
597
598    unsafe impl<D: fidl::encoding::ResourceDialect>
599        fidl::encoding::Encode<SensorManagerClearTemperatureOverrideRequest, D>
600        for &SensorManagerClearTemperatureOverrideRequest
601    {
602        #[inline]
603        unsafe fn encode(
604            self,
605            encoder: &mut fidl::encoding::Encoder<'_, D>,
606            offset: usize,
607            _depth: fidl::encoding::Depth,
608        ) -> fidl::Result<()> {
609            encoder.debug_check_bounds::<SensorManagerClearTemperatureOverrideRequest>(offset);
610            // Delegate to tuple encoding.
611            fidl::encoding::Encode::<SensorManagerClearTemperatureOverrideRequest, D>::encode(
612                (<fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
613                    &self.name,
614                ),),
615                encoder,
616                offset,
617                _depth,
618            )
619        }
620    }
621    unsafe impl<
622        D: fidl::encoding::ResourceDialect,
623        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
624    > fidl::encoding::Encode<SensorManagerClearTemperatureOverrideRequest, D> for (T0,)
625    {
626        #[inline]
627        unsafe fn encode(
628            self,
629            encoder: &mut fidl::encoding::Encoder<'_, D>,
630            offset: usize,
631            depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            encoder.debug_check_bounds::<SensorManagerClearTemperatureOverrideRequest>(offset);
634            // Zero out padding regions. There's no need to apply masks
635            // because the unmasked parts will be overwritten by fields.
636            // Write the fields.
637            self.0.encode(encoder, offset + 0, depth)?;
638            Ok(())
639        }
640    }
641
642    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
643        for SensorManagerClearTemperatureOverrideRequest
644    {
645        #[inline(always)]
646        fn new_empty() -> Self {
647            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<256>, D) }
648        }
649
650        #[inline]
651        unsafe fn decode(
652            &mut self,
653            decoder: &mut fidl::encoding::Decoder<'_, D>,
654            offset: usize,
655            _depth: fidl::encoding::Depth,
656        ) -> fidl::Result<()> {
657            decoder.debug_check_bounds::<Self>(offset);
658            // Verify that padding bytes are zero.
659            fidl::decode!(
660                fidl::encoding::BoundedString<256>,
661                D,
662                &mut self.name,
663                decoder,
664                offset + 0,
665                _depth
666            )?;
667            Ok(())
668        }
669    }
670
671    impl fidl::encoding::ValueTypeMarker for SensorManagerSetTemperatureOverrideRequest {
672        type Borrowed<'a> = &'a Self;
673        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
674            value
675        }
676    }
677
678    unsafe impl fidl::encoding::TypeMarker for SensorManagerSetTemperatureOverrideRequest {
679        type Owned = Self;
680
681        #[inline(always)]
682        fn inline_align(_context: fidl::encoding::Context) -> usize {
683            8
684        }
685
686        #[inline(always)]
687        fn inline_size(_context: fidl::encoding::Context) -> usize {
688            24
689        }
690    }
691
692    unsafe impl<D: fidl::encoding::ResourceDialect>
693        fidl::encoding::Encode<SensorManagerSetTemperatureOverrideRequest, D>
694        for &SensorManagerSetTemperatureOverrideRequest
695    {
696        #[inline]
697        unsafe fn encode(
698            self,
699            encoder: &mut fidl::encoding::Encoder<'_, D>,
700            offset: usize,
701            _depth: fidl::encoding::Depth,
702        ) -> fidl::Result<()> {
703            encoder.debug_check_bounds::<SensorManagerSetTemperatureOverrideRequest>(offset);
704            // Delegate to tuple encoding.
705            fidl::encoding::Encode::<SensorManagerSetTemperatureOverrideRequest, D>::encode(
706                (
707                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
708                        &self.name,
709                    ),
710                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.override_temperature),
711                ),
712                encoder,
713                offset,
714                _depth,
715            )
716        }
717    }
718    unsafe impl<
719        D: fidl::encoding::ResourceDialect,
720        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
721        T1: fidl::encoding::Encode<f32, D>,
722    > fidl::encoding::Encode<SensorManagerSetTemperatureOverrideRequest, D> for (T0, T1)
723    {
724        #[inline]
725        unsafe fn encode(
726            self,
727            encoder: &mut fidl::encoding::Encoder<'_, D>,
728            offset: usize,
729            depth: fidl::encoding::Depth,
730        ) -> fidl::Result<()> {
731            encoder.debug_check_bounds::<SensorManagerSetTemperatureOverrideRequest>(offset);
732            // Zero out padding regions. There's no need to apply masks
733            // because the unmasked parts will be overwritten by fields.
734            unsafe {
735                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
736                (ptr as *mut u64).write_unaligned(0);
737            }
738            // Write the fields.
739            self.0.encode(encoder, offset + 0, depth)?;
740            self.1.encode(encoder, offset + 16, depth)?;
741            Ok(())
742        }
743    }
744
745    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
746        for SensorManagerSetTemperatureOverrideRequest
747    {
748        #[inline(always)]
749        fn new_empty() -> Self {
750            Self {
751                name: fidl::new_empty!(fidl::encoding::BoundedString<256>, D),
752                override_temperature: fidl::new_empty!(f32, D),
753            }
754        }
755
756        #[inline]
757        unsafe fn decode(
758            &mut self,
759            decoder: &mut fidl::encoding::Decoder<'_, D>,
760            offset: usize,
761            _depth: fidl::encoding::Depth,
762        ) -> fidl::Result<()> {
763            decoder.debug_check_bounds::<Self>(offset);
764            // Verify that padding bytes are zero.
765            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
766            let padval = unsafe { (ptr as *const u64).read_unaligned() };
767            let mask = 0xffffffff00000000u64;
768            let maskedval = padval & mask;
769            if maskedval != 0 {
770                return Err(fidl::Error::NonZeroPadding {
771                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
772                });
773            }
774            fidl::decode!(
775                fidl::encoding::BoundedString<256>,
776                D,
777                &mut self.name,
778                decoder,
779                offset + 0,
780                _depth
781            )?;
782            fidl::decode!(f32, D, &mut self.override_temperature, decoder, offset + 16, _depth)?;
783            Ok(())
784        }
785    }
786
787    impl fidl::encoding::ValueTypeMarker for SensorManagerListSensorsResponse {
788        type Borrowed<'a> = &'a Self;
789        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
790            value
791        }
792    }
793
794    unsafe impl fidl::encoding::TypeMarker for SensorManagerListSensorsResponse {
795        type Owned = Self;
796
797        #[inline(always)]
798        fn inline_align(_context: fidl::encoding::Context) -> usize {
799            8
800        }
801
802        #[inline(always)]
803        fn inline_size(_context: fidl::encoding::Context) -> usize {
804            16
805        }
806    }
807
808    unsafe impl<D: fidl::encoding::ResourceDialect>
809        fidl::encoding::Encode<SensorManagerListSensorsResponse, D>
810        for &SensorManagerListSensorsResponse
811    {
812        #[inline]
813        unsafe fn encode(
814            self,
815            encoder: &mut fidl::encoding::Encoder<'_, D>,
816            offset: usize,
817            _depth: fidl::encoding::Depth,
818        ) -> fidl::Result<()> {
819            encoder.debug_check_bounds::<SensorManagerListSensorsResponse>(offset);
820            // Delegate to tuple encoding.
821            fidl::encoding::Encode::<SensorManagerListSensorsResponse, D>::encode(
822                (
823                    <fidl::encoding::UnboundedVector<SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.sensors),
824                ),
825                encoder, offset, _depth
826            )
827        }
828    }
829    unsafe impl<
830        D: fidl::encoding::ResourceDialect,
831        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<SensorInfo>, D>,
832    > fidl::encoding::Encode<SensorManagerListSensorsResponse, D> for (T0,)
833    {
834        #[inline]
835        unsafe fn encode(
836            self,
837            encoder: &mut fidl::encoding::Encoder<'_, D>,
838            offset: usize,
839            depth: fidl::encoding::Depth,
840        ) -> fidl::Result<()> {
841            encoder.debug_check_bounds::<SensorManagerListSensorsResponse>(offset);
842            // Zero out padding regions. There's no need to apply masks
843            // because the unmasked parts will be overwritten by fields.
844            // Write the fields.
845            self.0.encode(encoder, offset + 0, depth)?;
846            Ok(())
847        }
848    }
849
850    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
851        for SensorManagerListSensorsResponse
852    {
853        #[inline(always)]
854        fn new_empty() -> Self {
855            Self { sensors: fidl::new_empty!(fidl::encoding::UnboundedVector<SensorInfo>, D) }
856        }
857
858        #[inline]
859        unsafe fn decode(
860            &mut self,
861            decoder: &mut fidl::encoding::Decoder<'_, D>,
862            offset: usize,
863            _depth: fidl::encoding::Depth,
864        ) -> fidl::Result<()> {
865            decoder.debug_check_bounds::<Self>(offset);
866            // Verify that padding bytes are zero.
867            fidl::decode!(
868                fidl::encoding::UnboundedVector<SensorInfo>,
869                D,
870                &mut self.sensors,
871                decoder,
872                offset + 0,
873                _depth
874            )?;
875            Ok(())
876        }
877    }
878
879    impl SensorInfo {
880        #[inline(always)]
881        fn max_ordinal_present(&self) -> u64 {
882            if let Some(_) = self.name {
883                return 1;
884            }
885            0
886        }
887    }
888
889    impl fidl::encoding::ValueTypeMarker for SensorInfo {
890        type Borrowed<'a> = &'a Self;
891        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
892            value
893        }
894    }
895
896    unsafe impl fidl::encoding::TypeMarker for SensorInfo {
897        type Owned = Self;
898
899        #[inline(always)]
900        fn inline_align(_context: fidl::encoding::Context) -> usize {
901            8
902        }
903
904        #[inline(always)]
905        fn inline_size(_context: fidl::encoding::Context) -> usize {
906            16
907        }
908    }
909
910    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SensorInfo, D>
911        for &SensorInfo
912    {
913        unsafe fn encode(
914            self,
915            encoder: &mut fidl::encoding::Encoder<'_, D>,
916            offset: usize,
917            mut depth: fidl::encoding::Depth,
918        ) -> fidl::Result<()> {
919            encoder.debug_check_bounds::<SensorInfo>(offset);
920            // Vector header
921            let max_ordinal: u64 = self.max_ordinal_present();
922            encoder.write_num(max_ordinal, offset);
923            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
924            // Calling encoder.out_of_line_offset(0) is not allowed.
925            if max_ordinal == 0 {
926                return Ok(());
927            }
928            depth.increment()?;
929            let envelope_size = 8;
930            let bytes_len = max_ordinal as usize * envelope_size;
931            #[allow(unused_variables)]
932            let offset = encoder.out_of_line_offset(bytes_len);
933            let mut _prev_end_offset: usize = 0;
934            if 1 > max_ordinal {
935                return Ok(());
936            }
937
938            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
939            // are envelope_size bytes.
940            let cur_offset: usize = (1 - 1) * envelope_size;
941
942            // Zero reserved fields.
943            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
944
945            // Safety:
946            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
947            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
948            //   envelope_size bytes, there is always sufficient room.
949            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
950                self.name.as_ref().map(
951                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
952                ),
953                encoder,
954                offset + cur_offset,
955                depth,
956            )?;
957
958            _prev_end_offset = cur_offset + envelope_size;
959
960            Ok(())
961        }
962    }
963
964    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SensorInfo {
965        #[inline(always)]
966        fn new_empty() -> Self {
967            Self::default()
968        }
969
970        unsafe fn decode(
971            &mut self,
972            decoder: &mut fidl::encoding::Decoder<'_, D>,
973            offset: usize,
974            mut depth: fidl::encoding::Depth,
975        ) -> fidl::Result<()> {
976            decoder.debug_check_bounds::<Self>(offset);
977            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
978                None => return Err(fidl::Error::NotNullable),
979                Some(len) => len,
980            };
981            // Calling decoder.out_of_line_offset(0) is not allowed.
982            if len == 0 {
983                return Ok(());
984            };
985            depth.increment()?;
986            let envelope_size = 8;
987            let bytes_len = len * envelope_size;
988            let offset = decoder.out_of_line_offset(bytes_len)?;
989            // Decode the envelope for each type.
990            let mut _next_ordinal_to_read = 0;
991            let mut next_offset = offset;
992            let end_offset = offset + bytes_len;
993            _next_ordinal_to_read += 1;
994            if next_offset >= end_offset {
995                return Ok(());
996            }
997
998            // Decode unknown envelopes for gaps in ordinals.
999            while _next_ordinal_to_read < 1 {
1000                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1001                _next_ordinal_to_read += 1;
1002                next_offset += envelope_size;
1003            }
1004
1005            let next_out_of_line = decoder.next_out_of_line();
1006            let handles_before = decoder.remaining_handles();
1007            if let Some((inlined, num_bytes, num_handles)) =
1008                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1009            {
1010                let member_inline_size =
1011                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
1012                        decoder.context,
1013                    );
1014                if inlined != (member_inline_size <= 4) {
1015                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1016                }
1017                let inner_offset;
1018                let mut inner_depth = depth.clone();
1019                if inlined {
1020                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1021                    inner_offset = next_offset;
1022                } else {
1023                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1024                    inner_depth.increment()?;
1025                }
1026                let val_ref = self
1027                    .name
1028                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
1029                fidl::decode!(
1030                    fidl::encoding::BoundedString<256>,
1031                    D,
1032                    val_ref,
1033                    decoder,
1034                    inner_offset,
1035                    inner_depth
1036                )?;
1037                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1038                {
1039                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1040                }
1041                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1042                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1043                }
1044            }
1045
1046            next_offset += envelope_size;
1047
1048            // Decode the remaining unknown envelopes.
1049            while next_offset < end_offset {
1050                _next_ordinal_to_read += 1;
1051                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1052                next_offset += envelope_size;
1053            }
1054
1055            Ok(())
1056        }
1057    }
1058}