Skip to content

Commit

Permalink
Removed expand_tokens from public api
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantSparks committed Jul 3, 2024
1 parent 8983b73 commit 487567a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "grafton-config"
version = "0.1.3"
version = "0.2.0"
edition = "2021"
authors = ["Grant Sparks <[email protected]>"]
description = "Load configuration from toml files with token variable expansion and environment overrides"
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ database_url = "postgresql://user:password@${server.host}:${server.port}/mydb"
## API Reference

- `load_config_from_dir(path: &str) -> Result<T, Error>`: 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

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions src/token_expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ static TOKEN_REGEX: Lazy<Regex> = 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<Value, Error> {
expand_tokens_helper(val, val, 0, "")
}
Expand Down

0 comments on commit 487567a

Please sign in to comment.