pub type PathElementCI<'a> = PathElementGeneric<'a, CaseInsensitive>;Expand description
A validated, normalized, case-insensitive single path element.
Takes a raw path element name, validates it (rejecting empty strings, ., ..,
strings containing / or \0, and unassigned Unicode characters), normalizes it case-insensitively, and computes
an OS-compatible presentation form.
Equality, ordering, and hashing are based on the normalized (case-folded) form.
"Hello.txt" and "hello.txt" are equal.
Implements Hash.
Aliased Type§
pub struct PathElementCI<'a> { /* private fields */ }Implementations§
Source§impl<'a> PathElementCI<'a>
impl<'a> PathElementCI<'a>
Sourcepub fn from_bytes(original: impl Into<Cow<'a, [u8]>>) -> Result<Self>
pub fn from_bytes(original: impl Into<Cow<'a, [u8]>>) -> Result<Self>
Creates a new case-insensitive path element from a byte slice.
Invalid UTF-8 is accepted; see Normalization pipeline step 0.
§Errors
Returns Error if the name is invalid (empty, ., ..,
or contains /).
let pe = PathElementCI::from_bytes(b"Hello.TXT")?;
assert_eq!(pe.normalized(), "hello.txt");Sourcepub fn from_os_str(original: impl Into<Cow<'a, OsStr>>) -> Result<Self>
Available on crate feature std only.
pub fn from_os_str(original: impl Into<Cow<'a, OsStr>>) -> Result<Self>
std only.Creates a new case-insensitive path element from an OS string.
Invalid UTF-8 is accepted; see Normalization pipeline step 0.
§Errors
Returns Error if the name is invalid (empty, ., ..,
or contains /).
Trait Implementations§
Source§impl Hash for PathElementCI<'_>
Hashes by normalized(), consistent with PartialEq. Only
implemented for typed variants, not PathElement.
impl Hash for PathElementCI<'_>
Hashes by normalized(), consistent with PartialEq. Only
implemented for typed variants, not PathElement.
Source§impl<'a> TryFrom<PathElementGeneric<'a, CaseSensitivity>> for PathElementCI<'a>
Attempts to convert a runtime-dynamic PathElement into a PathElementCI.
impl<'a> TryFrom<PathElementGeneric<'a, CaseSensitivity>> for PathElementCI<'a>
Attempts to convert a runtime-dynamic PathElement into a PathElementCI.
Succeeds if the element is case-insensitive. On failure, returns the element
re-wrapped as a PathElementCS in the Err variant (no data is lost).