pub fn interpolate_with(
template: &str,
lookup: impl FnMut(&str) -> Option<Value>,
) -> StringExpand description
Replace each {expr} in template with the value lookup gives for
expr (trimmed): a string verbatim, any other JSON value as its JSON
text. An unknown expr becomes the empty string; an unclosed { is kept
as written.
The scanner is shared; what expr means is the caller’s. Orchestration
looks it up as a state key, the spec layer reads args. and state.
prefixes.
use gemini_adk_rs::utils::text::interpolate_with;
use serde_json::json;
let out = interpolate_with("hi {name}, n={n}, {gone}!", |key| match key {
"name" => Some(json!("Ada")),
"n" => Some(json!(3)),
_ => None,
});
assert_eq!(out, "hi Ada, n=3, !");