Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Invalid function signature when loading Rust-generated webassembly binary from Python

The full code is here:

https://github.com/dmerejkowsky/chuck-norris-webassembly-plugins

Here's what's wrong

There's a get_fact method written in Rust and exported with wasm_bindgen:

#[wasm_bindgen]
pub fn get_fact() -> String {
    "Chuck Norris can slam a revolving door".to_string()
}

When I build the wasm file with wasm-pack --target nodejs I can call the get_fact just fine from Javascript:

const assert = require('node:assert/strict');
const ck = require('../pkg/chuck_norris.js');

const actual = ck.get_fact();
assert.ok(actual.includes("Chuck Norris"));

But when trying to write the same test in Python:

from wasmer import engine, Store, Module, Instance
from wasmer_compiler_cranelift import Compiler

rust_wasm = Path / "to" / "chucknorris_bg.wasm"

store = Store(engine.Universal(Compiler))
module = Module(store, rust_wasm.read_bytes())
instance = Instance(module)
get_fact = instance.exports.get_fact
actual = get_fact()
assert "Chuck Norris" in actual

I get :

RuntimeError: Parameters of type [] did not match signature [I32] -> []

Any clues as to why NodeJs and Python disagree on the signature of the get_fact() function ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Answering myself: you cannot use webassembly with strings this way. More info on this blog post: https://medium.com/wasm/strings-in-webassembly-wasm-57a05c1ea333

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!