chipsenkbeil / chipsenkbeil/typed-path

Interopting with `std::path::Path`

Open
#28 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
69
Forks
15
Avg merge
10h 58m
Merged PRs (30d)
2

Description

Hey there, excellent library. I'm wondering if there is a recommended way to convert back and forth between the `std::path::Path` and `std::path::PathBuf` types.

It's nice to store types as `Utf8NativePath`, because that has an `AsRef`. That type can easily be passed into other libraries that expect the std path types.

However, it seems quite cumbersome to create that from an std path:

```
let native_path = Utf8NativePath::from_bytes_path(NativePath::new(
std_path.as_os_str().as_encoded_bytes(),
))
.expect("Path did not contain valid UTF-8 characters");
```

It seems to me that `NativePath` should have a `From`, since `from_bytes_path` is is infallable, and `Utf8NativePath` should have a fallable `TryFrom` with `Utf8Error`.

The library does an amazing job documenting and interopting with itself, but much of the Rust ecosystem uses std path, so I find this library hard to work with practically. Perhaps I missed something obvious?

Thanks for your time!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the definitions of NativePath and Utf8NativePath, then read from_bytes_path and the existing Path and PathBuf conversion APIs. Implement and verify the requested std::path conversions, including Utf8Error for invalid UTF-8, and confirm the existing test suite still passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.