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