Skip to main content

segment

Function segment 

Source
pub fn segment(s: &str) -> String
Expand description

Encode one key component as a single safe path/key segment.

This is a reversible percent-style encoding: the unreserved set [A-Za-z0-9_-] survives verbatim, and every other byte is escaped as %XX (uppercase hex of the UTF-8 byte). Because . and / are escaped, .. and path separators cannot escape a component; because the mapping is injective (decode_segment is its exact inverse), two distinct keys can never collide onto one path/object key — closing the silent cross-key overwrite and OCC-bypass that the old lossy _-collapse allowed.

Well-formed keys (only [A-Za-z0-9_-]) encode to themselves, so existing stores need no migration.