fidl_fuchsia_testing_common/
fidl_fuchsia_testing_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/// The type of event related to a deadline.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum DeadlineEventType {
15    /// The deadline was set.
16    Set = 1,
17    /// The deadline has been reached.
18    Expired = 2,
19}
20
21impl DeadlineEventType {
22    #[inline]
23    pub fn from_primitive(prim: u32) -> Option<Self> {
24        match prim {
25            1 => Some(Self::Set),
26            2 => Some(Self::Expired),
27            _ => None,
28        }
29    }
30
31    #[inline]
32    pub const fn into_primitive(self) -> u32 {
33        self as u32
34    }
35
36    #[deprecated = "Strict enums should not use `is_unknown`"]
37    #[inline]
38    pub fn is_unknown(&self) -> bool {
39        false
40    }
41}
42
43#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct FakeClockControlAdvanceRequest {
45    pub increment: Increment,
46}
47
48impl fidl::Persistable for FakeClockControlAdvanceRequest {}
49
50#[derive(Clone, Debug, PartialEq)]
51pub struct FakeClockControlIgnoreNamedDeadlineRequest {
52    pub deadline_id: fidl_fuchsia_testing_deadline::DeadlineId,
53}
54
55impl fidl::Persistable for FakeClockControlIgnoreNamedDeadlineRequest {}
56
57#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58pub struct FakeClockControlResumeWithIncrementsRequest {
59    pub real: i64,
60    pub increment: Increment,
61}
62
63impl fidl::Persistable for FakeClockControlResumeWithIncrementsRequest {}
64
65#[derive(Clone, Debug, PartialEq)]
66pub struct FakeClockCreateNamedDeadlineRequest {
67    pub id: fidl_fuchsia_testing_deadline::DeadlineId,
68    pub duration: i64,
69}
70
71impl fidl::Persistable for FakeClockCreateNamedDeadlineRequest {}
72
73#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74#[repr(C)]
75pub struct FakeClockCreateNamedDeadlineResponse {
76    pub deadline: i64,
77}
78
79impl fidl::Persistable for FakeClockCreateNamedDeadlineResponse {}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82#[repr(C)]
83pub struct FakeClockGetResponse {
84    pub time: i64,
85}
86
87impl fidl::Persistable for FakeClockGetResponse {}
88
89/// A fake clock increment in a uniform random range.
90#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91#[repr(C)]
92pub struct RandomRange {
93    /// The lower bound (inclusive) for the random duration.
94    pub min_rand: i64,
95    /// The upper bound (exclusive) for the random duration.
96    pub max_rand: i64,
97}
98
99impl fidl::Persistable for RandomRange {}
100
101/// A fake clock increment step.
102#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
103pub enum Increment {
104    /// Increments the fake clock by the `determined` duration.
105    Determined(i64),
106    /// Increments the fake clock by a random duration chosen uniformly from the range in `random`.
107    Random(RandomRange),
108}
109
110impl Increment {
111    #[inline]
112    pub fn ordinal(&self) -> u64 {
113        match *self {
114            Self::Determined(_) => 1,
115            Self::Random(_) => 2,
116        }
117    }
118
119    #[deprecated = "Strict unions should not use `is_unknown`"]
120    #[inline]
121    pub fn is_unknown(&self) -> bool {
122        false
123    }
124}
125
126impl fidl::Persistable for Increment {}
127
128mod internal {
129    use super::*;
130    unsafe impl fidl::encoding::TypeMarker for DeadlineEventType {
131        type Owned = Self;
132
133        #[inline(always)]
134        fn inline_align(_context: fidl::encoding::Context) -> usize {
135            std::mem::align_of::<u32>()
136        }
137
138        #[inline(always)]
139        fn inline_size(_context: fidl::encoding::Context) -> usize {
140            std::mem::size_of::<u32>()
141        }
142
143        #[inline(always)]
144        fn encode_is_copy() -> bool {
145            true
146        }
147
148        #[inline(always)]
149        fn decode_is_copy() -> bool {
150            false
151        }
152    }
153
154    impl fidl::encoding::ValueTypeMarker for DeadlineEventType {
155        type Borrowed<'a> = Self;
156        #[inline(always)]
157        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
158            *value
159        }
160    }
161
162    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
163        for DeadlineEventType
164    {
165        #[inline]
166        unsafe fn encode(
167            self,
168            encoder: &mut fidl::encoding::Encoder<'_, D>,
169            offset: usize,
170            _depth: fidl::encoding::Depth,
171        ) -> fidl::Result<()> {
172            encoder.debug_check_bounds::<Self>(offset);
173            encoder.write_num(self.into_primitive(), offset);
174            Ok(())
175        }
176    }
177
178    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeadlineEventType {
179        #[inline(always)]
180        fn new_empty() -> Self {
181            Self::Set
182        }
183
184        #[inline]
185        unsafe fn decode(
186            &mut self,
187            decoder: &mut fidl::encoding::Decoder<'_, D>,
188            offset: usize,
189            _depth: fidl::encoding::Depth,
190        ) -> fidl::Result<()> {
191            decoder.debug_check_bounds::<Self>(offset);
192            let prim = decoder.read_num::<u32>(offset);
193
194            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
195            Ok(())
196        }
197    }
198
199    impl fidl::encoding::ValueTypeMarker for FakeClockControlAdvanceRequest {
200        type Borrowed<'a> = &'a Self;
201        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
202            value
203        }
204    }
205
206    unsafe impl fidl::encoding::TypeMarker for FakeClockControlAdvanceRequest {
207        type Owned = Self;
208
209        #[inline(always)]
210        fn inline_align(_context: fidl::encoding::Context) -> usize {
211            8
212        }
213
214        #[inline(always)]
215        fn inline_size(_context: fidl::encoding::Context) -> usize {
216            16
217        }
218    }
219
220    unsafe impl<D: fidl::encoding::ResourceDialect>
221        fidl::encoding::Encode<FakeClockControlAdvanceRequest, D>
222        for &FakeClockControlAdvanceRequest
223    {
224        #[inline]
225        unsafe fn encode(
226            self,
227            encoder: &mut fidl::encoding::Encoder<'_, D>,
228            offset: usize,
229            _depth: fidl::encoding::Depth,
230        ) -> fidl::Result<()> {
231            encoder.debug_check_bounds::<FakeClockControlAdvanceRequest>(offset);
232            // Delegate to tuple encoding.
233            fidl::encoding::Encode::<FakeClockControlAdvanceRequest, D>::encode(
234                (<Increment as fidl::encoding::ValueTypeMarker>::borrow(&self.increment),),
235                encoder,
236                offset,
237                _depth,
238            )
239        }
240    }
241    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Increment, D>>
242        fidl::encoding::Encode<FakeClockControlAdvanceRequest, D> for (T0,)
243    {
244        #[inline]
245        unsafe fn encode(
246            self,
247            encoder: &mut fidl::encoding::Encoder<'_, D>,
248            offset: usize,
249            depth: fidl::encoding::Depth,
250        ) -> fidl::Result<()> {
251            encoder.debug_check_bounds::<FakeClockControlAdvanceRequest>(offset);
252            // Zero out padding regions. There's no need to apply masks
253            // because the unmasked parts will be overwritten by fields.
254            // Write the fields.
255            self.0.encode(encoder, offset + 0, depth)?;
256            Ok(())
257        }
258    }
259
260    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
261        for FakeClockControlAdvanceRequest
262    {
263        #[inline(always)]
264        fn new_empty() -> Self {
265            Self { increment: fidl::new_empty!(Increment, D) }
266        }
267
268        #[inline]
269        unsafe fn decode(
270            &mut self,
271            decoder: &mut fidl::encoding::Decoder<'_, D>,
272            offset: usize,
273            _depth: fidl::encoding::Depth,
274        ) -> fidl::Result<()> {
275            decoder.debug_check_bounds::<Self>(offset);
276            // Verify that padding bytes are zero.
277            fidl::decode!(Increment, D, &mut self.increment, decoder, offset + 0, _depth)?;
278            Ok(())
279        }
280    }
281
282    impl fidl::encoding::ValueTypeMarker for FakeClockControlIgnoreNamedDeadlineRequest {
283        type Borrowed<'a> = &'a Self;
284        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
285            value
286        }
287    }
288
289    unsafe impl fidl::encoding::TypeMarker for FakeClockControlIgnoreNamedDeadlineRequest {
290        type Owned = Self;
291
292        #[inline(always)]
293        fn inline_align(_context: fidl::encoding::Context) -> usize {
294            8
295        }
296
297        #[inline(always)]
298        fn inline_size(_context: fidl::encoding::Context) -> usize {
299            32
300        }
301    }
302
303    unsafe impl<D: fidl::encoding::ResourceDialect>
304        fidl::encoding::Encode<FakeClockControlIgnoreNamedDeadlineRequest, D>
305        for &FakeClockControlIgnoreNamedDeadlineRequest
306    {
307        #[inline]
308        unsafe fn encode(
309            self,
310            encoder: &mut fidl::encoding::Encoder<'_, D>,
311            offset: usize,
312            _depth: fidl::encoding::Depth,
313        ) -> fidl::Result<()> {
314            encoder.debug_check_bounds::<FakeClockControlIgnoreNamedDeadlineRequest>(offset);
315            // Delegate to tuple encoding.
316            fidl::encoding::Encode::<FakeClockControlIgnoreNamedDeadlineRequest, D>::encode(
317                (
318                    <fidl_fuchsia_testing_deadline::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline_id),
319                ),
320                encoder, offset, _depth
321            )
322        }
323    }
324    unsafe impl<
325            D: fidl::encoding::ResourceDialect,
326            T0: fidl::encoding::Encode<fidl_fuchsia_testing_deadline::DeadlineId, D>,
327        > fidl::encoding::Encode<FakeClockControlIgnoreNamedDeadlineRequest, D> for (T0,)
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::<FakeClockControlIgnoreNamedDeadlineRequest>(offset);
337            // Zero out padding regions. There's no need to apply masks
338            // because the unmasked parts will be overwritten by fields.
339            // Write the fields.
340            self.0.encode(encoder, offset + 0, depth)?;
341            Ok(())
342        }
343    }
344
345    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
346        for FakeClockControlIgnoreNamedDeadlineRequest
347    {
348        #[inline(always)]
349        fn new_empty() -> Self {
350            Self { deadline_id: fidl::new_empty!(fidl_fuchsia_testing_deadline::DeadlineId, D) }
351        }
352
353        #[inline]
354        unsafe fn decode(
355            &mut self,
356            decoder: &mut fidl::encoding::Decoder<'_, D>,
357            offset: usize,
358            _depth: fidl::encoding::Depth,
359        ) -> fidl::Result<()> {
360            decoder.debug_check_bounds::<Self>(offset);
361            // Verify that padding bytes are zero.
362            fidl::decode!(
363                fidl_fuchsia_testing_deadline::DeadlineId,
364                D,
365                &mut self.deadline_id,
366                decoder,
367                offset + 0,
368                _depth
369            )?;
370            Ok(())
371        }
372    }
373
374    impl fidl::encoding::ValueTypeMarker for FakeClockControlResumeWithIncrementsRequest {
375        type Borrowed<'a> = &'a Self;
376        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
377            value
378        }
379    }
380
381    unsafe impl fidl::encoding::TypeMarker for FakeClockControlResumeWithIncrementsRequest {
382        type Owned = Self;
383
384        #[inline(always)]
385        fn inline_align(_context: fidl::encoding::Context) -> usize {
386            8
387        }
388
389        #[inline(always)]
390        fn inline_size(_context: fidl::encoding::Context) -> usize {
391            24
392        }
393    }
394
395    unsafe impl<D: fidl::encoding::ResourceDialect>
396        fidl::encoding::Encode<FakeClockControlResumeWithIncrementsRequest, D>
397        for &FakeClockControlResumeWithIncrementsRequest
398    {
399        #[inline]
400        unsafe fn encode(
401            self,
402            encoder: &mut fidl::encoding::Encoder<'_, D>,
403            offset: usize,
404            _depth: fidl::encoding::Depth,
405        ) -> fidl::Result<()> {
406            encoder.debug_check_bounds::<FakeClockControlResumeWithIncrementsRequest>(offset);
407            // Delegate to tuple encoding.
408            fidl::encoding::Encode::<FakeClockControlResumeWithIncrementsRequest, D>::encode(
409                (
410                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.real),
411                    <Increment as fidl::encoding::ValueTypeMarker>::borrow(&self.increment),
412                ),
413                encoder,
414                offset,
415                _depth,
416            )
417        }
418    }
419    unsafe impl<
420            D: fidl::encoding::ResourceDialect,
421            T0: fidl::encoding::Encode<i64, D>,
422            T1: fidl::encoding::Encode<Increment, D>,
423        > fidl::encoding::Encode<FakeClockControlResumeWithIncrementsRequest, D> for (T0, T1)
424    {
425        #[inline]
426        unsafe fn encode(
427            self,
428            encoder: &mut fidl::encoding::Encoder<'_, D>,
429            offset: usize,
430            depth: fidl::encoding::Depth,
431        ) -> fidl::Result<()> {
432            encoder.debug_check_bounds::<FakeClockControlResumeWithIncrementsRequest>(offset);
433            // Zero out padding regions. There's no need to apply masks
434            // because the unmasked parts will be overwritten by fields.
435            // Write the fields.
436            self.0.encode(encoder, offset + 0, depth)?;
437            self.1.encode(encoder, offset + 8, depth)?;
438            Ok(())
439        }
440    }
441
442    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
443        for FakeClockControlResumeWithIncrementsRequest
444    {
445        #[inline(always)]
446        fn new_empty() -> Self {
447            Self { real: fidl::new_empty!(i64, D), increment: fidl::new_empty!(Increment, D) }
448        }
449
450        #[inline]
451        unsafe fn decode(
452            &mut self,
453            decoder: &mut fidl::encoding::Decoder<'_, D>,
454            offset: usize,
455            _depth: fidl::encoding::Depth,
456        ) -> fidl::Result<()> {
457            decoder.debug_check_bounds::<Self>(offset);
458            // Verify that padding bytes are zero.
459            fidl::decode!(i64, D, &mut self.real, decoder, offset + 0, _depth)?;
460            fidl::decode!(Increment, D, &mut self.increment, decoder, offset + 8, _depth)?;
461            Ok(())
462        }
463    }
464
465    impl fidl::encoding::ValueTypeMarker for FakeClockCreateNamedDeadlineRequest {
466        type Borrowed<'a> = &'a Self;
467        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
468            value
469        }
470    }
471
472    unsafe impl fidl::encoding::TypeMarker for FakeClockCreateNamedDeadlineRequest {
473        type Owned = Self;
474
475        #[inline(always)]
476        fn inline_align(_context: fidl::encoding::Context) -> usize {
477            8
478        }
479
480        #[inline(always)]
481        fn inline_size(_context: fidl::encoding::Context) -> usize {
482            40
483        }
484    }
485
486    unsafe impl<D: fidl::encoding::ResourceDialect>
487        fidl::encoding::Encode<FakeClockCreateNamedDeadlineRequest, D>
488        for &FakeClockCreateNamedDeadlineRequest
489    {
490        #[inline]
491        unsafe fn encode(
492            self,
493            encoder: &mut fidl::encoding::Encoder<'_, D>,
494            offset: usize,
495            _depth: fidl::encoding::Depth,
496        ) -> fidl::Result<()> {
497            encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineRequest>(offset);
498            // Delegate to tuple encoding.
499            fidl::encoding::Encode::<FakeClockCreateNamedDeadlineRequest, D>::encode(
500                (
501                    <fidl_fuchsia_testing_deadline::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
502                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.duration),
503                ),
504                encoder, offset, _depth
505            )
506        }
507    }
508    unsafe impl<
509            D: fidl::encoding::ResourceDialect,
510            T0: fidl::encoding::Encode<fidl_fuchsia_testing_deadline::DeadlineId, D>,
511            T1: fidl::encoding::Encode<i64, D>,
512        > fidl::encoding::Encode<FakeClockCreateNamedDeadlineRequest, D> for (T0, T1)
513    {
514        #[inline]
515        unsafe fn encode(
516            self,
517            encoder: &mut fidl::encoding::Encoder<'_, D>,
518            offset: usize,
519            depth: fidl::encoding::Depth,
520        ) -> fidl::Result<()> {
521            encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineRequest>(offset);
522            // Zero out padding regions. There's no need to apply masks
523            // because the unmasked parts will be overwritten by fields.
524            // Write the fields.
525            self.0.encode(encoder, offset + 0, depth)?;
526            self.1.encode(encoder, offset + 32, depth)?;
527            Ok(())
528        }
529    }
530
531    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
532        for FakeClockCreateNamedDeadlineRequest
533    {
534        #[inline(always)]
535        fn new_empty() -> Self {
536            Self {
537                id: fidl::new_empty!(fidl_fuchsia_testing_deadline::DeadlineId, D),
538                duration: fidl::new_empty!(i64, D),
539            }
540        }
541
542        #[inline]
543        unsafe fn decode(
544            &mut self,
545            decoder: &mut fidl::encoding::Decoder<'_, D>,
546            offset: usize,
547            _depth: fidl::encoding::Depth,
548        ) -> fidl::Result<()> {
549            decoder.debug_check_bounds::<Self>(offset);
550            // Verify that padding bytes are zero.
551            fidl::decode!(
552                fidl_fuchsia_testing_deadline::DeadlineId,
553                D,
554                &mut self.id,
555                decoder,
556                offset + 0,
557                _depth
558            )?;
559            fidl::decode!(i64, D, &mut self.duration, decoder, offset + 32, _depth)?;
560            Ok(())
561        }
562    }
563
564    impl fidl::encoding::ValueTypeMarker for FakeClockCreateNamedDeadlineResponse {
565        type Borrowed<'a> = &'a Self;
566        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
567            value
568        }
569    }
570
571    unsafe impl fidl::encoding::TypeMarker for FakeClockCreateNamedDeadlineResponse {
572        type Owned = Self;
573
574        #[inline(always)]
575        fn inline_align(_context: fidl::encoding::Context) -> usize {
576            8
577        }
578
579        #[inline(always)]
580        fn inline_size(_context: fidl::encoding::Context) -> usize {
581            8
582        }
583        #[inline(always)]
584        fn encode_is_copy() -> bool {
585            true
586        }
587
588        #[inline(always)]
589        fn decode_is_copy() -> bool {
590            true
591        }
592    }
593
594    unsafe impl<D: fidl::encoding::ResourceDialect>
595        fidl::encoding::Encode<FakeClockCreateNamedDeadlineResponse, D>
596        for &FakeClockCreateNamedDeadlineResponse
597    {
598        #[inline]
599        unsafe fn encode(
600            self,
601            encoder: &mut fidl::encoding::Encoder<'_, D>,
602            offset: usize,
603            _depth: fidl::encoding::Depth,
604        ) -> fidl::Result<()> {
605            encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineResponse>(offset);
606            unsafe {
607                // Copy the object into the buffer.
608                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
609                (buf_ptr as *mut FakeClockCreateNamedDeadlineResponse)
610                    .write_unaligned((self as *const FakeClockCreateNamedDeadlineResponse).read());
611                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
612                // done second because the memcpy will write garbage to these bytes.
613            }
614            Ok(())
615        }
616    }
617    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
618        fidl::encoding::Encode<FakeClockCreateNamedDeadlineResponse, D> for (T0,)
619    {
620        #[inline]
621        unsafe fn encode(
622            self,
623            encoder: &mut fidl::encoding::Encoder<'_, D>,
624            offset: usize,
625            depth: fidl::encoding::Depth,
626        ) -> fidl::Result<()> {
627            encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineResponse>(offset);
628            // Zero out padding regions. There's no need to apply masks
629            // because the unmasked parts will be overwritten by fields.
630            // Write the fields.
631            self.0.encode(encoder, offset + 0, depth)?;
632            Ok(())
633        }
634    }
635
636    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
637        for FakeClockCreateNamedDeadlineResponse
638    {
639        #[inline(always)]
640        fn new_empty() -> Self {
641            Self { deadline: fidl::new_empty!(i64, D) }
642        }
643
644        #[inline]
645        unsafe fn decode(
646            &mut self,
647            decoder: &mut fidl::encoding::Decoder<'_, D>,
648            offset: usize,
649            _depth: fidl::encoding::Depth,
650        ) -> fidl::Result<()> {
651            decoder.debug_check_bounds::<Self>(offset);
652            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
653            // Verify that padding bytes are zero.
654            // Copy from the buffer into the object.
655            unsafe {
656                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
657            }
658            Ok(())
659        }
660    }
661
662    impl fidl::encoding::ValueTypeMarker for FakeClockGetResponse {
663        type Borrowed<'a> = &'a Self;
664        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
665            value
666        }
667    }
668
669    unsafe impl fidl::encoding::TypeMarker for FakeClockGetResponse {
670        type Owned = Self;
671
672        #[inline(always)]
673        fn inline_align(_context: fidl::encoding::Context) -> usize {
674            8
675        }
676
677        #[inline(always)]
678        fn inline_size(_context: fidl::encoding::Context) -> usize {
679            8
680        }
681        #[inline(always)]
682        fn encode_is_copy() -> bool {
683            true
684        }
685
686        #[inline(always)]
687        fn decode_is_copy() -> bool {
688            true
689        }
690    }
691
692    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FakeClockGetResponse, D>
693        for &FakeClockGetResponse
694    {
695        #[inline]
696        unsafe fn encode(
697            self,
698            encoder: &mut fidl::encoding::Encoder<'_, D>,
699            offset: usize,
700            _depth: fidl::encoding::Depth,
701        ) -> fidl::Result<()> {
702            encoder.debug_check_bounds::<FakeClockGetResponse>(offset);
703            unsafe {
704                // Copy the object into the buffer.
705                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
706                (buf_ptr as *mut FakeClockGetResponse)
707                    .write_unaligned((self as *const FakeClockGetResponse).read());
708                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
709                // done second because the memcpy will write garbage to these bytes.
710            }
711            Ok(())
712        }
713    }
714    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
715        fidl::encoding::Encode<FakeClockGetResponse, D> for (T0,)
716    {
717        #[inline]
718        unsafe fn encode(
719            self,
720            encoder: &mut fidl::encoding::Encoder<'_, D>,
721            offset: usize,
722            depth: fidl::encoding::Depth,
723        ) -> fidl::Result<()> {
724            encoder.debug_check_bounds::<FakeClockGetResponse>(offset);
725            // Zero out padding regions. There's no need to apply masks
726            // because the unmasked parts will be overwritten by fields.
727            // Write the fields.
728            self.0.encode(encoder, offset + 0, depth)?;
729            Ok(())
730        }
731    }
732
733    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FakeClockGetResponse {
734        #[inline(always)]
735        fn new_empty() -> Self {
736            Self { time: fidl::new_empty!(i64, D) }
737        }
738
739        #[inline]
740        unsafe fn decode(
741            &mut self,
742            decoder: &mut fidl::encoding::Decoder<'_, D>,
743            offset: usize,
744            _depth: fidl::encoding::Depth,
745        ) -> fidl::Result<()> {
746            decoder.debug_check_bounds::<Self>(offset);
747            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
748            // Verify that padding bytes are zero.
749            // Copy from the buffer into the object.
750            unsafe {
751                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
752            }
753            Ok(())
754        }
755    }
756
757    impl fidl::encoding::ValueTypeMarker for RandomRange {
758        type Borrowed<'a> = &'a Self;
759        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
760            value
761        }
762    }
763
764    unsafe impl fidl::encoding::TypeMarker for RandomRange {
765        type Owned = Self;
766
767        #[inline(always)]
768        fn inline_align(_context: fidl::encoding::Context) -> usize {
769            8
770        }
771
772        #[inline(always)]
773        fn inline_size(_context: fidl::encoding::Context) -> usize {
774            16
775        }
776        #[inline(always)]
777        fn encode_is_copy() -> bool {
778            true
779        }
780
781        #[inline(always)]
782        fn decode_is_copy() -> bool {
783            true
784        }
785    }
786
787    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RandomRange, D>
788        for &RandomRange
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::<RandomRange>(offset);
798            unsafe {
799                // Copy the object into the buffer.
800                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
801                (buf_ptr as *mut RandomRange).write_unaligned((self as *const RandomRange).read());
802                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
803                // done second because the memcpy will write garbage to these bytes.
804            }
805            Ok(())
806        }
807    }
808    unsafe impl<
809            D: fidl::encoding::ResourceDialect,
810            T0: fidl::encoding::Encode<i64, D>,
811            T1: fidl::encoding::Encode<i64, D>,
812        > fidl::encoding::Encode<RandomRange, D> for (T0, T1)
813    {
814        #[inline]
815        unsafe fn encode(
816            self,
817            encoder: &mut fidl::encoding::Encoder<'_, D>,
818            offset: usize,
819            depth: fidl::encoding::Depth,
820        ) -> fidl::Result<()> {
821            encoder.debug_check_bounds::<RandomRange>(offset);
822            // Zero out padding regions. There's no need to apply masks
823            // because the unmasked parts will be overwritten by fields.
824            // Write the fields.
825            self.0.encode(encoder, offset + 0, depth)?;
826            self.1.encode(encoder, offset + 8, depth)?;
827            Ok(())
828        }
829    }
830
831    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RandomRange {
832        #[inline(always)]
833        fn new_empty() -> Self {
834            Self { min_rand: fidl::new_empty!(i64, D), max_rand: fidl::new_empty!(i64, D) }
835        }
836
837        #[inline]
838        unsafe fn decode(
839            &mut self,
840            decoder: &mut fidl::encoding::Decoder<'_, D>,
841            offset: usize,
842            _depth: fidl::encoding::Depth,
843        ) -> fidl::Result<()> {
844            decoder.debug_check_bounds::<Self>(offset);
845            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
846            // Verify that padding bytes are zero.
847            // Copy from the buffer into the object.
848            unsafe {
849                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
850            }
851            Ok(())
852        }
853    }
854
855    impl fidl::encoding::ValueTypeMarker for Increment {
856        type Borrowed<'a> = &'a Self;
857        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
858            value
859        }
860    }
861
862    unsafe impl fidl::encoding::TypeMarker for Increment {
863        type Owned = Self;
864
865        #[inline(always)]
866        fn inline_align(_context: fidl::encoding::Context) -> usize {
867            8
868        }
869
870        #[inline(always)]
871        fn inline_size(_context: fidl::encoding::Context) -> usize {
872            16
873        }
874    }
875
876    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Increment, D>
877        for &Increment
878    {
879        #[inline]
880        unsafe fn encode(
881            self,
882            encoder: &mut fidl::encoding::Encoder<'_, D>,
883            offset: usize,
884            _depth: fidl::encoding::Depth,
885        ) -> fidl::Result<()> {
886            encoder.debug_check_bounds::<Increment>(offset);
887            encoder.write_num::<u64>(self.ordinal(), offset);
888            match self {
889                Increment::Determined(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
890                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
891                    encoder,
892                    offset + 8,
893                    _depth,
894                ),
895                Increment::Random(ref val) => fidl::encoding::encode_in_envelope::<RandomRange, D>(
896                    <RandomRange as fidl::encoding::ValueTypeMarker>::borrow(val),
897                    encoder,
898                    offset + 8,
899                    _depth,
900                ),
901            }
902        }
903    }
904
905    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Increment {
906        #[inline(always)]
907        fn new_empty() -> Self {
908            Self::Determined(fidl::new_empty!(i64, D))
909        }
910
911        #[inline]
912        unsafe fn decode(
913            &mut self,
914            decoder: &mut fidl::encoding::Decoder<'_, D>,
915            offset: usize,
916            mut depth: fidl::encoding::Depth,
917        ) -> fidl::Result<()> {
918            decoder.debug_check_bounds::<Self>(offset);
919            #[allow(unused_variables)]
920            let next_out_of_line = decoder.next_out_of_line();
921            let handles_before = decoder.remaining_handles();
922            let (ordinal, inlined, num_bytes, num_handles) =
923                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
924
925            let member_inline_size = match ordinal {
926                1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
927                2 => <RandomRange as fidl::encoding::TypeMarker>::inline_size(decoder.context),
928                _ => return Err(fidl::Error::UnknownUnionTag),
929            };
930
931            if inlined != (member_inline_size <= 4) {
932                return Err(fidl::Error::InvalidInlineBitInEnvelope);
933            }
934            let _inner_offset;
935            if inlined {
936                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
937                _inner_offset = offset + 8;
938            } else {
939                depth.increment()?;
940                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
941            }
942            match ordinal {
943                1 => {
944                    #[allow(irrefutable_let_patterns)]
945                    if let Increment::Determined(_) = self {
946                        // Do nothing, read the value into the object
947                    } else {
948                        // Initialize `self` to the right variant
949                        *self = Increment::Determined(fidl::new_empty!(i64, D));
950                    }
951                    #[allow(irrefutable_let_patterns)]
952                    if let Increment::Determined(ref mut val) = self {
953                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
954                    } else {
955                        unreachable!()
956                    }
957                }
958                2 => {
959                    #[allow(irrefutable_let_patterns)]
960                    if let Increment::Random(_) = self {
961                        // Do nothing, read the value into the object
962                    } else {
963                        // Initialize `self` to the right variant
964                        *self = Increment::Random(fidl::new_empty!(RandomRange, D));
965                    }
966                    #[allow(irrefutable_let_patterns)]
967                    if let Increment::Random(ref mut val) = self {
968                        fidl::decode!(RandomRange, D, val, decoder, _inner_offset, depth)?;
969                    } else {
970                        unreachable!()
971                    }
972                }
973                ordinal => panic!("unexpected ordinal {:?}", ordinal),
974            }
975            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
976                return Err(fidl::Error::InvalidNumBytesInEnvelope);
977            }
978            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
979                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
980            }
981            Ok(())
982        }
983    }
984}