fidl_fuchsia_hardware_block__common/
fidl_fuchsia_hardware_block__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 MAPPINGS_BATCH_SIZE: u8 = 64;
12
13/// The maximum value for a transfer size, identifying that there
14/// effectively exists no maximum for a single operation.
15pub const MAX_TRANSFER_UNBOUNDED: u32 = 4294967295;
16
17/// Value reserved for "invalid" VmoId. Will never be allocated by the server,
18/// and may be utilized as a local value for an unallocated ID.
19pub const VMOID_INVALID: u16 = 0;
20
21bitflags! {
22    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
23    pub struct Flag: u32 {
24        /// All writes to the block device will fail.
25        const READONLY = 1;
26        /// The block device may be removed from the device during operation.
27        const REMOVABLE = 2;
28        /// The device has a bootdata partition map.
29        const BOOTPART = 4;
30        /// The device provides trim support.
31        const TRIM_SUPPORT = 8;
32        /// The device provides fua support.
33        const FUA_SUPPORT = 16;
34    }
35}
36
37impl Flag {}
38
39#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct BlockInfo {
41    /// The number of blocks in this block device.
42    pub block_count: u64,
43    /// The size of a single block.
44    pub block_size: u32,
45    /// The maximum size, in bytes, of a transfer.
46    /// Set to MAX_TRANSFER_UNBOUNDED if no such maximum exists.
47    pub max_transfer_size: u32,
48    /// Identifiers about the device.
49    pub flags: Flag,
50}
51
52impl fidl::Persistable for BlockInfo {}
53
54/// Describes a re-mapping of a block range.  See OffsetMap.
55/// Note that all fields are in *blocks*, not bytes.
56#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57#[repr(C)]
58pub struct BlockOffsetMapping {
59    pub source_block_offset: u64,
60    pub target_block_offset: u64,
61    pub length: u64,
62}
63
64impl fidl::Persistable for BlockOffsetMapping {}
65
66#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct BlockGetInfoResponse {
68    pub info: BlockInfo,
69}
70
71impl fidl::Persistable for BlockGetInfoResponse {}
72
73#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74#[repr(C)]
75pub struct FtlFormatResponse {
76    pub status: i32,
77}
78
79impl fidl::Persistable for FtlFormatResponse {}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82#[repr(C)]
83pub struct OffsetMapQueryRequest {
84    pub source_block_offset: u64,
85    pub length: u64,
86}
87
88impl fidl::Persistable for OffsetMapQueryRequest {}
89
90#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91pub struct OffsetMapQueryResponse {
92    pub mappings: Vec<BlockOffsetMapping>,
93}
94
95impl fidl::Persistable for OffsetMapQueryResponse {}
96
97#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
98#[repr(C)]
99pub struct SessionAttachVmoResponse {
100    pub vmoid: VmoId,
101}
102
103impl fidl::Persistable for SessionAttachVmoResponse {}
104
105#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106#[repr(C)]
107pub struct VmoId {
108    pub id: u16,
109}
110
111impl fidl::Persistable for VmoId {}
112
113pub mod block_ordinals {
114    pub const GET_INFO: u64 = 0x79df1a5cdb6cc6a3;
115    pub const OPEN_SESSION: u64 = 0x7241c68d17614a31;
116    pub const OPEN_SESSION_WITH_OFFSET_MAP: u64 = 0x7a8d3ba3d8bfa10f;
117}
118
119pub mod ftl_ordinals {
120    pub const GET_VMO: u64 = 0xf523185c6e67738;
121    pub const FORMAT: u64 = 0x79751d9c0b48a0d6;
122}
123
124pub mod inspect_vmo_provider_ordinals {
125    pub const GET_VMO: u64 = 0xf523185c6e67738;
126}
127
128pub mod offset_map_ordinals {
129    pub const QUERY: u64 = 0x18471939852e45a4;
130}
131
132pub mod session_ordinals {
133    pub const CLOSE: u64 = 0x5ac5d459ad7f657e;
134    pub const GET_FIFO: u64 = 0x61a31a92a206b7d5;
135    pub const ATTACH_VMO: u64 = 0x54edc4641d9569f5;
136}
137
138mod internal {
139    use super::*;
140    unsafe impl fidl::encoding::TypeMarker for Flag {
141        type Owned = Self;
142
143        #[inline(always)]
144        fn inline_align(_context: fidl::encoding::Context) -> usize {
145            4
146        }
147
148        #[inline(always)]
149        fn inline_size(_context: fidl::encoding::Context) -> usize {
150            4
151        }
152    }
153
154    impl fidl::encoding::ValueTypeMarker for Flag {
155        type Borrowed<'a> = Self;
156        #[inline(always)]
157        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
158            *value
159        }
160    }
161
162    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Flag {
163        #[inline]
164        unsafe fn encode(
165            self,
166            encoder: &mut fidl::encoding::Encoder<'_, D>,
167            offset: usize,
168            _depth: fidl::encoding::Depth,
169        ) -> fidl::Result<()> {
170            encoder.debug_check_bounds::<Self>(offset);
171            if self.bits() & Self::all().bits() != self.bits() {
172                return Err(fidl::Error::InvalidBitsValue);
173            }
174            encoder.write_num(self.bits(), offset);
175            Ok(())
176        }
177    }
178
179    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Flag {
180        #[inline(always)]
181        fn new_empty() -> Self {
182            Self::empty()
183        }
184
185        #[inline]
186        unsafe fn decode(
187            &mut self,
188            decoder: &mut fidl::encoding::Decoder<'_, D>,
189            offset: usize,
190            _depth: fidl::encoding::Depth,
191        ) -> fidl::Result<()> {
192            decoder.debug_check_bounds::<Self>(offset);
193            let prim = decoder.read_num::<u32>(offset);
194            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
195            Ok(())
196        }
197    }
198
199    impl fidl::encoding::ValueTypeMarker for BlockInfo {
200        type Borrowed<'a> = &'a Self;
201        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
202            value
203        }
204    }
205
206    unsafe impl fidl::encoding::TypeMarker for BlockInfo {
207        type Owned = Self;
208
209        #[inline(always)]
210        fn inline_align(_context: fidl::encoding::Context) -> usize {
211            8
212        }
213
214        #[inline(always)]
215        fn inline_size(_context: fidl::encoding::Context) -> usize {
216            24
217        }
218    }
219
220    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockInfo, D>
221        for &BlockInfo
222    {
223        #[inline]
224        unsafe fn encode(
225            self,
226            encoder: &mut fidl::encoding::Encoder<'_, D>,
227            offset: usize,
228            _depth: fidl::encoding::Depth,
229        ) -> fidl::Result<()> {
230            encoder.debug_check_bounds::<BlockInfo>(offset);
231            // Delegate to tuple encoding.
232            fidl::encoding::Encode::<BlockInfo, D>::encode(
233                (
234                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_count),
235                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_size),
236                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_transfer_size),
237                    <Flag as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
238                ),
239                encoder,
240                offset,
241                _depth,
242            )
243        }
244    }
245    unsafe impl<
246            D: fidl::encoding::ResourceDialect,
247            T0: fidl::encoding::Encode<u64, D>,
248            T1: fidl::encoding::Encode<u32, D>,
249            T2: fidl::encoding::Encode<u32, D>,
250            T3: fidl::encoding::Encode<Flag, D>,
251        > fidl::encoding::Encode<BlockInfo, D> for (T0, T1, T2, T3)
252    {
253        #[inline]
254        unsafe fn encode(
255            self,
256            encoder: &mut fidl::encoding::Encoder<'_, D>,
257            offset: usize,
258            depth: fidl::encoding::Depth,
259        ) -> fidl::Result<()> {
260            encoder.debug_check_bounds::<BlockInfo>(offset);
261            // Zero out padding regions. There's no need to apply masks
262            // because the unmasked parts will be overwritten by fields.
263            unsafe {
264                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
265                (ptr as *mut u64).write_unaligned(0);
266            }
267            // Write the fields.
268            self.0.encode(encoder, offset + 0, depth)?;
269            self.1.encode(encoder, offset + 8, depth)?;
270            self.2.encode(encoder, offset + 12, depth)?;
271            self.3.encode(encoder, offset + 16, depth)?;
272            Ok(())
273        }
274    }
275
276    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockInfo {
277        #[inline(always)]
278        fn new_empty() -> Self {
279            Self {
280                block_count: fidl::new_empty!(u64, D),
281                block_size: fidl::new_empty!(u32, D),
282                max_transfer_size: fidl::new_empty!(u32, D),
283                flags: fidl::new_empty!(Flag, D),
284            }
285        }
286
287        #[inline]
288        unsafe fn decode(
289            &mut self,
290            decoder: &mut fidl::encoding::Decoder<'_, D>,
291            offset: usize,
292            _depth: fidl::encoding::Depth,
293        ) -> fidl::Result<()> {
294            decoder.debug_check_bounds::<Self>(offset);
295            // Verify that padding bytes are zero.
296            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
297            let padval = unsafe { (ptr as *const u64).read_unaligned() };
298            let mask = 0xffffffff00000000u64;
299            let maskedval = padval & mask;
300            if maskedval != 0 {
301                return Err(fidl::Error::NonZeroPadding {
302                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
303                });
304            }
305            fidl::decode!(u64, D, &mut self.block_count, decoder, offset + 0, _depth)?;
306            fidl::decode!(u32, D, &mut self.block_size, decoder, offset + 8, _depth)?;
307            fidl::decode!(u32, D, &mut self.max_transfer_size, decoder, offset + 12, _depth)?;
308            fidl::decode!(Flag, D, &mut self.flags, decoder, offset + 16, _depth)?;
309            Ok(())
310        }
311    }
312
313    impl fidl::encoding::ValueTypeMarker for BlockOffsetMapping {
314        type Borrowed<'a> = &'a Self;
315        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
316            value
317        }
318    }
319
320    unsafe impl fidl::encoding::TypeMarker for BlockOffsetMapping {
321        type Owned = Self;
322
323        #[inline(always)]
324        fn inline_align(_context: fidl::encoding::Context) -> usize {
325            8
326        }
327
328        #[inline(always)]
329        fn inline_size(_context: fidl::encoding::Context) -> usize {
330            24
331        }
332        #[inline(always)]
333        fn encode_is_copy() -> bool {
334            true
335        }
336
337        #[inline(always)]
338        fn decode_is_copy() -> bool {
339            true
340        }
341    }
342
343    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockOffsetMapping, D>
344        for &BlockOffsetMapping
345    {
346        #[inline]
347        unsafe fn encode(
348            self,
349            encoder: &mut fidl::encoding::Encoder<'_, D>,
350            offset: usize,
351            _depth: fidl::encoding::Depth,
352        ) -> fidl::Result<()> {
353            encoder.debug_check_bounds::<BlockOffsetMapping>(offset);
354            unsafe {
355                // Copy the object into the buffer.
356                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
357                (buf_ptr as *mut BlockOffsetMapping)
358                    .write_unaligned((self as *const BlockOffsetMapping).read());
359                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
360                // done second because the memcpy will write garbage to these bytes.
361            }
362            Ok(())
363        }
364    }
365    unsafe impl<
366            D: fidl::encoding::ResourceDialect,
367            T0: fidl::encoding::Encode<u64, D>,
368            T1: fidl::encoding::Encode<u64, D>,
369            T2: fidl::encoding::Encode<u64, D>,
370        > fidl::encoding::Encode<BlockOffsetMapping, D> for (T0, T1, T2)
371    {
372        #[inline]
373        unsafe fn encode(
374            self,
375            encoder: &mut fidl::encoding::Encoder<'_, D>,
376            offset: usize,
377            depth: fidl::encoding::Depth,
378        ) -> fidl::Result<()> {
379            encoder.debug_check_bounds::<BlockOffsetMapping>(offset);
380            // Zero out padding regions. There's no need to apply masks
381            // because the unmasked parts will be overwritten by fields.
382            // Write the fields.
383            self.0.encode(encoder, offset + 0, depth)?;
384            self.1.encode(encoder, offset + 8, depth)?;
385            self.2.encode(encoder, offset + 16, depth)?;
386            Ok(())
387        }
388    }
389
390    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockOffsetMapping {
391        #[inline(always)]
392        fn new_empty() -> Self {
393            Self {
394                source_block_offset: fidl::new_empty!(u64, D),
395                target_block_offset: fidl::new_empty!(u64, D),
396                length: fidl::new_empty!(u64, D),
397            }
398        }
399
400        #[inline]
401        unsafe fn decode(
402            &mut self,
403            decoder: &mut fidl::encoding::Decoder<'_, D>,
404            offset: usize,
405            _depth: fidl::encoding::Depth,
406        ) -> fidl::Result<()> {
407            decoder.debug_check_bounds::<Self>(offset);
408            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
409            // Verify that padding bytes are zero.
410            // Copy from the buffer into the object.
411            unsafe {
412                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
413            }
414            Ok(())
415        }
416    }
417
418    impl fidl::encoding::ValueTypeMarker for BlockGetInfoResponse {
419        type Borrowed<'a> = &'a Self;
420        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
421            value
422        }
423    }
424
425    unsafe impl fidl::encoding::TypeMarker for BlockGetInfoResponse {
426        type Owned = Self;
427
428        #[inline(always)]
429        fn inline_align(_context: fidl::encoding::Context) -> usize {
430            8
431        }
432
433        #[inline(always)]
434        fn inline_size(_context: fidl::encoding::Context) -> usize {
435            24
436        }
437    }
438
439    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockGetInfoResponse, D>
440        for &BlockGetInfoResponse
441    {
442        #[inline]
443        unsafe fn encode(
444            self,
445            encoder: &mut fidl::encoding::Encoder<'_, D>,
446            offset: usize,
447            _depth: fidl::encoding::Depth,
448        ) -> fidl::Result<()> {
449            encoder.debug_check_bounds::<BlockGetInfoResponse>(offset);
450            // Delegate to tuple encoding.
451            fidl::encoding::Encode::<BlockGetInfoResponse, D>::encode(
452                (<BlockInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
453                encoder,
454                offset,
455                _depth,
456            )
457        }
458    }
459    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BlockInfo, D>>
460        fidl::encoding::Encode<BlockGetInfoResponse, D> for (T0,)
461    {
462        #[inline]
463        unsafe fn encode(
464            self,
465            encoder: &mut fidl::encoding::Encoder<'_, D>,
466            offset: usize,
467            depth: fidl::encoding::Depth,
468        ) -> fidl::Result<()> {
469            encoder.debug_check_bounds::<BlockGetInfoResponse>(offset);
470            // Zero out padding regions. There's no need to apply masks
471            // because the unmasked parts will be overwritten by fields.
472            // Write the fields.
473            self.0.encode(encoder, offset + 0, depth)?;
474            Ok(())
475        }
476    }
477
478    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockGetInfoResponse {
479        #[inline(always)]
480        fn new_empty() -> Self {
481            Self { info: fidl::new_empty!(BlockInfo, D) }
482        }
483
484        #[inline]
485        unsafe fn decode(
486            &mut self,
487            decoder: &mut fidl::encoding::Decoder<'_, D>,
488            offset: usize,
489            _depth: fidl::encoding::Depth,
490        ) -> fidl::Result<()> {
491            decoder.debug_check_bounds::<Self>(offset);
492            // Verify that padding bytes are zero.
493            fidl::decode!(BlockInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
494            Ok(())
495        }
496    }
497
498    impl fidl::encoding::ValueTypeMarker for FtlFormatResponse {
499        type Borrowed<'a> = &'a Self;
500        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
501            value
502        }
503    }
504
505    unsafe impl fidl::encoding::TypeMarker for FtlFormatResponse {
506        type Owned = Self;
507
508        #[inline(always)]
509        fn inline_align(_context: fidl::encoding::Context) -> usize {
510            4
511        }
512
513        #[inline(always)]
514        fn inline_size(_context: fidl::encoding::Context) -> usize {
515            4
516        }
517        #[inline(always)]
518        fn encode_is_copy() -> bool {
519            true
520        }
521
522        #[inline(always)]
523        fn decode_is_copy() -> bool {
524            true
525        }
526    }
527
528    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FtlFormatResponse, D>
529        for &FtlFormatResponse
530    {
531        #[inline]
532        unsafe fn encode(
533            self,
534            encoder: &mut fidl::encoding::Encoder<'_, D>,
535            offset: usize,
536            _depth: fidl::encoding::Depth,
537        ) -> fidl::Result<()> {
538            encoder.debug_check_bounds::<FtlFormatResponse>(offset);
539            unsafe {
540                // Copy the object into the buffer.
541                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
542                (buf_ptr as *mut FtlFormatResponse)
543                    .write_unaligned((self as *const FtlFormatResponse).read());
544                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
545                // done second because the memcpy will write garbage to these bytes.
546            }
547            Ok(())
548        }
549    }
550    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
551        fidl::encoding::Encode<FtlFormatResponse, D> for (T0,)
552    {
553        #[inline]
554        unsafe fn encode(
555            self,
556            encoder: &mut fidl::encoding::Encoder<'_, D>,
557            offset: usize,
558            depth: fidl::encoding::Depth,
559        ) -> fidl::Result<()> {
560            encoder.debug_check_bounds::<FtlFormatResponse>(offset);
561            // Zero out padding regions. There's no need to apply masks
562            // because the unmasked parts will be overwritten by fields.
563            // Write the fields.
564            self.0.encode(encoder, offset + 0, depth)?;
565            Ok(())
566        }
567    }
568
569    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FtlFormatResponse {
570        #[inline(always)]
571        fn new_empty() -> Self {
572            Self { status: fidl::new_empty!(i32, D) }
573        }
574
575        #[inline]
576        unsafe fn decode(
577            &mut self,
578            decoder: &mut fidl::encoding::Decoder<'_, D>,
579            offset: usize,
580            _depth: fidl::encoding::Depth,
581        ) -> fidl::Result<()> {
582            decoder.debug_check_bounds::<Self>(offset);
583            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
584            // Verify that padding bytes are zero.
585            // Copy from the buffer into the object.
586            unsafe {
587                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
588            }
589            Ok(())
590        }
591    }
592
593    impl fidl::encoding::ValueTypeMarker for OffsetMapQueryRequest {
594        type Borrowed<'a> = &'a Self;
595        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
596            value
597        }
598    }
599
600    unsafe impl fidl::encoding::TypeMarker for OffsetMapQueryRequest {
601        type Owned = Self;
602
603        #[inline(always)]
604        fn inline_align(_context: fidl::encoding::Context) -> usize {
605            8
606        }
607
608        #[inline(always)]
609        fn inline_size(_context: fidl::encoding::Context) -> usize {
610            16
611        }
612        #[inline(always)]
613        fn encode_is_copy() -> bool {
614            true
615        }
616
617        #[inline(always)]
618        fn decode_is_copy() -> bool {
619            true
620        }
621    }
622
623    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OffsetMapQueryRequest, D>
624        for &OffsetMapQueryRequest
625    {
626        #[inline]
627        unsafe fn encode(
628            self,
629            encoder: &mut fidl::encoding::Encoder<'_, D>,
630            offset: usize,
631            _depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            encoder.debug_check_bounds::<OffsetMapQueryRequest>(offset);
634            unsafe {
635                // Copy the object into the buffer.
636                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
637                (buf_ptr as *mut OffsetMapQueryRequest)
638                    .write_unaligned((self as *const OffsetMapQueryRequest).read());
639                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
640                // done second because the memcpy will write garbage to these bytes.
641            }
642            Ok(())
643        }
644    }
645    unsafe impl<
646            D: fidl::encoding::ResourceDialect,
647            T0: fidl::encoding::Encode<u64, D>,
648            T1: fidl::encoding::Encode<u64, D>,
649        > fidl::encoding::Encode<OffsetMapQueryRequest, D> for (T0, T1)
650    {
651        #[inline]
652        unsafe fn encode(
653            self,
654            encoder: &mut fidl::encoding::Encoder<'_, D>,
655            offset: usize,
656            depth: fidl::encoding::Depth,
657        ) -> fidl::Result<()> {
658            encoder.debug_check_bounds::<OffsetMapQueryRequest>(offset);
659            // Zero out padding regions. There's no need to apply masks
660            // because the unmasked parts will be overwritten by fields.
661            // Write the fields.
662            self.0.encode(encoder, offset + 0, depth)?;
663            self.1.encode(encoder, offset + 8, depth)?;
664            Ok(())
665        }
666    }
667
668    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OffsetMapQueryRequest {
669        #[inline(always)]
670        fn new_empty() -> Self {
671            Self { source_block_offset: fidl::new_empty!(u64, D), length: fidl::new_empty!(u64, D) }
672        }
673
674        #[inline]
675        unsafe fn decode(
676            &mut self,
677            decoder: &mut fidl::encoding::Decoder<'_, D>,
678            offset: usize,
679            _depth: fidl::encoding::Depth,
680        ) -> fidl::Result<()> {
681            decoder.debug_check_bounds::<Self>(offset);
682            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
683            // Verify that padding bytes are zero.
684            // Copy from the buffer into the object.
685            unsafe {
686                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
687            }
688            Ok(())
689        }
690    }
691
692    impl fidl::encoding::ValueTypeMarker for OffsetMapQueryResponse {
693        type Borrowed<'a> = &'a Self;
694        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
695            value
696        }
697    }
698
699    unsafe impl fidl::encoding::TypeMarker for OffsetMapQueryResponse {
700        type Owned = Self;
701
702        #[inline(always)]
703        fn inline_align(_context: fidl::encoding::Context) -> usize {
704            8
705        }
706
707        #[inline(always)]
708        fn inline_size(_context: fidl::encoding::Context) -> usize {
709            16
710        }
711    }
712
713    unsafe impl<D: fidl::encoding::ResourceDialect>
714        fidl::encoding::Encode<OffsetMapQueryResponse, D> for &OffsetMapQueryResponse
715    {
716        #[inline]
717        unsafe fn encode(
718            self,
719            encoder: &mut fidl::encoding::Encoder<'_, D>,
720            offset: usize,
721            _depth: fidl::encoding::Depth,
722        ) -> fidl::Result<()> {
723            encoder.debug_check_bounds::<OffsetMapQueryResponse>(offset);
724            // Delegate to tuple encoding.
725            fidl::encoding::Encode::<OffsetMapQueryResponse, D>::encode(
726                (
727                    <fidl::encoding::Vector<BlockOffsetMapping, 64> as fidl::encoding::ValueTypeMarker>::borrow(&self.mappings),
728                ),
729                encoder, offset, _depth
730            )
731        }
732    }
733    unsafe impl<
734            D: fidl::encoding::ResourceDialect,
735            T0: fidl::encoding::Encode<fidl::encoding::Vector<BlockOffsetMapping, 64>, D>,
736        > fidl::encoding::Encode<OffsetMapQueryResponse, D> for (T0,)
737    {
738        #[inline]
739        unsafe fn encode(
740            self,
741            encoder: &mut fidl::encoding::Encoder<'_, D>,
742            offset: usize,
743            depth: fidl::encoding::Depth,
744        ) -> fidl::Result<()> {
745            encoder.debug_check_bounds::<OffsetMapQueryResponse>(offset);
746            // Zero out padding regions. There's no need to apply masks
747            // because the unmasked parts will be overwritten by fields.
748            // Write the fields.
749            self.0.encode(encoder, offset + 0, depth)?;
750            Ok(())
751        }
752    }
753
754    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
755        for OffsetMapQueryResponse
756    {
757        #[inline(always)]
758        fn new_empty() -> Self {
759            Self { mappings: fidl::new_empty!(fidl::encoding::Vector<BlockOffsetMapping, 64>, D) }
760        }
761
762        #[inline]
763        unsafe fn decode(
764            &mut self,
765            decoder: &mut fidl::encoding::Decoder<'_, D>,
766            offset: usize,
767            _depth: fidl::encoding::Depth,
768        ) -> fidl::Result<()> {
769            decoder.debug_check_bounds::<Self>(offset);
770            // Verify that padding bytes are zero.
771            fidl::decode!(fidl::encoding::Vector<BlockOffsetMapping, 64>, D, &mut self.mappings, decoder, offset + 0, _depth)?;
772            Ok(())
773        }
774    }
775
776    impl fidl::encoding::ValueTypeMarker for SessionAttachVmoResponse {
777        type Borrowed<'a> = &'a Self;
778        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
779            value
780        }
781    }
782
783    unsafe impl fidl::encoding::TypeMarker for SessionAttachVmoResponse {
784        type Owned = Self;
785
786        #[inline(always)]
787        fn inline_align(_context: fidl::encoding::Context) -> usize {
788            2
789        }
790
791        #[inline(always)]
792        fn inline_size(_context: fidl::encoding::Context) -> usize {
793            2
794        }
795        #[inline(always)]
796        fn encode_is_copy() -> bool {
797            true
798        }
799
800        #[inline(always)]
801        fn decode_is_copy() -> bool {
802            true
803        }
804    }
805
806    unsafe impl<D: fidl::encoding::ResourceDialect>
807        fidl::encoding::Encode<SessionAttachVmoResponse, D> for &SessionAttachVmoResponse
808    {
809        #[inline]
810        unsafe fn encode(
811            self,
812            encoder: &mut fidl::encoding::Encoder<'_, D>,
813            offset: usize,
814            _depth: fidl::encoding::Depth,
815        ) -> fidl::Result<()> {
816            encoder.debug_check_bounds::<SessionAttachVmoResponse>(offset);
817            unsafe {
818                // Copy the object into the buffer.
819                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
820                (buf_ptr as *mut SessionAttachVmoResponse)
821                    .write_unaligned((self as *const SessionAttachVmoResponse).read());
822                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
823                // done second because the memcpy will write garbage to these bytes.
824            }
825            Ok(())
826        }
827    }
828    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<VmoId, D>>
829        fidl::encoding::Encode<SessionAttachVmoResponse, D> for (T0,)
830    {
831        #[inline]
832        unsafe fn encode(
833            self,
834            encoder: &mut fidl::encoding::Encoder<'_, D>,
835            offset: usize,
836            depth: fidl::encoding::Depth,
837        ) -> fidl::Result<()> {
838            encoder.debug_check_bounds::<SessionAttachVmoResponse>(offset);
839            // Zero out padding regions. There's no need to apply masks
840            // because the unmasked parts will be overwritten by fields.
841            // Write the fields.
842            self.0.encode(encoder, offset + 0, depth)?;
843            Ok(())
844        }
845    }
846
847    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
848        for SessionAttachVmoResponse
849    {
850        #[inline(always)]
851        fn new_empty() -> Self {
852            Self { vmoid: fidl::new_empty!(VmoId, D) }
853        }
854
855        #[inline]
856        unsafe fn decode(
857            &mut self,
858            decoder: &mut fidl::encoding::Decoder<'_, D>,
859            offset: usize,
860            _depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            decoder.debug_check_bounds::<Self>(offset);
863            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
864            // Verify that padding bytes are zero.
865            // Copy from the buffer into the object.
866            unsafe {
867                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
868            }
869            Ok(())
870        }
871    }
872
873    impl fidl::encoding::ValueTypeMarker for VmoId {
874        type Borrowed<'a> = &'a Self;
875        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
876            value
877        }
878    }
879
880    unsafe impl fidl::encoding::TypeMarker for VmoId {
881        type Owned = Self;
882
883        #[inline(always)]
884        fn inline_align(_context: fidl::encoding::Context) -> usize {
885            2
886        }
887
888        #[inline(always)]
889        fn inline_size(_context: fidl::encoding::Context) -> usize {
890            2
891        }
892        #[inline(always)]
893        fn encode_is_copy() -> bool {
894            true
895        }
896
897        #[inline(always)]
898        fn decode_is_copy() -> bool {
899            true
900        }
901    }
902
903    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VmoId, D> for &VmoId {
904        #[inline]
905        unsafe fn encode(
906            self,
907            encoder: &mut fidl::encoding::Encoder<'_, D>,
908            offset: usize,
909            _depth: fidl::encoding::Depth,
910        ) -> fidl::Result<()> {
911            encoder.debug_check_bounds::<VmoId>(offset);
912            unsafe {
913                // Copy the object into the buffer.
914                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
915                (buf_ptr as *mut VmoId).write_unaligned((self as *const VmoId).read());
916                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
917                // done second because the memcpy will write garbage to these bytes.
918            }
919            Ok(())
920        }
921    }
922    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u16, D>>
923        fidl::encoding::Encode<VmoId, D> for (T0,)
924    {
925        #[inline]
926        unsafe fn encode(
927            self,
928            encoder: &mut fidl::encoding::Encoder<'_, D>,
929            offset: usize,
930            depth: fidl::encoding::Depth,
931        ) -> fidl::Result<()> {
932            encoder.debug_check_bounds::<VmoId>(offset);
933            // Zero out padding regions. There's no need to apply masks
934            // because the unmasked parts will be overwritten by fields.
935            // Write the fields.
936            self.0.encode(encoder, offset + 0, depth)?;
937            Ok(())
938        }
939    }
940
941    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VmoId {
942        #[inline(always)]
943        fn new_empty() -> Self {
944            Self { id: fidl::new_empty!(u16, D) }
945        }
946
947        #[inline]
948        unsafe fn decode(
949            &mut self,
950            decoder: &mut fidl::encoding::Decoder<'_, D>,
951            offset: usize,
952            _depth: fidl::encoding::Depth,
953        ) -> fidl::Result<()> {
954            decoder.debug_check_bounds::<Self>(offset);
955            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
956            // Verify that padding bytes are zero.
957            // Copy from the buffer into the object.
958            unsafe {
959                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
960            }
961            Ok(())
962        }
963    }
964}