pub enum RedoxPath<'a> {
Standard(RedoxReference<'a>),
Legacy(RedoxScheme<'a>, RedoxReference<'a>),
}Expand description
A fully qualified Redox path
Variants§
Standard(RedoxReference<'a>)
Standard UNIX compatible format
Legacy(RedoxScheme<'a>, RedoxReference<'a>)
Legacy URI format
Implementations§
Source§impl<'a> RedoxPath<'a>
impl<'a> RedoxPath<'a>
Sourcepub fn from_absolute<S: Into<Cow<'a, str>>>(path: S) -> Option<Self>
pub fn from_absolute<S: Into<Cow<'a, str>>>(path: S) -> Option<Self>
Create RedoxPath from absolute path
Returns Some on success and None if the path contains NUL
Sourcepub fn from_absolute_c<S: Into<&'a CStr>>(path: S) -> Option<Self>
pub fn from_absolute_c<S: Into<&'a CStr>>(path: S) -> Option<Self>
Create a new RedoxPath from C string, ensuring it is a valid UTF-8
Sourcepub fn from_absolute_buf(path: &'a [u8], len: usize) -> Option<Self>
pub fn from_absolute_buf(path: &'a [u8], len: usize) -> Option<Self>
Create a new RedoxPath from a buffer, ensuring it is a valid UTF-8 and valid from NUL
Sourcepub fn from_reference(path: RedoxReference<'a>) -> Option<Self>
pub fn from_reference(path: RedoxReference<'a>) -> Option<Self>
Create a new RedoxPath from RedoxReference if the reference is absolute
Sourcepub fn join<'b, S: Into<Cow<'b, str>>>(&self, path: S) -> Option<RedoxPath<'b>>
pub fn join<'b, S: Into<Cow<'b, str>>>(&self, path: S) -> Option<RedoxPath<'b>>
Join a RedoxPath with a &str path. Relative paths will be appended to self,
absolute paths will be returned as a RedoxPath, ignoring self.
Returns Some on success and None if the path is not valid
Sourcepub fn join_checked<'b>(&self, path: RedoxReference<'b>) -> RedoxPath<'b>
pub fn join_checked<'b>(&self, path: RedoxReference<'b>) -> RedoxPath<'b>
Join, but checked from NUL
Sourcepub fn canonical(self) -> Self
pub fn canonical(self) -> Self
Canonicalize path, see RedoxReference::canonical
Sourcepub fn is_canon(&self) -> bool
pub fn is_canon(&self) -> bool
Verify that the path is canonicalized.
Returns false if any segment is “.”, “..” or “”. A path that is empty is allowed and is interpreted as “/”. Legacy paths are assumed to be canonical.
Sourcepub fn as_parts(&'a self) -> Option<(RedoxScheme<'a>, RedoxReference<'a>)>
pub fn as_parts(&'a self) -> Option<(RedoxScheme<'a>, RedoxReference<'a>)>
Convert into a RedoxScheme and RedoxReference.
- Standard paths will parse
/scheme/scheme_name/reference, and anything not starting with/schemewill be parsed as being part of thefilescheme - Legacy paths can be instantly converted
Sourcepub fn get_scheme(&'a self) -> Option<RedoxScheme<'a>>
pub fn get_scheme(&'a self) -> Option<RedoxScheme<'a>>
Get a RedoxScheme if the reference contained /scheme/scheme_name.
Does not fallback to default scheme if absent.
Sourcepub fn matches_scheme(&self, other: &str) -> bool
pub fn matches_scheme(&self, other: &str) -> bool
Is the scheme for this path the same as the given string?
Sourcepub fn is_scheme_category(&self, category: &str) -> bool
pub fn is_scheme_category(&self, category: &str) -> bool
Does the scheme match the given category, e.g. “disk-”
Sourcepub fn is_default_scheme(&self) -> bool
pub fn is_default_scheme(&self) -> bool
Is this the default scheme, “/scheme/file”?
Sourcepub fn to_standard(self) -> RedoxReference<'a>
pub fn to_standard(self) -> RedoxReference<'a>
Format a RedoxPath into a UNIX style path
Sourcepub fn to_standard_canon(self) -> RedoxPath<'a>
pub fn to_standard_canon(self) -> RedoxPath<'a>
Format a RedoxPath into a UNIX style path,
ensuring it is canonicalized
Sourcepub fn dirname_split(&'a self) -> (RedoxPath<'a>, Option<RedoxReference<'a>>)
pub fn dirname_split(&'a self) -> (RedoxPath<'a>, Option<RedoxReference<'a>>)
Get path upward one time and the file name
Sourcepub fn to_reference(self) -> RedoxReference<'a>
pub fn to_reference(self) -> RedoxReference<'a>
Convert into RedoxReference, if it an old scheme, the scheme part will be discarded.
Sourcepub fn as_reference(&self) -> &RedoxReference<'a>
pub fn as_reference(&self) -> &RedoxReference<'a>
Get RedoxReference, if it an old scheme, the scheme part will be discarded.
Sourcepub fn canonicalize_as_cwd<'b>(&self, path: RedoxStr<'b>) -> RedoxPath<'b>
pub fn canonicalize_as_cwd<'b>(&self, path: RedoxStr<'b>) -> RedoxPath<'b>
Similar to canonicalize_using_cwd
Sourcepub fn canonicalize_as_cwd_standard<'b>(
&self,
path: RedoxStr<'b>,
) -> RedoxPath<'b>
pub fn canonicalize_as_cwd_standard<'b>( &self, path: RedoxStr<'b>, ) -> RedoxPath<'b>
Similar to canonicalize_to_standard
Sourcepub fn canonicalize_as_cwd_with_max_upward<'b>(
&self,
relpath: RedoxReference<'b>,
max_upward: usize,
) -> Option<(RedoxPath<'b>, usize)>
pub fn canonicalize_as_cwd_with_max_upward<'b>( &self, relpath: RedoxReference<'b>, max_upward: usize, ) -> Option<(RedoxPath<'b>, usize)>
Similar to canonicalize_using_cwd_with_max_upward
Sourcepub fn into_owned<'b>(self) -> RedoxPath<'b>
pub fn into_owned<'b>(self) -> RedoxPath<'b>
Copy the content into owned