Skip to content

Commit

Permalink
Fix more build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatekii committed Dec 24, 2024
1 parent 154bacc commit ed04a4e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ impl Device {
/// descriptors will return an error.
pub fn get_descriptor(
&self,
_desc_type: u8,
_desc_index: u8,
_language_id: u16,
_timeout: Duration,
desc_type: u8,
desc_index: u8,
language_id: u16,
timeout: Duration,
) -> Result<Vec<u8>, Error> {
#[cfg(target_os = "windows")]
{
Expand Down
3 changes: 1 addition & 2 deletions src/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
use std::ffi::{OsStr, OsString};
use std::ops::AddAssign;

use web_sys::{js_sys::Reflect, wasm_bindgen::JsValue};

#[cfg(any(target_os = "linux", target_os = "android"))]
use crate::platform::SysfsPath;

Expand Down Expand Up @@ -104,6 +102,7 @@ impl DeviceInfo {

#[cfg(target_family = "wasm")]
{
use web_sys::{js_sys::Reflect, wasm_bindgen::JsValue};
let key = JsValue::from_str("nusbUniqueId");
static INCREMENT: std::sync::LazyLock<std::sync::Mutex<usize>> =
std::sync::LazyLock::new(|| std::sync::Mutex::new(0));
Expand Down
2 changes: 1 addition & 1 deletion src/platform/linux_usbfs/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl FromHexStr for u16 {

const SYSFS_USB_PREFIX: &'static str = "/sys/bus/usb/devices/";

pub fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
pub async fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
Ok(fs::read_dir(SYSFS_USB_PREFIX)?.flat_map(|entry| {
let path = entry.ok()?.path();
let name = path.file_name()?;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/linux_usbfs/usbfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn set_configuration<Fd: AsFd>(fd: Fd, configuration: u8) -> io::Result<()>
}
}

pub fn claim_interface<Fd: AsFd>(fd: Fd, interface: u8) -> io::Result<()> {
pub async fn claim_interface<Fd: AsFd>(fd: Fd, interface: u8) -> io::Result<()> {
unsafe {
let ctl =
ioctl::Setter::<ioctl::ReadOpcode<b'U', 15, c_uint>, c_uint>::new(interface.into());
Expand Down
4 changes: 2 additions & 2 deletions src/platform/macos_iokit/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn guess_active_config(dev: &IoKitDevice) -> Option<u8> {
}

impl MacDevice {
pub(crate) fn from_device_info(d: &DeviceInfo) -> Result<Arc<MacDevice>, Error> {
pub(crate) async fn from_device_info(d: &DeviceInfo) -> Result<Arc<MacDevice>, Error> {
log::info!("Opening device from registry id {}", d.registry_id);
let service = service_by_registry_id(d.registry_id)?;
let device = IoKitDevice::new(service)?;
Expand Down Expand Up @@ -196,7 +196,7 @@ impl MacDevice {
TransferHandle::new(super::TransferData::new_control(self.clone()))
}

pub(crate) fn claim_interface(
pub(crate) async fn claim_interface(
self: &Arc<Self>,
interface_number: u8,
) -> Result<Arc<MacInterface>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/macos_iokit/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn usb_controller_service_iter(
}
}

pub fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
pub async fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
Ok(usb_service_iter()?.filter_map(probe_device))
}

Expand Down
6 changes: 3 additions & 3 deletions src/platform/windows_winusb/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) struct WindowsDevice {
}

impl WindowsDevice {
pub(crate) fn from_device_info(d: &DeviceInfo) -> Result<Arc<WindowsDevice>, Error> {
pub(crate) async fn from_device_info(d: &DeviceInfo) -> Result<Arc<WindowsDevice>, Error> {
debug!("Creating device for {:?}", d.instance_id);

// Look up the device again in case the DeviceInfo is stale. In
Expand Down Expand Up @@ -108,7 +108,7 @@ impl WindowsDevice {
))
}

pub(crate) fn claim_interface(
pub(crate) async fn claim_interface(
self: &Arc<Self>,
interface_number: u8,
) -> Result<Arc<WindowsInterface>, Error> {
Expand Down Expand Up @@ -226,7 +226,7 @@ impl WinusbFileHandle {
})
}

fn claim_interface(
async fn claim_interface(
&mut self,
device: &Arc<WindowsDevice>,
interface_number: u8,
Expand Down
2 changes: 1 addition & 1 deletion src/platform/windows_winusb/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use super::{
util::WCString,
};

pub fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
pub async fn list_devices() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
let devs: Vec<DeviceInfo> = cfgmgr32::list_interfaces(GUID_DEVINTERFACE_USB_DEVICE, None)
// get USB_HUB devices as well, like other platforms. ROOT_HUBs will be dropped by probe_device
.iter()
Expand Down

0 comments on commit ed04a4e

Please sign in to comment.