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
11bitflags! {
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13 pub struct FlexibleButtons: u32 {
14 const PLAY = 1;
15 const PAUSE = 2;
16 const STOP = 4;
17 }
18}
19
20impl FlexibleButtons {
21 #[inline(always)]
22 pub fn from_bits_allow_unknown(bits: u32) -> Self {
23 Self::from_bits_retain(bits)
24 }
25
26 #[inline(always)]
27 pub fn has_unknown_bits(&self) -> bool {
28 self.get_unknown_bits() != 0
29 }
30
31 #[inline(always)]
32 pub fn get_unknown_bits(&self) -> u32 {
33 self.bits() & !Self::all().bits()
34 }
35}
36
37bitflags! {
38 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
39 pub struct StrictButtons: u32 {
40 const PLAY = 1;
41 const PAUSE = 2;
42 const STOP = 4;
43 }
44}
45
46impl StrictButtons {
47 #[deprecated = "Strict bits should not use `has_unknown_bits`"]
48 #[inline(always)]
49 pub fn has_unknown_bits(&self) -> bool {
50 false
51 }
52
53 #[deprecated = "Strict bits should not use `get_unknown_bits`"]
54 #[inline(always)]
55 pub fn get_unknown_bits(&self) -> u32 {
56 0
57 }
58}
59
60#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
61pub enum FlexibleAnimal {
62 Dog,
63 Cat,
64 Frog,
65 #[doc(hidden)]
66 __SourceBreaking {
67 unknown_ordinal: i32,
68 },
69}
70
71#[macro_export]
73macro_rules! FlexibleAnimalUnknown {
74 () => {
75 _
76 };
77}
78
79impl FlexibleAnimal {
80 #[inline]
81 pub fn from_primitive(prim: i32) -> Option<Self> {
82 match prim {
83 0 => Some(Self::Dog),
84 1 => Some(Self::Cat),
85 2 => Some(Self::Frog),
86 _ => None,
87 }
88 }
89
90 #[inline]
91 pub fn from_primitive_allow_unknown(prim: i32) -> Self {
92 match prim {
93 0 => Self::Dog,
94 1 => Self::Cat,
95 2 => Self::Frog,
96 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
97 }
98 }
99
100 #[inline]
101 pub fn unknown() -> Self {
102 Self::__SourceBreaking { unknown_ordinal: 0x7fffffff }
103 }
104
105 #[inline]
106 pub const fn into_primitive(self) -> i32 {
107 match self {
108 Self::Dog => 0,
109 Self::Cat => 1,
110 Self::Frog => 2,
111 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
112 }
113 }
114
115 #[inline]
116 pub fn is_unknown(&self) -> bool {
117 match self {
118 Self::__SourceBreaking { unknown_ordinal: _ } => true,
119 _ => false,
120 }
121 }
122}
123
124#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
125pub enum FlexibleEmptyEnum {
126 #[doc(hidden)]
127 __SourceBreaking { unknown_ordinal: i32 },
128}
129
130#[macro_export]
132macro_rules! FlexibleEmptyEnumUnknown {
133 () => {
134 _
135 };
136}
137
138impl FlexibleEmptyEnum {
139 #[inline]
140 pub fn from_primitive(prim: i32) -> Option<Self> {
141 match prim {
142 _ => None,
143 }
144 }
145
146 #[inline]
147 pub fn from_primitive_allow_unknown(prim: i32) -> Self {
148 match prim {
149 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
150 }
151 }
152
153 #[inline]
154 pub fn unknown() -> Self {
155 Self::__SourceBreaking { unknown_ordinal: 0x7fffffff }
156 }
157
158 #[inline]
159 pub const fn into_primitive(self) -> i32 {
160 match self {
161 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
162 }
163 }
164
165 #[inline]
166 pub fn is_unknown(&self) -> bool {
167 match self {
168 Self::__SourceBreaking { unknown_ordinal: _ } => true,
169 }
170 }
171}
172
173#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
174#[repr(i32)]
175pub enum StrictAnimal {
176 Dog = 0,
177 Cat = 1,
178 Frog = 2,
179}
180
181impl StrictAnimal {
182 #[inline]
183 pub fn from_primitive(prim: i32) -> Option<Self> {
184 match prim {
185 0 => Some(Self::Dog),
186 1 => Some(Self::Cat),
187 2 => Some(Self::Frog),
188 _ => None,
189 }
190 }
191
192 #[inline]
193 pub const fn into_primitive(self) -> i32 {
194 self as i32
195 }
196
197 #[deprecated = "Strict enums should not use `is_unknown`"]
198 #[inline]
199 pub fn is_unknown(&self) -> bool {
200 false
201 }
202}
203
204#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
205#[repr(C)]
206pub struct Coordinate {
207 pub x: u8,
208 pub y: u8,
209}
210
211impl fidl::Persistable for Coordinate {}
212
213#[derive(Clone, Debug, Default, PartialEq)]
214pub struct ValueRecord {
215 pub name: Option<String>,
216 pub age: Option<u8>,
217 #[doc(hidden)]
218 pub __source_breaking: fidl::marker::SourceBreaking,
219}
220
221impl fidl::Persistable for ValueRecord {}
222
223#[derive(Clone, Debug)]
224pub enum FlexibleValueThing {
225 Number(u32),
226 Name(String),
227 #[doc(hidden)]
228 __SourceBreaking {
229 unknown_ordinal: u64,
230 },
231}
232
233#[macro_export]
235macro_rules! FlexibleValueThingUnknown {
236 () => {
237 _
238 };
239}
240
241impl PartialEq for FlexibleValueThing {
243 fn eq(&self, other: &Self) -> bool {
244 match (self, other) {
245 (Self::Number(x), Self::Number(y)) => *x == *y,
246 (Self::Name(x), Self::Name(y)) => *x == *y,
247 _ => false,
248 }
249 }
250}
251
252impl FlexibleValueThing {
253 #[inline]
254 pub fn ordinal(&self) -> u64 {
255 match *self {
256 Self::Number(_) => 1,
257 Self::Name(_) => 2,
258 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
259 }
260 }
261
262 #[inline]
263 pub fn unknown_variant_for_testing() -> Self {
264 Self::__SourceBreaking { unknown_ordinal: 0 }
265 }
266
267 #[inline]
268 pub fn is_unknown(&self) -> bool {
269 match self {
270 Self::__SourceBreaking { .. } => true,
271 _ => false,
272 }
273 }
274}
275
276impl fidl::Persistable for FlexibleValueThing {}
277
278#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
279pub enum StrictValueThing {
280 Number(u32),
281 Name(String),
282}
283
284impl StrictValueThing {
285 #[inline]
286 pub fn ordinal(&self) -> u64 {
287 match *self {
288 Self::Number(_) => 1,
289 Self::Name(_) => 2,
290 }
291 }
292
293 #[deprecated = "Strict unions should not use `is_unknown`"]
294 #[inline]
295 pub fn is_unknown(&self) -> bool {
296 false
297 }
298}
299
300impl fidl::Persistable for StrictValueThing {}
301
302mod internal {
303 use super::*;
304 unsafe impl fidl::encoding::TypeMarker for FlexibleButtons {
305 type Owned = Self;
306
307 #[inline(always)]
308 fn inline_align(_context: fidl::encoding::Context) -> usize {
309 4
310 }
311
312 #[inline(always)]
313 fn inline_size(_context: fidl::encoding::Context) -> usize {
314 4
315 }
316 }
317
318 impl fidl::encoding::ValueTypeMarker for FlexibleButtons {
319 type Borrowed<'a> = Self;
320 #[inline(always)]
321 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
322 *value
323 }
324 }
325
326 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
327 for FlexibleButtons
328 {
329 #[inline]
330 unsafe fn encode(
331 self,
332 encoder: &mut fidl::encoding::Encoder<'_, D>,
333 offset: usize,
334 _depth: fidl::encoding::Depth,
335 ) -> fidl::Result<()> {
336 encoder.debug_check_bounds::<Self>(offset);
337 encoder.write_num(self.bits(), offset);
338 Ok(())
339 }
340 }
341
342 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexibleButtons {
343 #[inline(always)]
344 fn new_empty() -> Self {
345 Self::empty()
346 }
347
348 #[inline]
349 unsafe fn decode(
350 &mut self,
351 decoder: &mut fidl::encoding::Decoder<'_, D>,
352 offset: usize,
353 _depth: fidl::encoding::Depth,
354 ) -> fidl::Result<()> {
355 decoder.debug_check_bounds::<Self>(offset);
356 let prim = decoder.read_num::<u32>(offset);
357 *self = Self::from_bits_allow_unknown(prim);
358 Ok(())
359 }
360 }
361 unsafe impl fidl::encoding::TypeMarker for StrictButtons {
362 type Owned = Self;
363
364 #[inline(always)]
365 fn inline_align(_context: fidl::encoding::Context) -> usize {
366 4
367 }
368
369 #[inline(always)]
370 fn inline_size(_context: fidl::encoding::Context) -> usize {
371 4
372 }
373 }
374
375 impl fidl::encoding::ValueTypeMarker for StrictButtons {
376 type Borrowed<'a> = Self;
377 #[inline(always)]
378 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
379 *value
380 }
381 }
382
383 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StrictButtons {
384 #[inline]
385 unsafe fn encode(
386 self,
387 encoder: &mut fidl::encoding::Encoder<'_, D>,
388 offset: usize,
389 _depth: fidl::encoding::Depth,
390 ) -> fidl::Result<()> {
391 encoder.debug_check_bounds::<Self>(offset);
392 if self.bits() & Self::all().bits() != self.bits() {
393 return Err(fidl::Error::InvalidBitsValue);
394 }
395 encoder.write_num(self.bits(), offset);
396 Ok(())
397 }
398 }
399
400 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictButtons {
401 #[inline(always)]
402 fn new_empty() -> Self {
403 Self::empty()
404 }
405
406 #[inline]
407 unsafe fn decode(
408 &mut self,
409 decoder: &mut fidl::encoding::Decoder<'_, D>,
410 offset: usize,
411 _depth: fidl::encoding::Depth,
412 ) -> fidl::Result<()> {
413 decoder.debug_check_bounds::<Self>(offset);
414 let prim = decoder.read_num::<u32>(offset);
415 *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
416 Ok(())
417 }
418 }
419 unsafe impl fidl::encoding::TypeMarker for FlexibleAnimal {
420 type Owned = Self;
421
422 #[inline(always)]
423 fn inline_align(_context: fidl::encoding::Context) -> usize {
424 std::mem::align_of::<i32>()
425 }
426
427 #[inline(always)]
428 fn inline_size(_context: fidl::encoding::Context) -> usize {
429 std::mem::size_of::<i32>()
430 }
431
432 #[inline(always)]
433 fn encode_is_copy() -> bool {
434 false
435 }
436
437 #[inline(always)]
438 fn decode_is_copy() -> bool {
439 false
440 }
441 }
442
443 impl fidl::encoding::ValueTypeMarker for FlexibleAnimal {
444 type Borrowed<'a> = Self;
445 #[inline(always)]
446 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
447 *value
448 }
449 }
450
451 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for FlexibleAnimal {
452 #[inline]
453 unsafe fn encode(
454 self,
455 encoder: &mut fidl::encoding::Encoder<'_, D>,
456 offset: usize,
457 _depth: fidl::encoding::Depth,
458 ) -> fidl::Result<()> {
459 encoder.debug_check_bounds::<Self>(offset);
460 encoder.write_num(self.into_primitive(), offset);
461 Ok(())
462 }
463 }
464
465 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexibleAnimal {
466 #[inline(always)]
467 fn new_empty() -> Self {
468 Self::unknown()
469 }
470
471 #[inline]
472 unsafe fn decode(
473 &mut self,
474 decoder: &mut fidl::encoding::Decoder<'_, D>,
475 offset: usize,
476 _depth: fidl::encoding::Depth,
477 ) -> fidl::Result<()> {
478 decoder.debug_check_bounds::<Self>(offset);
479 let prim = decoder.read_num::<i32>(offset);
480
481 *self = Self::from_primitive_allow_unknown(prim);
482 Ok(())
483 }
484 }
485 unsafe impl fidl::encoding::TypeMarker for FlexibleEmptyEnum {
486 type Owned = Self;
487
488 #[inline(always)]
489 fn inline_align(_context: fidl::encoding::Context) -> usize {
490 std::mem::align_of::<i32>()
491 }
492
493 #[inline(always)]
494 fn inline_size(_context: fidl::encoding::Context) -> usize {
495 std::mem::size_of::<i32>()
496 }
497
498 #[inline(always)]
499 fn encode_is_copy() -> bool {
500 false
501 }
502
503 #[inline(always)]
504 fn decode_is_copy() -> bool {
505 false
506 }
507 }
508
509 impl fidl::encoding::ValueTypeMarker for FlexibleEmptyEnum {
510 type Borrowed<'a> = Self;
511 #[inline(always)]
512 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
513 *value
514 }
515 }
516
517 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
518 for FlexibleEmptyEnum
519 {
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 FlexibleEmptyEnum {
534 #[inline(always)]
535 fn new_empty() -> Self {
536 Self::unknown()
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::<i32>(offset);
548
549 *self = Self::from_primitive_allow_unknown(prim);
550 Ok(())
551 }
552 }
553 unsafe impl fidl::encoding::TypeMarker for StrictAnimal {
554 type Owned = Self;
555
556 #[inline(always)]
557 fn inline_align(_context: fidl::encoding::Context) -> usize {
558 std::mem::align_of::<i32>()
559 }
560
561 #[inline(always)]
562 fn inline_size(_context: fidl::encoding::Context) -> usize {
563 std::mem::size_of::<i32>()
564 }
565
566 #[inline(always)]
567 fn encode_is_copy() -> bool {
568 true
569 }
570
571 #[inline(always)]
572 fn decode_is_copy() -> bool {
573 false
574 }
575 }
576
577 impl fidl::encoding::ValueTypeMarker for StrictAnimal {
578 type Borrowed<'a> = Self;
579 #[inline(always)]
580 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
581 *value
582 }
583 }
584
585 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StrictAnimal {
586 #[inline]
587 unsafe fn encode(
588 self,
589 encoder: &mut fidl::encoding::Encoder<'_, D>,
590 offset: usize,
591 _depth: fidl::encoding::Depth,
592 ) -> fidl::Result<()> {
593 encoder.debug_check_bounds::<Self>(offset);
594 encoder.write_num(self.into_primitive(), offset);
595 Ok(())
596 }
597 }
598
599 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictAnimal {
600 #[inline(always)]
601 fn new_empty() -> Self {
602 Self::Dog
603 }
604
605 #[inline]
606 unsafe fn decode(
607 &mut self,
608 decoder: &mut fidl::encoding::Decoder<'_, D>,
609 offset: usize,
610 _depth: fidl::encoding::Depth,
611 ) -> fidl::Result<()> {
612 decoder.debug_check_bounds::<Self>(offset);
613 let prim = decoder.read_num::<i32>(offset);
614
615 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
616 Ok(())
617 }
618 }
619
620 impl fidl::encoding::ValueTypeMarker for Coordinate {
621 type Borrowed<'a> = &'a Self;
622 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
623 value
624 }
625 }
626
627 unsafe impl fidl::encoding::TypeMarker for Coordinate {
628 type Owned = Self;
629
630 #[inline(always)]
631 fn inline_align(_context: fidl::encoding::Context) -> usize {
632 1
633 }
634
635 #[inline(always)]
636 fn inline_size(_context: fidl::encoding::Context) -> usize {
637 2
638 }
639 #[inline(always)]
640 fn encode_is_copy() -> bool {
641 true
642 }
643
644 #[inline(always)]
645 fn decode_is_copy() -> bool {
646 true
647 }
648 }
649
650 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Coordinate, D>
651 for &Coordinate
652 {
653 #[inline]
654 unsafe fn encode(
655 self,
656 encoder: &mut fidl::encoding::Encoder<'_, D>,
657 offset: usize,
658 _depth: fidl::encoding::Depth,
659 ) -> fidl::Result<()> {
660 encoder.debug_check_bounds::<Coordinate>(offset);
661 unsafe {
662 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
664 (buf_ptr as *mut Coordinate).write_unaligned((self as *const Coordinate).read());
665 }
668 Ok(())
669 }
670 }
671 unsafe impl<
672 D: fidl::encoding::ResourceDialect,
673 T0: fidl::encoding::Encode<u8, D>,
674 T1: fidl::encoding::Encode<u8, D>,
675 > fidl::encoding::Encode<Coordinate, D> for (T0, T1)
676 {
677 #[inline]
678 unsafe fn encode(
679 self,
680 encoder: &mut fidl::encoding::Encoder<'_, D>,
681 offset: usize,
682 depth: fidl::encoding::Depth,
683 ) -> fidl::Result<()> {
684 encoder.debug_check_bounds::<Coordinate>(offset);
685 self.0.encode(encoder, offset + 0, depth)?;
689 self.1.encode(encoder, offset + 1, depth)?;
690 Ok(())
691 }
692 }
693
694 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Coordinate {
695 #[inline(always)]
696 fn new_empty() -> Self {
697 Self { x: fidl::new_empty!(u8, D), y: fidl::new_empty!(u8, D) }
698 }
699
700 #[inline]
701 unsafe fn decode(
702 &mut self,
703 decoder: &mut fidl::encoding::Decoder<'_, D>,
704 offset: usize,
705 _depth: fidl::encoding::Depth,
706 ) -> fidl::Result<()> {
707 decoder.debug_check_bounds::<Self>(offset);
708 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
709 unsafe {
712 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
713 }
714 Ok(())
715 }
716 }
717
718 impl ValueRecord {
719 #[inline(always)]
720 fn max_ordinal_present(&self) -> u64 {
721 if let Some(_) = self.age {
722 return 2;
723 }
724 if let Some(_) = self.name {
725 return 1;
726 }
727 0
728 }
729 }
730
731 impl fidl::encoding::ValueTypeMarker for ValueRecord {
732 type Borrowed<'a> = &'a Self;
733 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
734 value
735 }
736 }
737
738 unsafe impl fidl::encoding::TypeMarker for ValueRecord {
739 type Owned = Self;
740
741 #[inline(always)]
742 fn inline_align(_context: fidl::encoding::Context) -> usize {
743 8
744 }
745
746 #[inline(always)]
747 fn inline_size(_context: fidl::encoding::Context) -> usize {
748 16
749 }
750 }
751
752 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ValueRecord, D>
753 for &ValueRecord
754 {
755 unsafe fn encode(
756 self,
757 encoder: &mut fidl::encoding::Encoder<'_, D>,
758 offset: usize,
759 mut depth: fidl::encoding::Depth,
760 ) -> fidl::Result<()> {
761 encoder.debug_check_bounds::<ValueRecord>(offset);
762 let max_ordinal: u64 = self.max_ordinal_present();
764 encoder.write_num(max_ordinal, offset);
765 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
766 if max_ordinal == 0 {
768 return Ok(());
769 }
770 depth.increment()?;
771 let envelope_size = 8;
772 let bytes_len = max_ordinal as usize * envelope_size;
773 #[allow(unused_variables)]
774 let offset = encoder.out_of_line_offset(bytes_len);
775 let mut _prev_end_offset: usize = 0;
776 if 1 > max_ordinal {
777 return Ok(());
778 }
779
780 let cur_offset: usize = (1 - 1) * envelope_size;
783
784 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
786
787 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
792 self.name.as_ref().map(
793 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
794 ),
795 encoder,
796 offset + cur_offset,
797 depth,
798 )?;
799
800 _prev_end_offset = cur_offset + envelope_size;
801 if 2 > max_ordinal {
802 return Ok(());
803 }
804
805 let cur_offset: usize = (2 - 1) * envelope_size;
808
809 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
811
812 fidl::encoding::encode_in_envelope_optional::<u8, D>(
817 self.age.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
818 encoder,
819 offset + cur_offset,
820 depth,
821 )?;
822
823 _prev_end_offset = cur_offset + envelope_size;
824
825 Ok(())
826 }
827 }
828
829 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ValueRecord {
830 #[inline(always)]
831 fn new_empty() -> Self {
832 Self::default()
833 }
834
835 unsafe fn decode(
836 &mut self,
837 decoder: &mut fidl::encoding::Decoder<'_, D>,
838 offset: usize,
839 mut depth: fidl::encoding::Depth,
840 ) -> fidl::Result<()> {
841 decoder.debug_check_bounds::<Self>(offset);
842 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
843 None => return Err(fidl::Error::NotNullable),
844 Some(len) => len,
845 };
846 if len == 0 {
848 return Ok(());
849 };
850 depth.increment()?;
851 let envelope_size = 8;
852 let bytes_len = len * envelope_size;
853 let offset = decoder.out_of_line_offset(bytes_len)?;
854 let mut _next_ordinal_to_read = 0;
856 let mut next_offset = offset;
857 let end_offset = offset + bytes_len;
858 _next_ordinal_to_read += 1;
859 if next_offset >= end_offset {
860 return Ok(());
861 }
862
863 while _next_ordinal_to_read < 1 {
865 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
866 _next_ordinal_to_read += 1;
867 next_offset += envelope_size;
868 }
869
870 let next_out_of_line = decoder.next_out_of_line();
871 let handles_before = decoder.remaining_handles();
872 if let Some((inlined, num_bytes, num_handles)) =
873 fidl::encoding::decode_envelope_header(decoder, next_offset)?
874 {
875 let member_inline_size =
876 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
877 decoder.context,
878 );
879 if inlined != (member_inline_size <= 4) {
880 return Err(fidl::Error::InvalidInlineBitInEnvelope);
881 }
882 let inner_offset;
883 let mut inner_depth = depth.clone();
884 if inlined {
885 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
886 inner_offset = next_offset;
887 } else {
888 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
889 inner_depth.increment()?;
890 }
891 let val_ref = self
892 .name
893 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
894 fidl::decode!(
895 fidl::encoding::UnboundedString,
896 D,
897 val_ref,
898 decoder,
899 inner_offset,
900 inner_depth
901 )?;
902 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
903 {
904 return Err(fidl::Error::InvalidNumBytesInEnvelope);
905 }
906 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
907 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
908 }
909 }
910
911 next_offset += envelope_size;
912 _next_ordinal_to_read += 1;
913 if next_offset >= end_offset {
914 return Ok(());
915 }
916
917 while _next_ordinal_to_read < 2 {
919 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
920 _next_ordinal_to_read += 1;
921 next_offset += envelope_size;
922 }
923
924 let next_out_of_line = decoder.next_out_of_line();
925 let handles_before = decoder.remaining_handles();
926 if let Some((inlined, num_bytes, num_handles)) =
927 fidl::encoding::decode_envelope_header(decoder, next_offset)?
928 {
929 let member_inline_size =
930 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
931 if inlined != (member_inline_size <= 4) {
932 return Err(fidl::Error::InvalidInlineBitInEnvelope);
933 }
934 let inner_offset;
935 let mut inner_depth = depth.clone();
936 if inlined {
937 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
938 inner_offset = next_offset;
939 } else {
940 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
941 inner_depth.increment()?;
942 }
943 let val_ref = self.age.get_or_insert_with(|| fidl::new_empty!(u8, D));
944 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
945 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
946 {
947 return Err(fidl::Error::InvalidNumBytesInEnvelope);
948 }
949 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
950 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
951 }
952 }
953
954 next_offset += envelope_size;
955
956 while next_offset < end_offset {
958 _next_ordinal_to_read += 1;
959 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
960 next_offset += envelope_size;
961 }
962
963 Ok(())
964 }
965 }
966
967 impl fidl::encoding::ValueTypeMarker for FlexibleValueThing {
968 type Borrowed<'a> = &'a Self;
969 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
970 value
971 }
972 }
973
974 unsafe impl fidl::encoding::TypeMarker for FlexibleValueThing {
975 type Owned = Self;
976
977 #[inline(always)]
978 fn inline_align(_context: fidl::encoding::Context) -> usize {
979 8
980 }
981
982 #[inline(always)]
983 fn inline_size(_context: fidl::encoding::Context) -> usize {
984 16
985 }
986 }
987
988 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FlexibleValueThing, D>
989 for &FlexibleValueThing
990 {
991 #[inline]
992 unsafe fn encode(
993 self,
994 encoder: &mut fidl::encoding::Encoder<'_, D>,
995 offset: usize,
996 _depth: fidl::encoding::Depth,
997 ) -> fidl::Result<()> {
998 encoder.debug_check_bounds::<FlexibleValueThing>(offset);
999 encoder.write_num::<u64>(self.ordinal(), offset);
1000 match self {
1001 FlexibleValueThing::Number(ref val) => {
1002 fidl::encoding::encode_in_envelope::<u32, D>(
1003 <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
1004 encoder,
1005 offset + 8,
1006 _depth,
1007 )
1008 }
1009 FlexibleValueThing::Name(ref val) => fidl::encoding::encode_in_envelope::<
1010 fidl::encoding::UnboundedString,
1011 D,
1012 >(
1013 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
1014 val,
1015 ),
1016 encoder,
1017 offset + 8,
1018 _depth,
1019 ),
1020 FlexibleValueThing::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1021 }
1022 }
1023 }
1024
1025 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexibleValueThing {
1026 #[inline(always)]
1027 fn new_empty() -> Self {
1028 Self::__SourceBreaking { unknown_ordinal: 0 }
1029 }
1030
1031 #[inline]
1032 unsafe fn decode(
1033 &mut self,
1034 decoder: &mut fidl::encoding::Decoder<'_, D>,
1035 offset: usize,
1036 mut depth: fidl::encoding::Depth,
1037 ) -> fidl::Result<()> {
1038 decoder.debug_check_bounds::<Self>(offset);
1039 #[allow(unused_variables)]
1040 let next_out_of_line = decoder.next_out_of_line();
1041 let handles_before = decoder.remaining_handles();
1042 let (ordinal, inlined, num_bytes, num_handles) =
1043 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1044
1045 let member_inline_size = match ordinal {
1046 1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1047 2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1048 decoder.context,
1049 ),
1050 0 => return Err(fidl::Error::UnknownUnionTag),
1051 _ => num_bytes as usize,
1052 };
1053
1054 if inlined != (member_inline_size <= 4) {
1055 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1056 }
1057 let _inner_offset;
1058 if inlined {
1059 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1060 _inner_offset = offset + 8;
1061 } else {
1062 depth.increment()?;
1063 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1064 }
1065 match ordinal {
1066 1 => {
1067 #[allow(irrefutable_let_patterns)]
1068 if let FlexibleValueThing::Number(_) = self {
1069 } else {
1071 *self = FlexibleValueThing::Number(fidl::new_empty!(u32, D));
1073 }
1074 #[allow(irrefutable_let_patterns)]
1075 if let FlexibleValueThing::Number(ref mut val) = self {
1076 fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
1077 } else {
1078 unreachable!()
1079 }
1080 }
1081 2 => {
1082 #[allow(irrefutable_let_patterns)]
1083 if let FlexibleValueThing::Name(_) = self {
1084 } else {
1086 *self = FlexibleValueThing::Name(fidl::new_empty!(
1088 fidl::encoding::UnboundedString,
1089 D
1090 ));
1091 }
1092 #[allow(irrefutable_let_patterns)]
1093 if let FlexibleValueThing::Name(ref mut val) = self {
1094 fidl::decode!(
1095 fidl::encoding::UnboundedString,
1096 D,
1097 val,
1098 decoder,
1099 _inner_offset,
1100 depth
1101 )?;
1102 } else {
1103 unreachable!()
1104 }
1105 }
1106 #[allow(deprecated)]
1107 ordinal => {
1108 for _ in 0..num_handles {
1109 decoder.drop_next_handle()?;
1110 }
1111 *self = FlexibleValueThing::__SourceBreaking { unknown_ordinal: ordinal };
1112 }
1113 }
1114 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1115 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1116 }
1117 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1118 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1119 }
1120 Ok(())
1121 }
1122 }
1123
1124 impl fidl::encoding::ValueTypeMarker for StrictValueThing {
1125 type Borrowed<'a> = &'a Self;
1126 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1127 value
1128 }
1129 }
1130
1131 unsafe impl fidl::encoding::TypeMarker for StrictValueThing {
1132 type Owned = Self;
1133
1134 #[inline(always)]
1135 fn inline_align(_context: fidl::encoding::Context) -> usize {
1136 8
1137 }
1138
1139 #[inline(always)]
1140 fn inline_size(_context: fidl::encoding::Context) -> usize {
1141 16
1142 }
1143 }
1144
1145 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StrictValueThing, D>
1146 for &StrictValueThing
1147 {
1148 #[inline]
1149 unsafe fn encode(
1150 self,
1151 encoder: &mut fidl::encoding::Encoder<'_, D>,
1152 offset: usize,
1153 _depth: fidl::encoding::Depth,
1154 ) -> fidl::Result<()> {
1155 encoder.debug_check_bounds::<StrictValueThing>(offset);
1156 encoder.write_num::<u64>(self.ordinal(), offset);
1157 match self {
1158 StrictValueThing::Number(ref val) => fidl::encoding::encode_in_envelope::<u32, D>(
1159 <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
1160 encoder,
1161 offset + 8,
1162 _depth,
1163 ),
1164 StrictValueThing::Name(ref val) => fidl::encoding::encode_in_envelope::<
1165 fidl::encoding::UnboundedString,
1166 D,
1167 >(
1168 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
1169 val,
1170 ),
1171 encoder,
1172 offset + 8,
1173 _depth,
1174 ),
1175 }
1176 }
1177 }
1178
1179 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictValueThing {
1180 #[inline(always)]
1181 fn new_empty() -> Self {
1182 Self::Number(fidl::new_empty!(u32, D))
1183 }
1184
1185 #[inline]
1186 unsafe fn decode(
1187 &mut self,
1188 decoder: &mut fidl::encoding::Decoder<'_, D>,
1189 offset: usize,
1190 mut depth: fidl::encoding::Depth,
1191 ) -> fidl::Result<()> {
1192 decoder.debug_check_bounds::<Self>(offset);
1193 #[allow(unused_variables)]
1194 let next_out_of_line = decoder.next_out_of_line();
1195 let handles_before = decoder.remaining_handles();
1196 let (ordinal, inlined, num_bytes, num_handles) =
1197 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1198
1199 let member_inline_size = match ordinal {
1200 1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1201 2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1202 decoder.context,
1203 ),
1204 _ => return Err(fidl::Error::UnknownUnionTag),
1205 };
1206
1207 if inlined != (member_inline_size <= 4) {
1208 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1209 }
1210 let _inner_offset;
1211 if inlined {
1212 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1213 _inner_offset = offset + 8;
1214 } else {
1215 depth.increment()?;
1216 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1217 }
1218 match ordinal {
1219 1 => {
1220 #[allow(irrefutable_let_patterns)]
1221 if let StrictValueThing::Number(_) = self {
1222 } else {
1224 *self = StrictValueThing::Number(fidl::new_empty!(u32, D));
1226 }
1227 #[allow(irrefutable_let_patterns)]
1228 if let StrictValueThing::Number(ref mut val) = self {
1229 fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
1230 } else {
1231 unreachable!()
1232 }
1233 }
1234 2 => {
1235 #[allow(irrefutable_let_patterns)]
1236 if let StrictValueThing::Name(_) = self {
1237 } else {
1239 *self = StrictValueThing::Name(fidl::new_empty!(
1241 fidl::encoding::UnboundedString,
1242 D
1243 ));
1244 }
1245 #[allow(irrefutable_let_patterns)]
1246 if let StrictValueThing::Name(ref mut val) = self {
1247 fidl::decode!(
1248 fidl::encoding::UnboundedString,
1249 D,
1250 val,
1251 decoder,
1252 _inner_offset,
1253 depth
1254 )?;
1255 } else {
1256 unreachable!()
1257 }
1258 }
1259 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1260 }
1261 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1262 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1263 }
1264 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1265 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1266 }
1267 Ok(())
1268 }
1269 }
1270}