Skip to main content

route_hashmap_path

Function route_hashmap_path 

Source
pub fn route_hashmap_path<'a, 'k, I>(
    name: &'a str,
    my_prefix: &str,
    field_name: &str,
    inner_prefix: &str,
    keys: I,
) -> Option<(&'a str, String)>
where I: IntoIterator<Item = &'k str>,
Expand description

For a #[nested] HashMap<String, T> field, parse a get_prop/set_prop path of the form <my_prefix>.<field_name>.<hm_key>.<inner_suffix> and return the HashMap key + the fully-qualified inner name that the value type’s own get_prop / set_prop expects.

HashMap keys are user-controlled and may contain dots, URLs, or hostnames (for example model_providers.custom:https://example.invalid/v1.api-key). Inner values may themselves be deeply nested (AliasedAgentConfig has agent.thinking.<...> subpaths), so neither left-splitting nor right-splitting works in isolation. Match against the actual present keys and pick the longest prefix that is followed by . — this correctly handles dotted keys and deep inner paths in one parse.

keys is an iterator over the live HashMap’s keys (typically self.<field>.keys().map(String::as_str) from the derive). Returns None when the path doesn’t match, letting the derive’s generated code fall through to the next nested field.