Skip to main content

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