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