pub fn validate_path_segment(segment: &str, what: &str) -> Result<String>
Validates that a string is safe to use as a single path segment (e.g. an id or file stem).
Returns the trimmed segment on success.