Make it possible to use Path and friends on wasip2 without the so named feature - #1525
Conversation
|
I would agree that my thoughts there are being interpreted correctly. I can't comment much as to this PR specifically, however, as I am not familiar with this part of rustix (so would leave that part of review to someone else) |
Unfortunately, `OsStrExt` and `OsStringExt` require the wasip2 feature on wasip2 so we can't use `as_bytes()` on `OsStr` and friends. However, the recommendation on the upstream issue [1] is to just use `to_str` as WASI paths are unicode. [1]: rust-lang/rust#130323 (comment)
f88b181 to
5d66a62
Compare
|
For WASI for all time, the question of whether there will ever be a WASI API that we'd want to be reachable through Rust's But I think we can answer this question with sufficient confidence for WASIp2, specifically. WASIp2 filesystem paths are always USV strings. So for WASIp2, I think it's fine for Rustix to do the |
|
In that case, I think this PR is ready for a review. |
|
Thanks! |
|
This is now released in rustix 1.1.3. |
(draft because this is a bit of a hack and needs some discussion first)
At the moment, it's not possible to use
&Path,&OsStr, etc. with rustix on WASIp2 without the nightly compiler (requires thewasip2feature) asOsStrExtandOsStringExtrequire thewasip2feature on WASIp2 so we can't useas_bytes()onOsStrand friends.However, the recommendation on the upstream issue is to just use
to_stras WASI paths are Unicode. This PR does exactly that.@alexcrichton am I interpreting your comment correctly?
Alternatives:
OsStr::as_encoded_byteson wasi instead ofOsStrExt::as_bytes. It will technically work but it also technically relies on an unstable representation (one that will likely never change on WASI, but still...).This PR has two parts:
OsStringandOsStr, converting to utf8 strings where necessary.