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