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