fidl_cf_sc_internal_systemupdaterconfig__common/
fidl_cf_sc_internal_systemupdaterconfig__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, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13    pub concurrent_blob_fetches: u16,
14    pub concurrent_package_resolves: u16,
15    pub manifest_public_keys: Vec<String>,
16    pub verify_existing_blobs: bool,
17}
18
19impl fidl::Persistable for Config {}
20
21mod internal {
22    use super::*;
23
24    impl fidl::encoding::ValueTypeMarker for Config {
25        type Borrowed<'a> = &'a Self;
26        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
27            value
28        }
29    }
30
31    unsafe impl fidl::encoding::TypeMarker for Config {
32        type Owned = Self;
33
34        #[inline(always)]
35        fn inline_align(_context: fidl::encoding::Context) -> usize {
36            8
37        }
38
39        #[inline(always)]
40        fn inline_size(_context: fidl::encoding::Context) -> usize {
41            32
42        }
43    }
44
45    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
46        #[inline]
47        unsafe fn encode(
48            self,
49            encoder: &mut fidl::encoding::Encoder<'_, D>,
50            offset: usize,
51            _depth: fidl::encoding::Depth,
52        ) -> fidl::Result<()> {
53            encoder.debug_check_bounds::<Config>(offset);
54            // Delegate to tuple encoding.
55            fidl::encoding::Encode::<Config, D>::encode(
56                (
57                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.concurrent_blob_fetches),
58                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.concurrent_package_resolves),
59                    <fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10> as fidl::encoding::ValueTypeMarker>::borrow(&self.manifest_public_keys),
60                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.verify_existing_blobs),
61                ),
62                encoder, offset, _depth
63            )
64        }
65    }
66    unsafe impl<
67        D: fidl::encoding::ResourceDialect,
68        T0: fidl::encoding::Encode<u16, D>,
69        T1: fidl::encoding::Encode<u16, D>,
70        T2: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>, D>,
71        T3: fidl::encoding::Encode<bool, D>,
72    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3)
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::<Config>(offset);
82            // Zero out padding regions. There's no need to apply masks
83            // because the unmasked parts will be overwritten by fields.
84            unsafe {
85                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
86                (ptr as *mut u64).write_unaligned(0);
87            }
88            unsafe {
89                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
90                (ptr as *mut u64).write_unaligned(0);
91            }
92            // Write the fields.
93            self.0.encode(encoder, offset + 0, depth)?;
94            self.1.encode(encoder, offset + 2, depth)?;
95            self.2.encode(encoder, offset + 8, depth)?;
96            self.3.encode(encoder, offset + 24, depth)?;
97            Ok(())
98        }
99    }
100
101    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
102        #[inline(always)]
103        fn new_empty() -> Self {
104            Self {
105                concurrent_blob_fetches: fidl::new_empty!(u16, D),
106                concurrent_package_resolves: fidl::new_empty!(u16, D),
107                manifest_public_keys: fidl::new_empty!(
108                    fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>,
109                    D
110                ),
111                verify_existing_blobs: fidl::new_empty!(bool, D),
112            }
113        }
114
115        #[inline]
116        unsafe fn decode(
117            &mut self,
118            decoder: &mut fidl::encoding::Decoder<'_, D>,
119            offset: usize,
120            _depth: fidl::encoding::Depth,
121        ) -> fidl::Result<()> {
122            decoder.debug_check_bounds::<Self>(offset);
123            // Verify that padding bytes are zero.
124            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
125            let padval = unsafe { (ptr as *const u64).read_unaligned() };
126            let mask = 0xffffffff00000000u64;
127            let maskedval = padval & mask;
128            if maskedval != 0 {
129                return Err(fidl::Error::NonZeroPadding {
130                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
131                });
132            }
133            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
134            let padval = unsafe { (ptr as *const u64).read_unaligned() };
135            let mask = 0xffffffffffffff00u64;
136            let maskedval = padval & mask;
137            if maskedval != 0 {
138                return Err(fidl::Error::NonZeroPadding {
139                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
140                });
141            }
142            fidl::decode!(u16, D, &mut self.concurrent_blob_fetches, decoder, offset + 0, _depth)?;
143            fidl::decode!(
144                u16,
145                D,
146                &mut self.concurrent_package_resolves,
147                decoder,
148                offset + 2,
149                _depth
150            )?;
151            fidl::decode!(
152                fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>,
153                D,
154                &mut self.manifest_public_keys,
155                decoder,
156                offset + 8,
157                _depth
158            )?;
159            fidl::decode!(bool, D, &mut self.verify_existing_blobs, decoder, offset + 24, _depth)?;
160            Ok(())
161        }
162    }
163}