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 EncryptionInitVector = Vec<u8>;
12
13pub type EncryptionKeyId = Vec<u8>;
14
15pub type EncryptionScheme = String;
17
18pub const ENCRYPTION_SCHEME_CBC1: &str = "cbc1";
19
20pub const ENCRYPTION_SCHEME_CBCS: &str = "cbcs";
21
22pub const ENCRYPTION_SCHEME_CENC: &str = "cenc";
23
24pub const ENCRYPTION_SCHEME_CENS: &str = "cens";
25
26pub const MAX_ENCRYPTION_SCHEME_SIZE: u32 = 4;
28
29pub const MAX_INIT_VECTOR_SIZE: u32 = 16;
31
32pub const MAX_KEY_ID_SIZE: u32 = 16;
34
35pub const MAX_SUBSAMPLE_ENTRIES: u32 = 16;
37
38#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
43#[repr(C)]
44pub struct EncryptionPattern {
45 pub clear_blocks: u32,
46 pub encrypted_blocks: u32,
47}
48
49impl fidl::Persistable for EncryptionPattern {}
50
51#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55#[repr(C)]
56pub struct EncryptionSubsampleEntry {
57 pub clear_bytes: u32,
58 pub encrypted_bytes: u32,
59}
60
61impl fidl::Persistable for EncryptionSubsampleEntry {}
62
63#[derive(Clone, Debug, Default, PartialEq)]
68pub struct Encryption {
69 pub scheme: Option<String>,
78 pub default_key_id: Option<Vec<u8>>,
84 pub default_init_vector: Option<Vec<u8>>,
92 pub default_pattern: Option<EncryptionPattern>,
99 #[doc(hidden)]
100 pub __source_breaking: fidl::marker::SourceBreaking,
101}
102
103impl fidl::Persistable for Encryption {}
104
105#[derive(Clone, Debug, Default, PartialEq)]
107pub struct PacketEncryptionProperties {
108 pub is_encrypted: Option<bool>,
110 pub key_id: Option<Vec<u8>>,
112 pub init_vector: Option<Vec<u8>>,
114 pub pattern: Option<EncryptionPattern>,
116 pub subsamples: Option<Vec<EncryptionSubsampleEntry>>,
119 #[doc(hidden)]
120 pub __source_breaking: fidl::marker::SourceBreaking,
121}
122
123impl fidl::Persistable for PacketEncryptionProperties {}
124
125mod internal {
126 use super::*;
127
128 impl fidl::encoding::ValueTypeMarker for EncryptionPattern {
129 type Borrowed<'a> = &'a Self;
130 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
131 value
132 }
133 }
134
135 unsafe impl fidl::encoding::TypeMarker for EncryptionPattern {
136 type Owned = Self;
137
138 #[inline(always)]
139 fn inline_align(_context: fidl::encoding::Context) -> usize {
140 4
141 }
142
143 #[inline(always)]
144 fn inline_size(_context: fidl::encoding::Context) -> usize {
145 8
146 }
147 #[inline(always)]
148 fn encode_is_copy() -> bool {
149 true
150 }
151
152 #[inline(always)]
153 fn decode_is_copy() -> bool {
154 true
155 }
156 }
157
158 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EncryptionPattern, D>
159 for &EncryptionPattern
160 {
161 #[inline]
162 unsafe fn encode(
163 self,
164 encoder: &mut fidl::encoding::Encoder<'_, D>,
165 offset: usize,
166 _depth: fidl::encoding::Depth,
167 ) -> fidl::Result<()> {
168 encoder.debug_check_bounds::<EncryptionPattern>(offset);
169 unsafe {
170 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
172 (buf_ptr as *mut EncryptionPattern)
173 .write_unaligned((self as *const EncryptionPattern).read());
174 }
177 Ok(())
178 }
179 }
180 unsafe impl<
181 D: fidl::encoding::ResourceDialect,
182 T0: fidl::encoding::Encode<u32, D>,
183 T1: fidl::encoding::Encode<u32, D>,
184 > fidl::encoding::Encode<EncryptionPattern, D> for (T0, T1)
185 {
186 #[inline]
187 unsafe fn encode(
188 self,
189 encoder: &mut fidl::encoding::Encoder<'_, D>,
190 offset: usize,
191 depth: fidl::encoding::Depth,
192 ) -> fidl::Result<()> {
193 encoder.debug_check_bounds::<EncryptionPattern>(offset);
194 self.0.encode(encoder, offset + 0, depth)?;
198 self.1.encode(encoder, offset + 4, depth)?;
199 Ok(())
200 }
201 }
202
203 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EncryptionPattern {
204 #[inline(always)]
205 fn new_empty() -> Self {
206 Self {
207 clear_blocks: fidl::new_empty!(u32, D),
208 encrypted_blocks: fidl::new_empty!(u32, D),
209 }
210 }
211
212 #[inline]
213 unsafe fn decode(
214 &mut self,
215 decoder: &mut fidl::encoding::Decoder<'_, D>,
216 offset: usize,
217 _depth: fidl::encoding::Depth,
218 ) -> fidl::Result<()> {
219 decoder.debug_check_bounds::<Self>(offset);
220 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
221 unsafe {
224 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
225 }
226 Ok(())
227 }
228 }
229
230 impl fidl::encoding::ValueTypeMarker for EncryptionSubsampleEntry {
231 type Borrowed<'a> = &'a Self;
232 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
233 value
234 }
235 }
236
237 unsafe impl fidl::encoding::TypeMarker for EncryptionSubsampleEntry {
238 type Owned = Self;
239
240 #[inline(always)]
241 fn inline_align(_context: fidl::encoding::Context) -> usize {
242 4
243 }
244
245 #[inline(always)]
246 fn inline_size(_context: fidl::encoding::Context) -> usize {
247 8
248 }
249 #[inline(always)]
250 fn encode_is_copy() -> bool {
251 true
252 }
253
254 #[inline(always)]
255 fn decode_is_copy() -> bool {
256 true
257 }
258 }
259
260 unsafe impl<D: fidl::encoding::ResourceDialect>
261 fidl::encoding::Encode<EncryptionSubsampleEntry, D> for &EncryptionSubsampleEntry
262 {
263 #[inline]
264 unsafe fn encode(
265 self,
266 encoder: &mut fidl::encoding::Encoder<'_, D>,
267 offset: usize,
268 _depth: fidl::encoding::Depth,
269 ) -> fidl::Result<()> {
270 encoder.debug_check_bounds::<EncryptionSubsampleEntry>(offset);
271 unsafe {
272 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
274 (buf_ptr as *mut EncryptionSubsampleEntry)
275 .write_unaligned((self as *const EncryptionSubsampleEntry).read());
276 }
279 Ok(())
280 }
281 }
282 unsafe impl<
283 D: fidl::encoding::ResourceDialect,
284 T0: fidl::encoding::Encode<u32, D>,
285 T1: fidl::encoding::Encode<u32, D>,
286 > fidl::encoding::Encode<EncryptionSubsampleEntry, D> for (T0, T1)
287 {
288 #[inline]
289 unsafe fn encode(
290 self,
291 encoder: &mut fidl::encoding::Encoder<'_, D>,
292 offset: usize,
293 depth: fidl::encoding::Depth,
294 ) -> fidl::Result<()> {
295 encoder.debug_check_bounds::<EncryptionSubsampleEntry>(offset);
296 self.0.encode(encoder, offset + 0, depth)?;
300 self.1.encode(encoder, offset + 4, depth)?;
301 Ok(())
302 }
303 }
304
305 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
306 for EncryptionSubsampleEntry
307 {
308 #[inline(always)]
309 fn new_empty() -> Self {
310 Self {
311 clear_bytes: fidl::new_empty!(u32, D),
312 encrypted_bytes: fidl::new_empty!(u32, D),
313 }
314 }
315
316 #[inline]
317 unsafe fn decode(
318 &mut self,
319 decoder: &mut fidl::encoding::Decoder<'_, D>,
320 offset: usize,
321 _depth: fidl::encoding::Depth,
322 ) -> fidl::Result<()> {
323 decoder.debug_check_bounds::<Self>(offset);
324 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
325 unsafe {
328 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
329 }
330 Ok(())
331 }
332 }
333
334 impl Encryption {
335 #[inline(always)]
336 fn max_ordinal_present(&self) -> u64 {
337 if let Some(_) = self.default_pattern {
338 return 4;
339 }
340 if let Some(_) = self.default_init_vector {
341 return 3;
342 }
343 if let Some(_) = self.default_key_id {
344 return 2;
345 }
346 if let Some(_) = self.scheme {
347 return 1;
348 }
349 0
350 }
351 }
352
353 impl fidl::encoding::ValueTypeMarker for Encryption {
354 type Borrowed<'a> = &'a Self;
355 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
356 value
357 }
358 }
359
360 unsafe impl fidl::encoding::TypeMarker for Encryption {
361 type Owned = Self;
362
363 #[inline(always)]
364 fn inline_align(_context: fidl::encoding::Context) -> usize {
365 8
366 }
367
368 #[inline(always)]
369 fn inline_size(_context: fidl::encoding::Context) -> usize {
370 16
371 }
372 }
373
374 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Encryption, D>
375 for &Encryption
376 {
377 unsafe fn encode(
378 self,
379 encoder: &mut fidl::encoding::Encoder<'_, D>,
380 offset: usize,
381 mut depth: fidl::encoding::Depth,
382 ) -> fidl::Result<()> {
383 encoder.debug_check_bounds::<Encryption>(offset);
384 let max_ordinal: u64 = self.max_ordinal_present();
386 encoder.write_num(max_ordinal, offset);
387 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
388 if max_ordinal == 0 {
390 return Ok(());
391 }
392 depth.increment()?;
393 let envelope_size = 8;
394 let bytes_len = max_ordinal as usize * envelope_size;
395 #[allow(unused_variables)]
396 let offset = encoder.out_of_line_offset(bytes_len);
397 let mut _prev_end_offset: usize = 0;
398 if 1 > max_ordinal {
399 return Ok(());
400 }
401
402 let cur_offset: usize = (1 - 1) * envelope_size;
405
406 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
408
409 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4>, D>(
414 self.scheme.as_ref().map(
415 <fidl::encoding::BoundedString<4> as fidl::encoding::ValueTypeMarker>::borrow,
416 ),
417 encoder,
418 offset + cur_offset,
419 depth,
420 )?;
421
422 _prev_end_offset = cur_offset + envelope_size;
423 if 2 > max_ordinal {
424 return Ok(());
425 }
426
427 let cur_offset: usize = (2 - 1) * envelope_size;
430
431 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
433
434 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 16>, D>(
439 self.default_key_id.as_ref().map(
440 <fidl::encoding::Vector<u8, 16> as fidl::encoding::ValueTypeMarker>::borrow,
441 ),
442 encoder,
443 offset + cur_offset,
444 depth,
445 )?;
446
447 _prev_end_offset = cur_offset + envelope_size;
448 if 3 > max_ordinal {
449 return Ok(());
450 }
451
452 let cur_offset: usize = (3 - 1) * envelope_size;
455
456 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
458
459 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 16>, D>(
464 self.default_init_vector.as_ref().map(
465 <fidl::encoding::Vector<u8, 16> as fidl::encoding::ValueTypeMarker>::borrow,
466 ),
467 encoder,
468 offset + cur_offset,
469 depth,
470 )?;
471
472 _prev_end_offset = cur_offset + envelope_size;
473 if 4 > max_ordinal {
474 return Ok(());
475 }
476
477 let cur_offset: usize = (4 - 1) * envelope_size;
480
481 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
483
484 fidl::encoding::encode_in_envelope_optional::<EncryptionPattern, D>(
489 self.default_pattern
490 .as_ref()
491 .map(<EncryptionPattern as fidl::encoding::ValueTypeMarker>::borrow),
492 encoder,
493 offset + cur_offset,
494 depth,
495 )?;
496
497 _prev_end_offset = cur_offset + envelope_size;
498
499 Ok(())
500 }
501 }
502
503 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Encryption {
504 #[inline(always)]
505 fn new_empty() -> Self {
506 Self::default()
507 }
508
509 unsafe fn decode(
510 &mut self,
511 decoder: &mut fidl::encoding::Decoder<'_, D>,
512 offset: usize,
513 mut depth: fidl::encoding::Depth,
514 ) -> fidl::Result<()> {
515 decoder.debug_check_bounds::<Self>(offset);
516 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
517 None => return Err(fidl::Error::NotNullable),
518 Some(len) => len,
519 };
520 if len == 0 {
522 return Ok(());
523 };
524 depth.increment()?;
525 let envelope_size = 8;
526 let bytes_len = len * envelope_size;
527 let offset = decoder.out_of_line_offset(bytes_len)?;
528 let mut _next_ordinal_to_read = 0;
530 let mut next_offset = offset;
531 let end_offset = offset + bytes_len;
532 _next_ordinal_to_read += 1;
533 if next_offset >= end_offset {
534 return Ok(());
535 }
536
537 while _next_ordinal_to_read < 1 {
539 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
540 _next_ordinal_to_read += 1;
541 next_offset += envelope_size;
542 }
543
544 let next_out_of_line = decoder.next_out_of_line();
545 let handles_before = decoder.remaining_handles();
546 if let Some((inlined, num_bytes, num_handles)) =
547 fidl::encoding::decode_envelope_header(decoder, next_offset)?
548 {
549 let member_inline_size =
550 <fidl::encoding::BoundedString<4> as fidl::encoding::TypeMarker>::inline_size(
551 decoder.context,
552 );
553 if inlined != (member_inline_size <= 4) {
554 return Err(fidl::Error::InvalidInlineBitInEnvelope);
555 }
556 let inner_offset;
557 let mut inner_depth = depth.clone();
558 if inlined {
559 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
560 inner_offset = next_offset;
561 } else {
562 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
563 inner_depth.increment()?;
564 }
565 let val_ref = self
566 .scheme
567 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<4>, D));
568 fidl::decode!(
569 fidl::encoding::BoundedString<4>,
570 D,
571 val_ref,
572 decoder,
573 inner_offset,
574 inner_depth
575 )?;
576 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
577 {
578 return Err(fidl::Error::InvalidNumBytesInEnvelope);
579 }
580 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
581 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
582 }
583 }
584
585 next_offset += envelope_size;
586 _next_ordinal_to_read += 1;
587 if next_offset >= end_offset {
588 return Ok(());
589 }
590
591 while _next_ordinal_to_read < 2 {
593 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
594 _next_ordinal_to_read += 1;
595 next_offset += envelope_size;
596 }
597
598 let next_out_of_line = decoder.next_out_of_line();
599 let handles_before = decoder.remaining_handles();
600 if let Some((inlined, num_bytes, num_handles)) =
601 fidl::encoding::decode_envelope_header(decoder, next_offset)?
602 {
603 let member_inline_size =
604 <fidl::encoding::Vector<u8, 16> as fidl::encoding::TypeMarker>::inline_size(
605 decoder.context,
606 );
607 if inlined != (member_inline_size <= 4) {
608 return Err(fidl::Error::InvalidInlineBitInEnvelope);
609 }
610 let inner_offset;
611 let mut inner_depth = depth.clone();
612 if inlined {
613 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
614 inner_offset = next_offset;
615 } else {
616 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
617 inner_depth.increment()?;
618 }
619 let val_ref = self
620 .default_key_id
621 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 16>, D));
622 fidl::decode!(fidl::encoding::Vector<u8, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
623 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
624 {
625 return Err(fidl::Error::InvalidNumBytesInEnvelope);
626 }
627 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
628 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
629 }
630 }
631
632 next_offset += envelope_size;
633 _next_ordinal_to_read += 1;
634 if next_offset >= end_offset {
635 return Ok(());
636 }
637
638 while _next_ordinal_to_read < 3 {
640 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
641 _next_ordinal_to_read += 1;
642 next_offset += envelope_size;
643 }
644
645 let next_out_of_line = decoder.next_out_of_line();
646 let handles_before = decoder.remaining_handles();
647 if let Some((inlined, num_bytes, num_handles)) =
648 fidl::encoding::decode_envelope_header(decoder, next_offset)?
649 {
650 let member_inline_size =
651 <fidl::encoding::Vector<u8, 16> as fidl::encoding::TypeMarker>::inline_size(
652 decoder.context,
653 );
654 if inlined != (member_inline_size <= 4) {
655 return Err(fidl::Error::InvalidInlineBitInEnvelope);
656 }
657 let inner_offset;
658 let mut inner_depth = depth.clone();
659 if inlined {
660 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
661 inner_offset = next_offset;
662 } else {
663 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
664 inner_depth.increment()?;
665 }
666 let val_ref = self
667 .default_init_vector
668 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 16>, D));
669 fidl::decode!(fidl::encoding::Vector<u8, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
670 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
671 {
672 return Err(fidl::Error::InvalidNumBytesInEnvelope);
673 }
674 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
675 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
676 }
677 }
678
679 next_offset += envelope_size;
680 _next_ordinal_to_read += 1;
681 if next_offset >= end_offset {
682 return Ok(());
683 }
684
685 while _next_ordinal_to_read < 4 {
687 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
688 _next_ordinal_to_read += 1;
689 next_offset += envelope_size;
690 }
691
692 let next_out_of_line = decoder.next_out_of_line();
693 let handles_before = decoder.remaining_handles();
694 if let Some((inlined, num_bytes, num_handles)) =
695 fidl::encoding::decode_envelope_header(decoder, next_offset)?
696 {
697 let member_inline_size =
698 <EncryptionPattern as fidl::encoding::TypeMarker>::inline_size(decoder.context);
699 if inlined != (member_inline_size <= 4) {
700 return Err(fidl::Error::InvalidInlineBitInEnvelope);
701 }
702 let inner_offset;
703 let mut inner_depth = depth.clone();
704 if inlined {
705 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
706 inner_offset = next_offset;
707 } else {
708 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
709 inner_depth.increment()?;
710 }
711 let val_ref = self
712 .default_pattern
713 .get_or_insert_with(|| fidl::new_empty!(EncryptionPattern, D));
714 fidl::decode!(EncryptionPattern, D, val_ref, decoder, inner_offset, inner_depth)?;
715 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
716 {
717 return Err(fidl::Error::InvalidNumBytesInEnvelope);
718 }
719 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
720 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
721 }
722 }
723
724 next_offset += envelope_size;
725
726 while next_offset < end_offset {
728 _next_ordinal_to_read += 1;
729 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
730 next_offset += envelope_size;
731 }
732
733 Ok(())
734 }
735 }
736
737 impl PacketEncryptionProperties {
738 #[inline(always)]
739 fn max_ordinal_present(&self) -> u64 {
740 if let Some(_) = self.subsamples {
741 return 5;
742 }
743 if let Some(_) = self.pattern {
744 return 4;
745 }
746 if let Some(_) = self.init_vector {
747 return 3;
748 }
749 if let Some(_) = self.key_id {
750 return 2;
751 }
752 if let Some(_) = self.is_encrypted {
753 return 1;
754 }
755 0
756 }
757 }
758
759 impl fidl::encoding::ValueTypeMarker for PacketEncryptionProperties {
760 type Borrowed<'a> = &'a Self;
761 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
762 value
763 }
764 }
765
766 unsafe impl fidl::encoding::TypeMarker for PacketEncryptionProperties {
767 type Owned = Self;
768
769 #[inline(always)]
770 fn inline_align(_context: fidl::encoding::Context) -> usize {
771 8
772 }
773
774 #[inline(always)]
775 fn inline_size(_context: fidl::encoding::Context) -> usize {
776 16
777 }
778 }
779
780 unsafe impl<D: fidl::encoding::ResourceDialect>
781 fidl::encoding::Encode<PacketEncryptionProperties, D> for &PacketEncryptionProperties
782 {
783 unsafe fn encode(
784 self,
785 encoder: &mut fidl::encoding::Encoder<'_, D>,
786 offset: usize,
787 mut depth: fidl::encoding::Depth,
788 ) -> fidl::Result<()> {
789 encoder.debug_check_bounds::<PacketEncryptionProperties>(offset);
790 let max_ordinal: u64 = self.max_ordinal_present();
792 encoder.write_num(max_ordinal, offset);
793 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
794 if max_ordinal == 0 {
796 return Ok(());
797 }
798 depth.increment()?;
799 let envelope_size = 8;
800 let bytes_len = max_ordinal as usize * envelope_size;
801 #[allow(unused_variables)]
802 let offset = encoder.out_of_line_offset(bytes_len);
803 let mut _prev_end_offset: usize = 0;
804 if 1 > max_ordinal {
805 return Ok(());
806 }
807
808 let cur_offset: usize = (1 - 1) * envelope_size;
811
812 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
814
815 fidl::encoding::encode_in_envelope_optional::<bool, D>(
820 self.is_encrypted.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
821 encoder,
822 offset + cur_offset,
823 depth,
824 )?;
825
826 _prev_end_offset = cur_offset + envelope_size;
827 if 2 > max_ordinal {
828 return Ok(());
829 }
830
831 let cur_offset: usize = (2 - 1) * envelope_size;
834
835 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
837
838 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 16>, D>(
843 self.key_id.as_ref().map(
844 <fidl::encoding::Vector<u8, 16> as fidl::encoding::ValueTypeMarker>::borrow,
845 ),
846 encoder,
847 offset + cur_offset,
848 depth,
849 )?;
850
851 _prev_end_offset = cur_offset + envelope_size;
852 if 3 > max_ordinal {
853 return Ok(());
854 }
855
856 let cur_offset: usize = (3 - 1) * envelope_size;
859
860 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
862
863 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 16>, D>(
868 self.init_vector.as_ref().map(
869 <fidl::encoding::Vector<u8, 16> as fidl::encoding::ValueTypeMarker>::borrow,
870 ),
871 encoder,
872 offset + cur_offset,
873 depth,
874 )?;
875
876 _prev_end_offset = cur_offset + envelope_size;
877 if 4 > max_ordinal {
878 return Ok(());
879 }
880
881 let cur_offset: usize = (4 - 1) * envelope_size;
884
885 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
887
888 fidl::encoding::encode_in_envelope_optional::<EncryptionPattern, D>(
893 self.pattern
894 .as_ref()
895 .map(<EncryptionPattern as fidl::encoding::ValueTypeMarker>::borrow),
896 encoder,
897 offset + cur_offset,
898 depth,
899 )?;
900
901 _prev_end_offset = cur_offset + envelope_size;
902 if 5 > max_ordinal {
903 return Ok(());
904 }
905
906 let cur_offset: usize = (5 - 1) * envelope_size;
909
910 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
912
913 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<EncryptionSubsampleEntry, 16>, D>(
918 self.subsamples.as_ref().map(<fidl::encoding::Vector<EncryptionSubsampleEntry, 16> as fidl::encoding::ValueTypeMarker>::borrow),
919 encoder, offset + cur_offset, depth
920 )?;
921
922 _prev_end_offset = cur_offset + envelope_size;
923
924 Ok(())
925 }
926 }
927
928 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
929 for PacketEncryptionProperties
930 {
931 #[inline(always)]
932 fn new_empty() -> Self {
933 Self::default()
934 }
935
936 unsafe fn decode(
937 &mut self,
938 decoder: &mut fidl::encoding::Decoder<'_, D>,
939 offset: usize,
940 mut depth: fidl::encoding::Depth,
941 ) -> fidl::Result<()> {
942 decoder.debug_check_bounds::<Self>(offset);
943 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
944 None => return Err(fidl::Error::NotNullable),
945 Some(len) => len,
946 };
947 if len == 0 {
949 return Ok(());
950 };
951 depth.increment()?;
952 let envelope_size = 8;
953 let bytes_len = len * envelope_size;
954 let offset = decoder.out_of_line_offset(bytes_len)?;
955 let mut _next_ordinal_to_read = 0;
957 let mut next_offset = offset;
958 let end_offset = offset + bytes_len;
959 _next_ordinal_to_read += 1;
960 if next_offset >= end_offset {
961 return Ok(());
962 }
963
964 while _next_ordinal_to_read < 1 {
966 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
967 _next_ordinal_to_read += 1;
968 next_offset += envelope_size;
969 }
970
971 let next_out_of_line = decoder.next_out_of_line();
972 let handles_before = decoder.remaining_handles();
973 if let Some((inlined, num_bytes, num_handles)) =
974 fidl::encoding::decode_envelope_header(decoder, next_offset)?
975 {
976 let member_inline_size =
977 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
978 if inlined != (member_inline_size <= 4) {
979 return Err(fidl::Error::InvalidInlineBitInEnvelope);
980 }
981 let inner_offset;
982 let mut inner_depth = depth.clone();
983 if inlined {
984 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
985 inner_offset = next_offset;
986 } else {
987 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
988 inner_depth.increment()?;
989 }
990 let val_ref = self.is_encrypted.get_or_insert_with(|| fidl::new_empty!(bool, D));
991 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
992 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
993 {
994 return Err(fidl::Error::InvalidNumBytesInEnvelope);
995 }
996 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
997 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
998 }
999 }
1000
1001 next_offset += envelope_size;
1002 _next_ordinal_to_read += 1;
1003 if next_offset >= end_offset {
1004 return Ok(());
1005 }
1006
1007 while _next_ordinal_to_read < 2 {
1009 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1010 _next_ordinal_to_read += 1;
1011 next_offset += envelope_size;
1012 }
1013
1014 let next_out_of_line = decoder.next_out_of_line();
1015 let handles_before = decoder.remaining_handles();
1016 if let Some((inlined, num_bytes, num_handles)) =
1017 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1018 {
1019 let member_inline_size =
1020 <fidl::encoding::Vector<u8, 16> as fidl::encoding::TypeMarker>::inline_size(
1021 decoder.context,
1022 );
1023 if inlined != (member_inline_size <= 4) {
1024 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1025 }
1026 let inner_offset;
1027 let mut inner_depth = depth.clone();
1028 if inlined {
1029 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1030 inner_offset = next_offset;
1031 } else {
1032 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1033 inner_depth.increment()?;
1034 }
1035 let val_ref = self
1036 .key_id
1037 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 16>, D));
1038 fidl::decode!(fidl::encoding::Vector<u8, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
1039 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1040 {
1041 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1042 }
1043 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1044 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1045 }
1046 }
1047
1048 next_offset += envelope_size;
1049 _next_ordinal_to_read += 1;
1050 if next_offset >= end_offset {
1051 return Ok(());
1052 }
1053
1054 while _next_ordinal_to_read < 3 {
1056 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1057 _next_ordinal_to_read += 1;
1058 next_offset += envelope_size;
1059 }
1060
1061 let next_out_of_line = decoder.next_out_of_line();
1062 let handles_before = decoder.remaining_handles();
1063 if let Some((inlined, num_bytes, num_handles)) =
1064 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1065 {
1066 let member_inline_size =
1067 <fidl::encoding::Vector<u8, 16> as fidl::encoding::TypeMarker>::inline_size(
1068 decoder.context,
1069 );
1070 if inlined != (member_inline_size <= 4) {
1071 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1072 }
1073 let inner_offset;
1074 let mut inner_depth = depth.clone();
1075 if inlined {
1076 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1077 inner_offset = next_offset;
1078 } else {
1079 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1080 inner_depth.increment()?;
1081 }
1082 let val_ref = self
1083 .init_vector
1084 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 16>, D));
1085 fidl::decode!(fidl::encoding::Vector<u8, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
1086 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1087 {
1088 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1089 }
1090 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1091 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1092 }
1093 }
1094
1095 next_offset += envelope_size;
1096 _next_ordinal_to_read += 1;
1097 if next_offset >= end_offset {
1098 return Ok(());
1099 }
1100
1101 while _next_ordinal_to_read < 4 {
1103 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1104 _next_ordinal_to_read += 1;
1105 next_offset += envelope_size;
1106 }
1107
1108 let next_out_of_line = decoder.next_out_of_line();
1109 let handles_before = decoder.remaining_handles();
1110 if let Some((inlined, num_bytes, num_handles)) =
1111 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1112 {
1113 let member_inline_size =
1114 <EncryptionPattern as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1115 if inlined != (member_inline_size <= 4) {
1116 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1117 }
1118 let inner_offset;
1119 let mut inner_depth = depth.clone();
1120 if inlined {
1121 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1122 inner_offset = next_offset;
1123 } else {
1124 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1125 inner_depth.increment()?;
1126 }
1127 let val_ref =
1128 self.pattern.get_or_insert_with(|| fidl::new_empty!(EncryptionPattern, D));
1129 fidl::decode!(EncryptionPattern, D, val_ref, decoder, inner_offset, inner_depth)?;
1130 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1131 {
1132 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1133 }
1134 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1135 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1136 }
1137 }
1138
1139 next_offset += envelope_size;
1140 _next_ordinal_to_read += 1;
1141 if next_offset >= end_offset {
1142 return Ok(());
1143 }
1144
1145 while _next_ordinal_to_read < 5 {
1147 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1148 _next_ordinal_to_read += 1;
1149 next_offset += envelope_size;
1150 }
1151
1152 let next_out_of_line = decoder.next_out_of_line();
1153 let handles_before = decoder.remaining_handles();
1154 if let Some((inlined, num_bytes, num_handles)) =
1155 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1156 {
1157 let member_inline_size = <fidl::encoding::Vector<EncryptionSubsampleEntry, 16> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1158 if inlined != (member_inline_size <= 4) {
1159 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1160 }
1161 let inner_offset;
1162 let mut inner_depth = depth.clone();
1163 if inlined {
1164 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1165 inner_offset = next_offset;
1166 } else {
1167 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1168 inner_depth.increment()?;
1169 }
1170 let val_ref = self.subsamples.get_or_insert_with(
1171 || fidl::new_empty!(fidl::encoding::Vector<EncryptionSubsampleEntry, 16>, D),
1172 );
1173 fidl::decode!(fidl::encoding::Vector<EncryptionSubsampleEntry, 16>, D, val_ref, decoder, inner_offset, inner_depth)?;
1174 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1175 {
1176 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1177 }
1178 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1179 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1180 }
1181 }
1182
1183 next_offset += envelope_size;
1184
1185 while next_offset < end_offset {
1187 _next_ordinal_to_read += 1;
1188 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1189 next_offset += envelope_size;
1190 }
1191
1192 Ok(())
1193 }
1194 }
1195}