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
13pub const MAX_PARTITIONS_PER_OVERLAY: u32 = 2;
14
15#[derive(Clone, Debug, PartialEq)]
16pub struct OverlayPartitionGetPartitionsResponse {
17 pub partitions: Vec<PartitionInfo>,
18}
19
20impl fidl::Persistable for OverlayPartitionGetPartitionsResponse {}
21
22#[derive(Clone, Debug, PartialEq)]
23pub struct PartitionInfo {
24 pub name: String,
25 pub type_guid: fidl_fuchsia_storage_block__common::Guid,
26 pub instance_guid: fidl_fuchsia_storage_block__common::Guid,
27 pub start_block: u64,
28 pub num_blocks: u64,
29 pub flags: u64,
30}
31
32impl fidl::Persistable for PartitionInfo {}
33
34#[derive(Clone, Debug, PartialEq)]
35pub struct PartitionsAdminResetPartitionTableRequest {
36 pub partitions: Vec<PartitionInfo>,
37}
38
39impl fidl::Persistable for PartitionsAdminResetPartitionTableRequest {}
40
41#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42#[repr(C)]
43pub struct PartitionsManagerGetBlockInfoResponse {
44 pub block_count: u64,
45 pub block_size: u32,
46}
47
48impl fidl::Persistable for PartitionsManagerGetBlockInfoResponse {}
49
50pub mod overlay_partition_ordinals {
51 pub const GET_PARTITIONS: u64 = 0x7296daafa369c09b;
52}
53
54pub mod partition_ordinals {
55 pub const UPDATE_METADATA: u64 = 0x7bce44e5c9d5009c;
56}
57
58pub mod partitions_admin_ordinals {
59 pub const RESET_PARTITION_TABLE: u64 = 0x6d999e2c120fef14;
60}
61
62pub mod partitions_manager_ordinals {
63 pub const GET_BLOCK_INFO: u64 = 0x55663648cae3a1ef;
64 pub const CREATE_TRANSACTION: u64 = 0x5cedad08ef04fd02;
65 pub const COMMIT_TRANSACTION: u64 = 0x2354762d579c7654;
66 pub const ADD_PARTITION: u64 = 0x32afa9f7acf47e38;
67}
68
69mod internal {
70 use super::*;
71
72 impl fidl::encoding::ValueTypeMarker for OverlayPartitionGetPartitionsResponse {
73 type Borrowed<'a> = &'a Self;
74 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
75 value
76 }
77 }
78
79 unsafe impl fidl::encoding::TypeMarker for OverlayPartitionGetPartitionsResponse {
80 type Owned = Self;
81
82 #[inline(always)]
83 fn inline_align(_context: fidl::encoding::Context) -> usize {
84 8
85 }
86
87 #[inline(always)]
88 fn inline_size(_context: fidl::encoding::Context) -> usize {
89 16
90 }
91 }
92
93 unsafe impl<D: fidl::encoding::ResourceDialect>
94 fidl::encoding::Encode<OverlayPartitionGetPartitionsResponse, D>
95 for &OverlayPartitionGetPartitionsResponse
96 {
97 #[inline]
98 unsafe fn encode(
99 self,
100 encoder: &mut fidl::encoding::Encoder<'_, D>,
101 offset: usize,
102 _depth: fidl::encoding::Depth,
103 ) -> fidl::Result<()> {
104 encoder.debug_check_bounds::<OverlayPartitionGetPartitionsResponse>(offset);
105 fidl::encoding::Encode::<OverlayPartitionGetPartitionsResponse, D>::encode(
107 (
108 <fidl::encoding::Vector<PartitionInfo, 2> as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),
109 ),
110 encoder, offset, _depth
111 )
112 }
113 }
114 unsafe impl<
115 D: fidl::encoding::ResourceDialect,
116 T0: fidl::encoding::Encode<fidl::encoding::Vector<PartitionInfo, 2>, D>,
117 > fidl::encoding::Encode<OverlayPartitionGetPartitionsResponse, D> for (T0,)
118 {
119 #[inline]
120 unsafe fn encode(
121 self,
122 encoder: &mut fidl::encoding::Encoder<'_, D>,
123 offset: usize,
124 depth: fidl::encoding::Depth,
125 ) -> fidl::Result<()> {
126 encoder.debug_check_bounds::<OverlayPartitionGetPartitionsResponse>(offset);
127 self.0.encode(encoder, offset + 0, depth)?;
131 Ok(())
132 }
133 }
134
135 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
136 for OverlayPartitionGetPartitionsResponse
137 {
138 #[inline(always)]
139 fn new_empty() -> Self {
140 Self { partitions: fidl::new_empty!(fidl::encoding::Vector<PartitionInfo, 2>, D) }
141 }
142
143 #[inline]
144 unsafe fn decode(
145 &mut self,
146 decoder: &mut fidl::encoding::Decoder<'_, D>,
147 offset: usize,
148 _depth: fidl::encoding::Depth,
149 ) -> fidl::Result<()> {
150 decoder.debug_check_bounds::<Self>(offset);
151 fidl::decode!(fidl::encoding::Vector<PartitionInfo, 2>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
153 Ok(())
154 }
155 }
156
157 impl fidl::encoding::ValueTypeMarker for PartitionInfo {
158 type Borrowed<'a> = &'a Self;
159 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
160 value
161 }
162 }
163
164 unsafe impl fidl::encoding::TypeMarker for PartitionInfo {
165 type Owned = Self;
166
167 #[inline(always)]
168 fn inline_align(_context: fidl::encoding::Context) -> usize {
169 8
170 }
171
172 #[inline(always)]
173 fn inline_size(_context: fidl::encoding::Context) -> usize {
174 72
175 }
176 }
177
178 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PartitionInfo, D>
179 for &PartitionInfo
180 {
181 #[inline]
182 unsafe fn encode(
183 self,
184 encoder: &mut fidl::encoding::Encoder<'_, D>,
185 offset: usize,
186 _depth: fidl::encoding::Depth,
187 ) -> fidl::Result<()> {
188 encoder.debug_check_bounds::<PartitionInfo>(offset);
189 fidl::encoding::Encode::<PartitionInfo, D>::encode(
191 (
192 <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
193 <fidl_fuchsia_storage_block__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.type_guid),
194 <fidl_fuchsia_storage_block__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.instance_guid),
195 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.start_block),
196 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_blocks),
197 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
198 ),
199 encoder, offset, _depth
200 )
201 }
202 }
203 unsafe impl<
204 D: fidl::encoding::ResourceDialect,
205 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
206 T1: fidl::encoding::Encode<fidl_fuchsia_storage_block__common::Guid, D>,
207 T2: fidl::encoding::Encode<fidl_fuchsia_storage_block__common::Guid, D>,
208 T3: fidl::encoding::Encode<u64, D>,
209 T4: fidl::encoding::Encode<u64, D>,
210 T5: fidl::encoding::Encode<u64, D>,
211 > fidl::encoding::Encode<PartitionInfo, D> for (T0, T1, T2, T3, T4, T5)
212 {
213 #[inline]
214 unsafe fn encode(
215 self,
216 encoder: &mut fidl::encoding::Encoder<'_, D>,
217 offset: usize,
218 depth: fidl::encoding::Depth,
219 ) -> fidl::Result<()> {
220 encoder.debug_check_bounds::<PartitionInfo>(offset);
221 self.0.encode(encoder, offset + 0, depth)?;
225 self.1.encode(encoder, offset + 16, depth)?;
226 self.2.encode(encoder, offset + 32, depth)?;
227 self.3.encode(encoder, offset + 48, depth)?;
228 self.4.encode(encoder, offset + 56, depth)?;
229 self.5.encode(encoder, offset + 64, depth)?;
230 Ok(())
231 }
232 }
233
234 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PartitionInfo {
235 #[inline(always)]
236 fn new_empty() -> Self {
237 Self {
238 name: fidl::new_empty!(fidl::encoding::BoundedString<128>, D),
239 type_guid: fidl::new_empty!(fidl_fuchsia_storage_block__common::Guid, D),
240 instance_guid: fidl::new_empty!(fidl_fuchsia_storage_block__common::Guid, D),
241 start_block: fidl::new_empty!(u64, D),
242 num_blocks: fidl::new_empty!(u64, D),
243 flags: fidl::new_empty!(u64, D),
244 }
245 }
246
247 #[inline]
248 unsafe fn decode(
249 &mut self,
250 decoder: &mut fidl::encoding::Decoder<'_, D>,
251 offset: usize,
252 _depth: fidl::encoding::Depth,
253 ) -> fidl::Result<()> {
254 decoder.debug_check_bounds::<Self>(offset);
255 fidl::decode!(
257 fidl::encoding::BoundedString<128>,
258 D,
259 &mut self.name,
260 decoder,
261 offset + 0,
262 _depth
263 )?;
264 fidl::decode!(
265 fidl_fuchsia_storage_block__common::Guid,
266 D,
267 &mut self.type_guid,
268 decoder,
269 offset + 16,
270 _depth
271 )?;
272 fidl::decode!(
273 fidl_fuchsia_storage_block__common::Guid,
274 D,
275 &mut self.instance_guid,
276 decoder,
277 offset + 32,
278 _depth
279 )?;
280 fidl::decode!(u64, D, &mut self.start_block, decoder, offset + 48, _depth)?;
281 fidl::decode!(u64, D, &mut self.num_blocks, decoder, offset + 56, _depth)?;
282 fidl::decode!(u64, D, &mut self.flags, decoder, offset + 64, _depth)?;
283 Ok(())
284 }
285 }
286
287 impl fidl::encoding::ValueTypeMarker for PartitionsAdminResetPartitionTableRequest {
288 type Borrowed<'a> = &'a Self;
289 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
290 value
291 }
292 }
293
294 unsafe impl fidl::encoding::TypeMarker for PartitionsAdminResetPartitionTableRequest {
295 type Owned = Self;
296
297 #[inline(always)]
298 fn inline_align(_context: fidl::encoding::Context) -> usize {
299 8
300 }
301
302 #[inline(always)]
303 fn inline_size(_context: fidl::encoding::Context) -> usize {
304 16
305 }
306 }
307
308 unsafe impl<D: fidl::encoding::ResourceDialect>
309 fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D>
310 for &PartitionsAdminResetPartitionTableRequest
311 {
312 #[inline]
313 unsafe fn encode(
314 self,
315 encoder: &mut fidl::encoding::Encoder<'_, D>,
316 offset: usize,
317 _depth: fidl::encoding::Depth,
318 ) -> fidl::Result<()> {
319 encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
320 fidl::encoding::Encode::<PartitionsAdminResetPartitionTableRequest, D>::encode(
322 (
323 <fidl::encoding::Vector<PartitionInfo, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),
324 ),
325 encoder, offset, _depth
326 )
327 }
328 }
329 unsafe impl<
330 D: fidl::encoding::ResourceDialect,
331 T0: fidl::encoding::Encode<fidl::encoding::Vector<PartitionInfo, 128>, D>,
332 > fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D> for (T0,)
333 {
334 #[inline]
335 unsafe fn encode(
336 self,
337 encoder: &mut fidl::encoding::Encoder<'_, D>,
338 offset: usize,
339 depth: fidl::encoding::Depth,
340 ) -> fidl::Result<()> {
341 encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
342 self.0.encode(encoder, offset + 0, depth)?;
346 Ok(())
347 }
348 }
349
350 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
351 for PartitionsAdminResetPartitionTableRequest
352 {
353 #[inline(always)]
354 fn new_empty() -> Self {
355 Self { partitions: fidl::new_empty!(fidl::encoding::Vector<PartitionInfo, 128>, D) }
356 }
357
358 #[inline]
359 unsafe fn decode(
360 &mut self,
361 decoder: &mut fidl::encoding::Decoder<'_, D>,
362 offset: usize,
363 _depth: fidl::encoding::Depth,
364 ) -> fidl::Result<()> {
365 decoder.debug_check_bounds::<Self>(offset);
366 fidl::decode!(fidl::encoding::Vector<PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
368 Ok(())
369 }
370 }
371
372 impl fidl::encoding::ValueTypeMarker for PartitionsManagerGetBlockInfoResponse {
373 type Borrowed<'a> = &'a Self;
374 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
375 value
376 }
377 }
378
379 unsafe impl fidl::encoding::TypeMarker for PartitionsManagerGetBlockInfoResponse {
380 type Owned = Self;
381
382 #[inline(always)]
383 fn inline_align(_context: fidl::encoding::Context) -> usize {
384 8
385 }
386
387 #[inline(always)]
388 fn inline_size(_context: fidl::encoding::Context) -> usize {
389 16
390 }
391 }
392
393 unsafe impl<D: fidl::encoding::ResourceDialect>
394 fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D>
395 for &PartitionsManagerGetBlockInfoResponse
396 {
397 #[inline]
398 unsafe fn encode(
399 self,
400 encoder: &mut fidl::encoding::Encoder<'_, D>,
401 offset: usize,
402 _depth: fidl::encoding::Depth,
403 ) -> fidl::Result<()> {
404 encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
405 unsafe {
406 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
408 (buf_ptr as *mut PartitionsManagerGetBlockInfoResponse)
409 .write_unaligned((self as *const PartitionsManagerGetBlockInfoResponse).read());
410 let padding_ptr = buf_ptr.offset(8) as *mut u64;
413 let padding_mask = 0xffffffff00000000u64;
414 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
415 }
416 Ok(())
417 }
418 }
419 unsafe impl<
420 D: fidl::encoding::ResourceDialect,
421 T0: fidl::encoding::Encode<u64, D>,
422 T1: fidl::encoding::Encode<u32, D>,
423 > fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D> for (T0, T1)
424 {
425 #[inline]
426 unsafe fn encode(
427 self,
428 encoder: &mut fidl::encoding::Encoder<'_, D>,
429 offset: usize,
430 depth: fidl::encoding::Depth,
431 ) -> fidl::Result<()> {
432 encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
433 unsafe {
436 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
437 (ptr as *mut u64).write_unaligned(0);
438 }
439 self.0.encode(encoder, offset + 0, depth)?;
441 self.1.encode(encoder, offset + 8, depth)?;
442 Ok(())
443 }
444 }
445
446 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
447 for PartitionsManagerGetBlockInfoResponse
448 {
449 #[inline(always)]
450 fn new_empty() -> Self {
451 Self { block_count: fidl::new_empty!(u64, D), block_size: fidl::new_empty!(u32, D) }
452 }
453
454 #[inline]
455 unsafe fn decode(
456 &mut self,
457 decoder: &mut fidl::encoding::Decoder<'_, D>,
458 offset: usize,
459 _depth: fidl::encoding::Depth,
460 ) -> fidl::Result<()> {
461 decoder.debug_check_bounds::<Self>(offset);
462 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
463 let ptr = unsafe { buf_ptr.offset(8) };
465 let padval = unsafe { (ptr as *const u64).read_unaligned() };
466 let mask = 0xffffffff00000000u64;
467 let maskedval = padval & mask;
468 if maskedval != 0 {
469 return Err(fidl::Error::NonZeroPadding {
470 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
471 });
472 }
473 unsafe {
475 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
476 }
477 Ok(())
478 }
479 }
480}