| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = no_optional_structs |
| // fidl_experiment = output_index_json |
| // fidl_experiment = unknown_interactions |
| // fidl_experiment = unknown_interactions_mandate |
| |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)] |
| |
| use { |
| bitflags::bitflags, |
| fidl::{ |
| client::QueryResponseFut, |
| endpoints::{ControlHandle as _, Responder as _}, |
| }, |
| fuchsia_zircon_status as zx_status, |
| futures::future::{self, MaybeDone, TryFutureExt}, |
| }; |
| |
| #[cfg(target_os = "fuchsia")] |
| use fuchsia_zircon as zx; |
| |
| #[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 { |
| #[deprecated = "Use `EmptyFlexibleUnion::unknown()` to construct and `EmptyFlexibleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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 { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for EmptyFlexibleUnion {} |
| |
| #[derive(Clone, Debug)] |
| pub enum ExplicitFlexibleUnion { |
| I(i64), |
| F(f32), |
| #[deprecated = "Use `ExplicitFlexibleUnion::unknown()` to construct and `ExplicitFlexibleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for ExplicitFlexibleUnion {} |
| |
| #[derive(Clone, Debug)] |
| pub enum ExplicitFoo { |
| I(i32), |
| S(String), |
| #[deprecated = "Use `ExplicitFoo::unknown()` to construct and `ExplicitFooUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| impl fidl::Persistable for FieldCollision {} |
| |
| #[derive(Clone, Debug)] |
| pub enum FlexibleFoo { |
| S(String), |
| I(i32), |
| #[deprecated = "Use `FlexibleFoo::unknown()` to construct and `FlexibleFooUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for FlexibleFoo {} |
| |
| #[derive(Clone, Debug)] |
| pub enum FlexiblePizzaOrPasta { |
| Pizza(Pizza), |
| Pasta(Pasta), |
| #[deprecated = "Use `FlexiblePizzaOrPasta::unknown()` to construct and `FlexiblePizzaOrPastaUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for FlexiblePizzaOrPasta {} |
| |
| #[derive(Clone, Debug)] |
| pub enum FlexibleUnion { |
| Primitive(i32), |
| StringNeedsConstructor(String), |
| VectorStringAlsoNeedsConstructor(Vec<String>), |
| #[deprecated = "Use `FlexibleUnion::unknown()` to construct and `FlexibleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for FlexibleUnion {} |
| |
| #[derive(Clone, Debug)] |
| pub enum NewerSimpleUnion { |
| I(i64), |
| S(String), |
| V(Vec<String>), |
| #[deprecated = "Use `NewerSimpleUnion::unknown()` to construct and `NewerSimpleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for NewerSimpleUnion {} |
| |
| #[derive(Clone, Debug)] |
| pub enum OlderSimpleUnion { |
| I(i64), |
| F(f32), |
| #[deprecated = "Use `OlderSimpleUnion::unknown()` to construct and `OlderSimpleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for OlderSimpleUnion {} |
| |
| #[derive(Clone, Debug)] |
| pub enum OnlyReservedFlexibleUnion { |
| #[deprecated = "Use `OnlyReservedFlexibleUnion::unknown()` to construct and `OnlyReservedFlexibleUnionUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __Unknown { ordinal: u64 }, |
| } |
| |
| /// Pattern that matches an unknown `OnlyReservedFlexibleUnion` member. |
| #[macro_export] |
| macro_rules! OnlyReservedFlexibleUnionUnknown { |
| () => { |
| _ |
| }; |
| } |
| |
| // Custom PartialEq so that unknown variants are not equal to themselves. |
| impl PartialEq for OnlyReservedFlexibleUnion { |
| fn eq(&self, other: &Self) -> bool { |
| match (self, other) { |
| _ => false, |
| } |
| } |
| } |
| |
| impl OnlyReservedFlexibleUnion { |
| #[inline] |
| pub fn ordinal(&self) -> u64 { |
| match *self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for OnlyReservedFlexibleUnion {} |
| |
| #[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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| 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, |
| } |
| } |
| |
| #[deprecated = "Strict unions should not use `is_unknown`"] |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| false |
| } |
| } |
| |
| impl fidl::Persistable for Union {} |
| |
| #[derive(Clone, Debug)] |
| pub enum UnionContainingEmptyStruct { |
| Empty(Empty), |
| #[deprecated = "Use `UnionContainingEmptyStruct::unknown()` to construct and `UnionContainingEmptyStructUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for UnionContainingEmptyStruct {} |
| |
| #[derive(Clone, Debug)] |
| pub enum UnionWithAttributes { |
| X(i64), |
| #[deprecated = "Use `UnionWithAttributes::unknown()` to construct and `UnionWithAttributesUnknown!()` to exhaustively match."] |
| #[doc(hidden)] |
| #[non_exhaustive] |
| __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, |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal } => ordinal, |
| } |
| } |
| |
| #[inline] |
| pub fn unknown_variant_for_testing() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| pub fn is_unknown(&self) -> bool { |
| match self { |
| #[allow(deprecated)] |
| Self::__Unknown { .. } => true, |
| _ => false, |
| } |
| } |
| } |
| |
| impl fidl::Persistable for UnionWithAttributes {} |
| |
| #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| pub struct TestProtocolMarker; |
| |
| impl fidl::endpoints::ProtocolMarker for TestProtocolMarker { |
| type Proxy = TestProtocolProxy; |
| type RequestStream = TestProtocolRequestStream; |
| const DEBUG_NAME: &'static str = "(anonymous) TestProtocol"; |
| } |
| |
| pub trait TestProtocolProxyInterface: Send + Sync { |
| type StrictUnionHenceResponseMayBeStackAllocatedResponseFut: std::future::Future<Output = Result<StrictBoundedUnion, fidl::Error>> |
| + Send; |
| fn r#strict_union_hence_response_may_be_stack_allocated( |
| &self, |
| ) -> Self::StrictUnionHenceResponseMayBeStackAllocatedResponseFut; |
| type FlexibleUnionHenceResponseMustBeHeapAllocatedResponseFut: std::future::Future<Output = Result<OlderSimpleUnion, fidl::Error>> |
| + Send; |
| fn r#flexible_union_hence_response_must_be_heap_allocated( |
| &self, |
| ) -> Self::FlexibleUnionHenceResponseMustBeHeapAllocatedResponseFut; |
| } |
| |
| #[derive(Debug)] |
| #[cfg(target_os = "fuchsia")] |
| pub struct TestProtocolSynchronousProxy { |
| client: fidl::client::sync::Client, |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| impl TestProtocolSynchronousProxy { |
| pub fn new(channel: fidl::Channel) -> Self { |
| let protocol_name = <TestProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME; |
| Self { client: fidl::client::sync::Client::new(channel, protocol_name) } |
| } |
| |
| pub fn into_channel(self) -> fidl::Channel { |
| self.client.into_channel() |
| } |
| |
| /// Waits until an event arrives and returns it. It is safe for other |
| /// threads to make concurrent requests while waiting for an event. |
| pub fn wait_for_event(&self, deadline: zx::Time) -> Result<TestProtocolEvent, fidl::Error> { |
| TestProtocolEvent::decode(self.client.wait_for_event(deadline)?) |
| } |
| |
| pub fn r#strict_union_hence_response_may_be_stack_allocated( |
| &self, |
| ___deadline: zx::Time, |
| ) -> Result<StrictBoundedUnion, fidl::Error> { |
| let _response = self.client.send_query::< |
| fidl::encoding::EmptyPayload, |
| TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse, |
| >( |
| (), |
| 0x5bfca9479251b9c3, |
| fidl::encoding::DynamicFlags::empty(), |
| ___deadline, |
| )?; |
| Ok(_response.xu) |
| } |
| |
| pub fn r#flexible_union_hence_response_must_be_heap_allocated( |
| &self, |
| ___deadline: zx::Time, |
| ) -> Result<OlderSimpleUnion, fidl::Error> { |
| let _response = self.client.send_query::< |
| fidl::encoding::EmptyPayload, |
| TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse, |
| >( |
| (), |
| 0x694fede3b8829ce2, |
| fidl::encoding::DynamicFlags::empty(), |
| ___deadline, |
| )?; |
| Ok(_response.xu) |
| } |
| } |
| |
| #[derive(Debug, Clone)] |
| pub struct TestProtocolProxy { |
| client: fidl::client::Client, |
| } |
| |
| impl fidl::endpoints::Proxy for TestProtocolProxy { |
| type Protocol = TestProtocolMarker; |
| |
| fn from_channel(inner: fidl::AsyncChannel) -> Self { |
| Self::new(inner) |
| } |
| |
| fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> { |
| self.client.into_channel().map_err(|client| Self { client }) |
| } |
| |
| fn as_channel(&self) -> &::fidl::AsyncChannel { |
| self.client.as_channel() |
| } |
| } |
| |
| impl TestProtocolProxy { |
| /// Create a new Proxy for test.union/TestProtocol. |
| pub fn new(channel: fidl::AsyncChannel) -> Self { |
| let protocol_name = <TestProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME; |
| Self { client: fidl::client::Client::new(channel, protocol_name) } |
| } |
| |
| /// Get a Stream of events from the remote end of the protocol. |
| /// |
| /// # Panics |
| /// |
| /// Panics if the event stream was already taken. |
| pub fn take_event_stream(&self) -> TestProtocolEventStream { |
| TestProtocolEventStream { event_receiver: self.client.take_event_receiver() } |
| } |
| |
| pub fn r#strict_union_hence_response_may_be_stack_allocated( |
| &self, |
| ) -> fidl::client::QueryResponseFut<StrictBoundedUnion> { |
| TestProtocolProxyInterface::r#strict_union_hence_response_may_be_stack_allocated(self) |
| } |
| |
| pub fn r#flexible_union_hence_response_must_be_heap_allocated( |
| &self, |
| ) -> fidl::client::QueryResponseFut<OlderSimpleUnion> { |
| TestProtocolProxyInterface::r#flexible_union_hence_response_must_be_heap_allocated(self) |
| } |
| } |
| |
| impl TestProtocolProxyInterface for TestProtocolProxy { |
| type StrictUnionHenceResponseMayBeStackAllocatedResponseFut = |
| fidl::client::QueryResponseFut<StrictBoundedUnion>; |
| fn r#strict_union_hence_response_may_be_stack_allocated( |
| &self, |
| ) -> Self::StrictUnionHenceResponseMayBeStackAllocatedResponseFut { |
| fn _decode( |
| mut _buf: Result<fidl::MessageBufEtc, fidl::Error>, |
| ) -> Result<StrictBoundedUnion, fidl::Error> { |
| let _response = fidl::client::decode_transaction_body::< |
| TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse, |
| 0x5bfca9479251b9c3, |
| >(_buf?)?; |
| Ok(_response.xu) |
| } |
| self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StrictBoundedUnion>( |
| (), |
| 0x5bfca9479251b9c3, |
| fidl::encoding::DynamicFlags::empty(), |
| _decode, |
| ) |
| } |
| |
| type FlexibleUnionHenceResponseMustBeHeapAllocatedResponseFut = |
| fidl::client::QueryResponseFut<OlderSimpleUnion>; |
| fn r#flexible_union_hence_response_must_be_heap_allocated( |
| &self, |
| ) -> Self::FlexibleUnionHenceResponseMustBeHeapAllocatedResponseFut { |
| fn _decode( |
| mut _buf: Result<fidl::MessageBufEtc, fidl::Error>, |
| ) -> Result<OlderSimpleUnion, fidl::Error> { |
| let _response = fidl::client::decode_transaction_body::< |
| TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse, |
| 0x694fede3b8829ce2, |
| >(_buf?)?; |
| Ok(_response.xu) |
| } |
| self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, OlderSimpleUnion>( |
| (), |
| 0x694fede3b8829ce2, |
| fidl::encoding::DynamicFlags::empty(), |
| _decode, |
| ) |
| } |
| } |
| |
| pub struct TestProtocolEventStream { |
| event_receiver: fidl::client::EventReceiver, |
| } |
| |
| impl std::marker::Unpin for TestProtocolEventStream {} |
| |
| impl futures::stream::FusedStream for TestProtocolEventStream { |
| fn is_terminated(&self) -> bool { |
| self.event_receiver.is_terminated() |
| } |
| } |
| |
| impl futures::Stream for TestProtocolEventStream { |
| type Item = Result<TestProtocolEvent, fidl::Error>; |
| |
| fn poll_next( |
| mut self: std::pin::Pin<&mut Self>, |
| cx: &mut std::task::Context<'_>, |
| ) -> std::task::Poll<Option<Self::Item>> { |
| match futures::ready!(futures::stream::StreamExt::poll_next_unpin( |
| &mut self.event_receiver, |
| cx |
| )?) { |
| Some(buf) => std::task::Poll::Ready(Some(TestProtocolEvent::decode(buf))), |
| None => std::task::Poll::Ready(None), |
| } |
| } |
| } |
| |
| #[derive(Debug)] |
| pub enum TestProtocolEvent {} |
| |
| impl TestProtocolEvent { |
| /// Decodes a message buffer as a [`TestProtocolEvent`]. |
| fn decode(mut buf: fidl::MessageBufEtc) -> Result<TestProtocolEvent, fidl::Error> { |
| let (bytes, _handles) = buf.split_mut(); |
| let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?; |
| debug_assert_eq!(tx_header.tx_id, 0); |
| match tx_header.ordinal { |
| _ => Err(fidl::Error::UnknownOrdinal { |
| ordinal: tx_header.ordinal, |
| protocol_name: <TestProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME, |
| }), |
| } |
| } |
| } |
| |
| /// A Stream of incoming requests for test.union/TestProtocol. |
| pub struct TestProtocolRequestStream { |
| inner: std::sync::Arc<fidl::ServeInner>, |
| is_terminated: bool, |
| } |
| |
| impl std::marker::Unpin for TestProtocolRequestStream {} |
| |
| impl futures::stream::FusedStream for TestProtocolRequestStream { |
| fn is_terminated(&self) -> bool { |
| self.is_terminated |
| } |
| } |
| |
| impl fidl::endpoints::RequestStream for TestProtocolRequestStream { |
| type Protocol = TestProtocolMarker; |
| type ControlHandle = TestProtocolControlHandle; |
| |
| fn from_channel(channel: fidl::AsyncChannel) -> Self { |
| Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false } |
| } |
| |
| fn control_handle(&self) -> Self::ControlHandle { |
| TestProtocolControlHandle { inner: self.inner.clone() } |
| } |
| |
| fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) { |
| (self.inner, self.is_terminated) |
| } |
| |
| fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self { |
| Self { inner, is_terminated } |
| } |
| } |
| |
| impl futures::Stream for TestProtocolRequestStream { |
| type Item = Result<TestProtocolRequest, fidl::Error>; |
| |
| fn poll_next( |
| mut self: std::pin::Pin<&mut Self>, |
| cx: &mut std::task::Context<'_>, |
| ) -> std::task::Poll<Option<Self::Item>> { |
| let this = &mut *self; |
| if this.inner.check_shutdown(cx) { |
| this.is_terminated = true; |
| return std::task::Poll::Ready(None); |
| } |
| if this.is_terminated { |
| panic!("polled TestProtocolRequestStream after completion"); |
| } |
| fidl::encoding::with_tls_decode_buf(|bytes, handles| { |
| match this.inner.channel().read_etc(cx, bytes, handles) { |
| std::task::Poll::Ready(Ok(())) => {} |
| std::task::Poll::Pending => return std::task::Poll::Pending, |
| std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => { |
| this.is_terminated = true; |
| return std::task::Poll::Ready(None); |
| } |
| std::task::Poll::Ready(Err(e)) => { |
| return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e)))) |
| } |
| } |
| |
| // A message has been received from the channel |
| let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?; |
| |
| std::task::Poll::Ready(Some(match header.ordinal { |
| 0x5bfca9479251b9c3 => { |
| header.validate_request_tx_id(fidl::MethodType::TwoWay)?; |
| let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload); |
| fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>( |
| &header, |
| _body_bytes, |
| handles, |
| &mut req, |
| )?; |
| let control_handle = TestProtocolControlHandle { inner: this.inner.clone() }; |
| Ok(TestProtocolRequest::StrictUnionHenceResponseMayBeStackAllocated { |
| responder: |
| TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder { |
| control_handle: std::mem::ManuallyDrop::new(control_handle), |
| tx_id: header.tx_id, |
| }, |
| }) |
| } |
| 0x694fede3b8829ce2 => { |
| header.validate_request_tx_id(fidl::MethodType::TwoWay)?; |
| let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload); |
| fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>( |
| &header, |
| _body_bytes, |
| handles, |
| &mut req, |
| )?; |
| let control_handle = TestProtocolControlHandle { inner: this.inner.clone() }; |
| Ok(TestProtocolRequest::FlexibleUnionHenceResponseMustBeHeapAllocated { |
| responder: |
| TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder { |
| control_handle: std::mem::ManuallyDrop::new(control_handle), |
| tx_id: header.tx_id, |
| }, |
| }) |
| } |
| _ => Err(fidl::Error::UnknownOrdinal { |
| ordinal: header.ordinal, |
| protocol_name: |
| <TestProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME, |
| }), |
| })) |
| }) |
| } |
| } |
| |
| #[derive(Debug)] |
| pub enum TestProtocolRequest { |
| StrictUnionHenceResponseMayBeStackAllocated { |
| responder: TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder, |
| }, |
| FlexibleUnionHenceResponseMustBeHeapAllocated { |
| responder: TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder, |
| }, |
| } |
| |
| impl TestProtocolRequest { |
| #[allow(irrefutable_let_patterns)] |
| pub fn into_strict_union_hence_response_may_be_stack_allocated( |
| self, |
| ) -> Option<(TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder)> { |
| if let TestProtocolRequest::StrictUnionHenceResponseMayBeStackAllocated { responder } = self |
| { |
| Some((responder)) |
| } else { |
| None |
| } |
| } |
| |
| #[allow(irrefutable_let_patterns)] |
| pub fn into_flexible_union_hence_response_must_be_heap_allocated( |
| self, |
| ) -> Option<(TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder)> { |
| if let TestProtocolRequest::FlexibleUnionHenceResponseMustBeHeapAllocated { responder } = |
| self |
| { |
| Some((responder)) |
| } else { |
| None |
| } |
| } |
| |
| /// Name of the method defined in FIDL |
| pub fn method_name(&self) -> &'static str { |
| match *self { |
| TestProtocolRequest::StrictUnionHenceResponseMayBeStackAllocated { .. } => { |
| "strict_union_hence_response_may_be_stack_allocated" |
| } |
| TestProtocolRequest::FlexibleUnionHenceResponseMustBeHeapAllocated { .. } => { |
| "flexible_union_hence_response_must_be_heap_allocated" |
| } |
| } |
| } |
| } |
| |
| #[derive(Debug, Clone)] |
| pub struct TestProtocolControlHandle { |
| inner: std::sync::Arc<fidl::ServeInner>, |
| } |
| |
| impl fidl::endpoints::ControlHandle for TestProtocolControlHandle { |
| fn shutdown(&self) { |
| self.inner.shutdown() |
| } |
| |
| fn shutdown_with_epitaph(&self, status: zx_status::Status) { |
| self.inner.shutdown_with_epitaph(status) |
| } |
| |
| fn is_closed(&self) -> bool { |
| self.inner.channel().is_closed() |
| } |
| |
| fn on_closed<'a>(&'a self) -> fidl::OnSignals<'a> { |
| self.inner.channel().on_closed() |
| } |
| } |
| |
| impl TestProtocolControlHandle {} |
| |
| #[must_use = "FIDL methods require a response to be sent"] |
| #[derive(Debug)] |
| pub struct TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder { |
| control_handle: std::mem::ManuallyDrop<TestProtocolControlHandle>, |
| tx_id: u32, |
| } |
| |
| /// Set the the channel to be shutdown (see [`TestProtocolControlHandle::shutdown`]) |
| /// if the responder is dropped without sending a response, so that the client |
| /// doesn't hang. To prevent this behavior, call `drop_without_shutdown`. |
| impl std::ops::Drop for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder { |
| fn drop(&mut self) { |
| self.control_handle.shutdown(); |
| // Safety: drops once, never accessed again |
| unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) }; |
| } |
| } |
| |
| impl fidl::endpoints::Responder |
| for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder |
| { |
| type ControlHandle = TestProtocolControlHandle; |
| |
| fn control_handle(&self) -> &TestProtocolControlHandle { |
| &self.control_handle |
| } |
| |
| fn drop_without_shutdown(mut self) { |
| // Safety: drops once, never accessed again due to mem::forget |
| unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) }; |
| // Prevent Drop from running (which would shut down the channel) |
| std::mem::forget(self); |
| } |
| } |
| |
| impl TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponder { |
| /// Sends a response to the FIDL transaction. |
| /// |
| /// Sets the channel to shutdown if an error occurs. |
| pub fn send(self, mut xu: &StrictBoundedUnion) -> Result<(), fidl::Error> { |
| let _result = self.send_raw(xu); |
| if _result.is_err() { |
| self.control_handle.shutdown(); |
| } |
| self.drop_without_shutdown(); |
| _result |
| } |
| |
| /// Similar to "send" but does not shutdown the channel if an error occurs. |
| pub fn send_no_shutdown_on_err(self, mut xu: &StrictBoundedUnion) -> Result<(), fidl::Error> { |
| let _result = self.send_raw(xu); |
| self.drop_without_shutdown(); |
| _result |
| } |
| |
| fn send_raw(&self, mut xu: &StrictBoundedUnion) -> Result<(), fidl::Error> { |
| self.control_handle |
| .inner |
| .send::<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse>( |
| (xu,), |
| self.tx_id, |
| 0x5bfca9479251b9c3, |
| fidl::encoding::DynamicFlags::empty(), |
| ) |
| } |
| } |
| |
| #[must_use = "FIDL methods require a response to be sent"] |
| #[derive(Debug)] |
| pub struct TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder { |
| control_handle: std::mem::ManuallyDrop<TestProtocolControlHandle>, |
| tx_id: u32, |
| } |
| |
| /// Set the the channel to be shutdown (see [`TestProtocolControlHandle::shutdown`]) |
| /// if the responder is dropped without sending a response, so that the client |
| /// doesn't hang. To prevent this behavior, call `drop_without_shutdown`. |
| impl std::ops::Drop for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder { |
| fn drop(&mut self) { |
| self.control_handle.shutdown(); |
| // Safety: drops once, never accessed again |
| unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) }; |
| } |
| } |
| |
| impl fidl::endpoints::Responder |
| for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder |
| { |
| type ControlHandle = TestProtocolControlHandle; |
| |
| fn control_handle(&self) -> &TestProtocolControlHandle { |
| &self.control_handle |
| } |
| |
| fn drop_without_shutdown(mut self) { |
| // Safety: drops once, never accessed again due to mem::forget |
| unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) }; |
| // Prevent Drop from running (which would shut down the channel) |
| std::mem::forget(self); |
| } |
| } |
| |
| impl TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponder { |
| /// Sends a response to the FIDL transaction. |
| /// |
| /// Sets the channel to shutdown if an error occurs. |
| pub fn send(self, mut xu: &OlderSimpleUnion) -> Result<(), fidl::Error> { |
| let _result = self.send_raw(xu); |
| if _result.is_err() { |
| self.control_handle.shutdown(); |
| } |
| self.drop_without_shutdown(); |
| _result |
| } |
| |
| /// Similar to "send" but does not shutdown the channel if an error occurs. |
| pub fn send_no_shutdown_on_err(self, mut xu: &OlderSimpleUnion) -> Result<(), fidl::Error> { |
| let _result = self.send_raw(xu); |
| self.drop_without_shutdown(); |
| _result |
| } |
| |
| fn send_raw(&self, mut xu: &OlderSimpleUnion) -> Result<(), fidl::Error> { |
| self.control_handle |
| .inner |
| .send::<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse>( |
| (xu,), |
| self.tx_id, |
| 0x694fede3b8829ce2, |
| fidl::encoding::DynamicFlags::empty(), |
| ) |
| } |
| } |
| |
| mod internal { |
| use super::*; |
| |
| unsafe impl fidl::encoding::TypeMarker for Empty { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 1, |
| fidl::encoding::WireFormatVersion::V2 => 1, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 1, |
| fidl::encoding::WireFormatVersion::V2 => 1, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for Empty { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<Empty> for &Empty { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<Empty>(offset); |
| encoder.write_num(0u8, offset); |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for Empty { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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), |
| } |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for NullableUnionStruct { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for NullableUnionStruct { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<NullableUnionStruct> for &NullableUnionStruct { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<NullableUnionStruct>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<NullableUnionStruct>::encode( |
| ( |
| <fidl::encoding::OptionalUnion<Union> as fidl::encoding::ValueTypeMarker>::borrow(&self.the_union), |
| ), |
| encoder, offset, _depth |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<Union>>> |
| fidl::encoding::Encode<NullableUnionStruct> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for NullableUnionStruct { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { the_union: fidl::new_empty!(fidl::encoding::OptionalUnion<Union>) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!( |
| fidl::encoding::OptionalUnion<Union>, |
| &mut self.the_union, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for Pasta { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 16, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for Pasta { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<Pasta> for &Pasta { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<Pasta>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<Pasta>::encode( |
| (<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow( |
| &self.sauce, |
| ),), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>>> |
| fidl::encoding::Encode<Pasta> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for Pasta { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { sauce: fidl::new_empty!(fidl::encoding::BoundedString<16>) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!( |
| fidl::encoding::BoundedString<16>, |
| &mut self.sauce, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for Pizza { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 16, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for Pizza { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<Pizza> for &Pizza { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<Pizza>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<Pizza>::encode( |
| ( |
| <fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>> as fidl::encoding::ValueTypeMarker>::borrow(&self.toppings), |
| ), |
| encoder, offset, _depth |
| ) |
| } |
| } |
| unsafe impl< |
| T0: fidl::encoding::Encode< |
| fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>>, |
| >, |
| > fidl::encoding::Encode<Pizza> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for Pizza { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { |
| toppings: fidl::new_empty!( |
| fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>> |
| ), |
| } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!( |
| fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<16>>, |
| &mut self.toppings, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for StructWithNullableUnion { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StructWithNullableUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StructWithNullableUnion> for &StructWithNullableUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<StructWithNullableUnion>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<StructWithNullableUnion>::encode( |
| ( |
| <fidl::encoding::OptionalUnion<OlderSimpleUnion> as fidl::encoding::ValueTypeMarker>::borrow(&self.x1), |
| ), |
| encoder, offset, _depth |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<OlderSimpleUnion>>> |
| fidl::encoding::Encode<StructWithNullableUnion> for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StructWithNullableUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { x1: fidl::new_empty!(fidl::encoding::OptionalUnion<OlderSimpleUnion>) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!( |
| fidl::encoding::OptionalUnion<OlderSimpleUnion>, |
| &mut self.x1, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker |
| for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse |
| { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker |
| for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse |
| { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl |
| fidl::encoding::Encode<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse> |
| for &TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::< |
| TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse, |
| >::encode( |
| (<OlderSimpleUnion as fidl::encoding::ValueTypeMarker>::borrow(&self.xu),), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<OlderSimpleUnion>> |
| fidl::encoding::Encode<TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse> |
| for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> |
| for TestProtocolFlexibleUnionHenceResponseMustBeHeapAllocatedResponse |
| { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { xu: fidl::new_empty!(OlderSimpleUnion) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!(OlderSimpleUnion, &mut self.xu, decoder, offset + member_offset, _depth)?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker |
| for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse |
| { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker |
| for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse |
| { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl |
| fidl::encoding::Encode<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse> |
| for &TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse>::encode( |
| ( |
| <StrictBoundedUnion as fidl::encoding::ValueTypeMarker>::borrow(&self.xu), |
| ), |
| encoder, offset, _depth |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<StrictBoundedUnion>> |
| fidl::encoding::Encode<TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse> |
| for (T0,) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> |
| for TestProtocolStrictUnionHenceResponseMayBeStackAllocatedResponse |
| { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { xu: fidl::new_empty!(StrictBoundedUnion) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!( |
| StrictBoundedUnion, |
| &mut self.xu, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for UnionSandwich { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 40, |
| fidl::encoding::WireFormatVersion::V2 => 32, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for UnionSandwich { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<UnionSandwich> for &UnionSandwich { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<UnionSandwich>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<UnionSandwich>::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< |
| T0: fidl::encoding::Encode<u32>, |
| T1: fidl::encoding::Encode<ExplicitFlexibleUnion>, |
| T2: fidl::encoding::Encode<u32>, |
| > fidl::encoding::Encode<UnionSandwich> for (T0, T1, T2) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => { |
| 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(32); |
| (ptr as *mut u64).write_unaligned(0); |
| } |
| } |
| fidl::encoding::WireFormatVersion::V2 => { |
| 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. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| }; |
| self.1.encode(encoder, offset + member_offset, depth)?; |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 32, |
| fidl::encoding::WireFormatVersion::V2 => 24, |
| }; |
| self.2.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for UnionSandwich { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { |
| a: fidl::new_empty!(u32), |
| u: fidl::new_empty!(ExplicitFlexibleUnion), |
| b: fidl::new_empty!(u32), |
| } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => { |
| let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) }; |
| let padval = unsafe { (ptr as *const u64).read_unaligned() }; |
| let maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 0 |
| + ((0xffffffff00000000u64 as u64).trailing_zeros() / 8) as usize, |
| }); |
| } |
| let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) }; |
| let padval = unsafe { (ptr as *const u64).read_unaligned() }; |
| let maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 32 |
| + ((0xffffffff00000000u64 as u64).trailing_zeros() / 8) as usize, |
| }); |
| } |
| } |
| fidl::encoding::WireFormatVersion::V2 => { |
| let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) }; |
| let padval = unsafe { (ptr as *const u64).read_unaligned() }; |
| let maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 0 |
| + ((0xffffffff00000000u64 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 maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 24 |
| + ((0xffffffff00000000u64 as u64).trailing_zeros() / 8) as usize, |
| }); |
| } |
| } |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!(u32, &mut self.a, decoder, offset + member_offset, _depth)?; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| }; |
| fidl::decode!( |
| ExplicitFlexibleUnion, |
| &mut self.u, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 32, |
| fidl::encoding::WireFormatVersion::V2 => 24, |
| }; |
| fidl::decode!(u32, &mut self.b, decoder, offset + member_offset, _depth)?; |
| Ok(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for EmptyFlexibleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<EmptyFlexibleUnion> for &EmptyFlexibleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<EmptyFlexibleUnion>(offset); |
| encoder.write_num::<u64>(self.ordinal(), offset); |
| match self { |
| #[allow(deprecated)] |
| EmptyFlexibleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for EmptyFlexibleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ExplicitFlexibleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ExplicitFlexibleUnion> for &ExplicitFlexibleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i64 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| ExplicitFlexibleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32>( |
| <f32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| #[allow(deprecated)] |
| ExplicitFlexibleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ExplicitFlexibleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitFlexibleUnion::I(ref mut val) = self { |
| fidl::decode!(i64, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitFlexibleUnion::F(ref mut val) = self { |
| fidl::decode!(f32, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = ExplicitFlexibleUnion::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ExplicitFoo { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ExplicitFoo> for &ExplicitFoo { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| ExplicitFoo::S(ref val) => fidl::encoding::encode_in_envelope::< |
| fidl::encoding::UnboundedString, |
| >( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| #[allow(deprecated)] |
| ExplicitFoo::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ExplicitFoo { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitFoo::I(ref mut val) = self { |
| fidl::decode!(i32, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitFoo::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| val, |
| decoder, |
| _inner_offset, |
| depth |
| )?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = ExplicitFoo::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ExplicitPizzaOrPasta { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ExplicitPizzaOrPasta> for &ExplicitPizzaOrPasta { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <Pizza as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| ExplicitPizzaOrPasta::Pasta(ref val) => { |
| fidl::encoding::encode_in_envelope::<Pasta>( |
| <Pasta as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ExplicitPizzaOrPasta { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Pizza(fidl::new_empty!(Pizza)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitPizzaOrPasta::Pizza(ref mut val) = self { |
| fidl::decode!(Pizza, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitPizzaOrPasta::Pasta(ref mut val) = self { |
| fidl::decode!(Pasta, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ExplicitStrictFoo { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ExplicitStrictFoo> for &ExplicitStrictFoo { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| ExplicitStrictFoo::S(ref val) => fidl::encoding::encode_in_envelope::< |
| fidl::encoding::UnboundedString, |
| >( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ExplicitStrictFoo { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::I(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitStrictFoo::I(ref mut val) = self { |
| fidl::decode!(i32, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitStrictFoo::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ExplicitUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ExplicitUnion> for &ExplicitUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| ExplicitUnion::StringNeedsConstructor(ref val) => { |
| fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString>( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ExplicitUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Primitive(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitUnion::Primitive(ref mut val) = self { |
| fidl::decode!(i32, 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 |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ExplicitUnion::StringNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for FieldCollision { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<FieldCollision> for &FieldCollision { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for FieldCollision { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::FieldCollisionTag(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FieldCollision::FieldCollisionTag(ref mut val) = self { |
| fidl::decode!(i32, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for FlexibleFoo { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<FlexibleFoo> for &FlexibleFoo { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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, |
| >( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| FlexibleFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| #[allow(deprecated)] |
| FlexibleFoo::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for FlexibleFoo { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexibleFoo::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexibleFoo::I(ref mut val) = self { |
| fidl::decode!(i32, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = FlexibleFoo::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for FlexiblePizzaOrPasta { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<FlexiblePizzaOrPasta> for &FlexiblePizzaOrPasta { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <Pizza as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| FlexiblePizzaOrPasta::Pasta(ref val) => { |
| fidl::encoding::encode_in_envelope::<Pasta>( |
| <Pasta as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| #[allow(deprecated)] |
| FlexiblePizzaOrPasta::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for FlexiblePizzaOrPasta { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexiblePizzaOrPasta::Pizza(ref mut val) = self { |
| fidl::decode!(Pizza, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexiblePizzaOrPasta::Pasta(ref mut val) = self { |
| fidl::decode!(Pasta, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = FlexiblePizzaOrPasta::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for FlexibleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<FlexibleUnion> for &FlexibleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| FlexibleUnion::StringNeedsConstructor(ref val) => { |
| fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString>( |
| <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>>( |
| <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| #[allow(deprecated)] |
| FlexibleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for FlexibleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexibleUnion::Primitive(ref mut val) = self { |
| fidl::decode!(i32, 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 |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexibleUnion::StringNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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> |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let FlexibleUnion::VectorStringAlsoNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, |
| val, |
| decoder, |
| _inner_offset, |
| depth |
| )?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = FlexibleUnion::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for NewerSimpleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<NewerSimpleUnion> for &NewerSimpleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i64 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| NewerSimpleUnion::S(ref val) => { |
| fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString>( |
| <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>>( |
| <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| #[allow(deprecated)] |
| NewerSimpleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for NewerSimpleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let NewerSimpleUnion::I(ref mut val) = self { |
| fidl::decode!(i64, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let NewerSimpleUnion::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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> |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let NewerSimpleUnion::V(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, |
| val, |
| decoder, |
| _inner_offset, |
| depth |
| )?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = NewerSimpleUnion::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for OlderSimpleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<OlderSimpleUnion> for &OlderSimpleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i64 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| OlderSimpleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32>( |
| <f32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| #[allow(deprecated)] |
| OlderSimpleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for OlderSimpleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let OlderSimpleUnion::I(ref mut val) = self { |
| fidl::decode!(i64, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let OlderSimpleUnion::F(ref mut val) = self { |
| fidl::decode!(f32, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = OlderSimpleUnion::__Unknown { 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(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for OnlyReservedFlexibleUnion { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 8 |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for OnlyReservedFlexibleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<OnlyReservedFlexibleUnion> for &OnlyReservedFlexibleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<OnlyReservedFlexibleUnion>(offset); |
| encoder.write_num::<u64>(self.ordinal(), offset); |
| match self { |
| #[allow(deprecated)] |
| OnlyReservedFlexibleUnion::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for OnlyReservedFlexibleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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 = OnlyReservedFlexibleUnion::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for PizzaOrPasta { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<PizzaOrPasta> for &PizzaOrPasta { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <Pizza as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| PizzaOrPasta::Pasta(ref val) => fidl::encoding::encode_in_envelope::<Pasta>( |
| <Pasta as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for PizzaOrPasta { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Pizza(fidl::new_empty!(Pizza)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let PizzaOrPasta::Pizza(ref mut val) = self { |
| fidl::decode!(Pizza, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let PizzaOrPasta::Pasta(ref mut val) = self { |
| fidl::decode!(Pasta, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for ReverseOrdinalUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<ReverseOrdinalUnion> for &ReverseOrdinalUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <u32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| ReverseOrdinalUnion::Second(ref val) => fidl::encoding::encode_in_envelope::<u32>( |
| <u32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for ReverseOrdinalUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::First(fidl::new_empty!(u32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ReverseOrdinalUnion::First(ref mut val) = self { |
| fidl::decode!(u32, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let ReverseOrdinalUnion::Second(ref mut val) = self { |
| fidl::decode!(u32, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StrictBoundedUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StrictBoundedUnion> for &StrictBoundedUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>>( |
| <fidl::encoding::Vector<u8, 10> as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StrictBoundedUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::V(fidl::new_empty!(fidl::encoding::Vector<u8, 10>)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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>)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictBoundedUnion::V(ref mut val) = self { |
| fidl::decode!(fidl::encoding::Vector<u8, 10>, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StrictFoo { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StrictFoo> for &StrictFoo { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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, |
| >( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| StrictFoo::I(ref val) => fidl::encoding::encode_in_envelope::<i32>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StrictFoo { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::S(fidl::new_empty!(fidl::encoding::UnboundedString)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictFoo::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictFoo::I(ref mut val) = self { |
| fidl::decode!(i32, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StrictPizzaOrPasta { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StrictPizzaOrPasta> for &StrictPizzaOrPasta { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <Pizza as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| StrictPizzaOrPasta::Pasta(ref val) => fidl::encoding::encode_in_envelope::<Pasta>( |
| <Pasta as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StrictPizzaOrPasta { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Pizza(fidl::new_empty!(Pizza)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictPizzaOrPasta::Pizza(ref mut val) = self { |
| fidl::decode!(Pizza, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictPizzaOrPasta::Pasta(ref mut val) = self { |
| fidl::decode!(Pasta, 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StrictSimpleUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StrictSimpleUnion> for &StrictSimpleUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| StrictSimpleUnion::F(ref val) => fidl::encoding::encode_in_envelope::<f32>( |
| <f32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| StrictSimpleUnion::S(ref val) => fidl::encoding::encode_in_envelope::< |
| fidl::encoding::UnboundedString, |
| >( |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| val, |
| ), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StrictSimpleUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::I(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictSimpleUnion::I(ref mut val) = self { |
| fidl::decode!(i32, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictSimpleUnion::F(ref mut val) = self { |
| fidl::decode!(f32, 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictSimpleUnion::S(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for StrictUnion { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<StrictUnion> for &StrictUnion { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| StrictUnion::StringNeedsConstructor(ref val) => { |
| fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString>( |
| <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>>( |
| <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for StrictUnion { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Primitive(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictUnion::Primitive(ref mut val) = self { |
| fidl::decode!(i32, 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 |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictUnion::StringNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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> |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let StrictUnion::VectorStringAlsoNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, |
| 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for Union { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<Union> for &Union { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i32 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| Union::StringNeedsConstructor(ref val) => { |
| fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString>( |
| <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>>( |
| <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, offset + 8, _depth |
| ) |
| } |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for Union { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self::Primitive(fidl::new_empty!(i32)) |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let Union::Primitive(ref mut val) = self { |
| fidl::decode!(i32, 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 |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let Union::StringNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| 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> |
| )); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let Union::VectorStringAlsoNeedsConstructor(ref mut val) = self { |
| fidl::decode!( |
| fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, |
| 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for UnionContainingEmptyStruct { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<UnionContainingEmptyStruct> for &UnionContainingEmptyStruct { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <Empty as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ) |
| } |
| #[allow(deprecated)] |
| UnionContainingEmptyStruct::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for UnionContainingEmptyStruct { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let UnionContainingEmptyStruct::Empty(ref mut val) = self { |
| fidl::decode!(Empty, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = UnionContainingEmptyStruct::__Unknown { 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(()) |
| } |
| } |
| |
| 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 { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 16, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for UnionWithAttributes { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<UnionWithAttributes> for &UnionWithAttributes { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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>( |
| <i64 as fidl::encoding::ValueTypeMarker>::borrow(val), |
| encoder, |
| offset + 8, |
| _depth, |
| ), |
| #[allow(deprecated)] |
| UnionWithAttributes::__Unknown { .. } => Err(fidl::Error::UnknownUnionTag), |
| } |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for UnionWithAttributes { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| #[allow(deprecated)] |
| Self::__Unknown { ordinal: 0 } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| 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 let fidl::encoding::WireFormatVersion::V2 = decoder.context.wire_format_version { |
| 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)); |
| } |
| #[allow(irrefutable_let_patterns)] |
| if let UnionWithAttributes::X(ref mut val) = self { |
| fidl::decode!(i64, val, decoder, _inner_offset, depth)?; |
| } else { |
| unreachable!() |
| } |
| } |
| #[allow(deprecated)] |
| ordinal => { |
| for _ in 0..num_handles { |
| decoder.drop_next_handle()?; |
| } |
| *self = UnionWithAttributes::__Unknown { 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(()) |
| } |
| } |
| } |