Skip to main content

fidl_fuchsia_pkg_http__common/
fidl_fuchsia_pkg_http__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 ClientDownloadBlobError {
14    /// HTTP GET failed with server status 429 "Too Many Requests".
15    NetworkRateLimit = 1,
16    /// Download failed because of networking related reasons.
17    Network = 2,
18    /// Download failed because the remote file could not be found.
19    NotFound = 3,
20    /// Download failed because the device is out of space.
21    NoSpace = 4,
22    /// Download failed for unspecified reasons.
23    Other = 5,
24}
25
26impl ClientDownloadBlobError {
27    #[inline]
28    pub fn from_primitive(prim: u32) -> Option<Self> {
29        match prim {
30            1 => Some(Self::NetworkRateLimit),
31            2 => Some(Self::Network),
32            3 => Some(Self::NotFound),
33            4 => Some(Self::NoSpace),
34            5 => Some(Self::Other),
35            _ => None,
36        }
37    }
38
39    #[inline]
40    pub const fn into_primitive(self) -> u32 {
41        self as u32
42    }
43}
44
45#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46#[repr(C)]
47pub struct ClientDownloadBlobResponse {
48    pub size: u64,
49}
50
51impl fidl::Persistable for ClientDownloadBlobResponse {}
52
53pub mod client_ordinals {
54    pub const DOWNLOAD_BLOB: u64 = 0x829250010b00abb;
55}
56
57mod internal {
58    use super::*;
59    unsafe impl fidl::encoding::TypeMarker for ClientDownloadBlobError {
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 ClientDownloadBlobError {
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>
92        for ClientDownloadBlobError
93    {
94        #[inline]
95        unsafe fn encode(
96            self,
97            encoder: &mut fidl::encoding::Encoder<'_, D>,
98            offset: usize,
99            _depth: fidl::encoding::Depth,
100        ) -> fidl::Result<()> {
101            encoder.debug_check_bounds::<Self>(offset);
102            encoder.write_num(self.into_primitive(), offset);
103            Ok(())
104        }
105    }
106
107    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
108        for ClientDownloadBlobError
109    {
110        #[inline(always)]
111        fn new_empty() -> Self {
112            Self::NetworkRateLimit
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            let prim = decoder.read_num::<u32>(offset);
124
125            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
126            Ok(())
127        }
128    }
129
130    impl fidl::encoding::ValueTypeMarker for ClientDownloadBlobResponse {
131        type Borrowed<'a> = &'a Self;
132        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
133            value
134        }
135    }
136
137    unsafe impl fidl::encoding::TypeMarker for ClientDownloadBlobResponse {
138        type Owned = Self;
139
140        #[inline(always)]
141        fn inline_align(_context: fidl::encoding::Context) -> usize {
142            8
143        }
144
145        #[inline(always)]
146        fn inline_size(_context: fidl::encoding::Context) -> usize {
147            8
148        }
149        #[inline(always)]
150        fn encode_is_copy() -> bool {
151            true
152        }
153
154        #[inline(always)]
155        fn decode_is_copy() -> bool {
156            true
157        }
158    }
159
160    unsafe impl<D: fidl::encoding::ResourceDialect>
161        fidl::encoding::Encode<ClientDownloadBlobResponse, D> for &ClientDownloadBlobResponse
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::<ClientDownloadBlobResponse>(offset);
171            unsafe {
172                // Copy the object into the buffer.
173                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
174                (buf_ptr as *mut ClientDownloadBlobResponse)
175                    .write_unaligned((self as *const ClientDownloadBlobResponse).read());
176                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
177                // done second because the memcpy will write garbage to these bytes.
178            }
179            Ok(())
180        }
181    }
182    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
183        fidl::encoding::Encode<ClientDownloadBlobResponse, D> for (T0,)
184    {
185        #[inline]
186        unsafe fn encode(
187            self,
188            encoder: &mut fidl::encoding::Encoder<'_, D>,
189            offset: usize,
190            depth: fidl::encoding::Depth,
191        ) -> fidl::Result<()> {
192            encoder.debug_check_bounds::<ClientDownloadBlobResponse>(offset);
193            // Zero out padding regions. There's no need to apply masks
194            // because the unmasked parts will be overwritten by fields.
195            // Write the fields.
196            self.0.encode(encoder, offset + 0, depth)?;
197            Ok(())
198        }
199    }
200
201    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
202        for ClientDownloadBlobResponse
203    {
204        #[inline(always)]
205        fn new_empty() -> Self {
206            Self { size: fidl::new_empty!(u64, D) }
207        }
208
209        #[inline]
210        unsafe fn decode(
211            &mut self,
212            decoder: &mut fidl::encoding::Decoder<'_, D>,
213            offset: usize,
214            _depth: fidl::encoding::Depth,
215        ) -> fidl::Result<()> {
216            decoder.debug_check_bounds::<Self>(offset);
217            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
218            // Verify that padding bytes are zero.
219            // Copy from the buffer into the object.
220            unsafe {
221                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
222            }
223            Ok(())
224        }
225    }
226}