LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
607 stars 69 forks source link

Implicit use of `tokio::net` #141

Open elpiel opened 4 months ago

elpiel commented 4 months ago

Seems that the features is enabled by hyper_util but it's not enabled on this crate even though it's being used.

I was exploring the option to make wiremock wasm-unknown-unknown happy but sadly hyper_util doesn't allow it because it relies on tokio net which relies on mio. And mio only supports the wasm-wasi (there are OS socket after all)

While socket2 is not actually mandatory for the tokio feature itself but clien-legacy in hyper_util.

PS: Would be nice to enable resolver = "2" as well.

LukeMathWalker commented 4 months ago

I'm open to the idea of making changes to enable easier usage in a WASM context. What would that entail?

PS: Would be nice to enable resolver = "2" as well.

That only affects the project you're currently building. Having it set on wiremock makes no sense difference for downstream users AFAIK.

elpiel commented 4 months ago

I believe for WASM support we should target wasm32-wasi as it provides access to some OS resources. The main issue I suppose is the Tcp socket where currently tokio::net is used and, in terms, mio. But I haven't done much research on the topic so it must be more thoroughly checked.

as for the resolver, yes, you are right. features only show on the first occurrence of a given dependency in cargo tree and I had to hunt down which dep. enables a tokio features that requires mio

elpiel commented 4 months ago

And btw mio supports wasm32-wasi and TcpListener/TcpStream: https://docs.rs/mio/latest/wasm32-wasi/mio/net/index.html

Not sure if tokio will play nice though..

And wasm-bindgen doesn't support the target as well :/