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