Compare commits

...

2 commits

Author SHA1 Message Date
71fafc0b0d Fixed compilation error on wasm by handling errors 2025-03-09 22:59:55 -05:00
9505ef0204 Updated dependencies 2025-03-09 22:54:22 -05:00
3 changed files with 11 additions and 7 deletions

View file

@ -3,5 +3,5 @@ rustflags = ["--cfg=web_sys_unstable_apis"]
[build] [build]
#just comment in the "current" target #just comment in the "current" target
target = "x86_64-unknown-linux-gnu" #target = "x86_64-unknown-linux-gnu"
#target = "wasm32-unknown-unknown" target = "wasm32-unknown-unknown"

View file

@ -11,16 +11,16 @@ keywords = ["usb", "wasm", "web-usb", "webusb"]
categories = ["wasm", "web-programming", "hardware-support"] categories = ["wasm", "web-programming", "hardware-support"]
readme = "README.md" readme = "README.md"
license = "MIT" license = "MIT"
edition = "2021" edition = "2024"
[lib] [lib]
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
thiserror = "1.0" thiserror = "2.0"
[dev-dependencies] [dev-dependencies]
tokio-test = "0.4.3" tokio-test = "0.4"
# Wasm deps # Wasm deps
[target.'cfg(target_family = "wasm")'.dependencies] [target.'cfg(target_family = "wasm")'.dependencies]

View file

@ -410,7 +410,9 @@ impl<'a> UsbInterface<'a> for Interface {
let result: UsbOutTransferResult = match JsFuture::from(Promise::resolve( let result: UsbOutTransferResult = match JsFuture::from(Promise::resolve(
&self &self
.device .device
.control_transfer_out_with_buffer_source(&params, array_obj), .control_transfer_out_with_buffer_source(&params, array_obj)
.map_err(|j| Error::CommunicationError(j.as_string().unwrap_or_default()))?
.into(),
)) ))
.await .await
{ {
@ -448,7 +450,9 @@ impl<'a> UsbInterface<'a> for Interface {
let promise = Promise::resolve( let promise = Promise::resolve(
&self &self
.device .device
.transfer_out_with_buffer_source(endpoint, array_obj), .transfer_out_with_buffer_source(endpoint, array_obj)
.map_err(|j| Error::CommunicationError(j.as_string().unwrap_or_default()))?
.into(),
); );
let result = JsFuture::from(promise).await; let result = JsFuture::from(promise).await;