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 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_hardware_block_partition__common::Guid,
26    pub instance_guid: fidl_fuchsia_hardware_block_partition__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            // Delegate to tuple encoding.
106            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            // Zero out padding regions. There's no need to apply masks
128            // because the unmasked parts will be overwritten by fields.
129            // Write the fields.
130            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            // Verify that padding bytes are zero.
152            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            // Delegate to tuple encoding.
190            fidl::encoding::Encode::<PartitionInfo, D>::encode(
191                (
192                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
193                    <fidl_fuchsia_hardware_block_partition__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.type_guid),
194                    <fidl_fuchsia_hardware_block_partition__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_hardware_block_partition__common::Guid, D>,
207        T2: fidl::encoding::Encode<fidl_fuchsia_hardware_block_partition__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            // Zero out padding regions. There's no need to apply masks
222            // because the unmasked parts will be overwritten by fields.
223            // Write the fields.
224            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_hardware_block_partition__common::Guid, D),
240                instance_guid: fidl::new_empty!(
241                    fidl_fuchsia_hardware_block_partition__common::Guid,
242                    D
243                ),
244                start_block: fidl::new_empty!(u64, D),
245                num_blocks: fidl::new_empty!(u64, D),
246                flags: fidl::new_empty!(u64, D),
247            }
248        }
249
250        #[inline]
251        unsafe fn decode(
252            &mut self,
253            decoder: &mut fidl::encoding::Decoder<'_, D>,
254            offset: usize,
255            _depth: fidl::encoding::Depth,
256        ) -> fidl::Result<()> {
257            decoder.debug_check_bounds::<Self>(offset);
258            // Verify that padding bytes are zero.
259            fidl::decode!(
260                fidl::encoding::BoundedString<128>,
261                D,
262                &mut self.name,
263                decoder,
264                offset + 0,
265                _depth
266            )?;
267            fidl::decode!(
268                fidl_fuchsia_hardware_block_partition__common::Guid,
269                D,
270                &mut self.type_guid,
271                decoder,
272                offset + 16,
273                _depth
274            )?;
275            fidl::decode!(
276                fidl_fuchsia_hardware_block_partition__common::Guid,
277                D,
278                &mut self.instance_guid,
279                decoder,
280                offset + 32,
281                _depth
282            )?;
283            fidl::decode!(u64, D, &mut self.start_block, decoder, offset + 48, _depth)?;
284            fidl::decode!(u64, D, &mut self.num_blocks, decoder, offset + 56, _depth)?;
285            fidl::decode!(u64, D, &mut self.flags, decoder, offset + 64, _depth)?;
286            Ok(())
287        }
288    }
289
290    impl fidl::encoding::ValueTypeMarker for PartitionsAdminResetPartitionTableRequest {
291        type Borrowed<'a> = &'a Self;
292        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
293            value
294        }
295    }
296
297    unsafe impl fidl::encoding::TypeMarker for PartitionsAdminResetPartitionTableRequest {
298        type Owned = Self;
299
300        #[inline(always)]
301        fn inline_align(_context: fidl::encoding::Context) -> usize {
302            8
303        }
304
305        #[inline(always)]
306        fn inline_size(_context: fidl::encoding::Context) -> usize {
307            16
308        }
309    }
310
311    unsafe impl<D: fidl::encoding::ResourceDialect>
312        fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D>
313        for &PartitionsAdminResetPartitionTableRequest
314    {
315        #[inline]
316        unsafe fn encode(
317            self,
318            encoder: &mut fidl::encoding::Encoder<'_, D>,
319            offset: usize,
320            _depth: fidl::encoding::Depth,
321        ) -> fidl::Result<()> {
322            encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
323            // Delegate to tuple encoding.
324            fidl::encoding::Encode::<PartitionsAdminResetPartitionTableRequest, D>::encode(
325                (
326                    <fidl::encoding::Vector<PartitionInfo, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),
327                ),
328                encoder, offset, _depth
329            )
330        }
331    }
332    unsafe impl<
333        D: fidl::encoding::ResourceDialect,
334        T0: fidl::encoding::Encode<fidl::encoding::Vector<PartitionInfo, 128>, D>,
335    > fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D> for (T0,)
336    {
337        #[inline]
338        unsafe fn encode(
339            self,
340            encoder: &mut fidl::encoding::Encoder<'_, D>,
341            offset: usize,
342            depth: fidl::encoding::Depth,
343        ) -> fidl::Result<()> {
344            encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
345            // Zero out padding regions. There's no need to apply masks
346            // because the unmasked parts will be overwritten by fields.
347            // Write the fields.
348            self.0.encode(encoder, offset + 0, depth)?;
349            Ok(())
350        }
351    }
352
353    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
354        for PartitionsAdminResetPartitionTableRequest
355    {
356        #[inline(always)]
357        fn new_empty() -> Self {
358            Self { partitions: fidl::new_empty!(fidl::encoding::Vector<PartitionInfo, 128>, D) }
359        }
360
361        #[inline]
362        unsafe fn decode(
363            &mut self,
364            decoder: &mut fidl::encoding::Decoder<'_, D>,
365            offset: usize,
366            _depth: fidl::encoding::Depth,
367        ) -> fidl::Result<()> {
368            decoder.debug_check_bounds::<Self>(offset);
369            // Verify that padding bytes are zero.
370            fidl::decode!(fidl::encoding::Vector<PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
371            Ok(())
372        }
373    }
374
375    impl fidl::encoding::ValueTypeMarker for PartitionsManagerGetBlockInfoResponse {
376        type Borrowed<'a> = &'a Self;
377        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
378            value
379        }
380    }
381
382    unsafe impl fidl::encoding::TypeMarker for PartitionsManagerGetBlockInfoResponse {
383        type Owned = Self;
384
385        #[inline(always)]
386        fn inline_align(_context: fidl::encoding::Context) -> usize {
387            8
388        }
389
390        #[inline(always)]
391        fn inline_size(_context: fidl::encoding::Context) -> usize {
392            16
393        }
394    }
395
396    unsafe impl<D: fidl::encoding::ResourceDialect>
397        fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D>
398        for &PartitionsManagerGetBlockInfoResponse
399    {
400        #[inline]
401        unsafe fn encode(
402            self,
403            encoder: &mut fidl::encoding::Encoder<'_, D>,
404            offset: usize,
405            _depth: fidl::encoding::Depth,
406        ) -> fidl::Result<()> {
407            encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
408            unsafe {
409                // Copy the object into the buffer.
410                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
411                (buf_ptr as *mut PartitionsManagerGetBlockInfoResponse)
412                    .write_unaligned((self as *const PartitionsManagerGetBlockInfoResponse).read());
413                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
414                // done second because the memcpy will write garbage to these bytes.
415                let padding_ptr = buf_ptr.offset(8) as *mut u64;
416                let padding_mask = 0xffffffff00000000u64;
417                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
418            }
419            Ok(())
420        }
421    }
422    unsafe impl<
423        D: fidl::encoding::ResourceDialect,
424        T0: fidl::encoding::Encode<u64, D>,
425        T1: fidl::encoding::Encode<u32, D>,
426    > fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D> for (T0, T1)
427    {
428        #[inline]
429        unsafe fn encode(
430            self,
431            encoder: &mut fidl::encoding::Encoder<'_, D>,
432            offset: usize,
433            depth: fidl::encoding::Depth,
434        ) -> fidl::Result<()> {
435            encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
436            // Zero out padding regions. There's no need to apply masks
437            // because the unmasked parts will be overwritten by fields.
438            unsafe {
439                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
440                (ptr as *mut u64).write_unaligned(0);
441            }
442            // Write the fields.
443            self.0.encode(encoder, offset + 0, depth)?;
444            self.1.encode(encoder, offset + 8, depth)?;
445            Ok(())
446        }
447    }
448
449    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
450        for PartitionsManagerGetBlockInfoResponse
451    {
452        #[inline(always)]
453        fn new_empty() -> Self {
454            Self { block_count: fidl::new_empty!(u64, D), block_size: fidl::new_empty!(u32, D) }
455        }
456
457        #[inline]
458        unsafe fn decode(
459            &mut self,
460            decoder: &mut fidl::encoding::Decoder<'_, D>,
461            offset: usize,
462            _depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            decoder.debug_check_bounds::<Self>(offset);
465            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
466            // Verify that padding bytes are zero.
467            let ptr = unsafe { buf_ptr.offset(8) };
468            let padval = unsafe { (ptr as *const u64).read_unaligned() };
469            let mask = 0xffffffff00000000u64;
470            let maskedval = padval & mask;
471            if maskedval != 0 {
472                return Err(fidl::Error::NonZeroPadding {
473                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
474                });
475            }
476            // Copy from the buffer into the object.
477            unsafe {
478                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
479            }
480            Ok(())
481        }
482    }
483}