Skip to content

Commit b18df42

Browse files
committed
Fix wasm32_bindgen implementation
Use the `__wbg_shims` imports instead of creating new, local imports in the `wasm32_bindgen` module. Fixes rustwasm/wasm-bindgen#1189
1 parent a7c2eae commit b18df42

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

Diff for: rand_os/src/wasm32_bindgen.rs

+1-34
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,10 @@
1010
1111
use rand_core::{Error, ErrorKind};
1212
use super::OsRngImpl;
13+
use super::__wbg_shims::*;
1314

1415
use wasm_bindgen::prelude::*;
1516

16-
#[wasm_bindgen]
17-
extern "C" {
18-
pub type Function;
19-
#[wasm_bindgen(constructor)]
20-
pub fn new(s: &str) -> Function;
21-
#[wasm_bindgen(method)]
22-
pub fn call(this: &Function, self_: &JsValue) -> JsValue;
23-
24-
pub type This;
25-
#[wasm_bindgen(method, getter, structural, js_name = self)]
26-
pub fn self_(me: &This) -> JsValue;
27-
#[wasm_bindgen(method, getter, structural)]
28-
pub fn crypto(me: &This) -> JsValue;
29-
30-
#[derive(Clone, Debug)]
31-
pub type BrowserCrypto;
32-
33-
// TODO: these `structural` annotations here ideally wouldn't be here to
34-
// avoid a JS shim, but for now with feature detection they're
35-
// unavoidable.
36-
#[wasm_bindgen(method, js_name = getRandomValues, structural, getter)]
37-
pub fn get_random_values_fn(me: &BrowserCrypto) -> JsValue;
38-
#[wasm_bindgen(method, js_name = getRandomValues, structural)]
39-
pub fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]);
40-
41-
#[wasm_bindgen(js_name = require)]
42-
pub fn node_require(s: &str) -> NodeCrypto;
43-
44-
#[derive(Clone, Debug)]
45-
pub type NodeCrypto;
46-
47-
#[wasm_bindgen(method, js_name = randomFillSync, structural)]
48-
pub fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]);
49-
}
5017

5118
#[derive(Clone, Debug)]
5219
pub enum OsRng {

0 commit comments

Comments
 (0)