1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum DeadlineEventType {
15 Set = 1,
17 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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85#[repr(C)]
86pub struct RandomRange {
87 pub min_rand: i64,
89 pub max_rand: i64,
91}
92
93impl fidl::Persistable for RandomRange {}
94
95#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
97pub enum Increment {
98 Determined(i64),
100 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
116pub mod fake_clock_ordinals {
117 pub const GET: u64 = 0x2a08c060e0b95e7c;
118 pub const REGISTER_EVENT: u64 = 0x79917345514b5f95;
119 pub const RESCHEDULE_EVENT: u64 = 0x4e5207df2b0dba46;
120 pub const CANCEL_EVENT: u64 = 0x18bbdb18faa6cac0;
121 pub const CREATE_NAMED_DEADLINE: u64 = 0xf7a02c2ac2d116c;
122}
123
124pub mod fake_clock_control_ordinals {
125 pub const ADVANCE: u64 = 0x42f2265fb495497a;
126 pub const RESUME_WITH_INCREMENTS: u64 = 0x259be1eeba0bdd4a;
127 pub const ADD_STOP_POINT: u64 = 0x3b52fe2cba8c4245;
128 pub const PAUSE: u64 = 0x260df03b49199ba4;
129 pub const IGNORE_NAMED_DEADLINE: u64 = 0x2e445152a80d44aa;
130}
131
132mod internal {
133 use super::*;
134 unsafe impl fidl::encoding::TypeMarker for DeadlineEventType {
135 type Owned = Self;
136
137 #[inline(always)]
138 fn inline_align(_context: fidl::encoding::Context) -> usize {
139 std::mem::align_of::<u32>()
140 }
141
142 #[inline(always)]
143 fn inline_size(_context: fidl::encoding::Context) -> usize {
144 std::mem::size_of::<u32>()
145 }
146
147 #[inline(always)]
148 fn encode_is_copy() -> bool {
149 true
150 }
151
152 #[inline(always)]
153 fn decode_is_copy() -> bool {
154 false
155 }
156 }
157
158 impl fidl::encoding::ValueTypeMarker for DeadlineEventType {
159 type Borrowed<'a> = Self;
160 #[inline(always)]
161 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
162 *value
163 }
164 }
165
166 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
167 for DeadlineEventType
168 {
169 #[inline]
170 unsafe fn encode(
171 self,
172 encoder: &mut fidl::encoding::Encoder<'_, D>,
173 offset: usize,
174 _depth: fidl::encoding::Depth,
175 ) -> fidl::Result<()> {
176 encoder.debug_check_bounds::<Self>(offset);
177 encoder.write_num(self.into_primitive(), offset);
178 Ok(())
179 }
180 }
181
182 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeadlineEventType {
183 #[inline(always)]
184 fn new_empty() -> Self {
185 Self::Set
186 }
187
188 #[inline]
189 unsafe fn decode(
190 &mut self,
191 decoder: &mut fidl::encoding::Decoder<'_, D>,
192 offset: usize,
193 _depth: fidl::encoding::Depth,
194 ) -> fidl::Result<()> {
195 decoder.debug_check_bounds::<Self>(offset);
196 let prim = decoder.read_num::<u32>(offset);
197
198 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
199 Ok(())
200 }
201 }
202
203 impl fidl::encoding::ValueTypeMarker for FakeClockControlAdvanceRequest {
204 type Borrowed<'a> = &'a Self;
205 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
206 value
207 }
208 }
209
210 unsafe impl fidl::encoding::TypeMarker for FakeClockControlAdvanceRequest {
211 type Owned = Self;
212
213 #[inline(always)]
214 fn inline_align(_context: fidl::encoding::Context) -> usize {
215 8
216 }
217
218 #[inline(always)]
219 fn inline_size(_context: fidl::encoding::Context) -> usize {
220 16
221 }
222 }
223
224 unsafe impl<D: fidl::encoding::ResourceDialect>
225 fidl::encoding::Encode<FakeClockControlAdvanceRequest, D>
226 for &FakeClockControlAdvanceRequest
227 {
228 #[inline]
229 unsafe fn encode(
230 self,
231 encoder: &mut fidl::encoding::Encoder<'_, D>,
232 offset: usize,
233 _depth: fidl::encoding::Depth,
234 ) -> fidl::Result<()> {
235 encoder.debug_check_bounds::<FakeClockControlAdvanceRequest>(offset);
236 fidl::encoding::Encode::<FakeClockControlAdvanceRequest, D>::encode(
238 (<Increment as fidl::encoding::ValueTypeMarker>::borrow(&self.increment),),
239 encoder,
240 offset,
241 _depth,
242 )
243 }
244 }
245 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Increment, D>>
246 fidl::encoding::Encode<FakeClockControlAdvanceRequest, D> for (T0,)
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::<FakeClockControlAdvanceRequest>(offset);
256 self.0.encode(encoder, offset + 0, depth)?;
260 Ok(())
261 }
262 }
263
264 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
265 for FakeClockControlAdvanceRequest
266 {
267 #[inline(always)]
268 fn new_empty() -> Self {
269 Self { increment: fidl::new_empty!(Increment, D) }
270 }
271
272 #[inline]
273 unsafe fn decode(
274 &mut self,
275 decoder: &mut fidl::encoding::Decoder<'_, D>,
276 offset: usize,
277 _depth: fidl::encoding::Depth,
278 ) -> fidl::Result<()> {
279 decoder.debug_check_bounds::<Self>(offset);
280 fidl::decode!(Increment, D, &mut self.increment, decoder, offset + 0, _depth)?;
282 Ok(())
283 }
284 }
285
286 impl fidl::encoding::ValueTypeMarker for FakeClockControlIgnoreNamedDeadlineRequest {
287 type Borrowed<'a> = &'a Self;
288 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
289 value
290 }
291 }
292
293 unsafe impl fidl::encoding::TypeMarker for FakeClockControlIgnoreNamedDeadlineRequest {
294 type Owned = Self;
295
296 #[inline(always)]
297 fn inline_align(_context: fidl::encoding::Context) -> usize {
298 8
299 }
300
301 #[inline(always)]
302 fn inline_size(_context: fidl::encoding::Context) -> usize {
303 32
304 }
305 }
306
307 unsafe impl<D: fidl::encoding::ResourceDialect>
308 fidl::encoding::Encode<FakeClockControlIgnoreNamedDeadlineRequest, D>
309 for &FakeClockControlIgnoreNamedDeadlineRequest
310 {
311 #[inline]
312 unsafe fn encode(
313 self,
314 encoder: &mut fidl::encoding::Encoder<'_, D>,
315 offset: usize,
316 _depth: fidl::encoding::Depth,
317 ) -> fidl::Result<()> {
318 encoder.debug_check_bounds::<FakeClockControlIgnoreNamedDeadlineRequest>(offset);
319 fidl::encoding::Encode::<FakeClockControlIgnoreNamedDeadlineRequest, D>::encode(
321 (
322 <fidl_fuchsia_testing_deadline__common::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline_id),
323 ),
324 encoder, offset, _depth
325 )
326 }
327 }
328 unsafe impl<
329 D: fidl::encoding::ResourceDialect,
330 T0: fidl::encoding::Encode<fidl_fuchsia_testing_deadline__common::DeadlineId, D>,
331 > fidl::encoding::Encode<FakeClockControlIgnoreNamedDeadlineRequest, D> for (T0,)
332 {
333 #[inline]
334 unsafe fn encode(
335 self,
336 encoder: &mut fidl::encoding::Encoder<'_, D>,
337 offset: usize,
338 depth: fidl::encoding::Depth,
339 ) -> fidl::Result<()> {
340 encoder.debug_check_bounds::<FakeClockControlIgnoreNamedDeadlineRequest>(offset);
341 self.0.encode(encoder, offset + 0, depth)?;
345 Ok(())
346 }
347 }
348
349 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
350 for FakeClockControlIgnoreNamedDeadlineRequest
351 {
352 #[inline(always)]
353 fn new_empty() -> Self {
354 Self {
355 deadline_id: fidl::new_empty!(fidl_fuchsia_testing_deadline__common::DeadlineId, D),
356 }
357 }
358
359 #[inline]
360 unsafe fn decode(
361 &mut self,
362 decoder: &mut fidl::encoding::Decoder<'_, D>,
363 offset: usize,
364 _depth: fidl::encoding::Depth,
365 ) -> fidl::Result<()> {
366 decoder.debug_check_bounds::<Self>(offset);
367 fidl::decode!(
369 fidl_fuchsia_testing_deadline__common::DeadlineId,
370 D,
371 &mut self.deadline_id,
372 decoder,
373 offset + 0,
374 _depth
375 )?;
376 Ok(())
377 }
378 }
379
380 impl fidl::encoding::ValueTypeMarker for FakeClockControlResumeWithIncrementsRequest {
381 type Borrowed<'a> = &'a Self;
382 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
383 value
384 }
385 }
386
387 unsafe impl fidl::encoding::TypeMarker for FakeClockControlResumeWithIncrementsRequest {
388 type Owned = Self;
389
390 #[inline(always)]
391 fn inline_align(_context: fidl::encoding::Context) -> usize {
392 8
393 }
394
395 #[inline(always)]
396 fn inline_size(_context: fidl::encoding::Context) -> usize {
397 24
398 }
399 }
400
401 unsafe impl<D: fidl::encoding::ResourceDialect>
402 fidl::encoding::Encode<FakeClockControlResumeWithIncrementsRequest, D>
403 for &FakeClockControlResumeWithIncrementsRequest
404 {
405 #[inline]
406 unsafe fn encode(
407 self,
408 encoder: &mut fidl::encoding::Encoder<'_, D>,
409 offset: usize,
410 _depth: fidl::encoding::Depth,
411 ) -> fidl::Result<()> {
412 encoder.debug_check_bounds::<FakeClockControlResumeWithIncrementsRequest>(offset);
413 fidl::encoding::Encode::<FakeClockControlResumeWithIncrementsRequest, D>::encode(
415 (
416 <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.real),
417 <Increment as fidl::encoding::ValueTypeMarker>::borrow(&self.increment),
418 ),
419 encoder,
420 offset,
421 _depth,
422 )
423 }
424 }
425 unsafe impl<
426 D: fidl::encoding::ResourceDialect,
427 T0: fidl::encoding::Encode<i64, D>,
428 T1: fidl::encoding::Encode<Increment, D>,
429 > fidl::encoding::Encode<FakeClockControlResumeWithIncrementsRequest, D> for (T0, T1)
430 {
431 #[inline]
432 unsafe fn encode(
433 self,
434 encoder: &mut fidl::encoding::Encoder<'_, D>,
435 offset: usize,
436 depth: fidl::encoding::Depth,
437 ) -> fidl::Result<()> {
438 encoder.debug_check_bounds::<FakeClockControlResumeWithIncrementsRequest>(offset);
439 self.0.encode(encoder, offset + 0, depth)?;
443 self.1.encode(encoder, offset + 8, depth)?;
444 Ok(())
445 }
446 }
447
448 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
449 for FakeClockControlResumeWithIncrementsRequest
450 {
451 #[inline(always)]
452 fn new_empty() -> Self {
453 Self { real: fidl::new_empty!(i64, D), increment: fidl::new_empty!(Increment, D) }
454 }
455
456 #[inline]
457 unsafe fn decode(
458 &mut self,
459 decoder: &mut fidl::encoding::Decoder<'_, D>,
460 offset: usize,
461 _depth: fidl::encoding::Depth,
462 ) -> fidl::Result<()> {
463 decoder.debug_check_bounds::<Self>(offset);
464 fidl::decode!(i64, D, &mut self.real, decoder, offset + 0, _depth)?;
466 fidl::decode!(Increment, D, &mut self.increment, decoder, offset + 8, _depth)?;
467 Ok(())
468 }
469 }
470
471 impl fidl::encoding::ValueTypeMarker for FakeClockCreateNamedDeadlineRequest {
472 type Borrowed<'a> = &'a Self;
473 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
474 value
475 }
476 }
477
478 unsafe impl fidl::encoding::TypeMarker for FakeClockCreateNamedDeadlineRequest {
479 type Owned = Self;
480
481 #[inline(always)]
482 fn inline_align(_context: fidl::encoding::Context) -> usize {
483 8
484 }
485
486 #[inline(always)]
487 fn inline_size(_context: fidl::encoding::Context) -> usize {
488 40
489 }
490 }
491
492 unsafe impl<D: fidl::encoding::ResourceDialect>
493 fidl::encoding::Encode<FakeClockCreateNamedDeadlineRequest, D>
494 for &FakeClockCreateNamedDeadlineRequest
495 {
496 #[inline]
497 unsafe fn encode(
498 self,
499 encoder: &mut fidl::encoding::Encoder<'_, D>,
500 offset: usize,
501 _depth: fidl::encoding::Depth,
502 ) -> fidl::Result<()> {
503 encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineRequest>(offset);
504 fidl::encoding::Encode::<FakeClockCreateNamedDeadlineRequest, D>::encode(
506 (
507 <fidl_fuchsia_testing_deadline__common::DeadlineId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
508 <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.duration),
509 ),
510 encoder, offset, _depth
511 )
512 }
513 }
514 unsafe impl<
515 D: fidl::encoding::ResourceDialect,
516 T0: fidl::encoding::Encode<fidl_fuchsia_testing_deadline__common::DeadlineId, D>,
517 T1: fidl::encoding::Encode<i64, D>,
518 > fidl::encoding::Encode<FakeClockCreateNamedDeadlineRequest, D> for (T0, T1)
519 {
520 #[inline]
521 unsafe fn encode(
522 self,
523 encoder: &mut fidl::encoding::Encoder<'_, D>,
524 offset: usize,
525 depth: fidl::encoding::Depth,
526 ) -> fidl::Result<()> {
527 encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineRequest>(offset);
528 self.0.encode(encoder, offset + 0, depth)?;
532 self.1.encode(encoder, offset + 32, depth)?;
533 Ok(())
534 }
535 }
536
537 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
538 for FakeClockCreateNamedDeadlineRequest
539 {
540 #[inline(always)]
541 fn new_empty() -> Self {
542 Self {
543 id: fidl::new_empty!(fidl_fuchsia_testing_deadline__common::DeadlineId, D),
544 duration: fidl::new_empty!(i64, D),
545 }
546 }
547
548 #[inline]
549 unsafe fn decode(
550 &mut self,
551 decoder: &mut fidl::encoding::Decoder<'_, D>,
552 offset: usize,
553 _depth: fidl::encoding::Depth,
554 ) -> fidl::Result<()> {
555 decoder.debug_check_bounds::<Self>(offset);
556 fidl::decode!(
558 fidl_fuchsia_testing_deadline__common::DeadlineId,
559 D,
560 &mut self.id,
561 decoder,
562 offset + 0,
563 _depth
564 )?;
565 fidl::decode!(i64, D, &mut self.duration, decoder, offset + 32, _depth)?;
566 Ok(())
567 }
568 }
569
570 impl fidl::encoding::ValueTypeMarker for FakeClockCreateNamedDeadlineResponse {
571 type Borrowed<'a> = &'a Self;
572 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
573 value
574 }
575 }
576
577 unsafe impl fidl::encoding::TypeMarker for FakeClockCreateNamedDeadlineResponse {
578 type Owned = Self;
579
580 #[inline(always)]
581 fn inline_align(_context: fidl::encoding::Context) -> usize {
582 8
583 }
584
585 #[inline(always)]
586 fn inline_size(_context: fidl::encoding::Context) -> usize {
587 8
588 }
589 #[inline(always)]
590 fn encode_is_copy() -> bool {
591 true
592 }
593
594 #[inline(always)]
595 fn decode_is_copy() -> bool {
596 true
597 }
598 }
599
600 unsafe impl<D: fidl::encoding::ResourceDialect>
601 fidl::encoding::Encode<FakeClockCreateNamedDeadlineResponse, D>
602 for &FakeClockCreateNamedDeadlineResponse
603 {
604 #[inline]
605 unsafe fn encode(
606 self,
607 encoder: &mut fidl::encoding::Encoder<'_, D>,
608 offset: usize,
609 _depth: fidl::encoding::Depth,
610 ) -> fidl::Result<()> {
611 encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineResponse>(offset);
612 unsafe {
613 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
615 (buf_ptr as *mut FakeClockCreateNamedDeadlineResponse)
616 .write_unaligned((self as *const FakeClockCreateNamedDeadlineResponse).read());
617 }
620 Ok(())
621 }
622 }
623 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
624 fidl::encoding::Encode<FakeClockCreateNamedDeadlineResponse, D> for (T0,)
625 {
626 #[inline]
627 unsafe fn encode(
628 self,
629 encoder: &mut fidl::encoding::Encoder<'_, D>,
630 offset: usize,
631 depth: fidl::encoding::Depth,
632 ) -> fidl::Result<()> {
633 encoder.debug_check_bounds::<FakeClockCreateNamedDeadlineResponse>(offset);
634 self.0.encode(encoder, offset + 0, depth)?;
638 Ok(())
639 }
640 }
641
642 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
643 for FakeClockCreateNamedDeadlineResponse
644 {
645 #[inline(always)]
646 fn new_empty() -> Self {
647 Self { deadline: fidl::new_empty!(i64, D) }
648 }
649
650 #[inline]
651 unsafe fn decode(
652 &mut self,
653 decoder: &mut fidl::encoding::Decoder<'_, D>,
654 offset: usize,
655 _depth: fidl::encoding::Depth,
656 ) -> fidl::Result<()> {
657 decoder.debug_check_bounds::<Self>(offset);
658 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
659 unsafe {
662 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
663 }
664 Ok(())
665 }
666 }
667
668 impl fidl::encoding::ValueTypeMarker for FakeClockGetResponse {
669 type Borrowed<'a> = &'a Self;
670 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
671 value
672 }
673 }
674
675 unsafe impl fidl::encoding::TypeMarker for FakeClockGetResponse {
676 type Owned = Self;
677
678 #[inline(always)]
679 fn inline_align(_context: fidl::encoding::Context) -> usize {
680 8
681 }
682
683 #[inline(always)]
684 fn inline_size(_context: fidl::encoding::Context) -> usize {
685 8
686 }
687 #[inline(always)]
688 fn encode_is_copy() -> bool {
689 true
690 }
691
692 #[inline(always)]
693 fn decode_is_copy() -> bool {
694 true
695 }
696 }
697
698 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FakeClockGetResponse, D>
699 for &FakeClockGetResponse
700 {
701 #[inline]
702 unsafe fn encode(
703 self,
704 encoder: &mut fidl::encoding::Encoder<'_, D>,
705 offset: usize,
706 _depth: fidl::encoding::Depth,
707 ) -> fidl::Result<()> {
708 encoder.debug_check_bounds::<FakeClockGetResponse>(offset);
709 unsafe {
710 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
712 (buf_ptr as *mut FakeClockGetResponse)
713 .write_unaligned((self as *const FakeClockGetResponse).read());
714 }
717 Ok(())
718 }
719 }
720 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
721 fidl::encoding::Encode<FakeClockGetResponse, D> for (T0,)
722 {
723 #[inline]
724 unsafe fn encode(
725 self,
726 encoder: &mut fidl::encoding::Encoder<'_, D>,
727 offset: usize,
728 depth: fidl::encoding::Depth,
729 ) -> fidl::Result<()> {
730 encoder.debug_check_bounds::<FakeClockGetResponse>(offset);
731 self.0.encode(encoder, offset + 0, depth)?;
735 Ok(())
736 }
737 }
738
739 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FakeClockGetResponse {
740 #[inline(always)]
741 fn new_empty() -> Self {
742 Self { time: fidl::new_empty!(i64, D) }
743 }
744
745 #[inline]
746 unsafe fn decode(
747 &mut self,
748 decoder: &mut fidl::encoding::Decoder<'_, D>,
749 offset: usize,
750 _depth: fidl::encoding::Depth,
751 ) -> fidl::Result<()> {
752 decoder.debug_check_bounds::<Self>(offset);
753 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
754 unsafe {
757 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
758 }
759 Ok(())
760 }
761 }
762
763 impl fidl::encoding::ValueTypeMarker for RandomRange {
764 type Borrowed<'a> = &'a Self;
765 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
766 value
767 }
768 }
769
770 unsafe impl fidl::encoding::TypeMarker for RandomRange {
771 type Owned = Self;
772
773 #[inline(always)]
774 fn inline_align(_context: fidl::encoding::Context) -> usize {
775 8
776 }
777
778 #[inline(always)]
779 fn inline_size(_context: fidl::encoding::Context) -> usize {
780 16
781 }
782 #[inline(always)]
783 fn encode_is_copy() -> bool {
784 true
785 }
786
787 #[inline(always)]
788 fn decode_is_copy() -> bool {
789 true
790 }
791 }
792
793 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RandomRange, D>
794 for &RandomRange
795 {
796 #[inline]
797 unsafe fn encode(
798 self,
799 encoder: &mut fidl::encoding::Encoder<'_, D>,
800 offset: usize,
801 _depth: fidl::encoding::Depth,
802 ) -> fidl::Result<()> {
803 encoder.debug_check_bounds::<RandomRange>(offset);
804 unsafe {
805 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
807 (buf_ptr as *mut RandomRange).write_unaligned((self as *const RandomRange).read());
808 }
811 Ok(())
812 }
813 }
814 unsafe impl<
815 D: fidl::encoding::ResourceDialect,
816 T0: fidl::encoding::Encode<i64, D>,
817 T1: fidl::encoding::Encode<i64, D>,
818 > fidl::encoding::Encode<RandomRange, D> for (T0, T1)
819 {
820 #[inline]
821 unsafe fn encode(
822 self,
823 encoder: &mut fidl::encoding::Encoder<'_, D>,
824 offset: usize,
825 depth: fidl::encoding::Depth,
826 ) -> fidl::Result<()> {
827 encoder.debug_check_bounds::<RandomRange>(offset);
828 self.0.encode(encoder, offset + 0, depth)?;
832 self.1.encode(encoder, offset + 8, depth)?;
833 Ok(())
834 }
835 }
836
837 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RandomRange {
838 #[inline(always)]
839 fn new_empty() -> Self {
840 Self { min_rand: fidl::new_empty!(i64, D), max_rand: fidl::new_empty!(i64, D) }
841 }
842
843 #[inline]
844 unsafe fn decode(
845 &mut self,
846 decoder: &mut fidl::encoding::Decoder<'_, D>,
847 offset: usize,
848 _depth: fidl::encoding::Depth,
849 ) -> fidl::Result<()> {
850 decoder.debug_check_bounds::<Self>(offset);
851 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
852 unsafe {
855 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
856 }
857 Ok(())
858 }
859 }
860
861 impl fidl::encoding::ValueTypeMarker for Increment {
862 type Borrowed<'a> = &'a Self;
863 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
864 value
865 }
866 }
867
868 unsafe impl fidl::encoding::TypeMarker for Increment {
869 type Owned = Self;
870
871 #[inline(always)]
872 fn inline_align(_context: fidl::encoding::Context) -> usize {
873 8
874 }
875
876 #[inline(always)]
877 fn inline_size(_context: fidl::encoding::Context) -> usize {
878 16
879 }
880 }
881
882 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Increment, D>
883 for &Increment
884 {
885 #[inline]
886 unsafe fn encode(
887 self,
888 encoder: &mut fidl::encoding::Encoder<'_, D>,
889 offset: usize,
890 _depth: fidl::encoding::Depth,
891 ) -> fidl::Result<()> {
892 encoder.debug_check_bounds::<Increment>(offset);
893 encoder.write_num::<u64>(self.ordinal(), offset);
894 match self {
895 Increment::Determined(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
896 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
897 encoder,
898 offset + 8,
899 _depth,
900 ),
901 Increment::Random(ref val) => fidl::encoding::encode_in_envelope::<RandomRange, D>(
902 <RandomRange as fidl::encoding::ValueTypeMarker>::borrow(val),
903 encoder,
904 offset + 8,
905 _depth,
906 ),
907 }
908 }
909 }
910
911 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Increment {
912 #[inline(always)]
913 fn new_empty() -> Self {
914 Self::Determined(fidl::new_empty!(i64, D))
915 }
916
917 #[inline]
918 unsafe fn decode(
919 &mut self,
920 decoder: &mut fidl::encoding::Decoder<'_, D>,
921 offset: usize,
922 mut depth: fidl::encoding::Depth,
923 ) -> fidl::Result<()> {
924 decoder.debug_check_bounds::<Self>(offset);
925 #[allow(unused_variables)]
926 let next_out_of_line = decoder.next_out_of_line();
927 let handles_before = decoder.remaining_handles();
928 let (ordinal, inlined, num_bytes, num_handles) =
929 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
930
931 let member_inline_size = match ordinal {
932 1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
933 2 => <RandomRange as fidl::encoding::TypeMarker>::inline_size(decoder.context),
934 _ => return Err(fidl::Error::UnknownUnionTag),
935 };
936
937 if inlined != (member_inline_size <= 4) {
938 return Err(fidl::Error::InvalidInlineBitInEnvelope);
939 }
940 let _inner_offset;
941 if inlined {
942 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
943 _inner_offset = offset + 8;
944 } else {
945 depth.increment()?;
946 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
947 }
948 match ordinal {
949 1 => {
950 #[allow(irrefutable_let_patterns)]
951 if let Increment::Determined(_) = self {
952 } else {
954 *self = Increment::Determined(fidl::new_empty!(i64, D));
956 }
957 #[allow(irrefutable_let_patterns)]
958 if let Increment::Determined(ref mut val) = self {
959 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
960 } else {
961 unreachable!()
962 }
963 }
964 2 => {
965 #[allow(irrefutable_let_patterns)]
966 if let Increment::Random(_) = self {
967 } else {
969 *self = Increment::Random(fidl::new_empty!(RandomRange, D));
971 }
972 #[allow(irrefutable_let_patterns)]
973 if let Increment::Random(ref mut val) = self {
974 fidl::decode!(RandomRange, D, val, decoder, _inner_offset, depth)?;
975 } else {
976 unreachable!()
977 }
978 }
979 ordinal => panic!("unexpected ordinal {:?}", ordinal),
980 }
981 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
982 return Err(fidl::Error::InvalidNumBytesInEnvelope);
983 }
984 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
985 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
986 }
987 Ok(())
988 }
989 }
990}