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