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
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
41mod internal {
42    use super::*;
43
44    impl fidl::encoding::ValueTypeMarker for PartitionInfo {
45        type Borrowed<'a> = &'a Self;
46        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
47            value
48        }
49    }
50
51    unsafe impl fidl::encoding::TypeMarker for PartitionInfo {
52        type Owned = Self;
53
54        #[inline(always)]
55        fn inline_align(_context: fidl::encoding::Context) -> usize {
56            8
57        }
58
59        #[inline(always)]
60        fn inline_size(_context: fidl::encoding::Context) -> usize {
61            72
62        }
63    }
64
65    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PartitionInfo, D>
66        for &PartitionInfo
67    {
68        #[inline]
69        unsafe fn encode(
70            self,
71            encoder: &mut fidl::encoding::Encoder<'_, D>,
72            offset: usize,
73            _depth: fidl::encoding::Depth,
74        ) -> fidl::Result<()> {
75            encoder.debug_check_bounds::<PartitionInfo>(offset);
76            // Delegate to tuple encoding.
77            fidl::encoding::Encode::<PartitionInfo, D>::encode(
78                (
79                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
80                    <fidl_fuchsia_hardware_block_partition__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.type_guid),
81                    <fidl_fuchsia_hardware_block_partition__common::Guid as fidl::encoding::ValueTypeMarker>::borrow(&self.instance_guid),
82                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.start_block),
83                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_blocks),
84                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
85                ),
86                encoder, offset, _depth
87            )
88        }
89    }
90    unsafe impl<
91            D: fidl::encoding::ResourceDialect,
92            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
93            T1: fidl::encoding::Encode<fidl_fuchsia_hardware_block_partition__common::Guid, D>,
94            T2: fidl::encoding::Encode<fidl_fuchsia_hardware_block_partition__common::Guid, D>,
95            T3: fidl::encoding::Encode<u64, D>,
96            T4: fidl::encoding::Encode<u64, D>,
97            T5: fidl::encoding::Encode<u64, D>,
98        > fidl::encoding::Encode<PartitionInfo, D> for (T0, T1, T2, T3, T4, T5)
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::<PartitionInfo>(offset);
108            // Zero out padding regions. There's no need to apply masks
109            // because the unmasked parts will be overwritten by fields.
110            // Write the fields.
111            self.0.encode(encoder, offset + 0, depth)?;
112            self.1.encode(encoder, offset + 16, depth)?;
113            self.2.encode(encoder, offset + 32, depth)?;
114            self.3.encode(encoder, offset + 48, depth)?;
115            self.4.encode(encoder, offset + 56, depth)?;
116            self.5.encode(encoder, offset + 64, depth)?;
117            Ok(())
118        }
119    }
120
121    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PartitionInfo {
122        #[inline(always)]
123        fn new_empty() -> Self {
124            Self {
125                name: fidl::new_empty!(fidl::encoding::BoundedString<128>, D),
126                type_guid: fidl::new_empty!(fidl_fuchsia_hardware_block_partition__common::Guid, D),
127                instance_guid: fidl::new_empty!(
128                    fidl_fuchsia_hardware_block_partition__common::Guid,
129                    D
130                ),
131                start_block: fidl::new_empty!(u64, D),
132                num_blocks: fidl::new_empty!(u64, D),
133                flags: fidl::new_empty!(u64, D),
134            }
135        }
136
137        #[inline]
138        unsafe fn decode(
139            &mut self,
140            decoder: &mut fidl::encoding::Decoder<'_, D>,
141            offset: usize,
142            _depth: fidl::encoding::Depth,
143        ) -> fidl::Result<()> {
144            decoder.debug_check_bounds::<Self>(offset);
145            // Verify that padding bytes are zero.
146            fidl::decode!(
147                fidl::encoding::BoundedString<128>,
148                D,
149                &mut self.name,
150                decoder,
151                offset + 0,
152                _depth
153            )?;
154            fidl::decode!(
155                fidl_fuchsia_hardware_block_partition__common::Guid,
156                D,
157                &mut self.type_guid,
158                decoder,
159                offset + 16,
160                _depth
161            )?;
162            fidl::decode!(
163                fidl_fuchsia_hardware_block_partition__common::Guid,
164                D,
165                &mut self.instance_guid,
166                decoder,
167                offset + 32,
168                _depth
169            )?;
170            fidl::decode!(u64, D, &mut self.start_block, decoder, offset + 48, _depth)?;
171            fidl::decode!(u64, D, &mut self.num_blocks, decoder, offset + 56, _depth)?;
172            fidl::decode!(u64, D, &mut self.flags, decoder, offset + 64, _depth)?;
173            Ok(())
174        }
175    }
176
177    impl fidl::encoding::ValueTypeMarker for PartitionsAdminResetPartitionTableRequest {
178        type Borrowed<'a> = &'a Self;
179        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
180            value
181        }
182    }
183
184    unsafe impl fidl::encoding::TypeMarker for PartitionsAdminResetPartitionTableRequest {
185        type Owned = Self;
186
187        #[inline(always)]
188        fn inline_align(_context: fidl::encoding::Context) -> usize {
189            8
190        }
191
192        #[inline(always)]
193        fn inline_size(_context: fidl::encoding::Context) -> usize {
194            16
195        }
196    }
197
198    unsafe impl<D: fidl::encoding::ResourceDialect>
199        fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D>
200        for &PartitionsAdminResetPartitionTableRequest
201    {
202        #[inline]
203        unsafe fn encode(
204            self,
205            encoder: &mut fidl::encoding::Encoder<'_, D>,
206            offset: usize,
207            _depth: fidl::encoding::Depth,
208        ) -> fidl::Result<()> {
209            encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
210            // Delegate to tuple encoding.
211            fidl::encoding::Encode::<PartitionsAdminResetPartitionTableRequest, D>::encode(
212                (
213                    <fidl::encoding::Vector<PartitionInfo, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.partitions),
214                ),
215                encoder, offset, _depth
216            )
217        }
218    }
219    unsafe impl<
220            D: fidl::encoding::ResourceDialect,
221            T0: fidl::encoding::Encode<fidl::encoding::Vector<PartitionInfo, 128>, D>,
222        > fidl::encoding::Encode<PartitionsAdminResetPartitionTableRequest, D> for (T0,)
223    {
224        #[inline]
225        unsafe fn encode(
226            self,
227            encoder: &mut fidl::encoding::Encoder<'_, D>,
228            offset: usize,
229            depth: fidl::encoding::Depth,
230        ) -> fidl::Result<()> {
231            encoder.debug_check_bounds::<PartitionsAdminResetPartitionTableRequest>(offset);
232            // Zero out padding regions. There's no need to apply masks
233            // because the unmasked parts will be overwritten by fields.
234            // Write the fields.
235            self.0.encode(encoder, offset + 0, depth)?;
236            Ok(())
237        }
238    }
239
240    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
241        for PartitionsAdminResetPartitionTableRequest
242    {
243        #[inline(always)]
244        fn new_empty() -> Self {
245            Self { partitions: fidl::new_empty!(fidl::encoding::Vector<PartitionInfo, 128>, D) }
246        }
247
248        #[inline]
249        unsafe fn decode(
250            &mut self,
251            decoder: &mut fidl::encoding::Decoder<'_, D>,
252            offset: usize,
253            _depth: fidl::encoding::Depth,
254        ) -> fidl::Result<()> {
255            decoder.debug_check_bounds::<Self>(offset);
256            // Verify that padding bytes are zero.
257            fidl::decode!(fidl::encoding::Vector<PartitionInfo, 128>, D, &mut self.partitions, decoder, offset + 0, _depth)?;
258            Ok(())
259        }
260    }
261
262    impl fidl::encoding::ValueTypeMarker for PartitionsManagerGetBlockInfoResponse {
263        type Borrowed<'a> = &'a Self;
264        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
265            value
266        }
267    }
268
269    unsafe impl fidl::encoding::TypeMarker for PartitionsManagerGetBlockInfoResponse {
270        type Owned = Self;
271
272        #[inline(always)]
273        fn inline_align(_context: fidl::encoding::Context) -> usize {
274            8
275        }
276
277        #[inline(always)]
278        fn inline_size(_context: fidl::encoding::Context) -> usize {
279            16
280        }
281    }
282
283    unsafe impl<D: fidl::encoding::ResourceDialect>
284        fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D>
285        for &PartitionsManagerGetBlockInfoResponse
286    {
287        #[inline]
288        unsafe fn encode(
289            self,
290            encoder: &mut fidl::encoding::Encoder<'_, D>,
291            offset: usize,
292            _depth: fidl::encoding::Depth,
293        ) -> fidl::Result<()> {
294            encoder.debug_check_bounds::<PartitionsManagerGetBlockInfoResponse>(offset);
295            unsafe {
296                // Copy the object into the buffer.
297                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
298                (buf_ptr as *mut PartitionsManagerGetBlockInfoResponse)
299                    .write_unaligned((self as *const PartitionsManagerGetBlockInfoResponse).read());
300                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
301                // done second because the memcpy will write garbage to these bytes.
302                let padding_ptr = buf_ptr.offset(8) as *mut u64;
303                let padding_mask = 0xffffffff00000000u64;
304                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
305            }
306            Ok(())
307        }
308    }
309    unsafe impl<
310            D: fidl::encoding::ResourceDialect,
311            T0: fidl::encoding::Encode<u64, D>,
312            T1: fidl::encoding::Encode<u32, D>,
313        > fidl::encoding::Encode<PartitionsManagerGetBlockInfoResponse, D> for (T0, T1)
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::<PartitionsManagerGetBlockInfoResponse>(offset);
323            // Zero out padding regions. There's no need to apply masks
324            // because the unmasked parts will be overwritten by fields.
325            unsafe {
326                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
327                (ptr as *mut u64).write_unaligned(0);
328            }
329            // Write the fields.
330            self.0.encode(encoder, offset + 0, depth)?;
331            self.1.encode(encoder, offset + 8, depth)?;
332            Ok(())
333        }
334    }
335
336    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
337        for PartitionsManagerGetBlockInfoResponse
338    {
339        #[inline(always)]
340        fn new_empty() -> Self {
341            Self { block_count: fidl::new_empty!(u64, D), block_size: fidl::new_empty!(u32, D) }
342        }
343
344        #[inline]
345        unsafe fn decode(
346            &mut self,
347            decoder: &mut fidl::encoding::Decoder<'_, D>,
348            offset: usize,
349            _depth: fidl::encoding::Depth,
350        ) -> fidl::Result<()> {
351            decoder.debug_check_bounds::<Self>(offset);
352            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
353            // Verify that padding bytes are zero.
354            let ptr = unsafe { buf_ptr.offset(8) };
355            let padval = unsafe { (ptr as *const u64).read_unaligned() };
356            let mask = 0xffffffff00000000u64;
357            let maskedval = padval & mask;
358            if maskedval != 0 {
359                return Err(fidl::Error::NonZeroPadding {
360                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
361                });
362            }
363            // Copy from the buffer into the object.
364            unsafe {
365                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
366            }
367            Ok(())
368        }
369    }
370}