gateway_common/config/
yaml.rs

1use crate::error::BoxError;
2use serde_yaml::Value;
3
4pub fn get_yaml_by_context<'a, T: serde::Deserialize<'a>>(
5    yaml_context: &str,
6) -> Result<T, BoxError> {
7    // 解析 TOML 文件内容
8    let parsed_toml: Value = serde_yaml::from_str(yaml_context)?;
9    Ok(T::deserialize(parsed_toml).map_err(|e| format!("json to json error {:?}", e))?)
10}