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 PolicyId = u32;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum Error {
17 Failed = 1,
19 UnknownPolicy = 2,
24 InvalidPolicy = 3,
29}
30
31impl Error {
32 #[inline]
33 pub fn from_primitive(prim: u32) -> Option<Self> {
34 match prim {
35 1 => Some(Self::Failed),
36 2 => Some(Self::UnknownPolicy),
37 3 => Some(Self::InvalidPolicy),
38 _ => None,
39 }
40 }
41
42 #[inline]
43 pub const fn into_primitive(self) -> u32 {
44 self as u32
45 }
46
47 #[deprecated = "Strict enums should not use `is_unknown`"]
48 #[inline]
49 pub fn is_unknown(&self) -> bool {
50 false
51 }
52}
53
54#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
60#[repr(u8)]
61pub enum Transform {
62 Max = 1,
82 Min = 2,
94}
95
96impl Transform {
97 #[inline]
98 pub fn from_primitive(prim: u8) -> Option<Self> {
99 match prim {
100 1 => Some(Self::Max),
101 2 => Some(Self::Min),
102 _ => None,
103 }
104 }
105
106 #[inline]
107 pub const fn into_primitive(self) -> u8 {
108 self as u8
109 }
110
111 #[deprecated = "Strict enums should not use `is_unknown`"]
112 #[inline]
113 pub fn is_unknown(&self) -> bool {
114 false
115 }
116}
117
118#[derive(Clone, Debug, Default, PartialEq)]
120pub struct Policy {
121 pub policy_id: Option<u32>,
125 pub parameters: Option<PolicyParameters>,
127 #[doc(hidden)]
128 pub __source_breaking: fidl::marker::SourceBreaking,
129}
130
131impl fidl::Persistable for Policy {}
132
133#[derive(Clone, Debug, Default, PartialEq)]
136pub struct Property {
137 pub target: Option<Target>,
141 pub available_transforms: Option<Vec<Transform>>,
143 pub active_policies: Option<Vec<Policy>>,
145 #[doc(hidden)]
146 pub __source_breaking: fidl::marker::SourceBreaking,
147}
148
149impl fidl::Persistable for Property {}
150
151#[derive(Clone, Debug, Default, PartialEq)]
152pub struct Volume {
153 pub volume: Option<f32>,
155 #[doc(hidden)]
156 pub __source_breaking: fidl::marker::SourceBreaking,
157}
158
159impl fidl::Persistable for Volume {}
160
161#[derive(Clone, Debug, PartialEq)]
166pub enum PolicyParameters {
167 Min(Volume),
170 Max(Volume),
173}
174
175impl PolicyParameters {
176 #[inline]
177 pub fn ordinal(&self) -> u64 {
178 match *self {
179 Self::Min(_) => 1,
180 Self::Max(_) => 2,
181 }
182 }
183
184 #[deprecated = "Strict unions should not use `is_unknown`"]
185 #[inline]
186 pub fn is_unknown(&self) -> bool {
187 false
188 }
189}
190
191impl fidl::Persistable for PolicyParameters {}
192
193#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
195pub enum Target {
196 Stream(fidl_fuchsia_media::AudioRenderUsage),
198}
199
200impl Target {
201 #[inline]
202 pub fn ordinal(&self) -> u64 {
203 match *self {
204 Self::Stream(_) => 1,
205 }
206 }
207
208 #[deprecated = "Strict unions should not use `is_unknown`"]
209 #[inline]
210 pub fn is_unknown(&self) -> bool {
211 false
212 }
213}
214
215impl fidl::Persistable for Target {}
216
217mod internal {
218 use super::*;
219 unsafe impl fidl::encoding::TypeMarker for Error {
220 type Owned = Self;
221
222 #[inline(always)]
223 fn inline_align(_context: fidl::encoding::Context) -> usize {
224 std::mem::align_of::<u32>()
225 }
226
227 #[inline(always)]
228 fn inline_size(_context: fidl::encoding::Context) -> usize {
229 std::mem::size_of::<u32>()
230 }
231
232 #[inline(always)]
233 fn encode_is_copy() -> bool {
234 true
235 }
236
237 #[inline(always)]
238 fn decode_is_copy() -> bool {
239 false
240 }
241 }
242
243 impl fidl::encoding::ValueTypeMarker for Error {
244 type Borrowed<'a> = Self;
245 #[inline(always)]
246 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
247 *value
248 }
249 }
250
251 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
252 #[inline]
253 unsafe fn encode(
254 self,
255 encoder: &mut fidl::encoding::Encoder<'_, D>,
256 offset: usize,
257 _depth: fidl::encoding::Depth,
258 ) -> fidl::Result<()> {
259 encoder.debug_check_bounds::<Self>(offset);
260 encoder.write_num(self.into_primitive(), offset);
261 Ok(())
262 }
263 }
264
265 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
266 #[inline(always)]
267 fn new_empty() -> Self {
268 Self::Failed
269 }
270
271 #[inline]
272 unsafe fn decode(
273 &mut self,
274 decoder: &mut fidl::encoding::Decoder<'_, D>,
275 offset: usize,
276 _depth: fidl::encoding::Depth,
277 ) -> fidl::Result<()> {
278 decoder.debug_check_bounds::<Self>(offset);
279 let prim = decoder.read_num::<u32>(offset);
280
281 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
282 Ok(())
283 }
284 }
285 unsafe impl fidl::encoding::TypeMarker for Transform {
286 type Owned = Self;
287
288 #[inline(always)]
289 fn inline_align(_context: fidl::encoding::Context) -> usize {
290 std::mem::align_of::<u8>()
291 }
292
293 #[inline(always)]
294 fn inline_size(_context: fidl::encoding::Context) -> usize {
295 std::mem::size_of::<u8>()
296 }
297
298 #[inline(always)]
299 fn encode_is_copy() -> bool {
300 true
301 }
302
303 #[inline(always)]
304 fn decode_is_copy() -> bool {
305 false
306 }
307 }
308
309 impl fidl::encoding::ValueTypeMarker for Transform {
310 type Borrowed<'a> = Self;
311 #[inline(always)]
312 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
313 *value
314 }
315 }
316
317 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Transform {
318 #[inline]
319 unsafe fn encode(
320 self,
321 encoder: &mut fidl::encoding::Encoder<'_, D>,
322 offset: usize,
323 _depth: fidl::encoding::Depth,
324 ) -> fidl::Result<()> {
325 encoder.debug_check_bounds::<Self>(offset);
326 encoder.write_num(self.into_primitive(), offset);
327 Ok(())
328 }
329 }
330
331 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Transform {
332 #[inline(always)]
333 fn new_empty() -> Self {
334 Self::Max
335 }
336
337 #[inline]
338 unsafe fn decode(
339 &mut self,
340 decoder: &mut fidl::encoding::Decoder<'_, D>,
341 offset: usize,
342 _depth: fidl::encoding::Depth,
343 ) -> fidl::Result<()> {
344 decoder.debug_check_bounds::<Self>(offset);
345 let prim = decoder.read_num::<u8>(offset);
346
347 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
348 Ok(())
349 }
350 }
351
352 impl Policy {
353 #[inline(always)]
354 fn max_ordinal_present(&self) -> u64 {
355 if let Some(_) = self.parameters {
356 return 2;
357 }
358 if let Some(_) = self.policy_id {
359 return 1;
360 }
361 0
362 }
363 }
364
365 impl fidl::encoding::ValueTypeMarker for Policy {
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 Policy {
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<Policy, D> for &Policy {
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::<Policy>(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::<u32, D>(
424 self.policy_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
425 encoder,
426 offset + cur_offset,
427 depth,
428 )?;
429
430 _prev_end_offset = cur_offset + envelope_size;
431 if 2 > max_ordinal {
432 return Ok(());
433 }
434
435 let cur_offset: usize = (2 - 1) * envelope_size;
438
439 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
441
442 fidl::encoding::encode_in_envelope_optional::<PolicyParameters, D>(
447 self.parameters
448 .as_ref()
449 .map(<PolicyParameters as fidl::encoding::ValueTypeMarker>::borrow),
450 encoder,
451 offset + cur_offset,
452 depth,
453 )?;
454
455 _prev_end_offset = cur_offset + envelope_size;
456
457 Ok(())
458 }
459 }
460
461 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Policy {
462 #[inline(always)]
463 fn new_empty() -> Self {
464 Self::default()
465 }
466
467 unsafe fn decode(
468 &mut self,
469 decoder: &mut fidl::encoding::Decoder<'_, D>,
470 offset: usize,
471 mut depth: fidl::encoding::Depth,
472 ) -> fidl::Result<()> {
473 decoder.debug_check_bounds::<Self>(offset);
474 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
475 None => return Err(fidl::Error::NotNullable),
476 Some(len) => len,
477 };
478 if len == 0 {
480 return Ok(());
481 };
482 depth.increment()?;
483 let envelope_size = 8;
484 let bytes_len = len * envelope_size;
485 let offset = decoder.out_of_line_offset(bytes_len)?;
486 let mut _next_ordinal_to_read = 0;
488 let mut next_offset = offset;
489 let end_offset = offset + bytes_len;
490 _next_ordinal_to_read += 1;
491 if next_offset >= end_offset {
492 return Ok(());
493 }
494
495 while _next_ordinal_to_read < 1 {
497 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
498 _next_ordinal_to_read += 1;
499 next_offset += envelope_size;
500 }
501
502 let next_out_of_line = decoder.next_out_of_line();
503 let handles_before = decoder.remaining_handles();
504 if let Some((inlined, num_bytes, num_handles)) =
505 fidl::encoding::decode_envelope_header(decoder, next_offset)?
506 {
507 let member_inline_size =
508 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
509 if inlined != (member_inline_size <= 4) {
510 return Err(fidl::Error::InvalidInlineBitInEnvelope);
511 }
512 let inner_offset;
513 let mut inner_depth = depth.clone();
514 if inlined {
515 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
516 inner_offset = next_offset;
517 } else {
518 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
519 inner_depth.increment()?;
520 }
521 let val_ref = self.policy_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
522 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
523 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
524 {
525 return Err(fidl::Error::InvalidNumBytesInEnvelope);
526 }
527 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
528 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
529 }
530 }
531
532 next_offset += envelope_size;
533 _next_ordinal_to_read += 1;
534 if next_offset >= end_offset {
535 return Ok(());
536 }
537
538 while _next_ordinal_to_read < 2 {
540 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
541 _next_ordinal_to_read += 1;
542 next_offset += envelope_size;
543 }
544
545 let next_out_of_line = decoder.next_out_of_line();
546 let handles_before = decoder.remaining_handles();
547 if let Some((inlined, num_bytes, num_handles)) =
548 fidl::encoding::decode_envelope_header(decoder, next_offset)?
549 {
550 let member_inline_size =
551 <PolicyParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
552 if inlined != (member_inline_size <= 4) {
553 return Err(fidl::Error::InvalidInlineBitInEnvelope);
554 }
555 let inner_offset;
556 let mut inner_depth = depth.clone();
557 if inlined {
558 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
559 inner_offset = next_offset;
560 } else {
561 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
562 inner_depth.increment()?;
563 }
564 let val_ref =
565 self.parameters.get_or_insert_with(|| fidl::new_empty!(PolicyParameters, D));
566 fidl::decode!(PolicyParameters, D, val_ref, decoder, inner_offset, inner_depth)?;
567 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
568 {
569 return Err(fidl::Error::InvalidNumBytesInEnvelope);
570 }
571 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
572 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
573 }
574 }
575
576 next_offset += envelope_size;
577
578 while next_offset < end_offset {
580 _next_ordinal_to_read += 1;
581 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
582 next_offset += envelope_size;
583 }
584
585 Ok(())
586 }
587 }
588
589 impl Property {
590 #[inline(always)]
591 fn max_ordinal_present(&self) -> u64 {
592 if let Some(_) = self.active_policies {
593 return 3;
594 }
595 if let Some(_) = self.available_transforms {
596 return 2;
597 }
598 if let Some(_) = self.target {
599 return 1;
600 }
601 0
602 }
603 }
604
605 impl fidl::encoding::ValueTypeMarker for Property {
606 type Borrowed<'a> = &'a Self;
607 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
608 value
609 }
610 }
611
612 unsafe impl fidl::encoding::TypeMarker for Property {
613 type Owned = Self;
614
615 #[inline(always)]
616 fn inline_align(_context: fidl::encoding::Context) -> usize {
617 8
618 }
619
620 #[inline(always)]
621 fn inline_size(_context: fidl::encoding::Context) -> usize {
622 16
623 }
624 }
625
626 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Property, D> for &Property {
627 unsafe fn encode(
628 self,
629 encoder: &mut fidl::encoding::Encoder<'_, D>,
630 offset: usize,
631 mut depth: fidl::encoding::Depth,
632 ) -> fidl::Result<()> {
633 encoder.debug_check_bounds::<Property>(offset);
634 let max_ordinal: u64 = self.max_ordinal_present();
636 encoder.write_num(max_ordinal, offset);
637 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
638 if max_ordinal == 0 {
640 return Ok(());
641 }
642 depth.increment()?;
643 let envelope_size = 8;
644 let bytes_len = max_ordinal as usize * envelope_size;
645 #[allow(unused_variables)]
646 let offset = encoder.out_of_line_offset(bytes_len);
647 let mut _prev_end_offset: usize = 0;
648 if 1 > max_ordinal {
649 return Ok(());
650 }
651
652 let cur_offset: usize = (1 - 1) * envelope_size;
655
656 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
658
659 fidl::encoding::encode_in_envelope_optional::<Target, D>(
664 self.target.as_ref().map(<Target as fidl::encoding::ValueTypeMarker>::borrow),
665 encoder,
666 offset + cur_offset,
667 depth,
668 )?;
669
670 _prev_end_offset = cur_offset + envelope_size;
671 if 2 > max_ordinal {
672 return Ok(());
673 }
674
675 let cur_offset: usize = (2 - 1) * envelope_size;
678
679 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
681
682 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Transform>, D>(
687 self.available_transforms.as_ref().map(<fidl::encoding::UnboundedVector<Transform> as fidl::encoding::ValueTypeMarker>::borrow),
688 encoder, offset + cur_offset, depth
689 )?;
690
691 _prev_end_offset = cur_offset + envelope_size;
692 if 3 > max_ordinal {
693 return Ok(());
694 }
695
696 let cur_offset: usize = (3 - 1) * envelope_size;
699
700 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
702
703 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Policy>, D>(
708 self.active_policies.as_ref().map(<fidl::encoding::UnboundedVector<Policy> as fidl::encoding::ValueTypeMarker>::borrow),
709 encoder, offset + cur_offset, depth
710 )?;
711
712 _prev_end_offset = cur_offset + envelope_size;
713
714 Ok(())
715 }
716 }
717
718 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Property {
719 #[inline(always)]
720 fn new_empty() -> Self {
721 Self::default()
722 }
723
724 unsafe fn decode(
725 &mut self,
726 decoder: &mut fidl::encoding::Decoder<'_, D>,
727 offset: usize,
728 mut depth: fidl::encoding::Depth,
729 ) -> fidl::Result<()> {
730 decoder.debug_check_bounds::<Self>(offset);
731 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
732 None => return Err(fidl::Error::NotNullable),
733 Some(len) => len,
734 };
735 if len == 0 {
737 return Ok(());
738 };
739 depth.increment()?;
740 let envelope_size = 8;
741 let bytes_len = len * envelope_size;
742 let offset = decoder.out_of_line_offset(bytes_len)?;
743 let mut _next_ordinal_to_read = 0;
745 let mut next_offset = offset;
746 let end_offset = offset + bytes_len;
747 _next_ordinal_to_read += 1;
748 if next_offset >= end_offset {
749 return Ok(());
750 }
751
752 while _next_ordinal_to_read < 1 {
754 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
755 _next_ordinal_to_read += 1;
756 next_offset += envelope_size;
757 }
758
759 let next_out_of_line = decoder.next_out_of_line();
760 let handles_before = decoder.remaining_handles();
761 if let Some((inlined, num_bytes, num_handles)) =
762 fidl::encoding::decode_envelope_header(decoder, next_offset)?
763 {
764 let member_inline_size =
765 <Target as fidl::encoding::TypeMarker>::inline_size(decoder.context);
766 if inlined != (member_inline_size <= 4) {
767 return Err(fidl::Error::InvalidInlineBitInEnvelope);
768 }
769 let inner_offset;
770 let mut inner_depth = depth.clone();
771 if inlined {
772 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
773 inner_offset = next_offset;
774 } else {
775 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
776 inner_depth.increment()?;
777 }
778 let val_ref = self.target.get_or_insert_with(|| fidl::new_empty!(Target, D));
779 fidl::decode!(Target, D, val_ref, decoder, inner_offset, inner_depth)?;
780 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
781 {
782 return Err(fidl::Error::InvalidNumBytesInEnvelope);
783 }
784 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
785 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
786 }
787 }
788
789 next_offset += envelope_size;
790 _next_ordinal_to_read += 1;
791 if next_offset >= end_offset {
792 return Ok(());
793 }
794
795 while _next_ordinal_to_read < 2 {
797 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
798 _next_ordinal_to_read += 1;
799 next_offset += envelope_size;
800 }
801
802 let next_out_of_line = decoder.next_out_of_line();
803 let handles_before = decoder.remaining_handles();
804 if let Some((inlined, num_bytes, num_handles)) =
805 fidl::encoding::decode_envelope_header(decoder, next_offset)?
806 {
807 let member_inline_size = <fidl::encoding::UnboundedVector<Transform> 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.available_transforms.get_or_insert_with(|| {
821 fidl::new_empty!(fidl::encoding::UnboundedVector<Transform>, D)
822 });
823 fidl::decode!(
824 fidl::encoding::UnboundedVector<Transform>,
825 D,
826 val_ref,
827 decoder,
828 inner_offset,
829 inner_depth
830 )?;
831 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
832 {
833 return Err(fidl::Error::InvalidNumBytesInEnvelope);
834 }
835 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
836 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
837 }
838 }
839
840 next_offset += envelope_size;
841 _next_ordinal_to_read += 1;
842 if next_offset >= end_offset {
843 return Ok(());
844 }
845
846 while _next_ordinal_to_read < 3 {
848 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
849 _next_ordinal_to_read += 1;
850 next_offset += envelope_size;
851 }
852
853 let next_out_of_line = decoder.next_out_of_line();
854 let handles_before = decoder.remaining_handles();
855 if let Some((inlined, num_bytes, num_handles)) =
856 fidl::encoding::decode_envelope_header(decoder, next_offset)?
857 {
858 let member_inline_size = <fidl::encoding::UnboundedVector<Policy> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
859 if inlined != (member_inline_size <= 4) {
860 return Err(fidl::Error::InvalidInlineBitInEnvelope);
861 }
862 let inner_offset;
863 let mut inner_depth = depth.clone();
864 if inlined {
865 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
866 inner_offset = next_offset;
867 } else {
868 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
869 inner_depth.increment()?;
870 }
871 let val_ref = self.active_policies.get_or_insert_with(|| {
872 fidl::new_empty!(fidl::encoding::UnboundedVector<Policy>, D)
873 });
874 fidl::decode!(
875 fidl::encoding::UnboundedVector<Policy>,
876 D,
877 val_ref,
878 decoder,
879 inner_offset,
880 inner_depth
881 )?;
882 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
883 {
884 return Err(fidl::Error::InvalidNumBytesInEnvelope);
885 }
886 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
887 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
888 }
889 }
890
891 next_offset += envelope_size;
892
893 while next_offset < end_offset {
895 _next_ordinal_to_read += 1;
896 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
897 next_offset += envelope_size;
898 }
899
900 Ok(())
901 }
902 }
903
904 impl Volume {
905 #[inline(always)]
906 fn max_ordinal_present(&self) -> u64 {
907 if let Some(_) = self.volume {
908 return 1;
909 }
910 0
911 }
912 }
913
914 impl fidl::encoding::ValueTypeMarker for Volume {
915 type Borrowed<'a> = &'a Self;
916 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
917 value
918 }
919 }
920
921 unsafe impl fidl::encoding::TypeMarker for Volume {
922 type Owned = Self;
923
924 #[inline(always)]
925 fn inline_align(_context: fidl::encoding::Context) -> usize {
926 8
927 }
928
929 #[inline(always)]
930 fn inline_size(_context: fidl::encoding::Context) -> usize {
931 16
932 }
933 }
934
935 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Volume, D> for &Volume {
936 unsafe fn encode(
937 self,
938 encoder: &mut fidl::encoding::Encoder<'_, D>,
939 offset: usize,
940 mut depth: fidl::encoding::Depth,
941 ) -> fidl::Result<()> {
942 encoder.debug_check_bounds::<Volume>(offset);
943 let max_ordinal: u64 = self.max_ordinal_present();
945 encoder.write_num(max_ordinal, offset);
946 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
947 if max_ordinal == 0 {
949 return Ok(());
950 }
951 depth.increment()?;
952 let envelope_size = 8;
953 let bytes_len = max_ordinal as usize * envelope_size;
954 #[allow(unused_variables)]
955 let offset = encoder.out_of_line_offset(bytes_len);
956 let mut _prev_end_offset: usize = 0;
957 if 1 > max_ordinal {
958 return Ok(());
959 }
960
961 let cur_offset: usize = (1 - 1) * envelope_size;
964
965 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
967
968 fidl::encoding::encode_in_envelope_optional::<f32, D>(
973 self.volume.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
974 encoder,
975 offset + cur_offset,
976 depth,
977 )?;
978
979 _prev_end_offset = cur_offset + envelope_size;
980
981 Ok(())
982 }
983 }
984
985 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Volume {
986 #[inline(always)]
987 fn new_empty() -> Self {
988 Self::default()
989 }
990
991 unsafe fn decode(
992 &mut self,
993 decoder: &mut fidl::encoding::Decoder<'_, D>,
994 offset: usize,
995 mut depth: fidl::encoding::Depth,
996 ) -> fidl::Result<()> {
997 decoder.debug_check_bounds::<Self>(offset);
998 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
999 None => return Err(fidl::Error::NotNullable),
1000 Some(len) => len,
1001 };
1002 if len == 0 {
1004 return Ok(());
1005 };
1006 depth.increment()?;
1007 let envelope_size = 8;
1008 let bytes_len = len * envelope_size;
1009 let offset = decoder.out_of_line_offset(bytes_len)?;
1010 let mut _next_ordinal_to_read = 0;
1012 let mut next_offset = offset;
1013 let end_offset = offset + bytes_len;
1014 _next_ordinal_to_read += 1;
1015 if next_offset >= end_offset {
1016 return Ok(());
1017 }
1018
1019 while _next_ordinal_to_read < 1 {
1021 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1022 _next_ordinal_to_read += 1;
1023 next_offset += envelope_size;
1024 }
1025
1026 let next_out_of_line = decoder.next_out_of_line();
1027 let handles_before = decoder.remaining_handles();
1028 if let Some((inlined, num_bytes, num_handles)) =
1029 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1030 {
1031 let member_inline_size =
1032 <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1033 if inlined != (member_inline_size <= 4) {
1034 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1035 }
1036 let inner_offset;
1037 let mut inner_depth = depth.clone();
1038 if inlined {
1039 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1040 inner_offset = next_offset;
1041 } else {
1042 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1043 inner_depth.increment()?;
1044 }
1045 let val_ref = self.volume.get_or_insert_with(|| fidl::new_empty!(f32, D));
1046 fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1047 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1048 {
1049 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1050 }
1051 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1052 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1053 }
1054 }
1055
1056 next_offset += envelope_size;
1057
1058 while next_offset < end_offset {
1060 _next_ordinal_to_read += 1;
1061 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1062 next_offset += envelope_size;
1063 }
1064
1065 Ok(())
1066 }
1067 }
1068
1069 impl fidl::encoding::ValueTypeMarker for PolicyParameters {
1070 type Borrowed<'a> = &'a Self;
1071 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1072 value
1073 }
1074 }
1075
1076 unsafe impl fidl::encoding::TypeMarker for PolicyParameters {
1077 type Owned = Self;
1078
1079 #[inline(always)]
1080 fn inline_align(_context: fidl::encoding::Context) -> usize {
1081 8
1082 }
1083
1084 #[inline(always)]
1085 fn inline_size(_context: fidl::encoding::Context) -> usize {
1086 16
1087 }
1088 }
1089
1090 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PolicyParameters, D>
1091 for &PolicyParameters
1092 {
1093 #[inline]
1094 unsafe fn encode(
1095 self,
1096 encoder: &mut fidl::encoding::Encoder<'_, D>,
1097 offset: usize,
1098 _depth: fidl::encoding::Depth,
1099 ) -> fidl::Result<()> {
1100 encoder.debug_check_bounds::<PolicyParameters>(offset);
1101 encoder.write_num::<u64>(self.ordinal(), offset);
1102 match self {
1103 PolicyParameters::Min(ref val) => fidl::encoding::encode_in_envelope::<Volume, D>(
1104 <Volume as fidl::encoding::ValueTypeMarker>::borrow(val),
1105 encoder,
1106 offset + 8,
1107 _depth,
1108 ),
1109 PolicyParameters::Max(ref val) => fidl::encoding::encode_in_envelope::<Volume, D>(
1110 <Volume as fidl::encoding::ValueTypeMarker>::borrow(val),
1111 encoder,
1112 offset + 8,
1113 _depth,
1114 ),
1115 }
1116 }
1117 }
1118
1119 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PolicyParameters {
1120 #[inline(always)]
1121 fn new_empty() -> Self {
1122 Self::Min(fidl::new_empty!(Volume, D))
1123 }
1124
1125 #[inline]
1126 unsafe fn decode(
1127 &mut self,
1128 decoder: &mut fidl::encoding::Decoder<'_, D>,
1129 offset: usize,
1130 mut depth: fidl::encoding::Depth,
1131 ) -> fidl::Result<()> {
1132 decoder.debug_check_bounds::<Self>(offset);
1133 #[allow(unused_variables)]
1134 let next_out_of_line = decoder.next_out_of_line();
1135 let handles_before = decoder.remaining_handles();
1136 let (ordinal, inlined, num_bytes, num_handles) =
1137 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1138
1139 let member_inline_size = match ordinal {
1140 1 => <Volume as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1141 2 => <Volume as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1142 _ => return Err(fidl::Error::UnknownUnionTag),
1143 };
1144
1145 if inlined != (member_inline_size <= 4) {
1146 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1147 }
1148 let _inner_offset;
1149 if inlined {
1150 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1151 _inner_offset = offset + 8;
1152 } else {
1153 depth.increment()?;
1154 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1155 }
1156 match ordinal {
1157 1 => {
1158 #[allow(irrefutable_let_patterns)]
1159 if let PolicyParameters::Min(_) = self {
1160 } else {
1162 *self = PolicyParameters::Min(fidl::new_empty!(Volume, D));
1164 }
1165 #[allow(irrefutable_let_patterns)]
1166 if let PolicyParameters::Min(ref mut val) = self {
1167 fidl::decode!(Volume, D, val, decoder, _inner_offset, depth)?;
1168 } else {
1169 unreachable!()
1170 }
1171 }
1172 2 => {
1173 #[allow(irrefutable_let_patterns)]
1174 if let PolicyParameters::Max(_) = self {
1175 } else {
1177 *self = PolicyParameters::Max(fidl::new_empty!(Volume, D));
1179 }
1180 #[allow(irrefutable_let_patterns)]
1181 if let PolicyParameters::Max(ref mut val) = self {
1182 fidl::decode!(Volume, D, val, decoder, _inner_offset, depth)?;
1183 } else {
1184 unreachable!()
1185 }
1186 }
1187 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1188 }
1189 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1190 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1191 }
1192 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1193 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1194 }
1195 Ok(())
1196 }
1197 }
1198
1199 impl fidl::encoding::ValueTypeMarker for Target {
1200 type Borrowed<'a> = &'a Self;
1201 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1202 value
1203 }
1204 }
1205
1206 unsafe impl fidl::encoding::TypeMarker for Target {
1207 type Owned = Self;
1208
1209 #[inline(always)]
1210 fn inline_align(_context: fidl::encoding::Context) -> usize {
1211 8
1212 }
1213
1214 #[inline(always)]
1215 fn inline_size(_context: fidl::encoding::Context) -> usize {
1216 16
1217 }
1218 }
1219
1220 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Target, D> for &Target {
1221 #[inline]
1222 unsafe fn encode(
1223 self,
1224 encoder: &mut fidl::encoding::Encoder<'_, D>,
1225 offset: usize,
1226 _depth: fidl::encoding::Depth,
1227 ) -> fidl::Result<()> {
1228 encoder.debug_check_bounds::<Target>(offset);
1229 encoder.write_num::<u64>(self.ordinal(), offset);
1230 match self {
1231 Target::Stream(ref val) => {
1232 fidl::encoding::encode_in_envelope::<fidl_fuchsia_media::AudioRenderUsage, D>(
1233 <fidl_fuchsia_media::AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(val),
1234 encoder, offset + 8, _depth
1235 )
1236 }
1237 }
1238 }
1239 }
1240
1241 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Target {
1242 #[inline(always)]
1243 fn new_empty() -> Self {
1244 Self::Stream(fidl::new_empty!(fidl_fuchsia_media::AudioRenderUsage, D))
1245 }
1246
1247 #[inline]
1248 unsafe fn decode(
1249 &mut self,
1250 decoder: &mut fidl::encoding::Decoder<'_, D>,
1251 offset: usize,
1252 mut depth: fidl::encoding::Depth,
1253 ) -> fidl::Result<()> {
1254 decoder.debug_check_bounds::<Self>(offset);
1255 #[allow(unused_variables)]
1256 let next_out_of_line = decoder.next_out_of_line();
1257 let handles_before = decoder.remaining_handles();
1258 let (ordinal, inlined, num_bytes, num_handles) =
1259 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1260
1261 let member_inline_size = match ordinal {
1262 1 => <fidl_fuchsia_media::AudioRenderUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1263 _ => return Err(fidl::Error::UnknownUnionTag),
1264 };
1265
1266 if inlined != (member_inline_size <= 4) {
1267 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1268 }
1269 let _inner_offset;
1270 if inlined {
1271 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1272 _inner_offset = offset + 8;
1273 } else {
1274 depth.increment()?;
1275 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1276 }
1277 match ordinal {
1278 1 => {
1279 #[allow(irrefutable_let_patterns)]
1280 if let Target::Stream(_) = self {
1281 } else {
1283 *self = Target::Stream(fidl::new_empty!(
1285 fidl_fuchsia_media::AudioRenderUsage,
1286 D
1287 ));
1288 }
1289 #[allow(irrefutable_let_patterns)]
1290 if let Target::Stream(ref mut val) = self {
1291 fidl::decode!(
1292 fidl_fuchsia_media::AudioRenderUsage,
1293 D,
1294 val,
1295 decoder,
1296 _inner_offset,
1297 depth
1298 )?;
1299 } else {
1300 unreachable!()
1301 }
1302 }
1303 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1304 }
1305 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1306 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1307 }
1308 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1309 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1310 }
1311 Ok(())
1312 }
1313 }
1314}