apollo-configuration-macros 0.1.1

Supporting macros for apollo-configuration (internal, do not use directly)
Documentation
use crate::ir::FieldDefinition;

/// The fields of an enum variant, either parsed (for struct variants) or raw (for tuple/unit).
pub(crate) enum VariantFields {
    /// Unit variant (no fields).
    Unit,
    /// Tuple variant - fields are passed through without parsing.
    Tuple(syn::FieldsUnnamed),
    /// Struct variant - fields are parsed for #[config] attributes.
    Struct(Vec<FieldDefinition>),
}

/// A variant within a configuration enum.
pub(crate) struct VariantDefinition {
    pub(crate) name: syn::Ident,

    /// Non-apollo-configuration variant attributes to pass through to the output.
    pub(crate) attrs: Vec<syn::Attribute>,

    /// `#[cfg(...)]` attributes that should be applied to generated code for this variant.
    pub(crate) cfg_attrs: Vec<syn::Attribute>,

    pub(crate) fields: VariantFields,

    /// Whether this variant is marked as the default.
    pub(crate) is_default: bool,
}

pub(crate) struct ConfigEnumDefinition {
    pub(crate) enum_token: syn::Token![enum],

    pub(crate) name: syn::Ident,

    pub(crate) vis: syn::Visibility,

    pub(crate) generics: syn::Generics,

    /// Non-serde/schemars enum attributes to pass through BEFORE the derives.
    pub(crate) attrs: Vec<syn::Attribute>,

    /// Serde/schemars helper attributes to pass through AFTER the derives.
    pub(crate) derive_helper_attrs: Vec<syn::Attribute>,

    pub(crate) variants: Vec<VariantDefinition>,

    /// Path to a custom validation function for the whole enum.
    pub(crate) validator: Option<syn::Path>,
}