bozaro / lz4-rs

Rust LZ4 bindins library
MIT License
185 stars 77 forks source link

Is wasm support possible? #38

Open burmecia opened 5 years ago

burmecia commented 5 years ago

Is that possible to support wasm? I know currently libc crate doesn't support wasm yet (https://github.com/rust-lang/libc/pull/1126), but since this crate only used limited number of c types (c_char, c_int and etc.). Replace them with Rust types like i8, i32 and etc, could be a possible temporary solution.

Any thoughts?

jheyens commented 5 years ago

This would be possible at the cost of platform independency. See #36 for example.

Additionally, when I last tried wasm with Rust months ago, crates required ![no_std] to properly work. lz4-sys is no_std but lz4 uses collections and IO traits.

I just looked it up and I think wasm does not require no_std, but a lot of libstd is simply unsupported.

For your specific problem, I'ld suggest doing one of two things:

  1. Wait, until libc supports wasm
  2. Refactor this crate locally and hard-code the types. I think I could guide you through that, if want to go this route.
jheyens commented 5 years ago

Alright, I just saw you did that already, awesome :-)

https://github.com/burmecia/lz4-rs

This crate needs some tidying up anyways, so I think, I'll note wasm support for a future lz4 2.0, where I am going to add stream mode and refactor the API to match alexcrichton's flate2

burmecia commented 5 years ago

Thanks @jheyens. Yes, I've already forked and am playing around with it, hopefully will make it run in browser!