Skip to main content

fidl_cf_sc_internal_pkgresolverconfig__common/
fidl_cf_sc_internal_pkgresolverconfig__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, Eq, Hash, Ord, PartialEq, PartialOrd)]
12#[repr(C)]
13pub struct Config {
14    pub blob_download_concurrency_limit: u16,
15    pub blob_download_resumption_attempts_limit: u32,
16    pub blob_network_body_timeout_seconds: u32,
17    pub blob_network_header_timeout_seconds: u32,
18    pub delivery_blob_type: u32,
19    pub tuf_metadata_timeout_seconds: u32,
20    pub tuf_network_header_timeout_seconds: u32,
21}
22
23impl fidl::Persistable for Config {}
24
25mod internal {
26    use super::*;
27
28    impl fidl::encoding::ValueTypeMarker for Config {
29        type Borrowed<'a> = &'a Self;
30        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
31            value
32        }
33    }
34
35    unsafe impl fidl::encoding::TypeMarker for Config {
36        type Owned = Self;
37
38        #[inline(always)]
39        fn inline_align(_context: fidl::encoding::Context) -> usize {
40            4
41        }
42
43        #[inline(always)]
44        fn inline_size(_context: fidl::encoding::Context) -> usize {
45            28
46        }
47    }
48
49    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
50        #[inline]
51        unsafe fn encode(
52            self,
53            encoder: &mut fidl::encoding::Encoder<'_, D>,
54            offset: usize,
55            _depth: fidl::encoding::Depth,
56        ) -> fidl::Result<()> {
57            encoder.debug_check_bounds::<Config>(offset);
58            unsafe {
59                // Copy the object into the buffer.
60                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
61                (buf_ptr as *mut Config).write_unaligned((self as *const Config).read());
62                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
63                // done second because the memcpy will write garbage to these bytes.
64                let padding_ptr = buf_ptr.offset(0) as *mut u32;
65                let padding_mask = 0xffff0000u32;
66                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
67            }
68            Ok(())
69        }
70    }
71    unsafe impl<
72        D: fidl::encoding::ResourceDialect,
73        T0: fidl::encoding::Encode<u16, D>,
74        T1: fidl::encoding::Encode<u32, D>,
75        T2: fidl::encoding::Encode<u32, D>,
76        T3: fidl::encoding::Encode<u32, D>,
77        T4: fidl::encoding::Encode<u32, D>,
78        T5: fidl::encoding::Encode<u32, D>,
79        T6: fidl::encoding::Encode<u32, D>,
80    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6)
81    {
82        #[inline]
83        unsafe fn encode(
84            self,
85            encoder: &mut fidl::encoding::Encoder<'_, D>,
86            offset: usize,
87            depth: fidl::encoding::Depth,
88        ) -> fidl::Result<()> {
89            encoder.debug_check_bounds::<Config>(offset);
90            // Zero out padding regions. There's no need to apply masks
91            // because the unmasked parts will be overwritten by fields.
92            unsafe {
93                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
94                (ptr as *mut u32).write_unaligned(0);
95            }
96            // Write the fields.
97            self.0.encode(encoder, offset + 0, depth)?;
98            self.1.encode(encoder, offset + 4, depth)?;
99            self.2.encode(encoder, offset + 8, depth)?;
100            self.3.encode(encoder, offset + 12, depth)?;
101            self.4.encode(encoder, offset + 16, depth)?;
102            self.5.encode(encoder, offset + 20, depth)?;
103            self.6.encode(encoder, offset + 24, depth)?;
104            Ok(())
105        }
106    }
107
108    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
109        #[inline(always)]
110        fn new_empty() -> Self {
111            Self {
112                blob_download_concurrency_limit: fidl::new_empty!(u16, D),
113                blob_download_resumption_attempts_limit: fidl::new_empty!(u32, D),
114                blob_network_body_timeout_seconds: fidl::new_empty!(u32, D),
115                blob_network_header_timeout_seconds: fidl::new_empty!(u32, D),
116                delivery_blob_type: fidl::new_empty!(u32, D),
117                tuf_metadata_timeout_seconds: fidl::new_empty!(u32, D),
118                tuf_network_header_timeout_seconds: fidl::new_empty!(u32, D),
119            }
120        }
121
122        #[inline]
123        unsafe fn decode(
124            &mut self,
125            decoder: &mut fidl::encoding::Decoder<'_, D>,
126            offset: usize,
127            _depth: fidl::encoding::Depth,
128        ) -> fidl::Result<()> {
129            decoder.debug_check_bounds::<Self>(offset);
130            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
131            // Verify that padding bytes are zero.
132            let ptr = unsafe { buf_ptr.offset(0) };
133            let padval = unsafe { (ptr as *const u32).read_unaligned() };
134            let mask = 0xffff0000u32;
135            let maskedval = padval & mask;
136            if maskedval != 0 {
137                return Err(fidl::Error::NonZeroPadding {
138                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
139                });
140            }
141            // Copy from the buffer into the object.
142            unsafe {
143                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 28);
144            }
145            Ok(())
146        }
147    }
148}