fidl_test_suspendcontrol_common/
fidl_test_suspendcontrol_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Clone, Debug, Default, PartialEq)]
12pub struct DeviceSetSuspendStatesRequest {
13    pub suspend_states: Option<Vec<fidl_fuchsia_hardware_suspend::SuspendState>>,
14    #[doc(hidden)]
15    pub __source_breaking: fidl::marker::SourceBreaking,
16}
17
18impl fidl::Persistable for DeviceSetSuspendStatesRequest {}
19
20#[derive(Clone, Debug, Default, PartialEq)]
21pub struct DeviceAwaitSuspendResponse {
22    pub state_index: Option<u64>,
23    #[doc(hidden)]
24    pub __source_breaking: fidl::marker::SourceBreaking,
25}
26
27impl fidl::Persistable for DeviceAwaitSuspendResponse {}
28
29#[derive(Clone, Debug, Default, PartialEq)]
30pub struct SuspendResult {
31    pub reason: Option<fidl_fuchsia_hardware_suspend::WakeReason>,
32    pub suspend_duration: Option<i64>,
33    pub suspend_overhead: Option<i64>,
34    #[doc(hidden)]
35    pub __source_breaking: fidl::marker::SourceBreaking,
36}
37
38impl fidl::Persistable for SuspendResult {}
39
40#[derive(Clone, Debug)]
41pub enum DeviceResumeRequest {
42    Result(SuspendResult),
43    Error(i32),
44    #[doc(hidden)]
45    __SourceBreaking {
46        unknown_ordinal: u64,
47    },
48}
49
50/// Pattern that matches an unknown `DeviceResumeRequest` member.
51#[macro_export]
52macro_rules! DeviceResumeRequestUnknown {
53    () => {
54        _
55    };
56}
57
58// Custom PartialEq so that unknown variants are not equal to themselves.
59impl PartialEq for DeviceResumeRequest {
60    fn eq(&self, other: &Self) -> bool {
61        match (self, other) {
62            (Self::Result(x), Self::Result(y)) => *x == *y,
63            (Self::Error(x), Self::Error(y)) => *x == *y,
64            _ => false,
65        }
66    }
67}
68
69impl DeviceResumeRequest {
70    #[inline]
71    pub fn ordinal(&self) -> u64 {
72        match *self {
73            Self::Result(_) => 1,
74            Self::Error(_) => 2,
75            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
76        }
77    }
78
79    #[inline]
80    pub fn unknown_variant_for_testing() -> Self {
81        Self::__SourceBreaking { unknown_ordinal: 0 }
82    }
83
84    #[inline]
85    pub fn is_unknown(&self) -> bool {
86        match self {
87            Self::__SourceBreaking { .. } => true,
88            _ => false,
89        }
90    }
91}
92
93impl fidl::Persistable for DeviceResumeRequest {}
94
95mod internal {
96    use super::*;
97
98    impl DeviceSetSuspendStatesRequest {
99        #[inline(always)]
100        fn max_ordinal_present(&self) -> u64 {
101            if let Some(_) = self.suspend_states {
102                return 1;
103            }
104            0
105        }
106    }
107
108    impl fidl::encoding::ValueTypeMarker for DeviceSetSuspendStatesRequest {
109        type Borrowed<'a> = &'a Self;
110        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
111            value
112        }
113    }
114
115    unsafe impl fidl::encoding::TypeMarker for DeviceSetSuspendStatesRequest {
116        type Owned = Self;
117
118        #[inline(always)]
119        fn inline_align(_context: fidl::encoding::Context) -> usize {
120            8
121        }
122
123        #[inline(always)]
124        fn inline_size(_context: fidl::encoding::Context) -> usize {
125            16
126        }
127    }
128
129    unsafe impl<D: fidl::encoding::ResourceDialect>
130        fidl::encoding::Encode<DeviceSetSuspendStatesRequest, D>
131        for &DeviceSetSuspendStatesRequest
132    {
133        unsafe fn encode(
134            self,
135            encoder: &mut fidl::encoding::Encoder<'_, D>,
136            offset: usize,
137            mut depth: fidl::encoding::Depth,
138        ) -> fidl::Result<()> {
139            encoder.debug_check_bounds::<DeviceSetSuspendStatesRequest>(offset);
140            // Vector header
141            let max_ordinal: u64 = self.max_ordinal_present();
142            encoder.write_num(max_ordinal, offset);
143            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
144            // Calling encoder.out_of_line_offset(0) is not allowed.
145            if max_ordinal == 0 {
146                return Ok(());
147            }
148            depth.increment()?;
149            let envelope_size = 8;
150            let bytes_len = max_ordinal as usize * envelope_size;
151            #[allow(unused_variables)]
152            let offset = encoder.out_of_line_offset(bytes_len);
153            let mut _prev_end_offset: usize = 0;
154            if 1 > max_ordinal {
155                return Ok(());
156            }
157
158            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
159            // are envelope_size bytes.
160            let cur_offset: usize = (1 - 1) * envelope_size;
161
162            // Zero reserved fields.
163            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
164
165            // Safety:
166            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
167            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
168            //   envelope_size bytes, there is always sufficient room.
169            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_hardware_suspend::SuspendState, 256>, D>(
170            self.suspend_states.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_hardware_suspend::SuspendState, 256> as fidl::encoding::ValueTypeMarker>::borrow),
171            encoder, offset + cur_offset, depth
172        )?;
173
174            _prev_end_offset = cur_offset + envelope_size;
175
176            Ok(())
177        }
178    }
179
180    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
181        for DeviceSetSuspendStatesRequest
182    {
183        #[inline(always)]
184        fn new_empty() -> Self {
185            Self::default()
186        }
187
188        unsafe fn decode(
189            &mut self,
190            decoder: &mut fidl::encoding::Decoder<'_, D>,
191            offset: usize,
192            mut depth: fidl::encoding::Depth,
193        ) -> fidl::Result<()> {
194            decoder.debug_check_bounds::<Self>(offset);
195            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
196                None => return Err(fidl::Error::NotNullable),
197                Some(len) => len,
198            };
199            // Calling decoder.out_of_line_offset(0) is not allowed.
200            if len == 0 {
201                return Ok(());
202            };
203            depth.increment()?;
204            let envelope_size = 8;
205            let bytes_len = len * envelope_size;
206            let offset = decoder.out_of_line_offset(bytes_len)?;
207            // Decode the envelope for each type.
208            let mut _next_ordinal_to_read = 0;
209            let mut next_offset = offset;
210            let end_offset = offset + bytes_len;
211            _next_ordinal_to_read += 1;
212            if next_offset >= end_offset {
213                return Ok(());
214            }
215
216            // Decode unknown envelopes for gaps in ordinals.
217            while _next_ordinal_to_read < 1 {
218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
219                _next_ordinal_to_read += 1;
220                next_offset += envelope_size;
221            }
222
223            let next_out_of_line = decoder.next_out_of_line();
224            let handles_before = decoder.remaining_handles();
225            if let Some((inlined, num_bytes, num_handles)) =
226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
227            {
228                let member_inline_size = <fidl::encoding::Vector<
229                    fidl_fuchsia_hardware_suspend::SuspendState,
230                    256,
231                > as fidl::encoding::TypeMarker>::inline_size(
232                    decoder.context
233                );
234                if inlined != (member_inline_size <= 4) {
235                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
236                }
237                let inner_offset;
238                let mut inner_depth = depth.clone();
239                if inlined {
240                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
241                    inner_offset = next_offset;
242                } else {
243                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
244                    inner_depth.increment()?;
245                }
246                let val_ref =
247                self.suspend_states.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_suspend::SuspendState, 256>, D));
248                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_suspend::SuspendState, 256>, D, val_ref, decoder, inner_offset, inner_depth)?;
249                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
250                {
251                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
252                }
253                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
254                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
255                }
256            }
257
258            next_offset += envelope_size;
259
260            // Decode the remaining unknown envelopes.
261            while next_offset < end_offset {
262                _next_ordinal_to_read += 1;
263                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
264                next_offset += envelope_size;
265            }
266
267            Ok(())
268        }
269    }
270
271    impl DeviceAwaitSuspendResponse {
272        #[inline(always)]
273        fn max_ordinal_present(&self) -> u64 {
274            if let Some(_) = self.state_index {
275                return 1;
276            }
277            0
278        }
279    }
280
281    impl fidl::encoding::ValueTypeMarker for DeviceAwaitSuspendResponse {
282        type Borrowed<'a> = &'a Self;
283        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
284            value
285        }
286    }
287
288    unsafe impl fidl::encoding::TypeMarker for DeviceAwaitSuspendResponse {
289        type Owned = Self;
290
291        #[inline(always)]
292        fn inline_align(_context: fidl::encoding::Context) -> usize {
293            8
294        }
295
296        #[inline(always)]
297        fn inline_size(_context: fidl::encoding::Context) -> usize {
298            16
299        }
300    }
301
302    unsafe impl<D: fidl::encoding::ResourceDialect>
303        fidl::encoding::Encode<DeviceAwaitSuspendResponse, D> for &DeviceAwaitSuspendResponse
304    {
305        unsafe fn encode(
306            self,
307            encoder: &mut fidl::encoding::Encoder<'_, D>,
308            offset: usize,
309            mut depth: fidl::encoding::Depth,
310        ) -> fidl::Result<()> {
311            encoder.debug_check_bounds::<DeviceAwaitSuspendResponse>(offset);
312            // Vector header
313            let max_ordinal: u64 = self.max_ordinal_present();
314            encoder.write_num(max_ordinal, offset);
315            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
316            // Calling encoder.out_of_line_offset(0) is not allowed.
317            if max_ordinal == 0 {
318                return Ok(());
319            }
320            depth.increment()?;
321            let envelope_size = 8;
322            let bytes_len = max_ordinal as usize * envelope_size;
323            #[allow(unused_variables)]
324            let offset = encoder.out_of_line_offset(bytes_len);
325            let mut _prev_end_offset: usize = 0;
326            if 1 > max_ordinal {
327                return Ok(());
328            }
329
330            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
331            // are envelope_size bytes.
332            let cur_offset: usize = (1 - 1) * envelope_size;
333
334            // Zero reserved fields.
335            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
336
337            // Safety:
338            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
339            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
340            //   envelope_size bytes, there is always sufficient room.
341            fidl::encoding::encode_in_envelope_optional::<u64, D>(
342                self.state_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
343                encoder,
344                offset + cur_offset,
345                depth,
346            )?;
347
348            _prev_end_offset = cur_offset + envelope_size;
349
350            Ok(())
351        }
352    }
353
354    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
355        for DeviceAwaitSuspendResponse
356    {
357        #[inline(always)]
358        fn new_empty() -> Self {
359            Self::default()
360        }
361
362        unsafe fn decode(
363            &mut self,
364            decoder: &mut fidl::encoding::Decoder<'_, D>,
365            offset: usize,
366            mut depth: fidl::encoding::Depth,
367        ) -> fidl::Result<()> {
368            decoder.debug_check_bounds::<Self>(offset);
369            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
370                None => return Err(fidl::Error::NotNullable),
371                Some(len) => len,
372            };
373            // Calling decoder.out_of_line_offset(0) is not allowed.
374            if len == 0 {
375                return Ok(());
376            };
377            depth.increment()?;
378            let envelope_size = 8;
379            let bytes_len = len * envelope_size;
380            let offset = decoder.out_of_line_offset(bytes_len)?;
381            // Decode the envelope for each type.
382            let mut _next_ordinal_to_read = 0;
383            let mut next_offset = offset;
384            let end_offset = offset + bytes_len;
385            _next_ordinal_to_read += 1;
386            if next_offset >= end_offset {
387                return Ok(());
388            }
389
390            // Decode unknown envelopes for gaps in ordinals.
391            while _next_ordinal_to_read < 1 {
392                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
393                _next_ordinal_to_read += 1;
394                next_offset += envelope_size;
395            }
396
397            let next_out_of_line = decoder.next_out_of_line();
398            let handles_before = decoder.remaining_handles();
399            if let Some((inlined, num_bytes, num_handles)) =
400                fidl::encoding::decode_envelope_header(decoder, next_offset)?
401            {
402                let member_inline_size =
403                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
404                if inlined != (member_inline_size <= 4) {
405                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
406                }
407                let inner_offset;
408                let mut inner_depth = depth.clone();
409                if inlined {
410                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
411                    inner_offset = next_offset;
412                } else {
413                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
414                    inner_depth.increment()?;
415                }
416                let val_ref = self.state_index.get_or_insert_with(|| fidl::new_empty!(u64, D));
417                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
419                {
420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
421                }
422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
424                }
425            }
426
427            next_offset += envelope_size;
428
429            // Decode the remaining unknown envelopes.
430            while next_offset < end_offset {
431                _next_ordinal_to_read += 1;
432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
433                next_offset += envelope_size;
434            }
435
436            Ok(())
437        }
438    }
439
440    impl SuspendResult {
441        #[inline(always)]
442        fn max_ordinal_present(&self) -> u64 {
443            if let Some(_) = self.suspend_overhead {
444                return 3;
445            }
446            if let Some(_) = self.suspend_duration {
447                return 2;
448            }
449            if let Some(_) = self.reason {
450                return 1;
451            }
452            0
453        }
454    }
455
456    impl fidl::encoding::ValueTypeMarker for SuspendResult {
457        type Borrowed<'a> = &'a Self;
458        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
459            value
460        }
461    }
462
463    unsafe impl fidl::encoding::TypeMarker for SuspendResult {
464        type Owned = Self;
465
466        #[inline(always)]
467        fn inline_align(_context: fidl::encoding::Context) -> usize {
468            8
469        }
470
471        #[inline(always)]
472        fn inline_size(_context: fidl::encoding::Context) -> usize {
473            16
474        }
475    }
476
477    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SuspendResult, D>
478        for &SuspendResult
479    {
480        unsafe fn encode(
481            self,
482            encoder: &mut fidl::encoding::Encoder<'_, D>,
483            offset: usize,
484            mut depth: fidl::encoding::Depth,
485        ) -> fidl::Result<()> {
486            encoder.debug_check_bounds::<SuspendResult>(offset);
487            // Vector header
488            let max_ordinal: u64 = self.max_ordinal_present();
489            encoder.write_num(max_ordinal, offset);
490            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
491            // Calling encoder.out_of_line_offset(0) is not allowed.
492            if max_ordinal == 0 {
493                return Ok(());
494            }
495            depth.increment()?;
496            let envelope_size = 8;
497            let bytes_len = max_ordinal as usize * envelope_size;
498            #[allow(unused_variables)]
499            let offset = encoder.out_of_line_offset(bytes_len);
500            let mut _prev_end_offset: usize = 0;
501            if 1 > max_ordinal {
502                return Ok(());
503            }
504
505            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
506            // are envelope_size bytes.
507            let cur_offset: usize = (1 - 1) * envelope_size;
508
509            // Zero reserved fields.
510            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
511
512            // Safety:
513            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
514            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
515            //   envelope_size bytes, there is always sufficient room.
516            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_suspend::WakeReason, D>(
517            self.reason.as_ref().map(<fidl_fuchsia_hardware_suspend::WakeReason as fidl::encoding::ValueTypeMarker>::borrow),
518            encoder, offset + cur_offset, depth
519        )?;
520
521            _prev_end_offset = cur_offset + envelope_size;
522            if 2 > max_ordinal {
523                return Ok(());
524            }
525
526            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
527            // are envelope_size bytes.
528            let cur_offset: usize = (2 - 1) * envelope_size;
529
530            // Zero reserved fields.
531            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
532
533            // Safety:
534            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
535            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
536            //   envelope_size bytes, there is always sufficient room.
537            fidl::encoding::encode_in_envelope_optional::<i64, D>(
538                self.suspend_duration
539                    .as_ref()
540                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
541                encoder,
542                offset + cur_offset,
543                depth,
544            )?;
545
546            _prev_end_offset = cur_offset + envelope_size;
547            if 3 > max_ordinal {
548                return Ok(());
549            }
550
551            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
552            // are envelope_size bytes.
553            let cur_offset: usize = (3 - 1) * envelope_size;
554
555            // Zero reserved fields.
556            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
557
558            // Safety:
559            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
560            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
561            //   envelope_size bytes, there is always sufficient room.
562            fidl::encoding::encode_in_envelope_optional::<i64, D>(
563                self.suspend_overhead
564                    .as_ref()
565                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
566                encoder,
567                offset + cur_offset,
568                depth,
569            )?;
570
571            _prev_end_offset = cur_offset + envelope_size;
572
573            Ok(())
574        }
575    }
576
577    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SuspendResult {
578        #[inline(always)]
579        fn new_empty() -> Self {
580            Self::default()
581        }
582
583        unsafe fn decode(
584            &mut self,
585            decoder: &mut fidl::encoding::Decoder<'_, D>,
586            offset: usize,
587            mut depth: fidl::encoding::Depth,
588        ) -> fidl::Result<()> {
589            decoder.debug_check_bounds::<Self>(offset);
590            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
591                None => return Err(fidl::Error::NotNullable),
592                Some(len) => len,
593            };
594            // Calling decoder.out_of_line_offset(0) is not allowed.
595            if len == 0 {
596                return Ok(());
597            };
598            depth.increment()?;
599            let envelope_size = 8;
600            let bytes_len = len * envelope_size;
601            let offset = decoder.out_of_line_offset(bytes_len)?;
602            // Decode the envelope for each type.
603            let mut _next_ordinal_to_read = 0;
604            let mut next_offset = offset;
605            let end_offset = offset + bytes_len;
606            _next_ordinal_to_read += 1;
607            if next_offset >= end_offset {
608                return Ok(());
609            }
610
611            // Decode unknown envelopes for gaps in ordinals.
612            while _next_ordinal_to_read < 1 {
613                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
614                _next_ordinal_to_read += 1;
615                next_offset += envelope_size;
616            }
617
618            let next_out_of_line = decoder.next_out_of_line();
619            let handles_before = decoder.remaining_handles();
620            if let Some((inlined, num_bytes, num_handles)) =
621                fidl::encoding::decode_envelope_header(decoder, next_offset)?
622            {
623                let member_inline_size = <fidl_fuchsia_hardware_suspend::WakeReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
624                if inlined != (member_inline_size <= 4) {
625                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
626                }
627                let inner_offset;
628                let mut inner_depth = depth.clone();
629                if inlined {
630                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
631                    inner_offset = next_offset;
632                } else {
633                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
634                    inner_depth.increment()?;
635                }
636                let val_ref = self.reason.get_or_insert_with(|| {
637                    fidl::new_empty!(fidl_fuchsia_hardware_suspend::WakeReason, D)
638                });
639                fidl::decode!(
640                    fidl_fuchsia_hardware_suspend::WakeReason,
641                    D,
642                    val_ref,
643                    decoder,
644                    inner_offset,
645                    inner_depth
646                )?;
647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
648                {
649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
650                }
651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
653                }
654            }
655
656            next_offset += envelope_size;
657            _next_ordinal_to_read += 1;
658            if next_offset >= end_offset {
659                return Ok(());
660            }
661
662            // Decode unknown envelopes for gaps in ordinals.
663            while _next_ordinal_to_read < 2 {
664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
665                _next_ordinal_to_read += 1;
666                next_offset += envelope_size;
667            }
668
669            let next_out_of_line = decoder.next_out_of_line();
670            let handles_before = decoder.remaining_handles();
671            if let Some((inlined, num_bytes, num_handles)) =
672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
673            {
674                let member_inline_size =
675                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
676                if inlined != (member_inline_size <= 4) {
677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
678                }
679                let inner_offset;
680                let mut inner_depth = depth.clone();
681                if inlined {
682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
683                    inner_offset = next_offset;
684                } else {
685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
686                    inner_depth.increment()?;
687                }
688                let val_ref = self.suspend_duration.get_or_insert_with(|| fidl::new_empty!(i64, D));
689                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
690                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
691                {
692                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
693                }
694                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
695                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
696                }
697            }
698
699            next_offset += envelope_size;
700            _next_ordinal_to_read += 1;
701            if next_offset >= end_offset {
702                return Ok(());
703            }
704
705            // Decode unknown envelopes for gaps in ordinals.
706            while _next_ordinal_to_read < 3 {
707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
708                _next_ordinal_to_read += 1;
709                next_offset += envelope_size;
710            }
711
712            let next_out_of_line = decoder.next_out_of_line();
713            let handles_before = decoder.remaining_handles();
714            if let Some((inlined, num_bytes, num_handles)) =
715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
716            {
717                let member_inline_size =
718                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
719                if inlined != (member_inline_size <= 4) {
720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
721                }
722                let inner_offset;
723                let mut inner_depth = depth.clone();
724                if inlined {
725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
726                    inner_offset = next_offset;
727                } else {
728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
729                    inner_depth.increment()?;
730                }
731                let val_ref = self.suspend_overhead.get_or_insert_with(|| fidl::new_empty!(i64, D));
732                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
733                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
734                {
735                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
736                }
737                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
738                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
739                }
740            }
741
742            next_offset += envelope_size;
743
744            // Decode the remaining unknown envelopes.
745            while next_offset < end_offset {
746                _next_ordinal_to_read += 1;
747                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
748                next_offset += envelope_size;
749            }
750
751            Ok(())
752        }
753    }
754
755    impl fidl::encoding::ValueTypeMarker for DeviceResumeRequest {
756        type Borrowed<'a> = &'a Self;
757        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
758            value
759        }
760    }
761
762    unsafe impl fidl::encoding::TypeMarker for DeviceResumeRequest {
763        type Owned = Self;
764
765        #[inline(always)]
766        fn inline_align(_context: fidl::encoding::Context) -> usize {
767            8
768        }
769
770        #[inline(always)]
771        fn inline_size(_context: fidl::encoding::Context) -> usize {
772            16
773        }
774    }
775
776    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceResumeRequest, D>
777        for &DeviceResumeRequest
778    {
779        #[inline]
780        unsafe fn encode(
781            self,
782            encoder: &mut fidl::encoding::Encoder<'_, D>,
783            offset: usize,
784            _depth: fidl::encoding::Depth,
785        ) -> fidl::Result<()> {
786            encoder.debug_check_bounds::<DeviceResumeRequest>(offset);
787            encoder.write_num::<u64>(self.ordinal(), offset);
788            match self {
789                DeviceResumeRequest::Result(ref val) => {
790                    fidl::encoding::encode_in_envelope::<SuspendResult, D>(
791                        <SuspendResult as fidl::encoding::ValueTypeMarker>::borrow(val),
792                        encoder,
793                        offset + 8,
794                        _depth,
795                    )
796                }
797                DeviceResumeRequest::Error(ref val) => {
798                    fidl::encoding::encode_in_envelope::<i32, D>(
799                        <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
800                        encoder,
801                        offset + 8,
802                        _depth,
803                    )
804                }
805                DeviceResumeRequest::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
806            }
807        }
808    }
809
810    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceResumeRequest {
811        #[inline(always)]
812        fn new_empty() -> Self {
813            Self::__SourceBreaking { unknown_ordinal: 0 }
814        }
815
816        #[inline]
817        unsafe fn decode(
818            &mut self,
819            decoder: &mut fidl::encoding::Decoder<'_, D>,
820            offset: usize,
821            mut depth: fidl::encoding::Depth,
822        ) -> fidl::Result<()> {
823            decoder.debug_check_bounds::<Self>(offset);
824            #[allow(unused_variables)]
825            let next_out_of_line = decoder.next_out_of_line();
826            let handles_before = decoder.remaining_handles();
827            let (ordinal, inlined, num_bytes, num_handles) =
828                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
829
830            let member_inline_size = match ordinal {
831                1 => <SuspendResult as fidl::encoding::TypeMarker>::inline_size(decoder.context),
832                2 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
833                0 => return Err(fidl::Error::UnknownUnionTag),
834                _ => num_bytes as usize,
835            };
836
837            if inlined != (member_inline_size <= 4) {
838                return Err(fidl::Error::InvalidInlineBitInEnvelope);
839            }
840            let _inner_offset;
841            if inlined {
842                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
843                _inner_offset = offset + 8;
844            } else {
845                depth.increment()?;
846                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
847            }
848            match ordinal {
849                1 => {
850                    #[allow(irrefutable_let_patterns)]
851                    if let DeviceResumeRequest::Result(_) = self {
852                        // Do nothing, read the value into the object
853                    } else {
854                        // Initialize `self` to the right variant
855                        *self = DeviceResumeRequest::Result(fidl::new_empty!(SuspendResult, D));
856                    }
857                    #[allow(irrefutable_let_patterns)]
858                    if let DeviceResumeRequest::Result(ref mut val) = self {
859                        fidl::decode!(SuspendResult, D, val, decoder, _inner_offset, depth)?;
860                    } else {
861                        unreachable!()
862                    }
863                }
864                2 => {
865                    #[allow(irrefutable_let_patterns)]
866                    if let DeviceResumeRequest::Error(_) = self {
867                        // Do nothing, read the value into the object
868                    } else {
869                        // Initialize `self` to the right variant
870                        *self = DeviceResumeRequest::Error(fidl::new_empty!(i32, D));
871                    }
872                    #[allow(irrefutable_let_patterns)]
873                    if let DeviceResumeRequest::Error(ref mut val) = self {
874                        fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
875                    } else {
876                        unreachable!()
877                    }
878                }
879                #[allow(deprecated)]
880                ordinal => {
881                    for _ in 0..num_handles {
882                        decoder.drop_next_handle()?;
883                    }
884                    *self = DeviceResumeRequest::__SourceBreaking { unknown_ordinal: ordinal };
885                }
886            }
887            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
888                return Err(fidl::Error::InvalidNumBytesInEnvelope);
889            }
890            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
891                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
892            }
893            Ok(())
894        }
895    }
896}