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