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