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

//! Thrift type definitions for `terse_write`.

#![allow(clippy::redundant_closure)]

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

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MyStruct {
    // 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 {
    bool_field(::std::primitive::bool),
    byte_field(::std::primitive::i8),
    short_field(::std::primitive::i16),
    int_field(::std::primitive::i32),
    long_field(::std::primitive::i64),
    float_field(::std::primitive::f32),
    double_field(::std::primitive::f64),
    string_field(::std::string::String),
    binary_field(::std::vec::Vec<::std::primitive::u8>),
    enum_field(crate::types::MyEnum),
    list_field(::std::vec::Vec<::std::primitive::i16>),
    set_field(::std::collections::BTreeSet<::std::primitive::i16>),
    map_field(::std::collections::BTreeMap<::std::primitive::i16, ::std::primitive::i16>),
    struct_field(crate::types::MyStruct),
    UnknownField(::std::primitive::i32),
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MyStructWithCustomDefault {
    pub field1: ::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)]
pub struct StructLevelTerseStruct {
    pub bool_field: ::std::primitive::bool,
    pub byte_field: ::std::primitive::i8,
    pub short_field: ::std::primitive::i16,
    pub int_field: ::std::primitive::i32,
    pub long_field: ::std::primitive::i64,
    pub float_field: ::std::primitive::f32,
    pub double_field: ::std::primitive::f64,
    pub string_field: ::std::string::String,
    pub binary_field: ::std::vec::Vec<::std::primitive::u8>,
    pub enum_field: crate::types::MyEnum,
    pub list_field: ::std::vec::Vec<::std::primitive::i16>,
    pub set_field: ::std::collections::BTreeSet<::std::primitive::i16>,
    pub map_field: ::std::collections::BTreeMap<::std::primitive::i16, ::std::primitive::i16>,
    pub struct_field: crate::types::MyStruct,
    pub union_field: 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,
}

#[derive(Clone, PartialEq)]
pub struct FieldLevelTerseStruct {
    pub terse_bool_field: ::std::primitive::bool,
    pub terse_byte_field: ::std::primitive::i8,
    pub terse_short_field: ::std::primitive::i16,
    pub terse_int_field: ::std::primitive::i32,
    pub terse_long_field: ::std::primitive::i64,
    pub terse_float_field: ::std::primitive::f32,
    pub terse_double_field: ::std::primitive::f64,
    pub terse_string_field: ::std::string::String,
    pub terse_binary_field: ::std::vec::Vec<::std::primitive::u8>,
    pub terse_enum_field: crate::types::MyEnum,
    pub terse_list_field: ::std::vec::Vec<::std::primitive::i16>,
    pub terse_set_field: ::std::collections::BTreeSet<::std::primitive::i16>,
    pub terse_map_field: ::std::collections::BTreeMap<::std::primitive::i16, ::std::primitive::i16>,
    pub terse_struct_field: crate::types::MyStruct,
    pub terse_union_field: crate::types::MyUnion,
    pub bool_field: ::std::primitive::bool,
    pub byte_field: ::std::primitive::i8,
    pub short_field: ::std::primitive::i16,
    pub int_field: ::std::primitive::i32,
    pub long_field: ::std::primitive::i64,
    pub float_field: ::std::primitive::f32,
    pub double_field: ::std::primitive::f64,
    pub string_field: ::std::string::String,
    pub binary_field: ::std::vec::Vec<::std::primitive::u8>,
    pub enum_field: crate::types::MyEnum,
    pub list_field: ::std::vec::Vec<::std::primitive::i16>,
    pub set_field: ::std::collections::BTreeSet<::std::primitive::i16>,
    pub map_field: ::std::collections::BTreeMap<::std::primitive::i16, ::std::primitive::i16>,
    pub struct_field: crate::types::MyStruct,
    pub union_field: 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,
}

#[derive(Clone, PartialEq)]
pub struct TerseStructWithCustomDefault {
    pub bool_field: ::std::primitive::bool,
    pub byte_field: ::std::primitive::i8,
    pub short_field: ::std::primitive::i16,
    pub int_field: ::std::primitive::i32,
    pub long_field: ::std::primitive::i64,
    pub float_field: ::std::primitive::f32,
    pub double_field: ::std::primitive::f64,
    pub string_field: ::std::string::String,
    pub binary_field: ::std::vec::Vec<::std::primitive::u8>,
    pub enum_field: crate::types::MyEnum,
    pub list_field: ::std::vec::Vec<::std::primitive::i16>,
    pub set_field: ::std::collections::BTreeSet<::std::primitive::i16>,
    pub map_field: ::std::collections::BTreeMap<::std::primitive::i16, ::std::primitive::i16>,
    pub struct_field: crate::types::MyStructWithCustomDefault,
    // 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 AdaptedFields {
    pub field1: crate::types::MyInteger,
    pub field2: ::std::primitive::i32,
    pub field3: crate::types::MyInteger,
    // 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 WrappedFields {
    pub field1: ::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 TerseException {
    pub msg: ::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,
}

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

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

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

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

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

impl MyEnum {
    pub const ME0: Self = MyEnum(0i32);
    pub const ME1: Self = MyEnum(1i32);
}

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

    fn variants() -> &'static [&'static str] {
        &[
            "ME0",
            "ME1",
        ]
    }

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

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

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)] = &[
            ("ME0", 0),
            ("ME1", 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)] = &[
            ("ME0", 0),
            ("ME1", 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 str {
        "facebook.com/thrift/test/terse_write/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(p.read_i32()?))
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::MyStruct {
    fn default() -> Self {
        Self {
            _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")
            .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 ::fbthrift::GetTType for self::MyStruct {
    const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}

impl ::fbthrift::GetUri for self::MyStruct {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/MyStruct"
    }
}

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

impl<P> ::fbthrift::Deserialize<P> for self::MyStruct
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
        ];
        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,
                (fty, _) => p.skip(fty)?,
            }
            p.read_field_end()?;
        }
        p.read_struct_end()?;
        ::std::result::Result::Ok(Self {
            _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>();

        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 {
            _ => {}
        }

        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 str {
        "facebook.com/thrift/test/terse_write/MyUnion"
    }
}

impl<P> ::fbthrift::Serialize<P> for MyUnion
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyUnion");
        match self {
            Self::bool_field(inner) => {
                p.write_field_begin("bool_field", ::fbthrift::TType::Bool, 1);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::byte_field(inner) => {
                p.write_field_begin("byte_field", ::fbthrift::TType::Byte, 2);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::short_field(inner) => {
                p.write_field_begin("short_field", ::fbthrift::TType::I16, 3);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::int_field(inner) => {
                p.write_field_begin("int_field", ::fbthrift::TType::I32, 4);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::long_field(inner) => {
                p.write_field_begin("long_field", ::fbthrift::TType::I64, 5);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::float_field(inner) => {
                p.write_field_begin("float_field", ::fbthrift::TType::Float, 6);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::double_field(inner) => {
                p.write_field_begin("double_field", ::fbthrift::TType::Double, 7);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::string_field(inner) => {
                p.write_field_begin("string_field", ::fbthrift::TType::String, 8);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::binary_field(inner) => {
                p.write_field_begin("binary_field", ::fbthrift::TType::String, 9);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::enum_field(inner) => {
                p.write_field_begin("enum_field", ::fbthrift::TType::I32, 10);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::list_field(inner) => {
                p.write_field_begin("list_field", ::fbthrift::TType::List, 11);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::set_field(inner) => {
                p.write_field_begin("set_field", ::fbthrift::TType::Set, 12);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::map_field(inner) => {
                p.write_field_begin("map_field", ::fbthrift::TType::Map, 13);
                ::fbthrift::Serialize::write(inner, p);
                p.write_field_end();
            }
            Self::struct_field(inner) => {
                p.write_field_begin("struct_field", ::fbthrift::TType::Struct, 14);
                ::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,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("binary_field", ::fbthrift::TType::String, 9),
            ::fbthrift::Field::new("bool_field", ::fbthrift::TType::Bool, 1),
            ::fbthrift::Field::new("byte_field", ::fbthrift::TType::Byte, 2),
            ::fbthrift::Field::new("double_field", ::fbthrift::TType::Double, 7),
            ::fbthrift::Field::new("enum_field", ::fbthrift::TType::I32, 10),
            ::fbthrift::Field::new("float_field", ::fbthrift::TType::Float, 6),
            ::fbthrift::Field::new("int_field", ::fbthrift::TType::I32, 4),
            ::fbthrift::Field::new("list_field", ::fbthrift::TType::List, 11),
            ::fbthrift::Field::new("long_field", ::fbthrift::TType::I64, 5),
            ::fbthrift::Field::new("map_field", ::fbthrift::TType::Map, 13),
            ::fbthrift::Field::new("set_field", ::fbthrift::TType::Set, 12),
            ::fbthrift::Field::new("short_field", ::fbthrift::TType::I16, 3),
            ::fbthrift::Field::new("string_field", ::fbthrift::TType::String, 8),
            ::fbthrift::Field::new("struct_field", ::fbthrift::TType::Struct, 14),
        ];
        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::Bool, 1, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::bool_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Byte, 2, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::byte_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::I16, 3, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::short_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::I32, 4, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::int_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::I64, 5, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::long_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Float, 6, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::float_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Double, 7, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::double_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::String, 8, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::string_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::String, 9, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::binary_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::I32, 10, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::enum_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::List, 11, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::list_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Set, 12, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::set_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Map, 13, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::map_field(::fbthrift::Deserialize::read(p)?));
                }
                (::fbthrift::TType::Struct, 14, false) => {
                    once = true;
                    alt = ::std::option::Option::Some(Self::struct_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(
                    "MyUnion".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 MyUnion {
    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 => {
            },
            6 => {
            },
            7 => {
            },
            8 => {
            },
            9 => {
            },
            10 => {
            },
            11 => {
            },
            12 => {
            },
            13 => {
            },
            14 => {
            },
            _ => {}
        }

        None
    }
}

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

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

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

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

impl ::fbthrift::GetUri for self::MyStructWithCustomDefault {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/MyStructWithCustomDefault"
    }
}

impl<P> ::fbthrift::Serialize<P> for self::MyStructWithCustomDefault
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("MyStructWithCustomDefault");
        p.write_field_begin("field1", ::fbthrift::TType::I64, 1);
        ::fbthrift::Serialize::write(&self.field1, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::MyStructWithCustomDefault
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("field1", ::fbthrift::TType::I64, 1),
        ];
        let mut field_field1 = ::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::I64, 1) => field_field1 = ::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 {
            field1: field_field1.unwrap_or(1),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for MyStructWithCustomDefault {
    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 => {
            },
            _ => {}
        }

        None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::StructLevelTerseStruct {
    fn default() -> Self {
        Self {
            bool_field: ::std::default::Default::default(),
            byte_field: ::std::default::Default::default(),
            short_field: ::std::default::Default::default(),
            int_field: ::std::default::Default::default(),
            long_field: ::std::default::Default::default(),
            float_field: ::std::default::Default::default(),
            double_field: ::std::default::Default::default(),
            string_field: ::std::default::Default::default(),
            binary_field: ::std::default::Default::default(),
            enum_field: ::std::default::Default::default(),
            list_field: ::std::default::Default::default(),
            set_field: ::std::default::Default::default(),
            map_field: ::std::default::Default::default(),
            struct_field: ::std::default::Default::default(),
            union_field: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::StructLevelTerseStruct {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("StructLevelTerseStruct")
            .field("bool_field", &self.bool_field)
            .field("byte_field", &self.byte_field)
            .field("short_field", &self.short_field)
            .field("int_field", &self.int_field)
            .field("long_field", &self.long_field)
            .field("float_field", &self.float_field)
            .field("double_field", &self.double_field)
            .field("string_field", &self.string_field)
            .field("binary_field", &self.binary_field)
            .field("enum_field", &self.enum_field)
            .field("list_field", &self.list_field)
            .field("set_field", &self.set_field)
            .field("map_field", &self.map_field)
            .field("struct_field", &self.struct_field)
            .field("union_field", &self.union_field)
            .finish()
    }
}

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

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

impl ::fbthrift::GetUri for self::StructLevelTerseStruct {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/StructLevelTerseStruct"
    }
}

impl<P> ::fbthrift::Serialize<P> for self::StructLevelTerseStruct
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("StructLevelTerseStruct");
        p.write_field_begin("bool_field", ::fbthrift::TType::Bool, 1);
        ::fbthrift::Serialize::write(&self.bool_field, p);
        p.write_field_end();
        p.write_field_begin("byte_field", ::fbthrift::TType::Byte, 2);
        ::fbthrift::Serialize::write(&self.byte_field, p);
        p.write_field_end();
        p.write_field_begin("short_field", ::fbthrift::TType::I16, 3);
        ::fbthrift::Serialize::write(&self.short_field, p);
        p.write_field_end();
        p.write_field_begin("int_field", ::fbthrift::TType::I32, 4);
        ::fbthrift::Serialize::write(&self.int_field, p);
        p.write_field_end();
        p.write_field_begin("long_field", ::fbthrift::TType::I64, 5);
        ::fbthrift::Serialize::write(&self.long_field, p);
        p.write_field_end();
        p.write_field_begin("float_field", ::fbthrift::TType::Float, 6);
        ::fbthrift::Serialize::write(&self.float_field, p);
        p.write_field_end();
        p.write_field_begin("double_field", ::fbthrift::TType::Double, 7);
        ::fbthrift::Serialize::write(&self.double_field, p);
        p.write_field_end();
        p.write_field_begin("string_field", ::fbthrift::TType::String, 8);
        ::fbthrift::Serialize::write(&self.string_field, p);
        p.write_field_end();
        p.write_field_begin("binary_field", ::fbthrift::TType::String, 9);
        ::fbthrift::Serialize::write(&self.binary_field, p);
        p.write_field_end();
        p.write_field_begin("enum_field", ::fbthrift::TType::I32, 10);
        ::fbthrift::Serialize::write(&self.enum_field, p);
        p.write_field_end();
        p.write_field_begin("list_field", ::fbthrift::TType::List, 11);
        ::fbthrift::Serialize::write(&self.list_field, p);
        p.write_field_end();
        p.write_field_begin("set_field", ::fbthrift::TType::Set, 12);
        ::fbthrift::Serialize::write(&self.set_field, p);
        p.write_field_end();
        p.write_field_begin("map_field", ::fbthrift::TType::Map, 13);
        ::fbthrift::Serialize::write(&self.map_field, p);
        p.write_field_end();
        p.write_field_begin("struct_field", ::fbthrift::TType::Struct, 14);
        ::fbthrift::Serialize::write(&self.struct_field, p);
        p.write_field_end();
        p.write_field_begin("union_field", ::fbthrift::TType::Struct, 15);
        ::fbthrift::Serialize::write(&self.union_field, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::StructLevelTerseStruct
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("binary_field", ::fbthrift::TType::String, 9),
            ::fbthrift::Field::new("bool_field", ::fbthrift::TType::Bool, 1),
            ::fbthrift::Field::new("byte_field", ::fbthrift::TType::Byte, 2),
            ::fbthrift::Field::new("double_field", ::fbthrift::TType::Double, 7),
            ::fbthrift::Field::new("enum_field", ::fbthrift::TType::I32, 10),
            ::fbthrift::Field::new("float_field", ::fbthrift::TType::Float, 6),
            ::fbthrift::Field::new("int_field", ::fbthrift::TType::I32, 4),
            ::fbthrift::Field::new("list_field", ::fbthrift::TType::List, 11),
            ::fbthrift::Field::new("long_field", ::fbthrift::TType::I64, 5),
            ::fbthrift::Field::new("map_field", ::fbthrift::TType::Map, 13),
            ::fbthrift::Field::new("set_field", ::fbthrift::TType::Set, 12),
            ::fbthrift::Field::new("short_field", ::fbthrift::TType::I16, 3),
            ::fbthrift::Field::new("string_field", ::fbthrift::TType::String, 8),
            ::fbthrift::Field::new("struct_field", ::fbthrift::TType::Struct, 14),
            ::fbthrift::Field::new("union_field", ::fbthrift::TType::Struct, 15),
        ];
        let mut field_bool_field = ::std::option::Option::None;
        let mut field_byte_field = ::std::option::Option::None;
        let mut field_short_field = ::std::option::Option::None;
        let mut field_int_field = ::std::option::Option::None;
        let mut field_long_field = ::std::option::Option::None;
        let mut field_float_field = ::std::option::Option::None;
        let mut field_double_field = ::std::option::Option::None;
        let mut field_string_field = ::std::option::Option::None;
        let mut field_binary_field = ::std::option::Option::None;
        let mut field_enum_field = ::std::option::Option::None;
        let mut field_list_field = ::std::option::Option::None;
        let mut field_set_field = ::std::option::Option::None;
        let mut field_map_field = ::std::option::Option::None;
        let mut field_struct_field = ::std::option::Option::None;
        let mut field_union_field = ::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::Bool, 1) => field_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Byte, 2) => field_byte_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I16, 3) => field_short_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 4) => field_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I64, 5) => field_long_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Float, 6) => field_float_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 7) => field_double_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 8) => field_string_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 9) => field_binary_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 10) => field_enum_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::List, 11) => field_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 12) => field_set_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Map, 13) => field_map_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 14) => field_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 15) => field_union_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 {
            bool_field: field_bool_field.unwrap_or_default(),
            byte_field: field_byte_field.unwrap_or_default(),
            short_field: field_short_field.unwrap_or_default(),
            int_field: field_int_field.unwrap_or_default(),
            long_field: field_long_field.unwrap_or_default(),
            float_field: field_float_field.unwrap_or_default(),
            double_field: field_double_field.unwrap_or_default(),
            string_field: field_string_field.unwrap_or_default(),
            binary_field: field_binary_field.unwrap_or_default(),
            enum_field: field_enum_field.unwrap_or_default(),
            list_field: field_list_field.unwrap_or_default(),
            set_field: field_set_field.unwrap_or_default(),
            map_field: field_map_field.unwrap_or_default(),
            struct_field: field_struct_field.unwrap_or_default(),
            union_field: field_union_field.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for StructLevelTerseStruct {
    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::<thrift::types::TerseWrite>() {
            let mut tmp = Some(thrift::types::TerseWrite {
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        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 => {
            },
            6 => {
            },
            7 => {
            },
            8 => {
            },
            9 => {
            },
            10 => {
            },
            11 => {
            },
            12 => {
            },
            13 => {
            },
            14 => {
            },
            15 => {
            },
            _ => {}
        }

        None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::FieldLevelTerseStruct {
    fn default() -> Self {
        Self {
            terse_bool_field: ::std::default::Default::default(),
            terse_byte_field: ::std::default::Default::default(),
            terse_short_field: ::std::default::Default::default(),
            terse_int_field: ::std::default::Default::default(),
            terse_long_field: ::std::default::Default::default(),
            terse_float_field: ::std::default::Default::default(),
            terse_double_field: ::std::default::Default::default(),
            terse_string_field: ::std::default::Default::default(),
            terse_binary_field: ::std::default::Default::default(),
            terse_enum_field: ::std::default::Default::default(),
            terse_list_field: ::std::default::Default::default(),
            terse_set_field: ::std::default::Default::default(),
            terse_map_field: ::std::default::Default::default(),
            terse_struct_field: ::std::default::Default::default(),
            terse_union_field: ::std::default::Default::default(),
            bool_field: ::std::default::Default::default(),
            byte_field: ::std::default::Default::default(),
            short_field: ::std::default::Default::default(),
            int_field: ::std::default::Default::default(),
            long_field: ::std::default::Default::default(),
            float_field: ::std::default::Default::default(),
            double_field: ::std::default::Default::default(),
            string_field: ::std::default::Default::default(),
            binary_field: ::std::default::Default::default(),
            enum_field: ::std::default::Default::default(),
            list_field: ::std::default::Default::default(),
            set_field: ::std::default::Default::default(),
            map_field: ::std::default::Default::default(),
            struct_field: ::std::default::Default::default(),
            union_field: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::FieldLevelTerseStruct {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("FieldLevelTerseStruct")
            .field("terse_bool_field", &self.terse_bool_field)
            .field("terse_byte_field", &self.terse_byte_field)
            .field("terse_short_field", &self.terse_short_field)
            .field("terse_int_field", &self.terse_int_field)
            .field("terse_long_field", &self.terse_long_field)
            .field("terse_float_field", &self.terse_float_field)
            .field("terse_double_field", &self.terse_double_field)
            .field("terse_string_field", &self.terse_string_field)
            .field("terse_binary_field", &self.terse_binary_field)
            .field("terse_enum_field", &self.terse_enum_field)
            .field("terse_list_field", &self.terse_list_field)
            .field("terse_set_field", &self.terse_set_field)
            .field("terse_map_field", &self.terse_map_field)
            .field("terse_struct_field", &self.terse_struct_field)
            .field("terse_union_field", &self.terse_union_field)
            .field("bool_field", &self.bool_field)
            .field("byte_field", &self.byte_field)
            .field("short_field", &self.short_field)
            .field("int_field", &self.int_field)
            .field("long_field", &self.long_field)
            .field("float_field", &self.float_field)
            .field("double_field", &self.double_field)
            .field("string_field", &self.string_field)
            .field("binary_field", &self.binary_field)
            .field("enum_field", &self.enum_field)
            .field("list_field", &self.list_field)
            .field("set_field", &self.set_field)
            .field("map_field", &self.map_field)
            .field("struct_field", &self.struct_field)
            .field("union_field", &self.union_field)
            .finish()
    }
}

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

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

impl ::fbthrift::GetUri for self::FieldLevelTerseStruct {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/FieldLevelTerseStruct"
    }
}

impl<P> ::fbthrift::Serialize<P> for self::FieldLevelTerseStruct
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("FieldLevelTerseStruct");
        p.write_field_begin("terse_bool_field", ::fbthrift::TType::Bool, 1);
        ::fbthrift::Serialize::write(&self.terse_bool_field, p);
        p.write_field_end();
        p.write_field_begin("terse_byte_field", ::fbthrift::TType::Byte, 2);
        ::fbthrift::Serialize::write(&self.terse_byte_field, p);
        p.write_field_end();
        p.write_field_begin("terse_short_field", ::fbthrift::TType::I16, 3);
        ::fbthrift::Serialize::write(&self.terse_short_field, p);
        p.write_field_end();
        p.write_field_begin("terse_int_field", ::fbthrift::TType::I32, 4);
        ::fbthrift::Serialize::write(&self.terse_int_field, p);
        p.write_field_end();
        p.write_field_begin("terse_long_field", ::fbthrift::TType::I64, 5);
        ::fbthrift::Serialize::write(&self.terse_long_field, p);
        p.write_field_end();
        p.write_field_begin("terse_float_field", ::fbthrift::TType::Float, 6);
        ::fbthrift::Serialize::write(&self.terse_float_field, p);
        p.write_field_end();
        p.write_field_begin("terse_double_field", ::fbthrift::TType::Double, 7);
        ::fbthrift::Serialize::write(&self.terse_double_field, p);
        p.write_field_end();
        p.write_field_begin("terse_string_field", ::fbthrift::TType::String, 8);
        ::fbthrift::Serialize::write(&self.terse_string_field, p);
        p.write_field_end();
        p.write_field_begin("terse_binary_field", ::fbthrift::TType::String, 9);
        ::fbthrift::Serialize::write(&self.terse_binary_field, p);
        p.write_field_end();
        p.write_field_begin("terse_enum_field", ::fbthrift::TType::I32, 10);
        ::fbthrift::Serialize::write(&self.terse_enum_field, p);
        p.write_field_end();
        p.write_field_begin("terse_list_field", ::fbthrift::TType::List, 11);
        ::fbthrift::Serialize::write(&self.terse_list_field, p);
        p.write_field_end();
        p.write_field_begin("terse_set_field", ::fbthrift::TType::Set, 12);
        ::fbthrift::Serialize::write(&self.terse_set_field, p);
        p.write_field_end();
        p.write_field_begin("terse_map_field", ::fbthrift::TType::Map, 13);
        ::fbthrift::Serialize::write(&self.terse_map_field, p);
        p.write_field_end();
        p.write_field_begin("terse_struct_field", ::fbthrift::TType::Struct, 14);
        ::fbthrift::Serialize::write(&self.terse_struct_field, p);
        p.write_field_end();
        p.write_field_begin("terse_union_field", ::fbthrift::TType::Struct, 29);
        ::fbthrift::Serialize::write(&self.terse_union_field, p);
        p.write_field_end();
        p.write_field_begin("bool_field", ::fbthrift::TType::Bool, 15);
        ::fbthrift::Serialize::write(&self.bool_field, p);
        p.write_field_end();
        p.write_field_begin("byte_field", ::fbthrift::TType::Byte, 16);
        ::fbthrift::Serialize::write(&self.byte_field, p);
        p.write_field_end();
        p.write_field_begin("short_field", ::fbthrift::TType::I16, 17);
        ::fbthrift::Serialize::write(&self.short_field, p);
        p.write_field_end();
        p.write_field_begin("int_field", ::fbthrift::TType::I32, 18);
        ::fbthrift::Serialize::write(&self.int_field, p);
        p.write_field_end();
        p.write_field_begin("long_field", ::fbthrift::TType::I64, 19);
        ::fbthrift::Serialize::write(&self.long_field, p);
        p.write_field_end();
        p.write_field_begin("float_field", ::fbthrift::TType::Float, 20);
        ::fbthrift::Serialize::write(&self.float_field, p);
        p.write_field_end();
        p.write_field_begin("double_field", ::fbthrift::TType::Double, 21);
        ::fbthrift::Serialize::write(&self.double_field, p);
        p.write_field_end();
        p.write_field_begin("string_field", ::fbthrift::TType::String, 22);
        ::fbthrift::Serialize::write(&self.string_field, p);
        p.write_field_end();
        p.write_field_begin("binary_field", ::fbthrift::TType::String, 23);
        ::fbthrift::Serialize::write(&self.binary_field, p);
        p.write_field_end();
        p.write_field_begin("enum_field", ::fbthrift::TType::I32, 24);
        ::fbthrift::Serialize::write(&self.enum_field, p);
        p.write_field_end();
        p.write_field_begin("list_field", ::fbthrift::TType::List, 25);
        ::fbthrift::Serialize::write(&self.list_field, p);
        p.write_field_end();
        p.write_field_begin("set_field", ::fbthrift::TType::Set, 26);
        ::fbthrift::Serialize::write(&self.set_field, p);
        p.write_field_end();
        p.write_field_begin("map_field", ::fbthrift::TType::Map, 27);
        ::fbthrift::Serialize::write(&self.map_field, p);
        p.write_field_end();
        p.write_field_begin("struct_field", ::fbthrift::TType::Struct, 28);
        ::fbthrift::Serialize::write(&self.struct_field, p);
        p.write_field_end();
        p.write_field_begin("union_field", ::fbthrift::TType::Struct, 30);
        ::fbthrift::Serialize::write(&self.union_field, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::FieldLevelTerseStruct
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("binary_field", ::fbthrift::TType::String, 23),
            ::fbthrift::Field::new("bool_field", ::fbthrift::TType::Bool, 15),
            ::fbthrift::Field::new("byte_field", ::fbthrift::TType::Byte, 16),
            ::fbthrift::Field::new("double_field", ::fbthrift::TType::Double, 21),
            ::fbthrift::Field::new("enum_field", ::fbthrift::TType::I32, 24),
            ::fbthrift::Field::new("float_field", ::fbthrift::TType::Float, 20),
            ::fbthrift::Field::new("int_field", ::fbthrift::TType::I32, 18),
            ::fbthrift::Field::new("list_field", ::fbthrift::TType::List, 25),
            ::fbthrift::Field::new("long_field", ::fbthrift::TType::I64, 19),
            ::fbthrift::Field::new("map_field", ::fbthrift::TType::Map, 27),
            ::fbthrift::Field::new("set_field", ::fbthrift::TType::Set, 26),
            ::fbthrift::Field::new("short_field", ::fbthrift::TType::I16, 17),
            ::fbthrift::Field::new("string_field", ::fbthrift::TType::String, 22),
            ::fbthrift::Field::new("struct_field", ::fbthrift::TType::Struct, 28),
            ::fbthrift::Field::new("terse_binary_field", ::fbthrift::TType::String, 9),
            ::fbthrift::Field::new("terse_bool_field", ::fbthrift::TType::Bool, 1),
            ::fbthrift::Field::new("terse_byte_field", ::fbthrift::TType::Byte, 2),
            ::fbthrift::Field::new("terse_double_field", ::fbthrift::TType::Double, 7),
            ::fbthrift::Field::new("terse_enum_field", ::fbthrift::TType::I32, 10),
            ::fbthrift::Field::new("terse_float_field", ::fbthrift::TType::Float, 6),
            ::fbthrift::Field::new("terse_int_field", ::fbthrift::TType::I32, 4),
            ::fbthrift::Field::new("terse_list_field", ::fbthrift::TType::List, 11),
            ::fbthrift::Field::new("terse_long_field", ::fbthrift::TType::I64, 5),
            ::fbthrift::Field::new("terse_map_field", ::fbthrift::TType::Map, 13),
            ::fbthrift::Field::new("terse_set_field", ::fbthrift::TType::Set, 12),
            ::fbthrift::Field::new("terse_short_field", ::fbthrift::TType::I16, 3),
            ::fbthrift::Field::new("terse_string_field", ::fbthrift::TType::String, 8),
            ::fbthrift::Field::new("terse_struct_field", ::fbthrift::TType::Struct, 14),
            ::fbthrift::Field::new("terse_union_field", ::fbthrift::TType::Struct, 29),
            ::fbthrift::Field::new("union_field", ::fbthrift::TType::Struct, 30),
        ];
        let mut field_terse_bool_field = ::std::option::Option::None;
        let mut field_terse_byte_field = ::std::option::Option::None;
        let mut field_terse_short_field = ::std::option::Option::None;
        let mut field_terse_int_field = ::std::option::Option::None;
        let mut field_terse_long_field = ::std::option::Option::None;
        let mut field_terse_float_field = ::std::option::Option::None;
        let mut field_terse_double_field = ::std::option::Option::None;
        let mut field_terse_string_field = ::std::option::Option::None;
        let mut field_terse_binary_field = ::std::option::Option::None;
        let mut field_terse_enum_field = ::std::option::Option::None;
        let mut field_terse_list_field = ::std::option::Option::None;
        let mut field_terse_set_field = ::std::option::Option::None;
        let mut field_terse_map_field = ::std::option::Option::None;
        let mut field_terse_struct_field = ::std::option::Option::None;
        let mut field_terse_union_field = ::std::option::Option::None;
        let mut field_bool_field = ::std::option::Option::None;
        let mut field_byte_field = ::std::option::Option::None;
        let mut field_short_field = ::std::option::Option::None;
        let mut field_int_field = ::std::option::Option::None;
        let mut field_long_field = ::std::option::Option::None;
        let mut field_float_field = ::std::option::Option::None;
        let mut field_double_field = ::std::option::Option::None;
        let mut field_string_field = ::std::option::Option::None;
        let mut field_binary_field = ::std::option::Option::None;
        let mut field_enum_field = ::std::option::Option::None;
        let mut field_list_field = ::std::option::Option::None;
        let mut field_set_field = ::std::option::Option::None;
        let mut field_map_field = ::std::option::Option::None;
        let mut field_struct_field = ::std::option::Option::None;
        let mut field_union_field = ::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::Bool, 1) => field_terse_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Byte, 2) => field_terse_byte_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I16, 3) => field_terse_short_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 4) => field_terse_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I64, 5) => field_terse_long_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Float, 6) => field_terse_float_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 7) => field_terse_double_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 8) => field_terse_string_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 9) => field_terse_binary_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 10) => field_terse_enum_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::List, 11) => field_terse_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 12) => field_terse_set_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Map, 13) => field_terse_map_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 14) => field_terse_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 29) => field_terse_union_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Bool, 15) => field_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Byte, 16) => field_byte_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I16, 17) => field_short_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 18) => field_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I64, 19) => field_long_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Float, 20) => field_float_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 21) => field_double_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 22) => field_string_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 23) => field_binary_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 24) => field_enum_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::List, 25) => field_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 26) => field_set_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Map, 27) => field_map_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 28) => field_struct_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 30) => field_union_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 {
            terse_bool_field: field_terse_bool_field.unwrap_or_default(),
            terse_byte_field: field_terse_byte_field.unwrap_or_default(),
            terse_short_field: field_terse_short_field.unwrap_or_default(),
            terse_int_field: field_terse_int_field.unwrap_or_default(),
            terse_long_field: field_terse_long_field.unwrap_or_default(),
            terse_float_field: field_terse_float_field.unwrap_or_default(),
            terse_double_field: field_terse_double_field.unwrap_or_default(),
            terse_string_field: field_terse_string_field.unwrap_or_default(),
            terse_binary_field: field_terse_binary_field.unwrap_or_default(),
            terse_enum_field: field_terse_enum_field.unwrap_or_default(),
            terse_list_field: field_terse_list_field.unwrap_or_default(),
            terse_set_field: field_terse_set_field.unwrap_or_default(),
            terse_map_field: field_terse_map_field.unwrap_or_default(),
            terse_struct_field: field_terse_struct_field.unwrap_or_default(),
            terse_union_field: field_terse_union_field.unwrap_or_default(),
            bool_field: field_bool_field.unwrap_or_default(),
            byte_field: field_byte_field.unwrap_or_default(),
            short_field: field_short_field.unwrap_or_default(),
            int_field: field_int_field.unwrap_or_default(),
            long_field: field_long_field.unwrap_or_default(),
            float_field: field_float_field.unwrap_or_default(),
            double_field: field_double_field.unwrap_or_default(),
            string_field: field_string_field.unwrap_or_default(),
            binary_field: field_binary_field.unwrap_or_default(),
            enum_field: field_enum_field.unwrap_or_default(),
            list_field: field_list_field.unwrap_or_default(),
            set_field: field_set_field.unwrap_or_default(),
            map_field: field_map_field.unwrap_or_default(),
            struct_field: field_struct_field.unwrap_or_default(),
            union_field: field_union_field.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for FieldLevelTerseStruct {
    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 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            2 => {

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

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

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            5 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            6 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            7 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            8 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            9 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            10 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            11 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            12 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            13 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            14 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            29 => {

                if type_id == ::std::any::TypeId::of::<thrift::types::TerseWrite>() {
                    let mut tmp = Some(thrift::types::TerseWrite {
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            15 => {
            },
            16 => {
            },
            17 => {
            },
            18 => {
            },
            19 => {
            },
            20 => {
            },
            21 => {
            },
            22 => {
            },
            23 => {
            },
            24 => {
            },
            25 => {
            },
            26 => {
            },
            27 => {
            },
            28 => {
            },
            30 => {
            },
            _ => {}
        }

        None
    }
}

#[allow(clippy::derivable_impls)]
impl ::std::default::Default for self::TerseStructWithCustomDefault {
    fn default() -> Self {
        Self {
            bool_field: true,
            byte_field: 1,
            short_field: 2,
            int_field: 3,
            long_field: 4,
            float_field: 5.0,
            double_field: 6.0,
            string_field: "7".to_owned(),
            binary_field: "8".as_bytes().into(),
            enum_field: crate::types::MyEnum::ME1,
            list_field: vec![
                    1,
                ],
            set_field: {
                    let mut set = ::std::collections::BTreeSet::new();
                    set.insert(1);
                    set
                },
            map_field: {
                    let mut map = ::std::collections::BTreeMap::new();
                    map.insert(1, 1);
                    map
                },
            struct_field: ::std::default::Default::default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        }
    }
}

impl ::std::fmt::Debug for self::TerseStructWithCustomDefault {
    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        formatter
            .debug_struct("TerseStructWithCustomDefault")
            .field("bool_field", &self.bool_field)
            .field("byte_field", &self.byte_field)
            .field("short_field", &self.short_field)
            .field("int_field", &self.int_field)
            .field("long_field", &self.long_field)
            .field("float_field", &self.float_field)
            .field("double_field", &self.double_field)
            .field("string_field", &self.string_field)
            .field("binary_field", &self.binary_field)
            .field("enum_field", &self.enum_field)
            .field("list_field", &self.list_field)
            .field("set_field", &self.set_field)
            .field("map_field", &self.map_field)
            .field("struct_field", &self.struct_field)
            .finish()
    }
}

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

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

impl ::fbthrift::GetUri for self::TerseStructWithCustomDefault {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/TerseStructWithCustomDefault"
    }
}

impl<P> ::fbthrift::Serialize<P> for self::TerseStructWithCustomDefault
where
    P: ::fbthrift::ProtocolWriter,
{
    fn write(&self, p: &mut P) {
        p.write_struct_begin("TerseStructWithCustomDefault");
        p.write_field_begin("bool_field", ::fbthrift::TType::Bool, 1);
        ::fbthrift::Serialize::write(&self.bool_field, p);
        p.write_field_end();
        p.write_field_begin("byte_field", ::fbthrift::TType::Byte, 2);
        ::fbthrift::Serialize::write(&self.byte_field, p);
        p.write_field_end();
        p.write_field_begin("short_field", ::fbthrift::TType::I16, 3);
        ::fbthrift::Serialize::write(&self.short_field, p);
        p.write_field_end();
        p.write_field_begin("int_field", ::fbthrift::TType::I32, 4);
        ::fbthrift::Serialize::write(&self.int_field, p);
        p.write_field_end();
        p.write_field_begin("long_field", ::fbthrift::TType::I64, 5);
        ::fbthrift::Serialize::write(&self.long_field, p);
        p.write_field_end();
        p.write_field_begin("float_field", ::fbthrift::TType::Float, 6);
        ::fbthrift::Serialize::write(&self.float_field, p);
        p.write_field_end();
        p.write_field_begin("double_field", ::fbthrift::TType::Double, 7);
        ::fbthrift::Serialize::write(&self.double_field, p);
        p.write_field_end();
        p.write_field_begin("string_field", ::fbthrift::TType::String, 8);
        ::fbthrift::Serialize::write(&self.string_field, p);
        p.write_field_end();
        p.write_field_begin("binary_field", ::fbthrift::TType::String, 9);
        ::fbthrift::Serialize::write(&self.binary_field, p);
        p.write_field_end();
        p.write_field_begin("enum_field", ::fbthrift::TType::I32, 10);
        ::fbthrift::Serialize::write(&self.enum_field, p);
        p.write_field_end();
        p.write_field_begin("list_field", ::fbthrift::TType::List, 11);
        ::fbthrift::Serialize::write(&self.list_field, p);
        p.write_field_end();
        p.write_field_begin("set_field", ::fbthrift::TType::Set, 12);
        ::fbthrift::Serialize::write(&self.set_field, p);
        p.write_field_end();
        p.write_field_begin("map_field", ::fbthrift::TType::Map, 13);
        ::fbthrift::Serialize::write(&self.map_field, p);
        p.write_field_end();
        p.write_field_begin("struct_field", ::fbthrift::TType::Struct, 14);
        ::fbthrift::Serialize::write(&self.struct_field, p);
        p.write_field_end();
        p.write_field_stop();
        p.write_struct_end();
    }
}

impl<P> ::fbthrift::Deserialize<P> for self::TerseStructWithCustomDefault
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("binary_field", ::fbthrift::TType::String, 9),
            ::fbthrift::Field::new("bool_field", ::fbthrift::TType::Bool, 1),
            ::fbthrift::Field::new("byte_field", ::fbthrift::TType::Byte, 2),
            ::fbthrift::Field::new("double_field", ::fbthrift::TType::Double, 7),
            ::fbthrift::Field::new("enum_field", ::fbthrift::TType::I32, 10),
            ::fbthrift::Field::new("float_field", ::fbthrift::TType::Float, 6),
            ::fbthrift::Field::new("int_field", ::fbthrift::TType::I32, 4),
            ::fbthrift::Field::new("list_field", ::fbthrift::TType::List, 11),
            ::fbthrift::Field::new("long_field", ::fbthrift::TType::I64, 5),
            ::fbthrift::Field::new("map_field", ::fbthrift::TType::Map, 13),
            ::fbthrift::Field::new("set_field", ::fbthrift::TType::Set, 12),
            ::fbthrift::Field::new("short_field", ::fbthrift::TType::I16, 3),
            ::fbthrift::Field::new("string_field", ::fbthrift::TType::String, 8),
            ::fbthrift::Field::new("struct_field", ::fbthrift::TType::Struct, 14),
        ];
        let mut field_bool_field = ::std::option::Option::None;
        let mut field_byte_field = ::std::option::Option::None;
        let mut field_short_field = ::std::option::Option::None;
        let mut field_int_field = ::std::option::Option::None;
        let mut field_long_field = ::std::option::Option::None;
        let mut field_float_field = ::std::option::Option::None;
        let mut field_double_field = ::std::option::Option::None;
        let mut field_string_field = ::std::option::Option::None;
        let mut field_binary_field = ::std::option::Option::None;
        let mut field_enum_field = ::std::option::Option::None;
        let mut field_list_field = ::std::option::Option::None;
        let mut field_set_field = ::std::option::Option::None;
        let mut field_map_field = ::std::option::Option::None;
        let mut field_struct_field = ::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::Bool, 1) => field_bool_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Byte, 2) => field_byte_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I16, 3) => field_short_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 4) => field_int_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I64, 5) => field_long_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Float, 6) => field_float_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Double, 7) => field_double_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 8) => field_string_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::String, 9) => field_binary_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 10) => field_enum_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::List, 11) => field_list_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Set, 12) => field_set_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Map, 13) => field_map_field = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::Struct, 14) => field_struct_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 {
            bool_field: field_bool_field.unwrap_or(true),
            byte_field: field_byte_field.unwrap_or_else(|| 1),
            short_field: field_short_field.unwrap_or(2),
            int_field: field_int_field.unwrap_or(3),
            long_field: field_long_field.unwrap_or(4),
            float_field: field_float_field.unwrap_or(5.0),
            double_field: field_double_field.unwrap_or(6.0),
            string_field: field_string_field.unwrap_or_else(|| "7".to_owned()),
            binary_field: field_binary_field.unwrap_or_else(|| "8".as_bytes().into()),
            enum_field: field_enum_field.unwrap_or(crate::types::MyEnum::ME1),
            list_field: field_list_field.unwrap_or_else(|| vec![
                    1,
                ]),
            set_field: field_set_field.unwrap_or_else(|| {
                    let mut set = ::std::collections::BTreeSet::new();
                    set.insert(1);
                    set
                }),
            map_field: field_map_field.unwrap_or_else(|| {
                    let mut map = ::std::collections::BTreeMap::new();
                    map.insert(1, 1);
                    map
                }),
            struct_field: field_struct_field.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for TerseStructWithCustomDefault {
    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::<thrift::types::TerseWrite>() {
            let mut tmp = Some(thrift::types::TerseWrite {
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        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 => {
            },
            6 => {
            },
            7 => {
            },
            8 => {
            },
            9 => {
            },
            10 => {
            },
            11 => {
            },
            12 => {
            },
            13 => {
            },
            14 => {
            },
            _ => {}
        }

        None
    }
}

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

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

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

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

impl ::fbthrift::GetUri for self::AdaptedFields {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/AdaptedFields"
    }
}

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

impl<P> ::fbthrift::Deserialize<P> for self::AdaptedFields
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("field1", ::fbthrift::TType::I32, 1),
            ::fbthrift::Field::new("field2", ::fbthrift::TType::I32, 2),
            ::fbthrift::Field::new("field3", ::fbthrift::TType::I32, 3),
        ];
        let mut field_field1 = ::std::option::Option::None;
        let mut field_field2 = ::std::option::Option::None;
        let mut field_field3 = ::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_field1 = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 2) => field_field2 = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                (::fbthrift::TType::I32, 3) => field_field3 = ::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 {
            field1: field_field1.unwrap_or_default(),
            field2: field_field2.unwrap_or_default(),
            field3: field_field3.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for AdaptedFields {
    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::<thrift::types::TerseWrite>() {
            let mut tmp = Some(thrift::types::TerseWrite {
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        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 => {

                if type_id == ::std::any::TypeId::of::<hack::types::Adapter>() {
                    let mut tmp = Some(hack::types::Adapter {
                        name: "\\Adapter1".to_owned(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }

                if type_id == ::std::any::TypeId::of::<cpp::types::Adapter>() {
                    let mut tmp = Some(cpp::types::Adapter {
                        name: "::my::Adapter".to_owned(),
                        adaptedType: ::std::default::Default::default(),
                        underlyingName: ::std::default::Default::default(),
                        extraNamespace: ::std::default::Default::default(),
                        moveOnly: ::std::default::Default::default(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }

                if let Some(r) = <cpp::types::Adapter as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
                    return Some(r);
                }
            },
            3 => {

                if type_id == ::std::any::TypeId::of::<cpp::types::Adapter>() {
                    let mut tmp = Some(cpp::types::Adapter {
                        name: "::my::Adapter".to_owned(),
                        adaptedType: ::std::default::Default::default(),
                        underlyingName: ::std::default::Default::default(),
                        extraNamespace: ::std::default::Default::default(),
                        moveOnly: ::std::default::Default::default(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }

                if let Some(r) = <cpp::types::Adapter as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::<T>() {
                    return Some(r);
                }
            },
            _ => {}
        }

        None
    }
}

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

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

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

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

impl ::fbthrift::GetUri for self::WrappedFields {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/WrappedFields"
    }
}

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

impl<P> ::fbthrift::Deserialize<P> for self::WrappedFields
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("field1", ::fbthrift::TType::I32, 1),
        ];
        let mut field_field1 = ::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_field1 = ::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 {
            field1: field_field1.unwrap_or(7),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for WrappedFields {
    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::<thrift::types::TerseWrite>() {
            let mut tmp = Some(thrift::types::TerseWrite {
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        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 => {

                if type_id == ::std::any::TypeId::of::<hack::types::FieldWrapper>() {
                    let mut tmp = Some(hack::types::FieldWrapper {
                        name: "\\MyFieldWrapper".to_owned(),
                        ..::std::default::Default::default()
                    });
                    let r: &mut dyn ::std::any::Any = &mut tmp;
                    let r: &mut Option<T> = r.downcast_mut().unwrap();
                    return r.take();
                }
            },
            _ => {}
        }

        None
    }
}

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

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

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

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

impl ::fbthrift::GetUri for self::TerseException {
    fn uri() -> &'static str {
        "facebook.com/thrift/test/terse_write/TerseException"
    }
}

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

impl<P> ::fbthrift::Deserialize<P> for self::TerseException
where
    P: ::fbthrift::ProtocolReader,
{
    fn read(p: &mut P) -> ::anyhow::Result<Self> {
        static FIELDS: &[::fbthrift::Field] = &[
            ::fbthrift::Field::new("msg", ::fbthrift::TType::String, 1),
        ];
        let mut field_msg = ::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_msg = ::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 {
            msg: field_msg.unwrap_or_default(),
            _dot_dot_Default_default: self::dot_dot::OtherFields(()),
        })
    }
}

impl ::fbthrift::metadata::ThriftAnnotations for TerseException {
    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::<thrift::types::TerseWrite>() {
            let mut tmp = Some(thrift::types::TerseWrite {
                ..::std::default::Default::default()
            });
            let r: &mut dyn ::std::any::Any = &mut tmp;
            let r: &mut Option<T> = r.downcast_mut().unwrap();
            return r.take();
        }

        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 => {
            },
            _ => {}
        }

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