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, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AdminStorageHostEnabledResponse {
36    pub enabled: bool,
37}
38
39impl fidl::Persistable for AdminStorageHostEnabledResponse {}
40
41#[derive(Clone, Debug, PartialEq)]
42pub struct RecoveryInitSystemPartitionTableRequest {
43    pub partitions: Vec<fidl_fuchsia_storage_partitions__common::PartitionInfo>,
44}
45
46impl fidl::Persistable for RecoveryInitSystemPartitionTableRequest {}
47
48#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49#[repr(C)]
50pub struct StarnixVolumeProviderMountResponse {
51    pub guid: [u8; 16],
52}
53
54impl fidl::Persistable for StarnixVolumeProviderMountResponse {}
55
56#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct Unformatted;
58
59impl fidl::Persistable for Unformatted {}
60
61pub mod admin_ordinals {
62    pub const SHRED_DATA_VOLUME: u64 = 0xb0d6c2e95343a10;
63    pub const STORAGE_HOST_ENABLED: u64 = 0x5934b6527ec49a35;
64}
65
66pub mod recovery_ordinals {
67    pub const INIT_SYSTEM_PARTITION_TABLE: u64 = 0x3dcadcbb75e2330b;
68    pub const WRITE_DATA_FILE: u64 = 0xd6cf7b3f57b418d;
69    pub const FORMAT_SYSTEM_BLOB_VOLUME: u64 = 0x4e93f6b198f61f7d;
70    pub const MOUNT_SYSTEM_BLOB_VOLUME: u64 = 0x63ddff4240e908c0;
71    pub const GET_BLOB_IMAGE_HANDLE: u64 = 0x5cc0f6646bdb5e57;
72    pub const INSTALL_BLOB_IMAGE: u64 = 0x323375398af8a29;
73}
74
75pub mod starnix_volume_provider_ordinals {
76    pub const MOUNT: u64 = 0x62ae75763dde5af6;
77}
78
79mod internal {
80    use super::*;
81    unsafe impl fidl::encoding::TypeMarker for MountMode {
82        type Owned = Self;
83
84        #[inline(always)]
85        fn inline_align(_context: fidl::encoding::Context) -> usize {
86            std::mem::align_of::<u32>()
87        }
88
89        #[inline(always)]
90        fn inline_size(_context: fidl::encoding::Context) -> usize {
91            std::mem::size_of::<u32>()
92        }
93
94        #[inline(always)]
95        fn encode_is_copy() -> bool {
96            true
97        }
98
99        #[inline(always)]
100        fn decode_is_copy() -> bool {
101            false
102        }
103    }
104
105    impl fidl::encoding::ValueTypeMarker for MountMode {
106        type Borrowed<'a> = Self;
107        #[inline(always)]
108        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
109            *value
110        }
111    }
112
113    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for MountMode {
114        #[inline]
115        unsafe fn encode(
116            self,
117            encoder: &mut fidl::encoding::Encoder<'_, D>,
118            offset: usize,
119            _depth: fidl::encoding::Depth,
120        ) -> fidl::Result<()> {
121            encoder.debug_check_bounds::<Self>(offset);
122            encoder.write_num(self.into_primitive(), offset);
123            Ok(())
124        }
125    }
126
127    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MountMode {
128        #[inline(always)]
129        fn new_empty() -> Self {
130            Self::MaybeCreate
131        }
132
133        #[inline]
134        unsafe fn decode(
135            &mut self,
136            decoder: &mut fidl::encoding::Decoder<'_, D>,
137            offset: usize,
138            _depth: fidl::encoding::Depth,
139        ) -> fidl::Result<()> {
140            decoder.debug_check_bounds::<Self>(offset);
141            let prim = decoder.read_num::<u32>(offset);
142
143            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
144            Ok(())
145        }
146    }
147
148    impl fidl::encoding::ValueTypeMarker for AdminStorageHostEnabledResponse {
149        type Borrowed<'a> = &'a Self;
150        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
151            value
152        }
153    }
154
155    unsafe impl fidl::encoding::TypeMarker for AdminStorageHostEnabledResponse {
156        type Owned = Self;
157
158        #[inline(always)]
159        fn inline_align(_context: fidl::encoding::Context) -> usize {
160            1
161        }
162
163        #[inline(always)]
164        fn inline_size(_context: fidl::encoding::Context) -> usize {
165            1
166        }
167    }
168
169    unsafe impl<D: fidl::encoding::ResourceDialect>
170        fidl::encoding::Encode<AdminStorageHostEnabledResponse, D>
171        for &AdminStorageHostEnabledResponse
172    {
173        #[inline]
174        unsafe fn encode(
175            self,
176            encoder: &mut fidl::encoding::Encoder<'_, D>,
177            offset: usize,
178            _depth: fidl::encoding::Depth,
179        ) -> fidl::Result<()> {
180            encoder.debug_check_bounds::<AdminStorageHostEnabledResponse>(offset);
181            // Delegate to tuple encoding.
182            fidl::encoding::Encode::<AdminStorageHostEnabledResponse, D>::encode(
183                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
184                encoder,
185                offset,
186                _depth,
187            )
188        }
189    }
190    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
191        fidl::encoding::Encode<AdminStorageHostEnabledResponse, 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::<AdminStorageHostEnabledResponse>(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 AdminStorageHostEnabledResponse
211    {
212        #[inline(always)]
213        fn new_empty() -> Self {
214            Self { enabled: fidl::new_empty!(bool, D) }
215        }
216
217        #[inline]
218        unsafe fn decode(
219            &mut self,
220            decoder: &mut fidl::encoding::Decoder<'_, D>,
221            offset: usize,
222            _depth: fidl::encoding::Depth,
223        ) -> fidl::Result<()> {
224            decoder.debug_check_bounds::<Self>(offset);
225            // Verify that padding bytes are zero.
226            fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
227            Ok(())
228        }
229    }
230
231    impl fidl::encoding::ValueTypeMarker for RecoveryInitSystemPartitionTableRequest {
232        type Borrowed<'a> = &'a Self;
233        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
234            value
235        }
236    }
237
238    unsafe impl fidl::encoding::TypeMarker for RecoveryInitSystemPartitionTableRequest {
239        type Owned = Self;
240
241        #[inline(always)]
242        fn inline_align(_context: fidl::encoding::Context) -> usize {
243            8
244        }
245
246        #[inline(always)]
247        fn inline_size(_context: fidl::encoding::Context) -> usize {
248            16
249        }
250    }
251
252    unsafe impl<D: fidl::encoding::ResourceDialect>
253        fidl::encoding::Encode<RecoveryInitSystemPartitionTableRequest, D>
254        for &RecoveryInitSystemPartitionTableRequest
255    {
256        #[inline]
257        unsafe fn encode(
258            self,
259            encoder: &mut fidl::encoding::Encoder<'_, D>,
260            offset: usize,
261            _depth: fidl::encoding::Depth,
262        ) -> fidl::Result<()> {
263            encoder.debug_check_bounds::<RecoveryInitSystemPartitionTableRequest>(offset);
264            // Delegate to tuple encoding.
265            fidl::encoding::Encode::<RecoveryInitSystemPartitionTableRequest, D>::encode(
266                (<fidl::encoding::Vector<
267                    fidl_fuchsia_storage_partitions__common::PartitionInfo,
268                    128,
269                > as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),),
270                encoder,
271                offset,
272                _depth,
273            )
274        }
275    }
276    unsafe impl<
277        D: fidl::encoding::ResourceDialect,
278        T0: fidl::encoding::Encode<
279                fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>,
280                D,
281            >,
282    > fidl::encoding::Encode<RecoveryInitSystemPartitionTableRequest, D> for (T0,)
283    {
284        #[inline]
285        unsafe fn encode(
286            self,
287            encoder: &mut fidl::encoding::Encoder<'_, D>,
288            offset: usize,
289            depth: fidl::encoding::Depth,
290        ) -> fidl::Result<()> {
291            encoder.debug_check_bounds::<RecoveryInitSystemPartitionTableRequest>(offset);
292            // Zero out padding regions. There's no need to apply masks
293            // because the unmasked parts will be overwritten by fields.
294            // Write the fields.
295            self.0.encode(encoder, offset + 0, depth)?;
296            Ok(())
297        }
298    }
299
300    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
301        for RecoveryInitSystemPartitionTableRequest
302    {
303        #[inline(always)]
304        fn new_empty() -> Self {
305            Self {
306                partitions: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>, D),
307            }
308        }
309
310        #[inline]
311        unsafe fn decode(
312            &mut self,
313            decoder: &mut fidl::encoding::Decoder<'_, D>,
314            offset: usize,
315            _depth: fidl::encoding::Depth,
316        ) -> fidl::Result<()> {
317            decoder.debug_check_bounds::<Self>(offset);
318            // Verify that padding bytes are zero.
319            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_storage_partitions__common::PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
320            Ok(())
321        }
322    }
323
324    impl fidl::encoding::ValueTypeMarker for StarnixVolumeProviderMountResponse {
325        type Borrowed<'a> = &'a Self;
326        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
327            value
328        }
329    }
330
331    unsafe impl fidl::encoding::TypeMarker for StarnixVolumeProviderMountResponse {
332        type Owned = Self;
333
334        #[inline(always)]
335        fn inline_align(_context: fidl::encoding::Context) -> usize {
336            1
337        }
338
339        #[inline(always)]
340        fn inline_size(_context: fidl::encoding::Context) -> usize {
341            16
342        }
343        #[inline(always)]
344        fn encode_is_copy() -> bool {
345            true
346        }
347
348        #[inline(always)]
349        fn decode_is_copy() -> bool {
350            true
351        }
352    }
353
354    unsafe impl<D: fidl::encoding::ResourceDialect>
355        fidl::encoding::Encode<StarnixVolumeProviderMountResponse, D>
356        for &StarnixVolumeProviderMountResponse
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::<StarnixVolumeProviderMountResponse>(offset);
366            unsafe {
367                // Copy the object into the buffer.
368                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
369                (buf_ptr as *mut StarnixVolumeProviderMountResponse)
370                    .write_unaligned((self as *const StarnixVolumeProviderMountResponse).read());
371                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
372                // done second because the memcpy will write garbage to these bytes.
373            }
374            Ok(())
375        }
376    }
377    unsafe impl<
378        D: fidl::encoding::ResourceDialect,
379        T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
380    > fidl::encoding::Encode<StarnixVolumeProviderMountResponse, D> for (T0,)
381    {
382        #[inline]
383        unsafe fn encode(
384            self,
385            encoder: &mut fidl::encoding::Encoder<'_, D>,
386            offset: usize,
387            depth: fidl::encoding::Depth,
388        ) -> fidl::Result<()> {
389            encoder.debug_check_bounds::<StarnixVolumeProviderMountResponse>(offset);
390            // Zero out padding regions. There's no need to apply masks
391            // because the unmasked parts will be overwritten by fields.
392            // Write the fields.
393            self.0.encode(encoder, offset + 0, depth)?;
394            Ok(())
395        }
396    }
397
398    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
399        for StarnixVolumeProviderMountResponse
400    {
401        #[inline(always)]
402        fn new_empty() -> Self {
403            Self { guid: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D) }
404        }
405
406        #[inline]
407        unsafe fn decode(
408            &mut self,
409            decoder: &mut fidl::encoding::Decoder<'_, D>,
410            offset: usize,
411            _depth: fidl::encoding::Depth,
412        ) -> fidl::Result<()> {
413            decoder.debug_check_bounds::<Self>(offset);
414            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
415            // Verify that padding bytes are zero.
416            // Copy from the buffer into the object.
417            unsafe {
418                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
419            }
420            Ok(())
421        }
422    }
423
424    impl fidl::encoding::ValueTypeMarker for Unformatted {
425        type Borrowed<'a> = &'a Self;
426        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
427            value
428        }
429    }
430
431    unsafe impl fidl::encoding::TypeMarker for Unformatted {
432        type Owned = Self;
433
434        #[inline(always)]
435        fn inline_align(_context: fidl::encoding::Context) -> usize {
436            1
437        }
438
439        #[inline(always)]
440        fn inline_size(_context: fidl::encoding::Context) -> usize {
441            1
442        }
443    }
444
445    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Unformatted, D>
446        for &Unformatted
447    {
448        #[inline]
449        unsafe fn encode(
450            self,
451            encoder: &mut fidl::encoding::Encoder<'_, D>,
452            offset: usize,
453            _depth: fidl::encoding::Depth,
454        ) -> fidl::Result<()> {
455            encoder.debug_check_bounds::<Unformatted>(offset);
456            encoder.write_num(0u8, offset);
457            Ok(())
458        }
459    }
460
461    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Unformatted {
462        #[inline(always)]
463        fn new_empty() -> Self {
464            Self
465        }
466
467        #[inline]
468        unsafe fn decode(
469            &mut self,
470            decoder: &mut fidl::encoding::Decoder<'_, D>,
471            offset: usize,
472            _depth: fidl::encoding::Depth,
473        ) -> fidl::Result<()> {
474            decoder.debug_check_bounds::<Self>(offset);
475            match decoder.read_num::<u8>(offset) {
476                0 => Ok(()),
477                _ => Err(fidl::Error::Invalid),
478            }
479        }
480    }
481}