libnar icon indicating copy to clipboard operation
libnar copied to clipboard

Support WASM

Open MatthewCroughan opened this issue 1 year ago • 0 comments

I followed https://rustwasm.github.io/docs/book/reference/add-wasm-support-to-crate.html to try to support webassembly in libnar, and it gets quite far but fails like so:

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> src/de.rs:7:14
  |
7 | use std::os::unix::fs::OpenOptionsExt;
  |              ^^^^ could not find `unix` in `os`

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> src/ser.rs:3:14
  |
3 | use std::os::unix::fs::MetadataExt;
  |              ^^^^ could not find `unix` in `os`

error[E0433]: failed to resolve: could not find `unix` in `os`
   --> src/de.rs:434:18
    |
434 |         std::os::unix::fs::symlink(target, dst)
    |                  ^^^^ could not find `unix` in `os`

error[E0599]: no method named `mode` found for struct `OpenOptions` in the current scope
   --> src/de.rs:419:17
    |
419 |             opt.mode(0o555);
    |                 ^^^^ method not found in `OpenOptions`

error[E0599]: no method named `mode` found for struct `OpenOptions` in the current scope
   --> src/de.rs:421:17
    |
421 |             opt.mode(0o444);
    |                 ^^^^ method not found in `OpenOptions`

error[E0599]: no method named `mode` found for struct `Metadata` in the current scope
  --> src/ser.rs:52:21
   |
52 |         if metadata.mode() & 0o111 != 0 {
   |                     ^^^^ help: there is a method with a similar name: `modified`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `libnar` (lib) due to 6 previous errors

Supporting WASM would mean we could compute the NAR Hash of files/folders on a webpage, which would be fantastic for web services built with Nix backends, as I am trying to make.

MatthewCroughan avatar Jun 02 '23 01:06 MatthewCroughan