1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub type OngoingActivityId = u32;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum State {
17 Unknown = 0,
18 Idle = 1,
21 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 #[deprecated = "Strict enums should not use `is_unknown`"]
49 #[inline]
50 pub fn is_unknown(&self) -> bool {
51 false
52 }
53}
54
55#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct ListenerOnStateChangedRequest {
57 pub state: State,
58 pub transition_time: i64,
59}
60
61impl fidl::Persistable for ListenerOnStateChangedRequest {}
62
63#[derive(Clone, Debug, Default, PartialEq)]
66pub struct GenericActivity {
67 pub label: Option<String>,
70 #[doc(hidden)]
71 pub __source_breaking: fidl::marker::SourceBreaking,
72}
73
74impl fidl::Persistable for GenericActivity {}
75
76#[derive(Clone, Debug)]
78pub enum DiscreteActivity {
79 Generic(GenericActivity),
81 #[doc(hidden)]
82 __SourceBreaking { unknown_ordinal: u64 },
83}
84
85#[macro_export]
87macro_rules! DiscreteActivityUnknown {
88 () => {
89 _
90 };
91}
92
93impl PartialEq for DiscreteActivity {
95 fn eq(&self, other: &Self) -> bool {
96 match (self, other) {
97 (Self::Generic(x), Self::Generic(y)) => *x == *y,
98 _ => false,
99 }
100 }
101}
102
103impl DiscreteActivity {
104 #[inline]
105 pub fn ordinal(&self) -> u64 {
106 match *self {
107 Self::Generic(_) => 1,
108 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
109 }
110 }
111
112 #[inline]
113 pub fn unknown_variant_for_testing() -> Self {
114 Self::__SourceBreaking { unknown_ordinal: 0 }
115 }
116
117 #[inline]
118 pub fn is_unknown(&self) -> bool {
119 match self {
120 Self::__SourceBreaking { .. } => true,
121 _ => false,
122 }
123 }
124}
125
126impl fidl::Persistable for DiscreteActivity {}
127
128#[derive(Clone, Debug)]
130pub enum OngoingActivity {
131 Generic(GenericActivity),
133 #[doc(hidden)]
134 __SourceBreaking { unknown_ordinal: u64 },
135}
136
137#[macro_export]
139macro_rules! OngoingActivityUnknown {
140 () => {
141 _
142 };
143}
144
145impl PartialEq for OngoingActivity {
147 fn eq(&self, other: &Self) -> bool {
148 match (self, other) {
149 (Self::Generic(x), Self::Generic(y)) => *x == *y,
150 _ => false,
151 }
152 }
153}
154
155impl OngoingActivity {
156 #[inline]
157 pub fn ordinal(&self) -> u64 {
158 match *self {
159 Self::Generic(_) => 1,
160 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
161 }
162 }
163
164 #[inline]
165 pub fn unknown_variant_for_testing() -> Self {
166 Self::__SourceBreaking { unknown_ordinal: 0 }
167 }
168
169 #[inline]
170 pub fn is_unknown(&self) -> bool {
171 match self {
172 Self::__SourceBreaking { .. } => true,
173 _ => false,
174 }
175 }
176}
177
178impl fidl::Persistable for OngoingActivity {}
179
180mod internal {
181 use super::*;
182 unsafe impl fidl::encoding::TypeMarker for State {
183 type Owned = Self;
184
185 #[inline(always)]
186 fn inline_align(_context: fidl::encoding::Context) -> usize {
187 std::mem::align_of::<u32>()
188 }
189
190 #[inline(always)]
191 fn inline_size(_context: fidl::encoding::Context) -> usize {
192 std::mem::size_of::<u32>()
193 }
194
195 #[inline(always)]
196 fn encode_is_copy() -> bool {
197 true
198 }
199
200 #[inline(always)]
201 fn decode_is_copy() -> bool {
202 false
203 }
204 }
205
206 impl fidl::encoding::ValueTypeMarker for State {
207 type Borrowed<'a> = Self;
208 #[inline(always)]
209 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
210 *value
211 }
212 }
213
214 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for State {
215 #[inline]
216 unsafe fn encode(
217 self,
218 encoder: &mut fidl::encoding::Encoder<'_, D>,
219 offset: usize,
220 _depth: fidl::encoding::Depth,
221 ) -> fidl::Result<()> {
222 encoder.debug_check_bounds::<Self>(offset);
223 encoder.write_num(self.into_primitive(), offset);
224 Ok(())
225 }
226 }
227
228 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
229 #[inline(always)]
230 fn new_empty() -> Self {
231 Self::Unknown
232 }
233
234 #[inline]
235 unsafe fn decode(
236 &mut self,
237 decoder: &mut fidl::encoding::Decoder<'_, D>,
238 offset: usize,
239 _depth: fidl::encoding::Depth,
240 ) -> fidl::Result<()> {
241 decoder.debug_check_bounds::<Self>(offset);
242 let prim = decoder.read_num::<u32>(offset);
243
244 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
245 Ok(())
246 }
247 }
248
249 impl fidl::encoding::ValueTypeMarker for ListenerOnStateChangedRequest {
250 type Borrowed<'a> = &'a Self;
251 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
252 value
253 }
254 }
255
256 unsafe impl fidl::encoding::TypeMarker for ListenerOnStateChangedRequest {
257 type Owned = Self;
258
259 #[inline(always)]
260 fn inline_align(_context: fidl::encoding::Context) -> usize {
261 8
262 }
263
264 #[inline(always)]
265 fn inline_size(_context: fidl::encoding::Context) -> usize {
266 16
267 }
268 }
269
270 unsafe impl<D: fidl::encoding::ResourceDialect>
271 fidl::encoding::Encode<ListenerOnStateChangedRequest, D>
272 for &ListenerOnStateChangedRequest
273 {
274 #[inline]
275 unsafe fn encode(
276 self,
277 encoder: &mut fidl::encoding::Encoder<'_, D>,
278 offset: usize,
279 _depth: fidl::encoding::Depth,
280 ) -> fidl::Result<()> {
281 encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
282 fidl::encoding::Encode::<ListenerOnStateChangedRequest, D>::encode(
284 (
285 <State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),
286 <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.transition_time),
287 ),
288 encoder,
289 offset,
290 _depth,
291 )
292 }
293 }
294 unsafe impl<
295 D: fidl::encoding::ResourceDialect,
296 T0: fidl::encoding::Encode<State, D>,
297 T1: fidl::encoding::Encode<i64, D>,
298 > fidl::encoding::Encode<ListenerOnStateChangedRequest, D> for (T0, T1)
299 {
300 #[inline]
301 unsafe fn encode(
302 self,
303 encoder: &mut fidl::encoding::Encoder<'_, D>,
304 offset: usize,
305 depth: fidl::encoding::Depth,
306 ) -> fidl::Result<()> {
307 encoder.debug_check_bounds::<ListenerOnStateChangedRequest>(offset);
308 unsafe {
311 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
312 (ptr as *mut u64).write_unaligned(0);
313 }
314 self.0.encode(encoder, offset + 0, depth)?;
316 self.1.encode(encoder, offset + 8, depth)?;
317 Ok(())
318 }
319 }
320
321 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
322 for ListenerOnStateChangedRequest
323 {
324 #[inline(always)]
325 fn new_empty() -> Self {
326 Self { state: fidl::new_empty!(State, D), transition_time: fidl::new_empty!(i64, D) }
327 }
328
329 #[inline]
330 unsafe fn decode(
331 &mut self,
332 decoder: &mut fidl::encoding::Decoder<'_, D>,
333 offset: usize,
334 _depth: fidl::encoding::Depth,
335 ) -> fidl::Result<()> {
336 decoder.debug_check_bounds::<Self>(offset);
337 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
339 let padval = unsafe { (ptr as *const u64).read_unaligned() };
340 let mask = 0xffffffff00000000u64;
341 let maskedval = padval & mask;
342 if maskedval != 0 {
343 return Err(fidl::Error::NonZeroPadding {
344 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
345 });
346 }
347 fidl::decode!(State, D, &mut self.state, decoder, offset + 0, _depth)?;
348 fidl::decode!(i64, D, &mut self.transition_time, decoder, offset + 8, _depth)?;
349 Ok(())
350 }
351 }
352
353 impl GenericActivity {
354 #[inline(always)]
355 fn max_ordinal_present(&self) -> u64 {
356 if let Some(_) = self.label {
357 return 1;
358 }
359 0
360 }
361 }
362
363 impl fidl::encoding::ValueTypeMarker for GenericActivity {
364 type Borrowed<'a> = &'a Self;
365 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
366 value
367 }
368 }
369
370 unsafe impl fidl::encoding::TypeMarker for GenericActivity {
371 type Owned = Self;
372
373 #[inline(always)]
374 fn inline_align(_context: fidl::encoding::Context) -> usize {
375 8
376 }
377
378 #[inline(always)]
379 fn inline_size(_context: fidl::encoding::Context) -> usize {
380 16
381 }
382 }
383
384 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GenericActivity, D>
385 for &GenericActivity
386 {
387 unsafe fn encode(
388 self,
389 encoder: &mut fidl::encoding::Encoder<'_, D>,
390 offset: usize,
391 mut depth: fidl::encoding::Depth,
392 ) -> fidl::Result<()> {
393 encoder.debug_check_bounds::<GenericActivity>(offset);
394 let max_ordinal: u64 = self.max_ordinal_present();
396 encoder.write_num(max_ordinal, offset);
397 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
398 if max_ordinal == 0 {
400 return Ok(());
401 }
402 depth.increment()?;
403 let envelope_size = 8;
404 let bytes_len = max_ordinal as usize * envelope_size;
405 #[allow(unused_variables)]
406 let offset = encoder.out_of_line_offset(bytes_len);
407 let mut _prev_end_offset: usize = 0;
408 if 1 > max_ordinal {
409 return Ok(());
410 }
411
412 let cur_offset: usize = (1 - 1) * envelope_size;
415
416 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
418
419 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
424 self.label.as_ref().map(
425 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
426 ),
427 encoder,
428 offset + cur_offset,
429 depth,
430 )?;
431
432 _prev_end_offset = cur_offset + envelope_size;
433
434 Ok(())
435 }
436 }
437
438 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GenericActivity {
439 #[inline(always)]
440 fn new_empty() -> Self {
441 Self::default()
442 }
443
444 unsafe fn decode(
445 &mut self,
446 decoder: &mut fidl::encoding::Decoder<'_, D>,
447 offset: usize,
448 mut depth: fidl::encoding::Depth,
449 ) -> fidl::Result<()> {
450 decoder.debug_check_bounds::<Self>(offset);
451 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
452 None => return Err(fidl::Error::NotNullable),
453 Some(len) => len,
454 };
455 if len == 0 {
457 return Ok(());
458 };
459 depth.increment()?;
460 let envelope_size = 8;
461 let bytes_len = len * envelope_size;
462 let offset = decoder.out_of_line_offset(bytes_len)?;
463 let mut _next_ordinal_to_read = 0;
465 let mut next_offset = offset;
466 let end_offset = offset + bytes_len;
467 _next_ordinal_to_read += 1;
468 if next_offset >= end_offset {
469 return Ok(());
470 }
471
472 while _next_ordinal_to_read < 1 {
474 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
475 _next_ordinal_to_read += 1;
476 next_offset += envelope_size;
477 }
478
479 let next_out_of_line = decoder.next_out_of_line();
480 let handles_before = decoder.remaining_handles();
481 if let Some((inlined, num_bytes, num_handles)) =
482 fidl::encoding::decode_envelope_header(decoder, next_offset)?
483 {
484 let member_inline_size =
485 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
486 decoder.context,
487 );
488 if inlined != (member_inline_size <= 4) {
489 return Err(fidl::Error::InvalidInlineBitInEnvelope);
490 }
491 let inner_offset;
492 let mut inner_depth = depth.clone();
493 if inlined {
494 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
495 inner_offset = next_offset;
496 } else {
497 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
498 inner_depth.increment()?;
499 }
500 let val_ref = self
501 .label
502 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
503 fidl::decode!(
504 fidl::encoding::UnboundedString,
505 D,
506 val_ref,
507 decoder,
508 inner_offset,
509 inner_depth
510 )?;
511 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
512 {
513 return Err(fidl::Error::InvalidNumBytesInEnvelope);
514 }
515 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
516 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
517 }
518 }
519
520 next_offset += envelope_size;
521
522 while next_offset < end_offset {
524 _next_ordinal_to_read += 1;
525 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
526 next_offset += envelope_size;
527 }
528
529 Ok(())
530 }
531 }
532
533 impl fidl::encoding::ValueTypeMarker for DiscreteActivity {
534 type Borrowed<'a> = &'a Self;
535 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
536 value
537 }
538 }
539
540 unsafe impl fidl::encoding::TypeMarker for DiscreteActivity {
541 type Owned = Self;
542
543 #[inline(always)]
544 fn inline_align(_context: fidl::encoding::Context) -> usize {
545 8
546 }
547
548 #[inline(always)]
549 fn inline_size(_context: fidl::encoding::Context) -> usize {
550 16
551 }
552 }
553
554 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DiscreteActivity, D>
555 for &DiscreteActivity
556 {
557 #[inline]
558 unsafe fn encode(
559 self,
560 encoder: &mut fidl::encoding::Encoder<'_, D>,
561 offset: usize,
562 _depth: fidl::encoding::Depth,
563 ) -> fidl::Result<()> {
564 encoder.debug_check_bounds::<DiscreteActivity>(offset);
565 encoder.write_num::<u64>(self.ordinal(), offset);
566 match self {
567 DiscreteActivity::Generic(ref val) => {
568 fidl::encoding::encode_in_envelope::<GenericActivity, D>(
569 <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
570 encoder,
571 offset + 8,
572 _depth,
573 )
574 }
575 DiscreteActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
576 }
577 }
578 }
579
580 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DiscreteActivity {
581 #[inline(always)]
582 fn new_empty() -> Self {
583 Self::__SourceBreaking { unknown_ordinal: 0 }
584 }
585
586 #[inline]
587 unsafe fn decode(
588 &mut self,
589 decoder: &mut fidl::encoding::Decoder<'_, D>,
590 offset: usize,
591 mut depth: fidl::encoding::Depth,
592 ) -> fidl::Result<()> {
593 decoder.debug_check_bounds::<Self>(offset);
594 #[allow(unused_variables)]
595 let next_out_of_line = decoder.next_out_of_line();
596 let handles_before = decoder.remaining_handles();
597 let (ordinal, inlined, num_bytes, num_handles) =
598 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
599
600 let member_inline_size = match ordinal {
601 1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
602 0 => return Err(fidl::Error::UnknownUnionTag),
603 _ => num_bytes as usize,
604 };
605
606 if inlined != (member_inline_size <= 4) {
607 return Err(fidl::Error::InvalidInlineBitInEnvelope);
608 }
609 let _inner_offset;
610 if inlined {
611 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
612 _inner_offset = offset + 8;
613 } else {
614 depth.increment()?;
615 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
616 }
617 match ordinal {
618 1 => {
619 #[allow(irrefutable_let_patterns)]
620 if let DiscreteActivity::Generic(_) = self {
621 } else {
623 *self = DiscreteActivity::Generic(fidl::new_empty!(GenericActivity, D));
625 }
626 #[allow(irrefutable_let_patterns)]
627 if let DiscreteActivity::Generic(ref mut val) = self {
628 fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
629 } else {
630 unreachable!()
631 }
632 }
633 #[allow(deprecated)]
634 ordinal => {
635 for _ in 0..num_handles {
636 decoder.drop_next_handle()?;
637 }
638 *self = DiscreteActivity::__SourceBreaking { unknown_ordinal: ordinal };
639 }
640 }
641 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
642 return Err(fidl::Error::InvalidNumBytesInEnvelope);
643 }
644 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
645 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
646 }
647 Ok(())
648 }
649 }
650
651 impl fidl::encoding::ValueTypeMarker for OngoingActivity {
652 type Borrowed<'a> = &'a Self;
653 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
654 value
655 }
656 }
657
658 unsafe impl fidl::encoding::TypeMarker for OngoingActivity {
659 type Owned = Self;
660
661 #[inline(always)]
662 fn inline_align(_context: fidl::encoding::Context) -> usize {
663 8
664 }
665
666 #[inline(always)]
667 fn inline_size(_context: fidl::encoding::Context) -> usize {
668 16
669 }
670 }
671
672 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OngoingActivity, D>
673 for &OngoingActivity
674 {
675 #[inline]
676 unsafe fn encode(
677 self,
678 encoder: &mut fidl::encoding::Encoder<'_, D>,
679 offset: usize,
680 _depth: fidl::encoding::Depth,
681 ) -> fidl::Result<()> {
682 encoder.debug_check_bounds::<OngoingActivity>(offset);
683 encoder.write_num::<u64>(self.ordinal(), offset);
684 match self {
685 OngoingActivity::Generic(ref val) => {
686 fidl::encoding::encode_in_envelope::<GenericActivity, D>(
687 <GenericActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
688 encoder,
689 offset + 8,
690 _depth,
691 )
692 }
693 OngoingActivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
694 }
695 }
696 }
697
698 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OngoingActivity {
699 #[inline(always)]
700 fn new_empty() -> Self {
701 Self::__SourceBreaking { unknown_ordinal: 0 }
702 }
703
704 #[inline]
705 unsafe fn decode(
706 &mut self,
707 decoder: &mut fidl::encoding::Decoder<'_, D>,
708 offset: usize,
709 mut depth: fidl::encoding::Depth,
710 ) -> fidl::Result<()> {
711 decoder.debug_check_bounds::<Self>(offset);
712 #[allow(unused_variables)]
713 let next_out_of_line = decoder.next_out_of_line();
714 let handles_before = decoder.remaining_handles();
715 let (ordinal, inlined, num_bytes, num_handles) =
716 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
717
718 let member_inline_size = match ordinal {
719 1 => <GenericActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
720 0 => return Err(fidl::Error::UnknownUnionTag),
721 _ => num_bytes as usize,
722 };
723
724 if inlined != (member_inline_size <= 4) {
725 return Err(fidl::Error::InvalidInlineBitInEnvelope);
726 }
727 let _inner_offset;
728 if inlined {
729 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
730 _inner_offset = offset + 8;
731 } else {
732 depth.increment()?;
733 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
734 }
735 match ordinal {
736 1 => {
737 #[allow(irrefutable_let_patterns)]
738 if let OngoingActivity::Generic(_) = self {
739 } else {
741 *self = OngoingActivity::Generic(fidl::new_empty!(GenericActivity, D));
743 }
744 #[allow(irrefutable_let_patterns)]
745 if let OngoingActivity::Generic(ref mut val) = self {
746 fidl::decode!(GenericActivity, D, val, decoder, _inner_offset, depth)?;
747 } else {
748 unreachable!()
749 }
750 }
751 #[allow(deprecated)]
752 ordinal => {
753 for _ in 0..num_handles {
754 decoder.drop_next_handle()?;
755 }
756 *self = OngoingActivity::__SourceBreaking { unknown_ordinal: ordinal };
757 }
758 }
759 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
760 return Err(fidl::Error::InvalidNumBytesInEnvelope);
761 }
762 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
763 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
764 }
765 Ok(())
766 }
767 }
768}