Introduce unstable, incomplete WASM support

This commit is contained in:
Sean McArthur
2019-09-24 14:50:30 -07:00
parent 6413a4349e
commit 932defd879
10 changed files with 543 additions and 78 deletions

View File

@@ -1,3 +1,4 @@
#![cfg_attr(target_arch = "wasm32", allow(unused))]
use std::error::Error as StdError;
use std::fmt;
use std::io;
@@ -12,7 +13,7 @@ pub struct Error {
inner: Box<Inner>,
}
type BoxError = Box<dyn StdError + Send + Sync>;
pub(crate) type BoxError = Box<dyn StdError + Send + Sync>;
struct Inner {
kind: Kind,
@@ -213,6 +214,12 @@ pub(crate) fn url_bad_scheme(url: Url) -> Error {
Error::new(Kind::Builder, Some("URL scheme is not allowed")).with_url(url)
}
if_wasm! {
pub(crate) fn wasm(js_val: wasm_bindgen::JsValue) -> BoxError {
format!("{:?}", js_val).into()
}
}
// io::Error helpers
#[allow(unused)]