| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)] |
| |
| use bitflags::bitflags; |
| use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect}; |
| use futures::future::{self, MaybeDone, TryFutureExt}; |
| use zx_status; |
| |
| #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| #[repr(C)] |
| pub struct StructLargeArray { |
| pub a: [u32; 100], |
| } |
| |
| impl fidl::Persistable for StructLargeArray {} |
| |
| #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| #[repr(C)] |
| pub struct StructSmallArray { |
| pub a: [u32; 2], |
| } |
| |
| impl fidl::Persistable for StructSmallArray {} |
| |
| #[derive(Clone, Debug, Default, PartialEq)] |
| pub struct TableLargeArray { |
| pub a: Option<[u32; 100]>, |
| #[doc(hidden)] |
| pub __source_breaking: fidl::marker::SourceBreaking, |
| } |
| |
| impl fidl::Persistable for TableLargeArray {} |
| |
| #[derive(Clone, Debug, Default, PartialEq)] |
| pub struct TableSmallArray { |
| pub a: Option<[u32; 2]>, |
| #[doc(hidden)] |
| pub __source_breaking: fidl::marker::SourceBreaking, |
| } |
| |
| impl fidl::Persistable for TableSmallArray {} |
| |
| #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| pub enum UnionLargeArray { |
| A([u32; 100]), |
| } |
| |
| impl UnionLargeArray { |
| #[inline] |
| pub fn ordinal(&self) -> u64 { |
| match *self { |
| Self::A(_) => 1, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for UnionLargeArray {} |
| |
| #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| pub enum UnionSmallArray { |
| A([u32; 2]), |
| } |
| |
| impl UnionSmallArray { |
| #[inline] |
| pub fn ordinal(&self) -> u64 { |
| match *self { |
| Self::A(_) => 1, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for UnionSmallArray {} |
| |
| mod internal { |
| use super::*; |
| |
| impl fidl::encoding::ValueTypeMarker for StructLargeArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for StructLargeArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 4 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 400 |
| } |
| #[inline(always)] |
| fn encode_is_copy() -> bool { |
| true |
| } |
| |
| #[inline(always)] |
| fn decode_is_copy() -> bool { |
| true |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StructLargeArray, D> |
| for &StructLargeArray |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<StructLargeArray>(offset); |
| unsafe { |
| // Copy the object into the buffer. |
| let buf_ptr = encoder.buf.as_mut_ptr().add(offset); |
| (buf_ptr as *mut StructLargeArray) |
| .write_unaligned((self as *const StructLargeArray).read()); |
| // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be |
| // done second because the memcpy will write garbage to these bytes. |
| } |
| Ok(()) |
| } |
| } |
| unsafe impl< |
| D: fidl::encoding::ResourceDialect, |
| T0: fidl::encoding::Encode<fidl::encoding::Array<u32, 100>, D>, |
| > fidl::encoding::Encode<StructLargeArray, D> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<StructLargeArray>(offset); |
| // Zero out padding regions. There's no need to apply masks |
| // because the unmasked parts will be overwritten by fields. |
| // Write the fields. |
| self.0.encode(encoder, offset + 0, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StructLargeArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { a: fidl::new_empty!(fidl::encoding::Array<u32, 100>, D) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) }; |
| // Verify that padding bytes are zero. |
| // Copy from the buffer into the object. |
| unsafe { |
| std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 400); |
| } |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for StructSmallArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for StructSmallArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 4 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| #[inline(always)] |
| fn encode_is_copy() -> bool { |
| true |
| } |
| |
| #[inline(always)] |
| fn decode_is_copy() -> bool { |
| true |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StructSmallArray, D> |
| for &StructSmallArray |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<StructSmallArray>(offset); |
| unsafe { |
| // Copy the object into the buffer. |
| let buf_ptr = encoder.buf.as_mut_ptr().add(offset); |
| (buf_ptr as *mut StructSmallArray) |
| .write_unaligned((self as *const StructSmallArray).read()); |
| // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be |
| // done second because the memcpy will write garbage to these bytes. |
| } |
| Ok(()) |
| } |
| } |
| unsafe impl< |
| D: fidl::encoding::ResourceDialect, |
| T0: fidl::encoding::Encode<fidl::encoding::Array<u32, 2>, D>, |
| > fidl::encoding::Encode<StructSmallArray, D> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<StructSmallArray>(offset); |
| // Zero out padding regions. There's no need to apply masks |
| // because the unmasked parts will be overwritten by fields. |
| // Write the fields. |
| self.0.encode(encoder, offset + 0, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StructSmallArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { a: fidl::new_empty!(fidl::encoding::Array<u32, 2>, D) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) }; |
| // Verify that padding bytes are zero. |
| // Copy from the buffer into the object. |
| unsafe { |
| std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8); |
| } |
| Ok(()) |
| } |
| } |
| |
| impl TableLargeArray { |
| #[inline(always)] |
| fn max_ordinal_present(&self) -> u64 { |
| if let Some(_) = self.a { |
| return 1; |
| } |
| 0 |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for TableLargeArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for TableLargeArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 16 |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TableLargeArray, D> |
| for &TableLargeArray |
| { |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<TableLargeArray>(offset); |
| // Vector header |
| let max_ordinal: u64 = self.max_ordinal_present(); |
| encoder.write_num(max_ordinal, offset); |
| encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8); |
| // Calling encoder.out_of_line_offset(0) is not allowed. |
| if max_ordinal == 0 { |
| return Ok(()); |
| } |
| depth.increment()?; |
| let envelope_size = 8; |
| let bytes_len = max_ordinal as usize * envelope_size; |
| #[allow(unused_variables)] |
| let offset = encoder.out_of_line_offset(bytes_len); |
| let mut _prev_end_offset: usize = 0; |
| if 1 > max_ordinal { |
| return Ok(()); |
| } |
| |
| // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes |
| // are envelope_size bytes. |
| let cur_offset: usize = (1 - 1) * envelope_size; |
| |
| // Zero reserved fields. |
| encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset); |
| |
| // Safety: |
| // - bytes_len is calculated to fit envelope_size*max(member.ordinal). |
| // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes |
| // envelope_size bytes, there is always sufficient room. |
| fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<u32, 100>, D>( |
| self.a.as_ref().map( |
| <fidl::encoding::Array<u32, 100> as fidl::encoding::ValueTypeMarker>::borrow, |
| ), |
| encoder, |
| offset + cur_offset, |
| depth, |
| )?; |
| |
| _prev_end_offset = cur_offset + envelope_size; |
| |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TableLargeArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::default() |
| } |
| |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| let len = match fidl::encoding::decode_vector_header(decoder, offset)? { |
| None => return Err(fidl::Error::NotNullable), |
| Some(len) => len, |
| }; |
| // Calling decoder.out_of_line_offset(0) is not allowed. |
| if len == 0 { |
| return Ok(()); |
| }; |
| depth.increment()?; |
| let envelope_size = 8; |
| let bytes_len = len * envelope_size; |
| let offset = decoder.out_of_line_offset(bytes_len)?; |
| // Decode the envelope for each type. |
| let mut _next_ordinal_to_read = 0; |
| let mut next_offset = offset; |
| let end_offset = offset + bytes_len; |
| _next_ordinal_to_read += 1; |
| if next_offset >= end_offset { |
| return Ok(()); |
| } |
| |
| // Decode unknown envelopes for gaps in ordinals. |
| while _next_ordinal_to_read < 1 { |
| fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?; |
| _next_ordinal_to_read += 1; |
| next_offset += envelope_size; |
| } |
| |
| let next_out_of_line = decoder.next_out_of_line(); |
| let handles_before = decoder.remaining_handles(); |
| if let Some((inlined, num_bytes, num_handles)) = |
| fidl::encoding::decode_envelope_header(decoder, next_offset)? |
| { |
| let member_inline_size = |
| <fidl::encoding::Array<u32, 100> as fidl::encoding::TypeMarker>::inline_size( |
| decoder.context, |
| ); |
| if inlined != (member_inline_size <= 4) { |
| return Err(fidl::Error::InvalidInlineBitInEnvelope); |
| } |
| let inner_offset; |
| let mut inner_depth = depth.clone(); |
| if inlined { |
| decoder.check_inline_envelope_padding(next_offset, member_inline_size)?; |
| inner_offset = next_offset; |
| } else { |
| inner_offset = decoder.out_of_line_offset(member_inline_size)?; |
| inner_depth.increment()?; |
| } |
| let val_ref = self |
| .a |
| .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<u32, 100>, D)); |
| fidl::decode!(fidl::encoding::Array<u32, 100>, D, val_ref, decoder, inner_offset, inner_depth)?; |
| if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) |
| { |
| return Err(fidl::Error::InvalidNumBytesInEnvelope); |
| } |
| if handles_before != decoder.remaining_handles() + (num_handles as usize) { |
| return Err(fidl::Error::InvalidNumHandlesInEnvelope); |
| } |
| } |
| |
| next_offset += envelope_size; |
| |
| // Decode the remaining unknown envelopes. |
| while next_offset < end_offset { |
| _next_ordinal_to_read += 1; |
| fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?; |
| next_offset += envelope_size; |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| impl TableSmallArray { |
| #[inline(always)] |
| fn max_ordinal_present(&self) -> u64 { |
| if let Some(_) = self.a { |
| return 1; |
| } |
| 0 |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for TableSmallArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for TableSmallArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 16 |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TableSmallArray, D> |
| for &TableSmallArray |
| { |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<TableSmallArray>(offset); |
| // Vector header |
| let max_ordinal: u64 = self.max_ordinal_present(); |
| encoder.write_num(max_ordinal, offset); |
| encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8); |
| // Calling encoder.out_of_line_offset(0) is not allowed. |
| if max_ordinal == 0 { |
| return Ok(()); |
| } |
| depth.increment()?; |
| let envelope_size = 8; |
| let bytes_len = max_ordinal as usize * envelope_size; |
| #[allow(unused_variables)] |
| let offset = encoder.out_of_line_offset(bytes_len); |
| let mut _prev_end_offset: usize = 0; |
| if 1 > max_ordinal { |
| return Ok(()); |
| } |
| |
| // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes |
| // are envelope_size bytes. |
| let cur_offset: usize = (1 - 1) * envelope_size; |
| |
| // Zero reserved fields. |
| encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset); |
| |
| // Safety: |
| // - bytes_len is calculated to fit envelope_size*max(member.ordinal). |
| // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes |
| // envelope_size bytes, there is always sufficient room. |
| fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<u32, 2>, D>( |
| self.a.as_ref().map( |
| <fidl::encoding::Array<u32, 2> as fidl::encoding::ValueTypeMarker>::borrow, |
| ), |
| encoder, |
| offset + cur_offset, |
| depth, |
| )?; |
| |
| _prev_end_offset = cur_offset + envelope_size; |
| |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TableSmallArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::default() |
| } |
| |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| let len = match fidl::encoding::decode_vector_header(decoder, offset)? { |
| None => return Err(fidl::Error::NotNullable), |
| Some(len) => len, |
| }; |
| // Calling decoder.out_of_line_offset(0) is not allowed. |
| if len == 0 { |
| return Ok(()); |
| }; |
| depth.increment()?; |
| let envelope_size = 8; |
| let bytes_len = len * envelope_size; |
| let offset = decoder.out_of_line_offset(bytes_len)?; |
| // Decode the envelope for each type. |
| let mut _next_ordinal_to_read = 0; |
| let mut next_offset = offset; |
| let end_offset = offset + bytes_len; |
| _next_ordinal_to_read += 1; |
| if next_offset >= end_offset { |
| return Ok(()); |
| } |
| |
| // Decode unknown envelopes for gaps in ordinals. |
| while _next_ordinal_to_read < 1 { |
| fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?; |
| _next_ordinal_to_read += 1; |
| next_offset += envelope_size; |
| } |
| |
| let next_out_of_line = decoder.next_out_of_line(); |
| let handles_before = decoder.remaining_handles(); |
| if let Some((inlined, num_bytes, num_handles)) = |
| fidl::encoding::decode_envelope_header(decoder, next_offset)? |
| { |
| let member_inline_size = |
| <fidl::encoding::Array<u32, 2> as fidl::encoding::TypeMarker>::inline_size( |
| decoder.context, |
| ); |
| if inlined != (member_inline_size <= 4) { |
| return Err(fidl::Error::InvalidInlineBitInEnvelope); |
| } |
| let inner_offset; |
| let mut inner_depth = depth.clone(); |
| if inlined { |
| decoder.check_inline_envelope_padding(next_offset, member_inline_size)?; |
| inner_offset = next_offset; |
| } else { |
| inner_offset = decoder.out_of_line_offset(member_inline_size)?; |
| inner_depth.increment()?; |
| } |
| let val_ref = self |
| .a |
| .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<u32, 2>, D)); |
| fidl::decode!(fidl::encoding::Array<u32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?; |
| if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) |
| { |
| return Err(fidl::Error::InvalidNumBytesInEnvelope); |
| } |
| if handles_before != decoder.remaining_handles() + (num_handles as usize) { |
| return Err(fidl::Error::InvalidNumHandlesInEnvelope); |
| } |
| } |
| |
| next_offset += envelope_size; |
| |
| // Decode the remaining unknown envelopes. |
| while next_offset < end_offset { |
| _next_ordinal_to_read += 1; |
| fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?; |
| next_offset += envelope_size; |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for UnionLargeArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for UnionLargeArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 16 |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnionLargeArray, D> |
| for &UnionLargeArray |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<UnionLargeArray>(offset); |
| encoder.write_num::<u64>(self.ordinal(), offset); |
| match self { |
| UnionLargeArray::A(ref val) => fidl::encoding::encode_in_envelope::< |
| fidl::encoding::Array<u32, 100>, |
| D, |
| >( |
| <fidl::encoding::Array<u32, 100> as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnionLargeArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::A(fidl::new_empty!(fidl::encoding::Array<u32, 100>, D)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| #[allow(unused_variables)] |
| let next_out_of_line = decoder.next_out_of_line(); |
| let handles_before = decoder.remaining_handles(); |
| let (ordinal, inlined, num_bytes, num_handles) = |
| fidl::encoding::decode_union_inline_portion(decoder, offset)?; |
| |
| let member_inline_size = match ordinal { |
| 1 => <fidl::encoding::Array<u32, 100> as fidl::encoding::TypeMarker>::inline_size( |
| decoder.context, |
| ), |
| _ => return Err(fidl::Error::UnknownUnionTag), |
| }; |
| |
| if inlined != (member_inline_size <= 4) { |
| return Err(fidl::Error::InvalidInlineBitInEnvelope); |
| } |
| let _inner_offset; |
| if inlined { |
| decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?; |
| _inner_offset = offset + 8; |
| } else { |
| depth.increment()?; |
| _inner_offset = decoder.out_of_line_offset(member_inline_size)?; |
| } |
| match ordinal { |
| 1 => { |
| #[allow(irrefutable_let_patterns)] |
| if let UnionLargeArray::A(_) = self { |
| // Do nothing, read the value into the object |
| } else { |
| // Initialize `self` to the right variant |
| *self = UnionLargeArray::A( |
| fidl::new_empty!(fidl::encoding::Array<u32, 100>, D), |
| ); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let UnionLargeArray::A(ref mut val) = self { |
| fidl::decode!(fidl::encoding::Array<u32, 100>, D, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| ordinal => panic!("unexpected ordinal {:?}", ordinal), |
| } |
| if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) { |
| return Err(fidl::Error::InvalidNumBytesInEnvelope); |
| } |
| if handles_before != decoder.remaining_handles() + (num_handles as usize) { |
| return Err(fidl::Error::InvalidNumHandlesInEnvelope); |
| } |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for UnionSmallArray { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for UnionSmallArray { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 16 |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnionSmallArray, D> |
| for &UnionSmallArray |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<UnionSmallArray>(offset); |
| encoder.write_num::<u64>(self.ordinal(), offset); |
| match self { |
| UnionSmallArray::A(ref val) => fidl::encoding::encode_in_envelope::< |
| fidl::encoding::Array<u32, 2>, |
| D, |
| >( |
| <fidl::encoding::Array<u32, 2> as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnionSmallArray { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::A(fidl::new_empty!(fidl::encoding::Array<u32, 2>, D)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_, D>, |
| offset: usize, |
| mut depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| #[allow(unused_variables)] |
| let next_out_of_line = decoder.next_out_of_line(); |
| let handles_before = decoder.remaining_handles(); |
| let (ordinal, inlined, num_bytes, num_handles) = |
| fidl::encoding::decode_union_inline_portion(decoder, offset)?; |
| |
| let member_inline_size = match ordinal { |
| 1 => <fidl::encoding::Array<u32, 2> as fidl::encoding::TypeMarker>::inline_size( |
| decoder.context, |
| ), |
| _ => return Err(fidl::Error::UnknownUnionTag), |
| }; |
| |
| if inlined != (member_inline_size <= 4) { |
| return Err(fidl::Error::InvalidInlineBitInEnvelope); |
| } |
| let _inner_offset; |
| if inlined { |
| decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?; |
| _inner_offset = offset + 8; |
| } else { |
| depth.increment()?; |
| _inner_offset = decoder.out_of_line_offset(member_inline_size)?; |
| } |
| match ordinal { |
| 1 => { |
| #[allow(irrefutable_let_patterns)] |
| if let UnionSmallArray::A(_) = self { |
| // Do nothing, read the value into the object |
| } else { |
| // Initialize `self` to the right variant |
| *self = |
| UnionSmallArray::A(fidl::new_empty!(fidl::encoding::Array<u32, 2>, D)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let UnionSmallArray::A(ref mut val) = self { |
| fidl::decode!(fidl::encoding::Array<u32, 2>, D, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| ordinal => panic!("unexpected ordinal {:?}", ordinal), |
| } |
| if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) { |
| return Err(fidl::Error::InvalidNumBytesInEnvelope); |
| } |
| if handles_before != decoder.remaining_handles() + (num_handles as usize) { |
| return Err(fidl::Error::InvalidNumHandlesInEnvelope); |
| } |
| Ok(()) |
| } |
| } |
| } |