Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda