use hocon_rs::Value;

use crate::lc_action::LcAction;
use crate::lc_action_config::LcActionConfig;
use crate::lc_entity_type::LcEntityType;
use crate::parser::lc_config_list_parser::parse_lc_config_list;

/// Parses a HOCON array into a typed [`LcActionConfig<T>`] using `parse_effect`
/// for each effect body. Thin wrapper over [`parse_lc_config_list`].
pub fn parse_lc_action_config<T, F>(
    value: &Value,
    parse_effect: &F,
) -> Result<LcActionConfig<T>, String>
where
    T: LcEntityType,
    F: Fn(&Value) -> Result<Box<dyn LcAction<T>>, String>,
{
    let configs = parse_lc_config_list(value, parse_effect)?;
    Ok(configs.into())
}
