apollo-errors-derive 0.4.0

Proc macro for deriving apollo-errors::Error trait
Documentation
//! Field definitions

use syn::{Ident, Type};

/// A field within an error variant
#[derive(Debug, Clone)]
pub(crate) struct FieldDefinition {
    /// The Rust identifier for this field
    pub(crate) rust_name: Ident,

    /// The output name for serialization (same as rust_name)
    pub(crate) output_name: String,

    /// The type of this field (used for metadata generation)
    pub(crate) ty: Type,

    /// Whether this field has `#[extension]`
    pub(crate) is_extension: bool,

    /// Whether this field has `#[source]` (implements std::error::Error::source())
    pub(crate) is_source: bool,

    /// Whether this field has `#[from]` (generates From<T> impl, implies #[source])
    pub(crate) is_from: bool,

    /// Whether this field is `Option<T>` (affects serialization - None values are omitted)
    pub(crate) is_option: bool,

    /// HTTP header name if this field should be returned as a header
    /// From `#[http_header("Header-Name")]`
    pub(crate) http_header: Option<String>,
}

/// A field within a transparent error variant
#[derive(Debug, Clone)]
pub(crate) struct TransparentFieldDefinition {
    /// The type of this field
    pub(crate) ty: Type,

    /// Whether this field has `#[from]` (generates From<T> impl)
    pub(crate) is_from: bool,
}