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