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