seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.51k stars 1.07k forks source link

Consideration of wasm32 (arch) being used for a gaming console #1917

Open hydroper opened 1 year ago

hydroper commented 1 year ago

This library is very useful, but the way it detects the browser may be problematic if you need WebAssembly for another purpose other than the browser, such as futurely compiling Rust to wasm32 to anything else that isn't supported officially by rustup (such as Nintendo Switch, which uses a very specific chip by Nvidia).

LLVM is harder to work with I think

In my case I'm planning to use two Cargo features for my generic graphical framework when running rialight run and rialight export:

My current plan is to wrap reqwest or hyper inside a called "network API". I wonder if there's a way to create two additional submodules into reqwest like these:

So I'll be able to perform a #[cfg(feature = "...")] in my end by using these 2 modules instead.

From Quora:

  • According to Wikipedia, the processor is built in to a “custom” chip made by Nvidia specifically for the switch. It is considered in the family of the Tegra X1 of systems on a chip. It uses two separate CPUs that work together (or work separate “shifts” depending on demands) based on power necessity as a single octa-core (called “ARM big.LITTLE”), one quad core ARM Cortex-A57 and one quad core ARM Cortex-A53.
  • The Nintendo Switch is based on Nvidia Tegra X1 chipset, which means that it is powered by a 256-core GM20B Maxwell GPU and octa-core CPU with four Cortex-A57 and four Cortex-A53 cores.
oblique commented 12 months ago

I have the same issue too. I'm developing a project that will run within Internet Computer, which compiles in WASM, but not for browsers. I can not deploy anything that is using wasm-bindgen, web-sys, or js-sys.

IMO, wasm32 should be considered only as architecture and browser the environment.

hydroper commented 12 months ago

Another solution is to simply take a default feature wasmbind, just like the chrono crate! Then anyone can go ahead and put default-features = false on the dependency and, if desired, use a conditional feature using features."reqwest/wasmbind"

seanmonstar commented 12 months ago

It's a fair point, and I generally agree! I don't really have much personal use with any of the WASM environments, so we would need someone with such experience to help figure out how to make it work in other envs, while still working correctly in the browser (and hopefully keeping the exposed part in reqwest to a minimum, since if we have to change things we don't want to break people).