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
11/// The maximum amount of data that can be decompressed in a single group of decompression
12/// operations.
13pub const MAX_DECOMPRESSED_BYTES: u64 = 134217728;
14
15/// The maximum value for a transfer size, identifying that there
16/// effectively exists no maximum for a single operation.
17pub const MAX_TRANSFER_UNBOUNDED: u32 = 4294967295;
18
19/// Value reserved for "invalid" VmoId. Will never be allocated by the server,
20/// and may be utilized as a local value for an unallocated ID.
21pub const VMOID_INVALID: u16 = 0;
22
23bitflags! {
24    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
25    pub struct Flag: u32 {
26        /// All writes to the block device will fail.
27        const READONLY = 1;
28        /// The block device may be removed from the device during operation.
29        const REMOVABLE = 2;
30        /// The device has a bootdata partition map.
31        const BOOTPART = 4;
32        /// The device provides trim support.
33        const TRIM_SUPPORT = 8;
34        /// The device provides Force Unit Access (FUA) support.
35        ///
36        /// If this bit is unset, and a request is sent with the FORCE_ACCESS option set, the device
37        /// will simulate a FUA by executing a device flush after the request completes (but before
38        /// responding to the client).  Clients are strongly encouraged to probe for FUA support and
39        /// avoid usage of FORCE_ACCESS without device support, since this is expensive.
40        const FUA_SUPPORT = 16;
41        /// The device provides zstd decompression support.
42        const ZSTD_DECOMPRESSION_SUPPORT = 32;
43        /// The device provides Barrier support.
44        ///
45        /// If this bit is unset, and a request is sent with the PRE_BARRIER option set, the device
46        /// will simulate a barrier by executing a device flush before the request is submitted.
47        /// Clients are strongly encouraged to probe for barrier support and avoid usage of
48        /// PRE_BARRIER without device support, since this is expensive.
49        const BARRIER_SUPPORT = 64;
50    }
51}
52
53impl Flag {}
54
55#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct BlockInfo {
57    /// The number of blocks in this block device.
58    pub block_count: u64,
59    /// The size of a single block.
60    pub block_size: u32,
61    /// The maximum size, in bytes, of a transfer.
62    /// Set to MAX_TRANSFER_UNBOUNDED if no such maximum exists.
63    pub max_transfer_size: u32,
64    /// Identifiers about the device.
65    pub flags: Flag,
66}
67
68impl fidl::Persistable for BlockInfo {}
69
70/// Describes a re-mapping of a block range.  See OffsetMap.
71/// Note that all fields are in *blocks*, not bytes.
72#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
73#[repr(C)]
74pub struct BlockOffsetMapping {
75    pub source_block_offset: u64,
76    pub target_block_offset: u64,
77    pub length: u64,
78}
79
80impl fidl::Persistable for BlockOffsetMapping {}
81
82#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
83pub struct BlockGetInfoResponse {
84    pub info: BlockInfo,
85}
86
87impl fidl::Persistable for BlockGetInfoResponse {}
88
89#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
90#[repr(C)]
91pub struct FtlFormatResponse {
92    pub status: i32,
93}
94
95impl fidl::Persistable for FtlFormatResponse {}
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 session_ordinals {
129    pub const CLOSE: u64 = 0x5ac5d459ad7f657e;
130    pub const GET_FIFO: u64 = 0x61a31a92a206b7d5;
131    pub const ATTACH_VMO: u64 = 0x54edc4641d9569f5;
132}
133
134mod internal {
135    use super::*;
136    unsafe impl fidl::encoding::TypeMarker for Flag {
137        type Owned = Self;
138
139        #[inline(always)]
140        fn inline_align(_context: fidl::encoding::Context) -> usize {
141            4
142        }
143
144        #[inline(always)]
145        fn inline_size(_context: fidl::encoding::Context) -> usize {
146            4
147        }
148    }
149
150    impl fidl::encoding::ValueTypeMarker for Flag {
151        type Borrowed<'a> = Self;
152        #[inline(always)]
153        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
154            *value
155        }
156    }
157
158    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Flag {
159        #[inline]
160        unsafe fn encode(
161            self,
162            encoder: &mut fidl::encoding::Encoder<'_, D>,
163            offset: usize,
164            _depth: fidl::encoding::Depth,
165        ) -> fidl::Result<()> {
166            encoder.debug_check_bounds::<Self>(offset);
167            if self.bits() & Self::all().bits() != self.bits() {
168                return Err(fidl::Error::InvalidBitsValue);
169            }
170            encoder.write_num(self.bits(), offset);
171            Ok(())
172        }
173    }
174
175    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Flag {
176        #[inline(always)]
177        fn new_empty() -> Self {
178            Self::empty()
179        }
180
181        #[inline]
182        unsafe fn decode(
183            &mut self,
184            decoder: &mut fidl::encoding::Decoder<'_, D>,
185            offset: usize,
186            _depth: fidl::encoding::Depth,
187        ) -> fidl::Result<()> {
188            decoder.debug_check_bounds::<Self>(offset);
189            let prim = decoder.read_num::<u32>(offset);
190            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
191            Ok(())
192        }
193    }
194
195    impl fidl::encoding::ValueTypeMarker for BlockInfo {
196        type Borrowed<'a> = &'a Self;
197        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
198            value
199        }
200    }
201
202    unsafe impl fidl::encoding::TypeMarker for BlockInfo {
203        type Owned = Self;
204
205        #[inline(always)]
206        fn inline_align(_context: fidl::encoding::Context) -> usize {
207            8
208        }
209
210        #[inline(always)]
211        fn inline_size(_context: fidl::encoding::Context) -> usize {
212            24
213        }
214    }
215
216    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockInfo, D>
217        for &BlockInfo
218    {
219        #[inline]
220        unsafe fn encode(
221            self,
222            encoder: &mut fidl::encoding::Encoder<'_, D>,
223            offset: usize,
224            _depth: fidl::encoding::Depth,
225        ) -> fidl::Result<()> {
226            encoder.debug_check_bounds::<BlockInfo>(offset);
227            // Delegate to tuple encoding.
228            fidl::encoding::Encode::<BlockInfo, D>::encode(
229                (
230                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_count),
231                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_size),
232                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_transfer_size),
233                    <Flag as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
234                ),
235                encoder,
236                offset,
237                _depth,
238            )
239        }
240    }
241    unsafe impl<
242        D: fidl::encoding::ResourceDialect,
243        T0: fidl::encoding::Encode<u64, D>,
244        T1: fidl::encoding::Encode<u32, D>,
245        T2: fidl::encoding::Encode<u32, D>,
246        T3: fidl::encoding::Encode<Flag, D>,
247    > fidl::encoding::Encode<BlockInfo, D> for (T0, T1, T2, T3)
248    {
249        #[inline]
250        unsafe fn encode(
251            self,
252            encoder: &mut fidl::encoding::Encoder<'_, D>,
253            offset: usize,
254            depth: fidl::encoding::Depth,
255        ) -> fidl::Result<()> {
256            encoder.debug_check_bounds::<BlockInfo>(offset);
257            // Zero out padding regions. There's no need to apply masks
258            // because the unmasked parts will be overwritten by fields.
259            unsafe {
260                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
261                (ptr as *mut u64).write_unaligned(0);
262            }
263            // Write the fields.
264            self.0.encode(encoder, offset + 0, depth)?;
265            self.1.encode(encoder, offset + 8, depth)?;
266            self.2.encode(encoder, offset + 12, depth)?;
267            self.3.encode(encoder, offset + 16, depth)?;
268            Ok(())
269        }
270    }
271
272    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockInfo {
273        #[inline(always)]
274        fn new_empty() -> Self {
275            Self {
276                block_count: fidl::new_empty!(u64, D),
277                block_size: fidl::new_empty!(u32, D),
278                max_transfer_size: fidl::new_empty!(u32, D),
279                flags: fidl::new_empty!(Flag, D),
280            }
281        }
282
283        #[inline]
284        unsafe fn decode(
285            &mut self,
286            decoder: &mut fidl::encoding::Decoder<'_, D>,
287            offset: usize,
288            _depth: fidl::encoding::Depth,
289        ) -> fidl::Result<()> {
290            decoder.debug_check_bounds::<Self>(offset);
291            // Verify that padding bytes are zero.
292            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
293            let padval = unsafe { (ptr as *const u64).read_unaligned() };
294            let mask = 0xffffffff00000000u64;
295            let maskedval = padval & mask;
296            if maskedval != 0 {
297                return Err(fidl::Error::NonZeroPadding {
298                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
299                });
300            }
301            fidl::decode!(u64, D, &mut self.block_count, decoder, offset + 0, _depth)?;
302            fidl::decode!(u32, D, &mut self.block_size, decoder, offset + 8, _depth)?;
303            fidl::decode!(u32, D, &mut self.max_transfer_size, decoder, offset + 12, _depth)?;
304            fidl::decode!(Flag, D, &mut self.flags, decoder, offset + 16, _depth)?;
305            Ok(())
306        }
307    }
308
309    impl fidl::encoding::ValueTypeMarker for BlockOffsetMapping {
310        type Borrowed<'a> = &'a Self;
311        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
312            value
313        }
314    }
315
316    unsafe impl fidl::encoding::TypeMarker for BlockOffsetMapping {
317        type Owned = Self;
318
319        #[inline(always)]
320        fn inline_align(_context: fidl::encoding::Context) -> usize {
321            8
322        }
323
324        #[inline(always)]
325        fn inline_size(_context: fidl::encoding::Context) -> usize {
326            24
327        }
328        #[inline(always)]
329        fn encode_is_copy() -> bool {
330            true
331        }
332
333        #[inline(always)]
334        fn decode_is_copy() -> bool {
335            true
336        }
337    }
338
339    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockOffsetMapping, D>
340        for &BlockOffsetMapping
341    {
342        #[inline]
343        unsafe fn encode(
344            self,
345            encoder: &mut fidl::encoding::Encoder<'_, D>,
346            offset: usize,
347            _depth: fidl::encoding::Depth,
348        ) -> fidl::Result<()> {
349            encoder.debug_check_bounds::<BlockOffsetMapping>(offset);
350            unsafe {
351                // Copy the object into the buffer.
352                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
353                (buf_ptr as *mut BlockOffsetMapping)
354                    .write_unaligned((self as *const BlockOffsetMapping).read());
355                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
356                // done second because the memcpy will write garbage to these bytes.
357            }
358            Ok(())
359        }
360    }
361    unsafe impl<
362        D: fidl::encoding::ResourceDialect,
363        T0: fidl::encoding::Encode<u64, D>,
364        T1: fidl::encoding::Encode<u64, D>,
365        T2: fidl::encoding::Encode<u64, D>,
366    > fidl::encoding::Encode<BlockOffsetMapping, D> for (T0, T1, T2)
367    {
368        #[inline]
369        unsafe fn encode(
370            self,
371            encoder: &mut fidl::encoding::Encoder<'_, D>,
372            offset: usize,
373            depth: fidl::encoding::Depth,
374        ) -> fidl::Result<()> {
375            encoder.debug_check_bounds::<BlockOffsetMapping>(offset);
376            // Zero out padding regions. There's no need to apply masks
377            // because the unmasked parts will be overwritten by fields.
378            // Write the fields.
379            self.0.encode(encoder, offset + 0, depth)?;
380            self.1.encode(encoder, offset + 8, depth)?;
381            self.2.encode(encoder, offset + 16, depth)?;
382            Ok(())
383        }
384    }
385
386    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockOffsetMapping {
387        #[inline(always)]
388        fn new_empty() -> Self {
389            Self {
390                source_block_offset: fidl::new_empty!(u64, D),
391                target_block_offset: fidl::new_empty!(u64, D),
392                length: fidl::new_empty!(u64, D),
393            }
394        }
395
396        #[inline]
397        unsafe fn decode(
398            &mut self,
399            decoder: &mut fidl::encoding::Decoder<'_, D>,
400            offset: usize,
401            _depth: fidl::encoding::Depth,
402        ) -> fidl::Result<()> {
403            decoder.debug_check_bounds::<Self>(offset);
404            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
405            // Verify that padding bytes are zero.
406            // Copy from the buffer into the object.
407            unsafe {
408                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
409            }
410            Ok(())
411        }
412    }
413
414    impl fidl::encoding::ValueTypeMarker for BlockGetInfoResponse {
415        type Borrowed<'a> = &'a Self;
416        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
417            value
418        }
419    }
420
421    unsafe impl fidl::encoding::TypeMarker for BlockGetInfoResponse {
422        type Owned = Self;
423
424        #[inline(always)]
425        fn inline_align(_context: fidl::encoding::Context) -> usize {
426            8
427        }
428
429        #[inline(always)]
430        fn inline_size(_context: fidl::encoding::Context) -> usize {
431            24
432        }
433    }
434
435    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockGetInfoResponse, D>
436        for &BlockGetInfoResponse
437    {
438        #[inline]
439        unsafe fn encode(
440            self,
441            encoder: &mut fidl::encoding::Encoder<'_, D>,
442            offset: usize,
443            _depth: fidl::encoding::Depth,
444        ) -> fidl::Result<()> {
445            encoder.debug_check_bounds::<BlockGetInfoResponse>(offset);
446            // Delegate to tuple encoding.
447            fidl::encoding::Encode::<BlockGetInfoResponse, D>::encode(
448                (<BlockInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
449                encoder,
450                offset,
451                _depth,
452            )
453        }
454    }
455    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BlockInfo, D>>
456        fidl::encoding::Encode<BlockGetInfoResponse, D> for (T0,)
457    {
458        #[inline]
459        unsafe fn encode(
460            self,
461            encoder: &mut fidl::encoding::Encoder<'_, D>,
462            offset: usize,
463            depth: fidl::encoding::Depth,
464        ) -> fidl::Result<()> {
465            encoder.debug_check_bounds::<BlockGetInfoResponse>(offset);
466            // Zero out padding regions. There's no need to apply masks
467            // because the unmasked parts will be overwritten by fields.
468            // Write the fields.
469            self.0.encode(encoder, offset + 0, depth)?;
470            Ok(())
471        }
472    }
473
474    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockGetInfoResponse {
475        #[inline(always)]
476        fn new_empty() -> Self {
477            Self { info: fidl::new_empty!(BlockInfo, D) }
478        }
479
480        #[inline]
481        unsafe fn decode(
482            &mut self,
483            decoder: &mut fidl::encoding::Decoder<'_, D>,
484            offset: usize,
485            _depth: fidl::encoding::Depth,
486        ) -> fidl::Result<()> {
487            decoder.debug_check_bounds::<Self>(offset);
488            // Verify that padding bytes are zero.
489            fidl::decode!(BlockInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
490            Ok(())
491        }
492    }
493
494    impl fidl::encoding::ValueTypeMarker for FtlFormatResponse {
495        type Borrowed<'a> = &'a Self;
496        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
497            value
498        }
499    }
500
501    unsafe impl fidl::encoding::TypeMarker for FtlFormatResponse {
502        type Owned = Self;
503
504        #[inline(always)]
505        fn inline_align(_context: fidl::encoding::Context) -> usize {
506            4
507        }
508
509        #[inline(always)]
510        fn inline_size(_context: fidl::encoding::Context) -> usize {
511            4
512        }
513        #[inline(always)]
514        fn encode_is_copy() -> bool {
515            true
516        }
517
518        #[inline(always)]
519        fn decode_is_copy() -> bool {
520            true
521        }
522    }
523
524    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FtlFormatResponse, D>
525        for &FtlFormatResponse
526    {
527        #[inline]
528        unsafe fn encode(
529            self,
530            encoder: &mut fidl::encoding::Encoder<'_, D>,
531            offset: usize,
532            _depth: fidl::encoding::Depth,
533        ) -> fidl::Result<()> {
534            encoder.debug_check_bounds::<FtlFormatResponse>(offset);
535            unsafe {
536                // Copy the object into the buffer.
537                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
538                (buf_ptr as *mut FtlFormatResponse)
539                    .write_unaligned((self as *const FtlFormatResponse).read());
540                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
541                // done second because the memcpy will write garbage to these bytes.
542            }
543            Ok(())
544        }
545    }
546    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
547        fidl::encoding::Encode<FtlFormatResponse, D> for (T0,)
548    {
549        #[inline]
550        unsafe fn encode(
551            self,
552            encoder: &mut fidl::encoding::Encoder<'_, D>,
553            offset: usize,
554            depth: fidl::encoding::Depth,
555        ) -> fidl::Result<()> {
556            encoder.debug_check_bounds::<FtlFormatResponse>(offset);
557            // Zero out padding regions. There's no need to apply masks
558            // because the unmasked parts will be overwritten by fields.
559            // Write the fields.
560            self.0.encode(encoder, offset + 0, depth)?;
561            Ok(())
562        }
563    }
564
565    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FtlFormatResponse {
566        #[inline(always)]
567        fn new_empty() -> Self {
568            Self { status: fidl::new_empty!(i32, D) }
569        }
570
571        #[inline]
572        unsafe fn decode(
573            &mut self,
574            decoder: &mut fidl::encoding::Decoder<'_, D>,
575            offset: usize,
576            _depth: fidl::encoding::Depth,
577        ) -> fidl::Result<()> {
578            decoder.debug_check_bounds::<Self>(offset);
579            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
580            // Verify that padding bytes are zero.
581            // Copy from the buffer into the object.
582            unsafe {
583                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
584            }
585            Ok(())
586        }
587    }
588
589    impl fidl::encoding::ValueTypeMarker for SessionAttachVmoResponse {
590        type Borrowed<'a> = &'a Self;
591        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
592            value
593        }
594    }
595
596    unsafe impl fidl::encoding::TypeMarker for SessionAttachVmoResponse {
597        type Owned = Self;
598
599        #[inline(always)]
600        fn inline_align(_context: fidl::encoding::Context) -> usize {
601            2
602        }
603
604        #[inline(always)]
605        fn inline_size(_context: fidl::encoding::Context) -> usize {
606            2
607        }
608        #[inline(always)]
609        fn encode_is_copy() -> bool {
610            true
611        }
612
613        #[inline(always)]
614        fn decode_is_copy() -> bool {
615            true
616        }
617    }
618
619    unsafe impl<D: fidl::encoding::ResourceDialect>
620        fidl::encoding::Encode<SessionAttachVmoResponse, D> for &SessionAttachVmoResponse
621    {
622        #[inline]
623        unsafe fn encode(
624            self,
625            encoder: &mut fidl::encoding::Encoder<'_, D>,
626            offset: usize,
627            _depth: fidl::encoding::Depth,
628        ) -> fidl::Result<()> {
629            encoder.debug_check_bounds::<SessionAttachVmoResponse>(offset);
630            unsafe {
631                // Copy the object into the buffer.
632                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
633                (buf_ptr as *mut SessionAttachVmoResponse)
634                    .write_unaligned((self as *const SessionAttachVmoResponse).read());
635                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
636                // done second because the memcpy will write garbage to these bytes.
637            }
638            Ok(())
639        }
640    }
641    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<VmoId, D>>
642        fidl::encoding::Encode<SessionAttachVmoResponse, D> for (T0,)
643    {
644        #[inline]
645        unsafe fn encode(
646            self,
647            encoder: &mut fidl::encoding::Encoder<'_, D>,
648            offset: usize,
649            depth: fidl::encoding::Depth,
650        ) -> fidl::Result<()> {
651            encoder.debug_check_bounds::<SessionAttachVmoResponse>(offset);
652            // Zero out padding regions. There's no need to apply masks
653            // because the unmasked parts will be overwritten by fields.
654            // Write the fields.
655            self.0.encode(encoder, offset + 0, depth)?;
656            Ok(())
657        }
658    }
659
660    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
661        for SessionAttachVmoResponse
662    {
663        #[inline(always)]
664        fn new_empty() -> Self {
665            Self { vmoid: fidl::new_empty!(VmoId, D) }
666        }
667
668        #[inline]
669        unsafe fn decode(
670            &mut self,
671            decoder: &mut fidl::encoding::Decoder<'_, D>,
672            offset: usize,
673            _depth: fidl::encoding::Depth,
674        ) -> fidl::Result<()> {
675            decoder.debug_check_bounds::<Self>(offset);
676            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
677            // Verify that padding bytes are zero.
678            // Copy from the buffer into the object.
679            unsafe {
680                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
681            }
682            Ok(())
683        }
684    }
685
686    impl fidl::encoding::ValueTypeMarker for VmoId {
687        type Borrowed<'a> = &'a Self;
688        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
689            value
690        }
691    }
692
693    unsafe impl fidl::encoding::TypeMarker for VmoId {
694        type Owned = Self;
695
696        #[inline(always)]
697        fn inline_align(_context: fidl::encoding::Context) -> usize {
698            2
699        }
700
701        #[inline(always)]
702        fn inline_size(_context: fidl::encoding::Context) -> usize {
703            2
704        }
705        #[inline(always)]
706        fn encode_is_copy() -> bool {
707            true
708        }
709
710        #[inline(always)]
711        fn decode_is_copy() -> bool {
712            true
713        }
714    }
715
716    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VmoId, D> for &VmoId {
717        #[inline]
718        unsafe fn encode(
719            self,
720            encoder: &mut fidl::encoding::Encoder<'_, D>,
721            offset: usize,
722            _depth: fidl::encoding::Depth,
723        ) -> fidl::Result<()> {
724            encoder.debug_check_bounds::<VmoId>(offset);
725            unsafe {
726                // Copy the object into the buffer.
727                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
728                (buf_ptr as *mut VmoId).write_unaligned((self as *const VmoId).read());
729                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
730                // done second because the memcpy will write garbage to these bytes.
731            }
732            Ok(())
733        }
734    }
735    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u16, D>>
736        fidl::encoding::Encode<VmoId, 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::<VmoId>(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> for VmoId {
755        #[inline(always)]
756        fn new_empty() -> Self {
757            Self { id: fidl::new_empty!(u16, D) }
758        }
759
760        #[inline]
761        unsafe fn decode(
762            &mut self,
763            decoder: &mut fidl::encoding::Decoder<'_, D>,
764            offset: usize,
765            _depth: fidl::encoding::Depth,
766        ) -> fidl::Result<()> {
767            decoder.debug_check_bounds::<Self>(offset);
768            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
769            // Verify that padding bytes are zero.
770            // Copy from the buffer into the object.
771            unsafe {
772                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
773            }
774            Ok(())
775        }
776    }
777}