//! Code generation for struct errors
//!
//! Struct errors are simpler than enum errors since there's only one "variant".

mod apollo;
mod display;
mod error;
mod from;
mod helpers;
mod registry;

use proc_macro2::TokenStream;
use quote::quote;

use crate::ir::StructDefinition;

use apollo::generate_apollo_impl;
use display::generate_display_impl;
use error::generate_error_impl;
use from::generate_from_impl;
use registry::generate_registry_entry;

/// Generate all trait implementations for a struct error
pub(crate) fn generate_struct_impl(ir: &StructDefinition) -> TokenStream {
    let display_impl = generate_display_impl(ir);
    let error_impl = generate_error_impl(ir);
    let apollo_impl = generate_apollo_impl(ir);
    let from_impl = generate_from_impl(ir);
    let registry_entry = generate_registry_entry(ir);

    quote! {
        #display_impl
        #error_impl
        #apollo_impl
        #from_impl
        #registry_entry
    }
}
