#file-path #algorithm #fundamental #general-purpose #collection #structures

no-std dev proper_path_tools

Collection of algorithms and structures to handle paths properly

14 breaking releases

0.15.0 Oct 30, 2024
0.13.0 Oct 30, 2024
0.8.0 Jun 29, 2024
0.4.0 Mar 26, 2024

#509 in Filesystem

Download history 811/week @ 2024-08-19 2129/week @ 2024-08-26 1478/week @ 2024-09-02 1490/week @ 2024-09-09 272/week @ 2024-09-16 182/week @ 2024-09-23 259/week @ 2024-09-30 220/week @ 2024-10-07 337/week @ 2024-10-14 144/week @ 2024-10-21 690/week @ 2024-10-28 137/week @ 2024-11-04 35/week @ 2024-11-11 77/week @ 2024-11-18 68/week @ 2024-11-25 149/week @ 2024-12-02

336 downloads per month
Used in 30 crates (2 directly)

MIT license

99KB
2K SLoC

Module :: proper_path_tools

experimental rust-status docs.rs discord

Collection of algorithms and structures to handle paths properly.

All functions in the crate don't touch file system, but only process paths.

Type AbsolutePath

The AbsolutePath type ensures that paths are absolute, which helps reduce issues and maintenance costs associated with relative paths. Relative paths can be problematic as they introduce additional variables and complexities, making code analysis, integration, refactoring, and testing more difficult. By using absolute paths, software architecture can be improved, similar to how avoiding global variables can enhance code quality. It is recommended to use relative paths only at the outskirts of an application.

Trait AsPath

This trait is used to avoid redundant allocation of memory by providing a reference to a Path. It is implemented only for types that can either be referenced or are references to Path itself. Unlike TryIntoPath, it does not allocate memory on the heap. However, TryIntoPath is implemented for a wider range of types because it is not restricted from allocating memory. Unlike AsRef< Path >, AsPath is implemented for a wider number of types, including those that are not directly convertible to a Path using AsRef. This is because AsPath is designed to provide a more flexible interface for path-like types, accommodating various representations that can logically be treated as paths.

Trait TryIntoPath

This trait is used to convert any path-like type into an owned PathBuf. Unlike TryIntoCowPath, it always returns an owned PathBuf, so there is no need to differentiate between borrowed and owned paths at runtime. Unlike AsPath, it is implemented for a wider range of path-like types, similar to TryIntoCowPath.

Trait TryIntoCowPath

This trait is designed to avoid redundant memory allocation. Unlike TryIntoPath, it does not allocate memory on the heap if it’s not necessary. Unlike AsPath, it is implemented for a wider number of path-like types, similar to TryIntoPath. The drawback is the necessity to differentiate borrowed and owned paths at runtime.

Dependencies

~4–5.5MB
~101K SLoC