fidl_fuchsia_hardware_usb_device__common/
fidl_fuchsia_hardware_usb_device__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/// sizeof(usb_device_descriptor_t)
12pub const DEVICE_DESC_SIZE: u32 = 18;
13
14/// UINT16_MAX
15pub const MAX_CONFIG_DESC_SIZE: u32 = 65536;
16
17/// See GetStringDescriptor description below
18pub const MAX_STRING_DESC_SIZE: u32 = 384;
19
20#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
21#[repr(C)]
22pub struct DeviceGetConfigurationDescriptorRequest {
23    pub config: u8,
24}
25
26impl fidl::Persistable for DeviceGetConfigurationDescriptorRequest {}
27
28#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct DeviceGetConfigurationDescriptorResponse {
30    pub s: i32,
31    pub desc: Vec<u8>,
32}
33
34impl fidl::Persistable for DeviceGetConfigurationDescriptorResponse {}
35
36#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37#[repr(C)]
38pub struct DeviceGetConfigurationDescriptorSizeRequest {
39    pub config: u8,
40}
41
42impl fidl::Persistable for DeviceGetConfigurationDescriptorSizeRequest {}
43
44#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45#[repr(C)]
46pub struct DeviceGetConfigurationDescriptorSizeResponse {
47    pub s: i32,
48    pub size: u16,
49}
50
51impl fidl::Persistable for DeviceGetConfigurationDescriptorSizeResponse {}
52
53#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
54#[repr(C)]
55pub struct DeviceGetConfigurationResponse {
56    pub configuration: u8,
57}
58
59impl fidl::Persistable for DeviceGetConfigurationResponse {}
60
61#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62#[repr(C)]
63pub struct DeviceGetDeviceDescriptorResponse {
64    pub desc: [u8; 18],
65}
66
67impl fidl::Persistable for DeviceGetDeviceDescriptorResponse {}
68
69#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70#[repr(C)]
71pub struct DeviceGetDeviceIdResponse {
72    pub device_id: u32,
73}
74
75impl fidl::Persistable for DeviceGetDeviceIdResponse {}
76
77#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78#[repr(C)]
79pub struct DeviceGetDeviceSpeedResponse {
80    pub speed: u32,
81}
82
83impl fidl::Persistable for DeviceGetDeviceSpeedResponse {}
84
85#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
86#[repr(C)]
87pub struct DeviceGetHubDeviceIdResponse {
88    pub hub_device_id: u32,
89}
90
91impl fidl::Persistable for DeviceGetHubDeviceIdResponse {}
92
93#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
94#[repr(C)]
95pub struct DeviceGetStringDescriptorRequest {
96    pub desc_id: u8,
97    pub lang_id: u16,
98}
99
100impl fidl::Persistable for DeviceGetStringDescriptorRequest {}
101
102#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
103pub struct DeviceGetStringDescriptorResponse {
104    pub s: i32,
105    pub desc: String,
106    pub actual_lang_id: u16,
107}
108
109impl fidl::Persistable for DeviceGetStringDescriptorResponse {}
110
111#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112#[repr(C)]
113pub struct DeviceSetConfigurationRequest {
114    pub configuration: u8,
115}
116
117impl fidl::Persistable for DeviceSetConfigurationRequest {}
118
119#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
120#[repr(C)]
121pub struct DeviceSetConfigurationResponse {
122    pub s: i32,
123}
124
125impl fidl::Persistable for DeviceSetConfigurationResponse {}
126
127#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
128#[repr(C)]
129pub struct DeviceSetInterfaceRequest {
130    pub interface_number: u8,
131    pub alt_setting: u8,
132}
133
134impl fidl::Persistable for DeviceSetInterfaceRequest {}
135
136#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137#[repr(C)]
138pub struct DeviceSetInterfaceResponse {
139    pub s: i32,
140}
141
142impl fidl::Persistable for DeviceSetInterfaceResponse {}
143
144pub mod device_ordinals {
145    pub const GET_DEVICE_SPEED: u64 = 0x623cd7927fb449de;
146    pub const GET_DEVICE_DESCRIPTOR: u64 = 0x5f761371f4b9f34a;
147    pub const GET_CONFIGURATION_DESCRIPTOR_SIZE: u64 = 0x65912d7d5e3a07c8;
148    pub const GET_CONFIGURATION_DESCRIPTOR: u64 = 0x1859a4e4421d2036;
149    pub const GET_STRING_DESCRIPTOR: u64 = 0x5ff601b3b6891337;
150    pub const SET_INTERFACE: u64 = 0x45348c50850b641d;
151    pub const GET_DEVICE_ID: u64 = 0x34a73eef491c2ce0;
152    pub const GET_HUB_DEVICE_ID: u64 = 0xce263c86f7bbbcd;
153    pub const GET_CONFIGURATION: u64 = 0x73f644382a2335fd;
154    pub const SET_CONFIGURATION: u64 = 0x12bf6e43b045ee9d;
155}
156
157mod internal {
158    use super::*;
159
160    impl fidl::encoding::ValueTypeMarker for DeviceGetConfigurationDescriptorRequest {
161        type Borrowed<'a> = &'a Self;
162        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
163            value
164        }
165    }
166
167    unsafe impl fidl::encoding::TypeMarker for DeviceGetConfigurationDescriptorRequest {
168        type Owned = Self;
169
170        #[inline(always)]
171        fn inline_align(_context: fidl::encoding::Context) -> usize {
172            1
173        }
174
175        #[inline(always)]
176        fn inline_size(_context: fidl::encoding::Context) -> usize {
177            1
178        }
179        #[inline(always)]
180        fn encode_is_copy() -> bool {
181            true
182        }
183
184        #[inline(always)]
185        fn decode_is_copy() -> bool {
186            true
187        }
188    }
189
190    unsafe impl<D: fidl::encoding::ResourceDialect>
191        fidl::encoding::Encode<DeviceGetConfigurationDescriptorRequest, D>
192        for &DeviceGetConfigurationDescriptorRequest
193    {
194        #[inline]
195        unsafe fn encode(
196            self,
197            encoder: &mut fidl::encoding::Encoder<'_, D>,
198            offset: usize,
199            _depth: fidl::encoding::Depth,
200        ) -> fidl::Result<()> {
201            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorRequest>(offset);
202            unsafe {
203                // Copy the object into the buffer.
204                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
205                (buf_ptr as *mut DeviceGetConfigurationDescriptorRequest).write_unaligned(
206                    (self as *const DeviceGetConfigurationDescriptorRequest).read(),
207                );
208                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
209                // done second because the memcpy will write garbage to these bytes.
210            }
211            Ok(())
212        }
213    }
214    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
215        fidl::encoding::Encode<DeviceGetConfigurationDescriptorRequest, D> for (T0,)
216    {
217        #[inline]
218        unsafe fn encode(
219            self,
220            encoder: &mut fidl::encoding::Encoder<'_, D>,
221            offset: usize,
222            depth: fidl::encoding::Depth,
223        ) -> fidl::Result<()> {
224            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorRequest>(offset);
225            // Zero out padding regions. There's no need to apply masks
226            // because the unmasked parts will be overwritten by fields.
227            // Write the fields.
228            self.0.encode(encoder, offset + 0, depth)?;
229            Ok(())
230        }
231    }
232
233    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
234        for DeviceGetConfigurationDescriptorRequest
235    {
236        #[inline(always)]
237        fn new_empty() -> Self {
238            Self { config: fidl::new_empty!(u8, D) }
239        }
240
241        #[inline]
242        unsafe fn decode(
243            &mut self,
244            decoder: &mut fidl::encoding::Decoder<'_, D>,
245            offset: usize,
246            _depth: fidl::encoding::Depth,
247        ) -> fidl::Result<()> {
248            decoder.debug_check_bounds::<Self>(offset);
249            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
250            // Verify that padding bytes are zero.
251            // Copy from the buffer into the object.
252            unsafe {
253                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
254            }
255            Ok(())
256        }
257    }
258
259    impl fidl::encoding::ValueTypeMarker for DeviceGetConfigurationDescriptorResponse {
260        type Borrowed<'a> = &'a Self;
261        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
262            value
263        }
264    }
265
266    unsafe impl fidl::encoding::TypeMarker for DeviceGetConfigurationDescriptorResponse {
267        type Owned = Self;
268
269        #[inline(always)]
270        fn inline_align(_context: fidl::encoding::Context) -> usize {
271            8
272        }
273
274        #[inline(always)]
275        fn inline_size(_context: fidl::encoding::Context) -> usize {
276            24
277        }
278    }
279
280    unsafe impl<D: fidl::encoding::ResourceDialect>
281        fidl::encoding::Encode<DeviceGetConfigurationDescriptorResponse, D>
282        for &DeviceGetConfigurationDescriptorResponse
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::<DeviceGetConfigurationDescriptorResponse>(offset);
292            // Delegate to tuple encoding.
293            fidl::encoding::Encode::<DeviceGetConfigurationDescriptorResponse, D>::encode(
294                (
295                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.s),
296                    <fidl::encoding::Vector<u8, 65536> as fidl::encoding::ValueTypeMarker>::borrow(
297                        &self.desc,
298                    ),
299                ),
300                encoder,
301                offset,
302                _depth,
303            )
304        }
305    }
306    unsafe impl<
307            D: fidl::encoding::ResourceDialect,
308            T0: fidl::encoding::Encode<i32, D>,
309            T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 65536>, D>,
310        > fidl::encoding::Encode<DeviceGetConfigurationDescriptorResponse, D> for (T0, T1)
311    {
312        #[inline]
313        unsafe fn encode(
314            self,
315            encoder: &mut fidl::encoding::Encoder<'_, D>,
316            offset: usize,
317            depth: fidl::encoding::Depth,
318        ) -> fidl::Result<()> {
319            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorResponse>(offset);
320            // Zero out padding regions. There's no need to apply masks
321            // because the unmasked parts will be overwritten by fields.
322            unsafe {
323                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
324                (ptr as *mut u64).write_unaligned(0);
325            }
326            // Write the fields.
327            self.0.encode(encoder, offset + 0, depth)?;
328            self.1.encode(encoder, offset + 8, depth)?;
329            Ok(())
330        }
331    }
332
333    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
334        for DeviceGetConfigurationDescriptorResponse
335    {
336        #[inline(always)]
337        fn new_empty() -> Self {
338            Self {
339                s: fidl::new_empty!(i32, D),
340                desc: fidl::new_empty!(fidl::encoding::Vector<u8, 65536>, D),
341            }
342        }
343
344        #[inline]
345        unsafe fn decode(
346            &mut self,
347            decoder: &mut fidl::encoding::Decoder<'_, D>,
348            offset: usize,
349            _depth: fidl::encoding::Depth,
350        ) -> fidl::Result<()> {
351            decoder.debug_check_bounds::<Self>(offset);
352            // Verify that padding bytes are zero.
353            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
354            let padval = unsafe { (ptr as *const u64).read_unaligned() };
355            let mask = 0xffffffff00000000u64;
356            let maskedval = padval & mask;
357            if maskedval != 0 {
358                return Err(fidl::Error::NonZeroPadding {
359                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
360                });
361            }
362            fidl::decode!(i32, D, &mut self.s, decoder, offset + 0, _depth)?;
363            fidl::decode!(fidl::encoding::Vector<u8, 65536>, D, &mut self.desc, decoder, offset + 8, _depth)?;
364            Ok(())
365        }
366    }
367
368    impl fidl::encoding::ValueTypeMarker for DeviceGetConfigurationDescriptorSizeRequest {
369        type Borrowed<'a> = &'a Self;
370        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
371            value
372        }
373    }
374
375    unsafe impl fidl::encoding::TypeMarker for DeviceGetConfigurationDescriptorSizeRequest {
376        type Owned = Self;
377
378        #[inline(always)]
379        fn inline_align(_context: fidl::encoding::Context) -> usize {
380            1
381        }
382
383        #[inline(always)]
384        fn inline_size(_context: fidl::encoding::Context) -> usize {
385            1
386        }
387        #[inline(always)]
388        fn encode_is_copy() -> bool {
389            true
390        }
391
392        #[inline(always)]
393        fn decode_is_copy() -> bool {
394            true
395        }
396    }
397
398    unsafe impl<D: fidl::encoding::ResourceDialect>
399        fidl::encoding::Encode<DeviceGetConfigurationDescriptorSizeRequest, D>
400        for &DeviceGetConfigurationDescriptorSizeRequest
401    {
402        #[inline]
403        unsafe fn encode(
404            self,
405            encoder: &mut fidl::encoding::Encoder<'_, D>,
406            offset: usize,
407            _depth: fidl::encoding::Depth,
408        ) -> fidl::Result<()> {
409            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorSizeRequest>(offset);
410            unsafe {
411                // Copy the object into the buffer.
412                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
413                (buf_ptr as *mut DeviceGetConfigurationDescriptorSizeRequest).write_unaligned(
414                    (self as *const DeviceGetConfigurationDescriptorSizeRequest).read(),
415                );
416                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
417                // done second because the memcpy will write garbage to these bytes.
418            }
419            Ok(())
420        }
421    }
422    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
423        fidl::encoding::Encode<DeviceGetConfigurationDescriptorSizeRequest, D> for (T0,)
424    {
425        #[inline]
426        unsafe fn encode(
427            self,
428            encoder: &mut fidl::encoding::Encoder<'_, D>,
429            offset: usize,
430            depth: fidl::encoding::Depth,
431        ) -> fidl::Result<()> {
432            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorSizeRequest>(offset);
433            // Zero out padding regions. There's no need to apply masks
434            // because the unmasked parts will be overwritten by fields.
435            // Write the fields.
436            self.0.encode(encoder, offset + 0, depth)?;
437            Ok(())
438        }
439    }
440
441    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
442        for DeviceGetConfigurationDescriptorSizeRequest
443    {
444        #[inline(always)]
445        fn new_empty() -> Self {
446            Self { config: fidl::new_empty!(u8, D) }
447        }
448
449        #[inline]
450        unsafe fn decode(
451            &mut self,
452            decoder: &mut fidl::encoding::Decoder<'_, D>,
453            offset: usize,
454            _depth: fidl::encoding::Depth,
455        ) -> fidl::Result<()> {
456            decoder.debug_check_bounds::<Self>(offset);
457            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
458            // Verify that padding bytes are zero.
459            // Copy from the buffer into the object.
460            unsafe {
461                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
462            }
463            Ok(())
464        }
465    }
466
467    impl fidl::encoding::ValueTypeMarker for DeviceGetConfigurationDescriptorSizeResponse {
468        type Borrowed<'a> = &'a Self;
469        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
470            value
471        }
472    }
473
474    unsafe impl fidl::encoding::TypeMarker for DeviceGetConfigurationDescriptorSizeResponse {
475        type Owned = Self;
476
477        #[inline(always)]
478        fn inline_align(_context: fidl::encoding::Context) -> usize {
479            4
480        }
481
482        #[inline(always)]
483        fn inline_size(_context: fidl::encoding::Context) -> usize {
484            8
485        }
486    }
487
488    unsafe impl<D: fidl::encoding::ResourceDialect>
489        fidl::encoding::Encode<DeviceGetConfigurationDescriptorSizeResponse, D>
490        for &DeviceGetConfigurationDescriptorSizeResponse
491    {
492        #[inline]
493        unsafe fn encode(
494            self,
495            encoder: &mut fidl::encoding::Encoder<'_, D>,
496            offset: usize,
497            _depth: fidl::encoding::Depth,
498        ) -> fidl::Result<()> {
499            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorSizeResponse>(offset);
500            unsafe {
501                // Copy the object into the buffer.
502                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
503                (buf_ptr as *mut DeviceGetConfigurationDescriptorSizeResponse).write_unaligned(
504                    (self as *const DeviceGetConfigurationDescriptorSizeResponse).read(),
505                );
506                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
507                // done second because the memcpy will write garbage to these bytes.
508                let padding_ptr = buf_ptr.offset(4) as *mut u32;
509                let padding_mask = 0xffff0000u32;
510                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
511            }
512            Ok(())
513        }
514    }
515    unsafe impl<
516            D: fidl::encoding::ResourceDialect,
517            T0: fidl::encoding::Encode<i32, D>,
518            T1: fidl::encoding::Encode<u16, D>,
519        > fidl::encoding::Encode<DeviceGetConfigurationDescriptorSizeResponse, D> for (T0, T1)
520    {
521        #[inline]
522        unsafe fn encode(
523            self,
524            encoder: &mut fidl::encoding::Encoder<'_, D>,
525            offset: usize,
526            depth: fidl::encoding::Depth,
527        ) -> fidl::Result<()> {
528            encoder.debug_check_bounds::<DeviceGetConfigurationDescriptorSizeResponse>(offset);
529            // Zero out padding regions. There's no need to apply masks
530            // because the unmasked parts will be overwritten by fields.
531            unsafe {
532                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
533                (ptr as *mut u32).write_unaligned(0);
534            }
535            // Write the fields.
536            self.0.encode(encoder, offset + 0, depth)?;
537            self.1.encode(encoder, offset + 4, depth)?;
538            Ok(())
539        }
540    }
541
542    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
543        for DeviceGetConfigurationDescriptorSizeResponse
544    {
545        #[inline(always)]
546        fn new_empty() -> Self {
547            Self { s: fidl::new_empty!(i32, D), size: fidl::new_empty!(u16, D) }
548        }
549
550        #[inline]
551        unsafe fn decode(
552            &mut self,
553            decoder: &mut fidl::encoding::Decoder<'_, D>,
554            offset: usize,
555            _depth: fidl::encoding::Depth,
556        ) -> fidl::Result<()> {
557            decoder.debug_check_bounds::<Self>(offset);
558            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
559            // Verify that padding bytes are zero.
560            let ptr = unsafe { buf_ptr.offset(4) };
561            let padval = unsafe { (ptr as *const u32).read_unaligned() };
562            let mask = 0xffff0000u32;
563            let maskedval = padval & mask;
564            if maskedval != 0 {
565                return Err(fidl::Error::NonZeroPadding {
566                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
567                });
568            }
569            // Copy from the buffer into the object.
570            unsafe {
571                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
572            }
573            Ok(())
574        }
575    }
576
577    impl fidl::encoding::ValueTypeMarker for DeviceGetConfigurationResponse {
578        type Borrowed<'a> = &'a Self;
579        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
580            value
581        }
582    }
583
584    unsafe impl fidl::encoding::TypeMarker for DeviceGetConfigurationResponse {
585        type Owned = Self;
586
587        #[inline(always)]
588        fn inline_align(_context: fidl::encoding::Context) -> usize {
589            1
590        }
591
592        #[inline(always)]
593        fn inline_size(_context: fidl::encoding::Context) -> usize {
594            1
595        }
596        #[inline(always)]
597        fn encode_is_copy() -> bool {
598            true
599        }
600
601        #[inline(always)]
602        fn decode_is_copy() -> bool {
603            true
604        }
605    }
606
607    unsafe impl<D: fidl::encoding::ResourceDialect>
608        fidl::encoding::Encode<DeviceGetConfigurationResponse, D>
609        for &DeviceGetConfigurationResponse
610    {
611        #[inline]
612        unsafe fn encode(
613            self,
614            encoder: &mut fidl::encoding::Encoder<'_, D>,
615            offset: usize,
616            _depth: fidl::encoding::Depth,
617        ) -> fidl::Result<()> {
618            encoder.debug_check_bounds::<DeviceGetConfigurationResponse>(offset);
619            unsafe {
620                // Copy the object into the buffer.
621                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
622                (buf_ptr as *mut DeviceGetConfigurationResponse)
623                    .write_unaligned((self as *const DeviceGetConfigurationResponse).read());
624                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
625                // done second because the memcpy will write garbage to these bytes.
626            }
627            Ok(())
628        }
629    }
630    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
631        fidl::encoding::Encode<DeviceGetConfigurationResponse, D> for (T0,)
632    {
633        #[inline]
634        unsafe fn encode(
635            self,
636            encoder: &mut fidl::encoding::Encoder<'_, D>,
637            offset: usize,
638            depth: fidl::encoding::Depth,
639        ) -> fidl::Result<()> {
640            encoder.debug_check_bounds::<DeviceGetConfigurationResponse>(offset);
641            // Zero out padding regions. There's no need to apply masks
642            // because the unmasked parts will be overwritten by fields.
643            // Write the fields.
644            self.0.encode(encoder, offset + 0, depth)?;
645            Ok(())
646        }
647    }
648
649    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
650        for DeviceGetConfigurationResponse
651    {
652        #[inline(always)]
653        fn new_empty() -> Self {
654            Self { configuration: fidl::new_empty!(u8, D) }
655        }
656
657        #[inline]
658        unsafe fn decode(
659            &mut self,
660            decoder: &mut fidl::encoding::Decoder<'_, D>,
661            offset: usize,
662            _depth: fidl::encoding::Depth,
663        ) -> fidl::Result<()> {
664            decoder.debug_check_bounds::<Self>(offset);
665            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
666            // Verify that padding bytes are zero.
667            // Copy from the buffer into the object.
668            unsafe {
669                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
670            }
671            Ok(())
672        }
673    }
674
675    impl fidl::encoding::ValueTypeMarker for DeviceGetDeviceDescriptorResponse {
676        type Borrowed<'a> = &'a Self;
677        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
678            value
679        }
680    }
681
682    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceDescriptorResponse {
683        type Owned = Self;
684
685        #[inline(always)]
686        fn inline_align(_context: fidl::encoding::Context) -> usize {
687            1
688        }
689
690        #[inline(always)]
691        fn inline_size(_context: fidl::encoding::Context) -> usize {
692            18
693        }
694        #[inline(always)]
695        fn encode_is_copy() -> bool {
696            true
697        }
698
699        #[inline(always)]
700        fn decode_is_copy() -> bool {
701            true
702        }
703    }
704
705    unsafe impl<D: fidl::encoding::ResourceDialect>
706        fidl::encoding::Encode<DeviceGetDeviceDescriptorResponse, D>
707        for &DeviceGetDeviceDescriptorResponse
708    {
709        #[inline]
710        unsafe fn encode(
711            self,
712            encoder: &mut fidl::encoding::Encoder<'_, D>,
713            offset: usize,
714            _depth: fidl::encoding::Depth,
715        ) -> fidl::Result<()> {
716            encoder.debug_check_bounds::<DeviceGetDeviceDescriptorResponse>(offset);
717            unsafe {
718                // Copy the object into the buffer.
719                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
720                (buf_ptr as *mut DeviceGetDeviceDescriptorResponse)
721                    .write_unaligned((self as *const DeviceGetDeviceDescriptorResponse).read());
722                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
723                // done second because the memcpy will write garbage to these bytes.
724            }
725            Ok(())
726        }
727    }
728    unsafe impl<
729            D: fidl::encoding::ResourceDialect,
730            T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 18>, D>,
731        > fidl::encoding::Encode<DeviceGetDeviceDescriptorResponse, D> for (T0,)
732    {
733        #[inline]
734        unsafe fn encode(
735            self,
736            encoder: &mut fidl::encoding::Encoder<'_, D>,
737            offset: usize,
738            depth: fidl::encoding::Depth,
739        ) -> fidl::Result<()> {
740            encoder.debug_check_bounds::<DeviceGetDeviceDescriptorResponse>(offset);
741            // Zero out padding regions. There's no need to apply masks
742            // because the unmasked parts will be overwritten by fields.
743            // Write the fields.
744            self.0.encode(encoder, offset + 0, depth)?;
745            Ok(())
746        }
747    }
748
749    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
750        for DeviceGetDeviceDescriptorResponse
751    {
752        #[inline(always)]
753        fn new_empty() -> Self {
754            Self { desc: fidl::new_empty!(fidl::encoding::Array<u8, 18>, D) }
755        }
756
757        #[inline]
758        unsafe fn decode(
759            &mut self,
760            decoder: &mut fidl::encoding::Decoder<'_, D>,
761            offset: usize,
762            _depth: fidl::encoding::Depth,
763        ) -> fidl::Result<()> {
764            decoder.debug_check_bounds::<Self>(offset);
765            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
766            // Verify that padding bytes are zero.
767            // Copy from the buffer into the object.
768            unsafe {
769                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 18);
770            }
771            Ok(())
772        }
773    }
774
775    impl fidl::encoding::ValueTypeMarker for DeviceGetDeviceIdResponse {
776        type Borrowed<'a> = &'a Self;
777        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
778            value
779        }
780    }
781
782    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceIdResponse {
783        type Owned = Self;
784
785        #[inline(always)]
786        fn inline_align(_context: fidl::encoding::Context) -> usize {
787            4
788        }
789
790        #[inline(always)]
791        fn inline_size(_context: fidl::encoding::Context) -> usize {
792            4
793        }
794        #[inline(always)]
795        fn encode_is_copy() -> bool {
796            true
797        }
798
799        #[inline(always)]
800        fn decode_is_copy() -> bool {
801            true
802        }
803    }
804
805    unsafe impl<D: fidl::encoding::ResourceDialect>
806        fidl::encoding::Encode<DeviceGetDeviceIdResponse, D> for &DeviceGetDeviceIdResponse
807    {
808        #[inline]
809        unsafe fn encode(
810            self,
811            encoder: &mut fidl::encoding::Encoder<'_, D>,
812            offset: usize,
813            _depth: fidl::encoding::Depth,
814        ) -> fidl::Result<()> {
815            encoder.debug_check_bounds::<DeviceGetDeviceIdResponse>(offset);
816            unsafe {
817                // Copy the object into the buffer.
818                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
819                (buf_ptr as *mut DeviceGetDeviceIdResponse)
820                    .write_unaligned((self as *const DeviceGetDeviceIdResponse).read());
821                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
822                // done second because the memcpy will write garbage to these bytes.
823            }
824            Ok(())
825        }
826    }
827    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
828        fidl::encoding::Encode<DeviceGetDeviceIdResponse, D> for (T0,)
829    {
830        #[inline]
831        unsafe fn encode(
832            self,
833            encoder: &mut fidl::encoding::Encoder<'_, D>,
834            offset: usize,
835            depth: fidl::encoding::Depth,
836        ) -> fidl::Result<()> {
837            encoder.debug_check_bounds::<DeviceGetDeviceIdResponse>(offset);
838            // Zero out padding regions. There's no need to apply masks
839            // because the unmasked parts will be overwritten by fields.
840            // Write the fields.
841            self.0.encode(encoder, offset + 0, depth)?;
842            Ok(())
843        }
844    }
845
846    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
847        for DeviceGetDeviceIdResponse
848    {
849        #[inline(always)]
850        fn new_empty() -> Self {
851            Self { device_id: fidl::new_empty!(u32, D) }
852        }
853
854        #[inline]
855        unsafe fn decode(
856            &mut self,
857            decoder: &mut fidl::encoding::Decoder<'_, D>,
858            offset: usize,
859            _depth: fidl::encoding::Depth,
860        ) -> fidl::Result<()> {
861            decoder.debug_check_bounds::<Self>(offset);
862            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
863            // Verify that padding bytes are zero.
864            // Copy from the buffer into the object.
865            unsafe {
866                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
867            }
868            Ok(())
869        }
870    }
871
872    impl fidl::encoding::ValueTypeMarker for DeviceGetDeviceSpeedResponse {
873        type Borrowed<'a> = &'a Self;
874        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
875            value
876        }
877    }
878
879    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceSpeedResponse {
880        type Owned = Self;
881
882        #[inline(always)]
883        fn inline_align(_context: fidl::encoding::Context) -> usize {
884            4
885        }
886
887        #[inline(always)]
888        fn inline_size(_context: fidl::encoding::Context) -> usize {
889            4
890        }
891        #[inline(always)]
892        fn encode_is_copy() -> bool {
893            true
894        }
895
896        #[inline(always)]
897        fn decode_is_copy() -> bool {
898            true
899        }
900    }
901
902    unsafe impl<D: fidl::encoding::ResourceDialect>
903        fidl::encoding::Encode<DeviceGetDeviceSpeedResponse, D> for &DeviceGetDeviceSpeedResponse
904    {
905        #[inline]
906        unsafe fn encode(
907            self,
908            encoder: &mut fidl::encoding::Encoder<'_, D>,
909            offset: usize,
910            _depth: fidl::encoding::Depth,
911        ) -> fidl::Result<()> {
912            encoder.debug_check_bounds::<DeviceGetDeviceSpeedResponse>(offset);
913            unsafe {
914                // Copy the object into the buffer.
915                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
916                (buf_ptr as *mut DeviceGetDeviceSpeedResponse)
917                    .write_unaligned((self as *const DeviceGetDeviceSpeedResponse).read());
918                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
919                // done second because the memcpy will write garbage to these bytes.
920            }
921            Ok(())
922        }
923    }
924    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
925        fidl::encoding::Encode<DeviceGetDeviceSpeedResponse, D> for (T0,)
926    {
927        #[inline]
928        unsafe fn encode(
929            self,
930            encoder: &mut fidl::encoding::Encoder<'_, D>,
931            offset: usize,
932            depth: fidl::encoding::Depth,
933        ) -> fidl::Result<()> {
934            encoder.debug_check_bounds::<DeviceGetDeviceSpeedResponse>(offset);
935            // Zero out padding regions. There's no need to apply masks
936            // because the unmasked parts will be overwritten by fields.
937            // Write the fields.
938            self.0.encode(encoder, offset + 0, depth)?;
939            Ok(())
940        }
941    }
942
943    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
944        for DeviceGetDeviceSpeedResponse
945    {
946        #[inline(always)]
947        fn new_empty() -> Self {
948            Self { speed: fidl::new_empty!(u32, D) }
949        }
950
951        #[inline]
952        unsafe fn decode(
953            &mut self,
954            decoder: &mut fidl::encoding::Decoder<'_, D>,
955            offset: usize,
956            _depth: fidl::encoding::Depth,
957        ) -> fidl::Result<()> {
958            decoder.debug_check_bounds::<Self>(offset);
959            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
960            // Verify that padding bytes are zero.
961            // Copy from the buffer into the object.
962            unsafe {
963                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
964            }
965            Ok(())
966        }
967    }
968
969    impl fidl::encoding::ValueTypeMarker for DeviceGetHubDeviceIdResponse {
970        type Borrowed<'a> = &'a Self;
971        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
972            value
973        }
974    }
975
976    unsafe impl fidl::encoding::TypeMarker for DeviceGetHubDeviceIdResponse {
977        type Owned = Self;
978
979        #[inline(always)]
980        fn inline_align(_context: fidl::encoding::Context) -> usize {
981            4
982        }
983
984        #[inline(always)]
985        fn inline_size(_context: fidl::encoding::Context) -> usize {
986            4
987        }
988        #[inline(always)]
989        fn encode_is_copy() -> bool {
990            true
991        }
992
993        #[inline(always)]
994        fn decode_is_copy() -> bool {
995            true
996        }
997    }
998
999    unsafe impl<D: fidl::encoding::ResourceDialect>
1000        fidl::encoding::Encode<DeviceGetHubDeviceIdResponse, D> for &DeviceGetHubDeviceIdResponse
1001    {
1002        #[inline]
1003        unsafe fn encode(
1004            self,
1005            encoder: &mut fidl::encoding::Encoder<'_, D>,
1006            offset: usize,
1007            _depth: fidl::encoding::Depth,
1008        ) -> fidl::Result<()> {
1009            encoder.debug_check_bounds::<DeviceGetHubDeviceIdResponse>(offset);
1010            unsafe {
1011                // Copy the object into the buffer.
1012                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1013                (buf_ptr as *mut DeviceGetHubDeviceIdResponse)
1014                    .write_unaligned((self as *const DeviceGetHubDeviceIdResponse).read());
1015                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1016                // done second because the memcpy will write garbage to these bytes.
1017            }
1018            Ok(())
1019        }
1020    }
1021    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1022        fidl::encoding::Encode<DeviceGetHubDeviceIdResponse, D> for (T0,)
1023    {
1024        #[inline]
1025        unsafe fn encode(
1026            self,
1027            encoder: &mut fidl::encoding::Encoder<'_, D>,
1028            offset: usize,
1029            depth: fidl::encoding::Depth,
1030        ) -> fidl::Result<()> {
1031            encoder.debug_check_bounds::<DeviceGetHubDeviceIdResponse>(offset);
1032            // Zero out padding regions. There's no need to apply masks
1033            // because the unmasked parts will be overwritten by fields.
1034            // Write the fields.
1035            self.0.encode(encoder, offset + 0, depth)?;
1036            Ok(())
1037        }
1038    }
1039
1040    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1041        for DeviceGetHubDeviceIdResponse
1042    {
1043        #[inline(always)]
1044        fn new_empty() -> Self {
1045            Self { hub_device_id: fidl::new_empty!(u32, D) }
1046        }
1047
1048        #[inline]
1049        unsafe fn decode(
1050            &mut self,
1051            decoder: &mut fidl::encoding::Decoder<'_, D>,
1052            offset: usize,
1053            _depth: fidl::encoding::Depth,
1054        ) -> fidl::Result<()> {
1055            decoder.debug_check_bounds::<Self>(offset);
1056            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1057            // Verify that padding bytes are zero.
1058            // Copy from the buffer into the object.
1059            unsafe {
1060                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1061            }
1062            Ok(())
1063        }
1064    }
1065
1066    impl fidl::encoding::ValueTypeMarker for DeviceGetStringDescriptorRequest {
1067        type Borrowed<'a> = &'a Self;
1068        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1069            value
1070        }
1071    }
1072
1073    unsafe impl fidl::encoding::TypeMarker for DeviceGetStringDescriptorRequest {
1074        type Owned = Self;
1075
1076        #[inline(always)]
1077        fn inline_align(_context: fidl::encoding::Context) -> usize {
1078            2
1079        }
1080
1081        #[inline(always)]
1082        fn inline_size(_context: fidl::encoding::Context) -> usize {
1083            4
1084        }
1085    }
1086
1087    unsafe impl<D: fidl::encoding::ResourceDialect>
1088        fidl::encoding::Encode<DeviceGetStringDescriptorRequest, D>
1089        for &DeviceGetStringDescriptorRequest
1090    {
1091        #[inline]
1092        unsafe fn encode(
1093            self,
1094            encoder: &mut fidl::encoding::Encoder<'_, D>,
1095            offset: usize,
1096            _depth: fidl::encoding::Depth,
1097        ) -> fidl::Result<()> {
1098            encoder.debug_check_bounds::<DeviceGetStringDescriptorRequest>(offset);
1099            unsafe {
1100                // Copy the object into the buffer.
1101                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1102                (buf_ptr as *mut DeviceGetStringDescriptorRequest)
1103                    .write_unaligned((self as *const DeviceGetStringDescriptorRequest).read());
1104                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1105                // done second because the memcpy will write garbage to these bytes.
1106                let padding_ptr = buf_ptr.offset(0) as *mut u16;
1107                let padding_mask = 0xff00u16;
1108                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
1109            }
1110            Ok(())
1111        }
1112    }
1113    unsafe impl<
1114            D: fidl::encoding::ResourceDialect,
1115            T0: fidl::encoding::Encode<u8, D>,
1116            T1: fidl::encoding::Encode<u16, D>,
1117        > fidl::encoding::Encode<DeviceGetStringDescriptorRequest, D> for (T0, T1)
1118    {
1119        #[inline]
1120        unsafe fn encode(
1121            self,
1122            encoder: &mut fidl::encoding::Encoder<'_, D>,
1123            offset: usize,
1124            depth: fidl::encoding::Depth,
1125        ) -> fidl::Result<()> {
1126            encoder.debug_check_bounds::<DeviceGetStringDescriptorRequest>(offset);
1127            // Zero out padding regions. There's no need to apply masks
1128            // because the unmasked parts will be overwritten by fields.
1129            unsafe {
1130                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1131                (ptr as *mut u16).write_unaligned(0);
1132            }
1133            // Write the fields.
1134            self.0.encode(encoder, offset + 0, depth)?;
1135            self.1.encode(encoder, offset + 2, depth)?;
1136            Ok(())
1137        }
1138    }
1139
1140    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1141        for DeviceGetStringDescriptorRequest
1142    {
1143        #[inline(always)]
1144        fn new_empty() -> Self {
1145            Self { desc_id: fidl::new_empty!(u8, D), lang_id: fidl::new_empty!(u16, D) }
1146        }
1147
1148        #[inline]
1149        unsafe fn decode(
1150            &mut self,
1151            decoder: &mut fidl::encoding::Decoder<'_, D>,
1152            offset: usize,
1153            _depth: fidl::encoding::Depth,
1154        ) -> fidl::Result<()> {
1155            decoder.debug_check_bounds::<Self>(offset);
1156            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1157            // Verify that padding bytes are zero.
1158            let ptr = unsafe { buf_ptr.offset(0) };
1159            let padval = unsafe { (ptr as *const u16).read_unaligned() };
1160            let mask = 0xff00u16;
1161            let maskedval = padval & mask;
1162            if maskedval != 0 {
1163                return Err(fidl::Error::NonZeroPadding {
1164                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1165                });
1166            }
1167            // Copy from the buffer into the object.
1168            unsafe {
1169                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1170            }
1171            Ok(())
1172        }
1173    }
1174
1175    impl fidl::encoding::ValueTypeMarker for DeviceGetStringDescriptorResponse {
1176        type Borrowed<'a> = &'a Self;
1177        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1178            value
1179        }
1180    }
1181
1182    unsafe impl fidl::encoding::TypeMarker for DeviceGetStringDescriptorResponse {
1183        type Owned = Self;
1184
1185        #[inline(always)]
1186        fn inline_align(_context: fidl::encoding::Context) -> usize {
1187            8
1188        }
1189
1190        #[inline(always)]
1191        fn inline_size(_context: fidl::encoding::Context) -> usize {
1192            32
1193        }
1194    }
1195
1196    unsafe impl<D: fidl::encoding::ResourceDialect>
1197        fidl::encoding::Encode<DeviceGetStringDescriptorResponse, D>
1198        for &DeviceGetStringDescriptorResponse
1199    {
1200        #[inline]
1201        unsafe fn encode(
1202            self,
1203            encoder: &mut fidl::encoding::Encoder<'_, D>,
1204            offset: usize,
1205            _depth: fidl::encoding::Depth,
1206        ) -> fidl::Result<()> {
1207            encoder.debug_check_bounds::<DeviceGetStringDescriptorResponse>(offset);
1208            // Delegate to tuple encoding.
1209            fidl::encoding::Encode::<DeviceGetStringDescriptorResponse, D>::encode(
1210                (
1211                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.s),
1212                    <fidl::encoding::BoundedString<384> as fidl::encoding::ValueTypeMarker>::borrow(
1213                        &self.desc,
1214                    ),
1215                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.actual_lang_id),
1216                ),
1217                encoder,
1218                offset,
1219                _depth,
1220            )
1221        }
1222    }
1223    unsafe impl<
1224            D: fidl::encoding::ResourceDialect,
1225            T0: fidl::encoding::Encode<i32, D>,
1226            T1: fidl::encoding::Encode<fidl::encoding::BoundedString<384>, D>,
1227            T2: fidl::encoding::Encode<u16, D>,
1228        > fidl::encoding::Encode<DeviceGetStringDescriptorResponse, D> for (T0, T1, T2)
1229    {
1230        #[inline]
1231        unsafe fn encode(
1232            self,
1233            encoder: &mut fidl::encoding::Encoder<'_, D>,
1234            offset: usize,
1235            depth: fidl::encoding::Depth,
1236        ) -> fidl::Result<()> {
1237            encoder.debug_check_bounds::<DeviceGetStringDescriptorResponse>(offset);
1238            // Zero out padding regions. There's no need to apply masks
1239            // because the unmasked parts will be overwritten by fields.
1240            unsafe {
1241                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1242                (ptr as *mut u64).write_unaligned(0);
1243            }
1244            unsafe {
1245                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1246                (ptr as *mut u64).write_unaligned(0);
1247            }
1248            // Write the fields.
1249            self.0.encode(encoder, offset + 0, depth)?;
1250            self.1.encode(encoder, offset + 8, depth)?;
1251            self.2.encode(encoder, offset + 24, depth)?;
1252            Ok(())
1253        }
1254    }
1255
1256    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1257        for DeviceGetStringDescriptorResponse
1258    {
1259        #[inline(always)]
1260        fn new_empty() -> Self {
1261            Self {
1262                s: fidl::new_empty!(i32, D),
1263                desc: fidl::new_empty!(fidl::encoding::BoundedString<384>, D),
1264                actual_lang_id: fidl::new_empty!(u16, D),
1265            }
1266        }
1267
1268        #[inline]
1269        unsafe fn decode(
1270            &mut self,
1271            decoder: &mut fidl::encoding::Decoder<'_, D>,
1272            offset: usize,
1273            _depth: fidl::encoding::Depth,
1274        ) -> fidl::Result<()> {
1275            decoder.debug_check_bounds::<Self>(offset);
1276            // Verify that padding bytes are zero.
1277            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1278            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1279            let mask = 0xffffffff00000000u64;
1280            let maskedval = padval & mask;
1281            if maskedval != 0 {
1282                return Err(fidl::Error::NonZeroPadding {
1283                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1284                });
1285            }
1286            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1287            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1288            let mask = 0xffffffffffff0000u64;
1289            let maskedval = padval & mask;
1290            if maskedval != 0 {
1291                return Err(fidl::Error::NonZeroPadding {
1292                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1293                });
1294            }
1295            fidl::decode!(i32, D, &mut self.s, decoder, offset + 0, _depth)?;
1296            fidl::decode!(
1297                fidl::encoding::BoundedString<384>,
1298                D,
1299                &mut self.desc,
1300                decoder,
1301                offset + 8,
1302                _depth
1303            )?;
1304            fidl::decode!(u16, D, &mut self.actual_lang_id, decoder, offset + 24, _depth)?;
1305            Ok(())
1306        }
1307    }
1308
1309    impl fidl::encoding::ValueTypeMarker for DeviceSetConfigurationRequest {
1310        type Borrowed<'a> = &'a Self;
1311        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1312            value
1313        }
1314    }
1315
1316    unsafe impl fidl::encoding::TypeMarker for DeviceSetConfigurationRequest {
1317        type Owned = Self;
1318
1319        #[inline(always)]
1320        fn inline_align(_context: fidl::encoding::Context) -> usize {
1321            1
1322        }
1323
1324        #[inline(always)]
1325        fn inline_size(_context: fidl::encoding::Context) -> usize {
1326            1
1327        }
1328        #[inline(always)]
1329        fn encode_is_copy() -> bool {
1330            true
1331        }
1332
1333        #[inline(always)]
1334        fn decode_is_copy() -> bool {
1335            true
1336        }
1337    }
1338
1339    unsafe impl<D: fidl::encoding::ResourceDialect>
1340        fidl::encoding::Encode<DeviceSetConfigurationRequest, D>
1341        for &DeviceSetConfigurationRequest
1342    {
1343        #[inline]
1344        unsafe fn encode(
1345            self,
1346            encoder: &mut fidl::encoding::Encoder<'_, D>,
1347            offset: usize,
1348            _depth: fidl::encoding::Depth,
1349        ) -> fidl::Result<()> {
1350            encoder.debug_check_bounds::<DeviceSetConfigurationRequest>(offset);
1351            unsafe {
1352                // Copy the object into the buffer.
1353                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1354                (buf_ptr as *mut DeviceSetConfigurationRequest)
1355                    .write_unaligned((self as *const DeviceSetConfigurationRequest).read());
1356                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1357                // done second because the memcpy will write garbage to these bytes.
1358            }
1359            Ok(())
1360        }
1361    }
1362    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
1363        fidl::encoding::Encode<DeviceSetConfigurationRequest, D> for (T0,)
1364    {
1365        #[inline]
1366        unsafe fn encode(
1367            self,
1368            encoder: &mut fidl::encoding::Encoder<'_, D>,
1369            offset: usize,
1370            depth: fidl::encoding::Depth,
1371        ) -> fidl::Result<()> {
1372            encoder.debug_check_bounds::<DeviceSetConfigurationRequest>(offset);
1373            // Zero out padding regions. There's no need to apply masks
1374            // because the unmasked parts will be overwritten by fields.
1375            // Write the fields.
1376            self.0.encode(encoder, offset + 0, depth)?;
1377            Ok(())
1378        }
1379    }
1380
1381    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1382        for DeviceSetConfigurationRequest
1383    {
1384        #[inline(always)]
1385        fn new_empty() -> Self {
1386            Self { configuration: fidl::new_empty!(u8, D) }
1387        }
1388
1389        #[inline]
1390        unsafe fn decode(
1391            &mut self,
1392            decoder: &mut fidl::encoding::Decoder<'_, D>,
1393            offset: usize,
1394            _depth: fidl::encoding::Depth,
1395        ) -> fidl::Result<()> {
1396            decoder.debug_check_bounds::<Self>(offset);
1397            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1398            // Verify that padding bytes are zero.
1399            // Copy from the buffer into the object.
1400            unsafe {
1401                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
1402            }
1403            Ok(())
1404        }
1405    }
1406
1407    impl fidl::encoding::ValueTypeMarker for DeviceSetConfigurationResponse {
1408        type Borrowed<'a> = &'a Self;
1409        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1410            value
1411        }
1412    }
1413
1414    unsafe impl fidl::encoding::TypeMarker for DeviceSetConfigurationResponse {
1415        type Owned = Self;
1416
1417        #[inline(always)]
1418        fn inline_align(_context: fidl::encoding::Context) -> usize {
1419            4
1420        }
1421
1422        #[inline(always)]
1423        fn inline_size(_context: fidl::encoding::Context) -> usize {
1424            4
1425        }
1426        #[inline(always)]
1427        fn encode_is_copy() -> bool {
1428            true
1429        }
1430
1431        #[inline(always)]
1432        fn decode_is_copy() -> bool {
1433            true
1434        }
1435    }
1436
1437    unsafe impl<D: fidl::encoding::ResourceDialect>
1438        fidl::encoding::Encode<DeviceSetConfigurationResponse, D>
1439        for &DeviceSetConfigurationResponse
1440    {
1441        #[inline]
1442        unsafe fn encode(
1443            self,
1444            encoder: &mut fidl::encoding::Encoder<'_, D>,
1445            offset: usize,
1446            _depth: fidl::encoding::Depth,
1447        ) -> fidl::Result<()> {
1448            encoder.debug_check_bounds::<DeviceSetConfigurationResponse>(offset);
1449            unsafe {
1450                // Copy the object into the buffer.
1451                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1452                (buf_ptr as *mut DeviceSetConfigurationResponse)
1453                    .write_unaligned((self as *const DeviceSetConfigurationResponse).read());
1454                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1455                // done second because the memcpy will write garbage to these bytes.
1456            }
1457            Ok(())
1458        }
1459    }
1460    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
1461        fidl::encoding::Encode<DeviceSetConfigurationResponse, D> for (T0,)
1462    {
1463        #[inline]
1464        unsafe fn encode(
1465            self,
1466            encoder: &mut fidl::encoding::Encoder<'_, D>,
1467            offset: usize,
1468            depth: fidl::encoding::Depth,
1469        ) -> fidl::Result<()> {
1470            encoder.debug_check_bounds::<DeviceSetConfigurationResponse>(offset);
1471            // Zero out padding regions. There's no need to apply masks
1472            // because the unmasked parts will be overwritten by fields.
1473            // Write the fields.
1474            self.0.encode(encoder, offset + 0, depth)?;
1475            Ok(())
1476        }
1477    }
1478
1479    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1480        for DeviceSetConfigurationResponse
1481    {
1482        #[inline(always)]
1483        fn new_empty() -> Self {
1484            Self { s: fidl::new_empty!(i32, D) }
1485        }
1486
1487        #[inline]
1488        unsafe fn decode(
1489            &mut self,
1490            decoder: &mut fidl::encoding::Decoder<'_, D>,
1491            offset: usize,
1492            _depth: fidl::encoding::Depth,
1493        ) -> fidl::Result<()> {
1494            decoder.debug_check_bounds::<Self>(offset);
1495            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1496            // Verify that padding bytes are zero.
1497            // Copy from the buffer into the object.
1498            unsafe {
1499                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1500            }
1501            Ok(())
1502        }
1503    }
1504
1505    impl fidl::encoding::ValueTypeMarker for DeviceSetInterfaceRequest {
1506        type Borrowed<'a> = &'a Self;
1507        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1508            value
1509        }
1510    }
1511
1512    unsafe impl fidl::encoding::TypeMarker for DeviceSetInterfaceRequest {
1513        type Owned = Self;
1514
1515        #[inline(always)]
1516        fn inline_align(_context: fidl::encoding::Context) -> usize {
1517            1
1518        }
1519
1520        #[inline(always)]
1521        fn inline_size(_context: fidl::encoding::Context) -> usize {
1522            2
1523        }
1524        #[inline(always)]
1525        fn encode_is_copy() -> bool {
1526            true
1527        }
1528
1529        #[inline(always)]
1530        fn decode_is_copy() -> bool {
1531            true
1532        }
1533    }
1534
1535    unsafe impl<D: fidl::encoding::ResourceDialect>
1536        fidl::encoding::Encode<DeviceSetInterfaceRequest, D> for &DeviceSetInterfaceRequest
1537    {
1538        #[inline]
1539        unsafe fn encode(
1540            self,
1541            encoder: &mut fidl::encoding::Encoder<'_, D>,
1542            offset: usize,
1543            _depth: fidl::encoding::Depth,
1544        ) -> fidl::Result<()> {
1545            encoder.debug_check_bounds::<DeviceSetInterfaceRequest>(offset);
1546            unsafe {
1547                // Copy the object into the buffer.
1548                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1549                (buf_ptr as *mut DeviceSetInterfaceRequest)
1550                    .write_unaligned((self as *const DeviceSetInterfaceRequest).read());
1551                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1552                // done second because the memcpy will write garbage to these bytes.
1553            }
1554            Ok(())
1555        }
1556    }
1557    unsafe impl<
1558            D: fidl::encoding::ResourceDialect,
1559            T0: fidl::encoding::Encode<u8, D>,
1560            T1: fidl::encoding::Encode<u8, D>,
1561        > fidl::encoding::Encode<DeviceSetInterfaceRequest, D> for (T0, T1)
1562    {
1563        #[inline]
1564        unsafe fn encode(
1565            self,
1566            encoder: &mut fidl::encoding::Encoder<'_, D>,
1567            offset: usize,
1568            depth: fidl::encoding::Depth,
1569        ) -> fidl::Result<()> {
1570            encoder.debug_check_bounds::<DeviceSetInterfaceRequest>(offset);
1571            // Zero out padding regions. There's no need to apply masks
1572            // because the unmasked parts will be overwritten by fields.
1573            // Write the fields.
1574            self.0.encode(encoder, offset + 0, depth)?;
1575            self.1.encode(encoder, offset + 1, depth)?;
1576            Ok(())
1577        }
1578    }
1579
1580    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1581        for DeviceSetInterfaceRequest
1582    {
1583        #[inline(always)]
1584        fn new_empty() -> Self {
1585            Self { interface_number: fidl::new_empty!(u8, D), alt_setting: fidl::new_empty!(u8, D) }
1586        }
1587
1588        #[inline]
1589        unsafe fn decode(
1590            &mut self,
1591            decoder: &mut fidl::encoding::Decoder<'_, D>,
1592            offset: usize,
1593            _depth: fidl::encoding::Depth,
1594        ) -> fidl::Result<()> {
1595            decoder.debug_check_bounds::<Self>(offset);
1596            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1597            // Verify that padding bytes are zero.
1598            // Copy from the buffer into the object.
1599            unsafe {
1600                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
1601            }
1602            Ok(())
1603        }
1604    }
1605
1606    impl fidl::encoding::ValueTypeMarker for DeviceSetInterfaceResponse {
1607        type Borrowed<'a> = &'a Self;
1608        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1609            value
1610        }
1611    }
1612
1613    unsafe impl fidl::encoding::TypeMarker for DeviceSetInterfaceResponse {
1614        type Owned = Self;
1615
1616        #[inline(always)]
1617        fn inline_align(_context: fidl::encoding::Context) -> usize {
1618            4
1619        }
1620
1621        #[inline(always)]
1622        fn inline_size(_context: fidl::encoding::Context) -> usize {
1623            4
1624        }
1625        #[inline(always)]
1626        fn encode_is_copy() -> bool {
1627            true
1628        }
1629
1630        #[inline(always)]
1631        fn decode_is_copy() -> bool {
1632            true
1633        }
1634    }
1635
1636    unsafe impl<D: fidl::encoding::ResourceDialect>
1637        fidl::encoding::Encode<DeviceSetInterfaceResponse, D> for &DeviceSetInterfaceResponse
1638    {
1639        #[inline]
1640        unsafe fn encode(
1641            self,
1642            encoder: &mut fidl::encoding::Encoder<'_, D>,
1643            offset: usize,
1644            _depth: fidl::encoding::Depth,
1645        ) -> fidl::Result<()> {
1646            encoder.debug_check_bounds::<DeviceSetInterfaceResponse>(offset);
1647            unsafe {
1648                // Copy the object into the buffer.
1649                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1650                (buf_ptr as *mut DeviceSetInterfaceResponse)
1651                    .write_unaligned((self as *const DeviceSetInterfaceResponse).read());
1652                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1653                // done second because the memcpy will write garbage to these bytes.
1654            }
1655            Ok(())
1656        }
1657    }
1658    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
1659        fidl::encoding::Encode<DeviceSetInterfaceResponse, D> for (T0,)
1660    {
1661        #[inline]
1662        unsafe fn encode(
1663            self,
1664            encoder: &mut fidl::encoding::Encoder<'_, D>,
1665            offset: usize,
1666            depth: fidl::encoding::Depth,
1667        ) -> fidl::Result<()> {
1668            encoder.debug_check_bounds::<DeviceSetInterfaceResponse>(offset);
1669            // Zero out padding regions. There's no need to apply masks
1670            // because the unmasked parts will be overwritten by fields.
1671            // Write the fields.
1672            self.0.encode(encoder, offset + 0, depth)?;
1673            Ok(())
1674        }
1675    }
1676
1677    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1678        for DeviceSetInterfaceResponse
1679    {
1680        #[inline(always)]
1681        fn new_empty() -> Self {
1682            Self { s: fidl::new_empty!(i32, D) }
1683        }
1684
1685        #[inline]
1686        unsafe fn decode(
1687            &mut self,
1688            decoder: &mut fidl::encoding::Decoder<'_, D>,
1689            offset: usize,
1690            _depth: fidl::encoding::Depth,
1691        ) -> fidl::Result<()> {
1692            decoder.debug_check_bounds::<Self>(offset);
1693            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1694            // Verify that padding bytes are zero.
1695            // Copy from the buffer into the object.
1696            unsafe {
1697                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1698            }
1699            Ok(())
1700        }
1701    }
1702}