fidl_fuchsia_hardware_block_partition_common/
fidl_fuchsia_hardware_block_partition_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 GUID_LENGTH: u32 = 16;
12
13pub const NAME_LENGTH: u32 = 128;
14
15/// A Globally Unique IDentifier, which may be utilized to identify
16/// a partition.
17#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
18#[repr(C)]
19pub struct Guid {
20    pub value: [u8; 16],
21}
22
23impl fidl::Persistable for Guid {}
24
25#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct PartitionGetInstanceGuidResponse {
27    pub status: i32,
28    pub guid: Option<Box<Guid>>,
29}
30
31impl fidl::Persistable for PartitionGetInstanceGuidResponse {}
32
33#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct PartitionGetNameResponse {
35    pub status: i32,
36    pub name: Option<String>,
37}
38
39impl fidl::Persistable for PartitionGetNameResponse {}
40
41#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42pub struct PartitionGetTypeGuidResponse {
43    pub status: i32,
44    pub guid: Option<Box<Guid>>,
45}
46
47impl fidl::Persistable for PartitionGetTypeGuidResponse {}
48
49#[derive(Clone, Debug, Default, PartialEq)]
50pub struct PartitionGetMetadataResponse {
51    pub name: Option<String>,
52    pub type_guid: Option<Guid>,
53    pub instance_guid: Option<Guid>,
54    /// start_block_offset will be absent if the partition is non-contiguous.
55    pub start_block_offset: Option<u64>,
56    /// num_blocks will be absent if the partition is a dynamic volume, in which case
57    /// fuchsia.hardware.block.volume.Volume/GetVolumeInfo should be called instead.
58    pub num_blocks: Option<u64>,
59    pub flags: Option<u64>,
60    #[doc(hidden)]
61    pub __source_breaking: fidl::marker::SourceBreaking,
62}
63
64impl fidl::Persistable for PartitionGetMetadataResponse {}
65
66mod internal {
67    use super::*;
68
69    impl fidl::encoding::ValueTypeMarker for Guid {
70        type Borrowed<'a> = &'a Self;
71        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
72            value
73        }
74    }
75
76    unsafe impl fidl::encoding::TypeMarker for Guid {
77        type Owned = Self;
78
79        #[inline(always)]
80        fn inline_align(_context: fidl::encoding::Context) -> usize {
81            1
82        }
83
84        #[inline(always)]
85        fn inline_size(_context: fidl::encoding::Context) -> usize {
86            16
87        }
88        #[inline(always)]
89        fn encode_is_copy() -> bool {
90            true
91        }
92
93        #[inline(always)]
94        fn decode_is_copy() -> bool {
95            true
96        }
97    }
98
99    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Guid, D> for &Guid {
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::<Guid>(offset);
108            unsafe {
109                // Copy the object into the buffer.
110                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
111                (buf_ptr as *mut Guid).write_unaligned((self as *const Guid).read());
112                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
113                // done second because the memcpy will write garbage to these bytes.
114            }
115            Ok(())
116        }
117    }
118    unsafe impl<
119            D: fidl::encoding::ResourceDialect,
120            T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
121        > fidl::encoding::Encode<Guid, D> for (T0,)
122    {
123        #[inline]
124        unsafe fn encode(
125            self,
126            encoder: &mut fidl::encoding::Encoder<'_, D>,
127            offset: usize,
128            depth: fidl::encoding::Depth,
129        ) -> fidl::Result<()> {
130            encoder.debug_check_bounds::<Guid>(offset);
131            // Zero out padding regions. There's no need to apply masks
132            // because the unmasked parts will be overwritten by fields.
133            // Write the fields.
134            self.0.encode(encoder, offset + 0, depth)?;
135            Ok(())
136        }
137    }
138
139    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Guid {
140        #[inline(always)]
141        fn new_empty() -> Self {
142            Self { value: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D) }
143        }
144
145        #[inline]
146        unsafe fn decode(
147            &mut self,
148            decoder: &mut fidl::encoding::Decoder<'_, D>,
149            offset: usize,
150            _depth: fidl::encoding::Depth,
151        ) -> fidl::Result<()> {
152            decoder.debug_check_bounds::<Self>(offset);
153            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
154            // Verify that padding bytes are zero.
155            // Copy from the buffer into the object.
156            unsafe {
157                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
158            }
159            Ok(())
160        }
161    }
162
163    impl fidl::encoding::ValueTypeMarker for PartitionGetInstanceGuidResponse {
164        type Borrowed<'a> = &'a Self;
165        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
166            value
167        }
168    }
169
170    unsafe impl fidl::encoding::TypeMarker for PartitionGetInstanceGuidResponse {
171        type Owned = Self;
172
173        #[inline(always)]
174        fn inline_align(_context: fidl::encoding::Context) -> usize {
175            8
176        }
177
178        #[inline(always)]
179        fn inline_size(_context: fidl::encoding::Context) -> usize {
180            16
181        }
182    }
183
184    unsafe impl<D: fidl::encoding::ResourceDialect>
185        fidl::encoding::Encode<PartitionGetInstanceGuidResponse, D>
186        for &PartitionGetInstanceGuidResponse
187    {
188        #[inline]
189        unsafe fn encode(
190            self,
191            encoder: &mut fidl::encoding::Encoder<'_, D>,
192            offset: usize,
193            _depth: fidl::encoding::Depth,
194        ) -> fidl::Result<()> {
195            encoder.debug_check_bounds::<PartitionGetInstanceGuidResponse>(offset);
196            // Delegate to tuple encoding.
197            fidl::encoding::Encode::<PartitionGetInstanceGuidResponse, D>::encode(
198                (
199                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
200                    <fidl::encoding::Boxed<Guid> as fidl::encoding::ValueTypeMarker>::borrow(
201                        &self.guid,
202                    ),
203                ),
204                encoder,
205                offset,
206                _depth,
207            )
208        }
209    }
210    unsafe impl<
211            D: fidl::encoding::ResourceDialect,
212            T0: fidl::encoding::Encode<i32, D>,
213            T1: fidl::encoding::Encode<fidl::encoding::Boxed<Guid>, D>,
214        > fidl::encoding::Encode<PartitionGetInstanceGuidResponse, D> for (T0, T1)
215    {
216        #[inline]
217        unsafe fn encode(
218            self,
219            encoder: &mut fidl::encoding::Encoder<'_, D>,
220            offset: usize,
221            depth: fidl::encoding::Depth,
222        ) -> fidl::Result<()> {
223            encoder.debug_check_bounds::<PartitionGetInstanceGuidResponse>(offset);
224            // Zero out padding regions. There's no need to apply masks
225            // because the unmasked parts will be overwritten by fields.
226            unsafe {
227                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
228                (ptr as *mut u64).write_unaligned(0);
229            }
230            // Write the fields.
231            self.0.encode(encoder, offset + 0, depth)?;
232            self.1.encode(encoder, offset + 8, depth)?;
233            Ok(())
234        }
235    }
236
237    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
238        for PartitionGetInstanceGuidResponse
239    {
240        #[inline(always)]
241        fn new_empty() -> Self {
242            Self {
243                status: fidl::new_empty!(i32, D),
244                guid: fidl::new_empty!(fidl::encoding::Boxed<Guid>, D),
245            }
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            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
258            let padval = unsafe { (ptr as *const u64).read_unaligned() };
259            let mask = 0xffffffff00000000u64;
260            let maskedval = padval & mask;
261            if maskedval != 0 {
262                return Err(fidl::Error::NonZeroPadding {
263                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
264                });
265            }
266            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
267            fidl::decode!(
268                fidl::encoding::Boxed<Guid>,
269                D,
270                &mut self.guid,
271                decoder,
272                offset + 8,
273                _depth
274            )?;
275            Ok(())
276        }
277    }
278
279    impl fidl::encoding::ValueTypeMarker for PartitionGetNameResponse {
280        type Borrowed<'a> = &'a Self;
281        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
282            value
283        }
284    }
285
286    unsafe impl fidl::encoding::TypeMarker for PartitionGetNameResponse {
287        type Owned = Self;
288
289        #[inline(always)]
290        fn inline_align(_context: fidl::encoding::Context) -> usize {
291            8
292        }
293
294        #[inline(always)]
295        fn inline_size(_context: fidl::encoding::Context) -> usize {
296            24
297        }
298    }
299
300    unsafe impl<D: fidl::encoding::ResourceDialect>
301        fidl::encoding::Encode<PartitionGetNameResponse, D> for &PartitionGetNameResponse
302    {
303        #[inline]
304        unsafe fn encode(
305            self,
306            encoder: &mut fidl::encoding::Encoder<'_, D>,
307            offset: usize,
308            _depth: fidl::encoding::Depth,
309        ) -> fidl::Result<()> {
310            encoder.debug_check_bounds::<PartitionGetNameResponse>(offset);
311            // Delegate to tuple encoding.
312            fidl::encoding::Encode::<PartitionGetNameResponse, D>::encode(
313                (
314                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
315                    <fidl::encoding::Optional<fidl::encoding::BoundedString<128>> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
316                ),
317                encoder, offset, _depth
318            )
319        }
320    }
321    unsafe impl<
322            D: fidl::encoding::ResourceDialect,
323            T0: fidl::encoding::Encode<i32, D>,
324            T1: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<128>>, D>,
325        > fidl::encoding::Encode<PartitionGetNameResponse, D> for (T0, T1)
326    {
327        #[inline]
328        unsafe fn encode(
329            self,
330            encoder: &mut fidl::encoding::Encoder<'_, D>,
331            offset: usize,
332            depth: fidl::encoding::Depth,
333        ) -> fidl::Result<()> {
334            encoder.debug_check_bounds::<PartitionGetNameResponse>(offset);
335            // Zero out padding regions. There's no need to apply masks
336            // because the unmasked parts will be overwritten by fields.
337            unsafe {
338                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
339                (ptr as *mut u64).write_unaligned(0);
340            }
341            // Write the fields.
342            self.0.encode(encoder, offset + 0, depth)?;
343            self.1.encode(encoder, offset + 8, depth)?;
344            Ok(())
345        }
346    }
347
348    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
349        for PartitionGetNameResponse
350    {
351        #[inline(always)]
352        fn new_empty() -> Self {
353            Self {
354                status: fidl::new_empty!(i32, D),
355                name: fidl::new_empty!(
356                    fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
357                    D
358                ),
359            }
360        }
361
362        #[inline]
363        unsafe fn decode(
364            &mut self,
365            decoder: &mut fidl::encoding::Decoder<'_, D>,
366            offset: usize,
367            _depth: fidl::encoding::Depth,
368        ) -> fidl::Result<()> {
369            decoder.debug_check_bounds::<Self>(offset);
370            // Verify that padding bytes are zero.
371            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
372            let padval = unsafe { (ptr as *const u64).read_unaligned() };
373            let mask = 0xffffffff00000000u64;
374            let maskedval = padval & mask;
375            if maskedval != 0 {
376                return Err(fidl::Error::NonZeroPadding {
377                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
378                });
379            }
380            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
381            fidl::decode!(
382                fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
383                D,
384                &mut self.name,
385                decoder,
386                offset + 8,
387                _depth
388            )?;
389            Ok(())
390        }
391    }
392
393    impl fidl::encoding::ValueTypeMarker for PartitionGetTypeGuidResponse {
394        type Borrowed<'a> = &'a Self;
395        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
396            value
397        }
398    }
399
400    unsafe impl fidl::encoding::TypeMarker for PartitionGetTypeGuidResponse {
401        type Owned = Self;
402
403        #[inline(always)]
404        fn inline_align(_context: fidl::encoding::Context) -> usize {
405            8
406        }
407
408        #[inline(always)]
409        fn inline_size(_context: fidl::encoding::Context) -> usize {
410            16
411        }
412    }
413
414    unsafe impl<D: fidl::encoding::ResourceDialect>
415        fidl::encoding::Encode<PartitionGetTypeGuidResponse, D> for &PartitionGetTypeGuidResponse
416    {
417        #[inline]
418        unsafe fn encode(
419            self,
420            encoder: &mut fidl::encoding::Encoder<'_, D>,
421            offset: usize,
422            _depth: fidl::encoding::Depth,
423        ) -> fidl::Result<()> {
424            encoder.debug_check_bounds::<PartitionGetTypeGuidResponse>(offset);
425            // Delegate to tuple encoding.
426            fidl::encoding::Encode::<PartitionGetTypeGuidResponse, D>::encode(
427                (
428                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
429                    <fidl::encoding::Boxed<Guid> as fidl::encoding::ValueTypeMarker>::borrow(
430                        &self.guid,
431                    ),
432                ),
433                encoder,
434                offset,
435                _depth,
436            )
437        }
438    }
439    unsafe impl<
440            D: fidl::encoding::ResourceDialect,
441            T0: fidl::encoding::Encode<i32, D>,
442            T1: fidl::encoding::Encode<fidl::encoding::Boxed<Guid>, D>,
443        > fidl::encoding::Encode<PartitionGetTypeGuidResponse, D> for (T0, T1)
444    {
445        #[inline]
446        unsafe fn encode(
447            self,
448            encoder: &mut fidl::encoding::Encoder<'_, D>,
449            offset: usize,
450            depth: fidl::encoding::Depth,
451        ) -> fidl::Result<()> {
452            encoder.debug_check_bounds::<PartitionGetTypeGuidResponse>(offset);
453            // Zero out padding regions. There's no need to apply masks
454            // because the unmasked parts will be overwritten by fields.
455            unsafe {
456                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
457                (ptr as *mut u64).write_unaligned(0);
458            }
459            // Write the fields.
460            self.0.encode(encoder, offset + 0, depth)?;
461            self.1.encode(encoder, offset + 8, depth)?;
462            Ok(())
463        }
464    }
465
466    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
467        for PartitionGetTypeGuidResponse
468    {
469        #[inline(always)]
470        fn new_empty() -> Self {
471            Self {
472                status: fidl::new_empty!(i32, D),
473                guid: fidl::new_empty!(fidl::encoding::Boxed<Guid>, D),
474            }
475        }
476
477        #[inline]
478        unsafe fn decode(
479            &mut self,
480            decoder: &mut fidl::encoding::Decoder<'_, D>,
481            offset: usize,
482            _depth: fidl::encoding::Depth,
483        ) -> fidl::Result<()> {
484            decoder.debug_check_bounds::<Self>(offset);
485            // Verify that padding bytes are zero.
486            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
487            let padval = unsafe { (ptr as *const u64).read_unaligned() };
488            let mask = 0xffffffff00000000u64;
489            let maskedval = padval & mask;
490            if maskedval != 0 {
491                return Err(fidl::Error::NonZeroPadding {
492                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
493                });
494            }
495            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
496            fidl::decode!(
497                fidl::encoding::Boxed<Guid>,
498                D,
499                &mut self.guid,
500                decoder,
501                offset + 8,
502                _depth
503            )?;
504            Ok(())
505        }
506    }
507
508    impl PartitionGetMetadataResponse {
509        #[inline(always)]
510        fn max_ordinal_present(&self) -> u64 {
511            if let Some(_) = self.flags {
512                return 6;
513            }
514            if let Some(_) = self.num_blocks {
515                return 5;
516            }
517            if let Some(_) = self.start_block_offset {
518                return 4;
519            }
520            if let Some(_) = self.instance_guid {
521                return 3;
522            }
523            if let Some(_) = self.type_guid {
524                return 2;
525            }
526            if let Some(_) = self.name {
527                return 1;
528            }
529            0
530        }
531    }
532
533    impl fidl::encoding::ValueTypeMarker for PartitionGetMetadataResponse {
534        type Borrowed<'a> = &'a Self;
535        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
536            value
537        }
538    }
539
540    unsafe impl fidl::encoding::TypeMarker for PartitionGetMetadataResponse {
541        type Owned = Self;
542
543        #[inline(always)]
544        fn inline_align(_context: fidl::encoding::Context) -> usize {
545            8
546        }
547
548        #[inline(always)]
549        fn inline_size(_context: fidl::encoding::Context) -> usize {
550            16
551        }
552    }
553
554    unsafe impl<D: fidl::encoding::ResourceDialect>
555        fidl::encoding::Encode<PartitionGetMetadataResponse, D> for &PartitionGetMetadataResponse
556    {
557        unsafe fn encode(
558            self,
559            encoder: &mut fidl::encoding::Encoder<'_, D>,
560            offset: usize,
561            mut depth: fidl::encoding::Depth,
562        ) -> fidl::Result<()> {
563            encoder.debug_check_bounds::<PartitionGetMetadataResponse>(offset);
564            // Vector header
565            let max_ordinal: u64 = self.max_ordinal_present();
566            encoder.write_num(max_ordinal, offset);
567            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
568            // Calling encoder.out_of_line_offset(0) is not allowed.
569            if max_ordinal == 0 {
570                return Ok(());
571            }
572            depth.increment()?;
573            let envelope_size = 8;
574            let bytes_len = max_ordinal as usize * envelope_size;
575            #[allow(unused_variables)]
576            let offset = encoder.out_of_line_offset(bytes_len);
577            let mut _prev_end_offset: usize = 0;
578            if 1 > max_ordinal {
579                return Ok(());
580            }
581
582            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
583            // are envelope_size bytes.
584            let cur_offset: usize = (1 - 1) * envelope_size;
585
586            // Zero reserved fields.
587            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
588
589            // Safety:
590            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
591            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
592            //   envelope_size bytes, there is always sufficient room.
593            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
594                self.name.as_ref().map(
595                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
596                ),
597                encoder,
598                offset + cur_offset,
599                depth,
600            )?;
601
602            _prev_end_offset = cur_offset + envelope_size;
603            if 2 > max_ordinal {
604                return Ok(());
605            }
606
607            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
608            // are envelope_size bytes.
609            let cur_offset: usize = (2 - 1) * envelope_size;
610
611            // Zero reserved fields.
612            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
613
614            // Safety:
615            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
616            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
617            //   envelope_size bytes, there is always sufficient room.
618            fidl::encoding::encode_in_envelope_optional::<Guid, D>(
619                self.type_guid.as_ref().map(<Guid as fidl::encoding::ValueTypeMarker>::borrow),
620                encoder,
621                offset + cur_offset,
622                depth,
623            )?;
624
625            _prev_end_offset = cur_offset + envelope_size;
626            if 3 > max_ordinal {
627                return Ok(());
628            }
629
630            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
631            // are envelope_size bytes.
632            let cur_offset: usize = (3 - 1) * envelope_size;
633
634            // Zero reserved fields.
635            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
636
637            // Safety:
638            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
639            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
640            //   envelope_size bytes, there is always sufficient room.
641            fidl::encoding::encode_in_envelope_optional::<Guid, D>(
642                self.instance_guid.as_ref().map(<Guid as fidl::encoding::ValueTypeMarker>::borrow),
643                encoder,
644                offset + cur_offset,
645                depth,
646            )?;
647
648            _prev_end_offset = cur_offset + envelope_size;
649            if 4 > max_ordinal {
650                return Ok(());
651            }
652
653            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
654            // are envelope_size bytes.
655            let cur_offset: usize = (4 - 1) * envelope_size;
656
657            // Zero reserved fields.
658            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
659
660            // Safety:
661            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
662            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
663            //   envelope_size bytes, there is always sufficient room.
664            fidl::encoding::encode_in_envelope_optional::<u64, D>(
665                self.start_block_offset
666                    .as_ref()
667                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
668                encoder,
669                offset + cur_offset,
670                depth,
671            )?;
672
673            _prev_end_offset = cur_offset + envelope_size;
674            if 5 > max_ordinal {
675                return Ok(());
676            }
677
678            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
679            // are envelope_size bytes.
680            let cur_offset: usize = (5 - 1) * envelope_size;
681
682            // Zero reserved fields.
683            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
684
685            // Safety:
686            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
687            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
688            //   envelope_size bytes, there is always sufficient room.
689            fidl::encoding::encode_in_envelope_optional::<u64, D>(
690                self.num_blocks.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
691                encoder,
692                offset + cur_offset,
693                depth,
694            )?;
695
696            _prev_end_offset = cur_offset + envelope_size;
697            if 6 > max_ordinal {
698                return Ok(());
699            }
700
701            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
702            // are envelope_size bytes.
703            let cur_offset: usize = (6 - 1) * envelope_size;
704
705            // Zero reserved fields.
706            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
707
708            // Safety:
709            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
710            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
711            //   envelope_size bytes, there is always sufficient room.
712            fidl::encoding::encode_in_envelope_optional::<u64, D>(
713                self.flags.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
714                encoder,
715                offset + cur_offset,
716                depth,
717            )?;
718
719            _prev_end_offset = cur_offset + envelope_size;
720
721            Ok(())
722        }
723    }
724
725    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
726        for PartitionGetMetadataResponse
727    {
728        #[inline(always)]
729        fn new_empty() -> Self {
730            Self::default()
731        }
732
733        unsafe fn decode(
734            &mut self,
735            decoder: &mut fidl::encoding::Decoder<'_, D>,
736            offset: usize,
737            mut depth: fidl::encoding::Depth,
738        ) -> fidl::Result<()> {
739            decoder.debug_check_bounds::<Self>(offset);
740            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
741                None => return Err(fidl::Error::NotNullable),
742                Some(len) => len,
743            };
744            // Calling decoder.out_of_line_offset(0) is not allowed.
745            if len == 0 {
746                return Ok(());
747            };
748            depth.increment()?;
749            let envelope_size = 8;
750            let bytes_len = len * envelope_size;
751            let offset = decoder.out_of_line_offset(bytes_len)?;
752            // Decode the envelope for each type.
753            let mut _next_ordinal_to_read = 0;
754            let mut next_offset = offset;
755            let end_offset = offset + bytes_len;
756            _next_ordinal_to_read += 1;
757            if next_offset >= end_offset {
758                return Ok(());
759            }
760
761            // Decode unknown envelopes for gaps in ordinals.
762            while _next_ordinal_to_read < 1 {
763                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
764                _next_ordinal_to_read += 1;
765                next_offset += envelope_size;
766            }
767
768            let next_out_of_line = decoder.next_out_of_line();
769            let handles_before = decoder.remaining_handles();
770            if let Some((inlined, num_bytes, num_handles)) =
771                fidl::encoding::decode_envelope_header(decoder, next_offset)?
772            {
773                let member_inline_size =
774                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
775                        decoder.context,
776                    );
777                if inlined != (member_inline_size <= 4) {
778                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
779                }
780                let inner_offset;
781                let mut inner_depth = depth.clone();
782                if inlined {
783                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
784                    inner_offset = next_offset;
785                } else {
786                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
787                    inner_depth.increment()?;
788                }
789                let val_ref = self
790                    .name
791                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
792                fidl::decode!(
793                    fidl::encoding::BoundedString<128>,
794                    D,
795                    val_ref,
796                    decoder,
797                    inner_offset,
798                    inner_depth
799                )?;
800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
801                {
802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
803                }
804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
806                }
807            }
808
809            next_offset += envelope_size;
810            _next_ordinal_to_read += 1;
811            if next_offset >= end_offset {
812                return Ok(());
813            }
814
815            // Decode unknown envelopes for gaps in ordinals.
816            while _next_ordinal_to_read < 2 {
817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
818                _next_ordinal_to_read += 1;
819                next_offset += envelope_size;
820            }
821
822            let next_out_of_line = decoder.next_out_of_line();
823            let handles_before = decoder.remaining_handles();
824            if let Some((inlined, num_bytes, num_handles)) =
825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
826            {
827                let member_inline_size =
828                    <Guid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
829                if inlined != (member_inline_size <= 4) {
830                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
831                }
832                let inner_offset;
833                let mut inner_depth = depth.clone();
834                if inlined {
835                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
836                    inner_offset = next_offset;
837                } else {
838                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
839                    inner_depth.increment()?;
840                }
841                let val_ref = self.type_guid.get_or_insert_with(|| fidl::new_empty!(Guid, D));
842                fidl::decode!(Guid, D, val_ref, decoder, inner_offset, inner_depth)?;
843                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
844                {
845                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
846                }
847                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
848                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
849                }
850            }
851
852            next_offset += envelope_size;
853            _next_ordinal_to_read += 1;
854            if next_offset >= end_offset {
855                return Ok(());
856            }
857
858            // Decode unknown envelopes for gaps in ordinals.
859            while _next_ordinal_to_read < 3 {
860                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
861                _next_ordinal_to_read += 1;
862                next_offset += envelope_size;
863            }
864
865            let next_out_of_line = decoder.next_out_of_line();
866            let handles_before = decoder.remaining_handles();
867            if let Some((inlined, num_bytes, num_handles)) =
868                fidl::encoding::decode_envelope_header(decoder, next_offset)?
869            {
870                let member_inline_size =
871                    <Guid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
872                if inlined != (member_inline_size <= 4) {
873                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
874                }
875                let inner_offset;
876                let mut inner_depth = depth.clone();
877                if inlined {
878                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
879                    inner_offset = next_offset;
880                } else {
881                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
882                    inner_depth.increment()?;
883                }
884                let val_ref = self.instance_guid.get_or_insert_with(|| fidl::new_empty!(Guid, D));
885                fidl::decode!(Guid, D, val_ref, decoder, inner_offset, inner_depth)?;
886                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
887                {
888                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
889                }
890                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
891                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
892                }
893            }
894
895            next_offset += envelope_size;
896            _next_ordinal_to_read += 1;
897            if next_offset >= end_offset {
898                return Ok(());
899            }
900
901            // Decode unknown envelopes for gaps in ordinals.
902            while _next_ordinal_to_read < 4 {
903                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
904                _next_ordinal_to_read += 1;
905                next_offset += envelope_size;
906            }
907
908            let next_out_of_line = decoder.next_out_of_line();
909            let handles_before = decoder.remaining_handles();
910            if let Some((inlined, num_bytes, num_handles)) =
911                fidl::encoding::decode_envelope_header(decoder, next_offset)?
912            {
913                let member_inline_size =
914                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
915                if inlined != (member_inline_size <= 4) {
916                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
917                }
918                let inner_offset;
919                let mut inner_depth = depth.clone();
920                if inlined {
921                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
922                    inner_offset = next_offset;
923                } else {
924                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
925                    inner_depth.increment()?;
926                }
927                let val_ref =
928                    self.start_block_offset.get_or_insert_with(|| fidl::new_empty!(u64, D));
929                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
930                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
931                {
932                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
933                }
934                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
935                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
936                }
937            }
938
939            next_offset += envelope_size;
940            _next_ordinal_to_read += 1;
941            if next_offset >= end_offset {
942                return Ok(());
943            }
944
945            // Decode unknown envelopes for gaps in ordinals.
946            while _next_ordinal_to_read < 5 {
947                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
948                _next_ordinal_to_read += 1;
949                next_offset += envelope_size;
950            }
951
952            let next_out_of_line = decoder.next_out_of_line();
953            let handles_before = decoder.remaining_handles();
954            if let Some((inlined, num_bytes, num_handles)) =
955                fidl::encoding::decode_envelope_header(decoder, next_offset)?
956            {
957                let member_inline_size =
958                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
959                if inlined != (member_inline_size <= 4) {
960                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
961                }
962                let inner_offset;
963                let mut inner_depth = depth.clone();
964                if inlined {
965                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
966                    inner_offset = next_offset;
967                } else {
968                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
969                    inner_depth.increment()?;
970                }
971                let val_ref = self.num_blocks.get_or_insert_with(|| fidl::new_empty!(u64, D));
972                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
973                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
974                {
975                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
976                }
977                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
978                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
979                }
980            }
981
982            next_offset += envelope_size;
983            _next_ordinal_to_read += 1;
984            if next_offset >= end_offset {
985                return Ok(());
986            }
987
988            // Decode unknown envelopes for gaps in ordinals.
989            while _next_ordinal_to_read < 6 {
990                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
991                _next_ordinal_to_read += 1;
992                next_offset += envelope_size;
993            }
994
995            let next_out_of_line = decoder.next_out_of_line();
996            let handles_before = decoder.remaining_handles();
997            if let Some((inlined, num_bytes, num_handles)) =
998                fidl::encoding::decode_envelope_header(decoder, next_offset)?
999            {
1000                let member_inline_size =
1001                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1002                if inlined != (member_inline_size <= 4) {
1003                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1004                }
1005                let inner_offset;
1006                let mut inner_depth = depth.clone();
1007                if inlined {
1008                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1009                    inner_offset = next_offset;
1010                } else {
1011                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1012                    inner_depth.increment()?;
1013                }
1014                let val_ref = self.flags.get_or_insert_with(|| fidl::new_empty!(u64, D));
1015                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1016                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1017                {
1018                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1019                }
1020                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1021                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1022                }
1023            }
1024
1025            next_offset += envelope_size;
1026
1027            // Decode the remaining unknown envelopes.
1028            while next_offset < end_offset {
1029                _next_ordinal_to_read += 1;
1030                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1031                next_offset += envelope_size;
1032            }
1033
1034            Ok(())
1035        }
1036    }
1037}