// @generated by Thrift for thrift/compiler/test/fixtures/basic/src/module.thrift
// This file is probably not the place you want to edit!


#![recursion_limit = "100000000"]
#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, clippy::redundant_closure, clippy::type_complexity)]

pub mod consts;
#[doc(inline)]
pub use self::consts::*;
pub mod services;

#[allow(unused_imports)]
pub(crate) use crate as types;

pub use crate::types::MyEnum as MyEnumAlias;

pub type MyDataItemAlias = crate::types::MyDataItem;

#[derive(Clone, PartialEq)]
pub struct MyStruct {
    pub MyIntField: ::std::primitive::i64,
    pub MyStringField: ::std::string::String,
    pub MyDataField: crate::types::MyDataItemAlias,
    pub myEnum: crate::types::MyEnum,
    pub oneway: ::std::primitive::bool,
    pub readonly: ::std::primitive::bool,
    pub idempotent: ::std::primitive::bool,
    pub floatSet: ::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>,
    pub no_hack_codegen_field: ::std::string::String,
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

#[derive(Clone, PartialEq)]
pub struct Containers {
    pub I32List: ::std::vec::Vec<::std::primitive::i32>,
    pub StringSet: ::std::collections::BTreeSet<::std::string::String>,
    pub StringToI64Map: ::std::collections::BTreeMap<::std::string::String, ::std::primitive::i64>,
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MyDataItem {
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

#[derive(Clone, PartialEq, Debug)]
pub enum MyUnion {
    myEnum(crate::types::MyEnumAlias),
    myStruct(crate::types::MyStruct),
    myDataItem(crate::types::MyDataItem),
    floatSet(::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>),
    UnknownField(::std::primitive::i32),
}

#[derive(Clone, PartialEq)]
pub struct MyException {
    pub MyIntField: ::std::primitive::i64,
    pub MyStringField: ::std::string::String,
    pub myStruct: crate::types::MyStruct,
    pub myUnion: crate::types::MyUnion,
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

impl ::fbthrift::ExceptionInfo for MyException {
    fn exn_value(&self) -> String {
        format!("{:?}", self)
    }

    #[inline]
    fn exn_is_declared(&self) -> bool { true }
}

impl ::std::error::Error for MyException {}

impl ::std::fmt::Display for MyException {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(f, "{:?}", self)
    }
}

#[derive(Clone, PartialEq)]
pub struct MyExceptionWithMessage {
    pub MyIntField: ::std::primitive::i64,
    pub MyStringField: ::std::string::String,
    pub myStruct: crate::types::MyStruct,
    pub myUnion: crate::types::MyUnion,
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

impl ::fbthrift::ExceptionInfo for MyExceptionWithMessage {
    fn exn_value(&self) -> String {
        format!("{:?}", self)
    }

    #[inline]
    fn exn_is_declared(&self) -> bool { true }
}

impl ::std::error::Error for MyExceptionWithMessage {}

impl ::std::fmt::Display for MyExceptionWithMessage {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(f, "MyExceptionWithMessage: {}", self.MyStringField)
    }
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ReservedKeyword {
    pub reserved_field: ::std::primitive::i32,
    // This field forces `..Default::default()` when instantiating this
    // struct, to make code future-proof against new fields added later to
    // the definition in Thrift. If you don't want this, add the annotation
    // `@rust.Exhaustive` to the Thrift struct to eliminate this field.
    #[doc(hidden)]
    pub _dot_dot_Default_default: self::dot_dot::OtherFields,
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum UnionToBeRenamed {
    reserved_field(::std::primitive::i32),
    UnknownField(::std::primitive::i32),
}

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct MyEnum(pub ::std::primitive::i32);

impl MyEnum {
    pub const MyValue1: Self = MyEnum(0i32);
    pub const MyValue2: Self = MyEnum(1i32);
}

impl ::fbthrift::ThriftEnum for MyEnum {
    fn enumerate() -> &'static [(Self, &'static ::std::primitive::str)] {
        &[
            (Self::MyValue1, "MyValue1"),
            (Self::MyValue2, "MyValue2"),
        ]
    }

    fn variants() -> &'static [&'static ::std::primitive::str] {
        &[
            "MyValue1",
            "MyValue2",
        ]
    }

    fn variant_values() -> &'static [Self] {
        &[
            Self::MyValue1,
            Self::MyValue2,
        ]
    }

    fn inner_value(&self) -> i32 {
        self.0
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for MyEnum {
    fn default() -> Self {
        Self(0)
    }
}

impl<'a> ::std::convert::From<&'a MyEnum> for ::std::primitive::i32 {
    #[inline]
    fn from(x: &'a MyEnum) -> Self {
        x.0
    }
}

impl ::std::convert::From<MyEnum> for ::std::primitive::i32 {
    #[inline]
    fn from(x: MyEnum) -> Self {
        x.0
    }
}

impl ::std::convert::From<::std::primitive::i32> for MyEnum {
    #[inline]
    fn from(x: ::std::primitive::i32) -> Self {
        Self(x)
    }
}

impl ::std::fmt::Display for MyEnum {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        static VARIANTS_BY_NUMBER: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("MyValue1", 0),
            ("MyValue2", 1),
        ];
        ::fbthrift::help::enum_display(VARIANTS_BY_NUMBER, fmt, self.0)
    }
}

impl ::std::fmt::Debug for MyEnum {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(fmt, "MyEnum::{}", self)
    }
}

impl ::std::str::FromStr for MyEnum {
    type Err = ::anyhow::Error;

    fn from_str(string: &::std::primitive::str) -> ::std::result::Result<Self, Self::Err> {
        static VARIANTS_BY_NAME: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("MyValue1", 0),
            ("MyValue2", 1),
        ];
        ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "MyEnum").map(Self)
    }
}

impl ::fbthrift::GetTType for MyEnum {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::I32;
}

impl ::fbthrift::GetUri for self::MyEnum {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyEnum"
    }
}

impl<P> ::fbthrift::Serialize<P> for MyEnum
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_i32(self.into())
    }
}

impl<P> ::fbthrift::Deserialize<P> for MyEnum
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        ::std::result::Result::Ok(Self::from(::anyhow::Context::context(p.read_i32(), "Expected a number indicating enum variant")?))
    }
}

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct HackEnum(pub ::std::primitive::i32);

impl HackEnum {
    pub const Value1: Self = HackEnum(0i32);
    pub const Value2: Self = HackEnum(1i32);
}

impl ::fbthrift::ThriftEnum for HackEnum {
    fn enumerate() -> &'static [(Self, &'static ::std::primitive::str)] {
        &[
            (Self::Value1, "Value1"),
            (Self::Value2, "Value2"),
        ]
    }

    fn variants() -> &'static [&'static ::std::primitive::str] {
        &[
            "Value1",
            "Value2",
        ]
    }

    fn variant_values() -> &'static [Self] {
        &[
            Self::Value1,
            Self::Value2,
        ]
    }

    fn inner_value(&self) -> i32 {
        self.0
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for HackEnum {
    fn default() -> Self {
        Self(0)
    }
}

impl<'a> ::std::convert::From<&'a HackEnum> for ::std::primitive::i32 {
    #[inline]
    fn from(x: &'a HackEnum) -> Self {
        x.0
    }
}

impl ::std::convert::From<HackEnum> for ::std::primitive::i32 {
    #[inline]
    fn from(x: HackEnum) -> Self {
        x.0
    }
}

impl ::std::convert::From<::std::primitive::i32> for HackEnum {
    #[inline]
    fn from(x: ::std::primitive::i32) -> Self {
        Self(x)
    }
}

impl ::std::fmt::Display for HackEnum {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        static VARIANTS_BY_NUMBER: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("Value1", 0),
            ("Value2", 1),
        ];
        ::fbthrift::help::enum_display(VARIANTS_BY_NUMBER, fmt, self.0)
    }
}

impl ::std::fmt::Debug for HackEnum {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(fmt, "HackEnum::{}", self)
    }
}

impl ::std::str::FromStr for HackEnum {
    type Err = ::anyhow::Error;

    fn from_str(string: &::std::primitive::str) -> ::std::result::Result<Self, Self::Err> {
        static VARIANTS_BY_NAME: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("Value1", 0),
            ("Value2", 1),
        ];
        ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "HackEnum").map(Self)
    }
}

impl ::fbthrift::GetTType for HackEnum {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::I32;
}

impl ::fbthrift::GetUri for self::HackEnum {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/HackEnum"
    }
}

impl<P> ::fbthrift::Serialize<P> for HackEnum
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_i32(self.into())
    }
}

impl<P> ::fbthrift::Deserialize<P> for HackEnum
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        ::std::result::Result::Ok(Self::from(::anyhow::Context::context(p.read_i32(), "Expected a number indicating enum variant")?))
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::MyStruct {
    fn default() -> Self {
        Self {
            MyIntField: ::std::default::Default::default(),
            MyStringField: ::std::default::Default::default(),
            MyDataField: ::std::default::Default::default(),
            myEnum: ::std::default::Default::default(),
            oneway: ::std::default::Default::default(),
            readonly: ::std::default::Default::default(),
            idempotent: ::std::default::Default::default(),
            floatSet: ::std::default::Default::default(),
            no_hack_codegen_field: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::MyStruct {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("MyStruct")
            .field("MyIntField", &self.MyIntField)
            .field("MyStringField", &self.MyStringField)
            .field("MyDataField", &self.MyDataField)
            .field("myEnum", &self.myEnum)
            .field("oneway", &self.oneway)
            .field("readonly", &self.readonly)
            .field("idempotent", &self.idempotent)
            .field("floatSet", &self.floatSet)
            .field("no_hack_codegen_field", &self.no_hack_codegen_field)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::MyStruct {}
unsafe impl ::std::marker::Sync for self::MyStruct {}
impl ::std::marker::Unpin for self::MyStruct {}
impl ::std::panic::RefUnwindSafe for self::MyStruct {}
impl ::std::panic::UnwindSafe for self::MyStruct {}

impl ::fbthrift::GetTType for self::MyStruct {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyStruct {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyStruct"
    }
}

impl ::fbthrift::GetTypeNameType for self::MyStruct {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::MyStruct
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyStruct");
        p.write_field_begin("MyIntField", ::fbthrift::TType::I64, 1);
        ::fbthrift::Serialize::write(&self.MyIntField, p);
        p.write_field_end();
        p.write_field_begin("MyStringField", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.MyStringField, p);
        p.write_field_end();
        p.write_field_begin("MyDataField", ::fbthrift::TType::Struct, 3);
        ::fbthrift::Serialize::write(&self.MyDataField, p);
        p.write_field_end();
        p.write_field_begin("myEnum", ::fbthrift::TType::I32, 4);
        ::fbthrift::Serialize::write(&self.myEnum, p);
        p.write_field_end();
        p.write_field_begin("oneway", ::fbthrift::TType::Bool, 5);
        ::fbthrift::Serialize::write(&self.oneway, p);
        p.write_field_end();
        p.write_field_begin("readonly", ::fbthrift::TType::Bool, 6);
        ::fbthrift::Serialize::write(&self.readonly, p);
        p.write_field_end();
        p.write_field_begin("idempotent", ::fbthrift::TType::Bool, 7);
        ::fbthrift::Serialize::write(&self.idempotent, p);
        p.write_field_end();
        p.write_field_begin("floatSet", ::fbthrift::TType::Set, 8);
        ::fbthrift::Serialize::write(&self.floatSet, p);
        p.write_field_end();
        p.write_field_begin("no_hack_codegen_field", ::fbthrift::TType::String, 9);
        ::fbthrift::Serialize::write(&self.no_hack_codegen_field, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::MyStruct
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("MyDataField", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("MyIntField", ::fbthrift::TType::I64, 1),
            ::fbthrift::Field::new("MyStringField", ::fbthrift::TType::String, 2),
            ::fbthrift::Field::new("floatSet", ::fbthrift::TType::Set, 8),
            ::fbthrift::Field::new("idempotent", ::fbthrift::TType::Bool, 7),
            ::fbthrift::Field::new("myEnum", ::fbthrift::TType::I32, 4),
            ::fbthrift::Field::new("no_hack_codegen_field", ::fbthrift::TType::String, 9),
            ::fbthrift::Field::new("oneway", ::fbthrift::TType::Bool, 5),
            ::fbthrift::Field::new("readonly", ::fbthrift::TType::Bool, 6),
        ];
        let mut field_MyIntField = ::std::option::Option::None;
        let mut field_MyStringField = ::std::option::Option::None;
        let mut field_MyDataField = ::std::option::Option::None;
        let mut field_myEnum = ::std::option::Option::None;
        let mut field_oneway = ::std::option::Option::None;
        let mut field_readonly = ::std::option::Option::None;
        let mut field_idempotent = ::std::option::Option::None;
        let mut field_floatSet = ::std::option::Option::None;
        let mut field_no_hack_codegen_field = ::std::option::Option::None;
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a MyStruct")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::I64, 1) => field_MyIntField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_MyStringField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 3) => field_MyDataField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 4) => field_myEnum = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Bool, 5) => field_oneway = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Bool, 6) => field_readonly = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Bool, 7) => field_idempotent = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 8) => field_floatSet = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 9) => field_no_hack_codegen_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            MyIntField: field_MyIntField.unwrap_or_default(),
            MyStringField: field_MyStringField.unwrap_or_default(),
            MyDataField: field_MyDataField.unwrap_or_default(),
            myEnum: field_myEnum.unwrap_or_default(),
            oneway: field_oneway.unwrap_or_default(),
            readonly: field_readonly.unwrap_or_default(),
            idempotent: field_idempotent.unwrap_or_default(),
            floatSet: field_floatSet.unwrap_or_default(),
            no_hack_codegen_field: field_no_hack_codegen_field.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for MyStruct {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {
            },
            5 => {
            },
            6 => {
            },
            7 => {
            },
            8 => {

                if type_id == ::std::any::TypeId::of::<hack__types::SkipCodegen>() {
                    let mut tmp = ::std::option::Option::Some(hack__types::SkipCodegen {
                        reason: "Invalid key type".to_owned(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            9 => {

                if type_id == ::std::any::TypeId::of::<hack__types::SkipCodegen>() {
                    let mut tmp = ::std::option::Option::Some(hack__types::SkipCodegen {
                        reason: "skip field codegen for deprecation".to_owned(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}


#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::Containers {
    fn default() -> Self {
        Self {
            I32List: ::std::default::Default::default(),
            StringSet: ::std::default::Default::default(),
            StringToI64Map: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::Containers {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("Containers")
            .field("I32List", &self.I32List)
            .field("StringSet", &self.StringSet)
            .field("StringToI64Map", &self.StringToI64Map)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::Containers {}
unsafe impl ::std::marker::Sync for self::Containers {}
impl ::std::marker::Unpin for self::Containers {}
impl ::std::panic::RefUnwindSafe for self::Containers {}
impl ::std::panic::UnwindSafe for self::Containers {}

impl ::fbthrift::GetTType for self::Containers {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::Containers {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/Containers"
    }
}

impl ::fbthrift::GetTypeNameType for self::Containers {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::Containers
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("Containers");
        p.write_field_begin("I32List", ::fbthrift::TType::List, 1);
        ::fbthrift::Serialize::write(&self.I32List, p);
        p.write_field_end();
        p.write_field_begin("StringSet", ::fbthrift::TType::Set, 2);
        ::fbthrift::Serialize::write(&self.StringSet, p);
        p.write_field_end();
        p.write_field_begin("StringToI64Map", ::fbthrift::TType::Map, 3);
        ::fbthrift::Serialize::write(&self.StringToI64Map, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::Containers
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("I32List", ::fbthrift::TType::List, 1),
            ::fbthrift::Field::new("StringSet", ::fbthrift::TType::Set, 2),
            ::fbthrift::Field::new("StringToI64Map", ::fbthrift::TType::Map, 3),
        ];
        let mut field_I32List = ::std::option::Option::None;
        let mut field_StringSet = ::std::option::Option::None;
        let mut field_StringToI64Map = ::std::option::Option::None;
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a Containers")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::List, 1) => field_I32List = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 2) => field_StringSet = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Map, 3) => field_StringToI64Map = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            I32List: field_I32List.unwrap_or_default(),
            StringSet: field_StringSet.unwrap_or_default(),
            StringToI64Map: field_StringToI64Map.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for Containers {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}


#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::MyDataItem {
    fn default() -> Self {
        Self {
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::MyDataItem {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("MyDataItem")
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::MyDataItem {}
unsafe impl ::std::marker::Sync for self::MyDataItem {}
impl ::std::marker::Unpin for self::MyDataItem {}
impl ::std::panic::RefUnwindSafe for self::MyDataItem {}
impl ::std::panic::UnwindSafe for self::MyDataItem {}

impl ::fbthrift::GetTType for self::MyDataItem {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyDataItem {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyDataItem"
    }
}

impl ::fbthrift::GetTypeNameType for self::MyDataItem {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::MyDataItem
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyDataItem");
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::MyDataItem
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
        ];
        #[allow(unused_mut)]
        let mut fields = Self {
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        };
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a MyDataItem")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(fields)
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for MyDataItem {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            _ => {}
        }

        ::std::option::Option::None
    }
}



impl ::std::default::Default for MyUnion {
    fn default() -> Self {
        Self::UnknownField(-1)
    }
}

impl ::fbthrift::GetTType for MyUnion {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyUnion {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyUnion"
    }
}

impl ::fbthrift::GetTypeNameType for self::MyUnion {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::UnionType
    }
}

impl<P> ::fbthrift::Serialize<P> for MyUnion
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyUnion");
        match self {
            Self::myEnum(inner) => {
                p.write_field_begin("myEnum", ::fbthrift::TType::I32, 1);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::myStruct(inner) => {
                p.write_field_begin("myStruct", ::fbthrift::TType::Struct, 2);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::myDataItem(inner) => {
                p.write_field_begin("myDataItem", ::fbthrift::TType::Struct, 3);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::floatSet(inner) => {
                p.write_field_begin("floatSet", ::fbthrift::TType::Set, 4);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::UnknownField(_) => {}
        }
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for MyUnion
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("floatSet", ::fbthrift::TType::Set, 4),
            ::fbthrift::Field::new("myDataItem", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("myEnum", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("myStruct", ::fbthrift::TType::Struct, 2),
        ];
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a MyUnion")?;
        let mut once = false;
        let mut alt = ::std::option::Option::None;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32, once) {
                (::fbthrift::TType::Stop, _, _) => break,
                (::fbthrift::TType::I32, 1, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::myEnum(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Struct, 2, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::myStruct(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Struct, 3, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::myDataItem(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Set, 4, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::floatSet(::fbthrift::Deserialize::read(p)?));
                }
                (fty, _, false) => p.skip(fty)?,
                (badty, badid, true) => return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ProtocolError::UnwantedExtraUnionField(
                    "MyUnion".to_string(),
                    badty,
                    badid,
                ))),
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(alt.unwrap_or_default())
    }
}

impl MyUnion {
    /// Return current union variant name as a tuple of (Rust name, original name).
    pub fn variant_name(&self) -> ::std::option::Option<(&'static ::std::primitive::str, &'static ::std::primitive::str)> {
        match self {
            Self::myEnum(_) => ::std::option::Option::Some(("myEnum", "myEnum")),
            Self::myStruct(_) => ::std::option::Option::Some(("myStruct", "myStruct")),
            Self::myDataItem(_) => ::std::option::Option::Some(("myDataItem", "myDataItem")),
            Self::floatSet(_) => ::std::option::Option::Some(("floatSet", "floatSet")),
            Self::UnknownField(_) => ::std::option::Option::None,
        }
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for MyUnion {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {

                if type_id == ::std::any::TypeId::of::<hack__types::SkipCodegen>() {
                    let mut tmp = ::std::option::Option::Some(hack__types::SkipCodegen {
                        reason: "Invalid key type".to_owned(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::MyException {
    fn default() -> Self {
        Self {
            MyIntField: ::std::default::Default::default(),
            MyStringField: ::std::default::Default::default(),
            myStruct: ::std::default::Default::default(),
            myUnion: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::MyException {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("MyException")
            .field("MyIntField", &self.MyIntField)
            .field("MyStringField", &self.MyStringField)
            .field("myStruct", &self.myStruct)
            .field("myUnion", &self.myUnion)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::MyException {}
unsafe impl ::std::marker::Sync for self::MyException {}
impl ::std::marker::Unpin for self::MyException {}
impl ::std::panic::RefUnwindSafe for self::MyException {}
impl ::std::panic::UnwindSafe for self::MyException {}

impl ::fbthrift::GetTType for self::MyException {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyException {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyException"
    }
}

impl ::fbthrift::GetTypeNameType for self::MyException {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::MyException
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyException");
        p.write_field_begin("MyIntField", ::fbthrift::TType::I64, 1);
        ::fbthrift::Serialize::write(&self.MyIntField, p);
        p.write_field_end();
        p.write_field_begin("MyStringField", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.MyStringField, p);
        p.write_field_end();
        p.write_field_begin("myStruct", ::fbthrift::TType::Struct, 3);
        ::fbthrift::Serialize::write(&self.myStruct, p);
        p.write_field_end();
        p.write_field_begin("myUnion", ::fbthrift::TType::Struct, 4);
        ::fbthrift::Serialize::write(&self.myUnion, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::MyException
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("MyIntField", ::fbthrift::TType::I64, 1),
            ::fbthrift::Field::new("MyStringField", ::fbthrift::TType::String, 2),
            ::fbthrift::Field::new("myStruct", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("myUnion", ::fbthrift::TType::Struct, 4),
        ];
        let mut field_MyIntField = ::std::option::Option::None;
        let mut field_MyStringField = ::std::option::Option::None;
        let mut field_myStruct = ::std::option::Option::None;
        let mut field_myUnion = ::std::option::Option::None;
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a MyException")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::I64, 1) => field_MyIntField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_MyStringField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 3) => field_myStruct = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 4) => field_myUnion = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            MyIntField: field_MyIntField.unwrap_or_default(),
            MyStringField: field_MyStringField.unwrap_or_default(),
            myStruct: field_myStruct.unwrap_or_default(),
            myUnion: field_myUnion.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for MyException {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}


#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::MyExceptionWithMessage {
    fn default() -> Self {
        Self {
            MyIntField: ::std::default::Default::default(),
            MyStringField: ::std::default::Default::default(),
            myStruct: ::std::default::Default::default(),
            myUnion: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::MyExceptionWithMessage {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("MyExceptionWithMessage")
            .field("MyIntField", &self.MyIntField)
            .field("MyStringField", &self.MyStringField)
            .field("myStruct", &self.myStruct)
            .field("myUnion", &self.myUnion)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::MyExceptionWithMessage {}
unsafe impl ::std::marker::Sync for self::MyExceptionWithMessage {}
impl ::std::marker::Unpin for self::MyExceptionWithMessage {}
impl ::std::panic::RefUnwindSafe for self::MyExceptionWithMessage {}
impl ::std::panic::UnwindSafe for self::MyExceptionWithMessage {}

impl ::fbthrift::GetTType for self::MyExceptionWithMessage {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyExceptionWithMessage {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/MyExceptionWithMessage"
    }
}

impl ::fbthrift::GetTypeNameType for self::MyExceptionWithMessage {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::MyExceptionWithMessage
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyExceptionWithMessage");
        p.write_field_begin("MyIntField", ::fbthrift::TType::I64, 1);
        ::fbthrift::Serialize::write(&self.MyIntField, p);
        p.write_field_end();
        p.write_field_begin("MyStringField", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.MyStringField, p);
        p.write_field_end();
        p.write_field_begin("myStruct", ::fbthrift::TType::Struct, 3);
        ::fbthrift::Serialize::write(&self.myStruct, p);
        p.write_field_end();
        p.write_field_begin("myUnion", ::fbthrift::TType::Struct, 4);
        ::fbthrift::Serialize::write(&self.myUnion, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::MyExceptionWithMessage
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("MyIntField", ::fbthrift::TType::I64, 1),
            ::fbthrift::Field::new("MyStringField", ::fbthrift::TType::String, 2),
            ::fbthrift::Field::new("myStruct", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("myUnion", ::fbthrift::TType::Struct, 4),
        ];
        let mut field_MyIntField = ::std::option::Option::None;
        let mut field_MyStringField = ::std::option::Option::None;
        let mut field_myStruct = ::std::option::Option::None;
        let mut field_myUnion = ::std::option::Option::None;
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a MyExceptionWithMessage")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::I64, 1) => field_MyIntField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_MyStringField = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 3) => field_myStruct = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 4) => field_myUnion = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            MyIntField: field_MyIntField.unwrap_or_default(),
            MyStringField: field_MyStringField.unwrap_or_default(),
            myStruct: field_myStruct.unwrap_or_default(),
            myUnion: field_myUnion.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for MyExceptionWithMessage {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {
            },
            2 => {

                if type_id == ::std::any::TypeId::of::<thrift__types::ExceptionMessage>() {
                    let mut tmp = ::std::option::Option::Some(thrift__types::ExceptionMessage {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            3 => {
            },
            4 => {
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}


#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::ReservedKeyword {
    fn default() -> Self {
        Self {
            reserved_field: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::ReservedKeyword {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("ReservedKeyword")
            .field("reserved_field", &self.reserved_field)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::ReservedKeyword {}
unsafe impl ::std::marker::Sync for self::ReservedKeyword {}
impl ::std::marker::Unpin for self::ReservedKeyword {}
impl ::std::panic::RefUnwindSafe for self::ReservedKeyword {}
impl ::std::panic::UnwindSafe for self::ReservedKeyword {}

impl ::fbthrift::GetTType for self::ReservedKeyword {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::ReservedKeyword {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/ReservedKeyword"
    }
}

impl ::fbthrift::GetTypeNameType for self::ReservedKeyword {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::StructType
    }
}

impl<P> ::fbthrift::Serialize<P> for self::ReservedKeyword
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("ReservedKeyword");
        p.write_field_begin("reserved_field", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.reserved_field, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::ReservedKeyword
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("reserved_field", ::fbthrift::TType::I32, 1),
        ];
        let mut field_reserved_field = ::std::option::Option::None;
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a ReservedKeyword")?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::I32, 1) => field_reserved_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            reserved_field: field_reserved_field.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}


impl ::fbthrift::metadata::ThriftAnnotations for ReservedKeyword {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        if type_id == ::std::any::TypeId::of::<hack__types::Name>() {
            let mut tmp = ::std::option::Option::Some(hack__types::Name {
                name: "MyRenamedStruct".to_owned(),
                reason: ::std::default::Default::default(),
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        if let ::std::option::Option::Some(r) = <hack__types::Name as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
            return ::std::option::Option::Some(r);
        }

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {

                if type_id == ::std::any::TypeId::of::<hack__types::Name>() {
                    let mut tmp = ::std::option::Option::Some(hack__types::Name {
                        name: "renamed_field".to_owned(),
                        reason: ::std::default::Default::default(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }

                if let ::std::option::Option::Some(r) = <hack__types::Name as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
                    return ::std::option::Option::Some(r);
                }
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}



impl ::std::default::Default for UnionToBeRenamed {
    fn default() -> Self {
        Self::UnknownField(-1)
    }
}

impl ::fbthrift::GetTType for UnionToBeRenamed {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::UnionToBeRenamed {
    fn uri() -> &'static ::std::primitive::str {
        "test.dev/fixtures/basic/UnionToBeRenamed"
    }
}

impl ::fbthrift::GetTypeNameType for self::UnionToBeRenamed {
    fn type_name_type() -> fbthrift::TypeNameType {
        ::fbthrift::TypeNameType::UnionType
    }
}

impl<P> ::fbthrift::Serialize<P> for UnionToBeRenamed
where
    P: ::fbthrift::ProtocolWriter,
{
    #[inline]
    fn write(&self, p: &mut P) {
        p.write_struct_begin("UnionToBeRenamed");
        match self {
            Self::reserved_field(inner) => {
                p.write_field_begin("reserved_field", ::fbthrift::TType::I32, 1);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::UnknownField(_) => {}
        }
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for UnionToBeRenamed
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("reserved_field", ::fbthrift::TType::I32, 1),
        ];
        let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a UnionToBeRenamed")?;
        let mut once = false;
        let mut alt = ::std::option::Option::None;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32, once) {
                (::fbthrift::TType::Stop, _, _) => break,
                (::fbthrift::TType::I32, 1, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::reserved_field(::fbthrift::Deserialize::read(p)?));
                }
                (fty, _, false) => p.skip(fty)?,
                (badty, badid, true) => return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ProtocolError::UnwantedExtraUnionField(
                    "UnionToBeRenamed".to_string(),
                    badty,
                    badid,
                ))),
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(alt.unwrap_or_default())
    }
}

impl UnionToBeRenamed {
    /// Return current union variant name as a tuple of (Rust name, original name).
    pub fn variant_name(&self) -> ::std::option::Option<(&'static ::std::primitive::str, &'static ::std::primitive::str)> {
        match self {
            Self::reserved_field(_) => ::std::option::Option::Some(("reserved_field", "reserved_field")),
            Self::UnknownField(_) => ::std::option::Option::None,
        }
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for UnionToBeRenamed {
    fn get_structured_annotation<T: Sized + 'static>() -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        if type_id == ::std::any::TypeId::of::<hack__types::Name>() {
            let mut tmp = ::std::option::Option::Some(hack__types::Name {
                name: "MyRenamedUnion".to_owned(),
                reason: ::std::default::Default::default(),
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        if let ::std::option::Option::Some(r) = <hack__types::Name as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
            return ::std::option::Option::Some(r);
        }

        ::std::option::Option::None
    }

    fn get_field_structured_annotation<T: Sized + 'static>(field_id: ::std::primitive::i16) -> ::std::option::Option<T> {
        #[allow(unused_variables)]
        let type_id = ::std::any::TypeId::of::<T>();

        #[allow(clippy::match_single_binding)]
        match field_id {
            1 => {

                if type_id == ::std::any::TypeId::of::<hack__types::Name>() {
                    let mut tmp = ::std::option::Option::Some(hack__types::Name {
                        name: "renamed_field".to_owned(),
                        reason: ::std::default::Default::default(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut ::std::option::Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }

                if let ::std::option::Option::Some(r) = <hack__types::Name as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
                    return ::std::option::Option::Some(r);
                }
            },
            _ => {}
        }

        ::std::option::Option::None
    }
}

mod dot_dot {
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct OtherFields(pub(crate) ());

    #[allow(dead_code)] // if serde isn't being used
    pub(super) fn default_for_serde_deserialize() -> OtherFields {
        OtherFields(())
    }
}

pub(crate) mod r#impl {
    use ::ref_cast::RefCast;

    #[derive(RefCast)]
    #[repr(transparent)]
    pub(crate) struct LocalImpl<T>(T);

    #[allow(unused)]
    pub(crate) fn write<T, P>(value: &T, p: &mut P)
    where
        LocalImpl<T>: ::fbthrift::Serialize<P>,
        P: ::fbthrift::ProtocolWriter,
    {
        ::fbthrift::Serialize::write(LocalImpl::ref_cast(value), p);
    }

    #[allow(unused)]
    pub(crate) fn read<T, P>(p: &mut P) -> ::anyhow::Result<T>
    where
        LocalImpl<T>: ::fbthrift::Deserialize<P>,
        P: ::fbthrift::ProtocolReader,
    {
        let value: LocalImpl<T> = ::fbthrift::Deserialize::read(p)?;
        ::std::result::Result::Ok(value.0)
    }
}
