fidl_fuchsia_fs_common/
fidl_fuchsia_fs_common.rs1#![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)]
12pub enum VfsType {
13 Blobfs,
14 Fatfs,
15 Minfs,
16 Memfs,
17 Factoryfs,
18 Fxfs,
19 F2Fs,
20 Erofs,
21 #[doc(hidden)]
22 __SourceBreaking {
23 unknown_ordinal: u32,
24 },
25}
26
27#[macro_export]
29macro_rules! VfsTypeUnknown {
30 () => {
31 _
32 };
33}
34
35impl VfsType {
36 #[inline]
37 pub fn from_primitive(prim: u32) -> Option<Self> {
38 match prim {
39 2657701153 => Some(Self::Blobfs),
40 3463007521 => Some(Self::Fatfs),
41 1852394785 => Some(Self::Minfs),
42 1047088417 => Some(Self::Memfs),
43 510217505 => Some(Self::Factoryfs),
44 1936095334 => Some(Self::Fxfs),
45 4268313889 => Some(Self::F2Fs),
46 1701998438 => Some(Self::Erofs),
47 _ => None,
48 }
49 }
50
51 #[inline]
52 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
53 match prim {
54 2657701153 => Self::Blobfs,
55 3463007521 => Self::Fatfs,
56 1852394785 => Self::Minfs,
57 1047088417 => Self::Memfs,
58 510217505 => Self::Factoryfs,
59 1936095334 => Self::Fxfs,
60 4268313889 => Self::F2Fs,
61 1701998438 => Self::Erofs,
62 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
63 }
64 }
65
66 #[inline]
67 pub fn unknown() -> Self {
68 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
69 }
70
71 #[inline]
72 pub const fn into_primitive(self) -> u32 {
73 match self {
74 Self::Blobfs => 2657701153,
75 Self::Fatfs => 3463007521,
76 Self::Minfs => 1852394785,
77 Self::Memfs => 1047088417,
78 Self::Factoryfs => 510217505,
79 Self::Fxfs => 1936095334,
80 Self::F2Fs => 4268313889,
81 Self::Erofs => 1701998438,
82 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
83 }
84 }
85
86 #[inline]
87 pub fn is_unknown(&self) -> bool {
88 match self {
89 Self::__SourceBreaking { unknown_ordinal: _ } => true,
90 _ => false,
91 }
92 }
93}
94
95pub mod admin_ordinals {
96 pub const SHUTDOWN: u64 = 0x5476abc45167ca8e;
97}
98
99mod internal {
100 use super::*;
101 unsafe impl fidl::encoding::TypeMarker for VfsType {
102 type Owned = Self;
103
104 #[inline(always)]
105 fn inline_align(_context: fidl::encoding::Context) -> usize {
106 std::mem::align_of::<u32>()
107 }
108
109 #[inline(always)]
110 fn inline_size(_context: fidl::encoding::Context) -> usize {
111 std::mem::size_of::<u32>()
112 }
113
114 #[inline(always)]
115 fn encode_is_copy() -> bool {
116 false
117 }
118
119 #[inline(always)]
120 fn decode_is_copy() -> bool {
121 false
122 }
123 }
124
125 impl fidl::encoding::ValueTypeMarker for VfsType {
126 type Borrowed<'a> = Self;
127 #[inline(always)]
128 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
129 *value
130 }
131 }
132
133 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for VfsType {
134 #[inline]
135 unsafe fn encode(
136 self,
137 encoder: &mut fidl::encoding::Encoder<'_, D>,
138 offset: usize,
139 _depth: fidl::encoding::Depth,
140 ) -> fidl::Result<()> {
141 encoder.debug_check_bounds::<Self>(offset);
142 encoder.write_num(self.into_primitive(), offset);
143 Ok(())
144 }
145 }
146
147 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VfsType {
148 #[inline(always)]
149 fn new_empty() -> Self {
150 Self::unknown()
151 }
152
153 #[inline]
154 unsafe fn decode(
155 &mut self,
156 decoder: &mut fidl::encoding::Decoder<'_, D>,
157 offset: usize,
158 _depth: fidl::encoding::Depth,
159 ) -> fidl::Result<()> {
160 decoder.debug_check_bounds::<Self>(offset);
161 let prim = decoder.read_num::<u32>(offset);
162
163 *self = Self::from_primitive_allow_unknown(prim);
164 Ok(())
165 }
166 }
167}