//! Hello World Component Examples
//!
//! This module demonstrates basic component implementations using both struct and enum types.
//!
//! ## License
//!
//! Copyright (c) Microsoft Corporation.
//!
//! SPDX-License-Identifier: Apache-2.0
//!
use patina::{
    component::{component, params::Config},
    error::Result,
};

/// A simple struct component example.
pub struct HelloStruct(pub &'static str);

#[component]
impl HelloStruct {
    fn entry_point(self, age: Config<i32>) -> Result<()> {
        log::info!("Hello, {}! You are age {}!", self.0, *age);
        Ok(())
    }
}

/// A simple enum component implementation example.
pub enum GreetingsEnum {
    /// Represents a greeting message.
    Hello(&'static str),
    /// Represents a farewell message.
    Goodbye(&'static str),
}

#[component]
impl GreetingsEnum {
    fn entry_point(self) -> Result<()> {
        match self {
            GreetingsEnum::Hello(name) => log::info!("Hello, {name}!"),
            GreetingsEnum::Goodbye(name) => log::info!("Goodbye, {name}!"),
        }
        Ok(())
    }
}
