Skip to main content

fidl_fuchsia_fshost__common/
fidl_fuchsia_fshost__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 MountMode {
14    MaybeCreate = 1,
15    AlwaysCreate = 2,
16}
17
18impl MountMode {
19    #[inline]
20    pub fn from_primitive(prim: u32) -> Option<Self> {
21        match prim {
22            1 => Some(Self::MaybeCreate),
23            2 => Some(Self::AlwaysCreate),
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, Debug, PartialEq)]
35pub struct RecoveryInitSystemPartitionTableRequest {
36    pub partitions: Vec<fidl_fuchsia_storage_partitions__common::PartitionInfo>,
37}
38
39impl fidl::Persistable for RecoveryInitSystemPartitionTableRequest {}
40
41#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42#[repr(C)]
43pub struct StarnixVolumeProviderMountResponse {
44    pub guid: [u8; 16],
45}
46
47impl fidl::Persistable for StarnixVolumeProviderMountResponse {}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct Unformatted;
51
52impl fidl::Persistable for Unformatted {}
53
54pub mod admin_ordinals {
55    pub const SHRED_DATA_VOLUME: u64 = 0xb0d6c2e95343a10;
56}
57
58pub mod recovery_ordinals {
59    pub const INIT_SYSTEM_PARTITION_TABLE: u64 = 0x3dcadcbb75e2330b;
60    pub const WRITE_DATA_FILE: u64 = 0xd6cf7b3f57b418d;
61    pub const FORMAT_SYSTEM_BLOB_VOLUME: u64 = 0x4e93f6b198f61f7d;
62    pub const MOUNT_SYSTEM_BLOB_VOLUME: u64 = 0x63ddff4240e908c0;
63    pub const GET_BLOB_IMAGE_HANDLE: u64 = 0x5cc0f6646bdb5e57;
64    pub const INSTALL_BLOB_IMAGE: u64 = 0x323375398af8a29;
65}
66
67pub mod starnix_volume_provider_ordinals {
68    pub const MOUNT: u64 = 0x62ae75763dde5af6;
69}
70
71mod internal {
72    use super::*;
73    unsafe impl fidl::encoding::TypeMarker for MountMode {
74        type Owned = Self;
75
76        #[inline(always)]
77        fn inline_align(_context: fidl::encoding::Context) -> usize {
78            std::mem::align_of::<u32>()
79        }
80
81        #[inline(always)]
82        fn inline_size(_context: fidl::encoding::Context) -> usize {
83            std::mem::size_of::<u32>()
84        }
85
86        #[inline(always)]
87        fn encode_is_copy() -> bool {
88            true
89        }
90
91        #[inline(always)]
92        fn decode_is_copy() -> bool {
93            false
94        }
95    }
96
97    impl fidl::encoding::ValueTypeMarker for MountMode {
98        type Borrowed<'a> = Self;
99        #[inline(always)]
100        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
101            *value
102        }
103    }
104
105    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for MountMode {
106        #[inline]
107        unsafe fn encode(
108            self,
109            encoder: &mut fidl::encoding::Encoder<'_, D>,
110            offset: usize,
111            _depth: fidl::encoding::Depth,
112        ) -> fidl::Result<()> {
113            encoder.debug_check_bounds::<Self>(offset);
114            encoder.write_num(self.into_primitive(), offset);
115            Ok(())
116        }
117    }
118
119    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MountMode {
120        #[inline(always)]
121        fn new_empty() -> Self {
122            Self::MaybeCreate
123        }
124
125        #[inline]
126        unsafe fn decode(
127            &mut self,
128            decoder: &mut fidl::encoding::Decoder<'_, D>,
129            offset: usize,
130            _depth: fidl::encoding::Depth,
131        ) -> fidl::Result<()> {
132            decoder.debug_check_bounds::<Self>(offset);
133            let prim = decoder.read_num::<u32>(offset);
134
135            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
136            Ok(())
137        }
138    }
139
140    impl fidl::encoding::ValueTypeMarker for RecoveryInitSystemPartitionTableRequest {
141        type Borrowed<'a> = &'a Self;
142        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
143            value
144        }
145    }
146
147    unsafe impl fidl::encoding::TypeMarker for RecoveryInitSystemPartitionTableRequest {
148        type Owned = Self;
149
150        #[inline(always)]
151        fn inline_align(_context: fidl::encoding::Context) -> usize {
152            8
153        }
154
155        #[inline(always)]
156        fn inline_size(_context: fidl::encoding::Context) -> usize {
157            16
158        }
159    }
160
161    unsafe impl<D: fidl::encoding::ResourceDialect>
162        fidl::encoding::Encode<RecoveryInitSystemPartitionTableRequest, D>
163        for &RecoveryInitSystemPartitionTableRequest
164    {
165        #[inline]
166        unsafe fn encode(
167            self,
168            encoder: &mut fidl::encoding::Encoder<'_, D>,
169            offset: usize,
170            _depth: fidl::encoding::Depth,
171        ) -> fidl::Result<()> {
172            encoder.debug_check_bounds::<RecoveryInitSystemPartitionTableRequest>(offset);
173            // Delegate to tuple encoding.
174            fidl::encoding::Encode::<RecoveryInitSystemPartitionTableRequest, D>::encode(
175                (<fidl::encoding::Vector<
176                    fidl_fuchsia_storage_partitions__common::PartitionInfo,
177                    128,
178                > as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),),
179                encoder,
180                offset,
181                _depth,
182            )
183        }
184    }
185    unsafe impl<
186        D: fidl::encoding::ResourceDialect,
187        T0: fidl::encoding::Encode<
188                fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>,
189                D,
190            >,
191    > fidl::encoding::Encode<RecoveryInitSystemPartitionTableRequest, D> for (T0,)
192    {
193        #[inline]
194        unsafe fn encode(
195            self,
196            encoder: &mut fidl::encoding::Encoder<'_, D>,
197            offset: usize,
198            depth: fidl::encoding::Depth,
199        ) -> fidl::Result<()> {
200            encoder.debug_check_bounds::<RecoveryInitSystemPartitionTableRequest>(offset);
201            // Zero out padding regions. There's no need to apply masks
202            // because the unmasked parts will be overwritten by fields.
203            // Write the fields.
204            self.0.encode(encoder, offset + 0, depth)?;
205            Ok(())
206        }
207    }
208
209    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
210        for RecoveryInitSystemPartitionTableRequest
211    {
212        #[inline(always)]
213        fn new_empty() -> Self {
214            Self {
215                partitions: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>, D),
216            }
217        }
218
219        #[inline]
220        unsafe fn decode(
221            &mut self,
222            decoder: &mut fidl::encoding::Decoder<'_, D>,
223            offset: usize,
224            _depth: fidl::encoding::Depth,
225        ) -> fidl::Result<()> {
226            decoder.debug_check_bounds::<Self>(offset);
227            // Verify that padding bytes are zero.
228            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
229            Ok(())
230        }
231    }
232
233    impl fidl::encoding::ValueTypeMarker for StarnixVolumeProviderMountResponse {
234        type Borrowed<'a> = &'a Self;
235        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
236            value
237        }
238    }
239
240    unsafe impl fidl::encoding::TypeMarker for StarnixVolumeProviderMountResponse {
241        type Owned = Self;
242
243        #[inline(always)]
244        fn inline_align(_context: fidl::encoding::Context) -> usize {
245            1
246        }
247
248        #[inline(always)]
249        fn inline_size(_context: fidl::encoding::Context) -> usize {
250            16
251        }
252        #[inline(always)]
253        fn encode_is_copy() -> bool {
254            true
255        }
256
257        #[inline(always)]
258        fn decode_is_copy() -> bool {
259            true
260        }
261    }
262
263    unsafe impl<D: fidl::encoding::ResourceDialect>
264        fidl::encoding::Encode<StarnixVolumeProviderMountResponse, D>
265        for &StarnixVolumeProviderMountResponse
266    {
267        #[inline]
268        unsafe fn encode(
269            self,
270            encoder: &mut fidl::encoding::Encoder<'_, D>,
271            offset: usize,
272            _depth: fidl::encoding::Depth,
273        ) -> fidl::Result<()> {
274            encoder.debug_check_bounds::<StarnixVolumeProviderMountResponse>(offset);
275            unsafe {
276                // Copy the object into the buffer.
277                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
278                (buf_ptr as *mut StarnixVolumeProviderMountResponse)
279                    .write_unaligned((self as *const StarnixVolumeProviderMountResponse).read());
280                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
281                // done second because the memcpy will write garbage to these bytes.
282            }
283            Ok(())
284        }
285    }
286    unsafe impl<
287        D: fidl::encoding::ResourceDialect,
288        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
289    > fidl::encoding::Encode<StarnixVolumeProviderMountResponse, D> for (T0,)
290    {
291        #[inline]
292        unsafe fn encode(
293            self,
294            encoder: &mut fidl::encoding::Encoder<'_, D>,
295            offset: usize,
296            depth: fidl::encoding::Depth,
297        ) -> fidl::Result<()> {
298            encoder.debug_check_bounds::<StarnixVolumeProviderMountResponse>(offset);
299            // Zero out padding regions. There's no need to apply masks
300            // because the unmasked parts will be overwritten by fields.
301            // Write the fields.
302            self.0.encode(encoder, offset + 0, depth)?;
303            Ok(())
304        }
305    }
306
307    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
308        for StarnixVolumeProviderMountResponse
309    {
310        #[inline(always)]
311        fn new_empty() -> Self {
312            Self { guid: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D) }
313        }
314
315        #[inline]
316        unsafe fn decode(
317            &mut self,
318            decoder: &mut fidl::encoding::Decoder<'_, D>,
319            offset: usize,
320            _depth: fidl::encoding::Depth,
321        ) -> fidl::Result<()> {
322            decoder.debug_check_bounds::<Self>(offset);
323            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
324            // Verify that padding bytes are zero.
325            // Copy from the buffer into the object.
326            unsafe {
327                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
328            }
329            Ok(())
330        }
331    }
332
333    impl fidl::encoding::ValueTypeMarker for Unformatted {
334        type Borrowed<'a> = &'a Self;
335        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
336            value
337        }
338    }
339
340    unsafe impl fidl::encoding::TypeMarker for Unformatted {
341        type Owned = Self;
342
343        #[inline(always)]
344        fn inline_align(_context: fidl::encoding::Context) -> usize {
345            1
346        }
347
348        #[inline(always)]
349        fn inline_size(_context: fidl::encoding::Context) -> usize {
350            1
351        }
352    }
353
354    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Unformatted, D>
355        for &Unformatted
356    {
357        #[inline]
358        unsafe fn encode(
359            self,
360            encoder: &mut fidl::encoding::Encoder<'_, D>,
361            offset: usize,
362            _depth: fidl::encoding::Depth,
363        ) -> fidl::Result<()> {
364            encoder.debug_check_bounds::<Unformatted>(offset);
365            encoder.write_num(0u8, offset);
366            Ok(())
367        }
368    }
369
370    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Unformatted {
371        #[inline(always)]
372        fn new_empty() -> Self {
373            Self
374        }
375
376        #[inline]
377        unsafe fn decode(
378            &mut self,
379            decoder: &mut fidl::encoding::Decoder<'_, D>,
380            offset: usize,
381            _depth: fidl::encoding::Depth,
382        ) -> fidl::Result<()> {
383            decoder.debug_check_bounds::<Self>(offset);
384            match decoder.read_num::<u8>(offset) {
385                0 => Ok(()),
386                _ => Err(fidl::Error::Invalid),
387            }
388        }
389    }
390}