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