fidl_fuchsia_hardware_temperature__common/
fidl_fuchsia_hardware_temperature__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/// An arbritrary, human-readable string that uniquely identifies a temperature sensor.
12pub type SensorName = String;
13
14pub const MAX_SENSOR_NAME_LEN: u32 = 256;
15
16#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct DeviceGetSensorNameResponse {
18    pub name: String,
19}
20
21impl fidl::Persistable for DeviceGetSensorNameResponse {}
22
23#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
24pub struct DeviceGetTemperatureCelsiusResponse {
25    pub status: i32,
26    pub temp: f32,
27}
28
29impl fidl::Persistable for DeviceGetTemperatureCelsiusResponse {}
30
31pub mod device_ordinals {
32    pub const GET_TEMPERATURE_CELSIUS: u64 = 0x755e08b84736133c;
33    pub const GET_SENSOR_NAME: u64 = 0x4cbd7abaeafc02c1;
34}
35
36mod internal {
37    use super::*;
38
39    impl fidl::encoding::ValueTypeMarker for DeviceGetSensorNameResponse {
40        type Borrowed<'a> = &'a Self;
41        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
42            value
43        }
44    }
45
46    unsafe impl fidl::encoding::TypeMarker for DeviceGetSensorNameResponse {
47        type Owned = Self;
48
49        #[inline(always)]
50        fn inline_align(_context: fidl::encoding::Context) -> usize {
51            8
52        }
53
54        #[inline(always)]
55        fn inline_size(_context: fidl::encoding::Context) -> usize {
56            16
57        }
58    }
59
60    unsafe impl<D: fidl::encoding::ResourceDialect>
61        fidl::encoding::Encode<DeviceGetSensorNameResponse, D> for &DeviceGetSensorNameResponse
62    {
63        #[inline]
64        unsafe fn encode(
65            self,
66            encoder: &mut fidl::encoding::Encoder<'_, D>,
67            offset: usize,
68            _depth: fidl::encoding::Depth,
69        ) -> fidl::Result<()> {
70            encoder.debug_check_bounds::<DeviceGetSensorNameResponse>(offset);
71            // Delegate to tuple encoding.
72            fidl::encoding::Encode::<DeviceGetSensorNameResponse, D>::encode(
73                (<fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
74                    &self.name,
75                ),),
76                encoder,
77                offset,
78                _depth,
79            )
80        }
81    }
82    unsafe impl<
83            D: fidl::encoding::ResourceDialect,
84            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
85        > fidl::encoding::Encode<DeviceGetSensorNameResponse, D> for (T0,)
86    {
87        #[inline]
88        unsafe fn encode(
89            self,
90            encoder: &mut fidl::encoding::Encoder<'_, D>,
91            offset: usize,
92            depth: fidl::encoding::Depth,
93        ) -> fidl::Result<()> {
94            encoder.debug_check_bounds::<DeviceGetSensorNameResponse>(offset);
95            // Zero out padding regions. There's no need to apply masks
96            // because the unmasked parts will be overwritten by fields.
97            // Write the fields.
98            self.0.encode(encoder, offset + 0, depth)?;
99            Ok(())
100        }
101    }
102
103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
104        for DeviceGetSensorNameResponse
105    {
106        #[inline(always)]
107        fn new_empty() -> Self {
108            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<256>, D) }
109        }
110
111        #[inline]
112        unsafe fn decode(
113            &mut self,
114            decoder: &mut fidl::encoding::Decoder<'_, D>,
115            offset: usize,
116            _depth: fidl::encoding::Depth,
117        ) -> fidl::Result<()> {
118            decoder.debug_check_bounds::<Self>(offset);
119            // Verify that padding bytes are zero.
120            fidl::decode!(
121                fidl::encoding::BoundedString<256>,
122                D,
123                &mut self.name,
124                decoder,
125                offset + 0,
126                _depth
127            )?;
128            Ok(())
129        }
130    }
131
132    impl fidl::encoding::ValueTypeMarker for DeviceGetTemperatureCelsiusResponse {
133        type Borrowed<'a> = &'a Self;
134        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
135            value
136        }
137    }
138
139    unsafe impl fidl::encoding::TypeMarker for DeviceGetTemperatureCelsiusResponse {
140        type Owned = Self;
141
142        #[inline(always)]
143        fn inline_align(_context: fidl::encoding::Context) -> usize {
144            4
145        }
146
147        #[inline(always)]
148        fn inline_size(_context: fidl::encoding::Context) -> usize {
149            8
150        }
151    }
152
153    unsafe impl<D: fidl::encoding::ResourceDialect>
154        fidl::encoding::Encode<DeviceGetTemperatureCelsiusResponse, D>
155        for &DeviceGetTemperatureCelsiusResponse
156    {
157        #[inline]
158        unsafe fn encode(
159            self,
160            encoder: &mut fidl::encoding::Encoder<'_, D>,
161            offset: usize,
162            _depth: fidl::encoding::Depth,
163        ) -> fidl::Result<()> {
164            encoder.debug_check_bounds::<DeviceGetTemperatureCelsiusResponse>(offset);
165            // Delegate to tuple encoding.
166            fidl::encoding::Encode::<DeviceGetTemperatureCelsiusResponse, D>::encode(
167                (
168                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
169                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.temp),
170                ),
171                encoder,
172                offset,
173                _depth,
174            )
175        }
176    }
177    unsafe impl<
178            D: fidl::encoding::ResourceDialect,
179            T0: fidl::encoding::Encode<i32, D>,
180            T1: fidl::encoding::Encode<f32, D>,
181        > fidl::encoding::Encode<DeviceGetTemperatureCelsiusResponse, D> for (T0, T1)
182    {
183        #[inline]
184        unsafe fn encode(
185            self,
186            encoder: &mut fidl::encoding::Encoder<'_, D>,
187            offset: usize,
188            depth: fidl::encoding::Depth,
189        ) -> fidl::Result<()> {
190            encoder.debug_check_bounds::<DeviceGetTemperatureCelsiusResponse>(offset);
191            // Zero out padding regions. There's no need to apply masks
192            // because the unmasked parts will be overwritten by fields.
193            // Write the fields.
194            self.0.encode(encoder, offset + 0, depth)?;
195            self.1.encode(encoder, offset + 4, depth)?;
196            Ok(())
197        }
198    }
199
200    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
201        for DeviceGetTemperatureCelsiusResponse
202    {
203        #[inline(always)]
204        fn new_empty() -> Self {
205            Self { status: fidl::new_empty!(i32, D), temp: fidl::new_empty!(f32, D) }
206        }
207
208        #[inline]
209        unsafe fn decode(
210            &mut self,
211            decoder: &mut fidl::encoding::Decoder<'_, D>,
212            offset: usize,
213            _depth: fidl::encoding::Depth,
214        ) -> fidl::Result<()> {
215            decoder.debug_check_bounds::<Self>(offset);
216            // Verify that padding bytes are zero.
217            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
218            fidl::decode!(f32, D, &mut self.temp, decoder, offset + 4, _depth)?;
219            Ok(())
220        }
221    }
222}