Skip to main content

fidl_fuchsia_hardware_spi_common/
fidl_fuchsia_hardware_spi_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
11pub const MAX_TRANSFER_SIZE: u32 = 8196;
12
13#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14#[repr(C)]
15pub struct DeviceAssertCsResponse {
16    pub status: i32,
17}
18
19impl fidl::Persistable for DeviceAssertCsResponse {}
20
21#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct DeviceCanAssertCsResponse {
23    pub can: bool,
24}
25
26impl fidl::Persistable for DeviceCanAssertCsResponse {}
27
28#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29#[repr(C)]
30pub struct DeviceDeassertCsResponse {
31    pub status: i32,
32}
33
34impl fidl::Persistable for DeviceDeassertCsResponse {}
35
36#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct DeviceExchangeVectorRequest {
38    pub txdata: Vec<u8>,
39}
40
41impl fidl::Persistable for DeviceExchangeVectorRequest {}
42
43#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct DeviceExchangeVectorResponse {
45    pub status: i32,
46    pub rxdata: Vec<u8>,
47}
48
49impl fidl::Persistable for DeviceExchangeVectorResponse {}
50
51#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
52#[repr(C)]
53pub struct DeviceReceiveVectorRequest {
54    pub size: u32,
55}
56
57impl fidl::Persistable for DeviceReceiveVectorRequest {}
58
59#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
60pub struct DeviceReceiveVectorResponse {
61    pub status: i32,
62    pub data: Vec<u8>,
63}
64
65impl fidl::Persistable for DeviceReceiveVectorResponse {}
66
67#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
68pub struct DeviceTransmitVectorRequest {
69    pub data: Vec<u8>,
70}
71
72impl fidl::Persistable for DeviceTransmitVectorRequest {}
73
74#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75#[repr(C)]
76pub struct DeviceTransmitVectorResponse {
77    pub status: i32,
78}
79
80impl fidl::Persistable for DeviceTransmitVectorResponse {}
81
82pub mod controller_ordinals {
83    pub const OPEN_SESSION: u64 = 0x19d861074d409b34;
84}
85
86pub mod device_ordinals {
87    pub const TRANSMIT: u64 = 0x791970e4c961b0bf;
88    pub const RECEIVE: u64 = 0x1c31986cc443db59;
89    pub const EXCHANGE: u64 = 0x6ddad3b45d5deccc;
90    pub const REGISTER_VMO: u64 = 0x31df51e1e6ea4a15;
91    pub const UNREGISTER_VMO: u64 = 0x1194e9b693827109;
92    pub const TRANSMIT_VECTOR: u64 = 0x46a82725fcb5e5d2;
93    pub const RECEIVE_VECTOR: u64 = 0x37b160ed6bdd3fd6;
94    pub const EXCHANGE_VECTOR: u64 = 0x7facbdec2c3c03bd;
95    pub const CAN_ASSERT_CS: u64 = 0x1f8c12c089a9a874;
96    pub const ASSERT_CS: u64 = 0x4ff66add7bd91ce6;
97    pub const DEASSERT_CS: u64 = 0x5e4cd660a0bc0db8;
98}
99
100pub mod test_ordinals {
101    pub const GET: u64 = 0x64166e3a6984b1d9;
102    pub const CONNECT_SPI_LOOPBACK: u64 = 0x420403db2950bb2a;
103}
104
105mod internal {
106    use super::*;
107
108    impl fidl::encoding::ValueTypeMarker for DeviceAssertCsResponse {
109        type Borrowed<'a> = &'a Self;
110        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
111            value
112        }
113    }
114
115    unsafe impl fidl::encoding::TypeMarker for DeviceAssertCsResponse {
116        type Owned = Self;
117
118        #[inline(always)]
119        fn inline_align(_context: fidl::encoding::Context) -> usize {
120            4
121        }
122
123        #[inline(always)]
124        fn inline_size(_context: fidl::encoding::Context) -> usize {
125            4
126        }
127        #[inline(always)]
128        fn encode_is_copy() -> bool {
129            true
130        }
131
132        #[inline(always)]
133        fn decode_is_copy() -> bool {
134            true
135        }
136    }
137
138    unsafe impl<D: fidl::encoding::ResourceDialect>
139        fidl::encoding::Encode<DeviceAssertCsResponse, D> for &DeviceAssertCsResponse
140    {
141        #[inline]
142        unsafe fn encode(
143            self,
144            encoder: &mut fidl::encoding::Encoder<'_, D>,
145            offset: usize,
146            _depth: fidl::encoding::Depth,
147        ) -> fidl::Result<()> {
148            encoder.debug_check_bounds::<DeviceAssertCsResponse>(offset);
149            unsafe {
150                // Copy the object into the buffer.
151                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
152                (buf_ptr as *mut DeviceAssertCsResponse)
153                    .write_unaligned((self as *const DeviceAssertCsResponse).read());
154                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
155                // done second because the memcpy will write garbage to these bytes.
156            }
157            Ok(())
158        }
159    }
160    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
161        fidl::encoding::Encode<DeviceAssertCsResponse, D> for (T0,)
162    {
163        #[inline]
164        unsafe fn encode(
165            self,
166            encoder: &mut fidl::encoding::Encoder<'_, D>,
167            offset: usize,
168            depth: fidl::encoding::Depth,
169        ) -> fidl::Result<()> {
170            encoder.debug_check_bounds::<DeviceAssertCsResponse>(offset);
171            // Zero out padding regions. There's no need to apply masks
172            // because the unmasked parts will be overwritten by fields.
173            // Write the fields.
174            self.0.encode(encoder, offset + 0, depth)?;
175            Ok(())
176        }
177    }
178
179    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
180        for DeviceAssertCsResponse
181    {
182        #[inline(always)]
183        fn new_empty() -> Self {
184            Self { status: fidl::new_empty!(i32, D) }
185        }
186
187        #[inline]
188        unsafe fn decode(
189            &mut self,
190            decoder: &mut fidl::encoding::Decoder<'_, D>,
191            offset: usize,
192            _depth: fidl::encoding::Depth,
193        ) -> fidl::Result<()> {
194            decoder.debug_check_bounds::<Self>(offset);
195            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
196            // Verify that padding bytes are zero.
197            // Copy from the buffer into the object.
198            unsafe {
199                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
200            }
201            Ok(())
202        }
203    }
204
205    impl fidl::encoding::ValueTypeMarker for DeviceCanAssertCsResponse {
206        type Borrowed<'a> = &'a Self;
207        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
208            value
209        }
210    }
211
212    unsafe impl fidl::encoding::TypeMarker for DeviceCanAssertCsResponse {
213        type Owned = Self;
214
215        #[inline(always)]
216        fn inline_align(_context: fidl::encoding::Context) -> usize {
217            1
218        }
219
220        #[inline(always)]
221        fn inline_size(_context: fidl::encoding::Context) -> usize {
222            1
223        }
224    }
225
226    unsafe impl<D: fidl::encoding::ResourceDialect>
227        fidl::encoding::Encode<DeviceCanAssertCsResponse, D> for &DeviceCanAssertCsResponse
228    {
229        #[inline]
230        unsafe fn encode(
231            self,
232            encoder: &mut fidl::encoding::Encoder<'_, D>,
233            offset: usize,
234            _depth: fidl::encoding::Depth,
235        ) -> fidl::Result<()> {
236            encoder.debug_check_bounds::<DeviceCanAssertCsResponse>(offset);
237            // Delegate to tuple encoding.
238            fidl::encoding::Encode::<DeviceCanAssertCsResponse, D>::encode(
239                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.can),),
240                encoder,
241                offset,
242                _depth,
243            )
244        }
245    }
246    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
247        fidl::encoding::Encode<DeviceCanAssertCsResponse, D> for (T0,)
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::<DeviceCanAssertCsResponse>(offset);
257            // Zero out padding regions. There's no need to apply masks
258            // because the unmasked parts will be overwritten by fields.
259            // Write the fields.
260            self.0.encode(encoder, offset + 0, depth)?;
261            Ok(())
262        }
263    }
264
265    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
266        for DeviceCanAssertCsResponse
267    {
268        #[inline(always)]
269        fn new_empty() -> Self {
270            Self { can: fidl::new_empty!(bool, D) }
271        }
272
273        #[inline]
274        unsafe fn decode(
275            &mut self,
276            decoder: &mut fidl::encoding::Decoder<'_, D>,
277            offset: usize,
278            _depth: fidl::encoding::Depth,
279        ) -> fidl::Result<()> {
280            decoder.debug_check_bounds::<Self>(offset);
281            // Verify that padding bytes are zero.
282            fidl::decode!(bool, D, &mut self.can, decoder, offset + 0, _depth)?;
283            Ok(())
284        }
285    }
286
287    impl fidl::encoding::ValueTypeMarker for DeviceDeassertCsResponse {
288        type Borrowed<'a> = &'a Self;
289        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
290            value
291        }
292    }
293
294    unsafe impl fidl::encoding::TypeMarker for DeviceDeassertCsResponse {
295        type Owned = Self;
296
297        #[inline(always)]
298        fn inline_align(_context: fidl::encoding::Context) -> usize {
299            4
300        }
301
302        #[inline(always)]
303        fn inline_size(_context: fidl::encoding::Context) -> usize {
304            4
305        }
306        #[inline(always)]
307        fn encode_is_copy() -> bool {
308            true
309        }
310
311        #[inline(always)]
312        fn decode_is_copy() -> bool {
313            true
314        }
315    }
316
317    unsafe impl<D: fidl::encoding::ResourceDialect>
318        fidl::encoding::Encode<DeviceDeassertCsResponse, D> for &DeviceDeassertCsResponse
319    {
320        #[inline]
321        unsafe fn encode(
322            self,
323            encoder: &mut fidl::encoding::Encoder<'_, D>,
324            offset: usize,
325            _depth: fidl::encoding::Depth,
326        ) -> fidl::Result<()> {
327            encoder.debug_check_bounds::<DeviceDeassertCsResponse>(offset);
328            unsafe {
329                // Copy the object into the buffer.
330                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
331                (buf_ptr as *mut DeviceDeassertCsResponse)
332                    .write_unaligned((self as *const DeviceDeassertCsResponse).read());
333                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
334                // done second because the memcpy will write garbage to these bytes.
335            }
336            Ok(())
337        }
338    }
339    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
340        fidl::encoding::Encode<DeviceDeassertCsResponse, D> for (T0,)
341    {
342        #[inline]
343        unsafe fn encode(
344            self,
345            encoder: &mut fidl::encoding::Encoder<'_, D>,
346            offset: usize,
347            depth: fidl::encoding::Depth,
348        ) -> fidl::Result<()> {
349            encoder.debug_check_bounds::<DeviceDeassertCsResponse>(offset);
350            // Zero out padding regions. There's no need to apply masks
351            // because the unmasked parts will be overwritten by fields.
352            // Write the fields.
353            self.0.encode(encoder, offset + 0, depth)?;
354            Ok(())
355        }
356    }
357
358    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
359        for DeviceDeassertCsResponse
360    {
361        #[inline(always)]
362        fn new_empty() -> Self {
363            Self { status: fidl::new_empty!(i32, D) }
364        }
365
366        #[inline]
367        unsafe fn decode(
368            &mut self,
369            decoder: &mut fidl::encoding::Decoder<'_, D>,
370            offset: usize,
371            _depth: fidl::encoding::Depth,
372        ) -> fidl::Result<()> {
373            decoder.debug_check_bounds::<Self>(offset);
374            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
375            // Verify that padding bytes are zero.
376            // Copy from the buffer into the object.
377            unsafe {
378                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
379            }
380            Ok(())
381        }
382    }
383
384    impl fidl::encoding::ValueTypeMarker for DeviceExchangeVectorRequest {
385        type Borrowed<'a> = &'a Self;
386        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
387            value
388        }
389    }
390
391    unsafe impl fidl::encoding::TypeMarker for DeviceExchangeVectorRequest {
392        type Owned = Self;
393
394        #[inline(always)]
395        fn inline_align(_context: fidl::encoding::Context) -> usize {
396            8
397        }
398
399        #[inline(always)]
400        fn inline_size(_context: fidl::encoding::Context) -> usize {
401            16
402        }
403    }
404
405    unsafe impl<D: fidl::encoding::ResourceDialect>
406        fidl::encoding::Encode<DeviceExchangeVectorRequest, D> for &DeviceExchangeVectorRequest
407    {
408        #[inline]
409        unsafe fn encode(
410            self,
411            encoder: &mut fidl::encoding::Encoder<'_, D>,
412            offset: usize,
413            _depth: fidl::encoding::Depth,
414        ) -> fidl::Result<()> {
415            encoder.debug_check_bounds::<DeviceExchangeVectorRequest>(offset);
416            // Delegate to tuple encoding.
417            fidl::encoding::Encode::<DeviceExchangeVectorRequest, D>::encode(
418                (<fidl::encoding::Vector<u8, 8196> as fidl::encoding::ValueTypeMarker>::borrow(
419                    &self.txdata,
420                ),),
421                encoder,
422                offset,
423                _depth,
424            )
425        }
426    }
427    unsafe impl<
428        D: fidl::encoding::ResourceDialect,
429        T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 8196>, D>,
430    > fidl::encoding::Encode<DeviceExchangeVectorRequest, D> for (T0,)
431    {
432        #[inline]
433        unsafe fn encode(
434            self,
435            encoder: &mut fidl::encoding::Encoder<'_, D>,
436            offset: usize,
437            depth: fidl::encoding::Depth,
438        ) -> fidl::Result<()> {
439            encoder.debug_check_bounds::<DeviceExchangeVectorRequest>(offset);
440            // Zero out padding regions. There's no need to apply masks
441            // because the unmasked parts will be overwritten by fields.
442            // Write the fields.
443            self.0.encode(encoder, offset + 0, depth)?;
444            Ok(())
445        }
446    }
447
448    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
449        for DeviceExchangeVectorRequest
450    {
451        #[inline(always)]
452        fn new_empty() -> Self {
453            Self { txdata: fidl::new_empty!(fidl::encoding::Vector<u8, 8196>, D) }
454        }
455
456        #[inline]
457        unsafe fn decode(
458            &mut self,
459            decoder: &mut fidl::encoding::Decoder<'_, D>,
460            offset: usize,
461            _depth: fidl::encoding::Depth,
462        ) -> fidl::Result<()> {
463            decoder.debug_check_bounds::<Self>(offset);
464            // Verify that padding bytes are zero.
465            fidl::decode!(fidl::encoding::Vector<u8, 8196>, D, &mut self.txdata, decoder, offset + 0, _depth)?;
466            Ok(())
467        }
468    }
469
470    impl fidl::encoding::ValueTypeMarker for DeviceExchangeVectorResponse {
471        type Borrowed<'a> = &'a Self;
472        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
473            value
474        }
475    }
476
477    unsafe impl fidl::encoding::TypeMarker for DeviceExchangeVectorResponse {
478        type Owned = Self;
479
480        #[inline(always)]
481        fn inline_align(_context: fidl::encoding::Context) -> usize {
482            8
483        }
484
485        #[inline(always)]
486        fn inline_size(_context: fidl::encoding::Context) -> usize {
487            24
488        }
489    }
490
491    unsafe impl<D: fidl::encoding::ResourceDialect>
492        fidl::encoding::Encode<DeviceExchangeVectorResponse, D> for &DeviceExchangeVectorResponse
493    {
494        #[inline]
495        unsafe fn encode(
496            self,
497            encoder: &mut fidl::encoding::Encoder<'_, D>,
498            offset: usize,
499            _depth: fidl::encoding::Depth,
500        ) -> fidl::Result<()> {
501            encoder.debug_check_bounds::<DeviceExchangeVectorResponse>(offset);
502            // Delegate to tuple encoding.
503            fidl::encoding::Encode::<DeviceExchangeVectorResponse, D>::encode(
504                (
505                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
506                    <fidl::encoding::Vector<u8, 8196> as fidl::encoding::ValueTypeMarker>::borrow(
507                        &self.rxdata,
508                    ),
509                ),
510                encoder,
511                offset,
512                _depth,
513            )
514        }
515    }
516    unsafe impl<
517        D: fidl::encoding::ResourceDialect,
518        T0: fidl::encoding::Encode<i32, D>,
519        T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 8196>, D>,
520    > fidl::encoding::Encode<DeviceExchangeVectorResponse, D> for (T0, T1)
521    {
522        #[inline]
523        unsafe fn encode(
524            self,
525            encoder: &mut fidl::encoding::Encoder<'_, D>,
526            offset: usize,
527            depth: fidl::encoding::Depth,
528        ) -> fidl::Result<()> {
529            encoder.debug_check_bounds::<DeviceExchangeVectorResponse>(offset);
530            // Zero out padding regions. There's no need to apply masks
531            // because the unmasked parts will be overwritten by fields.
532            unsafe {
533                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
534                (ptr as *mut u64).write_unaligned(0);
535            }
536            // Write the fields.
537            self.0.encode(encoder, offset + 0, depth)?;
538            self.1.encode(encoder, offset + 8, depth)?;
539            Ok(())
540        }
541    }
542
543    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
544        for DeviceExchangeVectorResponse
545    {
546        #[inline(always)]
547        fn new_empty() -> Self {
548            Self {
549                status: fidl::new_empty!(i32, D),
550                rxdata: fidl::new_empty!(fidl::encoding::Vector<u8, 8196>, D),
551            }
552        }
553
554        #[inline]
555        unsafe fn decode(
556            &mut self,
557            decoder: &mut fidl::encoding::Decoder<'_, D>,
558            offset: usize,
559            _depth: fidl::encoding::Depth,
560        ) -> fidl::Result<()> {
561            decoder.debug_check_bounds::<Self>(offset);
562            // Verify that padding bytes are zero.
563            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
564            let padval = unsafe { (ptr as *const u64).read_unaligned() };
565            let mask = 0xffffffff00000000u64;
566            let maskedval = padval & mask;
567            if maskedval != 0 {
568                return Err(fidl::Error::NonZeroPadding {
569                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
570                });
571            }
572            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
573            fidl::decode!(fidl::encoding::Vector<u8, 8196>, D, &mut self.rxdata, decoder, offset + 8, _depth)?;
574            Ok(())
575        }
576    }
577
578    impl fidl::encoding::ValueTypeMarker for DeviceReceiveVectorRequest {
579        type Borrowed<'a> = &'a Self;
580        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
581            value
582        }
583    }
584
585    unsafe impl fidl::encoding::TypeMarker for DeviceReceiveVectorRequest {
586        type Owned = Self;
587
588        #[inline(always)]
589        fn inline_align(_context: fidl::encoding::Context) -> usize {
590            4
591        }
592
593        #[inline(always)]
594        fn inline_size(_context: fidl::encoding::Context) -> usize {
595            4
596        }
597        #[inline(always)]
598        fn encode_is_copy() -> bool {
599            true
600        }
601
602        #[inline(always)]
603        fn decode_is_copy() -> bool {
604            true
605        }
606    }
607
608    unsafe impl<D: fidl::encoding::ResourceDialect>
609        fidl::encoding::Encode<DeviceReceiveVectorRequest, D> for &DeviceReceiveVectorRequest
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::<DeviceReceiveVectorRequest>(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 DeviceReceiveVectorRequest)
623                    .write_unaligned((self as *const DeviceReceiveVectorRequest).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<u32, D>>
631        fidl::encoding::Encode<DeviceReceiveVectorRequest, 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::<DeviceReceiveVectorRequest>(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 DeviceReceiveVectorRequest
651    {
652        #[inline(always)]
653        fn new_empty() -> Self {
654            Self { size: fidl::new_empty!(u32, 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, 4);
670            }
671            Ok(())
672        }
673    }
674
675    impl fidl::encoding::ValueTypeMarker for DeviceReceiveVectorResponse {
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 DeviceReceiveVectorResponse {
683        type Owned = Self;
684
685        #[inline(always)]
686        fn inline_align(_context: fidl::encoding::Context) -> usize {
687            8
688        }
689
690        #[inline(always)]
691        fn inline_size(_context: fidl::encoding::Context) -> usize {
692            24
693        }
694    }
695
696    unsafe impl<D: fidl::encoding::ResourceDialect>
697        fidl::encoding::Encode<DeviceReceiveVectorResponse, D> for &DeviceReceiveVectorResponse
698    {
699        #[inline]
700        unsafe fn encode(
701            self,
702            encoder: &mut fidl::encoding::Encoder<'_, D>,
703            offset: usize,
704            _depth: fidl::encoding::Depth,
705        ) -> fidl::Result<()> {
706            encoder.debug_check_bounds::<DeviceReceiveVectorResponse>(offset);
707            // Delegate to tuple encoding.
708            fidl::encoding::Encode::<DeviceReceiveVectorResponse, D>::encode(
709                (
710                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
711                    <fidl::encoding::Vector<u8, 8196> as fidl::encoding::ValueTypeMarker>::borrow(
712                        &self.data,
713                    ),
714                ),
715                encoder,
716                offset,
717                _depth,
718            )
719        }
720    }
721    unsafe impl<
722        D: fidl::encoding::ResourceDialect,
723        T0: fidl::encoding::Encode<i32, D>,
724        T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 8196>, D>,
725    > fidl::encoding::Encode<DeviceReceiveVectorResponse, D> for (T0, T1)
726    {
727        #[inline]
728        unsafe fn encode(
729            self,
730            encoder: &mut fidl::encoding::Encoder<'_, D>,
731            offset: usize,
732            depth: fidl::encoding::Depth,
733        ) -> fidl::Result<()> {
734            encoder.debug_check_bounds::<DeviceReceiveVectorResponse>(offset);
735            // Zero out padding regions. There's no need to apply masks
736            // because the unmasked parts will be overwritten by fields.
737            unsafe {
738                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
739                (ptr as *mut u64).write_unaligned(0);
740            }
741            // Write the fields.
742            self.0.encode(encoder, offset + 0, depth)?;
743            self.1.encode(encoder, offset + 8, depth)?;
744            Ok(())
745        }
746    }
747
748    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
749        for DeviceReceiveVectorResponse
750    {
751        #[inline(always)]
752        fn new_empty() -> Self {
753            Self {
754                status: fidl::new_empty!(i32, D),
755                data: fidl::new_empty!(fidl::encoding::Vector<u8, 8196>, D),
756            }
757        }
758
759        #[inline]
760        unsafe fn decode(
761            &mut self,
762            decoder: &mut fidl::encoding::Decoder<'_, D>,
763            offset: usize,
764            _depth: fidl::encoding::Depth,
765        ) -> fidl::Result<()> {
766            decoder.debug_check_bounds::<Self>(offset);
767            // Verify that padding bytes are zero.
768            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
769            let padval = unsafe { (ptr as *const u64).read_unaligned() };
770            let mask = 0xffffffff00000000u64;
771            let maskedval = padval & mask;
772            if maskedval != 0 {
773                return Err(fidl::Error::NonZeroPadding {
774                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
775                });
776            }
777            fidl::decode!(i32, D, &mut self.status, decoder, offset + 0, _depth)?;
778            fidl::decode!(fidl::encoding::Vector<u8, 8196>, D, &mut self.data, decoder, offset + 8, _depth)?;
779            Ok(())
780        }
781    }
782
783    impl fidl::encoding::ValueTypeMarker for DeviceTransmitVectorRequest {
784        type Borrowed<'a> = &'a Self;
785        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
786            value
787        }
788    }
789
790    unsafe impl fidl::encoding::TypeMarker for DeviceTransmitVectorRequest {
791        type Owned = Self;
792
793        #[inline(always)]
794        fn inline_align(_context: fidl::encoding::Context) -> usize {
795            8
796        }
797
798        #[inline(always)]
799        fn inline_size(_context: fidl::encoding::Context) -> usize {
800            16
801        }
802    }
803
804    unsafe impl<D: fidl::encoding::ResourceDialect>
805        fidl::encoding::Encode<DeviceTransmitVectorRequest, D> for &DeviceTransmitVectorRequest
806    {
807        #[inline]
808        unsafe fn encode(
809            self,
810            encoder: &mut fidl::encoding::Encoder<'_, D>,
811            offset: usize,
812            _depth: fidl::encoding::Depth,
813        ) -> fidl::Result<()> {
814            encoder.debug_check_bounds::<DeviceTransmitVectorRequest>(offset);
815            // Delegate to tuple encoding.
816            fidl::encoding::Encode::<DeviceTransmitVectorRequest, D>::encode(
817                (<fidl::encoding::Vector<u8, 8196> as fidl::encoding::ValueTypeMarker>::borrow(
818                    &self.data,
819                ),),
820                encoder,
821                offset,
822                _depth,
823            )
824        }
825    }
826    unsafe impl<
827        D: fidl::encoding::ResourceDialect,
828        T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 8196>, D>,
829    > fidl::encoding::Encode<DeviceTransmitVectorRequest, D> for (T0,)
830    {
831        #[inline]
832        unsafe fn encode(
833            self,
834            encoder: &mut fidl::encoding::Encoder<'_, D>,
835            offset: usize,
836            depth: fidl::encoding::Depth,
837        ) -> fidl::Result<()> {
838            encoder.debug_check_bounds::<DeviceTransmitVectorRequest>(offset);
839            // Zero out padding regions. There's no need to apply masks
840            // because the unmasked parts will be overwritten by fields.
841            // Write the fields.
842            self.0.encode(encoder, offset + 0, depth)?;
843            Ok(())
844        }
845    }
846
847    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
848        for DeviceTransmitVectorRequest
849    {
850        #[inline(always)]
851        fn new_empty() -> Self {
852            Self { data: fidl::new_empty!(fidl::encoding::Vector<u8, 8196>, D) }
853        }
854
855        #[inline]
856        unsafe fn decode(
857            &mut self,
858            decoder: &mut fidl::encoding::Decoder<'_, D>,
859            offset: usize,
860            _depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            decoder.debug_check_bounds::<Self>(offset);
863            // Verify that padding bytes are zero.
864            fidl::decode!(fidl::encoding::Vector<u8, 8196>, D, &mut self.data, decoder, offset + 0, _depth)?;
865            Ok(())
866        }
867    }
868
869    impl fidl::encoding::ValueTypeMarker for DeviceTransmitVectorResponse {
870        type Borrowed<'a> = &'a Self;
871        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
872            value
873        }
874    }
875
876    unsafe impl fidl::encoding::TypeMarker for DeviceTransmitVectorResponse {
877        type Owned = Self;
878
879        #[inline(always)]
880        fn inline_align(_context: fidl::encoding::Context) -> usize {
881            4
882        }
883
884        #[inline(always)]
885        fn inline_size(_context: fidl::encoding::Context) -> usize {
886            4
887        }
888        #[inline(always)]
889        fn encode_is_copy() -> bool {
890            true
891        }
892
893        #[inline(always)]
894        fn decode_is_copy() -> bool {
895            true
896        }
897    }
898
899    unsafe impl<D: fidl::encoding::ResourceDialect>
900        fidl::encoding::Encode<DeviceTransmitVectorResponse, D> for &DeviceTransmitVectorResponse
901    {
902        #[inline]
903        unsafe fn encode(
904            self,
905            encoder: &mut fidl::encoding::Encoder<'_, D>,
906            offset: usize,
907            _depth: fidl::encoding::Depth,
908        ) -> fidl::Result<()> {
909            encoder.debug_check_bounds::<DeviceTransmitVectorResponse>(offset);
910            unsafe {
911                // Copy the object into the buffer.
912                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
913                (buf_ptr as *mut DeviceTransmitVectorResponse)
914                    .write_unaligned((self as *const DeviceTransmitVectorResponse).read());
915                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
916                // done second because the memcpy will write garbage to these bytes.
917            }
918            Ok(())
919        }
920    }
921    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
922        fidl::encoding::Encode<DeviceTransmitVectorResponse, D> for (T0,)
923    {
924        #[inline]
925        unsafe fn encode(
926            self,
927            encoder: &mut fidl::encoding::Encoder<'_, D>,
928            offset: usize,
929            depth: fidl::encoding::Depth,
930        ) -> fidl::Result<()> {
931            encoder.debug_check_bounds::<DeviceTransmitVectorResponse>(offset);
932            // Zero out padding regions. There's no need to apply masks
933            // because the unmasked parts will be overwritten by fields.
934            // Write the fields.
935            self.0.encode(encoder, offset + 0, depth)?;
936            Ok(())
937        }
938    }
939
940    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
941        for DeviceTransmitVectorResponse
942    {
943        #[inline(always)]
944        fn new_empty() -> Self {
945            Self { status: fidl::new_empty!(i32, D) }
946        }
947
948        #[inline]
949        unsafe fn decode(
950            &mut self,
951            decoder: &mut fidl::encoding::Decoder<'_, D>,
952            offset: usize,
953            _depth: fidl::encoding::Depth,
954        ) -> fidl::Result<()> {
955            decoder.debug_check_bounds::<Self>(offset);
956            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
957            // Verify that padding bytes are zero.
958            // Copy from the buffer into the object.
959            unsafe {
960                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
961            }
962            Ok(())
963        }
964    }
965}