Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support wasm32-wasip2 on the stable channel #983

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brooksmtownsend
Copy link
Contributor

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 the feature(...) 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:

  1. Removed the wasm32-wasip2 unstable feature gate
  2. Replaced the use of std::os::wasi::prelude::OsStrExt with a to_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-8
  3. Replaced the use of std::os::wasi::prelude::OsStrExt with a String::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 🙂

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@ebd5cfb). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #983   +/-   ##
=======================================
  Coverage        ?   82.28%           
=======================================
  Files           ?       22           
  Lines           ?     3561           
  Branches        ?        0           
=======================================
  Hits            ?     2930           
  Misses          ?      631           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant