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