Skip to content

Commit

Permalink
Fixed not compiling on WASM
Browse files Browse the repository at this point in the history
  • Loading branch information
G2-Games committed Apr 23, 2024
1 parent bbdb47a commit 9597aef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ rustflags = ["--cfg=web_sys_unstable_apis"]

[build]
#just comment in the "current" target
target = "x86_64-unknown-linux-gnu"
#target = "wasm32-unknown-unknown"
#target = "x86_64-unknown-linux-gnu"
target = "wasm32-unknown-unknown"
28 changes: 14 additions & 14 deletions src/backend/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ use web_sys::{

// Crate stuff
use crate::usb::{
ControlIn, ControlOut, ControlType, Descriptor, Device, Interface, Recipient, UsbError,
ControlIn, ControlOut, ControlType, UsbDescriptor, UsbDevice, UsbInterface, Recipient, UsbError,
};

#[wasm_bindgen]
#[derive(Debug)]
pub struct UsbDescriptor {
pub struct Descriptor {
device: WasmUsbDevice,
}

#[wasm_bindgen]
#[derive(Debug)]
pub struct UsbDevice {
pub struct Device {
device: WasmUsbDevice,
}

#[wasm_bindgen]
#[derive(Debug)]
pub struct UsbInterface {
pub struct Interface {
device: WasmUsbDevice,
_number: u8,
}
Expand Down Expand Up @@ -61,7 +61,7 @@ impl DeviceFilter {
}

#[wasm_bindgen]
pub async fn get_device(device_filter: Vec<DeviceFilter>) -> Result<UsbDescriptor, js_sys::Error> {
pub async fn get_device(device_filter: Vec<DeviceFilter>) -> Result<Descriptor, js_sys::Error> {
let window = web_sys::window().unwrap();

let navigator = window.navigator();
Expand Down Expand Up @@ -102,7 +102,7 @@ pub async fn get_device(device_filter: Vec<DeviceFilter>) -> Result<UsbDescripto
result
}) {
let _open_promise = JsFuture::from(Promise::resolve(&device.open())).await?;
return Ok(UsbDescriptor { device });
return Ok(Descriptor { device });
}
}

Expand Down Expand Up @@ -161,7 +161,7 @@ pub async fn get_device(device_filter: Vec<DeviceFilter>) -> Result<UsbDescripto

let _open_promise = JsFuture::from(Promise::resolve(&device.open())).await?;

Ok(UsbDescriptor { device })
Ok(Descriptor { device })
}

/*
Expand Down Expand Up @@ -273,8 +273,8 @@ pub async fn get_device_list(device_filter: Vec<DeviceFilter>) -> Result<Vec<Usb
}
*/

impl Descriptor for UsbDescriptor {
type Device = UsbDevice;
impl UsbDescriptor for Descriptor {
type Device = Device;

async fn open(self) -> Result<Self::Device, UsbError> {
Ok(Self::Device {
Expand Down Expand Up @@ -307,10 +307,10 @@ impl Descriptor for UsbDescriptor {
}
}

impl Device for UsbDevice {
type Interface = UsbInterface;
impl UsbDevice for Device {
type Interface = Interface;

async fn open_interface(&self, number: u8) -> Result<UsbInterface, UsbError> {
async fn open_interface(&self, number: u8) -> Result<Interface, UsbError> {
let dev_promise =
JsFuture::from(Promise::resolve(&self.device.claim_interface(number))).await;

Expand All @@ -324,7 +324,7 @@ impl Device for UsbDevice {
}
};

Ok(UsbInterface {
Ok(Interface {
device: self.device.clone(),
_number: number,
})
Expand Down Expand Up @@ -381,7 +381,7 @@ impl Device for UsbDevice {
}
}

impl<'a> Interface<'a> for UsbInterface {
impl<'a> UsbInterface<'a> for Interface {
async fn control_in(&self, data: crate::usb::ControlIn) -> Result<Vec<u8>, UsbError> {
let length = data.length;
let params: UsbControlTransferParameters = data.into();
Expand Down

0 comments on commit 9597aef

Please sign in to comment.