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

//! Thrift type definitions for `module`.

#![allow(clippy::redundant_closure)]

pub type MyCompany = crate::types::Company;

pub type MyStringIdentifier = ::std::string::String;

pub type MyIntIdentifier = ::std::primitive::i32;

pub type MyMapIdentifier = ::std::collections::BTreeMap<::std::string::String, ::std::string::String>;

#[derive(Clone, PartialEq)]
pub struct Internship {
    pub weeks: ::std::primitive::i32,
    pub title: ::std::string::String,
    pub employer: ::std::option::Option<crate::types::Company>,
    pub compensation: ::std::option::Option<::std::primitive::f64>,
    pub school: ::std::option::Option<::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, Eq, PartialOrd, Ord, Hash)]
pub struct Range {
    pub min: ::std::primitive::i32,
    pub max: ::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)]
pub struct struct1 {
    pub a: ::std::primitive::i32,
    pub b: ::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 struct2 {
    pub a: ::std::primitive::i32,
    pub b: ::std::string::String,
    pub c: crate::types::struct1,
    pub d: ::std::vec::Vec<::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)]
pub struct struct3 {
    pub a: ::std::string::String,
    pub b: ::std::primitive::i32,
    pub c: crate::types::struct2,
    // 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 struct4 {
    pub a: ::std::primitive::i32,
    pub b: ::std::option::Option<::std::primitive::f64>,
    pub c: ::std::option::Option<::std::primitive::i8>,
    // 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 union1 {
    i(::std::primitive::i32),
    d(::std::primitive::f64),
    UnknownField(::std::primitive::i32),
}

#[derive(Clone, PartialEq, Debug)]
pub enum union2 {
    i(::std::primitive::i32),
    d(::std::primitive::f64),
    s(crate::types::struct1),
    u(crate::types::union1),
    UnknownField(::std::primitive::i32),
}

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

impl EmptyEnum {
}

impl ::fbthrift::ThriftEnum for EmptyEnum {
    fn enumerate() -> &'static [(Self, &'static str)] {
        &[
        ]
    }

    fn variants() -> &'static [&'static str] {
        &[
        ]
    }

    fn variant_values() -> &'static [Self] {
        &[
        ]
    }
}

impl ::std::default::Default for EmptyEnum {
    fn default() -> Self {
        Self(::fbthrift::__UNKNOWN_ID)
    }
}

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

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

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

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

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

impl ::std::str::FromStr for EmptyEnum {
    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)] = &[
        ];
        ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "EmptyEnum").map(Self)
    }
}

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

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

impl<P> ::fbthrift::Deserialize<P> for EmptyEnum
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        ::std::result::Result::Ok(Self::from(p.read_i32()?))
    }
}

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

impl City {
    pub const NYC: Self = City(0i32);
    pub const MPK: Self = City(1i32);
    pub const SEA: Self = City(2i32);
    pub const LON: Self = City(3i32);
}

impl ::fbthrift::ThriftEnum for City {
    fn enumerate() -> &'static [(Self, &'static str)] {
        &[
            (Self::NYC, "NYC"),
            (Self::MPK, "MPK"),
            (Self::SEA, "SEA"),
            (Self::LON, "LON"),
        ]
    }

    fn variants() -> &'static [&'static str] {
        &[
            "NYC",
            "MPK",
            "SEA",
            "LON",
        ]
    }

    fn variant_values() -> &'static [Self] {
        &[
            Self::NYC,
            Self::MPK,
            Self::SEA,
            Self::LON,
        ]
    }
}

impl ::std::default::Default for City {
    fn default() -> Self {
        Self(::fbthrift::__UNKNOWN_ID)
    }
}

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

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

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

impl ::std::fmt::Display for City {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        static VARIANTS_BY_NUMBER: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("NYC", 0),
            ("MPK", 1),
            ("SEA", 2),
            ("LON", 3),
        ];
        ::fbthrift::help::enum_display(VARIANTS_BY_NUMBER, fmt, self.0)
    }
}

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

impl ::std::str::FromStr for City {
    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)] = &[
            ("LON", 3),
            ("MPK", 1),
            ("NYC", 0),
            ("SEA", 2),
        ];
        ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "City").map(Self)
    }
}

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

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

impl<P> ::fbthrift::Deserialize<P> for City
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        ::std::result::Result::Ok(Self::from(p.read_i32()?))
    }
}

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

impl Company {
    pub const FACEBOOK: Self = Company(0i32);
    pub const WHATSAPP: Self = Company(1i32);
    pub const OCULUS: Self = Company(2i32);
    pub const INSTAGRAM: Self = Company(3i32);
}

impl ::fbthrift::ThriftEnum for Company {
    fn enumerate() -> &'static [(Self, &'static str)] {
        &[
            (Self::FACEBOOK, "FACEBOOK"),
            (Self::WHATSAPP, "WHATSAPP"),
            (Self::OCULUS, "OCULUS"),
            (Self::INSTAGRAM, "INSTAGRAM"),
        ]
    }

    fn variants() -> &'static [&'static str] {
        &[
            "FACEBOOK",
            "WHATSAPP",
            "OCULUS",
            "INSTAGRAM",
        ]
    }

    fn variant_values() -> &'static [Self] {
        &[
            Self::FACEBOOK,
            Self::WHATSAPP,
            Self::OCULUS,
            Self::INSTAGRAM,
        ]
    }
}

impl ::std::default::Default for Company {
    fn default() -> Self {
        Self(::fbthrift::__UNKNOWN_ID)
    }
}

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

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

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

impl ::std::fmt::Display for Company {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        static VARIANTS_BY_NUMBER: &[(&::std::primitive::str, ::std::primitive::i32)] = &[
            ("FACEBOOK", 0),
            ("WHATSAPP", 1),
            ("OCULUS", 2),
            ("INSTAGRAM", 3),
        ];
        ::fbthrift::help::enum_display(VARIANTS_BY_NUMBER, fmt, self.0)
    }
}

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

impl ::std::str::FromStr for Company {
    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)] = &[
            ("FACEBOOK", 0),
            ("INSTAGRAM", 3),
            ("OCULUS", 2),
            ("WHATSAPP", 1),
        ];
        ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "Company").map(Self)
    }
}

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

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

impl<P> ::fbthrift::Deserialize<P> for Company
where
    P: ::fbthrift::ProtocolReader,
{
    #[inline]
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        ::std::result::Result::Ok(Self::from(p.read_i32()?))
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::Internship {
    fn default() -> Self {
        Self {
            weeks: ::std::default::Default::default(),
            title: ::std::default::Default::default(),
            employer: ::std::option::Option::None,
            compensation: ::std::option::Option::None,
            school: ::std::option::Option::None,
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::Internship {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("Internship")
            .field("weeks", &self.weeks)
            .field("title", &self.title)
            .field("employer", &self.employer)
            .field("compensation", &self.compensation)
            .field("school", &self.school)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::Internship {}
unsafe impl ::std::marker::Sync for self::Internship {}
impl ::std::marker::Unpin for self::Internship {}

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

impl<P> ::fbthrift::Serialize<P> for self::Internship
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("Internship");
        p.write_field_begin("weeks", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.weeks, p);
        p.write_field_end();
        p.write_field_begin("title", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.title, p);
        p.write_field_end();
        if let ::std::option::Option::Some(some) = &self.employer {
            p.write_field_begin("employer", ::fbthrift::TType::I32, 3);
            ::fbthrift::Serialize::write(some, p);
            p.write_field_end();
        }
        if let ::std::option::Option::Some(some) = &self.compensation {
            p.write_field_begin("compensation", ::fbthrift::TType::Double, 4);
            ::fbthrift::Serialize::write(some, p);
            p.write_field_end();
        }
        if let ::std::option::Option::Some(some) = &self.school {
            p.write_field_begin("school", ::fbthrift::TType::String, 5);
            ::fbthrift::Serialize::write(some, p);
            p.write_field_end();
        }
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::Internship
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("compensation", ::fbthrift::TType::Double, 4),
            ::fbthrift::Field::new("employer", ::fbthrift::TType::I32, 3),
            ::fbthrift::Field::new("school", ::fbthrift::TType::String, 5),
            ::fbthrift::Field::new("title", ::fbthrift::TType::String, 2),
            ::fbthrift::Field::new("weeks", ::fbthrift::TType::I32, 1),
        ];
        let mut field_weeks = ::std::option::Option::None;
        let mut field_title = ::std::option::Option::None;
        let mut field_employer = ::std::option::Option::None;
        let mut field_compensation = ::std::option::Option::None;
        let mut field_school = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        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_weeks = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_title = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 3) => field_employer = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 4) => field_compensation = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 5) => field_school = ::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 {
            weeks: field_weeks.unwrap_or_default(),
            title: field_title.unwrap_or_default(),
            employer: field_employer,
            compensation: field_compensation,
            school: field_school,
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {
            },
            5 => {
            },
            _ => {}
        }

        None
    }
}

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

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

unsafe impl ::std::marker::Send for self::Range {}
unsafe impl ::std::marker::Sync for self::Range {}
impl ::std::marker::Unpin for self::Range {}

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

impl<P> ::fbthrift::Serialize<P> for self::Range
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("Range");
        p.write_field_begin("min", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.min, p);
        p.write_field_end();
        p.write_field_begin("max", ::fbthrift::TType::I32, 2);
        ::fbthrift::Serialize::write(&self.max, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::Range
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("max", ::fbthrift::TType::I32, 2),
            ::fbthrift::Field::new("min", ::fbthrift::TType::I32, 1),
        ];
        let mut field_min = ::std::option::Option::None;
        let mut field_max = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        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_min = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 2) => field_max = ::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 {
            min: field_min.unwrap_or_default(),
            max: field_max.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            _ => {}
        }

        None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::struct1 {
    fn default() -> Self {
        Self {
            a: 1234567,
            b: "<uninitialized>".to_owned(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

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

unsafe impl ::std::marker::Send for self::struct1 {}
unsafe impl ::std::marker::Sync for self::struct1 {}
impl ::std::marker::Unpin for self::struct1 {}

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

impl<P> ::fbthrift::Serialize<P> for self::struct1
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("struct1");
        p.write_field_begin("a", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.a, p);
        p.write_field_end();
        p.write_field_begin("b", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.b, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::struct1
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("a", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("b", ::fbthrift::TType::String, 2),
        ];
        let mut field_a = ::std::option::Option::None;
        let mut field_b = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        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_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_b = ::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 {
            a: field_a.unwrap_or(1234567),
            b: field_b.unwrap_or_else(|| "<uninitialized>".to_owned()),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            _ => {}
        }

        None
    }
}

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

impl ::std::fmt::Debug for self::struct2 {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("struct2")
            .field("a", &self.a)
            .field("b", &self.b)
            .field("c", &self.c)
            .field("d", &self.d)
            .finish()
    }
}

unsafe impl ::std::marker::Send for self::struct2 {}
unsafe impl ::std::marker::Sync for self::struct2 {}
impl ::std::marker::Unpin for self::struct2 {}

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

impl<P> ::fbthrift::Serialize<P> for self::struct2
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("struct2");
        p.write_field_begin("a", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.a, p);
        p.write_field_end();
        p.write_field_begin("b", ::fbthrift::TType::String, 2);
        ::fbthrift::Serialize::write(&self.b, p);
        p.write_field_end();
        p.write_field_begin("c", ::fbthrift::TType::Struct, 3);
        ::fbthrift::Serialize::write(&self.c, p);
        p.write_field_end();
        p.write_field_begin("d", ::fbthrift::TType::List, 4);
        ::fbthrift::Serialize::write(&self.d, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::struct2
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("a", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("b", ::fbthrift::TType::String, 2),
            ::fbthrift::Field::new("c", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("d", ::fbthrift::TType::List, 4),
        ];
        let mut field_a = ::std::option::Option::None;
        let mut field_b = ::std::option::Option::None;
        let mut field_c = ::std::option::Option::None;
        let mut field_d = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        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_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 2) => field_b = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 3) => field_c = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::List, 4) => field_d = ::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 {
            a: field_a.unwrap_or_default(),
            b: field_b.unwrap_or_default(),
            c: field_c.unwrap_or_default(),
            d: field_d.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {
            },
            _ => {}
        }

        None
    }
}

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

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

unsafe impl ::std::marker::Send for self::struct3 {}
unsafe impl ::std::marker::Sync for self::struct3 {}
impl ::std::marker::Unpin for self::struct3 {}

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

impl<P> ::fbthrift::Serialize<P> for self::struct3
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("struct3");
        p.write_field_begin("a", ::fbthrift::TType::String, 1);
        ::fbthrift::Serialize::write(&self.a, p);
        p.write_field_end();
        p.write_field_begin("b", ::fbthrift::TType::I32, 2);
        ::fbthrift::Serialize::write(&self.b, p);
        p.write_field_end();
        p.write_field_begin("c", ::fbthrift::TType::Struct, 3);
        ::fbthrift::Serialize::write(&self.c, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::struct3
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("a", ::fbthrift::TType::String, 1),
            ::fbthrift::Field::new("b", ::fbthrift::TType::I32, 2),
            ::fbthrift::Field::new("c", ::fbthrift::TType::Struct, 3),
        ];
        let mut field_a = ::std::option::Option::None;
        let mut field_b = ::std::option::Option::None;
        let mut field_c = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        loop {
            let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
            match (fty, fid as ::std::primitive::i32) {
                (::fbthrift::TType::Stop, _) => break,
                (::fbthrift::TType::String, 1) => field_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 2) => field_b = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 3) => field_c = ::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 {
            a: field_a.unwrap_or_default(),
            b: field_b.unwrap_or_default(),
            c: field_c.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            _ => {}
        }

        None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::struct4 {
    fn default() -> Self {
        Self {
            a: ::std::default::Default::default(),
            b: ::std::option::Option::None,
            c: ::std::option::Option::None,
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

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

unsafe impl ::std::marker::Send for self::struct4 {}
unsafe impl ::std::marker::Sync for self::struct4 {}
impl ::std::marker::Unpin for self::struct4 {}

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

impl<P> ::fbthrift::Serialize<P> for self::struct4
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("struct4");
        p.write_field_begin("a", ::fbthrift::TType::I32, 1);
        ::fbthrift::Serialize::write(&self.a, p);
        p.write_field_end();
        if let ::std::option::Option::Some(some) = &self.b {
            p.write_field_begin("b", ::fbthrift::TType::Double, 2);
            ::fbthrift::Serialize::write(some, p);
            p.write_field_end();
        }
        if let ::std::option::Option::Some(some) = &self.c {
            p.write_field_begin("c", ::fbthrift::TType::Byte, 3);
            ::fbthrift::Serialize::write(some, p);
            p.write_field_end();
        }
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::struct4
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("a", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("b", ::fbthrift::TType::Double, 2),
            ::fbthrift::Field::new("c", ::fbthrift::TType::Byte, 3),
        ];
        let mut field_a = ::std::option::Option::None;
        let mut field_b = ::std::option::Option::None;
        let mut field_c = ::std::option::Option::None;
        let _ = p.read_struct_begin(|_| ())?;
        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_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 2) => field_b = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Byte, 3) => field_c = ::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 {
            a: field_a.unwrap_or_default(),
            b: field_b,
            c: field_c,
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            _ => {}
        }

        None
    }
}

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

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

impl<P> ::fbthrift::Serialize<P> for union1
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("union1");
        match self {
            Self::i(inner) => {
                p.write_field_begin("i", ::fbthrift::TType::I32, 1);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::d(inner) => {
                p.write_field_begin("d", ::fbthrift::TType::Double, 2);
                ::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 union1
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("d", ::fbthrift::TType::Double, 2),
            ::fbthrift::Field::new("i", ::fbthrift::TType::I32, 1),
        ];
        let _ = p.read_struct_begin(|_| ())?;
        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::i(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Double, 2, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::d(::fbthrift::Deserialize::read(p)?));
                }
                (fty, _, false) => p.skip(fty)?,
                (badty, badid, true) => return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ProtocolError::UnwantedExtraUnionField(
                    "union1".to_string(),
                    badty,
                    badid,
                ))),
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(alt.unwrap_or_default())
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            _ => {}
        }

        None
    }
}

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

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

impl<P> ::fbthrift::Serialize<P> for union2
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("union2");
        match self {
            Self::i(inner) => {
                p.write_field_begin("i", ::fbthrift::TType::I32, 1);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::d(inner) => {
                p.write_field_begin("d", ::fbthrift::TType::Double, 2);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::s(inner) => {
                p.write_field_begin("s", ::fbthrift::TType::Struct, 3);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::u(inner) => {
                p.write_field_begin("u", ::fbthrift::TType::Struct, 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 union2
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("d", ::fbthrift::TType::Double, 2),
            ::fbthrift::Field::new("i", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("s", ::fbthrift::TType::Struct, 3),
            ::fbthrift::Field::new("u", ::fbthrift::TType::Struct, 4),
        ];
        let _ = p.read_struct_begin(|_| ())?;
        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::i(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Double, 2, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::d(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Struct, 3, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::s(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Struct, 4, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::u(::fbthrift::Deserialize::read(p)?));
                }
                (fty, _, false) => p.skip(fty)?,
                (badty, badid, true) => return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ProtocolError::UnwantedExtraUnionField(
                    "union2".to_string(),
                    badty,
                    badid,
                ))),
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(alt.unwrap_or_default())
    }
}

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

        None
    }

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

        match field_id {
            1 => {
            },
            2 => {
            },
            3 => {
            },
            4 => {
            },
            _ => {}
        }

        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(())
    }
}