Giter Site home page Giter Site logo

WebAssembly support about ureq HOT 4 OPEN

brandonros avatar brandonros commented on May 28, 2024 1
WebAssembly support

from ureq.

Comments (4)

algesten avatar algesten commented on May 28, 2024

Hi @brandonros! Welcome to ureq!

I have never used WebAssembly myself, so I don't actually know what would be required to make that work. The Duration here are ultimately used as socket timeouts. Those sockets are std::net::TcpStream, and I'll imagine that even if we get past the Duration problems, we will get to a dead end for the sockets. I don't know if it would be possible to solve that – blocking sockets at the bottom of the call stack?

A possible direction for a ureq 3.0, would be to isolate the HTTP request/response function into a Sans IO pattern backing library without allocations, deliberately target no_std and webassembly. Then make nice higher level wrappers for std, no_std and webasm that sits on the same core.

from ureq.

jsha avatar jsha commented on May 28, 2024

I'm curious @brandonros, what's the use case for using ureq in WebAssembly?

If it's useful, we could probably do something where all the meaningful features are stubbed out to fetch, but we'd need some motivating use cases.

I do really like the idea of making a no_std version of ureq (with more user-friendly features stacked on top when std is present).

from ureq.

algesten avatar algesten commented on May 28, 2024

@jsha i've been thinking about the no_std thing.

Here's an experiment just fleshing out what a no_std low level API could look like: https://github.com/algesten/h1-call

Design goals:

  • no_std and no alloc crate. Stack is enough
  • Sans-IO. Bring your own transport.
  • Allow flushing the buffer to the transport at any point. I.e. do not require all headers to be in the borrowed buffer at the same time.
  • Encode protocol as types, i.e. let State mean "the state the call is currently in", Version means Http/1.0 or 1.1. Method means GET/HEAD/etc...
  • Using types, constraint operations to only those that are valid. I.e. Version HTTP/1.0 cannot send a body unless the Method is POST (the others are GET/HEAD which cannot have a body).

I've fleshed out how this could look with HTTP/1.0 – but it looks pretty promising, albeit it's a type soup.

from ureq.

brandonros avatar brandonros commented on May 28, 2024

I'm curious @brandonros, what's the use case for using ureq in WebAssembly?

If it's useful, we could probably do something where all the meaningful features are stubbed out to fetch, but we'd need some motivating use cases.

I do really like the idea of making a no_std version of ureq (with more user-friendly features stacked on top when std is present).

You're probably right. My "vision"/idea was probably due to a lack of understanding on how things should be done in wasm land but the argument was:

write once, be able to run it backend (native Rust binary) and/or in the browser with wasm without having to add logic like if backend, use ureq, otherwise, use web-sys fetch https://github.com/search?q=repo%3Arustwasm%2Fwasm-bindgen%20fetch_with_request&type=code

from ureq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.