blob: c18c0b6035737036a2e708d86d4c182cbbd639d6 [file] [log] [blame]
// 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, Debug, Default, PartialEq)]
pub struct LocalTablePayload {
pub a: Option<u16>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for LocalTablePayload {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct MainProtocolOneWayAnonRequest {
pub a: Option<u16>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for MainProtocolOneWayAnonRequest {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct MainProtocolTwoWayAnonResponse {
pub a: Option<u16>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for MainProtocolTwoWayAnonResponse {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct MainProtocolTwoWayAnonWithErrorRequest {
pub a: Option<u16>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for MainProtocolTwoWayAnonWithErrorRequest {}
#[derive(Clone, Debug)]
pub enum LocalUnionPayload {
B(bool),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `LocalUnionPayload` member.
#[macro_export]
macro_rules! LocalUnionPayloadUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for LocalUnionPayload {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::B(x), Self::B(y)) => *x == *y,
_ => false,
}
}
}
impl LocalUnionPayload {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::B(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for LocalUnionPayload {}
#[derive(Clone, Debug)]
pub enum MainProtocolOnAnonRequest {
B(bool),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `MainProtocolOnAnonRequest` member.
#[macro_export]
macro_rules! MainProtocolOnAnonRequestUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for MainProtocolOnAnonRequest {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::B(x), Self::B(y)) => *x == *y,
_ => false,
}
}
}
impl MainProtocolOnAnonRequest {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::B(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for MainProtocolOnAnonRequest {}
#[derive(Clone, Debug)]
pub enum MainProtocolTwoWayAnonRequest {
B(bool),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `MainProtocolTwoWayAnonRequest` member.
#[macro_export]
macro_rules! MainProtocolTwoWayAnonRequestUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for MainProtocolTwoWayAnonRequest {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::B(x), Self::B(y)) => *x == *y,
_ => false,
}
}
}
impl MainProtocolTwoWayAnonRequest {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::B(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for MainProtocolTwoWayAnonRequest {}
#[derive(Clone, Debug)]
pub enum MainProtocolTwoWayAnonWithErrorResponse {
B(bool),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `MainProtocolTwoWayAnonWithErrorResponse` member.
#[macro_export]
macro_rules! MainProtocolTwoWayAnonWithErrorResponseUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for MainProtocolTwoWayAnonWithErrorResponse {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::B(x), Self::B(y)) => *x == *y,
_ => false,
}
}
}
impl MainProtocolTwoWayAnonWithErrorResponse {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::B(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for MainProtocolTwoWayAnonWithErrorResponse {}
pub mod main_protocol_ordinals {
pub const ONE_WAY_ANON_COMPOSED: u64 = 0x67da05e1ae3f5e1;
pub const TWO_WAY_ANON_COMPOSED: u64 = 0x16afa17ea70d3370;
pub const TWO_WAY_ANON_COMPOSED_WITH_ERROR: u64 = 0x2ed33746b7bb119d;
pub const ON_ANON_COMPOSED: u64 = 0x7fa8a0bf08128a0b;
pub const ONE_WAY_NAMED_COMPOSED: u64 = 0x5d78ce13958eee58;
pub const TWO_WAY_NAMED_COMPOSED: u64 = 0xf67f27cae663810;
pub const TWO_WAY_NAMED_COMPOSED_WITH_ERROR: u64 = 0x30dac4182813ef7f;
pub const ON_NAMED_COMPOSED: u64 = 0x5e68f92a5b28cdea;
pub const ONE_WAY_IMPORT: u64 = 0x530db65f2691d3b;
pub const TWO_WAY_IMPORT: u64 = 0x2bf680c8f0d40604;
pub const TWO_WAY_IMPORT_WITH_ERROR: u64 = 0x432093586084ff0a;
pub const ON_IMPORT: u64 = 0x5b61e3156b09acd0;
pub const ONE_WAY_LOCAL: u64 = 0x54759b55efd60f43;
pub const TWO_WAY_LOCAL: u64 = 0x6bbeeb18f39c539b;
pub const TWO_WAY_LOCAL_WITH_ERROR: u64 = 0x4dd8e7287c4c9b57;
pub const ON_LOCAL: u64 = 0x3a46c48153f0437c;
pub const ONE_WAY_ANON: u64 = 0x3a552f30c77c76ec;
pub const TWO_WAY_ANON: u64 = 0x672eb5e71efdabcf;
pub const TWO_WAY_ANON_WITH_ERROR: u64 = 0x6bd5fcf6f7b46df1;
pub const ON_ANON: u64 = 0x64f7b1ec1ba0810b;
}
pub mod open_protocol_ordinals {
pub const FLEXIBLE_ONE_WAY: u64 = 0x30ce1cc0e7e88521;
pub const FLEXIBLE_TWO_WAY_NO_ERROR: u64 = 0x4d5655754da320d8;
pub const FLEXIBLE_TWO_WAY_WITH_ERROR: u64 = 0x30a12dd4f7823782;
pub const FLEXIBLE_EVENT: u64 = 0x7f038af71aad17d4;
pub const STRICT_ONE_WAY: u64 = 0x79fce2c7f5b1bfa7;
pub const STRICT_TWO_WAY_NO_ERROR: u64 = 0x3338d68165132184;
pub const STRICT_TWO_WAY_WITH_ERROR: u64 = 0x4a72f997c7db5037;
pub const STRICT_EVENT: u64 = 0x366a73eb0b37159d;
pub const FLEXIBLE_ONE_WAY_NAMED_PAYLOAD: u64 = 0x152c0b4acb5c0570;
}
mod internal {
use super::*;
impl LocalTablePayload {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.a {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for LocalTablePayload {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for LocalTablePayload {
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<LocalTablePayload, D>
for &LocalTablePayload
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<LocalTablePayload>(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::<u16, D>(
self.a.as_ref().map(<u16 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 LocalTablePayload {
#[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 =
<u16 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!(u16, D));
fidl::decode!(u16, 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 MainProtocolOneWayAnonRequest {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.a {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for MainProtocolOneWayAnonRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolOneWayAnonRequest {
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<MainProtocolOneWayAnonRequest, D>
for &MainProtocolOneWayAnonRequest
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolOneWayAnonRequest>(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::<u16, D>(
self.a.as_ref().map(<u16 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 MainProtocolOneWayAnonRequest
{
#[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 =
<u16 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!(u16, D));
fidl::decode!(u16, 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 MainProtocolTwoWayAnonResponse {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.a {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for MainProtocolTwoWayAnonResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolTwoWayAnonResponse {
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<MainProtocolTwoWayAnonResponse, D>
for &MainProtocolTwoWayAnonResponse
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolTwoWayAnonResponse>(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::<u16, D>(
self.a.as_ref().map(<u16 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 MainProtocolTwoWayAnonResponse
{
#[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 =
<u16 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!(u16, D));
fidl::decode!(u16, 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 MainProtocolTwoWayAnonWithErrorRequest {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.a {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for MainProtocolTwoWayAnonWithErrorRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolTwoWayAnonWithErrorRequest {
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<MainProtocolTwoWayAnonWithErrorRequest, D>
for &MainProtocolTwoWayAnonWithErrorRequest
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolTwoWayAnonWithErrorRequest>(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::<u16, D>(
self.a.as_ref().map(<u16 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 MainProtocolTwoWayAnonWithErrorRequest
{
#[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 =
<u16 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!(u16, D));
fidl::decode!(u16, 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 LocalUnionPayload {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for LocalUnionPayload {
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<LocalUnionPayload, D>
for &LocalUnionPayload
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<LocalUnionPayload>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
LocalUnionPayload::B(ref val) => fidl::encoding::encode_in_envelope::<bool, D>(
<bool as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
LocalUnionPayload::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LocalUnionPayload {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[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 => <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
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 LocalUnionPayload::B(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = LocalUnionPayload::B(fidl::new_empty!(bool, D));
}
#[allow(irrefutable_let_patterns)]
if let LocalUnionPayload::B(ref mut val) = self {
fidl::decode!(bool, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = LocalUnionPayload::__SourceBreaking { unknown_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 MainProtocolOnAnonRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolOnAnonRequest {
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<MainProtocolOnAnonRequest, D> for &MainProtocolOnAnonRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolOnAnonRequest>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
MainProtocolOnAnonRequest::B(ref val) => {
fidl::encoding::encode_in_envelope::<bool, D>(
<bool as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
MainProtocolOnAnonRequest::__SourceBreaking { .. } => {
Err(fidl::Error::UnknownUnionTag)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for MainProtocolOnAnonRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[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 => <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
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 MainProtocolOnAnonRequest::B(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = MainProtocolOnAnonRequest::B(fidl::new_empty!(bool, D));
}
#[allow(irrefutable_let_patterns)]
if let MainProtocolOnAnonRequest::B(ref mut val) = self {
fidl::decode!(bool, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self =
MainProtocolOnAnonRequest::__SourceBreaking { unknown_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 MainProtocolTwoWayAnonRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolTwoWayAnonRequest {
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<MainProtocolTwoWayAnonRequest, D>
for &MainProtocolTwoWayAnonRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolTwoWayAnonRequest>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
MainProtocolTwoWayAnonRequest::B(ref val) => {
fidl::encoding::encode_in_envelope::<bool, D>(
<bool as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
MainProtocolTwoWayAnonRequest::__SourceBreaking { .. } => {
Err(fidl::Error::UnknownUnionTag)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for MainProtocolTwoWayAnonRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[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 => <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
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 MainProtocolTwoWayAnonRequest::B(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = MainProtocolTwoWayAnonRequest::B(fidl::new_empty!(bool, D));
}
#[allow(irrefutable_let_patterns)]
if let MainProtocolTwoWayAnonRequest::B(ref mut val) = self {
fidl::decode!(bool, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = MainProtocolTwoWayAnonRequest::__SourceBreaking {
unknown_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 MainProtocolTwoWayAnonWithErrorResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for MainProtocolTwoWayAnonWithErrorResponse {
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<MainProtocolTwoWayAnonWithErrorResponse, D>
for &MainProtocolTwoWayAnonWithErrorResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<MainProtocolTwoWayAnonWithErrorResponse>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
MainProtocolTwoWayAnonWithErrorResponse::B(ref val) => {
fidl::encoding::encode_in_envelope::<bool, D>(
<bool as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
MainProtocolTwoWayAnonWithErrorResponse::__SourceBreaking { .. } => {
Err(fidl::Error::UnknownUnionTag)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for MainProtocolTwoWayAnonWithErrorResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[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 => <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
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 MainProtocolTwoWayAnonWithErrorResponse::B(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self =
MainProtocolTwoWayAnonWithErrorResponse::B(fidl::new_empty!(bool, D));
}
#[allow(irrefutable_let_patterns)]
if let MainProtocolTwoWayAnonWithErrorResponse::B(ref mut val) = self {
fidl::decode!(bool, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = MainProtocolTwoWayAnonWithErrorResponse::__SourceBreaking {
unknown_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(())
}
}
}