Skip to main content

generate_unique_node_name_from_names

Function generate_unique_node_name_from_names 

Source
pub fn generate_unique_node_name_from_names(
    node_name: impl Into<String>,
    names: &mut HashSet<String>,
) -> String
Expand description

Returns node_name, made a valid node name by sanitize_node_name, if it is not already in names.

Otherwise, appends an incrementing -{counter} suffix until a unique name is found, then returns it. Logs a warning when the name had to be adjusted, and when a duplicate is detected.

Sanitizing comes first, so names that only differ in what is adjusted (Alice and alice) are still told apart: the second one is alice-1.