pub fn validate_segment(seg: &str) -> Result<(), ConceptIdError>Expand description
Validates a single path segment, rejecting only what cannot be a concept id.
The reference bundle/paths.py restricts segments to
[A-Za-z0-9_][A-Za-z0-9_.\-]*, but that rule is an artifact of the reference
implementation rather than a requirement: the specification states no
character constraint on filenames, and conformance is a question of
frontmatter. ConceptId::from_path accordingly accepts non-portable
UTF-8 names, so applying the ASCII rule here only meant that ids the loader
had just produced could not be parsed back, and that links to those
concepts vanished from the graph without even being reported as broken.
What stays rejected is the set that cannot round-trip through the
/-joined string form or through ConceptId::to_path: an empty segment,
the traversal names . and .., the path separators / and \, and
control characters. Spaces, emoji, and other Unicode are accepted.
The ASCII convention is still worth following, so validate_bundle reports
segments outside it as a warning instead of refusing to parse them.
ยงErrors
Returns ConceptIdError for the small set of segments that cannot
round-trip through the /-joined string form or ConceptId::to_path:
empty, . and .., path separators, and control characters.