1#![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(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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
42#[repr(u8)]
43pub enum Class {
44 Generic = 1,
45 BluetoothHci = 2,
47 Console = 3,
49 KernelDebug = 4,
51 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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
76#[repr(u8)]
77pub enum FlowControl {
78 None = 1,
79 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#[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#[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 pub serial_vid: u32,
202 pub serial_pid: u32,
203}
204
205impl fidl::Persistable for SerialPortInfo {}
206impl fidl::Serializable for SerialPortInfo {
207 const SERIALIZABLE_NAME: &'static str = "fuchsia.hardware.serial.SerialPortInfo";
208}
209
210pub mod device_ordinals {
211 pub const GET_CLASS: u64 = 0x3d48bbcee248ab8b;
212 pub const SET_CONFIG: u64 = 0x771a0946f6f87173;
213 pub const READ: u64 = 0x63c41d3c053fadd8;
214 pub const WRITE: u64 = 0x6aa7adae6841779c;
215}
216
217pub mod device_proxy__ordinals {
218 pub const GET_CHANNEL: u64 = 0x580f1a3ef6c20fff;
219}
220
221mod internal {
222 use super::*;
223 unsafe impl fidl::encoding::TypeMarker for CharacterWidth {
224 type Owned = Self;
225
226 #[inline(always)]
227 fn inline_align(_context: fidl::encoding::Context) -> usize {
228 std::mem::align_of::<u8>()
229 }
230
231 #[inline(always)]
232 fn inline_size(_context: fidl::encoding::Context) -> usize {
233 std::mem::size_of::<u8>()
234 }
235
236 #[inline(always)]
237 fn encode_is_copy() -> bool {
238 true
239 }
240
241 #[inline(always)]
242 fn decode_is_copy() -> bool {
243 false
244 }
245 }
246
247 impl fidl::encoding::ValueTypeMarker for CharacterWidth {
248 type Borrowed<'a> = Self;
249 #[inline(always)]
250 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
251 *value
252 }
253 }
254
255 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CharacterWidth {
256 #[inline]
257 unsafe fn encode(
258 self,
259 encoder: &mut fidl::encoding::Encoder<'_, D>,
260 offset: usize,
261 _depth: fidl::encoding::Depth,
262 ) -> fidl::Result<()> {
263 encoder.debug_check_bounds::<Self>(offset);
264 encoder.write_num(self.into_primitive(), offset);
265 Ok(())
266 }
267 }
268
269 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CharacterWidth {
270 #[inline(always)]
271 fn new_empty() -> Self {
272 Self::Bits5
273 }
274
275 #[inline]
276 unsafe fn decode(
277 &mut self,
278 decoder: &mut fidl::encoding::Decoder<'_, D>,
279 offset: usize,
280 _depth: fidl::encoding::Depth,
281 ) -> fidl::Result<()> {
282 decoder.debug_check_bounds::<Self>(offset);
283 let prim = decoder.read_num::<u8>(offset);
284
285 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
286 Ok(())
287 }
288 }
289 unsafe impl fidl::encoding::TypeMarker for Class {
290 type Owned = Self;
291
292 #[inline(always)]
293 fn inline_align(_context: fidl::encoding::Context) -> usize {
294 std::mem::align_of::<u8>()
295 }
296
297 #[inline(always)]
298 fn inline_size(_context: fidl::encoding::Context) -> usize {
299 std::mem::size_of::<u8>()
300 }
301
302 #[inline(always)]
303 fn encode_is_copy() -> bool {
304 true
305 }
306
307 #[inline(always)]
308 fn decode_is_copy() -> bool {
309 false
310 }
311 }
312
313 impl fidl::encoding::ValueTypeMarker for Class {
314 type Borrowed<'a> = Self;
315 #[inline(always)]
316 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
317 *value
318 }
319 }
320
321 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Class {
322 #[inline]
323 unsafe fn encode(
324 self,
325 encoder: &mut fidl::encoding::Encoder<'_, D>,
326 offset: usize,
327 _depth: fidl::encoding::Depth,
328 ) -> fidl::Result<()> {
329 encoder.debug_check_bounds::<Self>(offset);
330 encoder.write_num(self.into_primitive(), offset);
331 Ok(())
332 }
333 }
334
335 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Class {
336 #[inline(always)]
337 fn new_empty() -> Self {
338 Self::Generic
339 }
340
341 #[inline]
342 unsafe fn decode(
343 &mut self,
344 decoder: &mut fidl::encoding::Decoder<'_, D>,
345 offset: usize,
346 _depth: fidl::encoding::Depth,
347 ) -> fidl::Result<()> {
348 decoder.debug_check_bounds::<Self>(offset);
349 let prim = decoder.read_num::<u8>(offset);
350
351 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
352 Ok(())
353 }
354 }
355 unsafe impl fidl::encoding::TypeMarker for FlowControl {
356 type Owned = Self;
357
358 #[inline(always)]
359 fn inline_align(_context: fidl::encoding::Context) -> usize {
360 std::mem::align_of::<u8>()
361 }
362
363 #[inline(always)]
364 fn inline_size(_context: fidl::encoding::Context) -> usize {
365 std::mem::size_of::<u8>()
366 }
367
368 #[inline(always)]
369 fn encode_is_copy() -> bool {
370 true
371 }
372
373 #[inline(always)]
374 fn decode_is_copy() -> bool {
375 false
376 }
377 }
378
379 impl fidl::encoding::ValueTypeMarker for FlowControl {
380 type Borrowed<'a> = Self;
381 #[inline(always)]
382 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
383 *value
384 }
385 }
386
387 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for FlowControl {
388 #[inline]
389 unsafe fn encode(
390 self,
391 encoder: &mut fidl::encoding::Encoder<'_, D>,
392 offset: usize,
393 _depth: fidl::encoding::Depth,
394 ) -> fidl::Result<()> {
395 encoder.debug_check_bounds::<Self>(offset);
396 encoder.write_num(self.into_primitive(), offset);
397 Ok(())
398 }
399 }
400
401 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlowControl {
402 #[inline(always)]
403 fn new_empty() -> Self {
404 Self::None
405 }
406
407 #[inline]
408 unsafe fn decode(
409 &mut self,
410 decoder: &mut fidl::encoding::Decoder<'_, D>,
411 offset: usize,
412 _depth: fidl::encoding::Depth,
413 ) -> fidl::Result<()> {
414 decoder.debug_check_bounds::<Self>(offset);
415 let prim = decoder.read_num::<u8>(offset);
416
417 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
418 Ok(())
419 }
420 }
421 unsafe impl fidl::encoding::TypeMarker for Parity {
422 type Owned = Self;
423
424 #[inline(always)]
425 fn inline_align(_context: fidl::encoding::Context) -> usize {
426 std::mem::align_of::<u8>()
427 }
428
429 #[inline(always)]
430 fn inline_size(_context: fidl::encoding::Context) -> usize {
431 std::mem::size_of::<u8>()
432 }
433
434 #[inline(always)]
435 fn encode_is_copy() -> bool {
436 true
437 }
438
439 #[inline(always)]
440 fn decode_is_copy() -> bool {
441 false
442 }
443 }
444
445 impl fidl::encoding::ValueTypeMarker for Parity {
446 type Borrowed<'a> = Self;
447 #[inline(always)]
448 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
449 *value
450 }
451 }
452
453 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Parity {
454 #[inline]
455 unsafe fn encode(
456 self,
457 encoder: &mut fidl::encoding::Encoder<'_, D>,
458 offset: usize,
459 _depth: fidl::encoding::Depth,
460 ) -> fidl::Result<()> {
461 encoder.debug_check_bounds::<Self>(offset);
462 encoder.write_num(self.into_primitive(), offset);
463 Ok(())
464 }
465 }
466
467 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Parity {
468 #[inline(always)]
469 fn new_empty() -> Self {
470 Self::None
471 }
472
473 #[inline]
474 unsafe fn decode(
475 &mut self,
476 decoder: &mut fidl::encoding::Decoder<'_, D>,
477 offset: usize,
478 _depth: fidl::encoding::Depth,
479 ) -> fidl::Result<()> {
480 decoder.debug_check_bounds::<Self>(offset);
481 let prim = decoder.read_num::<u8>(offset);
482
483 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
484 Ok(())
485 }
486 }
487 unsafe impl fidl::encoding::TypeMarker for StopWidth {
488 type Owned = Self;
489
490 #[inline(always)]
491 fn inline_align(_context: fidl::encoding::Context) -> usize {
492 std::mem::align_of::<u8>()
493 }
494
495 #[inline(always)]
496 fn inline_size(_context: fidl::encoding::Context) -> usize {
497 std::mem::size_of::<u8>()
498 }
499
500 #[inline(always)]
501 fn encode_is_copy() -> bool {
502 true
503 }
504
505 #[inline(always)]
506 fn decode_is_copy() -> bool {
507 false
508 }
509 }
510
511 impl fidl::encoding::ValueTypeMarker for StopWidth {
512 type Borrowed<'a> = Self;
513 #[inline(always)]
514 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
515 *value
516 }
517 }
518
519 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StopWidth {
520 #[inline]
521 unsafe fn encode(
522 self,
523 encoder: &mut fidl::encoding::Encoder<'_, D>,
524 offset: usize,
525 _depth: fidl::encoding::Depth,
526 ) -> fidl::Result<()> {
527 encoder.debug_check_bounds::<Self>(offset);
528 encoder.write_num(self.into_primitive(), offset);
529 Ok(())
530 }
531 }
532
533 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StopWidth {
534 #[inline(always)]
535 fn new_empty() -> Self {
536 Self::Bits1
537 }
538
539 #[inline]
540 unsafe fn decode(
541 &mut self,
542 decoder: &mut fidl::encoding::Decoder<'_, D>,
543 offset: usize,
544 _depth: fidl::encoding::Depth,
545 ) -> fidl::Result<()> {
546 decoder.debug_check_bounds::<Self>(offset);
547 let prim = decoder.read_num::<u8>(offset);
548
549 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
550 Ok(())
551 }
552 }
553
554 impl fidl::encoding::ValueTypeMarker for Config {
555 type Borrowed<'a> = &'a Self;
556 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
557 value
558 }
559 }
560
561 unsafe impl fidl::encoding::TypeMarker for Config {
562 type Owned = Self;
563
564 #[inline(always)]
565 fn inline_align(_context: fidl::encoding::Context) -> usize {
566 4
567 }
568
569 #[inline(always)]
570 fn inline_size(_context: fidl::encoding::Context) -> usize {
571 8
572 }
573 }
574
575 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
576 #[inline]
577 unsafe fn encode(
578 self,
579 encoder: &mut fidl::encoding::Encoder<'_, D>,
580 offset: usize,
581 _depth: fidl::encoding::Depth,
582 ) -> fidl::Result<()> {
583 encoder.debug_check_bounds::<Config>(offset);
584 fidl::encoding::Encode::<Config, D>::encode(
586 (
587 <CharacterWidth as fidl::encoding::ValueTypeMarker>::borrow(
588 &self.character_width,
589 ),
590 <StopWidth as fidl::encoding::ValueTypeMarker>::borrow(&self.stop_width),
591 <Parity as fidl::encoding::ValueTypeMarker>::borrow(&self.parity),
592 <FlowControl as fidl::encoding::ValueTypeMarker>::borrow(&self.control_flow),
593 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.baud_rate),
594 ),
595 encoder,
596 offset,
597 _depth,
598 )
599 }
600 }
601 unsafe impl<
602 D: fidl::encoding::ResourceDialect,
603 T0: fidl::encoding::Encode<CharacterWidth, D>,
604 T1: fidl::encoding::Encode<StopWidth, D>,
605 T2: fidl::encoding::Encode<Parity, D>,
606 T3: fidl::encoding::Encode<FlowControl, D>,
607 T4: fidl::encoding::Encode<u32, D>,
608 > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4)
609 {
610 #[inline]
611 unsafe fn encode(
612 self,
613 encoder: &mut fidl::encoding::Encoder<'_, D>,
614 offset: usize,
615 depth: fidl::encoding::Depth,
616 ) -> fidl::Result<()> {
617 encoder.debug_check_bounds::<Config>(offset);
618 self.0.encode(encoder, offset + 0, depth)?;
622 self.1.encode(encoder, offset + 1, depth)?;
623 self.2.encode(encoder, offset + 2, depth)?;
624 self.3.encode(encoder, offset + 3, depth)?;
625 self.4.encode(encoder, offset + 4, depth)?;
626 Ok(())
627 }
628 }
629
630 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
631 #[inline(always)]
632 fn new_empty() -> Self {
633 Self {
634 character_width: fidl::new_empty!(CharacterWidth, D),
635 stop_width: fidl::new_empty!(StopWidth, D),
636 parity: fidl::new_empty!(Parity, D),
637 control_flow: fidl::new_empty!(FlowControl, D),
638 baud_rate: fidl::new_empty!(u32, D),
639 }
640 }
641
642 #[inline]
643 unsafe fn decode(
644 &mut self,
645 decoder: &mut fidl::encoding::Decoder<'_, D>,
646 offset: usize,
647 _depth: fidl::encoding::Depth,
648 ) -> fidl::Result<()> {
649 decoder.debug_check_bounds::<Self>(offset);
650 fidl::decode!(
652 CharacterWidth,
653 D,
654 &mut self.character_width,
655 decoder,
656 offset + 0,
657 _depth
658 )?;
659 fidl::decode!(StopWidth, D, &mut self.stop_width, decoder, offset + 1, _depth)?;
660 fidl::decode!(Parity, D, &mut self.parity, decoder, offset + 2, _depth)?;
661 fidl::decode!(FlowControl, D, &mut self.control_flow, decoder, offset + 3, _depth)?;
662 fidl::decode!(u32, D, &mut self.baud_rate, decoder, offset + 4, _depth)?;
663 Ok(())
664 }
665 }
666
667 impl fidl::encoding::ValueTypeMarker for DeviceGetClassResponse {
668 type Borrowed<'a> = &'a Self;
669 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
670 value
671 }
672 }
673
674 unsafe impl fidl::encoding::TypeMarker for DeviceGetClassResponse {
675 type Owned = Self;
676
677 #[inline(always)]
678 fn inline_align(_context: fidl::encoding::Context) -> usize {
679 1
680 }
681
682 #[inline(always)]
683 fn inline_size(_context: fidl::encoding::Context) -> usize {
684 1
685 }
686 }
687
688 unsafe impl<D: fidl::encoding::ResourceDialect>
689 fidl::encoding::Encode<DeviceGetClassResponse, D> for &DeviceGetClassResponse
690 {
691 #[inline]
692 unsafe fn encode(
693 self,
694 encoder: &mut fidl::encoding::Encoder<'_, D>,
695 offset: usize,
696 _depth: fidl::encoding::Depth,
697 ) -> fidl::Result<()> {
698 encoder.debug_check_bounds::<DeviceGetClassResponse>(offset);
699 fidl::encoding::Encode::<DeviceGetClassResponse, D>::encode(
701 (<Class as fidl::encoding::ValueTypeMarker>::borrow(&self.device_class),),
702 encoder,
703 offset,
704 _depth,
705 )
706 }
707 }
708 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Class, D>>
709 fidl::encoding::Encode<DeviceGetClassResponse, D> for (T0,)
710 {
711 #[inline]
712 unsafe fn encode(
713 self,
714 encoder: &mut fidl::encoding::Encoder<'_, D>,
715 offset: usize,
716 depth: fidl::encoding::Depth,
717 ) -> fidl::Result<()> {
718 encoder.debug_check_bounds::<DeviceGetClassResponse>(offset);
719 self.0.encode(encoder, offset + 0, depth)?;
723 Ok(())
724 }
725 }
726
727 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
728 for DeviceGetClassResponse
729 {
730 #[inline(always)]
731 fn new_empty() -> Self {
732 Self { device_class: fidl::new_empty!(Class, D) }
733 }
734
735 #[inline]
736 unsafe fn decode(
737 &mut self,
738 decoder: &mut fidl::encoding::Decoder<'_, D>,
739 offset: usize,
740 _depth: fidl::encoding::Depth,
741 ) -> fidl::Result<()> {
742 decoder.debug_check_bounds::<Self>(offset);
743 fidl::decode!(Class, D, &mut self.device_class, decoder, offset + 0, _depth)?;
745 Ok(())
746 }
747 }
748
749 impl fidl::encoding::ValueTypeMarker for DeviceSetConfigRequest {
750 type Borrowed<'a> = &'a Self;
751 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
752 value
753 }
754 }
755
756 unsafe impl fidl::encoding::TypeMarker for DeviceSetConfigRequest {
757 type Owned = Self;
758
759 #[inline(always)]
760 fn inline_align(_context: fidl::encoding::Context) -> usize {
761 4
762 }
763
764 #[inline(always)]
765 fn inline_size(_context: fidl::encoding::Context) -> usize {
766 8
767 }
768 }
769
770 unsafe impl<D: fidl::encoding::ResourceDialect>
771 fidl::encoding::Encode<DeviceSetConfigRequest, D> for &DeviceSetConfigRequest
772 {
773 #[inline]
774 unsafe fn encode(
775 self,
776 encoder: &mut fidl::encoding::Encoder<'_, D>,
777 offset: usize,
778 _depth: fidl::encoding::Depth,
779 ) -> fidl::Result<()> {
780 encoder.debug_check_bounds::<DeviceSetConfigRequest>(offset);
781 fidl::encoding::Encode::<DeviceSetConfigRequest, D>::encode(
783 (<Config as fidl::encoding::ValueTypeMarker>::borrow(&self.config),),
784 encoder,
785 offset,
786 _depth,
787 )
788 }
789 }
790 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Config, D>>
791 fidl::encoding::Encode<DeviceSetConfigRequest, D> for (T0,)
792 {
793 #[inline]
794 unsafe fn encode(
795 self,
796 encoder: &mut fidl::encoding::Encoder<'_, D>,
797 offset: usize,
798 depth: fidl::encoding::Depth,
799 ) -> fidl::Result<()> {
800 encoder.debug_check_bounds::<DeviceSetConfigRequest>(offset);
801 self.0.encode(encoder, offset + 0, depth)?;
805 Ok(())
806 }
807 }
808
809 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
810 for DeviceSetConfigRequest
811 {
812 #[inline(always)]
813 fn new_empty() -> Self {
814 Self { config: fidl::new_empty!(Config, D) }
815 }
816
817 #[inline]
818 unsafe fn decode(
819 &mut self,
820 decoder: &mut fidl::encoding::Decoder<'_, D>,
821 offset: usize,
822 _depth: fidl::encoding::Depth,
823 ) -> fidl::Result<()> {
824 decoder.debug_check_bounds::<Self>(offset);
825 fidl::decode!(Config, D, &mut self.config, decoder, offset + 0, _depth)?;
827 Ok(())
828 }
829 }
830
831 impl fidl::encoding::ValueTypeMarker for DeviceSetConfigResponse {
832 type Borrowed<'a> = &'a Self;
833 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
834 value
835 }
836 }
837
838 unsafe impl fidl::encoding::TypeMarker for DeviceSetConfigResponse {
839 type Owned = Self;
840
841 #[inline(always)]
842 fn inline_align(_context: fidl::encoding::Context) -> usize {
843 4
844 }
845
846 #[inline(always)]
847 fn inline_size(_context: fidl::encoding::Context) -> usize {
848 4
849 }
850 #[inline(always)]
851 fn encode_is_copy() -> bool {
852 true
853 }
854
855 #[inline(always)]
856 fn decode_is_copy() -> bool {
857 true
858 }
859 }
860
861 unsafe impl<D: fidl::encoding::ResourceDialect>
862 fidl::encoding::Encode<DeviceSetConfigResponse, D> for &DeviceSetConfigResponse
863 {
864 #[inline]
865 unsafe fn encode(
866 self,
867 encoder: &mut fidl::encoding::Encoder<'_, D>,
868 offset: usize,
869 _depth: fidl::encoding::Depth,
870 ) -> fidl::Result<()> {
871 encoder.debug_check_bounds::<DeviceSetConfigResponse>(offset);
872 unsafe {
873 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
875 (buf_ptr as *mut DeviceSetConfigResponse)
876 .write_unaligned((self as *const DeviceSetConfigResponse).read());
877 }
880 Ok(())
881 }
882 }
883 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
884 fidl::encoding::Encode<DeviceSetConfigResponse, D> for (T0,)
885 {
886 #[inline]
887 unsafe fn encode(
888 self,
889 encoder: &mut fidl::encoding::Encoder<'_, D>,
890 offset: usize,
891 depth: fidl::encoding::Depth,
892 ) -> fidl::Result<()> {
893 encoder.debug_check_bounds::<DeviceSetConfigResponse>(offset);
894 self.0.encode(encoder, offset + 0, depth)?;
898 Ok(())
899 }
900 }
901
902 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
903 for DeviceSetConfigResponse
904 {
905 #[inline(always)]
906 fn new_empty() -> Self {
907 Self { s: fidl::new_empty!(i32, D) }
908 }
909
910 #[inline]
911 unsafe fn decode(
912 &mut self,
913 decoder: &mut fidl::encoding::Decoder<'_, D>,
914 offset: usize,
915 _depth: fidl::encoding::Depth,
916 ) -> fidl::Result<()> {
917 decoder.debug_check_bounds::<Self>(offset);
918 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
919 unsafe {
922 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
923 }
924 Ok(())
925 }
926 }
927
928 impl fidl::encoding::ValueTypeMarker for DeviceWriteRequest {
929 type Borrowed<'a> = &'a Self;
930 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
931 value
932 }
933 }
934
935 unsafe impl fidl::encoding::TypeMarker for DeviceWriteRequest {
936 type Owned = Self;
937
938 #[inline(always)]
939 fn inline_align(_context: fidl::encoding::Context) -> usize {
940 8
941 }
942
943 #[inline(always)]
944 fn inline_size(_context: fidl::encoding::Context) -> usize {
945 16
946 }
947 }
948
949 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceWriteRequest, D>
950 for &DeviceWriteRequest
951 {
952 #[inline]
953 unsafe fn encode(
954 self,
955 encoder: &mut fidl::encoding::Encoder<'_, D>,
956 offset: usize,
957 _depth: fidl::encoding::Depth,
958 ) -> fidl::Result<()> {
959 encoder.debug_check_bounds::<DeviceWriteRequest>(offset);
960 fidl::encoding::Encode::<DeviceWriteRequest, D>::encode(
962 (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
963 &self.data,
964 ),),
965 encoder,
966 offset,
967 _depth,
968 )
969 }
970 }
971 unsafe impl<
972 D: fidl::encoding::ResourceDialect,
973 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
974 > fidl::encoding::Encode<DeviceWriteRequest, D> for (T0,)
975 {
976 #[inline]
977 unsafe fn encode(
978 self,
979 encoder: &mut fidl::encoding::Encoder<'_, D>,
980 offset: usize,
981 depth: fidl::encoding::Depth,
982 ) -> fidl::Result<()> {
983 encoder.debug_check_bounds::<DeviceWriteRequest>(offset);
984 self.0.encode(encoder, offset + 0, depth)?;
988 Ok(())
989 }
990 }
991
992 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceWriteRequest {
993 #[inline(always)]
994 fn new_empty() -> Self {
995 Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
996 }
997
998 #[inline]
999 unsafe fn decode(
1000 &mut self,
1001 decoder: &mut fidl::encoding::Decoder<'_, D>,
1002 offset: usize,
1003 _depth: fidl::encoding::Depth,
1004 ) -> fidl::Result<()> {
1005 decoder.debug_check_bounds::<Self>(offset);
1006 fidl::decode!(
1008 fidl::encoding::UnboundedVector<u8>,
1009 D,
1010 &mut self.data,
1011 decoder,
1012 offset + 0,
1013 _depth
1014 )?;
1015 Ok(())
1016 }
1017 }
1018
1019 impl fidl::encoding::ValueTypeMarker for DeviceReadResponse {
1020 type Borrowed<'a> = &'a Self;
1021 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1022 value
1023 }
1024 }
1025
1026 unsafe impl fidl::encoding::TypeMarker for DeviceReadResponse {
1027 type Owned = Self;
1028
1029 #[inline(always)]
1030 fn inline_align(_context: fidl::encoding::Context) -> usize {
1031 8
1032 }
1033
1034 #[inline(always)]
1035 fn inline_size(_context: fidl::encoding::Context) -> usize {
1036 16
1037 }
1038 }
1039
1040 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceReadResponse, D>
1041 for &DeviceReadResponse
1042 {
1043 #[inline]
1044 unsafe fn encode(
1045 self,
1046 encoder: &mut fidl::encoding::Encoder<'_, D>,
1047 offset: usize,
1048 _depth: fidl::encoding::Depth,
1049 ) -> fidl::Result<()> {
1050 encoder.debug_check_bounds::<DeviceReadResponse>(offset);
1051 fidl::encoding::Encode::<DeviceReadResponse, D>::encode(
1053 (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
1054 &self.data,
1055 ),),
1056 encoder,
1057 offset,
1058 _depth,
1059 )
1060 }
1061 }
1062 unsafe impl<
1063 D: fidl::encoding::ResourceDialect,
1064 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
1065 > fidl::encoding::Encode<DeviceReadResponse, D> for (T0,)
1066 {
1067 #[inline]
1068 unsafe fn encode(
1069 self,
1070 encoder: &mut fidl::encoding::Encoder<'_, D>,
1071 offset: usize,
1072 depth: fidl::encoding::Depth,
1073 ) -> fidl::Result<()> {
1074 encoder.debug_check_bounds::<DeviceReadResponse>(offset);
1075 self.0.encode(encoder, offset + 0, depth)?;
1079 Ok(())
1080 }
1081 }
1082
1083 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceReadResponse {
1084 #[inline(always)]
1085 fn new_empty() -> Self {
1086 Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
1087 }
1088
1089 #[inline]
1090 unsafe fn decode(
1091 &mut self,
1092 decoder: &mut fidl::encoding::Decoder<'_, D>,
1093 offset: usize,
1094 _depth: fidl::encoding::Depth,
1095 ) -> fidl::Result<()> {
1096 decoder.debug_check_bounds::<Self>(offset);
1097 fidl::decode!(
1099 fidl::encoding::UnboundedVector<u8>,
1100 D,
1101 &mut self.data,
1102 decoder,
1103 offset + 0,
1104 _depth
1105 )?;
1106 Ok(())
1107 }
1108 }
1109
1110 impl fidl::encoding::ValueTypeMarker for SerialPortInfo {
1111 type Borrowed<'a> = &'a Self;
1112 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1113 value
1114 }
1115 }
1116
1117 unsafe impl fidl::encoding::TypeMarker for SerialPortInfo {
1118 type Owned = Self;
1119
1120 #[inline(always)]
1121 fn inline_align(_context: fidl::encoding::Context) -> usize {
1122 4
1123 }
1124
1125 #[inline(always)]
1126 fn inline_size(_context: fidl::encoding::Context) -> usize {
1127 12
1128 }
1129 }
1130
1131 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SerialPortInfo, D>
1132 for &SerialPortInfo
1133 {
1134 #[inline]
1135 unsafe fn encode(
1136 self,
1137 encoder: &mut fidl::encoding::Encoder<'_, D>,
1138 offset: usize,
1139 _depth: fidl::encoding::Depth,
1140 ) -> fidl::Result<()> {
1141 encoder.debug_check_bounds::<SerialPortInfo>(offset);
1142 fidl::encoding::Encode::<SerialPortInfo, D>::encode(
1144 (
1145 <Class as fidl::encoding::ValueTypeMarker>::borrow(&self.serial_class),
1146 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.serial_vid),
1147 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.serial_pid),
1148 ),
1149 encoder,
1150 offset,
1151 _depth,
1152 )
1153 }
1154 }
1155 unsafe impl<
1156 D: fidl::encoding::ResourceDialect,
1157 T0: fidl::encoding::Encode<Class, D>,
1158 T1: fidl::encoding::Encode<u32, D>,
1159 T2: fidl::encoding::Encode<u32, D>,
1160 > fidl::encoding::Encode<SerialPortInfo, D> for (T0, T1, T2)
1161 {
1162 #[inline]
1163 unsafe fn encode(
1164 self,
1165 encoder: &mut fidl::encoding::Encoder<'_, D>,
1166 offset: usize,
1167 depth: fidl::encoding::Depth,
1168 ) -> fidl::Result<()> {
1169 encoder.debug_check_bounds::<SerialPortInfo>(offset);
1170 unsafe {
1173 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1174 (ptr as *mut u32).write_unaligned(0);
1175 }
1176 self.0.encode(encoder, offset + 0, depth)?;
1178 self.1.encode(encoder, offset + 4, depth)?;
1179 self.2.encode(encoder, offset + 8, depth)?;
1180 Ok(())
1181 }
1182 }
1183
1184 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SerialPortInfo {
1185 #[inline(always)]
1186 fn new_empty() -> Self {
1187 Self {
1188 serial_class: fidl::new_empty!(Class, D),
1189 serial_vid: fidl::new_empty!(u32, D),
1190 serial_pid: fidl::new_empty!(u32, D),
1191 }
1192 }
1193
1194 #[inline]
1195 unsafe fn decode(
1196 &mut self,
1197 decoder: &mut fidl::encoding::Decoder<'_, D>,
1198 offset: usize,
1199 _depth: fidl::encoding::Depth,
1200 ) -> fidl::Result<()> {
1201 decoder.debug_check_bounds::<Self>(offset);
1202 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1204 let padval = unsafe { (ptr as *const u32).read_unaligned() };
1205 let mask = 0xffffff00u32;
1206 let maskedval = padval & mask;
1207 if maskedval != 0 {
1208 return Err(fidl::Error::NonZeroPadding {
1209 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1210 });
1211 }
1212 fidl::decode!(Class, D, &mut self.serial_class, decoder, offset + 0, _depth)?;
1213 fidl::decode!(u32, D, &mut self.serial_vid, decoder, offset + 4, _depth)?;
1214 fidl::decode!(u32, D, &mut self.serial_pid, decoder, offset + 8, _depth)?;
1215 Ok(())
1216 }
1217 }
1218}