[INFO]: 馃幆 Checking for the Wasm target...
[INFO]: 馃寑 Compiling to Wasm...
Compiling rustc-serialize v0.3.24
Compiling wasm-bindgen-macro-support v0.2.42
error[E0046]: not all trait items implemented, missing: `encode`
--> /Users/huangwutao/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1358:1
|
853 | fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>;
| ---------------------------------------------------------------- `encode` from trait
...
1358 | impl Encodable for path::Path {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `encode` in implementation
error[E0046]: not all trait items implemented, missing: `decode`
--> /Users/huangwutao/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1382:1
|
904 | fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>;
| ----------------------------------------------------------- `decode` from trait
...
1382 | impl Decodable for path::PathBuf {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `decode` in implementation
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0046`.
error: Could not compile `rustc-serialize`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
extern crate wasm_bindgen;
extern crate console_error_panic_hook;
extern crate libsm;
use wasm_bindgen::prelude::*;
use libsm::sm2::signature::{Pubkey, Seckey, Signature, SigCtx};
#[wasm_bindgen]
pub fn keyPair () -> String {
let ctx = SigCtx::new();
let (pk, sk) = ctx.new_keypair();
let pk_raw = ctx.serialize_pubkey(&pk, true);
hex::encode(&pk_raw)
}
Thanks for the report but the rustc-serialize crate does not support WebAssembly, and there's unfortunately not a ton we can do about that form wasm_bindgen. I'd recommend contacting upstream authors and asking them to drop rustc-serialize support