Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM bindings revisited #472

Open
platoscave opened this issue Apr 9, 2024 · 3 comments
Open

WASM bindings revisited #472

platoscave opened this issue Apr 9, 2024 · 3 comments

Comments

@platoscave
Copy link

I'd like to use jsonschema in a wasm a environment. I tried this code (below). The app compiles just fine, however it crashes just as soon as it just as soon as it reaches JSONSchema::compile

let schema = json!({"maxLength": 5});
let compiled = JSONSchema::compile(&schema);

I tried different versions / features combinations based in previous issues regarding the same matter (#222, #395) . They each crash for different reasons.

jsonschema = { version = "=0.15.1", default-features = false, features = ["structopt"]}
exception: no mapping for imported function sched_yield

jsonschema = { version = "0.17.0", default-features = false, features = ["resolve-file"]}
exception: no mapping for imported function fd_read

As soon as I add resolve-http to the features I get: could not find blocking in reqwest, which is what we're trying to avoid.

Which features do I need to add in order to use JSONSchema in WASM environment?

@Stranger6667
Copy link
Owner

Oh, thats problematic right now - I don't think that resolving works just yet, but it will as soon as I'll finish the rewrite. There will be async + blocking API for resolving refs via network. Not sure about the filesystem, but wasm32-wasi probably would work.

Also, I am going to run a full test suite on WASM as the implementation is ready.

Meanwhile - what is your rustc version and target?

@platoscave
Copy link
Author

rustc version

rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

target: wasi-sdk-20.0

Looking forward to the rewrite!

@Stranger6667
Copy link
Owner

Thanks! If you have any feedback on the API (current or the next version) & usability, feel free to leave a comment in this discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants