Skip to main content

Crate no_std_path

Crate no_std_path 

Source
Expand description

Cross-platform path manipulation.

This module provides two types, PathBuf and Path (akin to String and str), for working with paths abstractly. These types are thin wrappers around OsString and OsStr respectively, meaning that they work directly on strings according to the local platform’s path syntax.

Paths can be parsed into Components by iterating over the structure returned by the components method on Path. Components roughly correspond to the substrings between path separators (/ or \). You can reconstruct an equivalent path from components with the push method on PathBuf; note that the paths may differ syntactically by the normalization described in the documentation for the components method.

§Feature std

When the std feature is enabled, all types are re-exported directly from std::path and std::ffi, giving full platform support and filesystem methods. When std is disabled (the default), lightweight no_std implementations are provided instead.

Modules§

ffi
Re-exports of std::ffi::OsStr and std::ffi::OsString.

Structs§

Ancestors
An iterator over Path and its ancestors.
Components
An iterator over the Components of a Path.
Display
Helper struct for safely printing paths with format! and {}.
Iter
An iterator over the Components of a Path, as OsStr slices.
OsStr
Borrowed reference to an OS string (see OsString).
OsString
A type that can represent owned, mutable platform-native strings, but is cheaply inter-convertible with Rust strings.
Path
A slice of a path (akin to str).
PathBuf
An owned, mutable path (akin to String).
PrefixComponent
A structure wrapping a Windows path prefix as well as its unparsed string representation.
StripPrefixError
An error returned from Path::strip_prefix if the prefix was not found.

Enums§

Component
A single component of a path.
Prefix
Windows path prefixes, e.g., C: or \\server\share.

Constants§

MAIN_SEPARATOR
The primary separator of path components for the current platform, represented as a char; for example, this is '/' on Unix and '\\' on Windows.
MAIN_SEPARATOR_STR
The primary separator of path components for the current platform, represented as a &str; for example, this is "/" on Unix and "\\" on Windows.
NO_STD_IMPL
true when using the custom no_std implementation, false when re-exporting from std::path.

Functions§

is_separator
Determines whether the character is one of the permitted path separators for the current platform.