fidl_fuchsia_hardware_i2cimpl__common/
fidl_fuchsia_hardware_i2cimpl__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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12#[repr(C)]
13pub struct DeviceSetBitrateRequest {
14    pub bitrate: u32,
15}
16
17impl fidl::Persistable for DeviceSetBitrateRequest {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct DeviceTransactRequest {
21    pub op: Vec<I2cImplOp>,
22}
23
24impl fidl::Persistable for DeviceTransactRequest {}
25
26#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27#[repr(C)]
28pub struct DeviceGetMaxTransferSizeResponse {
29    pub size: u64,
30}
31
32impl fidl::Persistable for DeviceGetMaxTransferSizeResponse {}
33
34#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct DeviceTransactResponse {
36    pub read: Vec<ReadData>,
37}
38
39impl fidl::Persistable for DeviceTransactResponse {}
40
41/// See `Transact` below for usage.
42#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
43pub struct I2cImplOp {
44    pub address: u16,
45    pub type_: I2cImplOpType,
46    pub stop: bool,
47}
48
49impl fidl::Persistable for I2cImplOp {}
50
51/// The result of one read transaction.
52#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
53pub struct ReadData {
54    pub data: Vec<u8>,
55}
56
57impl fidl::Persistable for ReadData {}
58
59/// If `read_size` is set: This is a read operation and `read_size` bytes will be read.
60/// If `write_data` is set: This is a write operation and `write_data` will be written.
61#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62pub enum I2cImplOpType {
63    ReadSize(u32),
64    WriteData(Vec<u8>),
65}
66
67impl I2cImplOpType {
68    #[inline]
69    pub fn ordinal(&self) -> u64 {
70        match *self {
71            Self::ReadSize(_) => 1,
72            Self::WriteData(_) => 2,
73        }
74    }
75}
76
77impl fidl::Persistable for I2cImplOpType {}
78
79pub mod device_ordinals {
80    pub const GET_MAX_TRANSFER_SIZE: u64 = 0x4717665a97d2d719;
81    pub const SET_BITRATE: u64 = 0x71b6e880efd7faf4;
82    pub const TRANSACT: u64 = 0x59ad11290fc1b9a6;
83}
84
85mod internal {
86    use super::*;
87
88    impl fidl::encoding::ValueTypeMarker for DeviceSetBitrateRequest {
89        type Borrowed<'a> = &'a Self;
90        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
91            value
92        }
93    }
94
95    unsafe impl fidl::encoding::TypeMarker for DeviceSetBitrateRequest {
96        type Owned = Self;
97
98        #[inline(always)]
99        fn inline_align(_context: fidl::encoding::Context) -> usize {
100            4
101        }
102
103        #[inline(always)]
104        fn inline_size(_context: fidl::encoding::Context) -> usize {
105            4
106        }
107        #[inline(always)]
108        fn encode_is_copy() -> bool {
109            true
110        }
111
112        #[inline(always)]
113        fn decode_is_copy() -> bool {
114            true
115        }
116    }
117
118    unsafe impl<D: fidl::encoding::ResourceDialect>
119        fidl::encoding::Encode<DeviceSetBitrateRequest, D> for &DeviceSetBitrateRequest
120    {
121        #[inline]
122        unsafe fn encode(
123            self,
124            encoder: &mut fidl::encoding::Encoder<'_, D>,
125            offset: usize,
126            _depth: fidl::encoding::Depth,
127        ) -> fidl::Result<()> {
128            encoder.debug_check_bounds::<DeviceSetBitrateRequest>(offset);
129            unsafe {
130                // Copy the object into the buffer.
131                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
132                (buf_ptr as *mut DeviceSetBitrateRequest)
133                    .write_unaligned((self as *const DeviceSetBitrateRequest).read());
134                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
135                // done second because the memcpy will write garbage to these bytes.
136            }
137            Ok(())
138        }
139    }
140    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
141        fidl::encoding::Encode<DeviceSetBitrateRequest, D> for (T0,)
142    {
143        #[inline]
144        unsafe fn encode(
145            self,
146            encoder: &mut fidl::encoding::Encoder<'_, D>,
147            offset: usize,
148            depth: fidl::encoding::Depth,
149        ) -> fidl::Result<()> {
150            encoder.debug_check_bounds::<DeviceSetBitrateRequest>(offset);
151            // Zero out padding regions. There's no need to apply masks
152            // because the unmasked parts will be overwritten by fields.
153            // Write the fields.
154            self.0.encode(encoder, offset + 0, depth)?;
155            Ok(())
156        }
157    }
158
159    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
160        for DeviceSetBitrateRequest
161    {
162        #[inline(always)]
163        fn new_empty() -> Self {
164            Self { bitrate: fidl::new_empty!(u32, D) }
165        }
166
167        #[inline]
168        unsafe fn decode(
169            &mut self,
170            decoder: &mut fidl::encoding::Decoder<'_, D>,
171            offset: usize,
172            _depth: fidl::encoding::Depth,
173        ) -> fidl::Result<()> {
174            decoder.debug_check_bounds::<Self>(offset);
175            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
176            // Verify that padding bytes are zero.
177            // Copy from the buffer into the object.
178            unsafe {
179                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
180            }
181            Ok(())
182        }
183    }
184
185    impl fidl::encoding::ValueTypeMarker for DeviceTransactRequest {
186        type Borrowed<'a> = &'a Self;
187        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
188            value
189        }
190    }
191
192    unsafe impl fidl::encoding::TypeMarker for DeviceTransactRequest {
193        type Owned = Self;
194
195        #[inline(always)]
196        fn inline_align(_context: fidl::encoding::Context) -> usize {
197            8
198        }
199
200        #[inline(always)]
201        fn inline_size(_context: fidl::encoding::Context) -> usize {
202            16
203        }
204    }
205
206    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceTransactRequest, D>
207        for &DeviceTransactRequest
208    {
209        #[inline]
210        unsafe fn encode(
211            self,
212            encoder: &mut fidl::encoding::Encoder<'_, D>,
213            offset: usize,
214            _depth: fidl::encoding::Depth,
215        ) -> fidl::Result<()> {
216            encoder.debug_check_bounds::<DeviceTransactRequest>(offset);
217            // Delegate to tuple encoding.
218            fidl::encoding::Encode::<DeviceTransactRequest, D>::encode(
219                (
220                    <fidl::encoding::Vector<I2cImplOp, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.op),
221                ),
222                encoder, offset, _depth
223            )
224        }
225    }
226    unsafe impl<
227        D: fidl::encoding::ResourceDialect,
228        T0: fidl::encoding::Encode<fidl::encoding::Vector<I2cImplOp, 256>, D>,
229    > fidl::encoding::Encode<DeviceTransactRequest, D> for (T0,)
230    {
231        #[inline]
232        unsafe fn encode(
233            self,
234            encoder: &mut fidl::encoding::Encoder<'_, D>,
235            offset: usize,
236            depth: fidl::encoding::Depth,
237        ) -> fidl::Result<()> {
238            encoder.debug_check_bounds::<DeviceTransactRequest>(offset);
239            // Zero out padding regions. There's no need to apply masks
240            // because the unmasked parts will be overwritten by fields.
241            // Write the fields.
242            self.0.encode(encoder, offset + 0, depth)?;
243            Ok(())
244        }
245    }
246
247    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceTransactRequest {
248        #[inline(always)]
249        fn new_empty() -> Self {
250            Self { op: fidl::new_empty!(fidl::encoding::Vector<I2cImplOp, 256>, D) }
251        }
252
253        #[inline]
254        unsafe fn decode(
255            &mut self,
256            decoder: &mut fidl::encoding::Decoder<'_, D>,
257            offset: usize,
258            _depth: fidl::encoding::Depth,
259        ) -> fidl::Result<()> {
260            decoder.debug_check_bounds::<Self>(offset);
261            // Verify that padding bytes are zero.
262            fidl::decode!(fidl::encoding::Vector<I2cImplOp, 256>, D, &mut self.op, decoder, offset + 0, _depth)?;
263            Ok(())
264        }
265    }
266
267    impl fidl::encoding::ValueTypeMarker for DeviceGetMaxTransferSizeResponse {
268        type Borrowed<'a> = &'a Self;
269        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
270            value
271        }
272    }
273
274    unsafe impl fidl::encoding::TypeMarker for DeviceGetMaxTransferSizeResponse {
275        type Owned = Self;
276
277        #[inline(always)]
278        fn inline_align(_context: fidl::encoding::Context) -> usize {
279            8
280        }
281
282        #[inline(always)]
283        fn inline_size(_context: fidl::encoding::Context) -> usize {
284            8
285        }
286        #[inline(always)]
287        fn encode_is_copy() -> bool {
288            true
289        }
290
291        #[inline(always)]
292        fn decode_is_copy() -> bool {
293            true
294        }
295    }
296
297    unsafe impl<D: fidl::encoding::ResourceDialect>
298        fidl::encoding::Encode<DeviceGetMaxTransferSizeResponse, D>
299        for &DeviceGetMaxTransferSizeResponse
300    {
301        #[inline]
302        unsafe fn encode(
303            self,
304            encoder: &mut fidl::encoding::Encoder<'_, D>,
305            offset: usize,
306            _depth: fidl::encoding::Depth,
307        ) -> fidl::Result<()> {
308            encoder.debug_check_bounds::<DeviceGetMaxTransferSizeResponse>(offset);
309            unsafe {
310                // Copy the object into the buffer.
311                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
312                (buf_ptr as *mut DeviceGetMaxTransferSizeResponse)
313                    .write_unaligned((self as *const DeviceGetMaxTransferSizeResponse).read());
314                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
315                // done second because the memcpy will write garbage to these bytes.
316            }
317            Ok(())
318        }
319    }
320    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
321        fidl::encoding::Encode<DeviceGetMaxTransferSizeResponse, D> for (T0,)
322    {
323        #[inline]
324        unsafe fn encode(
325            self,
326            encoder: &mut fidl::encoding::Encoder<'_, D>,
327            offset: usize,
328            depth: fidl::encoding::Depth,
329        ) -> fidl::Result<()> {
330            encoder.debug_check_bounds::<DeviceGetMaxTransferSizeResponse>(offset);
331            // Zero out padding regions. There's no need to apply masks
332            // because the unmasked parts will be overwritten by fields.
333            // Write the fields.
334            self.0.encode(encoder, offset + 0, depth)?;
335            Ok(())
336        }
337    }
338
339    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
340        for DeviceGetMaxTransferSizeResponse
341    {
342        #[inline(always)]
343        fn new_empty() -> Self {
344            Self { size: fidl::new_empty!(u64, D) }
345        }
346
347        #[inline]
348        unsafe fn decode(
349            &mut self,
350            decoder: &mut fidl::encoding::Decoder<'_, D>,
351            offset: usize,
352            _depth: fidl::encoding::Depth,
353        ) -> fidl::Result<()> {
354            decoder.debug_check_bounds::<Self>(offset);
355            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
356            // Verify that padding bytes are zero.
357            // Copy from the buffer into the object.
358            unsafe {
359                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
360            }
361            Ok(())
362        }
363    }
364
365    impl fidl::encoding::ValueTypeMarker for DeviceTransactResponse {
366        type Borrowed<'a> = &'a Self;
367        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
368            value
369        }
370    }
371
372    unsafe impl fidl::encoding::TypeMarker for DeviceTransactResponse {
373        type Owned = Self;
374
375        #[inline(always)]
376        fn inline_align(_context: fidl::encoding::Context) -> usize {
377            8
378        }
379
380        #[inline(always)]
381        fn inline_size(_context: fidl::encoding::Context) -> usize {
382            16
383        }
384    }
385
386    unsafe impl<D: fidl::encoding::ResourceDialect>
387        fidl::encoding::Encode<DeviceTransactResponse, D> for &DeviceTransactResponse
388    {
389        #[inline]
390        unsafe fn encode(
391            self,
392            encoder: &mut fidl::encoding::Encoder<'_, D>,
393            offset: usize,
394            _depth: fidl::encoding::Depth,
395        ) -> fidl::Result<()> {
396            encoder.debug_check_bounds::<DeviceTransactResponse>(offset);
397            // Delegate to tuple encoding.
398            fidl::encoding::Encode::<DeviceTransactResponse, D>::encode(
399                (
400                    <fidl::encoding::Vector<ReadData, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.read),
401                ),
402                encoder, offset, _depth
403            )
404        }
405    }
406    unsafe impl<
407        D: fidl::encoding::ResourceDialect,
408        T0: fidl::encoding::Encode<fidl::encoding::Vector<ReadData, 256>, D>,
409    > fidl::encoding::Encode<DeviceTransactResponse, D> for (T0,)
410    {
411        #[inline]
412        unsafe fn encode(
413            self,
414            encoder: &mut fidl::encoding::Encoder<'_, D>,
415            offset: usize,
416            depth: fidl::encoding::Depth,
417        ) -> fidl::Result<()> {
418            encoder.debug_check_bounds::<DeviceTransactResponse>(offset);
419            // Zero out padding regions. There's no need to apply masks
420            // because the unmasked parts will be overwritten by fields.
421            // Write the fields.
422            self.0.encode(encoder, offset + 0, depth)?;
423            Ok(())
424        }
425    }
426
427    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
428        for DeviceTransactResponse
429    {
430        #[inline(always)]
431        fn new_empty() -> Self {
432            Self { read: fidl::new_empty!(fidl::encoding::Vector<ReadData, 256>, D) }
433        }
434
435        #[inline]
436        unsafe fn decode(
437            &mut self,
438            decoder: &mut fidl::encoding::Decoder<'_, D>,
439            offset: usize,
440            _depth: fidl::encoding::Depth,
441        ) -> fidl::Result<()> {
442            decoder.debug_check_bounds::<Self>(offset);
443            // Verify that padding bytes are zero.
444            fidl::decode!(fidl::encoding::Vector<ReadData, 256>, D, &mut self.read, decoder, offset + 0, _depth)?;
445            Ok(())
446        }
447    }
448
449    impl fidl::encoding::ValueTypeMarker for I2cImplOp {
450        type Borrowed<'a> = &'a Self;
451        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
452            value
453        }
454    }
455
456    unsafe impl fidl::encoding::TypeMarker for I2cImplOp {
457        type Owned = Self;
458
459        #[inline(always)]
460        fn inline_align(_context: fidl::encoding::Context) -> usize {
461            8
462        }
463
464        #[inline(always)]
465        fn inline_size(_context: fidl::encoding::Context) -> usize {
466            32
467        }
468    }
469
470    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<I2cImplOp, D>
471        for &I2cImplOp
472    {
473        #[inline]
474        unsafe fn encode(
475            self,
476            encoder: &mut fidl::encoding::Encoder<'_, D>,
477            offset: usize,
478            _depth: fidl::encoding::Depth,
479        ) -> fidl::Result<()> {
480            encoder.debug_check_bounds::<I2cImplOp>(offset);
481            // Delegate to tuple encoding.
482            fidl::encoding::Encode::<I2cImplOp, D>::encode(
483                (
484                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.address),
485                    <I2cImplOpType as fidl::encoding::ValueTypeMarker>::borrow(&self.type_),
486                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.stop),
487                ),
488                encoder,
489                offset,
490                _depth,
491            )
492        }
493    }
494    unsafe impl<
495        D: fidl::encoding::ResourceDialect,
496        T0: fidl::encoding::Encode<u16, D>,
497        T1: fidl::encoding::Encode<I2cImplOpType, D>,
498        T2: fidl::encoding::Encode<bool, D>,
499    > fidl::encoding::Encode<I2cImplOp, D> for (T0, T1, T2)
500    {
501        #[inline]
502        unsafe fn encode(
503            self,
504            encoder: &mut fidl::encoding::Encoder<'_, D>,
505            offset: usize,
506            depth: fidl::encoding::Depth,
507        ) -> fidl::Result<()> {
508            encoder.debug_check_bounds::<I2cImplOp>(offset);
509            // Zero out padding regions. There's no need to apply masks
510            // because the unmasked parts will be overwritten by fields.
511            unsafe {
512                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
513                (ptr as *mut u64).write_unaligned(0);
514            }
515            unsafe {
516                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
517                (ptr as *mut u64).write_unaligned(0);
518            }
519            // Write the fields.
520            self.0.encode(encoder, offset + 0, depth)?;
521            self.1.encode(encoder, offset + 8, depth)?;
522            self.2.encode(encoder, offset + 24, depth)?;
523            Ok(())
524        }
525    }
526
527    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for I2cImplOp {
528        #[inline(always)]
529        fn new_empty() -> Self {
530            Self {
531                address: fidl::new_empty!(u16, D),
532                type_: fidl::new_empty!(I2cImplOpType, D),
533                stop: fidl::new_empty!(bool, D),
534            }
535        }
536
537        #[inline]
538        unsafe fn decode(
539            &mut self,
540            decoder: &mut fidl::encoding::Decoder<'_, D>,
541            offset: usize,
542            _depth: fidl::encoding::Depth,
543        ) -> fidl::Result<()> {
544            decoder.debug_check_bounds::<Self>(offset);
545            // Verify that padding bytes are zero.
546            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
547            let padval = unsafe { (ptr as *const u64).read_unaligned() };
548            let mask = 0xffffffffffff0000u64;
549            let maskedval = padval & mask;
550            if maskedval != 0 {
551                return Err(fidl::Error::NonZeroPadding {
552                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
553                });
554            }
555            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
556            let padval = unsafe { (ptr as *const u64).read_unaligned() };
557            let mask = 0xffffffffffffff00u64;
558            let maskedval = padval & mask;
559            if maskedval != 0 {
560                return Err(fidl::Error::NonZeroPadding {
561                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
562                });
563            }
564            fidl::decode!(u16, D, &mut self.address, decoder, offset + 0, _depth)?;
565            fidl::decode!(I2cImplOpType, D, &mut self.type_, decoder, offset + 8, _depth)?;
566            fidl::decode!(bool, D, &mut self.stop, decoder, offset + 24, _depth)?;
567            Ok(())
568        }
569    }
570
571    impl fidl::encoding::ValueTypeMarker for ReadData {
572        type Borrowed<'a> = &'a Self;
573        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
574            value
575        }
576    }
577
578    unsafe impl fidl::encoding::TypeMarker for ReadData {
579        type Owned = Self;
580
581        #[inline(always)]
582        fn inline_align(_context: fidl::encoding::Context) -> usize {
583            8
584        }
585
586        #[inline(always)]
587        fn inline_size(_context: fidl::encoding::Context) -> usize {
588            16
589        }
590    }
591
592    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ReadData, D> for &ReadData {
593        #[inline]
594        unsafe fn encode(
595            self,
596            encoder: &mut fidl::encoding::Encoder<'_, D>,
597            offset: usize,
598            _depth: fidl::encoding::Depth,
599        ) -> fidl::Result<()> {
600            encoder.debug_check_bounds::<ReadData>(offset);
601            // Delegate to tuple encoding.
602            fidl::encoding::Encode::<ReadData, D>::encode(
603                (<fidl::encoding::Vector<u8, 32768> as fidl::encoding::ValueTypeMarker>::borrow(
604                    &self.data,
605                ),),
606                encoder,
607                offset,
608                _depth,
609            )
610        }
611    }
612    unsafe impl<
613        D: fidl::encoding::ResourceDialect,
614        T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 32768>, D>,
615    > fidl::encoding::Encode<ReadData, D> for (T0,)
616    {
617        #[inline]
618        unsafe fn encode(
619            self,
620            encoder: &mut fidl::encoding::Encoder<'_, D>,
621            offset: usize,
622            depth: fidl::encoding::Depth,
623        ) -> fidl::Result<()> {
624            encoder.debug_check_bounds::<ReadData>(offset);
625            // Zero out padding regions. There's no need to apply masks
626            // because the unmasked parts will be overwritten by fields.
627            // Write the fields.
628            self.0.encode(encoder, offset + 0, depth)?;
629            Ok(())
630        }
631    }
632
633    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReadData {
634        #[inline(always)]
635        fn new_empty() -> Self {
636            Self { data: fidl::new_empty!(fidl::encoding::Vector<u8, 32768>, D) }
637        }
638
639        #[inline]
640        unsafe fn decode(
641            &mut self,
642            decoder: &mut fidl::encoding::Decoder<'_, D>,
643            offset: usize,
644            _depth: fidl::encoding::Depth,
645        ) -> fidl::Result<()> {
646            decoder.debug_check_bounds::<Self>(offset);
647            // Verify that padding bytes are zero.
648            fidl::decode!(fidl::encoding::Vector<u8, 32768>, D, &mut self.data, decoder, offset + 0, _depth)?;
649            Ok(())
650        }
651    }
652
653    impl fidl::encoding::ValueTypeMarker for I2cImplOpType {
654        type Borrowed<'a> = &'a Self;
655        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
656            value
657        }
658    }
659
660    unsafe impl fidl::encoding::TypeMarker for I2cImplOpType {
661        type Owned = Self;
662
663        #[inline(always)]
664        fn inline_align(_context: fidl::encoding::Context) -> usize {
665            8
666        }
667
668        #[inline(always)]
669        fn inline_size(_context: fidl::encoding::Context) -> usize {
670            16
671        }
672    }
673
674    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<I2cImplOpType, D>
675        for &I2cImplOpType
676    {
677        #[inline]
678        unsafe fn encode(
679            self,
680            encoder: &mut fidl::encoding::Encoder<'_, D>,
681            offset: usize,
682            _depth: fidl::encoding::Depth,
683        ) -> fidl::Result<()> {
684            encoder.debug_check_bounds::<I2cImplOpType>(offset);
685            encoder.write_num::<u64>(self.ordinal(), offset);
686            match self {
687                I2cImplOpType::ReadSize(ref val) => fidl::encoding::encode_in_envelope::<u32, D>(
688                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
689                    encoder,
690                    offset + 8,
691                    _depth,
692                ),
693                I2cImplOpType::WriteData(ref val) => fidl::encoding::encode_in_envelope::<
694                    fidl::encoding::Vector<u8, 32768>,
695                    D,
696                >(
697                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::ValueTypeMarker>::borrow(
698                        val,
699                    ),
700                    encoder,
701                    offset + 8,
702                    _depth,
703                ),
704            }
705        }
706    }
707
708    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for I2cImplOpType {
709        #[inline(always)]
710        fn new_empty() -> Self {
711            Self::ReadSize(fidl::new_empty!(u32, D))
712        }
713
714        #[inline]
715        unsafe fn decode(
716            &mut self,
717            decoder: &mut fidl::encoding::Decoder<'_, D>,
718            offset: usize,
719            mut depth: fidl::encoding::Depth,
720        ) -> fidl::Result<()> {
721            decoder.debug_check_bounds::<Self>(offset);
722            #[allow(unused_variables)]
723            let next_out_of_line = decoder.next_out_of_line();
724            let handles_before = decoder.remaining_handles();
725            let (ordinal, inlined, num_bytes, num_handles) =
726                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
727
728            let member_inline_size = match ordinal {
729                1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
730                2 => {
731                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::TypeMarker>::inline_size(
732                        decoder.context,
733                    )
734                }
735                _ => return Err(fidl::Error::UnknownUnionTag),
736            };
737
738            if inlined != (member_inline_size <= 4) {
739                return Err(fidl::Error::InvalidInlineBitInEnvelope);
740            }
741            let _inner_offset;
742            if inlined {
743                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
744                _inner_offset = offset + 8;
745            } else {
746                depth.increment()?;
747                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
748            }
749            match ordinal {
750                1 => {
751                    #[allow(irrefutable_let_patterns)]
752                    if let I2cImplOpType::ReadSize(_) = self {
753                        // Do nothing, read the value into the object
754                    } else {
755                        // Initialize `self` to the right variant
756                        *self = I2cImplOpType::ReadSize(fidl::new_empty!(u32, D));
757                    }
758                    #[allow(irrefutable_let_patterns)]
759                    if let I2cImplOpType::ReadSize(ref mut val) = self {
760                        fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
761                    } else {
762                        unreachable!()
763                    }
764                }
765                2 => {
766                    #[allow(irrefutable_let_patterns)]
767                    if let I2cImplOpType::WriteData(_) = self {
768                        // Do nothing, read the value into the object
769                    } else {
770                        // Initialize `self` to the right variant
771                        *self = I2cImplOpType::WriteData(
772                            fidl::new_empty!(fidl::encoding::Vector<u8, 32768>, D),
773                        );
774                    }
775                    #[allow(irrefutable_let_patterns)]
776                    if let I2cImplOpType::WriteData(ref mut val) = self {
777                        fidl::decode!(fidl::encoding::Vector<u8, 32768>, D, val, decoder, _inner_offset, depth)?;
778                    } else {
779                        unreachable!()
780                    }
781                }
782                ordinal => panic!("unexpected ordinal {:?}", ordinal),
783            }
784            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
785                return Err(fidl::Error::InvalidNumBytesInEnvelope);
786            }
787            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
788                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
789            }
790            Ok(())
791        }
792    }
793}