fidl_fuchsia_ui_activity__common/
fidl_fuchsia_ui_activity__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
11pub type OngoingActivityId = u32;
12
13/// State is an enumeration of the activity states the system may be in.
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum State {
17    Unknown = 0,
18    /// IDLE implies that the system is not currently being used by a user.
19    /// In other words, the system is not ACTIVE.
20    Idle = 1,
21    /// ACTIVE implies that a user has recently or is currently using the
22    /// system.
23    ///
24    /// Activity can be signalled by discrete interactions (cursor, keyboard,
25    /// touchscreen), or by ongoing activities (video playback).
26    ///
27    /// The specific meaning of "recently" is an implementation
28    /// detail of the Activity Service, but a typical value is 15 minutes.
29    Active = 2,
30}
31
32impl State {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            0 => Some(Self::Unknown),
37            1 => Some(Self::Idle),
38            2 => Some(Self::Active),
39            _ => None,
40        }
41    }
42
43    #[inline]
44    pub const fn into_primitive(self) -> u32 {
45        self as u32
46    }
47}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct ListenerOnStateChangedRequest {
51    pub state: State,
52    pub transition_time: i64,
53}
54
55impl fidl::Persistable for ListenerOnStateChangedRequest {}
56
57/// GenericActivity is a user or system activity of unspecified type, e.g.
58/// a keyboard press or an alarm going off.
59#[derive(Clone, Debug, Default, PartialEq)]
60pub struct GenericActivity {
61    /// Brief human-readable label for the activity, for logging/debugging.
62    /// e.g. "cursor", "key", "video"
63    pub label: Option<String>,
64    #[doc(hidden)]
65    pub __source_breaking: fidl::marker::SourceBreaking,
66}
67
68impl fidl::Persistable for GenericActivity {}
69
70/// DiscreteActivity is an activity which occurs at a point in time.
71#[derive(Clone, Debug)]
72pub enum DiscreteActivity {
73    /// Activities that require no special handling.
74    Generic(GenericActivity),
75    #[doc(hidden)]
76    __SourceBreaking { unknown_ordinal: u64 },
77}
78
79/// Pattern that matches an unknown `DiscreteActivity` member.
80#[macro_export]
81macro_rules! DiscreteActivityUnknown {
82    () => {
83        _
84    };
85}
86
87// Custom PartialEq so that unknown variants are not equal to themselves.
88impl PartialEq for DiscreteActivity {
89    fn eq(&self, other: &Self) -> bool {
90        match (self, other) {
91            (Self::Generic(x), Self::Generic(y)) => *x == *y,
92            _ => false,
93        }
94    }
95}
96
97impl DiscreteActivity {
98    #[inline]
99    pub fn ordinal(&self) -> u64 {
100        match *self {
101            Self::Generic(_) => 1,
102            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
103        }
104    }
105
106    #[inline]
107    pub fn unknown_variant_for_testing() -> Self {
108        Self::__SourceBreaking { unknown_ordinal: 0 }
109    }
110
111    #[inline]
112    pub fn is_unknown(&self) -> bool {
113        match self {
114            Self::__SourceBreaking { .. } => true,
115            _ => false,
116        }
117    }
118}
119
120impl fidl::Persistable for DiscreteActivity {}
121
122/// OngoingActivity is an activity which has a definite start and end time.
123#[derive(Clone, Debug)]
124pub enum OngoingActivity {
125    /// Activities that require no special handling.
126    Generic(GenericActivity),
127    #[doc(hidden)]
128    __SourceBreaking { unknown_ordinal: u64 },
129}
130
131/// Pattern that matches an unknown `OngoingActivity` member.
132#[macro_export]
133macro_rules! OngoingActivityUnknown {
134    () => {
135        _
136    };
137}
138
139// Custom PartialEq so that unknown variants are not equal to themselves.
140impl PartialEq for OngoingActivity {
141    fn eq(&self, other: &Self) -> bool {
142        match (self, other) {
143            (Self::Generic(x), Self::Generic(y)) => *x == *y,
144            _ => false,
145        }
146    }
147}
148
149impl OngoingActivity {
150    #[inline]
151    pub fn ordinal(&self) -> u64 {
152        match *self {
153            Self::Generic(_) => 1,
154            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
155        }
156    }
157
158    #[inline]
159    pub fn unknown_variant_for_testing() -> Self {
160        Self::__SourceBreaking { unknown_ordinal: 0 }
161    }
162
163    #[inline]
164    pub fn is_unknown(&self) -> bool {
165        match self {
166            Self::__SourceBreaking { .. } => true,
167            _ => false,
168        }
169    }
170}
171
172impl fidl::Persistable for OngoingActivity {}
173
174mod internal {
175    use super::*;
176    unsafe impl fidl::encoding::TypeMarker for State {
177        type Owned = Self;
178
179        #[inline(always)]
180        fn inline_align(_context: fidl::encoding::Context) -> usize {
181            std::mem::align_of::<u32>()
182        }
183
184        #[inline(always)]
185        fn inline_size(_context: fidl::encoding::Context) -> usize {
186            std::mem::size_of::<u32>()
187        }
188
189        #[inline(always)]
190        fn encode_is_copy() -> bool {
191            true
192        }
193
194        #[inline(always)]
195        fn decode_is_copy() -> bool {
196            false
197        }
198    }
199
200    impl fidl::encoding::ValueTypeMarker for State {
201        type Borrowed<'a> = Self;
202        #[inline(always)]
203        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
204            *value
205        }
206    }
207
208    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for State {
209        #[inline]
210        unsafe fn encode(
211            self,
212            encoder: &mut fidl::encoding::Encoder<'_, D>,
213            offset: usize,
214            _depth: fidl::encoding::Depth,
215        ) -> fidl::Result<()> {
216            encoder.debug_check_bounds::<Self>(offset);
217            encoder.write_num(self.into_primitive(), offset);
218            Ok(())
219        }
220    }
221
222    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
223        #[inline(always)]
224        fn new_empty() -> Self {
225            Self::Unknown
226        }
227
228        #[inline]
229        unsafe fn decode(
230            &mut self,
231            decoder: &mut fidl::encoding::Decoder<'_, D>,
232            offset: usize,
233            _depth: fidl::encoding::Depth,
234        ) -> fidl::Result<()> {
235            decoder.debug_check_bounds::<Self>(offset);
236            let prim = decoder.read_num::<u32>(offset);
237
238            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
239            Ok(())
240        }
241    }
242
243    impl fidl::encoding::ValueTypeMarker for ListenerOnStateChangedRequest {
244        type Borrowed<'a> = &'a Self;
245        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
246            value
247        }
248    }
249
250    unsafe impl fidl::encoding::TypeMarker for ListenerOnStateChangedRequest {
251        type Owned = Self;
252
253        #[inline(always)]
254        fn inline_align(_context: fidl::encoding::Context) -> usize {
255            8
256        }
257
258        #[inline(always)]
259        fn inline_size(_context: fidl::encoding::Context) -> usize {
260            16
261        }
262    }
263
264    unsafe impl<D: fidl::encoding::ResourceDialect>
265        fidl::encoding::Encode<ListenerOnStateChangedRequest, D>
266        for &ListenerOnStateChangedRequest
267    {
268        #[inline]
269        unsafe fn encode(
270            self,
271            encoder: &mut fidl::encoding::Encoder<'_, D>,
272            offset: usize,
273            _depth: fidl::encoding::Depth,
274        ) -> fidl::Result<()> {
275            encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
276            // Delegate to tuple encoding.
277            fidl::encoding::Encode::<ListenerOnStateChangedRequest, D>::encode(
278                (
279                    <State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),
280                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.transition_time),
281                ),
282                encoder,
283                offset,
284                _depth,
285            )
286        }
287    }
288    unsafe impl<
289            D: fidl::encoding::ResourceDialect,
290            T0: fidl::encoding::Encode<State, D>,
291            T1: fidl::encoding::Encode<i64, D>,
292        > fidl::encoding::Encode<ListenerOnStateChangedRequest, D> for (T0, T1)
293    {
294        #[inline]
295        unsafe fn encode(
296            self,
297            encoder: &mut fidl::encoding::Encoder<'_, D>,
298            offset: usize,
299            depth: fidl::encoding::Depth,
300        ) -> fidl::Result<()> {
301            encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
302            // Zero out padding regions. There's no need to apply masks
303            // because the unmasked parts will be overwritten by fields.
304            unsafe {
305                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
306                (ptr as *mut u64).write_unaligned(0);
307            }
308            // Write the fields.
309            self.0.encode(encoder, offset + 0, depth)?;
310            self.1.encode(encoder, offset + 8, depth)?;
311            Ok(())
312        }
313    }
314
315    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
316        for ListenerOnStateChangedRequest
317    {
318        #[inline(always)]
319        fn new_empty() -> Self {
320            Self { state: fidl::new_empty!(State, D), transition_time: fidl::new_empty!(i64, D) }
321        }
322
323        #[inline]
324        unsafe fn decode(
325            &mut self,
326            decoder: &mut fidl::encoding::Decoder<'_, D>,
327            offset: usize,
328            _depth: fidl::encoding::Depth,
329        ) -> fidl::Result<()> {
330            decoder.debug_check_bounds::<Self>(offset);
331            // Verify that padding bytes are zero.
332            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
333            let padval = unsafe { (ptr as *const u64).read_unaligned() };
334            let mask = 0xffffffff00000000u64;
335            let maskedval = padval & mask;
336            if maskedval != 0 {
337                return Err(fidl::Error::NonZeroPadding {
338                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
339                });
340            }
341            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
342            fidl::decode!(i64, D, &mut self.transition_time, decoder, offset + 8, _depth)?;
343            Ok(())
344        }
345    }
346
347    impl GenericActivity {
348        #[inline(always)]
349        fn max_ordinal_present(&self) -> u64 {
350            if let Some(_) = self.label {
351                return 1;
352            }
353            0
354        }
355    }
356
357    impl fidl::encoding::ValueTypeMarker for GenericActivity {
358        type Borrowed<'a> = &'a Self;
359        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
360            value
361        }
362    }
363
364    unsafe impl fidl::encoding::TypeMarker for GenericActivity {
365        type Owned = Self;
366
367        #[inline(always)]
368        fn inline_align(_context: fidl::encoding::Context) -> usize {
369            8
370        }
371
372        #[inline(always)]
373        fn inline_size(_context: fidl::encoding::Context) -> usize {
374            16
375        }
376    }
377
378    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GenericActivity, D>
379        for &GenericActivity
380    {
381        unsafe fn encode(
382            self,
383            encoder: &mut fidl::encoding::Encoder<'_, D>,
384            offset: usize,
385            mut depth: fidl::encoding::Depth,
386        ) -> fidl::Result<()> {
387            encoder.debug_check_bounds::<GenericActivity>(offset);
388            // Vector header
389            let max_ordinal: u64 = self.max_ordinal_present();
390            encoder.write_num(max_ordinal, offset);
391            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
392            // Calling encoder.out_of_line_offset(0) is not allowed.
393            if max_ordinal == 0 {
394                return Ok(());
395            }
396            depth.increment()?;
397            let envelope_size = 8;
398            let bytes_len = max_ordinal as usize * envelope_size;
399            #[allow(unused_variables)]
400            let offset = encoder.out_of_line_offset(bytes_len);
401            let mut _prev_end_offset: usize = 0;
402            if 1 > max_ordinal {
403                return Ok(());
404            }
405
406            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
407            // are envelope_size bytes.
408            let cur_offset: usize = (1 - 1) * envelope_size;
409
410            // Zero reserved fields.
411            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
412
413            // Safety:
414            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
415            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
416            //   envelope_size bytes, there is always sufficient room.
417            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
418                self.label.as_ref().map(
419                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
420                ),
421                encoder,
422                offset + cur_offset,
423                depth,
424            )?;
425
426            _prev_end_offset = cur_offset + envelope_size;
427
428            Ok(())
429        }
430    }
431
432    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GenericActivity {
433        #[inline(always)]
434        fn new_empty() -> Self {
435            Self::default()
436        }
437
438        unsafe fn decode(
439            &mut self,
440            decoder: &mut fidl::encoding::Decoder<'_, D>,
441            offset: usize,
442            mut depth: fidl::encoding::Depth,
443        ) -> fidl::Result<()> {
444            decoder.debug_check_bounds::<Self>(offset);
445            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
446                None => return Err(fidl::Error::NotNullable),
447                Some(len) => len,
448            };
449            // Calling decoder.out_of_line_offset(0) is not allowed.
450            if len == 0 {
451                return Ok(());
452            };
453            depth.increment()?;
454            let envelope_size = 8;
455            let bytes_len = len * envelope_size;
456            let offset = decoder.out_of_line_offset(bytes_len)?;
457            // Decode the envelope for each type.
458            let mut _next_ordinal_to_read = 0;
459            let mut next_offset = offset;
460            let end_offset = offset + bytes_len;
461            _next_ordinal_to_read += 1;
462            if next_offset >= end_offset {
463                return Ok(());
464            }
465
466            // Decode unknown envelopes for gaps in ordinals.
467            while _next_ordinal_to_read < 1 {
468                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
469                _next_ordinal_to_read += 1;
470                next_offset += envelope_size;
471            }
472
473            let next_out_of_line = decoder.next_out_of_line();
474            let handles_before = decoder.remaining_handles();
475            if let Some((inlined, num_bytes, num_handles)) =
476                fidl::encoding::decode_envelope_header(decoder, next_offset)?
477            {
478                let member_inline_size =
479                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
480                        decoder.context,
481                    );
482                if inlined != (member_inline_size <= 4) {
483                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
484                }
485                let inner_offset;
486                let mut inner_depth = depth.clone();
487                if inlined {
488                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
489                    inner_offset = next_offset;
490                } else {
491                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
492                    inner_depth.increment()?;
493                }
494                let val_ref = self
495                    .label
496                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
497                fidl::decode!(
498                    fidl::encoding::UnboundedString,
499                    D,
500                    val_ref,
501                    decoder,
502                    inner_offset,
503                    inner_depth
504                )?;
505                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
506                {
507                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
508                }
509                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
510                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
511                }
512            }
513
514            next_offset += envelope_size;
515
516            // Decode the remaining unknown envelopes.
517            while next_offset < end_offset {
518                _next_ordinal_to_read += 1;
519                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
520                next_offset += envelope_size;
521            }
522
523            Ok(())
524        }
525    }
526
527    impl fidl::encoding::ValueTypeMarker for DiscreteActivity {
528        type Borrowed<'a> = &'a Self;
529        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
530            value
531        }
532    }
533
534    unsafe impl fidl::encoding::TypeMarker for DiscreteActivity {
535        type Owned = Self;
536
537        #[inline(always)]
538        fn inline_align(_context: fidl::encoding::Context) -> usize {
539            8
540        }
541
542        #[inline(always)]
543        fn inline_size(_context: fidl::encoding::Context) -> usize {
544            16
545        }
546    }
547
548    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DiscreteActivity, D>
549        for &DiscreteActivity
550    {
551        #[inline]
552        unsafe fn encode(
553            self,
554            encoder: &mut fidl::encoding::Encoder<'_, D>,
555            offset: usize,
556            _depth: fidl::encoding::Depth,
557        ) -> fidl::Result<()> {
558            encoder.debug_check_bounds::<DiscreteActivity>(offset);
559            encoder.write_num::<u64>(self.ordinal(), offset);
560            match self {
561                DiscreteActivity::Generic(ref val) => {
562                    fidl::encoding::encode_in_envelope::<GenericActivity, D>(
563                        <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
564                        encoder,
565                        offset + 8,
566                        _depth,
567                    )
568                }
569                DiscreteActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
570            }
571        }
572    }
573
574    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DiscreteActivity {
575        #[inline(always)]
576        fn new_empty() -> Self {
577            Self::__SourceBreaking { unknown_ordinal: 0 }
578        }
579
580        #[inline]
581        unsafe fn decode(
582            &mut self,
583            decoder: &mut fidl::encoding::Decoder<'_, D>,
584            offset: usize,
585            mut depth: fidl::encoding::Depth,
586        ) -> fidl::Result<()> {
587            decoder.debug_check_bounds::<Self>(offset);
588            #[allow(unused_variables)]
589            let next_out_of_line = decoder.next_out_of_line();
590            let handles_before = decoder.remaining_handles();
591            let (ordinal, inlined, num_bytes, num_handles) =
592                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
593
594            let member_inline_size = match ordinal {
595                1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
596                0 => return Err(fidl::Error::UnknownUnionTag),
597                _ => num_bytes as usize,
598            };
599
600            if inlined != (member_inline_size <= 4) {
601                return Err(fidl::Error::InvalidInlineBitInEnvelope);
602            }
603            let _inner_offset;
604            if inlined {
605                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
606                _inner_offset = offset + 8;
607            } else {
608                depth.increment()?;
609                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
610            }
611            match ordinal {
612                1 => {
613                    #[allow(irrefutable_let_patterns)]
614                    if let DiscreteActivity::Generic(_) = self {
615                        // Do nothing, read the value into the object
616                    } else {
617                        // Initialize `self` to the right variant
618                        *self = DiscreteActivity::Generic(fidl::new_empty!(GenericActivity, D));
619                    }
620                    #[allow(irrefutable_let_patterns)]
621                    if let DiscreteActivity::Generic(ref mut val) = self {
622                        fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
623                    } else {
624                        unreachable!()
625                    }
626                }
627                #[allow(deprecated)]
628                ordinal => {
629                    for _ in 0..num_handles {
630                        decoder.drop_next_handle()?;
631                    }
632                    *self = DiscreteActivity::__SourceBreaking { unknown_ordinal: ordinal };
633                }
634            }
635            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
636                return Err(fidl::Error::InvalidNumBytesInEnvelope);
637            }
638            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
639                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
640            }
641            Ok(())
642        }
643    }
644
645    impl fidl::encoding::ValueTypeMarker for OngoingActivity {
646        type Borrowed<'a> = &'a Self;
647        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
648            value
649        }
650    }
651
652    unsafe impl fidl::encoding::TypeMarker for OngoingActivity {
653        type Owned = Self;
654
655        #[inline(always)]
656        fn inline_align(_context: fidl::encoding::Context) -> usize {
657            8
658        }
659
660        #[inline(always)]
661        fn inline_size(_context: fidl::encoding::Context) -> usize {
662            16
663        }
664    }
665
666    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OngoingActivity, D>
667        for &OngoingActivity
668    {
669        #[inline]
670        unsafe fn encode(
671            self,
672            encoder: &mut fidl::encoding::Encoder<'_, D>,
673            offset: usize,
674            _depth: fidl::encoding::Depth,
675        ) -> fidl::Result<()> {
676            encoder.debug_check_bounds::<OngoingActivity>(offset);
677            encoder.write_num::<u64>(self.ordinal(), offset);
678            match self {
679                OngoingActivity::Generic(ref val) => {
680                    fidl::encoding::encode_in_envelope::<GenericActivity, D>(
681                        <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
682                        encoder,
683                        offset + 8,
684                        _depth,
685                    )
686                }
687                OngoingActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
688            }
689        }
690    }
691
692    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OngoingActivity {
693        #[inline(always)]
694        fn new_empty() -> Self {
695            Self::__SourceBreaking { unknown_ordinal: 0 }
696        }
697
698        #[inline]
699        unsafe fn decode(
700            &mut self,
701            decoder: &mut fidl::encoding::Decoder<'_, D>,
702            offset: usize,
703            mut depth: fidl::encoding::Depth,
704        ) -> fidl::Result<()> {
705            decoder.debug_check_bounds::<Self>(offset);
706            #[allow(unused_variables)]
707            let next_out_of_line = decoder.next_out_of_line();
708            let handles_before = decoder.remaining_handles();
709            let (ordinal, inlined, num_bytes, num_handles) =
710                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
711
712            let member_inline_size = match ordinal {
713                1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
714                0 => return Err(fidl::Error::UnknownUnionTag),
715                _ => num_bytes as usize,
716            };
717
718            if inlined != (member_inline_size <= 4) {
719                return Err(fidl::Error::InvalidInlineBitInEnvelope);
720            }
721            let _inner_offset;
722            if inlined {
723                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
724                _inner_offset = offset + 8;
725            } else {
726                depth.increment()?;
727                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
728            }
729            match ordinal {
730                1 => {
731                    #[allow(irrefutable_let_patterns)]
732                    if let OngoingActivity::Generic(_) = self {
733                        // Do nothing, read the value into the object
734                    } else {
735                        // Initialize `self` to the right variant
736                        *self = OngoingActivity::Generic(fidl::new_empty!(GenericActivity, D));
737                    }
738                    #[allow(irrefutable_let_patterns)]
739                    if let OngoingActivity::Generic(ref mut val) = self {
740                        fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
741                    } else {
742                        unreachable!()
743                    }
744                }
745                #[allow(deprecated)]
746                ordinal => {
747                    for _ in 0..num_handles {
748                        decoder.drop_next_handle()?;
749                    }
750                    *self = OngoingActivity::__SourceBreaking { unknown_ordinal: ordinal };
751                }
752            }
753            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
754                return Err(fidl::Error::InvalidNumBytesInEnvelope);
755            }
756            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
757                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
758            }
759            Ok(())
760        }
761    }
762}