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