fix: support wasm32-wasip2
on the stable channel
#983
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, me again 👋🏻 😅
As of today, Rust 1.82.0, the
wasm32-wasip2
target is now in the stable channel. My previous PR #960 only accounted for the nightly channel, since thefeature(...)
directive is enabled there. Unfortunately it meant that my changes didn't allow for using this crate in a project on the stable channel.After looking at the feedback in the last PR, and the comments following in rust-lang/rust#130323, I thought it might be useful to try and fix this. So in this PR I:
wasm32-wasip2
unstable feature gatestd::os::wasi::prelude::OsStrExt
with ato_string_lossy
conversion, bearing in mind that as per wasip2 target should not conditionally feature gate stdlib APIs rust-lang/rust#130323 this is practically infallible since WASI paths are valid UTF-8std::os::wasi::prelude::OsStrExt
with aString::from_utf8(bytes).map(|path| PathBuf::from(path))
conversion, bearing in mind that as per wasip2 target should not conditionally feature gate stdlib APIs rust-lang/rust#130323 this is practically infallible since WASI paths are valid UTF-8. In the case that this would fail, I return an error instead to follow the convention of that function.I tried to fit existing code patterns as best I could, but I'm open to changing any of the code or even dropping back to an issue to discuss. There are some really interesting projects like reqwest & waki that are starting to get some wasm32-wasip2 support, which is why I'm making these PRs 🙂