-
Notifications
You must be signed in to change notification settings - Fork 226
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
Allow wasm to compile #939
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In all of our uses, azure_core
is set to default-features=false. Perhaps we should not set default features for azure_core, and have it's dependencies do that?
❯ rg -I ^azure_core -g '**/Cargo.toml' | sort -u
azure_core = { path = "../../../sdk/core", version = "0.3", default-features = false }
azure_core = { path = "../core", version = "0.3", default-features = false }
azure_core = { path = "../core", version = "0.3", default-features = false}
azure_core = { path = "../core", version = "0.3", default-features=false }
azure_core = { path = "../core", version = "0.3", default_features = false }
❯
For WASI support, I've been using a modified version of this SDK that works with https://github.com/deislabs/wasi-experimental-http and Wasmtime — main...radu-matei:azure-sdk-for-rust:enable-wasi-experimental-http |
@radu-matei awesome! I hope to have a change soon that allows for easily swapping out the transport policy. Once that's done, it should hopefully be easy to have a |
Fixes #906
This cleans up our wasm support a bit and paves the way for actual wasm support to be added in the near future.
User experience
Users can now compiler for
wasm32
targets as long as thereqwest
features are not turned on (since reqwest does not have wasm support).If the user compiles for
wasm32
targets with thereqwest
features enabled (as they are by default), they see the following error.The noop client
We currently don't support any way for users to make requests when compiling for the
wasm32
target. In the future, we will provide an easy way for users to supply there own transport policies. Users who compile for wasm in the browser, can provide a transport policy that uses the browser APIs, while users compiling for wasi, can use a transport policy that uses wasi based APIs.Since there is (IMO) no obvious default, we have a
NoopClient
that simply panics and prints out the outgoing request. Most users who will be using thereqwest
feature, will never run into this.Some challenges
This solution isn't 100% elegant, but is IMO an improvement over the status quo. There are some downsides though:
Send
futures for wasm targets. This causes us to have to propogate this out since by defaultBoxFuture
and theFuture
s created by theasync_trait
macro are all constrained to beSend
. So, we still have a lot ofcfg
markers for wasm, but there in much more predictable places and we don't have to add a bunch ofallow(unused)
directives everywhere.