fidl_fidl_test_imported__common/
fidl_fidl_test_imported__common.rs

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