Skip to main content

fidl_fuchsia_hardware_sharedmemory_common/
fidl_fuchsia_hardware_sharedmemory_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
11bitflags! {
12    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13    pub struct SharedVmoRight: u32 {
14        /// The protocol implementation can read from this VMO (used for transmit requests).
15        const READ = 1;
16        /// The protocol implementation can write to this VMO (used for receive requests).
17        const WRITE = 2;
18    }
19}
20
21impl SharedVmoRight {
22    #[inline(always)]
23    pub fn from_bits_allow_unknown(bits: u32) -> Self {
24        Self::from_bits_retain(bits)
25    }
26
27    #[inline(always)]
28    pub fn has_unknown_bits(&self) -> bool {
29        self.get_unknown_bits() != 0
30    }
31
32    #[inline(always)]
33    pub fn get_unknown_bits(&self) -> u32 {
34        self.bits() & !Self::all().bits()
35    }
36}
37
38#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
39#[repr(C)]
40pub struct SharedVmoBuffer {
41    pub vmo_id: u32,
42    pub offset: u64,
43    pub size: u64,
44}
45
46impl fidl::Persistable for SharedVmoBuffer {}
47
48#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49#[repr(C)]
50pub struct SharedVmoIoExchangeRequest {
51    pub tx_buffer: SharedVmoBuffer,
52    pub rx_buffer: SharedVmoBuffer,
53}
54
55impl fidl::Persistable for SharedVmoIoExchangeRequest {}
56
57#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58#[repr(C)]
59pub struct SharedVmoIoReceiveRequest {
60    pub buffer: SharedVmoBuffer,
61}
62
63impl fidl::Persistable for SharedVmoIoReceiveRequest {}
64
65#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66#[repr(C)]
67pub struct SharedVmoIoTransmitRequest {
68    pub buffer: SharedVmoBuffer,
69}
70
71impl fidl::Persistable for SharedVmoIoTransmitRequest {}
72
73#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74#[repr(C)]
75pub struct SharedVmoRegisterUnregisterVmoRequest {
76    pub vmo_id: u32,
77}
78
79impl fidl::Persistable for SharedVmoRegisterUnregisterVmoRequest {}
80
81pub mod shared_vmo_io_ordinals {
82    pub const TRANSMIT: u64 = 0x791970e4c961b0bf;
83    pub const RECEIVE: u64 = 0x1c31986cc443db59;
84    pub const EXCHANGE: u64 = 0x6ddad3b45d5deccc;
85}
86
87pub mod shared_vmo_register_ordinals {
88    pub const REGISTER_VMO: u64 = 0x31df51e1e6ea4a15;
89    pub const UNREGISTER_VMO: u64 = 0x1194e9b693827109;
90}
91
92mod internal {
93    use super::*;
94    unsafe impl fidl::encoding::TypeMarker for SharedVmoRight {
95        type Owned = Self;
96
97        #[inline(always)]
98        fn inline_align(_context: fidl::encoding::Context) -> usize {
99            4
100        }
101
102        #[inline(always)]
103        fn inline_size(_context: fidl::encoding::Context) -> usize {
104            4
105        }
106    }
107
108    impl fidl::encoding::ValueTypeMarker for SharedVmoRight {
109        type Borrowed<'a> = Self;
110        #[inline(always)]
111        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
112            *value
113        }
114    }
115
116    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SharedVmoRight {
117        #[inline]
118        unsafe fn encode(
119            self,
120            encoder: &mut fidl::encoding::Encoder<'_, D>,
121            offset: usize,
122            _depth: fidl::encoding::Depth,
123        ) -> fidl::Result<()> {
124            encoder.debug_check_bounds::<Self>(offset);
125            encoder.write_num(self.bits(), offset);
126            Ok(())
127        }
128    }
129
130    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SharedVmoRight {
131        #[inline(always)]
132        fn new_empty() -> Self {
133            Self::empty()
134        }
135
136        #[inline]
137        unsafe fn decode(
138            &mut self,
139            decoder: &mut fidl::encoding::Decoder<'_, D>,
140            offset: usize,
141            _depth: fidl::encoding::Depth,
142        ) -> fidl::Result<()> {
143            decoder.debug_check_bounds::<Self>(offset);
144            let prim = decoder.read_num::<u32>(offset);
145            *self = Self::from_bits_allow_unknown(prim);
146            Ok(())
147        }
148    }
149
150    impl fidl::encoding::ValueTypeMarker for SharedVmoBuffer {
151        type Borrowed<'a> = &'a Self;
152        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
153            value
154        }
155    }
156
157    unsafe impl fidl::encoding::TypeMarker for SharedVmoBuffer {
158        type Owned = Self;
159
160        #[inline(always)]
161        fn inline_align(_context: fidl::encoding::Context) -> usize {
162            8
163        }
164
165        #[inline(always)]
166        fn inline_size(_context: fidl::encoding::Context) -> usize {
167            24
168        }
169    }
170
171    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SharedVmoBuffer, D>
172        for &SharedVmoBuffer
173    {
174        #[inline]
175        unsafe fn encode(
176            self,
177            encoder: &mut fidl::encoding::Encoder<'_, D>,
178            offset: usize,
179            _depth: fidl::encoding::Depth,
180        ) -> fidl::Result<()> {
181            encoder.debug_check_bounds::<SharedVmoBuffer>(offset);
182            unsafe {
183                // Copy the object into the buffer.
184                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
185                (buf_ptr as *mut SharedVmoBuffer)
186                    .write_unaligned((self as *const SharedVmoBuffer).read());
187                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
188                // done second because the memcpy will write garbage to these bytes.
189                let padding_ptr = buf_ptr.offset(0) as *mut u64;
190                let padding_mask = 0xffffffff00000000u64;
191                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
192            }
193            Ok(())
194        }
195    }
196    unsafe impl<
197        D: fidl::encoding::ResourceDialect,
198        T0: fidl::encoding::Encode<u32, D>,
199        T1: fidl::encoding::Encode<u64, D>,
200        T2: fidl::encoding::Encode<u64, D>,
201    > fidl::encoding::Encode<SharedVmoBuffer, D> for (T0, T1, T2)
202    {
203        #[inline]
204        unsafe fn encode(
205            self,
206            encoder: &mut fidl::encoding::Encoder<'_, D>,
207            offset: usize,
208            depth: fidl::encoding::Depth,
209        ) -> fidl::Result<()> {
210            encoder.debug_check_bounds::<SharedVmoBuffer>(offset);
211            // Zero out padding regions. There's no need to apply masks
212            // because the unmasked parts will be overwritten by fields.
213            unsafe {
214                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
215                (ptr as *mut u64).write_unaligned(0);
216            }
217            // Write the fields.
218            self.0.encode(encoder, offset + 0, depth)?;
219            self.1.encode(encoder, offset + 8, depth)?;
220            self.2.encode(encoder, offset + 16, depth)?;
221            Ok(())
222        }
223    }
224
225    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SharedVmoBuffer {
226        #[inline(always)]
227        fn new_empty() -> Self {
228            Self {
229                vmo_id: fidl::new_empty!(u32, D),
230                offset: fidl::new_empty!(u64, D),
231                size: fidl::new_empty!(u64, D),
232            }
233        }
234
235        #[inline]
236        unsafe fn decode(
237            &mut self,
238            decoder: &mut fidl::encoding::Decoder<'_, D>,
239            offset: usize,
240            _depth: fidl::encoding::Depth,
241        ) -> fidl::Result<()> {
242            decoder.debug_check_bounds::<Self>(offset);
243            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
244            // Verify that padding bytes are zero.
245            let ptr = unsafe { buf_ptr.offset(0) };
246            let padval = unsafe { (ptr as *const u64).read_unaligned() };
247            let mask = 0xffffffff00000000u64;
248            let maskedval = padval & mask;
249            if maskedval != 0 {
250                return Err(fidl::Error::NonZeroPadding {
251                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
252                });
253            }
254            // Copy from the buffer into the object.
255            unsafe {
256                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
257            }
258            Ok(())
259        }
260    }
261
262    impl fidl::encoding::ValueTypeMarker for SharedVmoIoExchangeRequest {
263        type Borrowed<'a> = &'a Self;
264        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
265            value
266        }
267    }
268
269    unsafe impl fidl::encoding::TypeMarker for SharedVmoIoExchangeRequest {
270        type Owned = Self;
271
272        #[inline(always)]
273        fn inline_align(_context: fidl::encoding::Context) -> usize {
274            8
275        }
276
277        #[inline(always)]
278        fn inline_size(_context: fidl::encoding::Context) -> usize {
279            48
280        }
281    }
282
283    unsafe impl<D: fidl::encoding::ResourceDialect>
284        fidl::encoding::Encode<SharedVmoIoExchangeRequest, D> for &SharedVmoIoExchangeRequest
285    {
286        #[inline]
287        unsafe fn encode(
288            self,
289            encoder: &mut fidl::encoding::Encoder<'_, D>,
290            offset: usize,
291            _depth: fidl::encoding::Depth,
292        ) -> fidl::Result<()> {
293            encoder.debug_check_bounds::<SharedVmoIoExchangeRequest>(offset);
294            unsafe {
295                // Copy the object into the buffer.
296                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
297                (buf_ptr as *mut SharedVmoIoExchangeRequest)
298                    .write_unaligned((self as *const SharedVmoIoExchangeRequest).read());
299                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
300                // done second because the memcpy will write garbage to these bytes.
301                let padding_ptr = buf_ptr.offset(0) as *mut u64;
302                let padding_mask = 0xffffffff00000000u64;
303                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
304                let padding_ptr = buf_ptr.offset(24) as *mut u64;
305                let padding_mask = 0xffffffff00000000u64;
306                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
307            }
308            Ok(())
309        }
310    }
311    unsafe impl<
312        D: fidl::encoding::ResourceDialect,
313        T0: fidl::encoding::Encode<SharedVmoBuffer, D>,
314        T1: fidl::encoding::Encode<SharedVmoBuffer, D>,
315    > fidl::encoding::Encode<SharedVmoIoExchangeRequest, D> for (T0, T1)
316    {
317        #[inline]
318        unsafe fn encode(
319            self,
320            encoder: &mut fidl::encoding::Encoder<'_, D>,
321            offset: usize,
322            depth: fidl::encoding::Depth,
323        ) -> fidl::Result<()> {
324            encoder.debug_check_bounds::<SharedVmoIoExchangeRequest>(offset);
325            // Zero out padding regions. There's no need to apply masks
326            // because the unmasked parts will be overwritten by fields.
327            // Write the fields.
328            self.0.encode(encoder, offset + 0, depth)?;
329            self.1.encode(encoder, offset + 24, depth)?;
330            Ok(())
331        }
332    }
333
334    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
335        for SharedVmoIoExchangeRequest
336    {
337        #[inline(always)]
338        fn new_empty() -> Self {
339            Self {
340                tx_buffer: fidl::new_empty!(SharedVmoBuffer, D),
341                rx_buffer: fidl::new_empty!(SharedVmoBuffer, D),
342            }
343        }
344
345        #[inline]
346        unsafe fn decode(
347            &mut self,
348            decoder: &mut fidl::encoding::Decoder<'_, D>,
349            offset: usize,
350            _depth: fidl::encoding::Depth,
351        ) -> fidl::Result<()> {
352            decoder.debug_check_bounds::<Self>(offset);
353            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
354            // Verify that padding bytes are zero.
355            let ptr = unsafe { buf_ptr.offset(0) };
356            let padval = unsafe { (ptr as *const u64).read_unaligned() };
357            let mask = 0xffffffff00000000u64;
358            let maskedval = padval & mask;
359            if maskedval != 0 {
360                return Err(fidl::Error::NonZeroPadding {
361                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
362                });
363            }
364            let ptr = unsafe { buf_ptr.offset(24) };
365            let padval = unsafe { (ptr as *const u64).read_unaligned() };
366            let mask = 0xffffffff00000000u64;
367            let maskedval = padval & mask;
368            if maskedval != 0 {
369                return Err(fidl::Error::NonZeroPadding {
370                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
371                });
372            }
373            // Copy from the buffer into the object.
374            unsafe {
375                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 48);
376            }
377            Ok(())
378        }
379    }
380
381    impl fidl::encoding::ValueTypeMarker for SharedVmoIoReceiveRequest {
382        type Borrowed<'a> = &'a Self;
383        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
384            value
385        }
386    }
387
388    unsafe impl fidl::encoding::TypeMarker for SharedVmoIoReceiveRequest {
389        type Owned = Self;
390
391        #[inline(always)]
392        fn inline_align(_context: fidl::encoding::Context) -> usize {
393            8
394        }
395
396        #[inline(always)]
397        fn inline_size(_context: fidl::encoding::Context) -> usize {
398            24
399        }
400    }
401
402    unsafe impl<D: fidl::encoding::ResourceDialect>
403        fidl::encoding::Encode<SharedVmoIoReceiveRequest, D> for &SharedVmoIoReceiveRequest
404    {
405        #[inline]
406        unsafe fn encode(
407            self,
408            encoder: &mut fidl::encoding::Encoder<'_, D>,
409            offset: usize,
410            _depth: fidl::encoding::Depth,
411        ) -> fidl::Result<()> {
412            encoder.debug_check_bounds::<SharedVmoIoReceiveRequest>(offset);
413            unsafe {
414                // Copy the object into the buffer.
415                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
416                (buf_ptr as *mut SharedVmoIoReceiveRequest)
417                    .write_unaligned((self as *const SharedVmoIoReceiveRequest).read());
418                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
419                // done second because the memcpy will write garbage to these bytes.
420                let padding_ptr = buf_ptr.offset(0) as *mut u64;
421                let padding_mask = 0xffffffff00000000u64;
422                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
423            }
424            Ok(())
425        }
426    }
427    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<SharedVmoBuffer, D>>
428        fidl::encoding::Encode<SharedVmoIoReceiveRequest, D> for (T0,)
429    {
430        #[inline]
431        unsafe fn encode(
432            self,
433            encoder: &mut fidl::encoding::Encoder<'_, D>,
434            offset: usize,
435            depth: fidl::encoding::Depth,
436        ) -> fidl::Result<()> {
437            encoder.debug_check_bounds::<SharedVmoIoReceiveRequest>(offset);
438            // Zero out padding regions. There's no need to apply masks
439            // because the unmasked parts will be overwritten by fields.
440            // Write the fields.
441            self.0.encode(encoder, offset + 0, depth)?;
442            Ok(())
443        }
444    }
445
446    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
447        for SharedVmoIoReceiveRequest
448    {
449        #[inline(always)]
450        fn new_empty() -> Self {
451            Self { buffer: fidl::new_empty!(SharedVmoBuffer, D) }
452        }
453
454        #[inline]
455        unsafe fn decode(
456            &mut self,
457            decoder: &mut fidl::encoding::Decoder<'_, D>,
458            offset: usize,
459            _depth: fidl::encoding::Depth,
460        ) -> fidl::Result<()> {
461            decoder.debug_check_bounds::<Self>(offset);
462            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
463            // Verify that padding bytes are zero.
464            let ptr = unsafe { buf_ptr.offset(0) };
465            let padval = unsafe { (ptr as *const u64).read_unaligned() };
466            let mask = 0xffffffff00000000u64;
467            let maskedval = padval & mask;
468            if maskedval != 0 {
469                return Err(fidl::Error::NonZeroPadding {
470                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
471                });
472            }
473            // Copy from the buffer into the object.
474            unsafe {
475                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
476            }
477            Ok(())
478        }
479    }
480
481    impl fidl::encoding::ValueTypeMarker for SharedVmoIoTransmitRequest {
482        type Borrowed<'a> = &'a Self;
483        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
484            value
485        }
486    }
487
488    unsafe impl fidl::encoding::TypeMarker for SharedVmoIoTransmitRequest {
489        type Owned = Self;
490
491        #[inline(always)]
492        fn inline_align(_context: fidl::encoding::Context) -> usize {
493            8
494        }
495
496        #[inline(always)]
497        fn inline_size(_context: fidl::encoding::Context) -> usize {
498            24
499        }
500    }
501
502    unsafe impl<D: fidl::encoding::ResourceDialect>
503        fidl::encoding::Encode<SharedVmoIoTransmitRequest, D> for &SharedVmoIoTransmitRequest
504    {
505        #[inline]
506        unsafe fn encode(
507            self,
508            encoder: &mut fidl::encoding::Encoder<'_, D>,
509            offset: usize,
510            _depth: fidl::encoding::Depth,
511        ) -> fidl::Result<()> {
512            encoder.debug_check_bounds::<SharedVmoIoTransmitRequest>(offset);
513            unsafe {
514                // Copy the object into the buffer.
515                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
516                (buf_ptr as *mut SharedVmoIoTransmitRequest)
517                    .write_unaligned((self as *const SharedVmoIoTransmitRequest).read());
518                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
519                // done second because the memcpy will write garbage to these bytes.
520                let padding_ptr = buf_ptr.offset(0) as *mut u64;
521                let padding_mask = 0xffffffff00000000u64;
522                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
523            }
524            Ok(())
525        }
526    }
527    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<SharedVmoBuffer, D>>
528        fidl::encoding::Encode<SharedVmoIoTransmitRequest, D> for (T0,)
529    {
530        #[inline]
531        unsafe fn encode(
532            self,
533            encoder: &mut fidl::encoding::Encoder<'_, D>,
534            offset: usize,
535            depth: fidl::encoding::Depth,
536        ) -> fidl::Result<()> {
537            encoder.debug_check_bounds::<SharedVmoIoTransmitRequest>(offset);
538            // Zero out padding regions. There's no need to apply masks
539            // because the unmasked parts will be overwritten by fields.
540            // Write the fields.
541            self.0.encode(encoder, offset + 0, depth)?;
542            Ok(())
543        }
544    }
545
546    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
547        for SharedVmoIoTransmitRequest
548    {
549        #[inline(always)]
550        fn new_empty() -> Self {
551            Self { buffer: fidl::new_empty!(SharedVmoBuffer, D) }
552        }
553
554        #[inline]
555        unsafe fn decode(
556            &mut self,
557            decoder: &mut fidl::encoding::Decoder<'_, D>,
558            offset: usize,
559            _depth: fidl::encoding::Depth,
560        ) -> fidl::Result<()> {
561            decoder.debug_check_bounds::<Self>(offset);
562            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
563            // Verify that padding bytes are zero.
564            let ptr = unsafe { buf_ptr.offset(0) };
565            let padval = unsafe { (ptr as *const u64).read_unaligned() };
566            let mask = 0xffffffff00000000u64;
567            let maskedval = padval & mask;
568            if maskedval != 0 {
569                return Err(fidl::Error::NonZeroPadding {
570                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
571                });
572            }
573            // Copy from the buffer into the object.
574            unsafe {
575                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
576            }
577            Ok(())
578        }
579    }
580
581    impl fidl::encoding::ValueTypeMarker for SharedVmoRegisterUnregisterVmoRequest {
582        type Borrowed<'a> = &'a Self;
583        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
584            value
585        }
586    }
587
588    unsafe impl fidl::encoding::TypeMarker for SharedVmoRegisterUnregisterVmoRequest {
589        type Owned = Self;
590
591        #[inline(always)]
592        fn inline_align(_context: fidl::encoding::Context) -> usize {
593            4
594        }
595
596        #[inline(always)]
597        fn inline_size(_context: fidl::encoding::Context) -> usize {
598            4
599        }
600        #[inline(always)]
601        fn encode_is_copy() -> bool {
602            true
603        }
604
605        #[inline(always)]
606        fn decode_is_copy() -> bool {
607            true
608        }
609    }
610
611    unsafe impl<D: fidl::encoding::ResourceDialect>
612        fidl::encoding::Encode<SharedVmoRegisterUnregisterVmoRequest, D>
613        for &SharedVmoRegisterUnregisterVmoRequest
614    {
615        #[inline]
616        unsafe fn encode(
617            self,
618            encoder: &mut fidl::encoding::Encoder<'_, D>,
619            offset: usize,
620            _depth: fidl::encoding::Depth,
621        ) -> fidl::Result<()> {
622            encoder.debug_check_bounds::<SharedVmoRegisterUnregisterVmoRequest>(offset);
623            unsafe {
624                // Copy the object into the buffer.
625                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
626                (buf_ptr as *mut SharedVmoRegisterUnregisterVmoRequest)
627                    .write_unaligned((self as *const SharedVmoRegisterUnregisterVmoRequest).read());
628                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
629                // done second because the memcpy will write garbage to these bytes.
630            }
631            Ok(())
632        }
633    }
634    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
635        fidl::encoding::Encode<SharedVmoRegisterUnregisterVmoRequest, D> for (T0,)
636    {
637        #[inline]
638        unsafe fn encode(
639            self,
640            encoder: &mut fidl::encoding::Encoder<'_, D>,
641            offset: usize,
642            depth: fidl::encoding::Depth,
643        ) -> fidl::Result<()> {
644            encoder.debug_check_bounds::<SharedVmoRegisterUnregisterVmoRequest>(offset);
645            // Zero out padding regions. There's no need to apply masks
646            // because the unmasked parts will be overwritten by fields.
647            // Write the fields.
648            self.0.encode(encoder, offset + 0, depth)?;
649            Ok(())
650        }
651    }
652
653    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
654        for SharedVmoRegisterUnregisterVmoRequest
655    {
656        #[inline(always)]
657        fn new_empty() -> Self {
658            Self { vmo_id: fidl::new_empty!(u32, D) }
659        }
660
661        #[inline]
662        unsafe fn decode(
663            &mut self,
664            decoder: &mut fidl::encoding::Decoder<'_, D>,
665            offset: usize,
666            _depth: fidl::encoding::Depth,
667        ) -> fidl::Result<()> {
668            decoder.debug_check_bounds::<Self>(offset);
669            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
670            // Verify that padding bytes are zero.
671            // Copy from the buffer into the object.
672            unsafe {
673                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
674            }
675            Ok(())
676        }
677    }
678}