Skip to main content

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    /// Unique board-level sensor name/type identifier (for example, matched by client thermal
249    /// configurations and exposed as `thermal_zone<N>/type` in Starnix).
250    pub name: Option<String>,
251    #[doc(hidden)]
252    pub __source_breaking: fidl::marker::SourceBreaking,
253}
254
255impl fidl::Persistable for SensorInfo {}
256
257pub mod client_state_connector_ordinals {
258    pub const CONNECT: u64 = 0x65abd3ba57ddaa1d;
259}
260
261pub mod client_state_watcher_ordinals {
262    pub const WATCH: u64 = 0x44831316a9942f7e;
263}
264
265pub mod sensor_manager_ordinals {
266    pub const LIST_SENSORS: u64 = 0x4407236d8bad1a9b;
267    pub const SET_TEMPERATURE_OVERRIDE: u64 = 0x13abb6faff00a238;
268    pub const CLEAR_TEMPERATURE_OVERRIDE: u64 = 0x3ad5b3a009f687cb;
269    pub const CONNECT: u64 = 0x76abcbb8819f26bf;
270}
271
272mod internal {
273    use super::*;
274    unsafe impl fidl::encoding::TypeMarker for ClearTemperatureOverrideError {
275        type Owned = Self;
276
277        #[inline(always)]
278        fn inline_align(_context: fidl::encoding::Context) -> usize {
279            std::mem::align_of::<u32>()
280        }
281
282        #[inline(always)]
283        fn inline_size(_context: fidl::encoding::Context) -> usize {
284            std::mem::size_of::<u32>()
285        }
286
287        #[inline(always)]
288        fn encode_is_copy() -> bool {
289            false
290        }
291
292        #[inline(always)]
293        fn decode_is_copy() -> bool {
294            false
295        }
296    }
297
298    impl fidl::encoding::ValueTypeMarker for ClearTemperatureOverrideError {
299        type Borrowed<'a> = Self;
300        #[inline(always)]
301        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
302            *value
303        }
304    }
305
306    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
307        for ClearTemperatureOverrideError
308    {
309        #[inline]
310        unsafe fn encode(
311            self,
312            encoder: &mut fidl::encoding::Encoder<'_, D>,
313            offset: usize,
314            _depth: fidl::encoding::Depth,
315        ) -> fidl::Result<()> {
316            encoder.debug_check_bounds::<Self>(offset);
317            encoder.write_num(self.into_primitive(), offset);
318            Ok(())
319        }
320    }
321
322    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
323        for ClearTemperatureOverrideError
324    {
325        #[inline(always)]
326        fn new_empty() -> Self {
327            Self::unknown()
328        }
329
330        #[inline]
331        unsafe fn decode(
332            &mut self,
333            decoder: &mut fidl::encoding::Decoder<'_, D>,
334            offset: usize,
335            _depth: fidl::encoding::Depth,
336        ) -> fidl::Result<()> {
337            decoder.debug_check_bounds::<Self>(offset);
338            let prim = decoder.read_num::<u32>(offset);
339
340            *self = Self::from_primitive_allow_unknown(prim);
341            Ok(())
342        }
343    }
344    unsafe impl fidl::encoding::TypeMarker for ConnectError {
345        type Owned = Self;
346
347        #[inline(always)]
348        fn inline_align(_context: fidl::encoding::Context) -> usize {
349            std::mem::align_of::<u32>()
350        }
351
352        #[inline(always)]
353        fn inline_size(_context: fidl::encoding::Context) -> usize {
354            std::mem::size_of::<u32>()
355        }
356
357        #[inline(always)]
358        fn encode_is_copy() -> bool {
359            false
360        }
361
362        #[inline(always)]
363        fn decode_is_copy() -> bool {
364            false
365        }
366    }
367
368    impl fidl::encoding::ValueTypeMarker for ConnectError {
369        type Borrowed<'a> = Self;
370        #[inline(always)]
371        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
372            *value
373        }
374    }
375
376    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ConnectError {
377        #[inline]
378        unsafe fn encode(
379            self,
380            encoder: &mut fidl::encoding::Encoder<'_, D>,
381            offset: usize,
382            _depth: fidl::encoding::Depth,
383        ) -> fidl::Result<()> {
384            encoder.debug_check_bounds::<Self>(offset);
385            encoder.write_num(self.into_primitive(), offset);
386            Ok(())
387        }
388    }
389
390    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectError {
391        #[inline(always)]
392        fn new_empty() -> Self {
393            Self::unknown()
394        }
395
396        #[inline]
397        unsafe fn decode(
398            &mut self,
399            decoder: &mut fidl::encoding::Decoder<'_, D>,
400            offset: usize,
401            _depth: fidl::encoding::Depth,
402        ) -> fidl::Result<()> {
403            decoder.debug_check_bounds::<Self>(offset);
404            let prim = decoder.read_num::<u32>(offset);
405
406            *self = Self::from_primitive_allow_unknown(prim);
407            Ok(())
408        }
409    }
410    unsafe impl fidl::encoding::TypeMarker for SetTemperatureOverrideError {
411        type Owned = Self;
412
413        #[inline(always)]
414        fn inline_align(_context: fidl::encoding::Context) -> usize {
415            std::mem::align_of::<u32>()
416        }
417
418        #[inline(always)]
419        fn inline_size(_context: fidl::encoding::Context) -> usize {
420            std::mem::size_of::<u32>()
421        }
422
423        #[inline(always)]
424        fn encode_is_copy() -> bool {
425            false
426        }
427
428        #[inline(always)]
429        fn decode_is_copy() -> bool {
430            false
431        }
432    }
433
434    impl fidl::encoding::ValueTypeMarker for SetTemperatureOverrideError {
435        type Borrowed<'a> = Self;
436        #[inline(always)]
437        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
438            *value
439        }
440    }
441
442    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
443        for SetTemperatureOverrideError
444    {
445        #[inline]
446        unsafe fn encode(
447            self,
448            encoder: &mut fidl::encoding::Encoder<'_, D>,
449            offset: usize,
450            _depth: fidl::encoding::Depth,
451        ) -> fidl::Result<()> {
452            encoder.debug_check_bounds::<Self>(offset);
453            encoder.write_num(self.into_primitive(), offset);
454            Ok(())
455        }
456    }
457
458    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
459        for SetTemperatureOverrideError
460    {
461        #[inline(always)]
462        fn new_empty() -> Self {
463            Self::unknown()
464        }
465
466        #[inline]
467        unsafe fn decode(
468            &mut self,
469            decoder: &mut fidl::encoding::Decoder<'_, D>,
470            offset: usize,
471            _depth: fidl::encoding::Depth,
472        ) -> fidl::Result<()> {
473            decoder.debug_check_bounds::<Self>(offset);
474            let prim = decoder.read_num::<u32>(offset);
475
476            *self = Self::from_primitive_allow_unknown(prim);
477            Ok(())
478        }
479    }
480
481    impl fidl::encoding::ValueTypeMarker for ClientStateWatcherWatchResponse {
482        type Borrowed<'a> = &'a Self;
483        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
484            value
485        }
486    }
487
488    unsafe impl fidl::encoding::TypeMarker for ClientStateWatcherWatchResponse {
489        type Owned = Self;
490
491        #[inline(always)]
492        fn inline_align(_context: fidl::encoding::Context) -> usize {
493            8
494        }
495
496        #[inline(always)]
497        fn inline_size(_context: fidl::encoding::Context) -> usize {
498            8
499        }
500        #[inline(always)]
501        fn encode_is_copy() -> bool {
502            true
503        }
504
505        #[inline(always)]
506        fn decode_is_copy() -> bool {
507            true
508        }
509    }
510
511    unsafe impl<D: fidl::encoding::ResourceDialect>
512        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D>
513        for &ClientStateWatcherWatchResponse
514    {
515        #[inline]
516        unsafe fn encode(
517            self,
518            encoder: &mut fidl::encoding::Encoder<'_, D>,
519            offset: usize,
520            _depth: fidl::encoding::Depth,
521        ) -> fidl::Result<()> {
522            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
523            unsafe {
524                // Copy the object into the buffer.
525                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
526                (buf_ptr as *mut ClientStateWatcherWatchResponse)
527                    .write_unaligned((self as *const ClientStateWatcherWatchResponse).read());
528                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
529                // done second because the memcpy will write garbage to these bytes.
530            }
531            Ok(())
532        }
533    }
534    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
535        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D> for (T0,)
536    {
537        #[inline]
538        unsafe fn encode(
539            self,
540            encoder: &mut fidl::encoding::Encoder<'_, D>,
541            offset: usize,
542            depth: fidl::encoding::Depth,
543        ) -> fidl::Result<()> {
544            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
545            // Zero out padding regions. There's no need to apply masks
546            // because the unmasked parts will be overwritten by fields.
547            // Write the fields.
548            self.0.encode(encoder, offset + 0, depth)?;
549            Ok(())
550        }
551    }
552
553    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
554        for ClientStateWatcherWatchResponse
555    {
556        #[inline(always)]
557        fn new_empty() -> Self {
558            Self { state: fidl::new_empty!(u64, D) }
559        }
560
561        #[inline]
562        unsafe fn decode(
563            &mut self,
564            decoder: &mut fidl::encoding::Decoder<'_, D>,
565            offset: usize,
566            _depth: fidl::encoding::Depth,
567        ) -> fidl::Result<()> {
568            decoder.debug_check_bounds::<Self>(offset);
569            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
570            // Verify that padding bytes are zero.
571            // Copy from the buffer into the object.
572            unsafe {
573                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
574            }
575            Ok(())
576        }
577    }
578
579    impl fidl::encoding::ValueTypeMarker for SensorManagerClearTemperatureOverrideRequest {
580        type Borrowed<'a> = &'a Self;
581        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
582            value
583        }
584    }
585
586    unsafe impl fidl::encoding::TypeMarker for SensorManagerClearTemperatureOverrideRequest {
587        type Owned = Self;
588
589        #[inline(always)]
590        fn inline_align(_context: fidl::encoding::Context) -> usize {
591            8
592        }
593
594        #[inline(always)]
595        fn inline_size(_context: fidl::encoding::Context) -> usize {
596            16
597        }
598    }
599
600    unsafe impl<D: fidl::encoding::ResourceDialect>
601        fidl::encoding::Encode<SensorManagerClearTemperatureOverrideRequest, D>
602        for &SensorManagerClearTemperatureOverrideRequest
603    {
604        #[inline]
605        unsafe fn encode(
606            self,
607            encoder: &mut fidl::encoding::Encoder<'_, D>,
608            offset: usize,
609            _depth: fidl::encoding::Depth,
610        ) -> fidl::Result<()> {
611            encoder.debug_check_bounds::<SensorManagerClearTemperatureOverrideRequest>(offset);
612            // Delegate to tuple encoding.
613            fidl::encoding::Encode::<SensorManagerClearTemperatureOverrideRequest, D>::encode(
614                (<fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
615                    &self.name,
616                ),),
617                encoder,
618                offset,
619                _depth,
620            )
621        }
622    }
623    unsafe impl<
624        D: fidl::encoding::ResourceDialect,
625        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
626    > fidl::encoding::Encode<SensorManagerClearTemperatureOverrideRequest, D> for (T0,)
627    {
628        #[inline]
629        unsafe fn encode(
630            self,
631            encoder: &mut fidl::encoding::Encoder<'_, D>,
632            offset: usize,
633            depth: fidl::encoding::Depth,
634        ) -> fidl::Result<()> {
635            encoder.debug_check_bounds::<SensorManagerClearTemperatureOverrideRequest>(offset);
636            // Zero out padding regions. There's no need to apply masks
637            // because the unmasked parts will be overwritten by fields.
638            // Write the fields.
639            self.0.encode(encoder, offset + 0, depth)?;
640            Ok(())
641        }
642    }
643
644    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
645        for SensorManagerClearTemperatureOverrideRequest
646    {
647        #[inline(always)]
648        fn new_empty() -> Self {
649            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<256>, D) }
650        }
651
652        #[inline]
653        unsafe fn decode(
654            &mut self,
655            decoder: &mut fidl::encoding::Decoder<'_, D>,
656            offset: usize,
657            _depth: fidl::encoding::Depth,
658        ) -> fidl::Result<()> {
659            decoder.debug_check_bounds::<Self>(offset);
660            // Verify that padding bytes are zero.
661            fidl::decode!(
662                fidl::encoding::BoundedString<256>,
663                D,
664                &mut self.name,
665                decoder,
666                offset + 0,
667                _depth
668            )?;
669            Ok(())
670        }
671    }
672
673    impl fidl::encoding::ValueTypeMarker for SensorManagerSetTemperatureOverrideRequest {
674        type Borrowed<'a> = &'a Self;
675        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
676            value
677        }
678    }
679
680    unsafe impl fidl::encoding::TypeMarker for SensorManagerSetTemperatureOverrideRequest {
681        type Owned = Self;
682
683        #[inline(always)]
684        fn inline_align(_context: fidl::encoding::Context) -> usize {
685            8
686        }
687
688        #[inline(always)]
689        fn inline_size(_context: fidl::encoding::Context) -> usize {
690            24
691        }
692    }
693
694    unsafe impl<D: fidl::encoding::ResourceDialect>
695        fidl::encoding::Encode<SensorManagerSetTemperatureOverrideRequest, D>
696        for &SensorManagerSetTemperatureOverrideRequest
697    {
698        #[inline]
699        unsafe fn encode(
700            self,
701            encoder: &mut fidl::encoding::Encoder<'_, D>,
702            offset: usize,
703            _depth: fidl::encoding::Depth,
704        ) -> fidl::Result<()> {
705            encoder.debug_check_bounds::<SensorManagerSetTemperatureOverrideRequest>(offset);
706            // Delegate to tuple encoding.
707            fidl::encoding::Encode::<SensorManagerSetTemperatureOverrideRequest, D>::encode(
708                (
709                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
710                        &self.name,
711                    ),
712                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.override_temperature),
713                ),
714                encoder,
715                offset,
716                _depth,
717            )
718        }
719    }
720    unsafe impl<
721        D: fidl::encoding::ResourceDialect,
722        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
723        T1: fidl::encoding::Encode<f32, D>,
724    > fidl::encoding::Encode<SensorManagerSetTemperatureOverrideRequest, D> for (T0, T1)
725    {
726        #[inline]
727        unsafe fn encode(
728            self,
729            encoder: &mut fidl::encoding::Encoder<'_, D>,
730            offset: usize,
731            depth: fidl::encoding::Depth,
732        ) -> fidl::Result<()> {
733            encoder.debug_check_bounds::<SensorManagerSetTemperatureOverrideRequest>(offset);
734            // Zero out padding regions. There's no need to apply masks
735            // because the unmasked parts will be overwritten by fields.
736            unsafe {
737                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
738                (ptr as *mut u64).write_unaligned(0);
739            }
740            // Write the fields.
741            self.0.encode(encoder, offset + 0, depth)?;
742            self.1.encode(encoder, offset + 16, depth)?;
743            Ok(())
744        }
745    }
746
747    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
748        for SensorManagerSetTemperatureOverrideRequest
749    {
750        #[inline(always)]
751        fn new_empty() -> Self {
752            Self {
753                name: fidl::new_empty!(fidl::encoding::BoundedString<256>, D),
754                override_temperature: fidl::new_empty!(f32, D),
755            }
756        }
757
758        #[inline]
759        unsafe fn decode(
760            &mut self,
761            decoder: &mut fidl::encoding::Decoder<'_, D>,
762            offset: usize,
763            _depth: fidl::encoding::Depth,
764        ) -> fidl::Result<()> {
765            decoder.debug_check_bounds::<Self>(offset);
766            // Verify that padding bytes are zero.
767            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
768            let padval = unsafe { (ptr as *const u64).read_unaligned() };
769            let mask = 0xffffffff00000000u64;
770            let maskedval = padval & mask;
771            if maskedval != 0 {
772                return Err(fidl::Error::NonZeroPadding {
773                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
774                });
775            }
776            fidl::decode!(
777                fidl::encoding::BoundedString<256>,
778                D,
779                &mut self.name,
780                decoder,
781                offset + 0,
782                _depth
783            )?;
784            fidl::decode!(f32, D, &mut self.override_temperature, decoder, offset + 16, _depth)?;
785            Ok(())
786        }
787    }
788
789    impl fidl::encoding::ValueTypeMarker for SensorManagerListSensorsResponse {
790        type Borrowed<'a> = &'a Self;
791        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
792            value
793        }
794    }
795
796    unsafe impl fidl::encoding::TypeMarker for SensorManagerListSensorsResponse {
797        type Owned = Self;
798
799        #[inline(always)]
800        fn inline_align(_context: fidl::encoding::Context) -> usize {
801            8
802        }
803
804        #[inline(always)]
805        fn inline_size(_context: fidl::encoding::Context) -> usize {
806            16
807        }
808    }
809
810    unsafe impl<D: fidl::encoding::ResourceDialect>
811        fidl::encoding::Encode<SensorManagerListSensorsResponse, D>
812        for &SensorManagerListSensorsResponse
813    {
814        #[inline]
815        unsafe fn encode(
816            self,
817            encoder: &mut fidl::encoding::Encoder<'_, D>,
818            offset: usize,
819            _depth: fidl::encoding::Depth,
820        ) -> fidl::Result<()> {
821            encoder.debug_check_bounds::<SensorManagerListSensorsResponse>(offset);
822            // Delegate to tuple encoding.
823            fidl::encoding::Encode::<SensorManagerListSensorsResponse, D>::encode(
824                (
825                    <fidl::encoding::UnboundedVector<SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.sensors),
826                ),
827                encoder, offset, _depth
828            )
829        }
830    }
831    unsafe impl<
832        D: fidl::encoding::ResourceDialect,
833        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<SensorInfo>, D>,
834    > fidl::encoding::Encode<SensorManagerListSensorsResponse, D> for (T0,)
835    {
836        #[inline]
837        unsafe fn encode(
838            self,
839            encoder: &mut fidl::encoding::Encoder<'_, D>,
840            offset: usize,
841            depth: fidl::encoding::Depth,
842        ) -> fidl::Result<()> {
843            encoder.debug_check_bounds::<SensorManagerListSensorsResponse>(offset);
844            // Zero out padding regions. There's no need to apply masks
845            // because the unmasked parts will be overwritten by fields.
846            // Write the fields.
847            self.0.encode(encoder, offset + 0, depth)?;
848            Ok(())
849        }
850    }
851
852    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
853        for SensorManagerListSensorsResponse
854    {
855        #[inline(always)]
856        fn new_empty() -> Self {
857            Self { sensors: fidl::new_empty!(fidl::encoding::UnboundedVector<SensorInfo>, D) }
858        }
859
860        #[inline]
861        unsafe fn decode(
862            &mut self,
863            decoder: &mut fidl::encoding::Decoder<'_, D>,
864            offset: usize,
865            _depth: fidl::encoding::Depth,
866        ) -> fidl::Result<()> {
867            decoder.debug_check_bounds::<Self>(offset);
868            // Verify that padding bytes are zero.
869            fidl::decode!(
870                fidl::encoding::UnboundedVector<SensorInfo>,
871                D,
872                &mut self.sensors,
873                decoder,
874                offset + 0,
875                _depth
876            )?;
877            Ok(())
878        }
879    }
880
881    impl SensorInfo {
882        #[inline(always)]
883        fn max_ordinal_present(&self) -> u64 {
884            if let Some(_) = self.name {
885                return 1;
886            }
887            0
888        }
889    }
890
891    impl fidl::encoding::ValueTypeMarker for SensorInfo {
892        type Borrowed<'a> = &'a Self;
893        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
894            value
895        }
896    }
897
898    unsafe impl fidl::encoding::TypeMarker for SensorInfo {
899        type Owned = Self;
900
901        #[inline(always)]
902        fn inline_align(_context: fidl::encoding::Context) -> usize {
903            8
904        }
905
906        #[inline(always)]
907        fn inline_size(_context: fidl::encoding::Context) -> usize {
908            16
909        }
910    }
911
912    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SensorInfo, D>
913        for &SensorInfo
914    {
915        unsafe fn encode(
916            self,
917            encoder: &mut fidl::encoding::Encoder<'_, D>,
918            offset: usize,
919            mut depth: fidl::encoding::Depth,
920        ) -> fidl::Result<()> {
921            encoder.debug_check_bounds::<SensorInfo>(offset);
922            // Vector header
923            let max_ordinal: u64 = self.max_ordinal_present();
924            encoder.write_num(max_ordinal, offset);
925            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
926            // Calling encoder.out_of_line_offset(0) is not allowed.
927            if max_ordinal == 0 {
928                return Ok(());
929            }
930            depth.increment()?;
931            let envelope_size = 8;
932            let bytes_len = max_ordinal as usize * envelope_size;
933            #[allow(unused_variables)]
934            let offset = encoder.out_of_line_offset(bytes_len);
935            let mut _prev_end_offset: usize = 0;
936            if 1 > max_ordinal {
937                return Ok(());
938            }
939
940            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
941            // are envelope_size bytes.
942            let cur_offset: usize = (1 - 1) * envelope_size;
943
944            // Zero reserved fields.
945            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
946
947            // Safety:
948            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
949            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
950            //   envelope_size bytes, there is always sufficient room.
951            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
952                self.name.as_ref().map(
953                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
954                ),
955                encoder,
956                offset + cur_offset,
957                depth,
958            )?;
959
960            _prev_end_offset = cur_offset + envelope_size;
961
962            Ok(())
963        }
964    }
965
966    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SensorInfo {
967        #[inline(always)]
968        fn new_empty() -> Self {
969            Self::default()
970        }
971
972        unsafe fn decode(
973            &mut self,
974            decoder: &mut fidl::encoding::Decoder<'_, D>,
975            offset: usize,
976            mut depth: fidl::encoding::Depth,
977        ) -> fidl::Result<()> {
978            decoder.debug_check_bounds::<Self>(offset);
979            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
980                None => return Err(fidl::Error::NotNullable),
981                Some(len) => len,
982            };
983            // Calling decoder.out_of_line_offset(0) is not allowed.
984            if len == 0 {
985                return Ok(());
986            };
987            depth.increment()?;
988            let envelope_size = 8;
989            let bytes_len = len * envelope_size;
990            let offset = decoder.out_of_line_offset(bytes_len)?;
991            // Decode the envelope for each type.
992            let mut _next_ordinal_to_read = 0;
993            let mut next_offset = offset;
994            let end_offset = offset + bytes_len;
995            _next_ordinal_to_read += 1;
996            if next_offset >= end_offset {
997                return Ok(());
998            }
999
1000            // Decode unknown envelopes for gaps in ordinals.
1001            while _next_ordinal_to_read < 1 {
1002                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1003                _next_ordinal_to_read += 1;
1004                next_offset += envelope_size;
1005            }
1006
1007            let next_out_of_line = decoder.next_out_of_line();
1008            let handles_before = decoder.remaining_handles();
1009            if let Some((inlined, num_bytes, num_handles)) =
1010                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1011            {
1012                let member_inline_size =
1013                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
1014                        decoder.context,
1015                    );
1016                if inlined != (member_inline_size <= 4) {
1017                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1018                }
1019                let inner_offset;
1020                let mut inner_depth = depth.clone();
1021                if inlined {
1022                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1023                    inner_offset = next_offset;
1024                } else {
1025                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1026                    inner_depth.increment()?;
1027                }
1028                let val_ref = self
1029                    .name
1030                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
1031                fidl::decode!(
1032                    fidl::encoding::BoundedString<256>,
1033                    D,
1034                    val_ref,
1035                    decoder,
1036                    inner_offset,
1037                    inner_depth
1038                )?;
1039                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1040                {
1041                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1042                }
1043                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1044                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1045                }
1046            }
1047
1048            next_offset += envelope_size;
1049
1050            // Decode the remaining unknown envelopes.
1051            while next_offset < end_offset {
1052                _next_ordinal_to_read += 1;
1053                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1054                next_offset += envelope_size;
1055            }
1056
1057            Ok(())
1058        }
1059    }
1060}