Grabbing resources, (fetch? get?) - emscripten/rust/asmjs/native-desktop


just finding my way around the asmjs / emscripten stuff, and browser world generally.

I’m after the straightforward ability to grab resources (images etc) from URLs in a rust/asmjs/emscripten app: I see that emscripten itself has C shims (which should be rust-callable,right) for doing this

But what I really want to do is have a single codepath that will let me run the exact same program natively on the desktop, or in the browser, and have it exhibit the exact same behaviour (e.g. grabbing images, responding to drag-drop etc) - in a manner similar to how emscripten gives you glut/SDL/glfw shims to port your native/desktop code for IO/gl

  • Does this sort of thing exist already in C/C++,

  • does this sort of thing exist already in Rust,
    if no, would there be existing rust networking libraries that would be suitable to port (wire up to the emscripten shims, I guess)

  • vica versa, would it be possible to use the emscripten shims themselves as a API and just provide emulation of those on the desktop (one fly in the ointment is that those C apis’s are going to be clunky to call from rust, I know dealing with C strings is a pain … so one would really want rustic safe wrappers for all that , I imagine…)

(the end goal is I just want to grab some images from URLs without having them bundled or anything … nothing earth shattering)

Doing this purely in the browser I leverage the fact it has async image grabbing already , but do ideally want to be able to run the same code on the desktop … so i’m going to have to look into Rust image file format libraries too