Skip to content

Commit

Permalink
Remove the js_sys::Uint8Array import
Browse files Browse the repository at this point in the history
Co-Authored-By: Artyom Pavlov <[email protected]>
  • Loading branch information
daxpedda and newpavlov committed Dec 9, 2024
1 parent ec6f289 commit cf72d6c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/backends/wasm_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pub use crate::util::{inner_u32, inner_u64};
#[cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))))]
compile_error!("`wasm_js` backend can be enabled only for OS-less WASM targets!");

#[cfg(target_feature = "atomics")]
use js_sys::Uint8Array;
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};

// Maximum buffer size allowed in `Crypto.getRandomValuesSize` is 65536 bytes.
Expand Down Expand Up @@ -40,7 +38,7 @@ fn inner(crypto: &Crypto, dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
let buf_len_u32 = buf_len
.try_into()
.expect("buffer length is bounded by MAX_BUFFER_SIZE");
let buf = Uint8Array::new_with_length(buf_len_u32);
let buf = js_sys::Uint8Array::new_with_length(buf_len_u32);
for chunk in dest.chunks_mut(buf_len) {
let chunk_len = chunk
.len()
Expand Down Expand Up @@ -77,5 +75,5 @@ extern "C" {
fn get_random_values(this: &Crypto, buf: &mut [MaybeUninit<u8>]) -> Result<(), JsValue>;
#[cfg(target_feature = "atomics")]
#[wasm_bindgen(method, js_name = getRandomValues, catch)]
fn get_random_values(this: &Crypto, buf: &Uint8Array) -> Result<(), JsValue>;
fn get_random_values(this: &Crypto, buf: &js_sys::Uint8Array) -> Result<(), JsValue>;
}

0 comments on commit cf72d6c

Please sign in to comment.