Skip to main content

thalassa_derive/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![doc = "# thalassa-derive\n\n[![Crates.io](https://img.shields.io/crates/v/thalassa-derive.svg)](https://crates.io/crates/thalassa-derive)\n[![docs.rs](https://docs.rs/thalassa-derive/badge.svg)](https://docs.rs/thalassa-derive)\n\n## Description\n\nDerives for [thalassa](https://crates.io/crates/thalassa)\n\nNote: A lot of this is similar to tls_codec\'s derives, in an effort to ease migration between the derives/attrs\n\n## Attributes\n\n### On Enums\n\n- `#[tlspl(untagged)]` - Marks that this enum contents should not be de/serialized preceded by their discriminant. This is especially useful when using the `#[tlspl(select)]` attribute\n- `#[tlspl(extensible)]` - This marks an enum as \"extensible\", meaning that the contents of the variants (eg. its fields) will be serialized as a variable-length bytes container, to ensure that it can be extended, serialized and deserialized even in the case of future evolutions or downstream-defined extensions. This is inspired by how MLS (RFC9420) Extensions are done.\n\n### On Enum Variants\n\n- `#[tlspl(discrmininant = \"path::to::constant\"|1337)]` - Allows to point to a discriminant tag for cases where it\'s not supported by the Rust language (eg complex data types/structs where explicit discriminant isn\'t allowed).\n  - This also supports the following forms\n    - integer literals: `#[tlspl(discriminant = 69)]`\n    - constants: `#[tlspl(discriminant = \"MY_CONST\")]` - note: wrapped in a string\n    - enum variants that have an explicit discriminant: `#[tlspl(discriminant = \"MyEnum::CaseN\")]` - note: wrapped in a string\n- `#[tlspl(other)]` - Marks a \"catch-all\" or \"unknown\" variant that needs to be a tuple having 1 field equal to the #[repr] of the enum (for naked enums), or 2 fields equal to `(repr, Cow<[u8]>)` (for enums that have data)\n  - Example\n\n```rust,ignore\n#[derive(TlsplSize, TlsplDeserialize, TlsplSerialize)]\n#[repr(u8)]\nenum Thing {\n    CaseA = 0,\n    CaseB = 1,\n    #[tlspl(other)]\n    Unknown(u8)\n}\n\n#[derive(TlsplSize, TlsplDeserialize, TlsplSerialize)]\n#[tlspl(extensible)]\n#[repr(u8)]\nenum ThingWithData<\'a> {\n    #[tlspl(discriminant = \"Thing::CaseA\")]\n    CaseA {\n        name: std::borrow::Cow<\'a, str>,\n    },\n    #[tlspl(discriminant = \"Thing::CaseB\")]\n    CaseB {\n        flag: bool\n    },\n    #[tlspl(other)]\n    Unknown(u8, std::borrow::Cow<\'a, [u8]>),\n}\n```\n\n### On Fields\n\n- `#[tlspl(skip)]` - Skips this field during both serialization and deserialization. Requires `Default` to be implemented on the field since this data format has a fixed data layout.\n- `#[tlspl(with = path::to::module)]` - Allows to override the ser/deser implementation of the underlying type with a custom implementation. The module should export any of those functions, depending on which trait your\'re deriving:\n  - `tlspl_serialized_len(&T) -> usize`\n  - `tlspl_serialize_to(&T, writer) -> TlsplWriteResult<usize>`\n  - `tlspl_deserialize_from(reader) -> TlsplReadResult<T>`\n- `#[tlspl(select = field.member.thing)]` - mirrors the `select` keyword in TLSPL prose found in specifications.\n  - Restrictions\n     1. The targeted field must be declared *BEFORE* this field. The order of declaration matters in TLSPL.\n     2. The type of the field with this attribute must be an enum that has `#[tlspl(untagged)]`\n  - Example\n\n```rust,ignore\n#[derive(TlsplAll)]\n#[repr(u8)]\npub enum FieldDiscriminant {\n    Variant1 = 0x01,\n    Variant2 = 0x02,\n}\n\n#[derive(TlsplAll)]\n#[tlspl(untagged)]\npub enum FieldContents {\n    #[tlspl(discriminant = \"FieldDiscriminant::Variant1\")]\n    Variant1,\n    #[tlspl(discriminant = \"FieldDiscriminant::Variant2\")]\n    Variant2 {\n        thing: bool,\n    }\n}\n\n#[derive(TlsplAll)]\npub struct ComplexStructure<\'a> {\n    pub field_type: FieldDiscriminant,\n    pub unrelated_field: u64,\n    pub another_field: Cow<\'a, [u8]>,\n    #[tlspl(select = field_type)]\n    pub field_contents: FieldContents,\n}\n```\n\n- Enum Variants\n"include_str!("../README.md")]
3
4// Note: A lot of this is similar to tls_codec's derives, in an effort to ease migration between the derives/attrs
5
6use darling::{
7    FromField, FromVariant as _,
8    ast::Fields,
9    util::{Flag, SpannedValue},
10};
11use proc_macro::TokenStream;
12use proc_macro2::{Span, TokenStream as TokenStream2};
13use quote::{format_ident, quote, quote_spanned};
14use syn::{
15    Attribute, DeriveInput, Expr, ExprLit, ExprPath, GenericParam, Generics, Ident, Lit, Type,
16    parse_macro_input, parse_quote, spanned::Spanned,
17};
18
19use crate::util::from_field_named_raw_to_actual;
20
21#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DiscriminantTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            DiscriminantTarget::Lit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Lit",
                    &__self_0),
            DiscriminantTarget::Path(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DiscriminantTarget {
    #[inline]
    fn clone(&self) -> DiscriminantTarget {
        match self {
            DiscriminantTarget::Lit(__self_0) =>
                DiscriminantTarget::Lit(::core::clone::Clone::clone(__self_0)),
            DiscriminantTarget::Path(__self_0) =>
                DiscriminantTarget::Path(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone)]
22enum DiscriminantTarget {
23    Lit(usize),
24    Path(ExprPath),
25}
26
27impl darling::FromMeta for DiscriminantTarget {
28    fn from_value(lit: &Lit) -> darling::Result<Self> {
29        Ok(match lit {
30            Lit::Str(lit_str) => Self::Path(lit_str.parse()?),
31            Lit::Byte(lit_byte) => Self::Lit(lit_byte.value() as _),
32            Lit::Int(lit_int) => Self::Lit(lit_int.base10_parse()?),
33            _ => {
34                return Err(darling::Error::custom(
35                    "expected path (`path::to::CONST::or::Enum::Variant`), integer or byte literal (`b'y'` / `69` (nice))",
36                ).with_span(lit));
37            }
38        })
39    }
40}
41
42#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TlsplEnumContainerAttrs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "TlsplEnumContainerAttrs", "untagged", &self.untagged,
            "extensible", &&self.extensible)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromMeta for TlsplEnumContainerAttrs {
    fn from_list(__items: &[::darling::export::NestedMeta])
        -> ::darling::Result<Self> {
        let mut untagged: (bool, ::darling::export::Option<Flag>) =
            (false, None);
        let mut extensible: (bool, ::darling::export::Option<Flag>) =
            (false, None);
        let mut __errors = ::darling::Error::accumulator();
        for __item in __items {
            match *__item {
                ::darling::export::NestedMeta::Meta(ref __inner) => {
                    let __name =
                        ::darling::util::path_to_string(__inner.path());
                    match __name.as_str() {
                        "untagged" => {
                            if !untagged.0 {
                                untagged =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("untagged"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("untagged").with_span(&__inner));
                            }
                        }
                        "extensible" => {
                            if !extensible.0 {
                                extensible =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("extensible"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("extensible").with_span(&__inner));
                            }
                        }
                        __other => {
                            __errors.push(::darling::Error::unknown_field_with_alts(__other,
                                        &["untagged", "extensible"]).with_span(__inner));
                        }
                    }
                }
                ::darling::export::NestedMeta::Lit(ref __inner) => {
                    __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                }
            }
        }
        if !untagged.0 {
            match <Flag as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    untagged.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("untagged"))
                }
            }
        }
        if !extensible.0 {
            match <Flag as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    extensible.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("extensible"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                untagged: untagged.1.expect("Uninitialized fields without defaults were already checked"),
                extensible: extensible.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromMeta)]
43struct TlsplEnumContainerAttrs {
44    /// Marks that this enum contents should not be de/serialized preceded by their
45    /// discriminant. This is especially useful when using the `#[tlspl(select)]` attribute
46    untagged: Flag,
47    /// This marks an enum as "extensible", meaning that the contents of the variants (eg. its fields) will be serialized
48    /// as a variable-length bytes container, to ensure that it can be extended, serialized and deserialized
49    /// even in the case of future evolutions or downstream-defined extensions. This is inspired by how MLS (RFC9420)
50    /// Extensions are done.
51    extensible: Flag,
52}
53
54#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TlsplFieldAttrs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "TlsplFieldAttrs", "with", &self.with, "skip", &self.skip,
            "select", &&self.select)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TlsplFieldAttrs {
    #[inline]
    fn clone(&self) -> TlsplFieldAttrs {
        TlsplFieldAttrs {
            with: ::core::clone::Clone::clone(&self.with),
            skip: ::core::clone::Clone::clone(&self.skip),
            select: ::core::clone::Clone::clone(&self.select),
        }
    }
}Clone, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromMeta for TlsplFieldAttrs {
    fn from_list(__items: &[::darling::export::NestedMeta])
        -> ::darling::Result<Self> {
        let mut with: (bool, ::darling::export::Option<Option<ExprPath>>) =
            (false, None);
        let mut skip: (bool, ::darling::export::Option<Flag>) = (false, None);
        let mut select: (bool, ::darling::export::Option<Option<Expr>>) =
            (false, None);
        let mut __errors = ::darling::Error::accumulator();
        for __item in __items {
            match *__item {
                ::darling::export::NestedMeta::Meta(ref __inner) => {
                    let __name =
                        ::darling::util::path_to_string(__inner.path());
                    match __name.as_str() {
                        "with" => {
                            if !with.0 {
                                with =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("with"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("with").with_span(&__inner));
                            }
                        }
                        "skip" => {
                            if !skip.0 {
                                skip =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("skip"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("skip").with_span(&__inner));
                            }
                        }
                        "select" => {
                            if !select.0 {
                                select =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                    ->
                                                                        ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map(Some).map_err(|e|
                                                    e.with_span(&__inner).at("select"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("select").with_span(&__inner));
                            }
                        }
                        __other => {
                            __errors.push(::darling::Error::unknown_field_with_alts(__other,
                                        &["with", "skip", "select"]).with_span(__inner));
                        }
                    }
                }
                ::darling::export::NestedMeta::Lit(ref __inner) => {
                    __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                }
            }
        }
        if !with.0 {
            match <Option<ExprPath> as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    with.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("with"))
                }
            }
        }
        if !skip.0 {
            match <Flag as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    skip.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("skip"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                with: with.1.expect("Uninitialized fields without defaults were already checked"),
                skip: skip.1.expect("Uninitialized fields without defaults were already checked"),
                select: if let Some(__val) = select.1 {
                    __val
                } else { ::darling::export::Default::default() },
            })
    }
}darling::FromMeta)]
55struct TlsplFieldAttrs {
56    /// Custom serialization pointing to a module that has any of those 3 functions:
57    /// - tlspl_serialized_len(&T) -> usize
58    /// - tlspl_serialize_to(&T, writer) -> WriteResult<usize>
59    /// - tlspl_deserialize_from(reader) -> ReadResult<T>
60    with: Option<ExprPath>,
61    /// Skip this field (requires [`Default`] since serialization has fixed layout)
62    skip: Flag,
63    /// A derive feature made to ease the implementation of TLSPL structures
64    /// that look like the code below (example section cont.). This mirrors the
65    /// `select` keyword in TLSPL prose found in specifications.
66    ///
67    /// ### Restrictions
68    ///
69    /// 1. The targeted field must be declared *BEFORE* this field. The order of declaration matters in TLSPL.
70    /// 2. The type of the field with this attribute must be an enum that has `#[tlspl(untagged)]`
71    ///
72    /// ### Example
73    ///
74    /// ```rust,ignore
75    /// #[derive(TlsplAll)]
76    /// #[repr(u8)]
77    /// pub enum FieldDiscriminant {
78    ///     Variant1 = 0x01,
79    ///     Variant2 = 0x02,
80    /// }
81    ///
82    /// #[derive(TlsplAll)]
83    /// #[tlspl(untagged)]
84    /// pub enum FieldContents {
85    ///     #[tlspl(discriminant = "FieldDiscriminant::Variant1")]
86    ///     Variant1,
87    ///     #[tlspl(discriminant = "FieldDiscriminant::Variant2")]
88    ///     Variant2 {
89    ///         thing: bool,
90    ///     }
91    /// }
92    ///
93    /// #[derive(TlsplAll)]
94    /// pub struct ComplexStructure<'a> {
95    ///     pub field_type: FieldDiscriminant,
96    ///     pub unrelated_field: u64,
97    ///     pub another_field: Cow<'a, [u8]>,
98    ///     #[tlspl(select = field_type)]
99    ///     pub field_contents: FieldContents,
100    /// }
101    /// ```
102    #[darling(default, map = Some)]
103    select: Option<Expr>,
104}
105
106#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TlsplEnumVariantAttrs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "TlsplEnumVariantAttrs", "discriminant", &self.discriminant,
            "other", &&self.other)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromMeta for TlsplEnumVariantAttrs {
    fn from_list(__items: &[::darling::export::NestedMeta])
        -> ::darling::Result<Self> {
        let mut discriminant:
                (bool,
                ::darling::export::Option<Option<DiscriminantTarget>>) =
            (false, None);
        let mut other: (bool, ::darling::export::Option<Flag>) =
            (false, None);
        let mut __errors = ::darling::Error::accumulator();
        for __item in __items {
            match *__item {
                ::darling::export::NestedMeta::Meta(ref __inner) => {
                    let __name =
                        ::darling::util::path_to_string(__inner.path());
                    match __name.as_str() {
                        "discriminant" => {
                            if !discriminant.0 {
                                discriminant =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("discriminant"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("discriminant").with_span(&__inner));
                            }
                        }
                        "other" => {
                            if !other.0 {
                                other =
                                    (true,
                                        __errors.handle(::darling::export::identity::<fn(&::darling::export::syn::Meta)
                                                                ->
                                                                    ::darling::Result<_>>(::darling::FromMeta::from_meta)(__inner).map_err(|e|
                                                    e.with_span(&__inner).at("other"))));
                            } else {
                                __errors.push(::darling::Error::duplicate_field("other").with_span(&__inner));
                            }
                        }
                        __other => {
                            __errors.push(::darling::Error::unknown_field_with_alts(__other,
                                        &["discriminant", "other"]).with_span(__inner));
                        }
                    }
                }
                ::darling::export::NestedMeta::Lit(ref __inner) => {
                    __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                }
            }
        }
        if !discriminant.0 {
            match <Option<DiscriminantTarget> as
                        ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    discriminant.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("discriminant"))
                }
            }
        }
        if !other.0 {
            match <Flag as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    other.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("other"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                discriminant: discriminant.1.expect("Uninitialized fields without defaults were already checked"),
                other: other.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromMeta)]
107struct TlsplEnumVariantAttrs {
108    /// Custom enum discriminant
109    discriminant: Option<DiscriminantTarget>,
110    /// Marks a "catch-all" or "unknown" variant that needs to
111    /// contain a single tuple field equal to the #[repr] of the enum
112    ///
113    /// Eg: for a `#[repr(u8)]`, this variant needs to contain a `u8` like so:
114    ///
115    /// ```rust,ignore
116    /// #[derive(TlsplSize, TlsplDeserialize, TlsplSerialize)]
117    /// #[repr(u8)]
118    /// enum Thing {
119    ///     CaseA = 0,
120    ///     CaseB = 1,
121    ///     #[tlspl(other)]
122    ///     Unknown(u8)
123    /// }
124    ///
125    /// #[derive(TlsplSize, TlsplDeserialize, TlsplSerialize)]
126    /// #[tlspl(extensible)]
127    /// #[repr(u8)]
128    /// enum ThingWithData<'a> {
129    ///     #[tlspl(discriminant = "Thing::CaseA")]
130    ///     CaseA {
131    ///         name: std::borrow::Cow<'a, str>,
132    ///     },
133    ///     #[tlspl(discriminant = "Thing::CaseB")]
134    ///     CaseB {
135    ///         flag: bool
136    ///     },
137    ///     #[tlspl(other)]
138    ///     Unknown(u8, std::borrow::Cow<'a, [u8]>),
139    /// }
140    /// ```
141    other: Flag,
142}
143
144fn discr_const_ident(variant_ident: &Ident) -> Ident {
145    match ::quote::__private::IdentFragmentAdapter(&variant_ident) {
    arg =>
        ::quote::__private::mk_ident(&::alloc::__export::must_use({
                        ::alloc::fmt::format(format_args!("__THALASSA_{0}", arg))
                    }), ::quote::__private::Option::None.or(arg.span())),
}quote::format_ident!("__THALASSA_{}", variant_ident)
146}
147
148#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FieldNamedRaw {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "FieldNamedRaw",
            "ident", &self.ident, "ty", &self.ty, "attr", &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromField for FieldNamedRaw {
    fn from_field(__field: &::darling::export::syn::Field)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr: (bool, ::darling::export::Option<TlsplFieldAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        use ::darling::ToTokens;
        for __attr in &__field.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                _ => continue,
            }
        }
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplFieldAttrs as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                ident: __field.ident.clone(),
                ty: __field.ty.clone(),
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromField)]
149#[darling(attributes(tlspl))]
150struct FieldNamedRaw {
151    // TODO: Uncomment + change type to `Ident` when darling 0.24 is out
152    // and rename the struct to FieldNamed (+ delete the other one)
153    // #[darling(with = darling::util::require_ident)]
154    ident: Option<Ident>,
155    ty: Type,
156    #[darling(flatten)]
157    attr: TlsplFieldAttrs,
158}
159
160#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FieldNamed {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "FieldNamed",
            "ident", &self.ident, "ty", &self.ty, "attr", &&self.attr)
    }
}Debug)]
161struct FieldNamed {
162    ident: Ident,
163    ty: Type,
164    attr: TlsplFieldAttrs,
165}
166
167impl FromField for FieldNamed {
168    fn from_field(field: &syn::Field) -> darling::Result<Self> {
169        FieldNamedRaw::from_field(field).map(from_field_named_raw_to_actual)
170    }
171}
172
173// TODO: Remove this once darling 0.24 is out with the fixes on adding #[darling(with)] on Ident
174mod util {
175    use darling::util::SpannedValue;
176
177    use crate::{FieldNamed, FieldNamedRaw};
178
179    pub fn from_field_named_raw_to_actual(fnr: FieldNamedRaw) -> FieldNamed {
180        FieldNamed {
181            ident: fnr
182                .ident
183                .expect("Implementation error, named fields ALWAYS have an identifier"),
184            ty: fnr.ty,
185            attr: fnr.attr,
186        }
187    }
188
189    pub fn map_spanned_raw_to_field(srf: SpannedValue<FieldNamedRaw>) -> SpannedValue<FieldNamed> {
190        let span = srf.span();
191        SpannedValue::new(from_field_named_raw_to_actual(srf.into_inner()), span)
192    }
193}
194
195#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StructNamedFields {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "StructNamedFields", "fields", &&self.fields)
    }
}Debug)]
196struct StructNamedFields {
197    fields: Vec<SpannedValue<FieldNamed>>,
198}
199
200impl TryFrom<&syn::Data> for StructNamedFields {
201    type Error = darling::Error;
202
203    fn try_from(data: &syn::Data) -> std::prelude::v1::Result<Self, Self::Error> {
204        let mut errors = darling::Error::accumulator();
205        let syn::Data::Struct(syn::DataStruct {
206            fields: syn::Fields::Named(fields),
207            ..
208        }) = data
209        else {
210            ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
211        };
212
213        let fields = fields
214            .named
215            .iter()
216            .filter_map(|field| {
217                errors.handle(
218                    // TODO: Simplify to just `SpannedValue::<FieldNamed>::from_field` when darling 0.24 is out
219                    SpannedValue::<FieldNamedRaw>::from_field(field)
220                        .map(util::map_spanned_raw_to_field),
221                )
222            })
223            .collect();
224        errors.finish_with(Self { fields })
225    }
226}
227
228#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FieldTuple {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "FieldTuple",
            "ty", &self.ty, "attr", &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromField for FieldTuple {
    fn from_field(__field: &::darling::export::syn::Field)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr: (bool, ::darling::export::Option<TlsplFieldAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        use ::darling::ToTokens;
        for __attr in &__field.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                _ => continue,
            }
        }
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplFieldAttrs as ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                ty: __field.ty.clone(),
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromField)]
229#[darling(attributes(tlspl))]
230struct FieldTuple {
231    ty: Type,
232    #[darling(flatten)]
233    attr: TlsplFieldAttrs,
234}
235
236#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StructTupleFields {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "StructTupleFields", "fields", &&self.fields)
    }
}Debug)]
237struct StructTupleFields {
238    fields: Vec<SpannedValue<FieldTuple>>,
239}
240
241impl TryFrom<&syn::Data> for StructTupleFields {
242    type Error = darling::Error;
243
244    fn try_from(data: &syn::Data) -> std::prelude::v1::Result<Self, Self::Error> {
245        let mut errors = darling::Error::accumulator();
246        let syn::Data::Struct(syn::DataStruct {
247            fields: syn::Fields::Unnamed(fields),
248            ..
249        }) = data
250        else {
251            ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
252        };
253
254        let fields = fields
255            .unnamed
256            .iter()
257            .filter_map(|field| errors.handle(SpannedValue::<FieldTuple>::from_field(field)))
258            .collect();
259        errors.finish_with(Self { fields })
260    }
261}
262
263#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantDiscriminant {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            VariantDiscriminant::ViaAttr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ViaAttr", &__self_0),
            VariantDiscriminant::Explicit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Explicit", &__self_0),
            VariantDiscriminant::Implicit =>
                ::core::fmt::Formatter::write_str(f, "Implicit"),
        }
    }
}Debug)]
264enum VariantDiscriminant {
265    ViaAttr(DiscriminantTarget),
266    Explicit(usize),
267    Implicit,
268}
269
270#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantUnit {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "VariantUnit",
            "ident", &self.ident, "discriminant", &self.discriminant, "attr",
            &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromVariant for VariantUnit {
    fn from_variant(__variant: &::darling::export::syn::Variant)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr:
                (bool, ::darling::export::Option<TlsplEnumVariantAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        use ::darling::ToTokens;
        for __attr in &__variant.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                _ => continue,
            }
        }
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplEnumVariantAttrs as ::darling::FromMeta>::from_none()
                {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                ident: __variant.ident.clone(),
                discriminant: __variant.discriminant.as_ref().map(|(_, expr)|
                        expr.clone()),
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromVariant)]
271#[darling(attributes(tlspl))]
272struct VariantUnit {
273    ident: Ident,
274    discriminant: Option<Expr>,
275    #[darling(flatten)]
276    attr: TlsplEnumVariantAttrs,
277}
278
279impl VariantUnit {
280    fn discr(&self, span: &Span) -> darling::Result<VariantDiscriminant> {
281        let explicit_discr = if let Some(Expr::Lit(ExprLit { lit, .. })) = &self.discriminant {
282            let discr = match lit {
283                Lit::Byte(lit_byte) => lit_byte.value() as usize,
284                Lit::Int(lit_int) => lit_int.base10_parse::<usize>()?,
285                _ => return Err(darling::Error::custom("The native discriminant cannot be parsed, it should be either an integer value or a byte literal").with_span(span)),
286            };
287            Some(discr)
288        } else {
289            None
290        };
291
292        if let Some(target) = &self.attr.discriminant {
293            // Small sanity check
294            if let (Some(native_discr), DiscriminantTarget::Lit(custom_discr)) =
295                (&explicit_discr, target)
296                && native_discr != custom_discr
297            {
298                return Err(darling::Error::custom("The explicit and custom discriminants are mismatched, this would result in weird errors").with_span(span));
299            }
300
301            return Ok(VariantDiscriminant::ViaAttr(target.clone()));
302        }
303
304        if let Some(discr) = explicit_discr {
305            return Ok(VariantDiscriminant::Explicit(discr));
306        }
307
308        Ok(VariantDiscriminant::Implicit)
309    }
310}
311
312#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantTuple {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "VariantTuple",
            "ident", &self.ident, "discriminant", &self.discriminant,
            "fields", &self.fields, "attr", &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromVariant for VariantTuple {
    fn from_variant(__variant: &::darling::export::syn::Variant)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr:
                (bool, ::darling::export::Option<TlsplEnumVariantAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        use ::darling::ToTokens;
        for __attr in &__variant.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                _ => continue,
            }
        }
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplEnumVariantAttrs as ::darling::FromMeta>::from_none()
                {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                ident: __variant.ident.clone(),
                discriminant: __variant.discriminant.as_ref().map(|(_, expr)|
                        expr.clone()),
                fields: ::darling::ast::Fields::try_from(&__variant.fields)?,
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromVariant)]
313#[darling(attributes(tlspl))]
314struct VariantTuple {
315    ident: Ident,
316    discriminant: Option<Expr>,
317    fields: Fields<SpannedValue<FieldTuple>>,
318    #[darling(flatten)]
319    attr: TlsplEnumVariantAttrs,
320}
321
322impl VariantTuple {
323    fn discr(&self, span: &Span) -> darling::Result<VariantDiscriminant> {
324        let explicit_discr = if let Some(Expr::Lit(ExprLit { lit, .. })) = &self.discriminant {
325            let discr = match lit {
326                Lit::Byte(lit_byte) => lit_byte.value() as usize,
327                Lit::Int(lit_int) => lit_int.base10_parse::<usize>()?,
328                _ => return Err(darling::Error::custom("The native discriminant cannot be parsed, it should be either an integer value or a byte literal").with_span(span)),
329            };
330            Some(discr)
331        } else {
332            None
333        };
334
335        if let Some(target) = &self.attr.discriminant {
336            // Small sanity check
337            if let (Some(native_discr), DiscriminantTarget::Lit(custom_discr)) =
338                (&explicit_discr, target)
339                && native_discr != custom_discr
340            {
341                return Err(darling::Error::custom("The explicit and custom discriminants are mismatched, this would result in weird errors").with_span(span));
342            }
343
344            return Ok(VariantDiscriminant::ViaAttr(target.clone()));
345        }
346
347        if let Some(discr) = explicit_discr {
348            return Ok(VariantDiscriminant::Explicit(discr));
349        }
350
351        Ok(VariantDiscriminant::Implicit)
352    }
353}
354
355#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantNamed {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "VariantNamed",
            "ident", &self.ident, "discriminant", &self.discriminant,
            "fields", &self.fields, "attr", &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromVariant for VariantNamed {
    fn from_variant(__variant: &::darling::export::syn::Variant)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr:
                (bool, ::darling::export::Option<TlsplEnumVariantAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        use ::darling::ToTokens;
        for __attr in &__variant.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                _ => continue,
            }
        }
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplEnumVariantAttrs as ::darling::FromMeta>::from_none()
                {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(Self {
                ident: __variant.ident.clone(),
                discriminant: __variant.discriminant.as_ref().map(|(_, expr)|
                        expr.clone()),
                fields: ::darling::ast::Fields::try_from(&__variant.fields)?,
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromVariant)]
356#[darling(attributes(tlspl))]
357struct VariantNamed {
358    ident: Ident,
359    discriminant: Option<Expr>,
360    fields: Fields<SpannedValue<FieldNamed>>,
361    #[darling(flatten)]
362    attr: TlsplEnumVariantAttrs,
363}
364
365impl VariantNamed {
366    fn discr(&self, span: &Span) -> darling::Result<VariantDiscriminant> {
367        let explicit_discr = if let Some(Expr::Lit(ExprLit { lit, .. })) = &self.discriminant {
368            let discr = match lit {
369                Lit::Byte(lit_byte) => lit_byte.value() as usize,
370                Lit::Int(lit_int) => lit_int.base10_parse::<usize>()?,
371                _ => return Err(darling::Error::custom("The native discriminant cannot be parsed, it should be either an integer value or a byte literal").with_span(span)),
372            };
373            Some(discr)
374        } else {
375            None
376        };
377
378        if let Some(target) = &self.attr.discriminant {
379            // Small sanity check
380            if let (Some(native_discr), DiscriminantTarget::Lit(custom_discr)) =
381                (&explicit_discr, target)
382                && native_discr != custom_discr
383            {
384                return Err(darling::Error::custom("The explicit and custom discriminants are mismatched, this would result in weird errors").with_span(span));
385            }
386
387            return Ok(VariantDiscriminant::ViaAttr(target.clone()));
388        }
389
390        if let Some(discr) = explicit_discr {
391            return Ok(VariantDiscriminant::Explicit(discr));
392        }
393
394        Ok(VariantDiscriminant::Implicit)
395    }
396}
397
398#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MemberWithAttrs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "MemberWithAttrs", "span", &self.span, "ident", &self.ident, "ty",
            &self.ty, "attrs", &&self.attrs)
    }
}Debug)]
399struct MemberWithAttrs {
400    span: Span,
401    ident: Ident,
402    ty: Type,
403    attrs: TlsplFieldAttrs,
404}
405
406#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Variant {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Variant::Unit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Unit",
                    &__self_0),
            Variant::Named(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Named",
                    &__self_0),
            Variant::Tuple(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tuple",
                    &__self_0),
        }
    }
}Debug)]
407enum Variant {
408    Unit(SpannedValue<VariantUnit>),
409    Named(SpannedValue<VariantNamed>),
410    Tuple(SpannedValue<VariantTuple>),
411}
412
413impl Variant {
414    fn span(&self) -> Span {
415        match self {
416            Variant::Unit(variant_unit) => variant_unit.span(),
417            Variant::Named(variant_named) => variant_named.span(),
418            Variant::Tuple(variant_tuple) => variant_tuple.span(),
419        }
420    }
421
422    fn ident(&self) -> &Ident {
423        match self {
424            Variant::Unit(variant_unit) => &variant_unit.ident,
425            Variant::Named(variant_named) => &variant_named.ident,
426            Variant::Tuple(variant_tuple) => &variant_tuple.ident,
427        }
428    }
429
430    fn discriminant(&self) -> darling::Result<VariantDiscriminant> {
431        match self {
432            Variant::Unit(variant_unit) => variant_unit.discr(&variant_unit.span()),
433            Variant::Named(variant_named) => variant_named.discr(&variant_named.span()),
434            Variant::Tuple(variant_tuple) => variant_tuple.discr(&variant_tuple.span()),
435        }
436    }
437
438    fn attrs(&self) -> &TlsplEnumVariantAttrs {
439        match self {
440            Variant::Unit(variant_unit) => &variant_unit.attr,
441            Variant::Named(variant_named) => &variant_named.attr,
442            Variant::Tuple(variant_tuple) => &variant_tuple.attr,
443        }
444    }
445
446    fn members_with_exprs(&self) -> Box<dyn Iterator<Item = MemberWithAttrs> + '_> {
447        match self {
448            Variant::Unit(_) => Box::new(std::iter::empty()),
449            Variant::Named(variant_named) => {
450                Box::new(variant_named.fields.iter().map(|f| MemberWithAttrs {
451                    span: f.span(),
452                    ident: f.ident.clone(),
453                    ty: f.ty.clone(),
454                    attrs: f.attr.clone(),
455                }))
456            }
457            Variant::Tuple(variant_tuple) => {
458                Box::new(variant_tuple.fields.iter().enumerate().map(|(idx, f)| {
459                    let span = f.span();
460                    MemberWithAttrs {
461                        ident: match ::quote::__private::IdentFragmentAdapter(&idx) {
    arg =>
        ::quote::__private::mk_ident(&::alloc::__export::must_use({
                        ::alloc::fmt::format(format_args!("tuple{0}", arg))
                    }),
            ::quote::__private::Option::Some::<::quote::__private::Span>(f.span())),
}format_ident!("tuple{}", idx, span = f.span()),
462                        span,
463                        ty: f.ty.clone(),
464                        attrs: f.attr.clone(),
465                    }
466                }))
467            }
468        }
469    }
470
471    fn field_count(&self) -> usize {
472        match self {
473            Variant::Unit(_) => 0,
474            Variant::Named(variant_named) => variant_named.fields.len(),
475            Variant::Tuple(variant_tuple) => variant_tuple.fields.len(),
476        }
477    }
478}
479
480impl TryFrom<&syn::Variant> for Variant {
481    type Error = darling::Error;
482
483    fn try_from(variant: &syn::Variant) -> std::prelude::v1::Result<Self, Self::Error> {
484        Ok(match variant.fields {
485            syn::Fields::Named(_) => {
486                Self::Named(SpannedValue::<VariantNamed>::from_variant(variant)?)
487            }
488            syn::Fields::Unnamed(_) => {
489                Self::Tuple(SpannedValue::<VariantTuple>::from_variant(variant)?)
490            }
491            syn::Fields::Unit => Self::Unit(SpannedValue::<VariantUnit>::from_variant(variant)?),
492        })
493    }
494}
495
496#[derive(#[automatically_derived]
impl ::core::fmt::Debug for EnumVariants {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "EnumVariants",
            "variants", &&self.variants)
    }
}Debug)]
497struct EnumVariants {
498    variants: Vec<Variant>,
499}
500
501impl EnumVariants {
502    fn discriminant_consts(&self, enum_target: &EnumTarget) -> darling::Result<TokenStream2> {
503        let enum_ident = enum_target.ident.clone();
504        let repr = extract_repr_from_attrs(&enum_target.attrs)?;
505
506        let enum_is_naked = self.variants.iter().all(|v| #[allow(non_exhaustive_omitted_patterns)] match v {
    Variant::Unit(_) => true,
    _ => false,
}matches!(v, Variant::Unit(_)));
507        let spans = if enum_is_naked {
508            self.variants
509                .iter()
510                .map(|v| {
511                    if v.attrs().discriminant.is_some() {
512                        return Err(darling::Error::custom(
513                            r#"This is a naked enum, you do not need to use the #[tlspl] attribute
514to define discriminants, just set an explicit discriminant to your variants, like so
515
516#[derive(thalassa::TlsplAll)]
517#[repr(u8)]
518enum MyEnum {
519    Variant1 = 0x12,
520    Variant2 = 0xAC,
521}
522
523"#,
524                        ));
525                    }
526                    let variant_ident = v.ident();
527                    let const_id = discr_const_ident(variant_ident);
528
529                    Ok({
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "allow");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s,
                        "non_upper_case_globals");
                    _s
                });
            _s
        });
    ::quote::__private::push_ident(&mut _s, "const");
    ::quote::ToTokens::to_tokens(&const_id, &mut _s);
    ::quote::__private::push_colon(&mut _s);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq(&mut _s);
    ::quote::ToTokens::to_tokens(&enum_ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_ident(&mut _s, "as");
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
530                        #[allow(non_upper_case_globals)]
531                        const #const_id: #repr = #enum_ident::#variant_ident as #repr;
532                    })
533                })
534                .collect::<darling::Result<Vec<_>>>()?
535        } else {
536            let mut implicit_discr = 0usize;
537            let mut path_used = false;
538
539            let mut spans = Vec::with_capacity(self.variants.len());
540            for variant in &self.variants {
541                // The `other` case doesn't need a discriminant const, as it's a fallback
542                if variant.attrs().other.is_present() {
543                    continue;
544                }
545
546                let variant_ident = variant.ident();
547                let const_id = discr_const_ident(variant_ident);
548                let span = variant.span();
549
550                fn path_used_err(span: &Span) -> darling::Error {
551                    darling::Error::custom(
552                        r#"The `#[tlspl(discriminant = \"path::to::thing\")]` is missing.
553It is a viral attribute, and if one variant uses a path discriminant, then ALL your variants must do so as well."#,
554                    ).with_span(span)
555                }
556
557                let tokens = match variant.discriminant()? {
558                    VariantDiscriminant::ViaAttr(discriminant_target) => {
559                        match discriminant_target {
560                            DiscriminantTarget::Lit(value) => {
561                                if path_used {
562                                    return Err(path_used_err(&span));
563                                }
564
565                                implicit_discr = value;
566                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "allow");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "non_upper_case_globals");
                    _s
                });
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "const");
    ::quote::ToTokens::to_tokens(&const_id, &mut _s);
    ::quote::__private::push_colon_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "if");
            ::quote::ToTokens::to_tokens(&value, &mut _s);
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "MIN");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_or_or_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&value, &mut _s);
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "MAX");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "panic");
                    ::quote::__private::push_bang_spanned(&mut _s, _span);
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::parse_spanned(&mut _s, _span,
                                "\"enum repr overflow\"");
                            _s
                        });
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    _s
                });
            ::quote::ToTokens::to_tokens(&value, &mut _s);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            _s
        });
    ::quote::__private::push_semi_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
567                                    #[allow(non_upper_case_globals)]
568                                    const #const_id: #repr = {
569                                        if #value < #repr::MIN as usize || #value > #repr::MAX as usize {
570                                            panic!("enum repr overflow");
571                                        }
572
573                                        #value as #repr
574                                    };
575                                }
576                            }
577                            DiscriminantTarget::Path(expr_path) => {
578                                path_used = true;
579                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "allow");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "clippy");
                    ::quote::__private::push_colon2_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "unnecessary_cast");
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "non_upper_case_globals");
                    _s
                });
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "const");
    ::quote::ToTokens::to_tokens(&const_id, &mut _s);
    ::quote::__private::push_colon_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "let");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "expr_us");
            ::quote::__private::push_eq_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "unsafe");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_star_spanned(&mut _s, _span);
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Parenthesis,
                                {
                                    let mut _s = ::quote::__private::TokenStream::new();
                                    ::quote::__private::push_group_spanned(&mut _s, _span,
                                        ::quote::__private::Delimiter::Parenthesis,
                                        {
                                            let mut _s = ::quote::__private::TokenStream::new();
                                            ::quote::__private::push_and_spanned(&mut _s, _span);
                                            ::quote::ToTokens::to_tokens(&expr_path, &mut _s);
                                            _s
                                        });
                                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                                        "as");
                                    ::quote::__private::push_star_spanned(&mut _s, _span);
                                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                                        "const");
                                    ::quote::__private::push_underscore_spanned(&mut _s, _span);
                                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                                        "as");
                                    ::quote::__private::push_star_spanned(&mut _s, _span);
                                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                                        "const");
                                    ::quote::ToTokens::to_tokens(&repr, &mut _s);
                                    _s
                                });
                            ::quote::__private::push_dot_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "cast");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_lt_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&repr, &mut _s);
                            ::quote::__private::push_gt_spanned(&mut _s, _span);
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Parenthesis,
                                { ::quote::__private::TokenStream::new() });
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "if");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "expr_us");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "MIN");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_or_or_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "expr_us");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "MAX");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "panic");
                    ::quote::__private::push_bang_spanned(&mut _s, _span);
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::parse_spanned(&mut _s, _span,
                                "\"enum repr overflow\"");
                            _s
                        });
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "expr_us");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            _s
        });
    ::quote::__private::push_semi_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
580                                    #[allow(clippy::unnecessary_cast, non_upper_case_globals)]
581                                    const #const_id: #repr = {
582                                        let expr_us = unsafe { *(((&#expr_path) as *const _ as *const #repr).cast::<#repr>()) } as usize;
583                                        if expr_us < #repr::MIN as usize || expr_us > #repr::MAX as usize {
584                                            panic!("enum repr overflow");
585                                        }
586
587                                        expr_us as #repr
588                                    };
589                                }
590                            }
591                        }
592                    }
593                    VariantDiscriminant::Explicit(value) => {
594                        if path_used {
595                            return Err(path_used_err(&span));
596                        }
597
598                        implicit_discr = value;
599
600                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "allow");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "non_upper_case_globals");
                    _s
                });
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "const");
    ::quote::ToTokens::to_tokens(&const_id, &mut _s);
    ::quote::__private::push_colon_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&implicit_discr, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_semi_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
601                            #[allow(non_upper_case_globals)]
602                            const #const_id: #repr = #implicit_discr as #repr;
603                        }
604                    }
605                    VariantDiscriminant::Implicit => {
606                        if path_used {
607                            return Err(path_used_err(&span));
608                        }
609
610                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "allow");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "non_upper_case_globals");
                    _s
                });
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "const");
    ::quote::ToTokens::to_tokens(&const_id, &mut _s);
    ::quote::__private::push_colon_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "if");
            ::quote::ToTokens::to_tokens(&implicit_discr, &mut _s);
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "MAX");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "panic");
                    ::quote::__private::push_bang_spanned(&mut _s, _span);
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::parse_spanned(&mut _s, _span,
                                "\"enum repr overflow: too many variants\"");
                            _s
                        });
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    _s
                });
            ::quote::ToTokens::to_tokens(&implicit_discr, &mut _s);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "as");
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            _s
        });
    ::quote::__private::push_semi_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
611                            #[allow(non_upper_case_globals)]
612                            const #const_id: #repr = {
613                                if #implicit_discr > #repr::MAX as usize {
614                                    panic!("enum repr overflow: too many variants");
615                                }
616                                #implicit_discr as #repr
617                            };
618                        }
619                    }
620                };
621
622                implicit_discr += 1;
623                spans.push(tokens);
624            }
625
626            spans
627        };
628
629        Ok({
    let mut _s = ::quote::__private::TokenStream::new();
    {
        use ::quote::__private::ext::*;
        let has_iter = ::quote::__private::HasIterator::<false>;
        #[allow(unused_mut)]
        let (mut spans, i) = spans.quote_into_iter();
        let has_iter = has_iter | i;
        <_ as ::quote::__private::CheckHasIterator<true>>::check(has_iter);
        while true {
            let spans =
                match spans.next() {
                    Some(_x) => ::quote::__private::RepInterp(_x),
                    None => break,
                };
            ::quote::ToTokens::to_tokens(&spans, &mut _s);
        }
    }
    _s
}quote! { #(#spans)* })
630    }
631}
632
633impl TryFrom<&syn::Data> for EnumVariants {
634    type Error = darling::Error;
635
636    fn try_from(data: &syn::Data) -> std::prelude::v1::Result<Self, Self::Error> {
637        let mut errors = darling::Error::accumulator();
638        let syn::Data::Enum(variants) = data else {
639            ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
640        };
641
642        let fields = variants
643            .variants
644            .iter()
645            .filter_map(|field| errors.handle(Variant::try_from(field)))
646            .collect();
647
648        errors.finish_with(Self { variants: fields })
649    }
650}
651
652#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StructUnitTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "StructUnitTarget", "ident", &self.ident, "generics",
            &&self.generics)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromDeriveInput for StructUnitTarget {
    fn from_derive_input(__di: &::darling::export::syn::DeriveInput)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        __errors.handle(::darling::export::Ok(&__di.data).and_then(::darling::export::Ok));
        let generics =
            __errors.handle(::darling::FromGenerics::from_generics(&__di.generics));
        __errors.finish()?;
        ::darling::export::Ok(StructUnitTarget {
                ident: __di.ident.clone(),
                generics: generics.expect("Errors were already checked"),
            })
    }
}darling::FromDeriveInput)]
653struct StructUnitTarget {
654    ident: Ident,
655    generics: Generics,
656}
657
658#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StructNamedTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "StructNamedTarget", "ident", &self.ident, "generics",
            &self.generics, "data", &&self.data)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromDeriveInput for StructNamedTarget {
    fn from_derive_input(__di: &::darling::export::syn::DeriveInput)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let data =
            __errors.handle(::darling::export::Ok(&__di.data).and_then(TryFrom::try_from));
        let generics =
            __errors.handle(::darling::FromGenerics::from_generics(&__di.generics));
        __errors.finish()?;
        ::darling::export::Ok(StructNamedTarget {
                ident: __di.ident.clone(),
                generics: generics.expect("Errors were already checked"),
                data: data.expect("Errors were already checked"),
            })
    }
}darling::FromDeriveInput)]
659struct StructNamedTarget {
660    ident: Ident,
661    generics: Generics,
662    #[darling(with = TryFrom::try_from)]
663    data: StructNamedFields,
664}
665
666#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StructTupleTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "StructTupleTarget", "ident", &self.ident, "generics",
            &self.generics, "data", &&self.data)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromDeriveInput for StructTupleTarget {
    fn from_derive_input(__di: &::darling::export::syn::DeriveInput)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let data =
            __errors.handle(::darling::export::Ok(&__di.data).and_then(TryFrom::try_from));
        let generics =
            __errors.handle(::darling::FromGenerics::from_generics(&__di.generics));
        __errors.finish()?;
        ::darling::export::Ok(StructTupleTarget {
                ident: __di.ident.clone(),
                generics: generics.expect("Errors were already checked"),
                data: data.expect("Errors were already checked"),
            })
    }
}darling::FromDeriveInput)]
667struct StructTupleTarget {
668    ident: Ident,
669    generics: Generics,
670    #[darling(with = TryFrom::try_from)]
671    data: StructTupleFields,
672}
673
674fn extract_repr_from_attrs(attrs: &[Attribute]) -> darling::Result<Ident> {
675    attrs
676        .iter()
677        .find_map(|attr| {
678            attr.path()
679                .is_ident("repr")
680                .then(|| attr.parse_args::<Ident>().map_err(Into::into))
681        })
682        .ok_or_else(|| {
683            darling::Error::custom(
684                "This enum doesn't have a #[repr] attribute, we can't do much with this",
685            )
686        })?
687        .and_then(|repr| if repr == "usize" || repr == "isize" {
688            Err(darling::Error::custom("`usize` and `isize` reprs are forbidden, as their byte representation depends on pointer size"))
689        } else {
690            Ok(repr)
691        })
692}
693
694#[derive(#[automatically_derived]
impl ::core::fmt::Debug for EnumTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "EnumTarget",
            "ident", &self.ident, "generics", &self.generics, "attrs",
            &self.attrs, "data", &self.data, "attr", &&self.attr)
    }
}Debug, #[automatically_derived]
#[allow(clippy :: manual_unwrap_or_default)]
impl ::darling::FromDeriveInput for EnumTarget {
    fn from_derive_input(__di: &::darling::export::syn::DeriveInput)
        -> ::darling::Result<Self> {
        let mut __errors = ::darling::Error::accumulator();
        let mut attr:
                (bool, ::darling::export::Option<TlsplEnumContainerAttrs>) =
            (false, None);
        let mut __flatten: Vec<::darling::ast::NestedMeta> =
            ::alloc::vec::Vec::new();
        let mut __fwd_attrs:
                ::darling::export::Vec<::darling::export::syn::Attribute> =
            ::alloc::vec::Vec::new();
        let mut attrs: ::darling::export::Option<_> = None;
        use ::darling::ToTokens;
        for __attr in &__di.attrs {
            match ::darling::export::ToString::to_string(&__attr.path().clone().into_token_stream()).as_str()
                {
                "tlspl" => {
                    match ::darling::util::parse_attribute_to_meta_list(__attr)
                        {
                        ::darling::export::Ok(__data) => {
                            match ::darling::export::NestedMeta::parse_meta_list(__data.tokens)
                                {
                                ::darling::export::Ok(ref __items) => {
                                    if __items.is_empty() { continue; }
                                    for __item in __items {
                                        match *__item {
                                            ::darling::export::NestedMeta::Meta(ref __inner) => {
                                                let __name =
                                                    ::darling::util::path_to_string(__inner.path());
                                                match __name.as_str() {
                                                    __other => {
                                                        __flatten.push(::darling::ast::NestedMeta::Meta(__inner.clone()));
                                                    }
                                                }
                                            }
                                            ::darling::export::NestedMeta::Lit(ref __inner) => {
                                                __errors.push(::darling::Error::unsupported_format("literal").with_span(__inner));
                                            }
                                        }
                                    }
                                }
                                ::darling::export::Err(__err) => {
                                    __errors.push(__err.into());
                                }
                            }
                        }
                        ::darling::export::Err(__err) => { __errors.push(__err); }
                    }
                }
                "repr" => __fwd_attrs.push(__attr.clone()),
                _ => continue,
            }
        }
        attrs = ::darling::export::Some(__fwd_attrs);
        let data =
            __errors.handle(::darling::export::Ok(&__di.data).and_then(TryFrom::try_from));
        let generics =
            __errors.handle(::darling::FromGenerics::from_generics(&__di.generics));
        attr =
            (true,
                __errors.handle(::darling::FromMeta::from_list(&__flatten)));
        if !attr.0 {
            match <TlsplEnumContainerAttrs as
                        ::darling::FromMeta>::from_none() {
                ::darling::export::Some(__type_fallback) => {
                    attr.1 = ::darling::export::Some(__type_fallback);
                }
                ::darling::export::None => {
                    __errors.push(::darling::Error::missing_field("attr"))
                }
            }
        }
        __errors.finish()?;
        ::darling::export::Ok(EnumTarget {
                ident: __di.ident.clone(),
                generics: generics.expect("Errors were already checked"),
                attrs: attrs.expect("Errors were already checked"),
                data: data.expect("Errors were already checked"),
                attr: attr.1.expect("Uninitialized fields without defaults were already checked"),
            })
    }
}darling::FromDeriveInput)]
695#[darling(attributes(tlspl), forward_attrs(repr))]
696struct EnumTarget {
697    ident: Ident,
698    generics: Generics,
699    attrs: Vec<Attribute>,
700    #[darling(with = TryFrom::try_from)]
701    data: EnumVariants,
702    #[darling(flatten)]
703    attr: TlsplEnumContainerAttrs,
704}
705
706#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TlsplDeriveTarget {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TlsplDeriveTarget::StructUnit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "StructUnit", &__self_0),
            TlsplDeriveTarget::StructNamed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "StructNamed", &__self_0),
            TlsplDeriveTarget::StructTuple(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "StructTuple", &__self_0),
            TlsplDeriveTarget::Enum(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Enum",
                    &__self_0),
        }
    }
}Debug)]
707enum TlsplDeriveTarget {
708    StructUnit(SpannedValue<StructUnitTarget>),
709    StructNamed(SpannedValue<StructNamedTarget>),
710    StructTuple(SpannedValue<StructTupleTarget>),
711    Enum(SpannedValue<EnumTarget>),
712}
713
714impl TlsplDeriveTarget {
715    #[allow(dead_code)]
716    fn span(&self) -> Span {
717        match self {
718            TlsplDeriveTarget::StructUnit(struct_unit_target) => struct_unit_target.span(),
719            TlsplDeriveTarget::StructNamed(struct_named_target) => struct_named_target.span(),
720            TlsplDeriveTarget::StructTuple(struct_tuple_target) => struct_tuple_target.span(),
721            TlsplDeriveTarget::Enum(enum_target) => enum_target.span(),
722        }
723    }
724}
725
726struct ImplTargets(<ImplTargets as
    ::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]
impl ::core::fmt::Debug for ImplTargets {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "ImplTargets",
            &&self.0)
    }
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ImplTargets { }
#[automatically_derived]
impl ::core::clone::Clone for ImplTargets {
    #[inline]
    fn clone(&self) -> ImplTargets {
        let _:
                ::core::clone::AssertParamIsClone<<ImplTargets as
                ::bitflags::__private::PublicFlags>::Internal>;
        *self
    }
}
#[automatically_derived]
impl ::core::marker::Copy for ImplTargets { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for ImplTargets { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ImplTargets {
    #[inline]
    fn eq(&self, other: &ImplTargets) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl ::core::cmp::Eq for ImplTargets {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _:
                ::core::cmp::AssertParamIsEq<<ImplTargets as
                ::bitflags::__private::PublicFlags>::Internal>;
    }
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for ImplTargets {
    #[inline]
    fn partial_cmp(&self, other: &ImplTargets)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}
#[automatically_derived]
impl ::core::cmp::Ord for ImplTargets {
    #[inline]
    fn cmp(&self, other: &ImplTargets) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}
#[automatically_derived]
impl ::core::hash::Hash for ImplTargets {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy :: min_ident_chars,
clippy :: assign_op_pattern, clippy :: indexing_slicing, clippy ::
same_name_method, clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[repr(transparent)]
        struct InternalBitFlags(u8);
        #[automatically_derived]
        #[doc(hidden)]
        unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::clone::Clone for InternalBitFlags {
            #[inline]
            fn clone(&self) -> InternalBitFlags {
                let _: ::core::clone::AssertParamIsClone<u8>;
                *self
            }
        }
        #[automatically_derived]
        impl ::core::marker::Copy for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::cmp::PartialEq for InternalBitFlags {
            #[inline]
            fn eq(&self, other: &InternalBitFlags) -> bool {
                self.0 == other.0
            }
        }
        #[automatically_derived]
        impl ::core::cmp::Eq for InternalBitFlags {
            #[inline]
            #[doc(hidden)]
            #[coverage(off)]
            fn assert_fields_are_eq(&self) {
                let _: ::core::cmp::AssertParamIsEq<u8>;
            }
        }
        #[automatically_derived]
        impl ::core::cmp::PartialOrd for InternalBitFlags {
            #[inline]
            fn partial_cmp(&self, other: &InternalBitFlags)
                -> ::core::option::Option<::core::cmp::Ordering> {
                ::core::option::Option::Some(::core::cmp::Ord::cmp(self,
                        other))
            }
        }
        #[automatically_derived]
        impl ::core::cmp::Ord for InternalBitFlags {
            #[inline]
            fn cmp(&self, other: &InternalBitFlags) -> ::core::cmp::Ordering {
                ::core::cmp::Ord::cmp(&self.0, &other.0)
            }
        }
        #[automatically_derived]
        impl ::core::hash::Hash for InternalBitFlags {
            #[inline]
            fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
                ::core::hash::Hash::hash(&self.0, state)
            }
        }
        impl ImplTargets {
            pub const SIZE: Self = Self::from_bits_retain(1 << 0);
            pub const SERIALIZE: Self = Self::from_bits_retain(1 << 1);
            pub const DESERIALIZE: Self = Self::from_bits_retain(1 << 2);
            pub const ALL: Self =
                Self::from_bits_retain(Self::SIZE.bits() |
                            Self::SERIALIZE.bits() | Self::DESERIALIZE.bits());
        }
        impl ::bitflags::Flags for ImplTargets {
            const FLAGS: &'static [::bitflags::Flag<ImplTargets>] =
                {
                    mod __bitflags_flag_names {
                        use super::*;
                        pub(super) const SIZE: &'static str = "SIZE";
                        pub(super) const SERIALIZE: &'static str = "SERIALIZE";
                        pub(super) const DESERIALIZE: &'static str = "DESERIALIZE";
                        pub(super) const ALL: &'static str = "ALL";
                    }
                    &[{
                                    ::bitflags::Flag::new(__bitflags_flag_names::SIZE,
                                        ImplTargets::SIZE)
                                },
                                {
                                    ::bitflags::Flag::new(__bitflags_flag_names::SERIALIZE,
                                        ImplTargets::SERIALIZE)
                                },
                                {
                                    ::bitflags::Flag::new(__bitflags_flag_names::DESERIALIZE,
                                        ImplTargets::DESERIALIZE)
                                },
                                {
                                    ::bitflags::Flag::new(__bitflags_flag_names::ALL,
                                        ImplTargets::ALL)
                                }]
                };
            type Bits = u8;
            fn bits(&self) -> u8 { ImplTargets::bits(self) }
            fn from_bits_retain(bits: u8) -> ImplTargets {
                ImplTargets::from_bits_retain(bits)
            }
            fn all_named() -> ImplTargets {
                const ALL_NAMED: u8 =
                    {
                        let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
                        let mut i = 0;
                        {
                            {
                                let flag = &<ImplTargets as ::bitflags::Flags>::FLAGS[i];
                                if flag.is_named() {
                                    truncated = truncated | flag.value().bits();
                                }
                                i += 1;
                            }
                        };
                        {
                            {
                                let flag = &<ImplTargets as ::bitflags::Flags>::FLAGS[i];
                                if flag.is_named() {
                                    truncated = truncated | flag.value().bits();
                                }
                                i += 1;
                            }
                        };
                        {
                            {
                                let flag = &<ImplTargets as ::bitflags::Flags>::FLAGS[i];
                                if flag.is_named() {
                                    truncated = truncated | flag.value().bits();
                                }
                                i += 1;
                            }
                        };
                        {
                            {
                                let flag = &<ImplTargets as ::bitflags::Flags>::FLAGS[i];
                                if flag.is_named() {
                                    truncated = truncated | flag.value().bits();
                                }
                                i += 1;
                            }
                        };
                        let _ = i;
                        truncated
                    };
                ImplTargets::from_bits_retain(ALL_NAMED)
            }
        }
        impl ::bitflags::__private::PublicFlags for ImplTargets {
            type Primitive = u8;
            type Internal = InternalBitFlags;
        }
        impl ::bitflags::__private::core::default::Default for
            InternalBitFlags {
            #[inline]
            fn default() -> Self { InternalBitFlags::empty() }
        }
        impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                if self.is_empty() {
                    f.write_fmt(format_args!("{0:#x}",
                            <u8 as ::bitflags::Bits>::EMPTY))
                } else {
                    ::bitflags::__private::core::fmt::Display::fmt(self, f)
                }
            }
        }
        impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                ::bitflags::parser::to_writer(&ImplTargets(*self), f)
            }
        }
        impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
            type Err = ::bitflags::parser::ParseError;
            fn from_str(s: &str)
                ->
                    ::bitflags::__private::core::result::Result<Self,
                    Self::Err> {
                ::bitflags::parser::from_str::<ImplTargets>(s).map(|flags|
                        flags.0)
            }
        }
        impl ::bitflags::__private::core::convert::AsRef<u8> for
            InternalBitFlags {
            fn as_ref(&self) -> &u8 { &self.0 }
        }
        impl ::bitflags::__private::core::convert::From<u8> for
            InternalBitFlags {
            fn from(bits: u8) -> Self { Self::from_bits_retain(bits) }
        }
        impl InternalBitFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u8 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <ImplTargets as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <ImplTargets as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <ImplTargets as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <ImplTargets as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::bitflags::__private::core::option::Option<Self> {
                let truncated = Self::from_bits_truncate(bits).0;
                if truncated == bits {
                    ::bitflags::__private::core::option::Option::Some(Self(bits))
                } else { ::bitflags::__private::core::option::Option::None }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                mod __bitflags_flag_names {
                    use super::*;
                    pub(super) const SIZE: &'static str = "SIZE";
                    pub(super) const SERIALIZE: &'static str = "SERIALIZE";
                    pub(super) const DESERIALIZE: &'static str = "DESERIALIZE";
                    pub(super) const ALL: &'static str = "ALL";
                }
                {
                    {
                        if name == __bitflags_flag_names::SIZE {
                            return ::bitflags::__private::core::option::Option::Some(Self(ImplTargets::SIZE.bits()));
                        }
                    };
                };
                {
                    {
                        if name == __bitflags_flag_names::SERIALIZE {
                            return ::bitflags::__private::core::option::Option::Some(Self(ImplTargets::SERIALIZE.bits()));
                        }
                    };
                };
                {
                    {
                        if name == __bitflags_flag_names::DESERIALIZE {
                            return ::bitflags::__private::core::option::Option::Some(Self(ImplTargets::DESERIALIZE.bits()));
                        }
                    };
                };
                {
                    {
                        if name == __bitflags_flag_names::ALL {
                            return ::bitflags::__private::core::option::Option::Some(Self(ImplTargets::ALL.bits()));
                        }
                    };
                };
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in `self` are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in `other` are also set in `self`.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in `other` are also set in `self`.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in `self`, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            fn bitor(self, other: InternalBitFlags) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            InternalBitFlags {
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            InternalBitFlags {
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
            type Output = Self;
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
            {
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in `self`, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
            for InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl InternalBitFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<ImplTargets> {
                ::bitflags::iter::Iter::__private_const_new(<ImplTargets as
                        ::bitflags::Flags>::FLAGS,
                    ImplTargets::from_bits_retain(self.bits()),
                    ImplTargets::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<ImplTargets> {
                ::bitflags::iter::IterNames::__private_const_new(<ImplTargets
                        as ::bitflags::Flags>::FLAGS,
                    ImplTargets::from_bits_retain(self.bits()),
                    ImplTargets::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            InternalBitFlags {
            type Item = ImplTargets;
            type IntoIter = ::bitflags::iter::Iter<ImplTargets>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
        impl InternalBitFlags {
            /// Returns a mutable reference to the raw value of the flags currently stored.
            #[inline]
            pub fn bits_mut(&mut self) -> &mut u8 { &mut self.0 }
        }
        impl ImplTargets {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self { Self(InternalBitFlags::all()) }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0.bits() }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_bits(bits) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_truncate(bits))
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_retain(bits))
            }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_name(name) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Whether all bits in `self` are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool { self.0.is_empty() }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool { self.0.is_all() }
            /// Whether any set bits in `other` are also set in `self`.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0.intersects(other.0)
            }
            /// Whether all set bits in `other` are also set in `self`.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0.contains(other.0)
            }
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                self.0.set(other.0, value)
            }
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0.intersection(other.0))
            }
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0.union(other.0))
            }
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0.difference(other.0))
            }
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0.symmetric_difference(other.0))
            }
            /// The bitwise negation (`!`) of the bits in `self`, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self(self.0.complement())
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for ImplTargets {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for ImplTargets {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for ImplTargets {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for ImplTargets {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for ImplTargets {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            fn bitor(self, other: ImplTargets) -> Self { self.union(other) }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for ImplTargets {
            /// The bitwise or (`|`) of the bits in `self` and `other`.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for ImplTargets {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for ImplTargets {
            /// The bitwise exclusive-or (`^`) of the bits in `self` and `other`.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for ImplTargets {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for ImplTargets {
            /// The bitwise and (`&`) of the bits in `self` and `other`.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for ImplTargets {
            type Output = Self;
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for ImplTargets {
            /// The intersection of `self` with the complement of `other` (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for ImplTargets {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in `self`, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<ImplTargets> for
            ImplTargets {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<ImplTargets> for
            ImplTargets {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl ImplTargets {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<ImplTargets> {
                ::bitflags::iter::Iter::__private_const_new(<ImplTargets as
                        ::bitflags::Flags>::FLAGS,
                    ImplTargets::from_bits_retain(self.bits()),
                    ImplTargets::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<ImplTargets> {
                ::bitflags::iter::IterNames::__private_const_new(<ImplTargets
                        as ::bitflags::Flags>::FLAGS,
                    ImplTargets::from_bits_retain(self.bits()),
                    ImplTargets::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for ImplTargets {
            type Item = ImplTargets;
            type IntoIter = ::bitflags::iter::Iter<ImplTargets>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
727    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
728    struct ImplTargets: u8 {
729        const SIZE = 1 << 0;
730        const SERIALIZE = 1 << 1;
731        const DESERIALIZE = 1 << 2;
732
733        const ALL = Self::SIZE.bits() | Self::SERIALIZE.bits() | Self::DESERIALIZE.bits();
734    }
735}
736
737fn augment_generics_ty(generics: &Generics, impl_targets: ImplTargets) -> Generics {
738    let mut generics = generics.clone();
739
740    for ty in generics.type_params_mut() {
741        if impl_targets.contains(ImplTargets::SIZE) {
742            let tlspl_size_bound = syn::TypeParamBound::Trait(::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "thalassa");
        ::quote::__private::push_colon2(&mut _s);
        ::quote::__private::push_ident(&mut _s, "TlsplSize");
        _s
    })parse_quote!(thalassa::TlsplSize));
743            if ty.bounds.iter().all(|bound| bound != &tlspl_size_bound) {
744                ty.bounds.push(tlspl_size_bound);
745            }
746        }
747
748        if impl_targets.contains(ImplTargets::SERIALIZE) {
749            let tlspl_ser_bound =
750                syn::TypeParamBound::Trait(::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "thalassa");
        ::quote::__private::push_colon2(&mut _s);
        ::quote::__private::push_ident(&mut _s, "TlsplSerialize");
        _s
    })parse_quote!(thalassa::TlsplSerialize));
751            if ty.bounds.iter().all(|bound| bound != &tlspl_ser_bound) {
752                ty.bounds.push(tlspl_ser_bound);
753            }
754        }
755
756        if impl_targets.contains(ImplTargets::DESERIALIZE) {
757            let tlspl_deser_bound =
758                syn::TypeParamBound::Trait(::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "thalassa");
        ::quote::__private::push_colon2(&mut _s);
        ::quote::__private::push_ident(&mut _s, "TlsplDeserialize");
        ::quote::__private::push_lt(&mut _s);
        ::quote::__private::push_lifetime(&mut _s, "\'tlspl");
        ::quote::__private::push_gt(&mut _s);
        _s
    })parse_quote!(thalassa::TlsplDeserialize<'tlspl>));
759            if ty.bounds.iter().all(|bound| bound != &tlspl_deser_bound) {
760                ty.bounds.push(tlspl_deser_bound);
761            }
762
763            let tlspl_lt_bound = syn::TypeParamBound::Lifetime(::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_lifetime(&mut _s, "\'tlspl");
        _s
    })parse_quote!('tlspl));
764            if ty.bounds.iter().all(|bound| bound != &tlspl_lt_bound) {
765                ty.bounds.push(tlspl_lt_bound);
766            }
767        }
768    }
769
770    generics
771}
772
773fn augment_generics_with_lt(generics: &Generics) -> Generics {
774    let mut generics = generics.clone();
775
776    if generics.lifetimes().next().is_none() {
777        generics
778            .params
779            .push(GenericParam::Lifetime(::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_lifetime(&mut _s, "\'tlspl");
        _s
    })parse_quote!('tlspl)));
780    } else if generics.lifetimes().all(|lt| lt.lifetime.ident != "tlspl") {
781        let lifetimes = generics.lifetimes();
782        generics.params.push(GenericParam::Lifetime(
783            ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_lifetime(&mut _s, "\'tlspl");
        ::quote::__private::push_colon(&mut _s);
        {
            use ::quote::__private::ext::*;
            let mut _first = true;
            let has_iter = ::quote::__private::HasIterator::<false>;
            #[allow(unused_mut)]
            let (mut lifetimes, i) = lifetimes.quote_into_iter();
            let has_iter = has_iter | i;
            <_ as
                    ::quote::__private::CheckHasIterator<true>>::check(has_iter);
            while true {
                let lifetimes =
                    match lifetimes.next() {
                        Some(_x) => ::quote::__private::RepInterp(_x),
                        None => break,
                    };
                if !_first { ::quote::__private::push_add(&mut _s); }
                _first = false;
                ::quote::ToTokens::to_tokens(&lifetimes, &mut _s);
            }
        }
        _s
    })parse_quote!('tlspl: #(#lifetimes)+*),
784        ));
785    }
786
787    generics
788}
789
790impl darling::FromDeriveInput for TlsplDeriveTarget {
791    fn from_derive_input(input: &DeriveInput) -> darling::Result<Self> {
792        let span = input.span();
793        Ok(match &input.data {
794            syn::Data::Struct(syn::DataStruct {
795                fields: syn::Fields::Named(_),
796                ..
797            }) => Self::StructNamed(SpannedValue::new(
798                StructNamedTarget::from_derive_input(input)?,
799                span,
800            )),
801            syn::Data::Struct(syn::DataStruct {
802                fields: syn::Fields::Unnamed(_),
803                ..
804            }) => Self::StructTuple(SpannedValue::new(
805                StructTupleTarget::from_derive_input(input)?,
806                span,
807            )),
808            syn::Data::Struct(syn::DataStruct {
809                fields: syn::Fields::Unit,
810                ..
811            }) => Self::StructUnit(SpannedValue::new(
812                StructUnitTarget::from_derive_input(input)?,
813                span,
814            )),
815            syn::Data::Enum(_) => {
816                let enum_def = EnumTarget::from_derive_input(input)?;
817                let enum_is_nakd = enum_def
818                    .data
819                    .variants
820                    .iter()
821                    // Skip over variants that are marked #[tlspl(other)] to get an accurate count
822                    .filter(|v| !v.attrs().other.is_present())
823                    .all(|v| v.field_count() == 0);
824                let enum_has_catchall = enum_def
825                    .data
826                    .variants
827                    .iter()
828                    .find(|v| v.attrs().other.is_present());
829
830                if enum_def.attr.untagged.is_present() {
831                    let all_variants_have_discriminants =
832                        enum_def.data.variants.iter().all(|variant| {
833                            #[allow(non_exhaustive_omitted_patterns)] match variant.attrs().discriminant {
    Some(DiscriminantTarget::Path(_)) => true,
    _ => false,
}matches!(
834                                variant.attrs().discriminant,
835                                Some(DiscriminantTarget::Path(_))
836                            )
837                        });
838
839                    if !all_variants_have_discriminants {
840                        return Err(darling::Error::custom(
841                            "Untagged enums REQUIRE to have all of their custom discriminants pointing to paths (eg: `#[tlspl(discriminant = \"OtherEnum::Variant\")]`",
842                        ));
843                    }
844                }
845
846                if let Some(catchall_variant) = enum_has_catchall {
847                    if !enum_is_nakd && !enum_def.attr.extensible.is_present() {
848                        return Err(darling::Error::custom(
849                            "`#[tlspl(other)]` is only useable on enums that are either naked enums (with no fields in variants) or enums that are marked `extensible`",
850                        ));
851                    }
852
853                    let enum_repr = extract_repr_from_attrs(&enum_def.attrs)?;
854                    let field_n = catchall_variant.field_count();
855
856                    let first_ty_matches_repr = || {
857                        if let Some(Type::Path(tp)) =
858                            catchall_variant.members_with_exprs().next().map(|m| m.ty)
859                        {
860                            tp.path.get_ident().unwrap() == &enum_repr
861                        } else {
862                            false
863                        }
864                    };
865
866                    let second_ty_is_bytes = || {
867                        if let Some(Type::Path(tp)) =
868                            &catchall_variant.members_with_exprs().nth(1).map(|m| m.ty)
869                        {
870                            tp.path.segments.last().unwrap().ident == "Cow"
871                        } else {
872                            false
873                        }
874                    };
875
876                    if enum_is_nakd {
877                        if field_n != 1 || !first_ty_matches_repr() {
878                            return Err(darling::Error::custom(
879                                "Catch-all variants marked with `#[tlspl(other)]` on naked enums need to have exactly *one* tuple field equal to the `#[repr]` of the enum",
880                            ));
881                        }
882                    } else {
883                        if field_n != 2 || !first_ty_matches_repr() || !second_ty_is_bytes() {
884                            return Err(darling::Error::custom(
885                                "Catch-all variants marked with `#[tlspl(other)]` on naked enums need to have exactly *two* tuple field equal to the `#[repr]` of the enum and a Cow<[u8]> container afterwards (like so: `Other(u8, Cow<'a, [u8]>)`",
886                            ));
887                        }
888                    }
889                }
890                Self::Enum(SpannedValue::new(enum_def, span))
891            }
892            syn::Data::Union(_) => {
893                return Err(darling::Error::custom(
894                    "Unions are not supported in the TLSPL data scheme",
895                ));
896            }
897        })
898    }
899}
900
901fn discr_fence_name(enum_ident: &Ident) -> Ident {
902    match ::quote::__private::IdentFragmentAdapter(&enum_ident) {
    arg =>
        ::quote::__private::mk_ident(&::alloc::__export::must_use({
                        ::alloc::fmt::format(format_args!("__THALASSA_DISCR_FENCE_{0}",
                                arg))
                    }), ::quote::__private::Option::None.or(arg.span())),
}format_ident!("__THALASSA_DISCR_FENCE_{}", enum_ident)
903}
904
905impl TlsplDeriveTarget {
906    fn impl_size(&self) -> darling::Result<TokenStream2> {
907        Ok(match self {
908            TlsplDeriveTarget::StructNamed(sv) => {
909                let span = sv.span();
910                let StructNamedTarget {
911                    ident,
912                    generics,
913                    data,
914                } = sv.as_ref();
915                let generics = augment_generics_ty(generics, ImplTargets::SIZE);
916                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
917
918                let member_calls = data.fields.iter().filter_map(|f| {
919                    if f.attr.skip.is_present() {
920                        return None;
921                    }
922
923                    let ident = syn::Member::Named(f.ident.clone());
924                    Some(if let Some(module_with) = &f.attr.with {
925                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&module_with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
            ::quote::__private::push_dot_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            _s
        });
    _s
}quote_spanned! {f.span()=> #module_with::tlspl_serialized_len(&self.#ident) }
926                    } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
927                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse_spanned(&mut _s, _span, "1");
    _s
}quote_spanned! {f.span()=> 1 }
928                    } else {
929                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! {f.span()=> self.#ident.tlspl_serialized_len() }
930                    })
931                });
932
933                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialized_len");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut member_calls, i) = member_calls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let member_calls =
                                match member_calls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::__private::push_add_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&member_calls, &mut _s);
                        }
                    }
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
934                    #[automatically_derived]
935                    impl #impl_generics thalassa::TlsplSize for #ident #ty_generics #where_c {
936                        #[inline]
937                        #[allow(clippy::identity_op)]
938                        fn tlspl_serialized_len(&self) -> usize {
939                            0 #(+ #member_calls)*
940                        }
941                    }
942                }
943            }
944            TlsplDeriveTarget::StructTuple(sv) => {
945                let span = sv.span();
946                let StructTupleTarget {
947                    ident,
948                    generics,
949                    data,
950                } = sv.as_ref();
951                let generics = augment_generics_ty(generics, ImplTargets::SIZE);
952                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
953
954                let member_calls = data.fields.iter().enumerate().filter_map(|(idx, f)| {
955                    if f.attr.skip.is_present() {
956                        return None;
957                    }
958
959                    let ident = syn::Member::Unnamed(idx.into());
960                    Some(if let Some(module_with) = &f.attr.with {
961                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&module_with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
            ::quote::__private::push_dot_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            _s
        });
    _s
}quote_spanned! { f.span()=> #module_with::tlspl_serialized_len(&self.#ident) }
962                    } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
963                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse_spanned(&mut _s, _span, "1");
    _s
}quote_spanned! {f.span()=> 1 }
964                    } else {
965                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! { f.span()=> self.#ident.tlspl_serialized_len() }
966                    })
967                });
968
969                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialized_len");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut member_calls, i) = member_calls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let member_calls =
                                match member_calls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::__private::push_add_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&member_calls, &mut _s);
                        }
                    }
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
970                    #[automatically_derived]
971                    impl #impl_generics thalassa::TlsplSize for #ident #ty_generics #where_c {
972                        #[inline]
973                        #[allow(clippy::identity_op)]
974                        fn tlspl_serialized_len(&self) -> usize {
975                            0 #(+ #member_calls)*
976                        }
977                    }
978                }
979            }
980            TlsplDeriveTarget::StructUnit(sv) => {
981                let span = sv.span();
982                let StructUnitTarget { ident, generics } = sv.as_ref();
983                let generics = augment_generics_ty(generics, ImplTargets::SIZE);
984                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
985
986                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialized_len");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
987                    #[automatically_derived]
988                    impl #impl_generics thalassa::TlsplSize for #ident #ty_generics #where_c {
989                        #[inline]
990                        #[allow(clippy::identity_op)]
991                        fn tlspl_serialized_len(&self) -> usize { 0 }
992                    }
993                }
994            }
995            Self::Enum(sv) => {
996                let span = sv.span();
997                let EnumTarget {
998                    ident,
999                    generics,
1000                    attrs,
1001                    data,
1002                    attr,
1003                } = sv.as_ref();
1004                let repr = extract_repr_from_attrs(attrs)?;
1005                let generics = augment_generics_ty(generics, ImplTargets::SIZE);
1006                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
1007
1008                let variant_arms = data.variants.iter().map(|variant| {
1009                    let span = variant.span();
1010                    let variant_ident = variant.ident();
1011                    let variant_is_tuple = #[allow(non_exhaustive_omitted_patterns)] match variant {
    Variant::Tuple(_) => true,
    _ => false,
}matches!(variant, Variant::Tuple(_));
1012
1013                    let (field_mappings, field_mapping_calls): (Vec<_>, Vec<_>) = variant.members_with_exprs().filter_map(|member| {
1014                        if member.attrs.skip.is_present() {
1015                            return None;
1016                        }
1017
1018                        let ident = member.ident;
1019                        let method_mapping = if let Some(with) = member.attrs.with {
1020                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            _s
        });
    _s
}quote_spanned! { member.span=> #with::tlspl_serialized_len(&#ident) }
1021                        } else if member.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1022                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse_spanned(&mut _s, _span, "1");
    _s
}quote_spanned! { member.span=> 1 }
1023                        } else {
1024                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialized_len");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! { member.span=> #ident.tlspl_serialized_len() }
1025                        };
1026
1027                        Some((ident, method_mapping))
1028                    }).unzip();
1029
1030                    if variant.attrs().other.is_present() {
1031                        return {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                }
            }
            ::quote::__private::push_dot2_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "return");
            ::quote::__private::parse_spanned(&mut _s, _span, "0");
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mapping_calls, i) =
                    field_mapping_calls.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mapping_calls =
                        match field_mapping_calls.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::__private::push_add_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
                }
            }
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1032                            #ident::#variant_ident(#(#field_mappings,)* ..) => { return 0 #(+ #field_mapping_calls)*; },
1033                        };
1034                    }
1035
1036                    if variant_is_tuple {
1037                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                }
            }
            ::quote::__private::push_dot2_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::__private::parse_spanned(&mut _s, _span, "0");
    {
        use ::quote::__private::ext::*;
        let has_iter = ::quote::__private::HasIterator::<false>;
        #[allow(unused_mut)]
        let (mut field_mapping_calls, i) =
            field_mapping_calls.quote_into_iter();
        let has_iter = has_iter | i;
        <_ as ::quote::__private::CheckHasIterator<true>>::check(has_iter);
        while true {
            let field_mapping_calls =
                match field_mapping_calls.next() {
                    Some(_x) => ::quote::__private::RepInterp(_x),
                    None => break,
                };
            ::quote::__private::push_add_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
        }
    }
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1038                            #ident::#variant_ident(#(#field_mappings,)* ..) => 0 #(+ #field_mapping_calls)*,
1039                        }
1040                    } else {
1041                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                }
            }
            ::quote::__private::push_dot2_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::__private::parse_spanned(&mut _s, _span, "0");
    {
        use ::quote::__private::ext::*;
        let has_iter = ::quote::__private::HasIterator::<false>;
        #[allow(unused_mut)]
        let (mut field_mapping_calls, i) =
            field_mapping_calls.quote_into_iter();
        let has_iter = has_iter | i;
        <_ as ::quote::__private::CheckHasIterator<true>>::check(has_iter);
        while true {
            let field_mapping_calls =
                match field_mapping_calls.next() {
                    Some(_x) => ::quote::__private::RepInterp(_x),
                    None => break,
                };
            ::quote::__private::push_add_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
        }
    }
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1042                            #ident::#variant_ident { #(#field_mappings,)* .. } => 0 #(+ #field_mapping_calls)*,
1043                        }
1044                    }
1045                });
1046
1047                let (discr_block, untagged_trait_impl, untagged_discr_fence) = if attr
1048                    .untagged
1049                    .is_present()
1050                {
1051                    let discr_fence_name = discr_fence_name(ident);
1052                    (
1053                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse(&mut _s, "0");
    _s
}quote!(0),
1054                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "automatically_derived");
            _s
        });
    ::quote::__private::push_ident(&mut _s, "unsafe");
    ::quote::__private::push_ident(&mut _s, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident(&mut _s, "thalassa");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "util");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "TlsplUntaggedEnum");
    ::quote::__private::push_ident(&mut _s, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Brace,
        ::quote::__private::TokenStream::new());
    _s
}quote! {
1055
1056                            #[automatically_derived]
1057                            unsafe impl #impl_generics thalassa::util::TlsplUntaggedEnum for #ident #ty_generics #where_c {}
1058                        },
1059                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "std");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "thread_local");
    ::quote::__private::push_bang(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound(&mut _s);
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "allow");
                    ::quote::__private::push_group(&mut _s,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident(&mut _s,
                                "non_upper_case_globals");
                            ::quote::__private::push_comma(&mut _s);
                            ::quote::__private::push_ident(&mut _s, "clippy");
                            ::quote::__private::push_colon2(&mut _s);
                            ::quote::__private::push_ident(&mut _s, "identity_op");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident(&mut _s, "pub");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "crate");
                    _s
                });
            ::quote::__private::push_ident(&mut _s, "static");
            ::quote::ToTokens::to_tokens(&discr_fence_name, &mut _s);
            ::quote::__private::push_colon(&mut _s);
            ::quote::__private::push_ident(&mut _s, "std");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "cell");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "Cell");
            ::quote::__private::push_lt(&mut _s);
            ::quote::__private::push_ident(&mut _s, "Option");
            ::quote::__private::push_lt(&mut _s);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_shr(&mut _s);
            ::quote::__private::push_eq(&mut _s);
            ::quote::__private::push_ident(&mut _s, "const");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "std");
                    ::quote::__private::push_colon2(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "cell");
                    ::quote::__private::push_colon2(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "Cell");
                    ::quote::__private::push_colon2(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "new");
                    ::quote::__private::push_group(&mut _s,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident(&mut _s, "None");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_semi(&mut _s);
            _s
        });
    _s
}quote! {
1060
1061                            std::thread_local! {
1062                                #[allow(non_upper_case_globals, clippy::identity_op)]
1063                                pub(crate) static #discr_fence_name: std::cell::Cell<Option<#repr>> = const { std::cell::Cell::new(None) };
1064                            }
1065                        },
1066                    )
1067                } else {
1068                    ({
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "core");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "mem");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "size_of");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_lt(&mut _s);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_gt(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        ::quote::__private::TokenStream::new());
    _s
}quote!(core::mem::size_of::<#repr>()), ::quote::__private::TokenStream::new()quote!(), ::quote::__private::TokenStream::new()quote!())
1069                };
1070
1071                let maybe_extensible = if attr.extensible.is_present() {
1072                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "thalassa");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "types");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s,
        "content_len_as_vlbytes_overhead");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "content_len");
            _s
        });
    _s
}quote!(thalassa::types::content_len_as_vlbytes_overhead(
1073                        content_len
1074                    ))
1075                } else {
1076                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse(&mut _s, "0");
    _s
}quote!(0)
1077                };
1078
1079                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialized_len");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "let");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "content_len");
                    ::quote::__private::push_eq_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "match");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Brace,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            {
                                use ::quote::__private::ext::*;
                                let has_iter = ::quote::__private::HasIterator::<false>;
                                #[allow(unused_mut)]
                                let (mut variant_arms, i) = variant_arms.quote_into_iter();
                                let has_iter = has_iter | i;
                                <_ as
                                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                                while true {
                                    let variant_arms =
                                        match variant_arms.next() {
                                            Some(_x) => ::quote::__private::RepInterp(_x),
                                            None => break,
                                        };
                                    ::quote::ToTokens::to_tokens(&variant_arms, &mut _s);
                                }
                            }
                            _s
                        });
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&discr_block, &mut _s);
                    ::quote::__private::push_add_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&maybe_extensible, &mut _s);
                    ::quote::__private::push_add_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "content_len");
                    _s
                });
            _s
        });
    ::quote::ToTokens::to_tokens(&untagged_trait_impl, &mut _s);
    ::quote::ToTokens::to_tokens(&untagged_discr_fence, &mut _s);
    _s
}quote_spanned! { span=>
1080                    #[automatically_derived]
1081                    impl #impl_generics thalassa::TlsplSize for #ident #ty_generics #where_c {
1082                        #[inline]
1083                        #[allow(clippy::identity_op)]
1084                        fn tlspl_serialized_len(&self) -> usize {
1085                            let content_len = match self {
1086                                #(#variant_arms)*
1087                            };
1088
1089                            #discr_block + #maybe_extensible + content_len
1090                        }
1091                    }
1092                    #untagged_trait_impl
1093                    #untagged_discr_fence
1094                }
1095            }
1096        })
1097    }
1098
1099    fn impl_serialize(&self) -> darling::Result<TokenStream2> {
1100        Ok(match self {
1101            TlsplDeriveTarget::StructNamed(sv) => {
1102                let span = sv.span();
1103                let StructNamedTarget {
1104                    ident,
1105                    generics,
1106                    data,
1107                } = sv.as_ref();
1108                let generics = augment_generics_ty(generics, ImplTargets::SERIALIZE);
1109                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
1110
1111                let member_calls = data.fields.iter().filter_map(|f| {
1112                    if f.attr.skip.is_present() {
1113                        return None;
1114                    }
1115
1116                    let ident = syn::Member::Named(f.ident.clone());
1117                    Some(if let Some(module_with) = &f.attr.with {
1118                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&module_with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
            ::quote::__private::push_dot_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            ::quote::__private::push_comma_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> #module_with::tlspl_serialize_to(&self.#ident, writer)? }
1119                    } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1120                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "write");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_dot_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&ident, &mut _s);
                    _s
                });
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> writer.write(&[self.#ident])? }
1121                    } else {
1122                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> self.#ident.tlspl_serialize_to(writer)? }
1123                    })
1124                });
1125
1126                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSerialize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialize_to");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Write");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "writer");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplWriteResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "let");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "written");
                    ::quote::__private::push_eq_spanned(&mut _s, _span);
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut member_calls, i) = member_calls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let member_calls =
                                match member_calls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "written");
                            ::quote::__private::push_add_eq_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&member_calls, &mut _s);
                            ::quote::__private::push_semi_spanned(&mut _s, _span);
                        }
                    }
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "written");
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1127                    #[automatically_derived]
1128                    impl #impl_generics thalassa::TlsplSerialize for #ident #ty_generics #where_c {
1129                        #[inline]
1130                        fn tlspl_serialize_to<W: thalassa::io::Write>(&self, writer: &mut W) -> thalassa::error::TlsplWriteResult<usize> {
1131                            let mut written = 0;
1132                            #(written += #member_calls;)*
1133                            Ok(written)
1134                        }
1135                    }
1136                }
1137            }
1138            TlsplDeriveTarget::StructTuple(sv) => {
1139                let span = sv.span();
1140                let StructTupleTarget {
1141                    ident,
1142                    generics,
1143                    data,
1144                } = sv.as_ref();
1145                let generics = augment_generics_ty(generics, ImplTargets::SERIALIZE);
1146                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
1147
1148                let member_calls = data.fields.iter().enumerate().filter_map(|(idx, f)| {
1149                    if f.attr.skip.is_present() {
1150                        return None;
1151                    }
1152
1153                    let ident = syn::Member::Unnamed(idx.into());
1154                    Some(if let Some(module_with) = &f.attr.with {
1155                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&module_with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
            ::quote::__private::push_dot_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            ::quote::__private::push_comma_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> #module_with::tlspl_serialize_to(&self.#ident, writer)? }
1156                    } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1157                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "write");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_dot_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&ident, &mut _s);
                    _s
                });
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> writer.write(&[self.#ident])? }
1158                    } else {
1159                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "self");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "writer");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> self.#ident.tlspl_serialize_to(writer)? }
1160                    })
1161                });
1162
1163                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSerialize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialize_to");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Write");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "writer");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplWriteResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "let");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "written");
                    ::quote::__private::push_eq_spanned(&mut _s, _span);
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut member_calls, i) = member_calls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let member_calls =
                                match member_calls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "written");
                            ::quote::__private::push_add_eq_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&member_calls, &mut _s);
                            ::quote::__private::push_semi_spanned(&mut _s, _span);
                        }
                    }
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "written");
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1164                    #[automatically_derived]
1165                    impl #impl_generics thalassa::TlsplSerialize for #ident #ty_generics #where_c {
1166                        #[inline]
1167                        fn tlspl_serialize_to<W: thalassa::io::Write>(&self, writer: &mut W) -> thalassa::error::TlsplWriteResult<usize> {
1168                            let mut written = 0;
1169                            #(written += #member_calls;)*
1170                            Ok(written)
1171                        }
1172                    }
1173                }
1174            }
1175            TlsplDeriveTarget::StructUnit(sv) => {
1176                let span = sv.span();
1177                let StructUnitTarget { ident, generics } = sv.as_ref();
1178                let generics = augment_generics_ty(generics, ImplTargets::SERIALIZE);
1179                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
1180
1181                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSerialize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialize_to");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Write");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "writer");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplWriteResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::parse_spanned(&mut _s, _span, "0");
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1182                    #[automatically_derived]
1183                    impl #impl_generics thalassa::TlsplSerialize for #ident #ty_generics #where_c {
1184                        #[inline]
1185                        fn tlspl_serialize_to<W: thalassa::io::Write>(&self, writer: &mut W) -> thalassa::error::TlsplWriteResult<usize> {
1186                            Ok(0)
1187                        }
1188                    }
1189                }
1190            }
1191            TlsplDeriveTarget::Enum(sv) => {
1192                let span = sv.span();
1193                let discriminants_ts = sv.data.discriminant_consts(sv.as_ref())?;
1194                let EnumTarget {
1195                    ident,
1196                    generics,
1197                    data,
1198                    attr,
1199                    attrs,
1200                } = sv.as_ref();
1201
1202                let generics = augment_generics_ty(generics, ImplTargets::SERIALIZE);
1203                let (impl_generics, ty_generics, where_c) = generics.split_for_impl();
1204                let repr = extract_repr_from_attrs(attrs)?;
1205
1206                let is_extensible = attr.extensible.is_present();
1207
1208                let (extensible_bootstrap, write_target, extensible_finalize) = if is_extensible {
1209                    (
1210                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "let");
    ::quote::__private::push_ident(&mut _s, "mut");
    ::quote::__private::push_ident(&mut _s, "buffer");
    ::quote::__private::push_eq(&mut _s);
    ::quote::__private::push_ident(&mut _s, "Vec");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_lt(&mut _s);
    ::quote::__private::push_ident(&mut _s, "u8");
    ::quote::__private::push_gt(&mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "with_capacity");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "self");
            ::quote::__private::push_dot(&mut _s);
            ::quote::__private::push_ident(&mut _s, "tlspl_serialized_len");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                ::quote::__private::TokenStream::new());
            ::quote::__private::push_sub(&mut _s);
            ::quote::__private::push_ident(&mut _s, "core");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "mem");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "size_of");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_lt(&mut _s);
            ::quote::ToTokens::to_tokens(&repr, &mut _s);
            ::quote::__private::push_gt(&mut _s);
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                ::quote::__private::TokenStream::new());
            ::quote::__private::push_sub(&mut _s);
            ::quote::__private::parse(&mut _s, "1");
            _s
        });
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
1211                            let mut buffer = Vec::<u8>::with_capacity(self.tlspl_serialized_len() - core::mem::size_of::<#repr>() - 1);
1212                        },
1213                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_and(&mut _s);
    ::quote::__private::push_ident(&mut _s, "mut");
    ::quote::__private::push_ident(&mut _s, "buffer");
    _s
}quote!(&mut buffer),
1214                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "debug_assert_eq");
            ::quote::__private::push_bang(&mut _s);
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "field_written");
                    ::quote::__private::push_comma(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "buffer");
                    ::quote::__private::push_dot(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "len");
                    ::quote::__private::push_group(&mut _s,
                        ::quote::__private::Delimiter::Parenthesis,
                        ::quote::__private::TokenStream::new());
                    ::quote::__private::push_comma(&mut _s);
                    ::quote::__private::parse(&mut _s, "\"Write mismatch\"");
                    _s
                });
            ::quote::__private::push_semi(&mut _s);
            ::quote::__private::push_ident(&mut _s, "buffer");
            ::quote::__private::push_dot(&mut _s);
            ::quote::__private::push_ident(&mut _s, "tlspl_serialize_to");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "writer");
                    _s
                });
            ::quote::__private::push_question(&mut _s);
            _s
        });
    _s
}quote! {{
1215                            debug_assert_eq!(field_written, buffer.len(), "Write mismatch");
1216                            buffer.tlspl_serialize_to(writer)?
1217                        }},
1218                    )
1219                } else {
1220                    (::quote::__private::TokenStream::new()quote!(), {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "writer");
    _s
}quote!(writer), {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "field_written");
    _s
}quote!(field_written))
1221                };
1222
1223                let variant_arms = data.variants.iter().map(|variant| {
1224                    let span = variant.span();
1225                    let variant_is_tuple = #[allow(non_exhaustive_omitted_patterns)] match variant {
    Variant::Tuple(_) => true,
    _ => false,
}matches!(variant, Variant::Tuple(_));
1226                    let variant_ident = variant.ident();
1227                    let discriminant = discr_const_ident(variant_ident);
1228                    let variant_is_catchall = variant.attrs().other.is_present();
1229
1230                    let actual_write_target = if variant_is_catchall {
1231                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "writer");
    _s
}quote!(writer)
1232                    } else {
1233                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&write_target, &mut _s);
    _s
}quote!(#write_target)
1234                    };
1235
1236                    let (field_mappings, field_mapping_calls): (Vec<_>, Vec<_>) = variant
1237                        .members_with_exprs()
1238                        .filter_map(|member| {
1239                            if member.attrs.skip.is_present() {
1240                                return None;
1241                            }
1242
1243                            let ident = member.ident;
1244                            let method_mapping = if let Some(with) = member.attrs.with {
1245                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            ::quote::__private::push_comma_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&actual_write_target, &mut _s);
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> #with::tlspl_serialize_to(&#ident, #actual_write_target)? }
1246                            } else if member.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1247                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&actual_write_target, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "write");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_star_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&ident, &mut _s);
                    _s
                });
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> #actual_write_target.write(&[*#ident])? }
1248                            } else {
1249                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_serialize_to");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&actual_write_target, &mut _s);
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> #ident.tlspl_serialize_to(#actual_write_target)? }
1250                            };
1251
1252                            Some((ident, method_mapping))
1253                        })
1254                        .unzip();
1255
1256
1257                    let variant_match = if variant_is_tuple {
1258                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_comma(&mut _s);
                }
            }
            ::quote::__private::push_dot2(&mut _s);
            _s
        });
    _s
}quote!(#ident::#variant_ident(#(#field_mappings,)* ..))
1259                    } else {
1260                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_comma(&mut _s);
                }
            }
            ::quote::__private::push_dot2(&mut _s);
            _s
        });
    _s
}quote!(#ident::#variant_ident { #(#field_mappings,)* .. })
1261                    };
1262
1263                    if variant_is_catchall {
1264                        if !variant_is_tuple || field_mappings.is_empty() || field_mappings.len() > 2 {
1265                            return Err(darling::Error::custom("The `other` Variant is malformed, it is expected to be a tuple comprised of 1 or 2 fields: (repr) or (repr, Cow<[u8]>)"));
1266                        }
1267
1268                        return Ok({
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&variant_match, &mut _s);
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "return");
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Ok");
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::parse_spanned(&mut _s, _span, "0");
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut field_mapping_calls, i) =
                            field_mapping_calls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let field_mapping_calls =
                                match field_mapping_calls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::__private::push_add_spanned(&mut _s, _span);
                            ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
                        }
                    }
                    _s
                });
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1269                            #variant_match => {
1270                                return Ok(0 #(+ #field_mapping_calls)*);
1271                            },
1272                        });
1273                    }
1274
1275                    let discr_block = if attr.untagged.is_present() {
1276                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::parse(&mut _s, "0");
    _s
}quote!(0)
1277                    } else {
1278                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "writer");
    ::quote::__private::push_dot(&mut _s);
    ::quote::__private::push_ident(&mut _s, "write");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_and(&mut _s);
            ::quote::ToTokens::to_tokens(&discriminant, &mut _s);
            ::quote::__private::push_dot(&mut _s);
            ::quote::__private::push_ident(&mut _s, "to_be_bytes");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                ::quote::__private::TokenStream::new());
            _s
        });
    ::quote::__private::push_question(&mut _s);
    _s
}quote!(writer.write(&#discriminant.to_be_bytes())?)
1279                    };
1280
1281                    Ok({
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&variant_match, &mut _s);
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&extensible_bootstrap, &mut _s);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "written");
            ::quote::__private::push_add_eq_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&discr_block, &mut _s);
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "field_written");
            ::quote::__private::push_add_eq_spanned(&mut _s, _span);
            ::quote::__private::parse_spanned(&mut _s, _span, "0");
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mapping_calls, i) =
                    field_mapping_calls.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mapping_calls =
                        match field_mapping_calls.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::__private::push_add_spanned(&mut _s, _span);
                    ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
                }
            }
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "written");
            ::quote::__private::push_add_eq_spanned(&mut _s, _span);
            ::quote::ToTokens::to_tokens(&extensible_finalize, &mut _s);
            ::quote::__private::push_semi_spanned(&mut _s, _span);
            _s
        });
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1282                        #variant_match => {
1283                            #extensible_bootstrap
1284                            written += #discr_block;
1285                            field_written += 0 #(+ #field_mapping_calls)*;
1286                            written += #extensible_finalize;
1287                        },
1288                    })
1289                }).collect::<darling::Result<Vec<_>>>()?;
1290
1291                let untagged_assert = if attr.untagged.is_present() {
1292                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "thalassa");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "assert_untagged");
    ::quote::__private::push_bang(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&ident, &mut _s);
            _s
        });
    ::quote::__private::push_semi(&mut _s);
    _s
}quote!(thalassa::assert_untagged!(#ident);)
1293                } else {
1294                    ::quote::__private::TokenStream::new()quote!()
1295                };
1296
1297                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "TlsplSerialize");
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            ::quote::__private::push_comma_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "non_upper_case_globals");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_serialize_to");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Write");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_comma_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "writer");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "W");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplWriteResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "usize");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::ToTokens::to_tokens(&discriminants_ts, &mut _s);
                    ::quote::__private::push_pound_spanned(&mut _s, _span);
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Bracket,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "allow");
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Parenthesis,
                                {
                                    let mut _s = ::quote::__private::TokenStream::new();
                                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                                        "unused_imports");
                                    _s
                                });
                            _s
                        });
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "use");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "thalassa");
                    ::quote::__private::push_colon2_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "TlsplSize");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "as");
                    ::quote::__private::push_underscore_spanned(&mut _s, _span);
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "let");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "written");
                    ::quote::__private::push_eq_spanned(&mut _s, _span);
                    ::quote::__private::parse_spanned(&mut _s, _span, "0usize");
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "let");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "field_written");
                    ::quote::__private::push_eq_spanned(&mut _s, _span);
                    ::quote::__private::parse_spanned(&mut _s, _span, "0usize");
                    ::quote::__private::push_semi_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "match");
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "self");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Brace,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            {
                                use ::quote::__private::ext::*;
                                let has_iter = ::quote::__private::HasIterator::<false>;
                                #[allow(unused_mut)]
                                let (mut variant_arms, i) = variant_arms.quote_into_iter();
                                let has_iter = has_iter | i;
                                <_ as
                                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                                while true {
                                    let variant_arms =
                                        match variant_arms.next() {
                                            Some(_x) => ::quote::__private::RepInterp(_x),
                                            None => break,
                                        };
                                    ::quote::ToTokens::to_tokens(&variant_arms, &mut _s);
                                }
                            }
                            _s
                        });
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "written");
                            _s
                        });
                    _s
                });
            _s
        });
    ::quote::ToTokens::to_tokens(&untagged_assert, &mut _s);
    _s
}quote_spanned! { span=>
1298                    #[automatically_derived]
1299                    impl #impl_generics thalassa::TlsplSerialize for #ident #ty_generics #where_c {
1300                        #[inline]
1301                        #[allow(clippy::identity_op, non_upper_case_globals)]
1302                        fn tlspl_serialize_to<W: thalassa::io::Write>(&self, writer: &mut W) -> thalassa::error::TlsplWriteResult<usize> {
1303                            #discriminants_ts
1304
1305                            #[allow(unused_imports)]
1306                            use thalassa::TlsplSize as _;
1307
1308                            let mut written = 0usize;
1309                            let mut field_written = 0usize;
1310                            match self {
1311                                #(#variant_arms)*
1312                            }
1313
1314                            Ok(written)
1315                        }
1316                    }
1317                    #untagged_assert
1318                }
1319            }
1320        })
1321    }
1322
1323    fn impl_deserialize(&self) -> darling::Result<TokenStream2> {
1324        Ok(match self {
1325            TlsplDeriveTarget::StructNamed(sv) => {
1326                let span = sv.span();
1327                let StructNamedTarget {
1328                    ident,
1329                    generics,
1330                    data,
1331                } = sv.as_ref();
1332
1333                let ty_generics_def = augment_generics_ty(generics, ImplTargets::DESERIALIZE);
1334                let impl_generics_def = augment_generics_with_lt(&ty_generics_def);
1335                let (impl_generics, _, _) = impl_generics_def.split_for_impl();
1336                let (_, ty_generics, where_c) = generics.split_for_impl();
1337
1338                let (member_list, member_decls): (Vec<_>, Vec<_>) = data
1339                    .fields
1340                    .iter()
1341                    .map(|f| {
1342                        let ident = f.ident.clone();
1343                        let ty = f.ty.clone();
1344                        let get_value_tokens = if f.attr.skip.is_present() {
1345                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "Default");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "default");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! { f.span()=> Default::default() }
1346                        } else if let Some(with) = &f.attr.with {
1347                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { f.span()=> #with::tlspl_deserialize_from(reader)? }
1348                        } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1349                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "read_byte");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> reader.read_byte()? }
1350                        } else {
1351                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_underscore_spanned(&mut _s, _span);
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { f.span()=> <_>::tlspl_deserialize_from(reader)? }
1352                        };
1353
1354                        let select_fence_store = if let Some(select_target) = &f.attr.select {
1355                            let syn::Type::Path(tp) = &f.ty else {
1356                                { ::core::panicking::panic_fmt(format_args!("Type is not an actual path")); };panic!("Type is not an actual path");
1357                            };
1358                            let ty_ident = tp.path.segments.last().expect("Type cannot be found");
1359                            let fence_ident = discr_fence_name(&ty_ident.ident);
1360                            let mut fence_tp = tp.path.clone();
1361                            let fence_tp_ty = fence_tp.segments.last_mut().unwrap();
1362                            fence_tp_ty.arguments = Default::default();
1363                            fence_tp_ty.ident = fence_ident;
1364
1365                            {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&fence_tp, &mut _s);
    ::quote::__private::push_dot(&mut _s);
    ::quote::__private::push_ident(&mut _s, "replace");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "Some");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::ToTokens::to_tokens(&select_target, &mut _s);
                    ::quote::__private::push_ident(&mut _s, "as");
                    ::quote::__private::push_underscore(&mut _s);
                    _s
                });
            _s
        });
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
1366                                #fence_tp.replace(Some(#select_target as _));
1367                            }
1368                        } else {
1369                            ::quote::__private::TokenStream::new()quote!()
1370                        };
1371
1372                        (
1373                            {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    _s
}quote!(#ident),
1374                            {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "let");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&ty, &mut _s);
    ::quote::__private::push_eq_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&select_fence_store, &mut _s);
            ::quote::ToTokens::to_tokens(&get_value_tokens, &mut _s);
            _s
        });
    ::quote::__private::push_semi_spanned(&mut _s, _span);
    _s
}quote_spanned! { f.span()=>
1375                                let #ident: #ty = {
1376                                    #select_fence_store
1377                                    #get_value_tokens
1378                                };
1379                            },
1380                        )
1381                    })
1382                    .unzip();
1383
1384                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "TlsplDeserialize");
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_lifetime_spanned(&mut _s, _span, "\'tlspl");
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_deserialize_from");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Read");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_lifetime_spanned(&mut _s, _span,
                "\'tlspl");
            ::quote::__private::push_shr_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "reader");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplReadResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Self");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    {
                        use ::quote::__private::ext::*;
                        let has_iter = ::quote::__private::HasIterator::<false>;
                        #[allow(unused_mut)]
                        let (mut member_decls, i) = member_decls.quote_into_iter();
                        let has_iter = has_iter | i;
                        <_ as
                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                        while true {
                            let member_decls =
                                match member_decls.next() {
                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                    None => break,
                                };
                            ::quote::ToTokens::to_tokens(&member_decls, &mut _s);
                        }
                    }
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "Self");
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Brace,
                                {
                                    let mut _s = ::quote::__private::TokenStream::new();
                                    {
                                        use ::quote::__private::ext::*;
                                        let has_iter = ::quote::__private::HasIterator::<false>;
                                        #[allow(unused_mut)]
                                        let (mut member_list, i) = member_list.quote_into_iter();
                                        let has_iter = has_iter | i;
                                        <_ as
                                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                                        while true {
                                            let member_list =
                                                match member_list.next() {
                                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                                    None => break,
                                                };
                                            ::quote::ToTokens::to_tokens(&member_list, &mut _s);
                                            ::quote::__private::push_comma_spanned(&mut _s, _span);
                                        }
                                    }
                                    _s
                                });
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1385                    #[automatically_derived]
1386                    impl #impl_generics thalassa::TlsplDeserialize<'tlspl> for #ident #ty_generics #where_c {
1387                        #[inline]
1388                        fn tlspl_deserialize_from<R: thalassa::io::Read<'tlspl>>(reader: &mut R) -> thalassa::error::TlsplReadResult<Self> {
1389                            #(#member_decls)*
1390                            Ok(Self {
1391                                #(#member_list,)*
1392                            })
1393                        }
1394                    }
1395                }
1396            }
1397            TlsplDeriveTarget::StructTuple(sv) => {
1398                let span = sv.span();
1399                let StructTupleTarget {
1400                    ident,
1401                    generics,
1402                    data,
1403                } = sv.as_ref();
1404
1405                let ty_generics_def = augment_generics_ty(generics, ImplTargets::DESERIALIZE);
1406                let impl_generics_def = augment_generics_with_lt(&ty_generics_def);
1407                let (impl_generics, _, _) = impl_generics_def.split_for_impl();
1408                let (_, ty_generics, where_c) = generics.split_for_impl();
1409
1410                let member_calls = data.fields.iter().map(|f| {
1411                    if f.attr.skip.is_present() {
1412                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "Default");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "default");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! { f.span()=> Default::default() }
1413                    } else if let Some(with) = &f.attr.with {
1414                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { f.span()=> #with::tlspl_deserialize_from(reader)? }
1415                    } else if f.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1416                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "read_byte");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! {f.span()=> reader.read_byte()? }
1417                    } else {
1418                        {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(f.span()).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_underscore_spanned(&mut _s, _span);
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span, "reader");
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { f.span()=> <_>::tlspl_deserialize_from(reader)? }
1419                    }
1420                });
1421
1422                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "TlsplDeserialize");
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_lifetime_spanned(&mut _s, _span, "\'tlspl");
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_deserialize_from");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Read");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_lifetime_spanned(&mut _s, _span,
                "\'tlspl");
            ::quote::__private::push_shr_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "reader");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplReadResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Self");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "Self");
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Parenthesis,
                                {
                                    let mut _s = ::quote::__private::TokenStream::new();
                                    {
                                        use ::quote::__private::ext::*;
                                        let has_iter = ::quote::__private::HasIterator::<false>;
                                        #[allow(unused_mut)]
                                        let (mut member_calls, i) = member_calls.quote_into_iter();
                                        let has_iter = has_iter | i;
                                        <_ as
                                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                                        while true {
                                            let member_calls =
                                                match member_calls.next() {
                                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                                    None => break,
                                                };
                                            ::quote::ToTokens::to_tokens(&member_calls, &mut _s);
                                            ::quote::__private::push_comma_spanned(&mut _s, _span);
                                        }
                                    }
                                    _s
                                });
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1423                    #[automatically_derived]
1424                    impl #impl_generics thalassa::TlsplDeserialize<'tlspl> for #ident #ty_generics #where_c {
1425                        #[inline]
1426                        fn tlspl_deserialize_from<R: thalassa::io::Read<'tlspl>>(reader: &mut R) -> thalassa::error::TlsplReadResult<Self> {
1427                            Ok(Self(#(#member_calls,)*))
1428                        }
1429                    }
1430                }
1431            }
1432            TlsplDeriveTarget::StructUnit(sv) => {
1433                let span = sv.span();
1434                let StructUnitTarget { ident, generics } = sv.as_ref();
1435                let ty_generics_def = augment_generics_ty(generics, ImplTargets::DESERIALIZE);
1436                let impl_generics_def = augment_generics_with_lt(&ty_generics_def);
1437                let (impl_generics, _, _) = impl_generics_def.split_for_impl();
1438                let (_, ty_generics, where_c) = generics.split_for_impl();
1439
1440                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "TlsplDeserialize");
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_lifetime_spanned(&mut _s, _span, "\'tlspl");
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_deserialize_from");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Read");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_lifetime_spanned(&mut _s, _span,
                "\'tlspl");
            ::quote::__private::push_shr_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "reader");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplReadResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Self");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "Self");
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1441                    #[automatically_derived]
1442                    impl #impl_generics thalassa::TlsplDeserialize<'tlspl> for #ident #ty_generics #where_c {
1443                        #[inline]
1444                        fn tlspl_deserialize_from<R: thalassa::io::Read<'tlspl>>(reader: &mut R) -> thalassa::error::TlsplReadResult<Self> {
1445                            Ok(Self)
1446                        }
1447                    }
1448                }
1449            }
1450            TlsplDeriveTarget::Enum(sv) => {
1451                let span = sv.span();
1452                let discriminants_ts = sv.data.discriminant_consts(sv.as_ref())?;
1453                let EnumTarget {
1454                    ident,
1455                    generics,
1456                    data,
1457                    attrs,
1458                    attr,
1459                } = sv.as_ref();
1460
1461                let repr = extract_repr_from_attrs(attrs)?;
1462                let ty_generics_def = augment_generics_ty(generics, ImplTargets::DESERIALIZE);
1463                let impl_generics_def = augment_generics_with_lt(&ty_generics_def);
1464                let (impl_generics, _, _) = impl_generics_def.split_for_impl();
1465                let (_, ty_generics, where_c) = generics.split_for_impl();
1466
1467                let mut catchall_def = None;
1468
1469                let extensible_bootstrap = if attr.extensible.is_present() {
1470                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "let");
    ::quote::__private::push_ident(&mut _s, "mut");
    ::quote::__private::push_ident(&mut _s, "buffer");
    ::quote::__private::push_eq(&mut _s);
    ::quote::__private::push_ident(&mut _s, "std");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "borrow");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "Cow");
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_lt(&mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "u8");
            _s
        });
    ::quote::__private::push_gt(&mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "tlspl_deserialize_from");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "reader");
            _s
        });
    ::quote::__private::push_question(&mut _s);
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
1471                        let mut buffer = std::borrow::Cow::<[u8]>::tlspl_deserialize_from(reader)?;
1472                    }
1473                } else {
1474                    ::quote::__private::TokenStream::new()quote!()
1475                };
1476
1477                let variant_arms = data.variants.iter().filter_map(|variant| {
1478                    if variant.attrs().other.is_present() {
1479                        catchall_def.replace((variant.ident().clone(), variant.field_count()));
1480                        return None;
1481                    }
1482
1483                    let span = variant.span();
1484                    let variant_ident = variant.ident();
1485                    let variant_is_tuple = #[allow(non_exhaustive_omitted_patterns)] match variant {
    Variant::Tuple(_) => true,
    _ => false,
}matches!(variant, Variant::Tuple(_));
1486                    let discriminant = discr_const_ident(variant_ident);
1487
1488                    let read_target = if attr.extensible.is_present() {
1489                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_and(&mut _s);
    ::quote::__private::push_ident(&mut _s, "mut");
    ::quote::__private::push_ident(&mut _s, "buffer");
    _s
}quote!(&mut buffer)
1490                    } else {
1491                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "reader");
    _s
}quote!(reader)
1492                    };
1493
1494                    let (field_mappings, field_mapping_calls): (Vec<_>, Vec<_>) = variant
1495                        .members_with_exprs()
1496                        .map(|member| {
1497                            let method_mapping = if member.attrs.skip.is_present() {
1498                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident_spanned(&mut _s, _span, "Default");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "default");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    _s
}quote_spanned! { member.span=> Default::default() }
1499                            } else if let Some(with) = member.attrs.with {
1500                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&with, &mut _s);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&read_target, &mut _s);
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> #with::tlspl_deserialize_from(#read_target)? }
1501                            }  else if member.ty == ::syn::__private::parse_quote({
        let mut _s = ::quote::__private::TokenStream::new();
        ::quote::__private::push_ident(&mut _s, "u8");
        _s
    })parse_quote!(u8) {
1502                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&read_target, &mut _s);
    ::quote::__private::push_dot_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "read_byte");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        { ::quote::__private::TokenStream::new() });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> #read_target.read_byte()? }
1503                            } else {
1504                                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(member.span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_underscore_spanned(&mut _s, _span);
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "tlspl_deserialize_from");
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::ToTokens::to_tokens(&read_target, &mut _s);
            _s
        });
    ::quote::__private::push_question_spanned(&mut _s, _span);
    _s
}quote_spanned! { member.span=> <_>::tlspl_deserialize_from(#read_target)? }
1505                            };
1506
1507                            (member.ident, method_mapping)
1508                        })
1509                        .unzip();
1510
1511                    let variant_splat = if variant_is_tuple {
1512                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mapping_calls, i) =
                    field_mapping_calls.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mapping_calls =
                        match field_mapping_calls.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
                    ::quote::__private::push_comma(&mut _s);
                }
            }
            _s
        });
    _s
}quote! {
1513                            #ident::#variant_ident(
1514                                #(#field_mapping_calls,)*
1515                            )
1516                        }
1517                    } else {
1518                        {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&variant_ident, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            {
                use ::quote::__private::ext::*;
                let has_iter = ::quote::__private::HasIterator::<false>;
                #[allow(unused_mut)]
                let (mut field_mappings, i) =
                    field_mappings.quote_into_iter();
                let has_iter = has_iter | i;
                #[allow(unused_mut)]
                let (mut field_mapping_calls, i) =
                    field_mapping_calls.quote_into_iter();
                let has_iter = has_iter | i;
                <_ as
                        ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                while true {
                    let field_mappings =
                        match field_mappings.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    let field_mapping_calls =
                        match field_mapping_calls.next() {
                            Some(_x) => ::quote::__private::RepInterp(_x),
                            None => break,
                        };
                    ::quote::ToTokens::to_tokens(&field_mappings, &mut _s);
                    ::quote::__private::push_colon(&mut _s);
                    ::quote::ToTokens::to_tokens(&field_mapping_calls, &mut _s);
                    ::quote::__private::push_comma(&mut _s);
                }
            }
            _s
        });
    _s
}quote! {
1519                            #ident::#variant_ident {
1520                                #(#field_mappings: #field_mapping_calls,)*
1521                            }
1522                        }
1523                    };
1524
1525                    Some({
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::ToTokens::to_tokens(&discriminant, &mut _s);
    ::quote::__private::push_fat_arrow_spanned(&mut _s, _span);
    ::quote::ToTokens::to_tokens(&variant_splat, &mut _s);
    ::quote::__private::push_comma_spanned(&mut _s, _span);
    _s
}quote_spanned! { span=>
1526                        #discriminant => #variant_splat,
1527                    })
1528                }).collect::<Vec<_>>();
1529
1530                let discr_fence_name = discr_fence_name(ident);
1531
1532                let discr_block = if attr.untagged.is_present() {
1533                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "let");
    ::quote::__private::push_ident(&mut _s, "discriminant");
    ::quote::__private::push_colon(&mut _s);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_eq(&mut _s);
    ::quote::ToTokens::to_tokens(&discr_fence_name, &mut _s);
    ::quote::__private::push_dot(&mut _s);
    ::quote::__private::push_ident(&mut _s, "take");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        ::quote::__private::TokenStream::new());
    ::quote::__private::push_dot(&mut _s);
    ::quote::__private::push_ident(&mut _s, "expect");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::parse(&mut _s,
                "\"There should be a value in the discriminant fence\"");
            _s
        });
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
1534                        let discriminant: #repr = #discr_fence_name.take().expect("There should be a value in the discriminant fence");
1535                    }
1536                } else {
1537                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "let");
    ::quote::__private::push_ident(&mut _s, "discriminant");
    ::quote::__private::push_eq(&mut _s);
    ::quote::__private::push_lt(&mut _s);
    ::quote::ToTokens::to_tokens(&repr, &mut _s);
    ::quote::__private::push_gt(&mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::__private::push_ident(&mut _s, "from_be_bytes");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_star(&mut _s);
            ::quote::__private::push_ident(&mut _s, "reader");
            ::quote::__private::push_dot(&mut _s);
            ::quote::__private::push_ident(&mut _s, "read_array");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                ::quote::__private::TokenStream::new());
            ::quote::__private::push_question(&mut _s);
            _s
        });
    ::quote::__private::push_semi(&mut _s);
    _s
}quote! {
1538                        let discriminant = <#repr>::from_be_bytes(*reader.read_array()?);
1539                    }
1540                };
1541
1542                let catchall_block = if let Some((catchall_variant, field_count)) = catchall_def {
1543                    match field_count {
1544                        1 => {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "discr");
    ::quote::__private::push_fat_arrow(&mut _s);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&catchall_variant, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "discr");
            _s
        });
    _s
}quote!(discr => #ident::#catchall_variant(discr)),
1545                        2 => {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_ident(&mut _s, "discr");
    ::quote::__private::push_fat_arrow(&mut _s);
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::__private::push_colon2(&mut _s);
    ::quote::ToTokens::to_tokens(&catchall_variant, &mut _s);
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "discr");
            ::quote::__private::push_comma(&mut _s);
            ::quote::__private::push_ident(&mut _s, "buffer");
            _s
        });
    _s
}quote!(discr => #ident::#catchall_variant(discr, buffer)),
1546                        _ => {
1547                            return Err(darling::Error::custom(
1548                                "Unexpected field count in the catchall enum, need 1 (naked) or 2 (fielded) depending on the enum nature",
1549                            ));
1550                        }
1551                    }
1552                } else {
1553                    {
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_underscore(&mut _s);
    ::quote::__private::push_fat_arrow(&mut _s);
    ::quote::__private::push_ident(&mut _s, "return");
    ::quote::__private::push_ident(&mut _s, "Err");
    ::quote::__private::push_group(&mut _s,
        ::quote::__private::Delimiter::Parenthesis,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident(&mut _s, "thalassa");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "error");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s, "TlsplReadError");
            ::quote::__private::push_colon2(&mut _s);
            ::quote::__private::push_ident(&mut _s,
                "UnknownEnumDiscriminant");
            ::quote::__private::push_group(&mut _s,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident(&mut _s, "discriminant");
                    ::quote::__private::push_dot(&mut _s);
                    ::quote::__private::push_ident(&mut _s, "into");
                    ::quote::__private::push_group(&mut _s,
                        ::quote::__private::Delimiter::Parenthesis,
                        ::quote::__private::TokenStream::new());
                    _s
                });
            _s
        });
    _s
}quote!(_ => return Err(thalassa::error::TlsplReadError::UnknownEnumDiscriminant(discriminant.into())))
1554                };
1555
1556                {
    let _span: ::quote::__private::Span =
        ::quote::__private::get_span(span).__into_span();
    let mut _s = ::quote::__private::TokenStream::new();
    ::quote::__private::push_pound_spanned(&mut _s, _span);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Bracket,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "automatically_derived");
            _s
        });
    ::quote::__private::push_ident_spanned(&mut _s, _span, "impl");
    ::quote::ToTokens::to_tokens(&impl_generics, &mut _s);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "thalassa");
    ::quote::__private::push_colon2_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span,
        "TlsplDeserialize");
    ::quote::__private::push_lt_spanned(&mut _s, _span);
    ::quote::__private::push_lifetime_spanned(&mut _s, _span, "\'tlspl");
    ::quote::__private::push_gt_spanned(&mut _s, _span);
    ::quote::__private::push_ident_spanned(&mut _s, _span, "for");
    ::quote::ToTokens::to_tokens(&ident, &mut _s);
    ::quote::ToTokens::to_tokens(&ty_generics, &mut _s);
    ::quote::ToTokens::to_tokens(&where_c, &mut _s);
    ::quote::__private::push_group_spanned(&mut _s, _span,
        ::quote::__private::Delimiter::Brace,
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "inline");
                    _s
                });
            ::quote::__private::push_pound_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Bracket,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "allow");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "clippy");
                            ::quote::__private::push_colon2_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "identity_op");
                            ::quote::__private::push_comma_spanned(&mut _s, _span);
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "non_upper_case_globals");
                            _s
                        });
                    _s
                });
            ::quote::__private::push_ident_spanned(&mut _s, _span, "fn");
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "tlspl_deserialize_from");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
            ::quote::__private::push_colon_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "io");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Read");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_lifetime_spanned(&mut _s, _span,
                "\'tlspl");
            ::quote::__private::push_shr_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Parenthesis,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "reader");
                    ::quote::__private::push_colon_spanned(&mut _s, _span);
                    ::quote::__private::push_and_spanned(&mut _s, _span);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "mut");
                    ::quote::__private::push_ident_spanned(&mut _s, _span, "R");
                    _s
                });
            ::quote::__private::push_rarrow_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "thalassa");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "error");
            ::quote::__private::push_colon2_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span,
                "TlsplReadResult");
            ::quote::__private::push_lt_spanned(&mut _s, _span);
            ::quote::__private::push_ident_spanned(&mut _s, _span, "Self");
            ::quote::__private::push_gt_spanned(&mut _s, _span);
            ::quote::__private::push_group_spanned(&mut _s, _span,
                ::quote::__private::Delimiter::Brace,
                {
                    let mut _s = ::quote::__private::TokenStream::new();
                    ::quote::ToTokens::to_tokens(&discriminants_ts, &mut _s);
                    ::quote::ToTokens::to_tokens(&discr_block, &mut _s);
                    ::quote::ToTokens::to_tokens(&extensible_bootstrap,
                        &mut _s);
                    ::quote::__private::push_ident_spanned(&mut _s, _span,
                        "Ok");
                    ::quote::__private::push_group_spanned(&mut _s, _span,
                        ::quote::__private::Delimiter::Parenthesis,
                        {
                            let mut _s = ::quote::__private::TokenStream::new();
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "match");
                            ::quote::__private::push_ident_spanned(&mut _s, _span,
                                "discriminant");
                            ::quote::__private::push_group_spanned(&mut _s, _span,
                                ::quote::__private::Delimiter::Brace,
                                {
                                    let mut _s = ::quote::__private::TokenStream::new();
                                    {
                                        use ::quote::__private::ext::*;
                                        let has_iter = ::quote::__private::HasIterator::<false>;
                                        #[allow(unused_mut)]
                                        let (mut variant_arms, i) = variant_arms.quote_into_iter();
                                        let has_iter = has_iter | i;
                                        <_ as
                                                ::quote::__private::CheckHasIterator<true>>::check(has_iter);
                                        while true {
                                            let variant_arms =
                                                match variant_arms.next() {
                                                    Some(_x) => ::quote::__private::RepInterp(_x),
                                                    None => break,
                                                };
                                            ::quote::ToTokens::to_tokens(&variant_arms, &mut _s);
                                        }
                                    }
                                    ::quote::ToTokens::to_tokens(&catchall_block, &mut _s);
                                    _s
                                });
                            _s
                        });
                    _s
                });
            _s
        });
    _s
}quote_spanned! { span=>
1557                    #[automatically_derived]
1558                    impl #impl_generics thalassa::TlsplDeserialize<'tlspl> for #ident #ty_generics #where_c {
1559                        #[inline]
1560                        #[allow(clippy::identity_op, non_upper_case_globals)]
1561                        fn tlspl_deserialize_from<R: thalassa::io::Read<'tlspl>>(reader: &mut R) -> thalassa::error::TlsplReadResult<Self> {
1562                            #discriminants_ts
1563                            #discr_block
1564                            #extensible_bootstrap
1565                            Ok(match discriminant {
1566                                #(#variant_arms)*
1567                                #catchall_block
1568                            })
1569                        }
1570                    }
1571                }
1572            }
1573        })
1574    }
1575
1576    fn impl_all(&self) -> darling::Result<TokenStream2> {
1577        let mut tokens = self.impl_size()?;
1578        tokens.extend(self.impl_serialize()?);
1579        tokens.extend(self.impl_deserialize()?);
1580        Ok(tokens)
1581    }
1582}
1583
1584#[proc_macro_derive(TlsplSize, attributes(tlspl))]
1585pub fn derive_size(input: TokenStream) -> TokenStream {
1586    use darling::FromDeriveInput as _;
1587    match TlsplDeriveTarget::from_derive_input(&match ::syn::parse::<DeriveInput>(input) {
    ::syn::__private::Ok(data) => data,
    ::syn::__private::Err(err) => {
        return ::syn::__private::TokenStream::from(err.to_compile_error());
    }
}parse_macro_input!(input as DeriveInput)) {
1588        Ok(target) => match target.impl_size() {
1589            Ok(tokens) => tokens.into(),
1590            Err(e) => e.write_errors().into(),
1591        },
1592        Err(e) => e.write_errors().into(),
1593    }
1594}
1595
1596#[proc_macro_derive(TlsplSerialize, attributes(tlspl))]
1597pub fn derive_serialize(input: TokenStream) -> TokenStream {
1598    use darling::FromDeriveInput as _;
1599    match TlsplDeriveTarget::from_derive_input(&match ::syn::parse::<DeriveInput>(input) {
    ::syn::__private::Ok(data) => data,
    ::syn::__private::Err(err) => {
        return ::syn::__private::TokenStream::from(err.to_compile_error());
    }
}parse_macro_input!(input as DeriveInput)) {
1600        Ok(target) => match target.impl_serialize() {
1601            Ok(tokens) => tokens.into(),
1602            Err(e) => e.write_errors().into(),
1603        },
1604        Err(e) => e.write_errors().into(),
1605    }
1606}
1607
1608#[proc_macro_derive(TlsplDeserialize, attributes(tlspl))]
1609pub fn derive_deserialize(input: TokenStream) -> TokenStream {
1610    use darling::FromDeriveInput as _;
1611    match TlsplDeriveTarget::from_derive_input(&match ::syn::parse::<DeriveInput>(input) {
    ::syn::__private::Ok(data) => data,
    ::syn::__private::Err(err) => {
        return ::syn::__private::TokenStream::from(err.to_compile_error());
    }
}parse_macro_input!(input as DeriveInput)) {
1612        Ok(target) => match target.impl_deserialize() {
1613            Ok(tokens) => tokens.into(),
1614            Err(e) => e.write_errors().into(),
1615        },
1616        Err(e) => e.write_errors().into(),
1617    }
1618}
1619
1620#[proc_macro_derive(TlsplAll, attributes(tlspl))]
1621pub fn derive_all(input: TokenStream) -> TokenStream {
1622    use darling::FromDeriveInput as _;
1623    match TlsplDeriveTarget::from_derive_input(&match ::syn::parse::<DeriveInput>(input) {
    ::syn::__private::Ok(data) => data,
    ::syn::__private::Err(err) => {
        return ::syn::__private::TokenStream::from(err.to_compile_error());
    }
}parse_macro_input!(input as DeriveInput)) {
1624        Ok(target) => match target.impl_all() {
1625            Ok(tokens) => tokens.into(),
1626            Err(e) => e.write_errors().into(),
1627        },
1628        Err(e) => e.write_errors().into(),
1629    }
1630}