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
174pub mod listener_ordinals {
175    pub const ON_STATE_CHANGED: u64 = 0xf74db3e6d5ba415;
176}
177
178pub mod provider_ordinals {
179    pub const WATCH_STATE: u64 = 0x592e25a4cbe7f884;
180}
181
182mod internal {
183    use super::*;
184    unsafe impl fidl::encoding::TypeMarker for State {
185        type Owned = Self;
186
187        #[inline(always)]
188        fn inline_align(_context: fidl::encoding::Context) -> usize {
189            std::mem::align_of::<u32>()
190        }
191
192        #[inline(always)]
193        fn inline_size(_context: fidl::encoding::Context) -> usize {
194            std::mem::size_of::<u32>()
195        }
196
197        #[inline(always)]
198        fn encode_is_copy() -> bool {
199            true
200        }
201
202        #[inline(always)]
203        fn decode_is_copy() -> bool {
204            false
205        }
206    }
207
208    impl fidl::encoding::ValueTypeMarker for State {
209        type Borrowed<'a> = Self;
210        #[inline(always)]
211        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
212            *value
213        }
214    }
215
216    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for State {
217        #[inline]
218        unsafe fn encode(
219            self,
220            encoder: &mut fidl::encoding::Encoder<'_, D>,
221            offset: usize,
222            _depth: fidl::encoding::Depth,
223        ) -> fidl::Result<()> {
224            encoder.debug_check_bounds::<Self>(offset);
225            encoder.write_num(self.into_primitive(), offset);
226            Ok(())
227        }
228    }
229
230    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
231        #[inline(always)]
232        fn new_empty() -> Self {
233            Self::Unknown
234        }
235
236        #[inline]
237        unsafe fn decode(
238            &mut self,
239            decoder: &mut fidl::encoding::Decoder<'_, D>,
240            offset: usize,
241            _depth: fidl::encoding::Depth,
242        ) -> fidl::Result<()> {
243            decoder.debug_check_bounds::<Self>(offset);
244            let prim = decoder.read_num::<u32>(offset);
245
246            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
247            Ok(())
248        }
249    }
250
251    impl fidl::encoding::ValueTypeMarker for ListenerOnStateChangedRequest {
252        type Borrowed<'a> = &'a Self;
253        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
254            value
255        }
256    }
257
258    unsafe impl fidl::encoding::TypeMarker for ListenerOnStateChangedRequest {
259        type Owned = Self;
260
261        #[inline(always)]
262        fn inline_align(_context: fidl::encoding::Context) -> usize {
263            8
264        }
265
266        #[inline(always)]
267        fn inline_size(_context: fidl::encoding::Context) -> usize {
268            16
269        }
270    }
271
272    unsafe impl<D: fidl::encoding::ResourceDialect>
273        fidl::encoding::Encode<ListenerOnStateChangedRequest, D>
274        for &ListenerOnStateChangedRequest
275    {
276        #[inline]
277        unsafe fn encode(
278            self,
279            encoder: &mut fidl::encoding::Encoder<'_, D>,
280            offset: usize,
281            _depth: fidl::encoding::Depth,
282        ) -> fidl::Result<()> {
283            encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
284            // Delegate to tuple encoding.
285            fidl::encoding::Encode::<ListenerOnStateChangedRequest, D>::encode(
286                (
287                    <State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),
288                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.transition_time),
289                ),
290                encoder,
291                offset,
292                _depth,
293            )
294        }
295    }
296    unsafe impl<
297            D: fidl::encoding::ResourceDialect,
298            T0: fidl::encoding::Encode<State, D>,
299            T1: fidl::encoding::Encode<i64, D>,
300        > fidl::encoding::Encode<ListenerOnStateChangedRequest, D> for (T0, T1)
301    {
302        #[inline]
303        unsafe fn encode(
304            self,
305            encoder: &mut fidl::encoding::Encoder<'_, D>,
306            offset: usize,
307            depth: fidl::encoding::Depth,
308        ) -> fidl::Result<()> {
309            encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
310            // Zero out padding regions. There's no need to apply masks
311            // because the unmasked parts will be overwritten by fields.
312            unsafe {
313                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
314                (ptr as *mut u64).write_unaligned(0);
315            }
316            // Write the fields.
317            self.0.encode(encoder, offset + 0, depth)?;
318            self.1.encode(encoder, offset + 8, depth)?;
319            Ok(())
320        }
321    }
322
323    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
324        for ListenerOnStateChangedRequest
325    {
326        #[inline(always)]
327        fn new_empty() -> Self {
328            Self { state: fidl::new_empty!(State, D), transition_time: fidl::new_empty!(i64, D) }
329        }
330
331        #[inline]
332        unsafe fn decode(
333            &mut self,
334            decoder: &mut fidl::encoding::Decoder<'_, D>,
335            offset: usize,
336            _depth: fidl::encoding::Depth,
337        ) -> fidl::Result<()> {
338            decoder.debug_check_bounds::<Self>(offset);
339            // Verify that padding bytes are zero.
340            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
341            let padval = unsafe { (ptr as *const u64).read_unaligned() };
342            let mask = 0xffffffff00000000u64;
343            let maskedval = padval & mask;
344            if maskedval != 0 {
345                return Err(fidl::Error::NonZeroPadding {
346                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
347                });
348            }
349            fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
350            fidl::decode!(i64, D, &mut self.transition_time, decoder, offset + 8, _depth)?;
351            Ok(())
352        }
353    }
354
355    impl GenericActivity {
356        #[inline(always)]
357        fn max_ordinal_present(&self) -> u64 {
358            if let Some(_) = self.label {
359                return 1;
360            }
361            0
362        }
363    }
364
365    impl fidl::encoding::ValueTypeMarker for GenericActivity {
366        type Borrowed<'a> = &'a Self;
367        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
368            value
369        }
370    }
371
372    unsafe impl fidl::encoding::TypeMarker for GenericActivity {
373        type Owned = Self;
374
375        #[inline(always)]
376        fn inline_align(_context: fidl::encoding::Context) -> usize {
377            8
378        }
379
380        #[inline(always)]
381        fn inline_size(_context: fidl::encoding::Context) -> usize {
382            16
383        }
384    }
385
386    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GenericActivity, D>
387        for &GenericActivity
388    {
389        unsafe fn encode(
390            self,
391            encoder: &mut fidl::encoding::Encoder<'_, D>,
392            offset: usize,
393            mut depth: fidl::encoding::Depth,
394        ) -> fidl::Result<()> {
395            encoder.debug_check_bounds::<GenericActivity>(offset);
396            // Vector header
397            let max_ordinal: u64 = self.max_ordinal_present();
398            encoder.write_num(max_ordinal, offset);
399            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
400            // Calling encoder.out_of_line_offset(0) is not allowed.
401            if max_ordinal == 0 {
402                return Ok(());
403            }
404            depth.increment()?;
405            let envelope_size = 8;
406            let bytes_len = max_ordinal as usize * envelope_size;
407            #[allow(unused_variables)]
408            let offset = encoder.out_of_line_offset(bytes_len);
409            let mut _prev_end_offset: usize = 0;
410            if 1 > max_ordinal {
411                return Ok(());
412            }
413
414            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
415            // are envelope_size bytes.
416            let cur_offset: usize = (1 - 1) * envelope_size;
417
418            // Zero reserved fields.
419            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
420
421            // Safety:
422            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
423            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
424            //   envelope_size bytes, there is always sufficient room.
425            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
426                self.label.as_ref().map(
427                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
428                ),
429                encoder,
430                offset + cur_offset,
431                depth,
432            )?;
433
434            _prev_end_offset = cur_offset + envelope_size;
435
436            Ok(())
437        }
438    }
439
440    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GenericActivity {
441        #[inline(always)]
442        fn new_empty() -> Self {
443            Self::default()
444        }
445
446        unsafe fn decode(
447            &mut self,
448            decoder: &mut fidl::encoding::Decoder<'_, D>,
449            offset: usize,
450            mut depth: fidl::encoding::Depth,
451        ) -> fidl::Result<()> {
452            decoder.debug_check_bounds::<Self>(offset);
453            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
454                None => return Err(fidl::Error::NotNullable),
455                Some(len) => len,
456            };
457            // Calling decoder.out_of_line_offset(0) is not allowed.
458            if len == 0 {
459                return Ok(());
460            };
461            depth.increment()?;
462            let envelope_size = 8;
463            let bytes_len = len * envelope_size;
464            let offset = decoder.out_of_line_offset(bytes_len)?;
465            // Decode the envelope for each type.
466            let mut _next_ordinal_to_read = 0;
467            let mut next_offset = offset;
468            let end_offset = offset + bytes_len;
469            _next_ordinal_to_read += 1;
470            if next_offset >= end_offset {
471                return Ok(());
472            }
473
474            // Decode unknown envelopes for gaps in ordinals.
475            while _next_ordinal_to_read < 1 {
476                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
477                _next_ordinal_to_read += 1;
478                next_offset += envelope_size;
479            }
480
481            let next_out_of_line = decoder.next_out_of_line();
482            let handles_before = decoder.remaining_handles();
483            if let Some((inlined, num_bytes, num_handles)) =
484                fidl::encoding::decode_envelope_header(decoder, next_offset)?
485            {
486                let member_inline_size =
487                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
488                        decoder.context,
489                    );
490                if inlined != (member_inline_size <= 4) {
491                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
492                }
493                let inner_offset;
494                let mut inner_depth = depth.clone();
495                if inlined {
496                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
497                    inner_offset = next_offset;
498                } else {
499                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
500                    inner_depth.increment()?;
501                }
502                let val_ref = self
503                    .label
504                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
505                fidl::decode!(
506                    fidl::encoding::UnboundedString,
507                    D,
508                    val_ref,
509                    decoder,
510                    inner_offset,
511                    inner_depth
512                )?;
513                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
514                {
515                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
516                }
517                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
518                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
519                }
520            }
521
522            next_offset += envelope_size;
523
524            // Decode the remaining unknown envelopes.
525            while next_offset < end_offset {
526                _next_ordinal_to_read += 1;
527                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
528                next_offset += envelope_size;
529            }
530
531            Ok(())
532        }
533    }
534
535    impl fidl::encoding::ValueTypeMarker for DiscreteActivity {
536        type Borrowed<'a> = &'a Self;
537        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
538            value
539        }
540    }
541
542    unsafe impl fidl::encoding::TypeMarker for DiscreteActivity {
543        type Owned = Self;
544
545        #[inline(always)]
546        fn inline_align(_context: fidl::encoding::Context) -> usize {
547            8
548        }
549
550        #[inline(always)]
551        fn inline_size(_context: fidl::encoding::Context) -> usize {
552            16
553        }
554    }
555
556    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DiscreteActivity, D>
557        for &DiscreteActivity
558    {
559        #[inline]
560        unsafe fn encode(
561            self,
562            encoder: &mut fidl::encoding::Encoder<'_, D>,
563            offset: usize,
564            _depth: fidl::encoding::Depth,
565        ) -> fidl::Result<()> {
566            encoder.debug_check_bounds::<DiscreteActivity>(offset);
567            encoder.write_num::<u64>(self.ordinal(), offset);
568            match self {
569                DiscreteActivity::Generic(ref val) => {
570                    fidl::encoding::encode_in_envelope::<GenericActivity, D>(
571                        <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
572                        encoder,
573                        offset + 8,
574                        _depth,
575                    )
576                }
577                DiscreteActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
578            }
579        }
580    }
581
582    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DiscreteActivity {
583        #[inline(always)]
584        fn new_empty() -> Self {
585            Self::__SourceBreaking { unknown_ordinal: 0 }
586        }
587
588        #[inline]
589        unsafe fn decode(
590            &mut self,
591            decoder: &mut fidl::encoding::Decoder<'_, D>,
592            offset: usize,
593            mut depth: fidl::encoding::Depth,
594        ) -> fidl::Result<()> {
595            decoder.debug_check_bounds::<Self>(offset);
596            #[allow(unused_variables)]
597            let next_out_of_line = decoder.next_out_of_line();
598            let handles_before = decoder.remaining_handles();
599            let (ordinal, inlined, num_bytes, num_handles) =
600                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
601
602            let member_inline_size = match ordinal {
603                1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
604                0 => return Err(fidl::Error::UnknownUnionTag),
605                _ => num_bytes as usize,
606            };
607
608            if inlined != (member_inline_size <= 4) {
609                return Err(fidl::Error::InvalidInlineBitInEnvelope);
610            }
611            let _inner_offset;
612            if inlined {
613                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
614                _inner_offset = offset + 8;
615            } else {
616                depth.increment()?;
617                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
618            }
619            match ordinal {
620                1 => {
621                    #[allow(irrefutable_let_patterns)]
622                    if let DiscreteActivity::Generic(_) = self {
623                        // Do nothing, read the value into the object
624                    } else {
625                        // Initialize `self` to the right variant
626                        *self = DiscreteActivity::Generic(fidl::new_empty!(GenericActivity, D));
627                    }
628                    #[allow(irrefutable_let_patterns)]
629                    if let DiscreteActivity::Generic(ref mut val) = self {
630                        fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
631                    } else {
632                        unreachable!()
633                    }
634                }
635                #[allow(deprecated)]
636                ordinal => {
637                    for _ in 0..num_handles {
638                        decoder.drop_next_handle()?;
639                    }
640                    *self = DiscreteActivity::__SourceBreaking { unknown_ordinal: ordinal };
641                }
642            }
643            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
644                return Err(fidl::Error::InvalidNumBytesInEnvelope);
645            }
646            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
647                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
648            }
649            Ok(())
650        }
651    }
652
653    impl fidl::encoding::ValueTypeMarker for OngoingActivity {
654        type Borrowed<'a> = &'a Self;
655        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
656            value
657        }
658    }
659
660    unsafe impl fidl::encoding::TypeMarker for OngoingActivity {
661        type Owned = Self;
662
663        #[inline(always)]
664        fn inline_align(_context: fidl::encoding::Context) -> usize {
665            8
666        }
667
668        #[inline(always)]
669        fn inline_size(_context: fidl::encoding::Context) -> usize {
670            16
671        }
672    }
673
674    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OngoingActivity, D>
675        for &OngoingActivity
676    {
677        #[inline]
678        unsafe fn encode(
679            self,
680            encoder: &mut fidl::encoding::Encoder<'_, D>,
681            offset: usize,
682            _depth: fidl::encoding::Depth,
683        ) -> fidl::Result<()> {
684            encoder.debug_check_bounds::<OngoingActivity>(offset);
685            encoder.write_num::<u64>(self.ordinal(), offset);
686            match self {
687                OngoingActivity::Generic(ref val) => {
688                    fidl::encoding::encode_in_envelope::<GenericActivity, D>(
689                        <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
690                        encoder,
691                        offset + 8,
692                        _depth,
693                    )
694                }
695                OngoingActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
696            }
697        }
698    }
699
700    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OngoingActivity {
701        #[inline(always)]
702        fn new_empty() -> Self {
703            Self::__SourceBreaking { unknown_ordinal: 0 }
704        }
705
706        #[inline]
707        unsafe fn decode(
708            &mut self,
709            decoder: &mut fidl::encoding::Decoder<'_, D>,
710            offset: usize,
711            mut depth: fidl::encoding::Depth,
712        ) -> fidl::Result<()> {
713            decoder.debug_check_bounds::<Self>(offset);
714            #[allow(unused_variables)]
715            let next_out_of_line = decoder.next_out_of_line();
716            let handles_before = decoder.remaining_handles();
717            let (ordinal, inlined, num_bytes, num_handles) =
718                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
719
720            let member_inline_size = match ordinal {
721                1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
722                0 => return Err(fidl::Error::UnknownUnionTag),
723                _ => num_bytes as usize,
724            };
725
726            if inlined != (member_inline_size <= 4) {
727                return Err(fidl::Error::InvalidInlineBitInEnvelope);
728            }
729            let _inner_offset;
730            if inlined {
731                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
732                _inner_offset = offset + 8;
733            } else {
734                depth.increment()?;
735                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
736            }
737            match ordinal {
738                1 => {
739                    #[allow(irrefutable_let_patterns)]
740                    if let OngoingActivity::Generic(_) = self {
741                        // Do nothing, read the value into the object
742                    } else {
743                        // Initialize `self` to the right variant
744                        *self = OngoingActivity::Generic(fidl::new_empty!(GenericActivity, D));
745                    }
746                    #[allow(irrefutable_let_patterns)]
747                    if let OngoingActivity::Generic(ref mut val) = self {
748                        fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
749                    } else {
750                        unreachable!()
751                    }
752                }
753                #[allow(deprecated)]
754                ordinal => {
755                    for _ in 0..num_handles {
756                        decoder.drop_next_handle()?;
757                    }
758                    *self = OngoingActivity::__SourceBreaking { unknown_ordinal: ordinal };
759                }
760            }
761            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
762                return Err(fidl::Error::InvalidNumBytesInEnvelope);
763            }
764            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
765                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
766            }
767            Ok(())
768        }
769    }
770}