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
20pub const VIRTIO_WAYLAND_INVALID_VFD_ID: u32 = 0;
21
22/// Sufficient to contain the opaque image info.
23pub const VIRTIO_WAYLAND_MAX_IMAGE_INFO_SIZE: u32 = 128;
24
25/// Contains the details of a device trap.
26#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27#[repr(C)]
28pub struct Trap {
29    /// The address of the device trap. This must be page-aligned.
30    pub addr: u64,
31    /// The size of the device trap. This must be a multiple of the page size.
32    pub size: u64,
33}
34
35impl fidl::Persistable for Trap {}
36
37#[derive(Clone, Debug, PartialEq)]
38pub struct VirtioBalloonGetMemStatsResponse {
39    pub status: i32,
40    pub mem_stats: Option<Vec<fidl_fuchsia_virtualization::MemStat>>,
41}
42
43impl fidl::Persistable for VirtioBalloonGetMemStatsResponse {}
44
45#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46#[repr(C)]
47pub struct VirtioBlockStartResponse {
48    pub capacity: u64,
49    pub block_size: u32,
50}
51
52impl fidl::Persistable for VirtioBlockStartResponse {}
53
54#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55#[repr(C)]
56pub struct VirtioDeviceConfigureQueueRequest {
57    pub queue: u16,
58    pub size: u16,
59    pub desc: u64,
60    pub avail: u64,
61    pub used: u64,
62}
63
64impl fidl::Persistable for VirtioDeviceConfigureQueueRequest {}
65
66#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67#[repr(C)]
68pub struct VirtioDeviceNotifyQueueRequest {
69    pub queue: u16,
70}
71
72impl fidl::Persistable for VirtioDeviceNotifyQueueRequest {}
73
74#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75#[repr(C)]
76pub struct VirtioDeviceReadyRequest {
77    pub negotiated_features: u32,
78}
79
80impl fidl::Persistable for VirtioDeviceReadyRequest {}
81
82#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
83#[repr(C)]
84pub struct VirtioMagmaStartResponse {
85    pub status: i32,
86}
87
88impl fidl::Persistable for VirtioMagmaStartResponse {}
89
90#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91#[repr(C)]
92pub struct VirtioMemOnConfigChangedRequest {
93    pub plugged_size: u64,
94}
95
96impl fidl::Persistable for VirtioMemOnConfigChangedRequest {}
97
98#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
99#[repr(C)]
100pub struct VirtioSoundStartResponse {
101    pub features: u32,
102    pub jacks: u32,
103    pub streams: u32,
104    pub chmaps: u32,
105}
106
107impl fidl::Persistable for VirtioSoundStartResponse {}
108
109#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
110#[repr(C)]
111pub struct VirtioWaylandImporterExportImageRequest {
112    pub vfd_id: u32,
113}
114
115impl fidl::Persistable for VirtioWaylandImporterExportImageRequest {}
116
117#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
118#[repr(C)]
119pub struct VirtioWaylandImporterImportImageResponse {
120    pub vfd_id: u32,
121}
122
123impl fidl::Persistable for VirtioWaylandImporterImportImageResponse {}
124
125mod internal {
126    use super::*;
127
128    impl fidl::encoding::ValueTypeMarker for Trap {
129        type Borrowed<'a> = &'a Self;
130        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
131            value
132        }
133    }
134
135    unsafe impl fidl::encoding::TypeMarker for Trap {
136        type Owned = Self;
137
138        #[inline(always)]
139        fn inline_align(_context: fidl::encoding::Context) -> usize {
140            8
141        }
142
143        #[inline(always)]
144        fn inline_size(_context: fidl::encoding::Context) -> usize {
145            16
146        }
147        #[inline(always)]
148        fn encode_is_copy() -> bool {
149            true
150        }
151
152        #[inline(always)]
153        fn decode_is_copy() -> bool {
154            true
155        }
156    }
157
158    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Trap, D> for &Trap {
159        #[inline]
160        unsafe fn encode(
161            self,
162            encoder: &mut fidl::encoding::Encoder<'_, D>,
163            offset: usize,
164            _depth: fidl::encoding::Depth,
165        ) -> fidl::Result<()> {
166            encoder.debug_check_bounds::<Trap>(offset);
167            unsafe {
168                // Copy the object into the buffer.
169                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
170                (buf_ptr as *mut Trap).write_unaligned((self as *const Trap).read());
171                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
172                // done second because the memcpy will write garbage to these bytes.
173            }
174            Ok(())
175        }
176    }
177    unsafe impl<
178            D: fidl::encoding::ResourceDialect,
179            T0: fidl::encoding::Encode<u64, D>,
180            T1: fidl::encoding::Encode<u64, D>,
181        > fidl::encoding::Encode<Trap, D> for (T0, T1)
182    {
183        #[inline]
184        unsafe fn encode(
185            self,
186            encoder: &mut fidl::encoding::Encoder<'_, D>,
187            offset: usize,
188            depth: fidl::encoding::Depth,
189        ) -> fidl::Result<()> {
190            encoder.debug_check_bounds::<Trap>(offset);
191            // Zero out padding regions. There's no need to apply masks
192            // because the unmasked parts will be overwritten by fields.
193            // Write the fields.
194            self.0.encode(encoder, offset + 0, depth)?;
195            self.1.encode(encoder, offset + 8, depth)?;
196            Ok(())
197        }
198    }
199
200    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Trap {
201        #[inline(always)]
202        fn new_empty() -> Self {
203            Self { addr: fidl::new_empty!(u64, D), size: fidl::new_empty!(u64, D) }
204        }
205
206        #[inline]
207        unsafe fn decode(
208            &mut self,
209            decoder: &mut fidl::encoding::Decoder<'_, D>,
210            offset: usize,
211            _depth: fidl::encoding::Depth,
212        ) -> fidl::Result<()> {
213            decoder.debug_check_bounds::<Self>(offset);
214            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
215            // Verify that padding bytes are zero.
216            // Copy from the buffer into the object.
217            unsafe {
218                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
219            }
220            Ok(())
221        }
222    }
223
224    impl fidl::encoding::ValueTypeMarker for VirtioBalloonGetMemStatsResponse {
225        type Borrowed<'a> = &'a Self;
226        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
227            value
228        }
229    }
230
231    unsafe impl fidl::encoding::TypeMarker for VirtioBalloonGetMemStatsResponse {
232        type Owned = Self;
233
234        #[inline(always)]
235        fn inline_align(_context: fidl::encoding::Context) -> usize {
236            8
237        }
238
239        #[inline(always)]
240        fn inline_size(_context: fidl::encoding::Context) -> usize {
241            24
242        }
243    }
244
245    unsafe impl<D: fidl::encoding::ResourceDialect>
246        fidl::encoding::Encode<VirtioBalloonGetMemStatsResponse, D>
247        for &VirtioBalloonGetMemStatsResponse
248    {
249        #[inline]
250        unsafe fn encode(
251            self,
252            encoder: &mut fidl::encoding::Encoder<'_, D>,
253            offset: usize,
254            _depth: fidl::encoding::Depth,
255        ) -> fidl::Result<()> {
256            encoder.debug_check_bounds::<VirtioBalloonGetMemStatsResponse>(offset);
257            // Delegate to tuple encoding.
258            fidl::encoding::Encode::<VirtioBalloonGetMemStatsResponse, D>::encode(
259                (
260                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
261                    <fidl::encoding::Optional<
262                        fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::MemStat>,
263                    > as fidl::encoding::ValueTypeMarker>::borrow(
264                        &self.mem_stats
265                    ),
266                ),
267                encoder,
268                offset,
269                _depth,
270            )
271        }
272    }
273    unsafe impl<
274            D: fidl::encoding::ResourceDialect,
275            T0: fidl::encoding::Encode<i32, D>,
276            T1: fidl::encoding::Encode<
277                fidl::encoding::Optional<
278                    fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::MemStat>,
279                >,
280                D,
281            >,
282        > fidl::encoding::Encode<VirtioBalloonGetMemStatsResponse, D> for (T0, T1)
283    {
284        #[inline]
285        unsafe fn encode(
286            self,
287            encoder: &mut fidl::encoding::Encoder<'_, D>,
288            offset: usize,
289            depth: fidl::encoding::Depth,
290        ) -> fidl::Result<()> {
291            encoder.debug_check_bounds::<VirtioBalloonGetMemStatsResponse>(offset);
292            // Zero out padding regions. There's no need to apply masks
293            // because the unmasked parts will be overwritten by fields.
294            unsafe {
295                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
296                (ptr as *mut u64).write_unaligned(0);
297            }
298            // Write the fields.
299            self.0.encode(encoder, offset + 0, depth)?;
300            self.1.encode(encoder, offset + 8, depth)?;
301            Ok(())
302        }
303    }
304
305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
306        for VirtioBalloonGetMemStatsResponse
307    {
308        #[inline(always)]
309        fn new_empty() -> Self {
310            Self {
311                status: fidl::new_empty!(i32, D),
312                mem_stats: fidl::new_empty!(
313                    fidl::encoding::Optional<
314                        fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::MemStat>,
315                    >,
316                    D
317                ),
318            }
319        }
320
321        #[inline]
322        unsafe fn decode(
323            &mut self,
324            decoder: &mut fidl::encoding::Decoder<'_, D>,
325            offset: usize,
326            _depth: fidl::encoding::Depth,
327        ) -> fidl::Result<()> {
328            decoder.debug_check_bounds::<Self>(offset);
329            // Verify that padding bytes are zero.
330            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
331            let padval = unsafe { (ptr as *const u64).read_unaligned() };
332            let mask = 0xffffffff00000000u64;
333            let maskedval = padval & mask;
334            if maskedval != 0 {
335                return Err(fidl::Error::NonZeroPadding {
336                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
337                });
338            }
339            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
340            fidl::decode!(
341                fidl::encoding::Optional<
342                    fidl::encoding::UnboundedVector<fidl_fuchsia_virtualization::MemStat>,
343                >,
344                D,
345                &mut self.mem_stats,
346                decoder,
347                offset + 8,
348                _depth
349            )?;
350            Ok(())
351        }
352    }
353
354    impl fidl::encoding::ValueTypeMarker for VirtioBlockStartResponse {
355        type Borrowed<'a> = &'a Self;
356        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
357            value
358        }
359    }
360
361    unsafe impl fidl::encoding::TypeMarker for VirtioBlockStartResponse {
362        type Owned = Self;
363
364        #[inline(always)]
365        fn inline_align(_context: fidl::encoding::Context) -> usize {
366            8
367        }
368
369        #[inline(always)]
370        fn inline_size(_context: fidl::encoding::Context) -> usize {
371            16
372        }
373    }
374
375    unsafe impl<D: fidl::encoding::ResourceDialect>
376        fidl::encoding::Encode<VirtioBlockStartResponse, D> for &VirtioBlockStartResponse
377    {
378        #[inline]
379        unsafe fn encode(
380            self,
381            encoder: &mut fidl::encoding::Encoder<'_, D>,
382            offset: usize,
383            _depth: fidl::encoding::Depth,
384        ) -> fidl::Result<()> {
385            encoder.debug_check_bounds::<VirtioBlockStartResponse>(offset);
386            unsafe {
387                // Copy the object into the buffer.
388                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
389                (buf_ptr as *mut VirtioBlockStartResponse)
390                    .write_unaligned((self as *const VirtioBlockStartResponse).read());
391                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
392                // done second because the memcpy will write garbage to these bytes.
393                let padding_ptr = buf_ptr.offset(8) as *mut u64;
394                let padding_mask = 0xffffffff00000000u64;
395                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
396            }
397            Ok(())
398        }
399    }
400    unsafe impl<
401            D: fidl::encoding::ResourceDialect,
402            T0: fidl::encoding::Encode<u64, D>,
403            T1: fidl::encoding::Encode<u32, D>,
404        > fidl::encoding::Encode<VirtioBlockStartResponse, D> for (T0, T1)
405    {
406        #[inline]
407        unsafe fn encode(
408            self,
409            encoder: &mut fidl::encoding::Encoder<'_, D>,
410            offset: usize,
411            depth: fidl::encoding::Depth,
412        ) -> fidl::Result<()> {
413            encoder.debug_check_bounds::<VirtioBlockStartResponse>(offset);
414            // Zero out padding regions. There's no need to apply masks
415            // because the unmasked parts will be overwritten by fields.
416            unsafe {
417                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
418                (ptr as *mut u64).write_unaligned(0);
419            }
420            // Write the fields.
421            self.0.encode(encoder, offset + 0, depth)?;
422            self.1.encode(encoder, offset + 8, depth)?;
423            Ok(())
424        }
425    }
426
427    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
428        for VirtioBlockStartResponse
429    {
430        #[inline(always)]
431        fn new_empty() -> Self {
432            Self { capacity: fidl::new_empty!(u64, D), block_size: fidl::new_empty!(u32, D) }
433        }
434
435        #[inline]
436        unsafe fn decode(
437            &mut self,
438            decoder: &mut fidl::encoding::Decoder<'_, D>,
439            offset: usize,
440            _depth: fidl::encoding::Depth,
441        ) -> fidl::Result<()> {
442            decoder.debug_check_bounds::<Self>(offset);
443            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
444            // Verify that padding bytes are zero.
445            let ptr = unsafe { buf_ptr.offset(8) };
446            let padval = unsafe { (ptr as *const u64).read_unaligned() };
447            let mask = 0xffffffff00000000u64;
448            let maskedval = padval & mask;
449            if maskedval != 0 {
450                return Err(fidl::Error::NonZeroPadding {
451                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
452                });
453            }
454            // Copy from the buffer into the object.
455            unsafe {
456                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
457            }
458            Ok(())
459        }
460    }
461
462    impl fidl::encoding::ValueTypeMarker for VirtioDeviceConfigureQueueRequest {
463        type Borrowed<'a> = &'a Self;
464        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
465            value
466        }
467    }
468
469    unsafe impl fidl::encoding::TypeMarker for VirtioDeviceConfigureQueueRequest {
470        type Owned = Self;
471
472        #[inline(always)]
473        fn inline_align(_context: fidl::encoding::Context) -> usize {
474            8
475        }
476
477        #[inline(always)]
478        fn inline_size(_context: fidl::encoding::Context) -> usize {
479            32
480        }
481    }
482
483    unsafe impl<D: fidl::encoding::ResourceDialect>
484        fidl::encoding::Encode<VirtioDeviceConfigureQueueRequest, D>
485        for &VirtioDeviceConfigureQueueRequest
486    {
487        #[inline]
488        unsafe fn encode(
489            self,
490            encoder: &mut fidl::encoding::Encoder<'_, D>,
491            offset: usize,
492            _depth: fidl::encoding::Depth,
493        ) -> fidl::Result<()> {
494            encoder.debug_check_bounds::<VirtioDeviceConfigureQueueRequest>(offset);
495            unsafe {
496                // Copy the object into the buffer.
497                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
498                (buf_ptr as *mut VirtioDeviceConfigureQueueRequest)
499                    .write_unaligned((self as *const VirtioDeviceConfigureQueueRequest).read());
500                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
501                // done second because the memcpy will write garbage to these bytes.
502                let padding_ptr = buf_ptr.offset(0) as *mut u64;
503                let padding_mask = 0xffffffff00000000u64;
504                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
505            }
506            Ok(())
507        }
508    }
509    unsafe impl<
510            D: fidl::encoding::ResourceDialect,
511            T0: fidl::encoding::Encode<u16, D>,
512            T1: fidl::encoding::Encode<u16, D>,
513            T2: fidl::encoding::Encode<u64, D>,
514            T3: fidl::encoding::Encode<u64, D>,
515            T4: fidl::encoding::Encode<u64, D>,
516        > fidl::encoding::Encode<VirtioDeviceConfigureQueueRequest, D> for (T0, T1, T2, T3, T4)
517    {
518        #[inline]
519        unsafe fn encode(
520            self,
521            encoder: &mut fidl::encoding::Encoder<'_, D>,
522            offset: usize,
523            depth: fidl::encoding::Depth,
524        ) -> fidl::Result<()> {
525            encoder.debug_check_bounds::<VirtioDeviceConfigureQueueRequest>(offset);
526            // Zero out padding regions. There's no need to apply masks
527            // because the unmasked parts will be overwritten by fields.
528            unsafe {
529                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
530                (ptr as *mut u64).write_unaligned(0);
531            }
532            // Write the fields.
533            self.0.encode(encoder, offset + 0, depth)?;
534            self.1.encode(encoder, offset + 2, depth)?;
535            self.2.encode(encoder, offset + 8, depth)?;
536            self.3.encode(encoder, offset + 16, depth)?;
537            self.4.encode(encoder, offset + 24, depth)?;
538            Ok(())
539        }
540    }
541
542    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
543        for VirtioDeviceConfigureQueueRequest
544    {
545        #[inline(always)]
546        fn new_empty() -> Self {
547            Self {
548                queue: fidl::new_empty!(u16, D),
549                size: fidl::new_empty!(u16, D),
550                desc: fidl::new_empty!(u64, D),
551                avail: fidl::new_empty!(u64, D),
552                used: fidl::new_empty!(u64, D),
553            }
554        }
555
556        #[inline]
557        unsafe fn decode(
558            &mut self,
559            decoder: &mut fidl::encoding::Decoder<'_, D>,
560            offset: usize,
561            _depth: fidl::encoding::Depth,
562        ) -> fidl::Result<()> {
563            decoder.debug_check_bounds::<Self>(offset);
564            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
565            // Verify that padding bytes are zero.
566            let ptr = unsafe { buf_ptr.offset(0) };
567            let padval = unsafe { (ptr as *const u64).read_unaligned() };
568            let mask = 0xffffffff00000000u64;
569            let maskedval = padval & mask;
570            if maskedval != 0 {
571                return Err(fidl::Error::NonZeroPadding {
572                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
573                });
574            }
575            // Copy from the buffer into the object.
576            unsafe {
577                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 32);
578            }
579            Ok(())
580        }
581    }
582
583    impl fidl::encoding::ValueTypeMarker for VirtioDeviceNotifyQueueRequest {
584        type Borrowed<'a> = &'a Self;
585        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
586            value
587        }
588    }
589
590    unsafe impl fidl::encoding::TypeMarker for VirtioDeviceNotifyQueueRequest {
591        type Owned = Self;
592
593        #[inline(always)]
594        fn inline_align(_context: fidl::encoding::Context) -> usize {
595            2
596        }
597
598        #[inline(always)]
599        fn inline_size(_context: fidl::encoding::Context) -> usize {
600            2
601        }
602        #[inline(always)]
603        fn encode_is_copy() -> bool {
604            true
605        }
606
607        #[inline(always)]
608        fn decode_is_copy() -> bool {
609            true
610        }
611    }
612
613    unsafe impl<D: fidl::encoding::ResourceDialect>
614        fidl::encoding::Encode<VirtioDeviceNotifyQueueRequest, D>
615        for &VirtioDeviceNotifyQueueRequest
616    {
617        #[inline]
618        unsafe fn encode(
619            self,
620            encoder: &mut fidl::encoding::Encoder<'_, D>,
621            offset: usize,
622            _depth: fidl::encoding::Depth,
623        ) -> fidl::Result<()> {
624            encoder.debug_check_bounds::<VirtioDeviceNotifyQueueRequest>(offset);
625            unsafe {
626                // Copy the object into the buffer.
627                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
628                (buf_ptr as *mut VirtioDeviceNotifyQueueRequest)
629                    .write_unaligned((self as *const VirtioDeviceNotifyQueueRequest).read());
630                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
631                // done second because the memcpy will write garbage to these bytes.
632            }
633            Ok(())
634        }
635    }
636    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u16, D>>
637        fidl::encoding::Encode<VirtioDeviceNotifyQueueRequest, D> for (T0,)
638    {
639        #[inline]
640        unsafe fn encode(
641            self,
642            encoder: &mut fidl::encoding::Encoder<'_, D>,
643            offset: usize,
644            depth: fidl::encoding::Depth,
645        ) -> fidl::Result<()> {
646            encoder.debug_check_bounds::<VirtioDeviceNotifyQueueRequest>(offset);
647            // Zero out padding regions. There's no need to apply masks
648            // because the unmasked parts will be overwritten by fields.
649            // Write the fields.
650            self.0.encode(encoder, offset + 0, depth)?;
651            Ok(())
652        }
653    }
654
655    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
656        for VirtioDeviceNotifyQueueRequest
657    {
658        #[inline(always)]
659        fn new_empty() -> Self {
660            Self { queue: fidl::new_empty!(u16, D) }
661        }
662
663        #[inline]
664        unsafe fn decode(
665            &mut self,
666            decoder: &mut fidl::encoding::Decoder<'_, D>,
667            offset: usize,
668            _depth: fidl::encoding::Depth,
669        ) -> fidl::Result<()> {
670            decoder.debug_check_bounds::<Self>(offset);
671            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
672            // Verify that padding bytes are zero.
673            // Copy from the buffer into the object.
674            unsafe {
675                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
676            }
677            Ok(())
678        }
679    }
680
681    impl fidl::encoding::ValueTypeMarker for VirtioDeviceReadyRequest {
682        type Borrowed<'a> = &'a Self;
683        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
684            value
685        }
686    }
687
688    unsafe impl fidl::encoding::TypeMarker for VirtioDeviceReadyRequest {
689        type Owned = Self;
690
691        #[inline(always)]
692        fn inline_align(_context: fidl::encoding::Context) -> usize {
693            4
694        }
695
696        #[inline(always)]
697        fn inline_size(_context: fidl::encoding::Context) -> usize {
698            4
699        }
700        #[inline(always)]
701        fn encode_is_copy() -> bool {
702            true
703        }
704
705        #[inline(always)]
706        fn decode_is_copy() -> bool {
707            true
708        }
709    }
710
711    unsafe impl<D: fidl::encoding::ResourceDialect>
712        fidl::encoding::Encode<VirtioDeviceReadyRequest, D> for &VirtioDeviceReadyRequest
713    {
714        #[inline]
715        unsafe fn encode(
716            self,
717            encoder: &mut fidl::encoding::Encoder<'_, D>,
718            offset: usize,
719            _depth: fidl::encoding::Depth,
720        ) -> fidl::Result<()> {
721            encoder.debug_check_bounds::<VirtioDeviceReadyRequest>(offset);
722            unsafe {
723                // Copy the object into the buffer.
724                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
725                (buf_ptr as *mut VirtioDeviceReadyRequest)
726                    .write_unaligned((self as *const VirtioDeviceReadyRequest).read());
727                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
728                // done second because the memcpy will write garbage to these bytes.
729            }
730            Ok(())
731        }
732    }
733    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
734        fidl::encoding::Encode<VirtioDeviceReadyRequest, D> for (T0,)
735    {
736        #[inline]
737        unsafe fn encode(
738            self,
739            encoder: &mut fidl::encoding::Encoder<'_, D>,
740            offset: usize,
741            depth: fidl::encoding::Depth,
742        ) -> fidl::Result<()> {
743            encoder.debug_check_bounds::<VirtioDeviceReadyRequest>(offset);
744            // Zero out padding regions. There's no need to apply masks
745            // because the unmasked parts will be overwritten by fields.
746            // Write the fields.
747            self.0.encode(encoder, offset + 0, depth)?;
748            Ok(())
749        }
750    }
751
752    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
753        for VirtioDeviceReadyRequest
754    {
755        #[inline(always)]
756        fn new_empty() -> Self {
757            Self { negotiated_features: fidl::new_empty!(u32, D) }
758        }
759
760        #[inline]
761        unsafe fn decode(
762            &mut self,
763            decoder: &mut fidl::encoding::Decoder<'_, D>,
764            offset: usize,
765            _depth: fidl::encoding::Depth,
766        ) -> fidl::Result<()> {
767            decoder.debug_check_bounds::<Self>(offset);
768            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
769            // Verify that padding bytes are zero.
770            // Copy from the buffer into the object.
771            unsafe {
772                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
773            }
774            Ok(())
775        }
776    }
777
778    impl fidl::encoding::ValueTypeMarker for VirtioMagmaStartResponse {
779        type Borrowed<'a> = &'a Self;
780        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
781            value
782        }
783    }
784
785    unsafe impl fidl::encoding::TypeMarker for VirtioMagmaStartResponse {
786        type Owned = Self;
787
788        #[inline(always)]
789        fn inline_align(_context: fidl::encoding::Context) -> usize {
790            4
791        }
792
793        #[inline(always)]
794        fn inline_size(_context: fidl::encoding::Context) -> usize {
795            4
796        }
797        #[inline(always)]
798        fn encode_is_copy() -> bool {
799            true
800        }
801
802        #[inline(always)]
803        fn decode_is_copy() -> bool {
804            true
805        }
806    }
807
808    unsafe impl<D: fidl::encoding::ResourceDialect>
809        fidl::encoding::Encode<VirtioMagmaStartResponse, D> for &VirtioMagmaStartResponse
810    {
811        #[inline]
812        unsafe fn encode(
813            self,
814            encoder: &mut fidl::encoding::Encoder<'_, D>,
815            offset: usize,
816            _depth: fidl::encoding::Depth,
817        ) -> fidl::Result<()> {
818            encoder.debug_check_bounds::<VirtioMagmaStartResponse>(offset);
819            unsafe {
820                // Copy the object into the buffer.
821                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
822                (buf_ptr as *mut VirtioMagmaStartResponse)
823                    .write_unaligned((self as *const VirtioMagmaStartResponse).read());
824                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
825                // done second because the memcpy will write garbage to these bytes.
826            }
827            Ok(())
828        }
829    }
830    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
831        fidl::encoding::Encode<VirtioMagmaStartResponse, D> for (T0,)
832    {
833        #[inline]
834        unsafe fn encode(
835            self,
836            encoder: &mut fidl::encoding::Encoder<'_, D>,
837            offset: usize,
838            depth: fidl::encoding::Depth,
839        ) -> fidl::Result<()> {
840            encoder.debug_check_bounds::<VirtioMagmaStartResponse>(offset);
841            // Zero out padding regions. There's no need to apply masks
842            // because the unmasked parts will be overwritten by fields.
843            // Write the fields.
844            self.0.encode(encoder, offset + 0, depth)?;
845            Ok(())
846        }
847    }
848
849    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
850        for VirtioMagmaStartResponse
851    {
852        #[inline(always)]
853        fn new_empty() -> Self {
854            Self { status: fidl::new_empty!(i32, D) }
855        }
856
857        #[inline]
858        unsafe fn decode(
859            &mut self,
860            decoder: &mut fidl::encoding::Decoder<'_, D>,
861            offset: usize,
862            _depth: fidl::encoding::Depth,
863        ) -> fidl::Result<()> {
864            decoder.debug_check_bounds::<Self>(offset);
865            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
866            // Verify that padding bytes are zero.
867            // Copy from the buffer into the object.
868            unsafe {
869                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
870            }
871            Ok(())
872        }
873    }
874
875    impl fidl::encoding::ValueTypeMarker for VirtioMemOnConfigChangedRequest {
876        type Borrowed<'a> = &'a Self;
877        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
878            value
879        }
880    }
881
882    unsafe impl fidl::encoding::TypeMarker for VirtioMemOnConfigChangedRequest {
883        type Owned = Self;
884
885        #[inline(always)]
886        fn inline_align(_context: fidl::encoding::Context) -> usize {
887            8
888        }
889
890        #[inline(always)]
891        fn inline_size(_context: fidl::encoding::Context) -> usize {
892            8
893        }
894        #[inline(always)]
895        fn encode_is_copy() -> bool {
896            true
897        }
898
899        #[inline(always)]
900        fn decode_is_copy() -> bool {
901            true
902        }
903    }
904
905    unsafe impl<D: fidl::encoding::ResourceDialect>
906        fidl::encoding::Encode<VirtioMemOnConfigChangedRequest, D>
907        for &VirtioMemOnConfigChangedRequest
908    {
909        #[inline]
910        unsafe fn encode(
911            self,
912            encoder: &mut fidl::encoding::Encoder<'_, D>,
913            offset: usize,
914            _depth: fidl::encoding::Depth,
915        ) -> fidl::Result<()> {
916            encoder.debug_check_bounds::<VirtioMemOnConfigChangedRequest>(offset);
917            unsafe {
918                // Copy the object into the buffer.
919                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
920                (buf_ptr as *mut VirtioMemOnConfigChangedRequest)
921                    .write_unaligned((self as *const VirtioMemOnConfigChangedRequest).read());
922                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
923                // done second because the memcpy will write garbage to these bytes.
924            }
925            Ok(())
926        }
927    }
928    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
929        fidl::encoding::Encode<VirtioMemOnConfigChangedRequest, D> for (T0,)
930    {
931        #[inline]
932        unsafe fn encode(
933            self,
934            encoder: &mut fidl::encoding::Encoder<'_, D>,
935            offset: usize,
936            depth: fidl::encoding::Depth,
937        ) -> fidl::Result<()> {
938            encoder.debug_check_bounds::<VirtioMemOnConfigChangedRequest>(offset);
939            // Zero out padding regions. There's no need to apply masks
940            // because the unmasked parts will be overwritten by fields.
941            // Write the fields.
942            self.0.encode(encoder, offset + 0, depth)?;
943            Ok(())
944        }
945    }
946
947    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
948        for VirtioMemOnConfigChangedRequest
949    {
950        #[inline(always)]
951        fn new_empty() -> Self {
952            Self { plugged_size: fidl::new_empty!(u64, D) }
953        }
954
955        #[inline]
956        unsafe fn decode(
957            &mut self,
958            decoder: &mut fidl::encoding::Decoder<'_, D>,
959            offset: usize,
960            _depth: fidl::encoding::Depth,
961        ) -> fidl::Result<()> {
962            decoder.debug_check_bounds::<Self>(offset);
963            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
964            // Verify that padding bytes are zero.
965            // Copy from the buffer into the object.
966            unsafe {
967                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
968            }
969            Ok(())
970        }
971    }
972
973    impl fidl::encoding::ValueTypeMarker for VirtioSoundStartResponse {
974        type Borrowed<'a> = &'a Self;
975        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
976            value
977        }
978    }
979
980    unsafe impl fidl::encoding::TypeMarker for VirtioSoundStartResponse {
981        type Owned = Self;
982
983        #[inline(always)]
984        fn inline_align(_context: fidl::encoding::Context) -> usize {
985            4
986        }
987
988        #[inline(always)]
989        fn inline_size(_context: fidl::encoding::Context) -> usize {
990            16
991        }
992        #[inline(always)]
993        fn encode_is_copy() -> bool {
994            true
995        }
996
997        #[inline(always)]
998        fn decode_is_copy() -> bool {
999            true
1000        }
1001    }
1002
1003    unsafe impl<D: fidl::encoding::ResourceDialect>
1004        fidl::encoding::Encode<VirtioSoundStartResponse, D> for &VirtioSoundStartResponse
1005    {
1006        #[inline]
1007        unsafe fn encode(
1008            self,
1009            encoder: &mut fidl::encoding::Encoder<'_, D>,
1010            offset: usize,
1011            _depth: fidl::encoding::Depth,
1012        ) -> fidl::Result<()> {
1013            encoder.debug_check_bounds::<VirtioSoundStartResponse>(offset);
1014            unsafe {
1015                // Copy the object into the buffer.
1016                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1017                (buf_ptr as *mut VirtioSoundStartResponse)
1018                    .write_unaligned((self as *const VirtioSoundStartResponse).read());
1019                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1020                // done second because the memcpy will write garbage to these bytes.
1021            }
1022            Ok(())
1023        }
1024    }
1025    unsafe impl<
1026            D: fidl::encoding::ResourceDialect,
1027            T0: fidl::encoding::Encode<u32, D>,
1028            T1: fidl::encoding::Encode<u32, D>,
1029            T2: fidl::encoding::Encode<u32, D>,
1030            T3: fidl::encoding::Encode<u32, D>,
1031        > fidl::encoding::Encode<VirtioSoundStartResponse, D> for (T0, T1, T2, T3)
1032    {
1033        #[inline]
1034        unsafe fn encode(
1035            self,
1036            encoder: &mut fidl::encoding::Encoder<'_, D>,
1037            offset: usize,
1038            depth: fidl::encoding::Depth,
1039        ) -> fidl::Result<()> {
1040            encoder.debug_check_bounds::<VirtioSoundStartResponse>(offset);
1041            // Zero out padding regions. There's no need to apply masks
1042            // because the unmasked parts will be overwritten by fields.
1043            // Write the fields.
1044            self.0.encode(encoder, offset + 0, depth)?;
1045            self.1.encode(encoder, offset + 4, depth)?;
1046            self.2.encode(encoder, offset + 8, depth)?;
1047            self.3.encode(encoder, offset + 12, depth)?;
1048            Ok(())
1049        }
1050    }
1051
1052    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1053        for VirtioSoundStartResponse
1054    {
1055        #[inline(always)]
1056        fn new_empty() -> Self {
1057            Self {
1058                features: fidl::new_empty!(u32, D),
1059                jacks: fidl::new_empty!(u32, D),
1060                streams: fidl::new_empty!(u32, D),
1061                chmaps: fidl::new_empty!(u32, D),
1062            }
1063        }
1064
1065        #[inline]
1066        unsafe fn decode(
1067            &mut self,
1068            decoder: &mut fidl::encoding::Decoder<'_, D>,
1069            offset: usize,
1070            _depth: fidl::encoding::Depth,
1071        ) -> fidl::Result<()> {
1072            decoder.debug_check_bounds::<Self>(offset);
1073            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1074            // Verify that padding bytes are zero.
1075            // Copy from the buffer into the object.
1076            unsafe {
1077                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
1078            }
1079            Ok(())
1080        }
1081    }
1082
1083    impl fidl::encoding::ValueTypeMarker for VirtioWaylandImporterExportImageRequest {
1084        type Borrowed<'a> = &'a Self;
1085        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1086            value
1087        }
1088    }
1089
1090    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterExportImageRequest {
1091        type Owned = Self;
1092
1093        #[inline(always)]
1094        fn inline_align(_context: fidl::encoding::Context) -> usize {
1095            4
1096        }
1097
1098        #[inline(always)]
1099        fn inline_size(_context: fidl::encoding::Context) -> usize {
1100            4
1101        }
1102        #[inline(always)]
1103        fn encode_is_copy() -> bool {
1104            true
1105        }
1106
1107        #[inline(always)]
1108        fn decode_is_copy() -> bool {
1109            true
1110        }
1111    }
1112
1113    unsafe impl<D: fidl::encoding::ResourceDialect>
1114        fidl::encoding::Encode<VirtioWaylandImporterExportImageRequest, D>
1115        for &VirtioWaylandImporterExportImageRequest
1116    {
1117        #[inline]
1118        unsafe fn encode(
1119            self,
1120            encoder: &mut fidl::encoding::Encoder<'_, D>,
1121            offset: usize,
1122            _depth: fidl::encoding::Depth,
1123        ) -> fidl::Result<()> {
1124            encoder.debug_check_bounds::<VirtioWaylandImporterExportImageRequest>(offset);
1125            unsafe {
1126                // Copy the object into the buffer.
1127                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1128                (buf_ptr as *mut VirtioWaylandImporterExportImageRequest).write_unaligned(
1129                    (self as *const VirtioWaylandImporterExportImageRequest).read(),
1130                );
1131                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1132                // done second because the memcpy will write garbage to these bytes.
1133            }
1134            Ok(())
1135        }
1136    }
1137    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1138        fidl::encoding::Encode<VirtioWaylandImporterExportImageRequest, D> for (T0,)
1139    {
1140        #[inline]
1141        unsafe fn encode(
1142            self,
1143            encoder: &mut fidl::encoding::Encoder<'_, D>,
1144            offset: usize,
1145            depth: fidl::encoding::Depth,
1146        ) -> fidl::Result<()> {
1147            encoder.debug_check_bounds::<VirtioWaylandImporterExportImageRequest>(offset);
1148            // Zero out padding regions. There's no need to apply masks
1149            // because the unmasked parts will be overwritten by fields.
1150            // Write the fields.
1151            self.0.encode(encoder, offset + 0, depth)?;
1152            Ok(())
1153        }
1154    }
1155
1156    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1157        for VirtioWaylandImporterExportImageRequest
1158    {
1159        #[inline(always)]
1160        fn new_empty() -> Self {
1161            Self { vfd_id: fidl::new_empty!(u32, D) }
1162        }
1163
1164        #[inline]
1165        unsafe fn decode(
1166            &mut self,
1167            decoder: &mut fidl::encoding::Decoder<'_, D>,
1168            offset: usize,
1169            _depth: fidl::encoding::Depth,
1170        ) -> fidl::Result<()> {
1171            decoder.debug_check_bounds::<Self>(offset);
1172            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1173            // Verify that padding bytes are zero.
1174            // Copy from the buffer into the object.
1175            unsafe {
1176                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1177            }
1178            Ok(())
1179        }
1180    }
1181
1182    impl fidl::encoding::ValueTypeMarker for VirtioWaylandImporterImportImageResponse {
1183        type Borrowed<'a> = &'a Self;
1184        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1185            value
1186        }
1187    }
1188
1189    unsafe impl fidl::encoding::TypeMarker for VirtioWaylandImporterImportImageResponse {
1190        type Owned = Self;
1191
1192        #[inline(always)]
1193        fn inline_align(_context: fidl::encoding::Context) -> usize {
1194            4
1195        }
1196
1197        #[inline(always)]
1198        fn inline_size(_context: fidl::encoding::Context) -> usize {
1199            4
1200        }
1201        #[inline(always)]
1202        fn encode_is_copy() -> bool {
1203            true
1204        }
1205
1206        #[inline(always)]
1207        fn decode_is_copy() -> bool {
1208            true
1209        }
1210    }
1211
1212    unsafe impl<D: fidl::encoding::ResourceDialect>
1213        fidl::encoding::Encode<VirtioWaylandImporterImportImageResponse, D>
1214        for &VirtioWaylandImporterImportImageResponse
1215    {
1216        #[inline]
1217        unsafe fn encode(
1218            self,
1219            encoder: &mut fidl::encoding::Encoder<'_, D>,
1220            offset: usize,
1221            _depth: fidl::encoding::Depth,
1222        ) -> fidl::Result<()> {
1223            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageResponse>(offset);
1224            unsafe {
1225                // Copy the object into the buffer.
1226                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1227                (buf_ptr as *mut VirtioWaylandImporterImportImageResponse).write_unaligned(
1228                    (self as *const VirtioWaylandImporterImportImageResponse).read(),
1229                );
1230                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1231                // done second because the memcpy will write garbage to these bytes.
1232            }
1233            Ok(())
1234        }
1235    }
1236    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1237        fidl::encoding::Encode<VirtioWaylandImporterImportImageResponse, D> for (T0,)
1238    {
1239        #[inline]
1240        unsafe fn encode(
1241            self,
1242            encoder: &mut fidl::encoding::Encoder<'_, D>,
1243            offset: usize,
1244            depth: fidl::encoding::Depth,
1245        ) -> fidl::Result<()> {
1246            encoder.debug_check_bounds::<VirtioWaylandImporterImportImageResponse>(offset);
1247            // Zero out padding regions. There's no need to apply masks
1248            // because the unmasked parts will be overwritten by fields.
1249            // Write the fields.
1250            self.0.encode(encoder, offset + 0, depth)?;
1251            Ok(())
1252        }
1253    }
1254
1255    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1256        for VirtioWaylandImporterImportImageResponse
1257    {
1258        #[inline(always)]
1259        fn new_empty() -> Self {
1260            Self { vfd_id: fidl::new_empty!(u32, D) }
1261        }
1262
1263        #[inline]
1264        unsafe fn decode(
1265            &mut self,
1266            decoder: &mut fidl::encoding::Decoder<'_, D>,
1267            offset: usize,
1268            _depth: fidl::encoding::Depth,
1269        ) -> fidl::Result<()> {
1270            decoder.debug_check_bounds::<Self>(offset);
1271            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1272            // Verify that padding bytes are zero.
1273            // Copy from the buffer into the object.
1274            unsafe {
1275                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1276            }
1277            Ok(())
1278        }
1279    }
1280}