1#![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
11pub const MAX_PARTITIONS: u32 = 128;
12
13#[derive(Clone, Debug, PartialEq)]
14pub struct PartitionInfo {
15 pub name: String,
16 pub type_guid: fidl_fuchsia_hardware_block_partition__common::Guid,
17 pub instance_guid: fidl_fuchsia_hardware_block_partition__common::Guid,
18 pub start_block: u64,
19 pub num_blocks: u64,
20 pub flags: u64,
21}
22
23impl fidl::Persistable for PartitionInfo {}
24
25#[derive(Clone, Debug, PartialEq)]
26pub struct PartitionsAdminResetPartitionTableRequest {
27 pub partitions: Vec<PartitionInfo>,
28}
29
30impl fidl::Persistable for PartitionsAdminResetPartitionTableRequest {}
31
32#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33#[repr(C)]
34pub struct PartitionsManagerGetBlockInfoResponse {
35 pub block_count: u64,
36 pub block_size: u32,
37}
38
39impl fidl::Persistable for PartitionsManagerGetBlockInfoResponse {}
40
41pub mod partition_ordinals {
42 pub const UPDATE_METADATA: u64 = 0x7bce44e5c9d5009c;
43}
44
45pub mod partitions_admin_ordinals {
46 pub const RESET_PARTITION_TABLE: u64 = 0x6d999e2c120fef14;
47}
48
49pub mod partitions_manager_ordinals {
50 pub const GET_BLOCK_INFO: u64 = 0x55663648cae3a1ef;
51 pub const CREATE_TRANSACTION: u64 = 0x5cedad08ef04fd02;
52 pub const COMMIT_TRANSACTION: u64 = 0x2354762d579c7654;
53 pub const ADD_PARTITION: u64 = 0x32afa9f7acf47e38;
54}
55
56mod internal {
57 use super::*;
58
59 impl fidl::encoding::ValueTypeMarker for PartitionInfo {
60 type Borrowed<'a> = &'a Self;
61 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
62 value
63 }
64 }
65
66 unsafe impl fidl::encoding::TypeMarker for PartitionInfo {
67 type Owned = Self;
68
69 #[inline(always)]
70 fn inline_align(_context: fidl::encoding::Context) -> usize {
71 8
72 }
73
74 #[inline(always)]
75 fn inline_size(_context: fidl::encoding::Context) -> usize {
76 72
77 }
78 }
79
80 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PartitionInfo, D>
81 for &PartitionInfo
82 {
83 #[inline]
84 unsafe fn encode(
85 self,
86 encoder: &mut fidl::encoding::Encoder<'_, D>,
87 offset: usize,
88 _depth: fidl::encoding::Depth,
89 ) -> fidl::Result<()> {
90 encoder.debug_check_bounds::<PartitionInfo>(offset);
91 fidl::encoding::Encode::<PartitionInfo, D>::encode(
93 (
94 <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
95 <fidl_fuchsia_hardware_block_partition__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.type_guid),
96 <fidl_fuchsia_hardware_block_partition__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.instance_guid),
97 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.start_block),
98 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_blocks),
99 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
100 ),
101 encoder, offset, _depth
102 )
103 }
104 }
105 unsafe impl<
106 D: fidl::encoding::ResourceDialect,
107 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
108 T1: fidl::encoding::Encode<fidl_fuchsia_hardware_block_partition__common::Guid, D>,
109 T2: fidl::encoding::Encode<fidl_fuchsia_hardware_block_partition__common::Guid, D>,
110 T3: fidl::encoding::Encode<u64, D>,
111 T4: fidl::encoding::Encode<u64, D>,
112 T5: fidl::encoding::Encode<u64, D>,
113 > fidl::encoding::Encode<PartitionInfo, D> for (T0, T1, T2, T3, T4, T5)
114 {
115 #[inline]
116 unsafe fn encode(
117 self,
118 encoder: &mut fidl::encoding::Encoder<'_, D>,
119 offset: usize,
120 depth: fidl::encoding::Depth,
121 ) -> fidl::Result<()> {
122 encoder.debug_check_bounds::<PartitionInfo>(offset);
123 self.0.encode(encoder, offset + 0, depth)?;
127 self.1.encode(encoder, offset + 16, depth)?;
128 self.2.encode(encoder, offset + 32, depth)?;
129 self.3.encode(encoder, offset + 48, depth)?;
130 self.4.encode(encoder, offset + 56, depth)?;
131 self.5.encode(encoder, offset + 64, depth)?;
132 Ok(())
133 }
134 }
135
136 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PartitionInfo {
137 #[inline(always)]
138 fn new_empty() -> Self {
139 Self {
140 name: fidl::new_empty!(fidl::encoding::BoundedString<128>, D),
141 type_guid: fidl::new_empty!(fidl_fuchsia_hardware_block_partition__common::Guid, D),
142 instance_guid: fidl::new_empty!(
143 fidl_fuchsia_hardware_block_partition__common::Guid,
144 D
145 ),
146 start_block: fidl::new_empty!(u64, D),
147 num_blocks: fidl::new_empty!(u64, D),
148 flags: fidl::new_empty!(u64, D),
149 }
150 }
151
152 #[inline]
153 unsafe fn decode(
154 &mut self,
155 decoder: &mut fidl::encoding::Decoder<'_, D>,
156 offset: usize,
157 _depth: fidl::encoding::Depth,
158 ) -> fidl::Result<()> {
159 decoder.debug_check_bounds::<Self>(offset);
160 fidl::decode!(
162 fidl::encoding::BoundedString<128>,
163 D,
164 &mut self.name,
165 decoder,
166 offset + 0,
167 _depth
168 )?;
169 fidl::decode!(
170 fidl_fuchsia_hardware_block_partition__common::Guid,
171 D,
172 &mut self.type_guid,
173 decoder,
174 offset + 16,
175 _depth
176 )?;
177 fidl::decode!(
178 fidl_fuchsia_hardware_block_partition__common::Guid,
179 D,
180 &mut self.instance_guid,
181 decoder,
182 offset + 32,
183 _depth
184 )?;
185 fidl::decode!(u64, D, &mut self.start_block, decoder, offset + 48, _depth)?;
186 fidl::decode!(u64, D, &mut self.num_blocks, decoder, offset + 56, _depth)?;
187 fidl::decode!(u64, D, &mut self.flags, decoder, offset + 64, _depth)?;
188 Ok(())
189 }
190 }
191
192 impl fidl::encoding::ValueTypeMarker for PartitionsAdminResetPartitionTableRequest {
193 type Borrowed<'a> = &'a Self;
194 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
195 value
196 }
197 }
198
199 unsafe impl fidl::encoding::TypeMarker for PartitionsAdminResetPartitionTableRequest {
200 type Owned = Self;
201
202 #[inline(always)]
203 fn inline_align(_context: fidl::encoding::Context) -> usize {
204 8
205 }
206
207 #[inline(always)]
208 fn inline_size(_context: fidl::encoding::Context) -> usize {
209 16
210 }
211 }
212
213 unsafe impl<D: fidl::encoding::ResourceDialect>
214 fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D>
215 for &PartitionsAdminResetPartitionTableRequest
216 {
217 #[inline]
218 unsafe fn encode(
219 self,
220 encoder: &mut fidl::encoding::Encoder<'_, D>,
221 offset: usize,
222 _depth: fidl::encoding::Depth,
223 ) -> fidl::Result<()> {
224 encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
225 fidl::encoding::Encode::<PartitionsAdminResetPartitionTableRequest, D>::encode(
227 (
228 <fidl::encoding::Vector<PartitionInfo, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),
229 ),
230 encoder, offset, _depth
231 )
232 }
233 }
234 unsafe impl<
235 D: fidl::encoding::ResourceDialect,
236 T0: fidl::encoding::Encode<fidl::encoding::Vector<PartitionInfo, 128>, D>,
237 > fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D> for (T0,)
238 {
239 #[inline]
240 unsafe fn encode(
241 self,
242 encoder: &mut fidl::encoding::Encoder<'_, D>,
243 offset: usize,
244 depth: fidl::encoding::Depth,
245 ) -> fidl::Result<()> {
246 encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
247 self.0.encode(encoder, offset + 0, depth)?;
251 Ok(())
252 }
253 }
254
255 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
256 for PartitionsAdminResetPartitionTableRequest
257 {
258 #[inline(always)]
259 fn new_empty() -> Self {
260 Self { partitions: fidl::new_empty!(fidl::encoding::Vector<PartitionInfo, 128>, D) }
261 }
262
263 #[inline]
264 unsafe fn decode(
265 &mut self,
266 decoder: &mut fidl::encoding::Decoder<'_, D>,
267 offset: usize,
268 _depth: fidl::encoding::Depth,
269 ) -> fidl::Result<()> {
270 decoder.debug_check_bounds::<Self>(offset);
271 fidl::decode!(fidl::encoding::Vector<PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
273 Ok(())
274 }
275 }
276
277 impl fidl::encoding::ValueTypeMarker for PartitionsManagerGetBlockInfoResponse {
278 type Borrowed<'a> = &'a Self;
279 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
280 value
281 }
282 }
283
284 unsafe impl fidl::encoding::TypeMarker for PartitionsManagerGetBlockInfoResponse {
285 type Owned = Self;
286
287 #[inline(always)]
288 fn inline_align(_context: fidl::encoding::Context) -> usize {
289 8
290 }
291
292 #[inline(always)]
293 fn inline_size(_context: fidl::encoding::Context) -> usize {
294 16
295 }
296 }
297
298 unsafe impl<D: fidl::encoding::ResourceDialect>
299 fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D>
300 for &PartitionsManagerGetBlockInfoResponse
301 {
302 #[inline]
303 unsafe fn encode(
304 self,
305 encoder: &mut fidl::encoding::Encoder<'_, D>,
306 offset: usize,
307 _depth: fidl::encoding::Depth,
308 ) -> fidl::Result<()> {
309 encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
310 unsafe {
311 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
313 (buf_ptr as *mut PartitionsManagerGetBlockInfoResponse)
314 .write_unaligned((self as *const PartitionsManagerGetBlockInfoResponse).read());
315 let padding_ptr = buf_ptr.offset(8) as *mut u64;
318 let padding_mask = 0xffffffff00000000u64;
319 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
320 }
321 Ok(())
322 }
323 }
324 unsafe impl<
325 D: fidl::encoding::ResourceDialect,
326 T0: fidl::encoding::Encode<u64, D>,
327 T1: fidl::encoding::Encode<u32, D>,
328 > fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D> for (T0, T1)
329 {
330 #[inline]
331 unsafe fn encode(
332 self,
333 encoder: &mut fidl::encoding::Encoder<'_, D>,
334 offset: usize,
335 depth: fidl::encoding::Depth,
336 ) -> fidl::Result<()> {
337 encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
338 unsafe {
341 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
342 (ptr as *mut u64).write_unaligned(0);
343 }
344 self.0.encode(encoder, offset + 0, depth)?;
346 self.1.encode(encoder, offset + 8, depth)?;
347 Ok(())
348 }
349 }
350
351 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
352 for PartitionsManagerGetBlockInfoResponse
353 {
354 #[inline(always)]
355 fn new_empty() -> Self {
356 Self { block_count: fidl::new_empty!(u64, D), block_size: fidl::new_empty!(u32, D) }
357 }
358
359 #[inline]
360 unsafe fn decode(
361 &mut self,
362 decoder: &mut fidl::encoding::Decoder<'_, D>,
363 offset: usize,
364 _depth: fidl::encoding::Depth,
365 ) -> fidl::Result<()> {
366 decoder.debug_check_bounds::<Self>(offset);
367 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
368 let ptr = unsafe { buf_ptr.offset(8) };
370 let padval = unsafe { (ptr as *const u64).read_unaligned() };
371 let mask = 0xffffffff00000000u64;
372 let maskedval = padval & mask;
373 if maskedval != 0 {
374 return Err(fidl::Error::NonZeroPadding {
375 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
376 });
377 }
378 unsafe {
380 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
381 }
382 Ok(())
383 }
384 }
385}