fidl_fuchsia_update_verify_common/
fidl_fuchsia_update_verify_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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12#[repr(u32)]
13pub enum HealthStatus {
14    Healthy = 1,
15    Unhealthy = 2,
16}
17
18impl HealthStatus {
19    #[inline]
20    pub fn from_primitive(prim: u32) -> Option<Self> {
21        match prim {
22            1 => Some(Self::Healthy),
23            2 => Some(Self::Unhealthy),
24            _ => None,
25        }
26    }
27
28    #[inline]
29    pub const fn into_primitive(self) -> u32 {
30        self as u32
31    }
32
33    #[deprecated = "Strict enums should not use `is_unknown`"]
34    #[inline]
35    pub fn is_unknown(&self) -> bool {
36        false
37    }
38}
39
40#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
41pub struct ComponentOtaHealthCheckGetHealthStatusResponse {
42    pub health_status: HealthStatus,
43}
44
45impl fidl::Persistable for ComponentOtaHealthCheckGetHealthStatusResponse {}
46
47#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48#[repr(C)]
49pub struct HealthVerificationQueryHealthChecksResponse {
50    pub status: i32,
51}
52
53impl fidl::Persistable for HealthVerificationQueryHealthChecksResponse {}
54
55mod internal {
56    use super::*;
57    unsafe impl fidl::encoding::TypeMarker for HealthStatus {
58        type Owned = Self;
59
60        #[inline(always)]
61        fn inline_align(_context: fidl::encoding::Context) -> usize {
62            std::mem::align_of::<u32>()
63        }
64
65        #[inline(always)]
66        fn inline_size(_context: fidl::encoding::Context) -> usize {
67            std::mem::size_of::<u32>()
68        }
69
70        #[inline(always)]
71        fn encode_is_copy() -> bool {
72            true
73        }
74
75        #[inline(always)]
76        fn decode_is_copy() -> bool {
77            false
78        }
79    }
80
81    impl fidl::encoding::ValueTypeMarker for HealthStatus {
82        type Borrowed<'a> = Self;
83        #[inline(always)]
84        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
85            *value
86        }
87    }
88
89    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for HealthStatus {
90        #[inline]
91        unsafe fn encode(
92            self,
93            encoder: &mut fidl::encoding::Encoder<'_, D>,
94            offset: usize,
95            _depth: fidl::encoding::Depth,
96        ) -> fidl::Result<()> {
97            encoder.debug_check_bounds::<Self>(offset);
98            encoder.write_num(self.into_primitive(), offset);
99            Ok(())
100        }
101    }
102
103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HealthStatus {
104        #[inline(always)]
105        fn new_empty() -> Self {
106            Self::Healthy
107        }
108
109        #[inline]
110        unsafe fn decode(
111            &mut self,
112            decoder: &mut fidl::encoding::Decoder<'_, D>,
113            offset: usize,
114            _depth: fidl::encoding::Depth,
115        ) -> fidl::Result<()> {
116            decoder.debug_check_bounds::<Self>(offset);
117            let prim = decoder.read_num::<u32>(offset);
118
119            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
120            Ok(())
121        }
122    }
123
124    impl fidl::encoding::ValueTypeMarker for ComponentOtaHealthCheckGetHealthStatusResponse {
125        type Borrowed<'a> = &'a Self;
126        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
127            value
128        }
129    }
130
131    unsafe impl fidl::encoding::TypeMarker for ComponentOtaHealthCheckGetHealthStatusResponse {
132        type Owned = Self;
133
134        #[inline(always)]
135        fn inline_align(_context: fidl::encoding::Context) -> usize {
136            4
137        }
138
139        #[inline(always)]
140        fn inline_size(_context: fidl::encoding::Context) -> usize {
141            4
142        }
143    }
144
145    unsafe impl<D: fidl::encoding::ResourceDialect>
146        fidl::encoding::Encode<ComponentOtaHealthCheckGetHealthStatusResponse, D>
147        for &ComponentOtaHealthCheckGetHealthStatusResponse
148    {
149        #[inline]
150        unsafe fn encode(
151            self,
152            encoder: &mut fidl::encoding::Encoder<'_, D>,
153            offset: usize,
154            _depth: fidl::encoding::Depth,
155        ) -> fidl::Result<()> {
156            encoder.debug_check_bounds::<ComponentOtaHealthCheckGetHealthStatusResponse>(offset);
157            // Delegate to tuple encoding.
158            fidl::encoding::Encode::<ComponentOtaHealthCheckGetHealthStatusResponse, D>::encode(
159                (<HealthStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.health_status),),
160                encoder,
161                offset,
162                _depth,
163            )
164        }
165    }
166    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<HealthStatus, D>>
167        fidl::encoding::Encode<ComponentOtaHealthCheckGetHealthStatusResponse, D> for (T0,)
168    {
169        #[inline]
170        unsafe fn encode(
171            self,
172            encoder: &mut fidl::encoding::Encoder<'_, D>,
173            offset: usize,
174            depth: fidl::encoding::Depth,
175        ) -> fidl::Result<()> {
176            encoder.debug_check_bounds::<ComponentOtaHealthCheckGetHealthStatusResponse>(offset);
177            // Zero out padding regions. There's no need to apply masks
178            // because the unmasked parts will be overwritten by fields.
179            // Write the fields.
180            self.0.encode(encoder, offset + 0, depth)?;
181            Ok(())
182        }
183    }
184
185    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
186        for ComponentOtaHealthCheckGetHealthStatusResponse
187    {
188        #[inline(always)]
189        fn new_empty() -> Self {
190            Self { health_status: fidl::new_empty!(HealthStatus, D) }
191        }
192
193        #[inline]
194        unsafe fn decode(
195            &mut self,
196            decoder: &mut fidl::encoding::Decoder<'_, D>,
197            offset: usize,
198            _depth: fidl::encoding::Depth,
199        ) -> fidl::Result<()> {
200            decoder.debug_check_bounds::<Self>(offset);
201            // Verify that padding bytes are zero.
202            fidl::decode!(HealthStatus, D, &mut self.health_status, decoder, offset + 0, _depth)?;
203            Ok(())
204        }
205    }
206
207    impl fidl::encoding::ValueTypeMarker for HealthVerificationQueryHealthChecksResponse {
208        type Borrowed<'a> = &'a Self;
209        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
210            value
211        }
212    }
213
214    unsafe impl fidl::encoding::TypeMarker for HealthVerificationQueryHealthChecksResponse {
215        type Owned = Self;
216
217        #[inline(always)]
218        fn inline_align(_context: fidl::encoding::Context) -> usize {
219            4
220        }
221
222        #[inline(always)]
223        fn inline_size(_context: fidl::encoding::Context) -> usize {
224            4
225        }
226        #[inline(always)]
227        fn encode_is_copy() -> bool {
228            true
229        }
230
231        #[inline(always)]
232        fn decode_is_copy() -> bool {
233            true
234        }
235    }
236
237    unsafe impl<D: fidl::encoding::ResourceDialect>
238        fidl::encoding::Encode<HealthVerificationQueryHealthChecksResponse, D>
239        for &HealthVerificationQueryHealthChecksResponse
240    {
241        #[inline]
242        unsafe fn encode(
243            self,
244            encoder: &mut fidl::encoding::Encoder<'_, D>,
245            offset: usize,
246            _depth: fidl::encoding::Depth,
247        ) -> fidl::Result<()> {
248            encoder.debug_check_bounds::<HealthVerificationQueryHealthChecksResponse>(offset);
249            unsafe {
250                // Copy the object into the buffer.
251                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
252                (buf_ptr as *mut HealthVerificationQueryHealthChecksResponse).write_unaligned(
253                    (self as *const HealthVerificationQueryHealthChecksResponse).read(),
254                );
255                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
256                // done second because the memcpy will write garbage to these bytes.
257            }
258            Ok(())
259        }
260    }
261    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
262        fidl::encoding::Encode<HealthVerificationQueryHealthChecksResponse, D> for (T0,)
263    {
264        #[inline]
265        unsafe fn encode(
266            self,
267            encoder: &mut fidl::encoding::Encoder<'_, D>,
268            offset: usize,
269            depth: fidl::encoding::Depth,
270        ) -> fidl::Result<()> {
271            encoder.debug_check_bounds::<HealthVerificationQueryHealthChecksResponse>(offset);
272            // Zero out padding regions. There's no need to apply masks
273            // because the unmasked parts will be overwritten by fields.
274            // Write the fields.
275            self.0.encode(encoder, offset + 0, depth)?;
276            Ok(())
277        }
278    }
279
280    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
281        for HealthVerificationQueryHealthChecksResponse
282    {
283        #[inline(always)]
284        fn new_empty() -> Self {
285            Self { status: fidl::new_empty!(i32, D) }
286        }
287
288        #[inline]
289        unsafe fn decode(
290            &mut self,
291            decoder: &mut fidl::encoding::Decoder<'_, D>,
292            offset: usize,
293            _depth: fidl::encoding::Depth,
294        ) -> fidl::Result<()> {
295            decoder.debug_check_bounds::<Self>(offset);
296            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
297            // Verify that padding bytes are zero.
298            // Copy from the buffer into the object.
299            unsafe {
300                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
301            }
302            Ok(())
303        }
304    }
305}