blob: 5543860daf13202a453a544b669f1e4cb4774cfc [file] [log] [blame] [edit]
// 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)]
pub struct Empty;
impl fidl::Persistable for Empty {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NullableUnionStruct {
pub the_union: Option<Box<Union>>,
}
impl fidl::Persistable for NullableUnionStruct {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Pasta {
pub sauce: String,
}
impl fidl::Persistable for Pasta {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Pizza {
pub toppings: Vec<String>,
}
impl fidl::Persistable for Pizza {}
#[derive(Clone, Debug, PartialEq)]
pub struct StructWithNullableUnion {
pub x1: Option<Box<OlderSimpleUnion>>,
}
impl fidl::Persistable for StructWithNullableUnion {}
#[derive(Clone, Debug, PartialEq)]
pub struct TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse {
pub xu: OlderSimpleUnion,
}
impl fidl::Persistable for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse {
pub xu: StrictBoundedUnion,
}
impl fidl::Persistable for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse {}
#[derive(Clone, Debug, PartialEq)]
pub struct UnionSandwich {
pub a: u32,
pub u: ExplicitFlexibleUnion,
pub b: u32,
}
impl fidl::Persistable for UnionSandwich {}
#[derive(Clone, Debug)]
pub enum EmptyFlexibleUnion {
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
/// Pattern that matches an unknown `EmptyFlexibleUnion` member.
#[macro_export]
macro_rules! EmptyFlexibleUnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for EmptyFlexibleUnion {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
_ => false,
}
}
}
impl EmptyFlexibleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
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,
}
}
}
impl fidl::Persistable for EmptyFlexibleUnion {}
#[derive(Clone, Debug)]
pub enum ExplicitFlexibleUnion {
I(i64),
F(f32),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `ExplicitFlexibleUnion` member.
#[macro_export]
macro_rules! ExplicitFlexibleUnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for ExplicitFlexibleUnion {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::I(x), Self::I(y)) => *x == *y,
(Self::F(x), Self::F(y)) => *x == *y,
_ => false,
}
}
}
impl ExplicitFlexibleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 1,
Self::F(_) => 4,
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 ExplicitFlexibleUnion {}
#[derive(Clone, Debug)]
pub enum ExplicitFoo {
I(i32),
S(String),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `ExplicitFoo` member.
#[macro_export]
macro_rules! ExplicitFooUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for ExplicitFoo {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::I(x), Self::I(y)) => *x == *y,
(Self::S(x), Self::S(y)) => *x == *y,
_ => false,
}
}
}
impl ExplicitFoo {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 1,
Self::S(_) => 2,
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 ExplicitFoo {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ExplicitPizzaOrPasta {
Pizza(Pizza),
Pasta(Pasta),
}
impl ExplicitPizzaOrPasta {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Pizza(_) => 1,
Self::Pasta(_) => 4,
}
}
}
impl fidl::Persistable for ExplicitPizzaOrPasta {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ExplicitStrictFoo {
I(i32),
S(String),
}
impl ExplicitStrictFoo {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 2,
Self::S(_) => 3,
}
}
}
impl fidl::Persistable for ExplicitStrictFoo {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ExplicitUnion {
Primitive(i32),
StringNeedsConstructor(String),
}
impl ExplicitUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Primitive(_) => 1,
Self::StringNeedsConstructor(_) => 3,
}
}
}
impl fidl::Persistable for ExplicitUnion {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum FieldCollision {
FieldCollisionTag(i32),
}
impl FieldCollision {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::FieldCollisionTag(_) => 1,
}
}
}
impl fidl::Persistable for FieldCollision {}
#[derive(Clone, Debug)]
pub enum FlexibleFoo {
S(String),
I(i32),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `FlexibleFoo` member.
#[macro_export]
macro_rules! FlexibleFooUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for FlexibleFoo {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::S(x), Self::S(y)) => *x == *y,
(Self::I(x), Self::I(y)) => *x == *y,
_ => false,
}
}
}
impl FlexibleFoo {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::S(_) => 1,
Self::I(_) => 2,
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 FlexibleFoo {}
#[derive(Clone, Debug)]
pub enum FlexiblePizzaOrPasta {
Pizza(Pizza),
Pasta(Pasta),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `FlexiblePizzaOrPasta` member.
#[macro_export]
macro_rules! FlexiblePizzaOrPastaUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for FlexiblePizzaOrPasta {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Pizza(x), Self::Pizza(y)) => *x == *y,
(Self::Pasta(x), Self::Pasta(y)) => *x == *y,
_ => false,
}
}
}
impl FlexiblePizzaOrPasta {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Pizza(_) => 1,
Self::Pasta(_) => 2,
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 FlexiblePizzaOrPasta {}
#[derive(Clone, Debug)]
pub enum FlexibleUnion {
Primitive(i32),
StringNeedsConstructor(String),
VectorStringAlsoNeedsConstructor(Vec<String>),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `FlexibleUnion` member.
#[macro_export]
macro_rules! FlexibleUnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for FlexibleUnion {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Primitive(x), Self::Primitive(y)) => *x == *y,
(Self::StringNeedsConstructor(x), Self::StringNeedsConstructor(y)) => *x == *y,
(
Self::VectorStringAlsoNeedsConstructor(x),
Self::VectorStringAlsoNeedsConstructor(y),
) => *x == *y,
_ => false,
}
}
}
impl FlexibleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Primitive(_) => 1,
Self::StringNeedsConstructor(_) => 2,
Self::VectorStringAlsoNeedsConstructor(_) => 3,
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 FlexibleUnion {}
#[derive(Clone, Debug)]
pub enum NewerSimpleUnion {
I(i64),
S(String),
V(Vec<String>),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `NewerSimpleUnion` member.
#[macro_export]
macro_rules! NewerSimpleUnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for NewerSimpleUnion {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::I(x), Self::I(y)) => *x == *y,
(Self::S(x), Self::S(y)) => *x == *y,
(Self::V(x), Self::V(y)) => *x == *y,
_ => false,
}
}
}
impl NewerSimpleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 1,
Self::S(_) => 2,
Self::V(_) => 3,
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 NewerSimpleUnion {}
#[derive(Clone, Debug)]
pub enum OlderSimpleUnion {
I(i64),
F(f32),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `OlderSimpleUnion` member.
#[macro_export]
macro_rules! OlderSimpleUnionUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for OlderSimpleUnion {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::I(x), Self::I(y)) => *x == *y,
(Self::F(x), Self::F(y)) => *x == *y,
_ => false,
}
}
}
impl OlderSimpleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 1,
Self::F(_) => 2,
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 OlderSimpleUnion {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum PizzaOrPasta {
Pizza(Pizza),
Pasta(Pasta),
}
impl PizzaOrPasta {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Pizza(_) => 1,
Self::Pasta(_) => 2,
}
}
}
impl fidl::Persistable for PizzaOrPasta {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ReverseOrdinalUnion {
First(u32),
Second(u32),
}
impl ReverseOrdinalUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::First(_) => 1,
Self::Second(_) => 2,
}
}
}
impl fidl::Persistable for ReverseOrdinalUnion {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StrictBoundedUnion {
V(Vec<u8>),
}
impl StrictBoundedUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::V(_) => 1,
}
}
}
impl fidl::Persistable for StrictBoundedUnion {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StrictFoo {
S(String),
I(i32),
}
impl StrictFoo {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::S(_) => 1,
Self::I(_) => 2,
}
}
}
impl fidl::Persistable for StrictFoo {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StrictPizzaOrPasta {
Pizza(Pizza),
Pasta(Pasta),
}
impl StrictPizzaOrPasta {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Pizza(_) => 1,
Self::Pasta(_) => 2,
}
}
}
impl fidl::Persistable for StrictPizzaOrPasta {}
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum StrictSimpleUnion {
I(i32),
F(f32),
S(String),
}
impl StrictSimpleUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::I(_) => 1,
Self::F(_) => 2,
Self::S(_) => 3,
}
}
}
impl fidl::Persistable for StrictSimpleUnion {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum StrictUnion {
Primitive(i32),
StringNeedsConstructor(String),
VectorStringAlsoNeedsConstructor(Vec<String>),
}
impl StrictUnion {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Primitive(_) => 1,
Self::StringNeedsConstructor(_) => 2,
Self::VectorStringAlsoNeedsConstructor(_) => 3,
}
}
}
impl fidl::Persistable for StrictUnion {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Union {
Primitive(i32),
StringNeedsConstructor(String),
VectorStringAlsoNeedsConstructor(Vec<String>),
}
impl Union {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Primitive(_) => 1,
Self::StringNeedsConstructor(_) => 2,
Self::VectorStringAlsoNeedsConstructor(_) => 3,
}
}
}
impl fidl::Persistable for Union {}
#[derive(Clone, Debug)]
pub enum UnionContainingEmptyStruct {
Empty(Empty),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `UnionContainingEmptyStruct` member.
#[macro_export]
macro_rules! UnionContainingEmptyStructUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for UnionContainingEmptyStruct {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Empty(x), Self::Empty(y)) => *x == *y,
_ => false,
}
}
}
impl UnionContainingEmptyStruct {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Empty(_) => 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 UnionContainingEmptyStruct {}
#[derive(Clone, Debug)]
pub enum UnionWithAttributes {
X(i64),
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u64,
},
}
/// Pattern that matches an unknown `UnionWithAttributes` member.
#[macro_export]
macro_rules! UnionWithAttributesUnknown {
() => {
_
};
}
// Custom PartialEq so that unknown variants are not equal to themselves.
impl PartialEq for UnionWithAttributes {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::X(x), Self::X(y)) => *x == *y,
_ => false,
}
}
}
impl UnionWithAttributes {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::X(_) => 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 UnionWithAttributes {}
pub mod test_protocol_ordinals {
pub const STRICT_UNION_HENCE_RESPONSE_MAY_BE_STACK_ALLOCATED: u64 = 0x5bfca9479251b9c3;
pub const FLEXIBLE_UNION_HENCE_RESPONSE_MUST_BE_HEAP_ALLOCATED: u64 = 0x694fede3b8829ce2;
}
mod internal {
use super::*;
impl fidl::encoding::ValueTypeMarker for Empty {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Empty {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
1
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Empty>(offset);
encoder.write_num(0u8, offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
#[inline(always)]
fn new_empty() -> Self {
Self
}
#[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);
match decoder.read_num::<u8>(offset) {
0 => Ok(()),
_ => Err(fidl::Error::Invalid),
}
}
}
impl fidl::encoding::ValueTypeMarker for NullableUnionStruct {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for NullableUnionStruct {
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<NullableUnionStruct, D>
for &NullableUnionStruct
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<NullableUnionStruct>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<NullableUnionStruct, D>::encode(
(
<fidl::encoding::OptionalUnion<Union> as fidl::encoding::ValueTypeMarker>::borrow(&self.the_union),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<Union>, D>,
> fidl::encoding::Encode<NullableUnionStruct, 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::<NullableUnionStruct>(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 NullableUnionStruct {
#[inline(always)]
fn new_empty() -> Self {
Self { the_union: fidl::new_empty!(fidl::encoding::OptionalUnion<Union>, 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);
// Verify that padding bytes are zero.
fidl::decode!(
fidl::encoding::OptionalUnion<Union>,
D,
&mut self.the_union,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Pasta {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Pasta {
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<Pasta, D> for &Pasta {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Pasta>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<Pasta, D>::encode(
(<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
&self.sauce,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
> fidl::encoding::Encode<Pasta, 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::<Pasta>(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 Pasta {
#[inline(always)]
fn new_empty() -> Self {
Self { sauce: fidl::new_empty!(fidl::encoding::BoundedString<16>, 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);
// Verify that padding bytes are zero.
fidl::decode!(
fidl::encoding::BoundedString<16>,
D,
&mut self.sauce,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Pizza {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Pizza {
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<Pizza, D> for &Pizza {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Pizza>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<Pizza, D>::encode(
(
<fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>> as fidl::encoding::ValueTypeMarker>::borrow(&self.toppings),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<
fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>>,
D,
>,
> fidl::encoding::Encode<Pizza, 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::<Pizza>(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 Pizza {
#[inline(always)]
fn new_empty() -> Self {
Self {
toppings: fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>>,
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);
// Verify that padding bytes are zero.
fidl::decode!(
fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>>,
D,
&mut self.toppings,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for StructWithNullableUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StructWithNullableUnion {
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<StructWithNullableUnion, D> for &StructWithNullableUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StructWithNullableUnion>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<StructWithNullableUnion, D>::encode(
(
<fidl::encoding::OptionalUnion<OlderSimpleUnion> as fidl::encoding::ValueTypeMarker>::borrow(&self.x1),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<OlderSimpleUnion>, D>,
> fidl::encoding::Encode<StructWithNullableUnion, 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::<StructWithNullableUnion>(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 StructWithNullableUnion
{
#[inline(always)]
fn new_empty() -> Self {
Self { x1: fidl::new_empty!(fidl::encoding::OptionalUnion<OlderSimpleUnion>, 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);
// Verify that padding bytes are zero.
fidl::decode!(
fidl::encoding::OptionalUnion<OlderSimpleUnion>,
D,
&mut self.x1,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker
for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse
{
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker
for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse
{
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<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse, D>
for &TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<
TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse,
D,
>::encode(
(<OlderSimpleUnion as fidl::encoding::ValueTypeMarker>::borrow(&self.xu),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OlderSimpleUnion, D>>
fidl::encoding::Encode<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse, 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::<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse>(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 TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { xu: fidl::new_empty!(OlderSimpleUnion, 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);
// Verify that padding bytes are zero.
fidl::decode!(OlderSimpleUnion, D, &mut self.xu, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker
for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse
{
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker
for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse
{
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<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse, D>
for &TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<
TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse,
D,
>::encode(
(<StrictBoundedUnion as fidl::encoding::ValueTypeMarker>::borrow(&self.xu),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<StrictBoundedUnion, D>,
> fidl::encoding::Encode<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse, 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::<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse>(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 TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { xu: fidl::new_empty!(StrictBoundedUnion, 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);
// Verify that padding bytes are zero.
fidl::decode!(StrictBoundedUnion, D, &mut self.xu, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for UnionSandwich {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for UnionSandwich {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
32
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnionSandwich, D>
for &UnionSandwich
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UnionSandwich>(offset);
// Delegate to tuple encoding.
fidl::encoding::Encode::<UnionSandwich, D>::encode(
(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.a),
<ExplicitFlexibleUnion as fidl::encoding::ValueTypeMarker>::borrow(&self.u),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.b),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<u32, D>,
T1: fidl::encoding::Encode<ExplicitFlexibleUnion, D>,
T2: fidl::encoding::Encode<u32, D>,
> fidl::encoding::Encode<UnionSandwich, D> for (T0, T1, T2)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UnionSandwich>(offset);
// Zero out padding regions. There's no need to apply masks
// because the unmasked parts will be overwritten by fields.
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
(ptr as *mut u64).write_unaligned(0);
}
// Write the fields.
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 24, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnionSandwich {
#[inline(always)]
fn new_empty() -> Self {
Self {
a: fidl::new_empty!(u32, D),
u: fidl::new_empty!(ExplicitFlexibleUnion, D),
b: fidl::new_empty!(u32, 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);
// Verify that padding bytes are zero.
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(u32, D, &mut self.a, decoder, offset + 0, _depth)?;
fidl::decode!(ExplicitFlexibleUnion, D, &mut self.u, decoder, offset + 8, _depth)?;
fidl::decode!(u32, D, &mut self.b, decoder, offset + 24, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for EmptyFlexibleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for EmptyFlexibleUnion {
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<EmptyFlexibleUnion, D>
for &EmptyFlexibleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EmptyFlexibleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
EmptyFlexibleUnion::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EmptyFlexibleUnion {
#[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 {
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 {
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = EmptyFlexibleUnion::__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 ExplicitFlexibleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ExplicitFlexibleUnion {
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<ExplicitFlexibleUnion, D>
for &ExplicitFlexibleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ExplicitFlexibleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ExplicitFlexibleUnion::I(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
ExplicitFlexibleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32, D>(
<f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
ExplicitFlexibleUnion::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExplicitFlexibleUnion {
#[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 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4 => <f32 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 ExplicitFlexibleUnion::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitFlexibleUnion::I(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitFlexibleUnion::I(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
4 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitFlexibleUnion::F(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitFlexibleUnion::F(fidl::new_empty!(f32, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitFlexibleUnion::F(ref mut val) = self {
fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = ExplicitFlexibleUnion::__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 ExplicitFoo {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ExplicitFoo {
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<ExplicitFoo, D>
for &ExplicitFoo
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ExplicitFoo>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ExplicitFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
ExplicitFoo::S(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::UnboundedString,
D,
>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
ExplicitFoo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExplicitFoo {
#[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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <fidl::encoding::UnboundedString 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 ExplicitFoo::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitFoo::I(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitFoo::I(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitFoo::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self =
ExplicitFoo::S(fidl::new_empty!(fidl::encoding::UnboundedString, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitFoo::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = ExplicitFoo::__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 ExplicitPizzaOrPasta {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ExplicitPizzaOrPasta {
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<ExplicitPizzaOrPasta, D>
for &ExplicitPizzaOrPasta
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ExplicitPizzaOrPasta>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ExplicitPizzaOrPasta::Pizza(ref val) => {
fidl::encoding::encode_in_envelope::<Pizza, D>(
<Pizza as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
ExplicitPizzaOrPasta::Pasta(ref val) => {
fidl::encoding::encode_in_envelope::<Pasta, D>(
<Pasta as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExplicitPizzaOrPasta {
#[inline(always)]
fn new_empty() -> Self {
Self::Pizza(fidl::new_empty!(Pizza, 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 => <Pizza as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4 => <Pasta 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 ExplicitPizzaOrPasta::Pizza(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitPizzaOrPasta::Pizza(fidl::new_empty!(Pizza, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitPizzaOrPasta::Pizza(ref mut val) = self {
fidl::decode!(Pizza, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
4 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitPizzaOrPasta::Pasta(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitPizzaOrPasta::Pasta(fidl::new_empty!(Pasta, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitPizzaOrPasta::Pasta(ref mut val) = self {
fidl::decode!(Pasta, 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 ExplicitStrictFoo {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ExplicitStrictFoo {
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<ExplicitStrictFoo, D>
for &ExplicitStrictFoo
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ExplicitStrictFoo>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ExplicitStrictFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
ExplicitStrictFoo::S(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::UnboundedString,
D,
>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExplicitStrictFoo {
#[inline(always)]
fn new_empty() -> Self {
Self::I(fidl::new_empty!(i32, 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 {
2 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedString 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 {
2 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitStrictFoo::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitStrictFoo::I(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitStrictFoo::I(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitStrictFoo::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitStrictFoo::S(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitStrictFoo::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
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 ExplicitUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ExplicitUnion {
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<ExplicitUnion, D>
for &ExplicitUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ExplicitUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ExplicitUnion::Primitive(ref val) => {
fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
ExplicitUnion::StringNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, D>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ExplicitUnion {
#[inline(always)]
fn new_empty() -> Self {
Self::Primitive(fidl::new_empty!(i32, 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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedString 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 ExplicitUnion::Primitive(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitUnion::Primitive(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitUnion::Primitive(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let ExplicitUnion::StringNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ExplicitUnion::StringNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let ExplicitUnion::StringNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
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 FieldCollision {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FieldCollision {
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<FieldCollision, D>
for &FieldCollision
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FieldCollision>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
FieldCollision::FieldCollisionTag(ref val) => {
fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FieldCollision {
#[inline(always)]
fn new_empty() -> Self {
Self::FieldCollisionTag(fidl::new_empty!(i32, 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 => <i32 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 FieldCollision::FieldCollisionTag(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FieldCollision::FieldCollisionTag(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let FieldCollision::FieldCollisionTag(ref mut val) = self {
fidl::decode!(i32, 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 FlexibleFoo {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FlexibleFoo {
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<FlexibleFoo, D>
for &FlexibleFoo
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FlexibleFoo>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
FlexibleFoo::S(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::UnboundedString,
D,
>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
FlexibleFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
FlexibleFoo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexibleFoo {
#[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 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
decoder.context,
),
2 => <i32 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 FlexibleFoo::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self =
FlexibleFoo::S(fidl::new_empty!(fidl::encoding::UnboundedString, D));
}
#[allow(irrefutable_let_patterns)]
if let FlexibleFoo::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let FlexibleFoo::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexibleFoo::I(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let FlexibleFoo::I(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = FlexibleFoo::__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 FlexiblePizzaOrPasta {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FlexiblePizzaOrPasta {
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<FlexiblePizzaOrPasta, D>
for &FlexiblePizzaOrPasta
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FlexiblePizzaOrPasta>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
FlexiblePizzaOrPasta::Pizza(ref val) => {
fidl::encoding::encode_in_envelope::<Pizza, D>(
<Pizza as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
FlexiblePizzaOrPasta::Pasta(ref val) => {
fidl::encoding::encode_in_envelope::<Pasta, D>(
<Pasta as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
FlexiblePizzaOrPasta::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexiblePizzaOrPasta {
#[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 => <Pizza as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <Pasta 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 FlexiblePizzaOrPasta::Pizza(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexiblePizzaOrPasta::Pizza(fidl::new_empty!(Pizza, D));
}
#[allow(irrefutable_let_patterns)]
if let FlexiblePizzaOrPasta::Pizza(ref mut val) = self {
fidl::decode!(Pizza, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let FlexiblePizzaOrPasta::Pasta(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexiblePizzaOrPasta::Pasta(fidl::new_empty!(Pasta, D));
}
#[allow(irrefutable_let_patterns)]
if let FlexiblePizzaOrPasta::Pasta(ref mut val) = self {
fidl::decode!(Pasta, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = FlexiblePizzaOrPasta::__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 FlexibleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FlexibleUnion {
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<FlexibleUnion, D>
for &FlexibleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FlexibleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
FlexibleUnion::Primitive(ref val) => {
fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
FlexibleUnion::StringNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, D>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
FlexibleUnion::VectorStringAlsoNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, D>(
<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
FlexibleUnion::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FlexibleUnion {
#[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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> 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 FlexibleUnion::Primitive(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexibleUnion::Primitive(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let FlexibleUnion::Primitive(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let FlexibleUnion::StringNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexibleUnion::StringNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let FlexibleUnion::StringNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let FlexibleUnion::VectorStringAlsoNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = FlexibleUnion::VectorStringAlsoNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D
));
}
#[allow(irrefutable_let_patterns)]
if let FlexibleUnion::VectorStringAlsoNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = FlexibleUnion::__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 NewerSimpleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for NewerSimpleUnion {
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<NewerSimpleUnion, D>
for &NewerSimpleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<NewerSimpleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
NewerSimpleUnion::I(ref val) => {
fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
NewerSimpleUnion::S(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, D>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
NewerSimpleUnion::V(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, D>(
<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
NewerSimpleUnion::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NewerSimpleUnion {
#[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 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> 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 NewerSimpleUnion::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = NewerSimpleUnion::I(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let NewerSimpleUnion::I(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let NewerSimpleUnion::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = NewerSimpleUnion::S(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let NewerSimpleUnion::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let NewerSimpleUnion::V(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = NewerSimpleUnion::V(fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D
));
}
#[allow(irrefutable_let_patterns)]
if let NewerSimpleUnion::V(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = NewerSimpleUnion::__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 OlderSimpleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for OlderSimpleUnion {
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<OlderSimpleUnion, D>
for &OlderSimpleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<OlderSimpleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
OlderSimpleUnion::I(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
OlderSimpleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32, D>(
<f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
OlderSimpleUnion::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OlderSimpleUnion {
#[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 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <f32 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 OlderSimpleUnion::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = OlderSimpleUnion::I(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let OlderSimpleUnion::I(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let OlderSimpleUnion::F(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = OlderSimpleUnion::F(fidl::new_empty!(f32, D));
}
#[allow(irrefutable_let_patterns)]
if let OlderSimpleUnion::F(ref mut val) = self {
fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = OlderSimpleUnion::__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 PizzaOrPasta {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for PizzaOrPasta {
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<PizzaOrPasta, D>
for &PizzaOrPasta
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PizzaOrPasta>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
PizzaOrPasta::Pizza(ref val) => fidl::encoding::encode_in_envelope::<Pizza, D>(
<Pizza as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
PizzaOrPasta::Pasta(ref val) => fidl::encoding::encode_in_envelope::<Pasta, D>(
<Pasta as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PizzaOrPasta {
#[inline(always)]
fn new_empty() -> Self {
Self::Pizza(fidl::new_empty!(Pizza, 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 => <Pizza as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <Pasta 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 PizzaOrPasta::Pizza(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = PizzaOrPasta::Pizza(fidl::new_empty!(Pizza, D));
}
#[allow(irrefutable_let_patterns)]
if let PizzaOrPasta::Pizza(ref mut val) = self {
fidl::decode!(Pizza, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let PizzaOrPasta::Pasta(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = PizzaOrPasta::Pasta(fidl::new_empty!(Pasta, D));
}
#[allow(irrefutable_let_patterns)]
if let PizzaOrPasta::Pasta(ref mut val) = self {
fidl::decode!(Pasta, 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 ReverseOrdinalUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for ReverseOrdinalUnion {
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<ReverseOrdinalUnion, D>
for &ReverseOrdinalUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ReverseOrdinalUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
ReverseOrdinalUnion::First(ref val) => {
fidl::encoding::encode_in_envelope::<u32, D>(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
ReverseOrdinalUnion::Second(ref val) => {
fidl::encoding::encode_in_envelope::<u32, D>(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReverseOrdinalUnion {
#[inline(always)]
fn new_empty() -> Self {
Self::First(fidl::new_empty!(u32, 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 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <u32 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 ReverseOrdinalUnion::First(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ReverseOrdinalUnion::First(fidl::new_empty!(u32, D));
}
#[allow(irrefutable_let_patterns)]
if let ReverseOrdinalUnion::First(ref mut val) = self {
fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let ReverseOrdinalUnion::Second(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = ReverseOrdinalUnion::Second(fidl::new_empty!(u32, D));
}
#[allow(irrefutable_let_patterns)]
if let ReverseOrdinalUnion::Second(ref mut val) = self {
fidl::decode!(u32, 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 StrictBoundedUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StrictBoundedUnion {
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<StrictBoundedUnion, D>
for &StrictBoundedUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StrictBoundedUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
StrictBoundedUnion::V(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<u8, 10>, D>(
<fidl::encoding::Vector<u8, 10> as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictBoundedUnion {
#[inline(always)]
fn new_empty() -> Self {
Self::V(fidl::new_empty!(fidl::encoding::Vector<u8, 10>, 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::Vector<u8, 10> 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 StrictBoundedUnion::V(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictBoundedUnion::V(
fidl::new_empty!(fidl::encoding::Vector<u8, 10>, D),
);
}
#[allow(irrefutable_let_patterns)]
if let StrictBoundedUnion::V(ref mut val) = self {
fidl::decode!(fidl::encoding::Vector<u8, 10>, 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 StrictFoo {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StrictFoo {
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<StrictFoo, D>
for &StrictFoo
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StrictFoo>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
StrictFoo::S(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::UnboundedString,
D,
>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
StrictFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictFoo {
#[inline(always)]
fn new_empty() -> Self {
Self::S(fidl::new_empty!(fidl::encoding::UnboundedString, 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::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
decoder.context,
),
2 => <i32 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 StrictFoo::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictFoo::S(fidl::new_empty!(fidl::encoding::UnboundedString, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictFoo::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let StrictFoo::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictFoo::I(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictFoo::I(ref mut val) = self {
fidl::decode!(i32, 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 StrictPizzaOrPasta {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StrictPizzaOrPasta {
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<StrictPizzaOrPasta, D>
for &StrictPizzaOrPasta
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StrictPizzaOrPasta>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
StrictPizzaOrPasta::Pizza(ref val) => {
fidl::encoding::encode_in_envelope::<Pizza, D>(
<Pizza as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
StrictPizzaOrPasta::Pasta(ref val) => {
fidl::encoding::encode_in_envelope::<Pasta, D>(
<Pasta as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictPizzaOrPasta {
#[inline(always)]
fn new_empty() -> Self {
Self::Pizza(fidl::new_empty!(Pizza, 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 => <Pizza as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <Pasta 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 StrictPizzaOrPasta::Pizza(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictPizzaOrPasta::Pizza(fidl::new_empty!(Pizza, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictPizzaOrPasta::Pizza(ref mut val) = self {
fidl::decode!(Pizza, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let StrictPizzaOrPasta::Pasta(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictPizzaOrPasta::Pasta(fidl::new_empty!(Pasta, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictPizzaOrPasta::Pasta(ref mut val) = self {
fidl::decode!(Pasta, 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 StrictSimpleUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StrictSimpleUnion {
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<StrictSimpleUnion, D>
for &StrictSimpleUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StrictSimpleUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
StrictSimpleUnion::I(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
StrictSimpleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32, D>(
<f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
StrictSimpleUnion::S(ref val) => fidl::encoding::encode_in_envelope::<
fidl::encoding::UnboundedString,
D,
>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
val,
),
encoder,
offset + 8,
_depth,
),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictSimpleUnion {
#[inline(always)]
fn new_empty() -> Self {
Self::I(fidl::new_empty!(i32, 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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedString 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 StrictSimpleUnion::I(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictSimpleUnion::I(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictSimpleUnion::I(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let StrictSimpleUnion::F(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictSimpleUnion::F(fidl::new_empty!(f32, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictSimpleUnion::F(ref mut val) = self {
fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let StrictSimpleUnion::S(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictSimpleUnion::S(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let StrictSimpleUnion::S(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
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 StrictUnion {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StrictUnion {
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<StrictUnion, D>
for &StrictUnion
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StrictUnion>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
StrictUnion::Primitive(ref val) => {
fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
StrictUnion::StringNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, D>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
StrictUnion::VectorStringAlsoNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, D>(
<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StrictUnion {
#[inline(always)]
fn new_empty() -> Self {
Self::Primitive(fidl::new_empty!(i32, 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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> 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 StrictUnion::Primitive(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictUnion::Primitive(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let StrictUnion::Primitive(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let StrictUnion::StringNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictUnion::StringNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let StrictUnion::StringNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let StrictUnion::VectorStringAlsoNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = StrictUnion::VectorStringAlsoNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D
));
}
#[allow(irrefutable_let_patterns)]
if let StrictUnion::VectorStringAlsoNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
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 Union {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Union {
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<Union, D> for &Union {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Union>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
Union::Primitive(ref val) => {
fidl::encoding::encode_in_envelope::<i32, D>(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
Union::StringNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, D>(
<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
Union::VectorStringAlsoNeedsConstructor(ref val) => {
fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, D>(
<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder, offset + 8, _depth
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Union {
#[inline(always)]
fn new_empty() -> Self {
Self::Primitive(fidl::new_empty!(i32, 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 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> 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 Union::Primitive(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = Union::Primitive(fidl::new_empty!(i32, D));
}
#[allow(irrefutable_let_patterns)]
if let Union::Primitive(ref mut val) = self {
fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let Union::StringNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = Union::StringNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedString,
D
));
}
#[allow(irrefutable_let_patterns)]
if let Union::StringNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedString,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let Union::VectorStringAlsoNeedsConstructor(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = Union::VectorStringAlsoNeedsConstructor(fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
D
));
}
#[allow(irrefutable_let_patterns)]
if let Union::VectorStringAlsoNeedsConstructor(ref mut val) = self {
fidl::decode!(
fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
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 UnionContainingEmptyStruct {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for UnionContainingEmptyStruct {
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<UnionContainingEmptyStruct, D> for &UnionContainingEmptyStruct
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UnionContainingEmptyStruct>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
UnionContainingEmptyStruct::Empty(ref val) => {
fidl::encoding::encode_in_envelope::<Empty, D>(
<Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
UnionContainingEmptyStruct::__SourceBreaking { .. } => {
Err(fidl::Error::UnknownUnionTag)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for UnionContainingEmptyStruct
{
#[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 => <Empty 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 UnionContainingEmptyStruct::Empty(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = UnionContainingEmptyStruct::Empty(fidl::new_empty!(Empty, D));
}
#[allow(irrefutable_let_patterns)]
if let UnionContainingEmptyStruct::Empty(ref mut val) = self {
fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self =
UnionContainingEmptyStruct::__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 UnionWithAttributes {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for UnionWithAttributes {
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<UnionWithAttributes, D>
for &UnionWithAttributes
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UnionWithAttributes>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
UnionWithAttributes::X(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
UnionWithAttributes::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnionWithAttributes {
#[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 => <i64 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 UnionWithAttributes::X(_) = self {
// Do nothing, read the value into the object
} else {
// Initialize `self` to the right variant
*self = UnionWithAttributes::X(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let UnionWithAttributes::X(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = UnionWithAttributes::__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(())
}
}
}