From 487567a3b6e7f0c502715a7b13d2ff974b615acd Mon Sep 17 00:00:00 2001 From: Grant Sparks Date: Wed, 3 Jul 2024 06:52:40 +0000 Subject: [PATCH] Removed expand_tokens from public api --- Cargo.toml | 2 +- readme.md | 1 - src/lib.rs | 2 +- src/token_expander.rs | 17 ----------------- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 47fcf63..1051bcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "grafton-config" -version = "0.1.3" +version = "0.2.0" edition = "2021" authors = ["Grant Sparks "] description = "Load configuration from toml files with token variable expansion and environment overrides" diff --git a/readme.md b/readme.md index 2ac3a0a..b67798a 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,6 @@ database_url = "postgresql://user:password@${server.host}:${server.port}/mydb" ## API Reference - `load_config_from_dir(path: &str) -> Result`: Load and parse configuration from a directory -- `expand_tokens(config: &mut T) -> Result<(), Error>`: Expand tokens in a configuration struct - `GraftonConfig`: Trait for Grafton configuration structs - `TokenExpandingConfig`: Trait for configuration structs that support token expansion diff --git a/src/lib.rs b/src/lib.rs index e879bde..cf5db75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub use error::Error; use serde::{de::DeserializeOwned, Serialize}; pub use { - config::GraftonConfig, config_loader::load_config_from_dir, token_expander::expand_tokens, + config::GraftonConfig, config_loader::load_config_from_dir, }; pub trait GraftonConfigProvider: TokenExpandingConfig { diff --git a/src/token_expander.rs b/src/token_expander.rs index 131a84a..cd5ac91 100644 --- a/src/token_expander.rs +++ b/src/token_expander.rs @@ -15,23 +15,6 @@ static TOKEN_REGEX: Lazy = Lazy::new(|| Regex::new(r"(\\*)\$\{(.*?)\}").u /// /// It may also return other errors that are specific to token expansion failures. /// -/// # Examples -/// -/// ``` -/// use serde_json::json; -/// use crate::grafton_config::expand_tokens; -/// -/// let input = json!({ -/// "firstName": "John", -/// "lastName": "Doe", -/// "fullName": "${firstName} ${lastName}", -/// "greeting": "Hello, ${fullName}!" -/// }); -/// -/// let expanded = expand_tokens(&input).unwrap(); -/// assert_eq!(expanded["fullName"], "John Doe"); -/// assert_eq!(expanded["greeting"], "Hello, John Doe!"); -/// ``` pub fn expand_tokens(val: &Value) -> Result { expand_tokens_helper(val, val, 0, "") }