diff --git a/mm2src/crypto/src/hw_client.rs b/mm2src/crypto/src/hw_client.rs index eda8caf36b..42e92e4547 100644 --- a/mm2src/crypto/src/hw_client.rs +++ b/mm2src/crypto/src/hw_client.rs @@ -124,12 +124,11 @@ impl HwClient { ) -> MmResult> { use common::custom_futures::timeout::TimeoutError; use common::executor::Timer; - use trezor::transport::{ConnectableDeviceWrapper, Transport}; + use trezor::transport::ConnectableDeviceWrapper; async fn try_to_connect() -> HwResult> where - C: ConnectableDeviceWrapper, - ::T: Transport + Sync + Send + 'static, + C: ConnectableDeviceWrapper + 'static, { let mut devices = C::find_devices().await?; if devices.is_empty() { diff --git a/mm2src/hw_common/src/transport/libusb.rs b/mm2src/hw_common/src/transport/libusb.rs index da33494dc5..da303f4919 100644 --- a/mm2src/hw_common/src/transport/libusb.rs +++ b/mm2src/hw_common/src/transport/libusb.rs @@ -127,7 +127,7 @@ pub struct UsbAvailableDevice { } impl UsbAvailableDevice { - pub fn connect(self) -> UsbResult { + pub fn connect(&self) -> UsbResult { // This is a non-blocking function; no requests are sent over the bus. let mut device_handle = self.device.open().map_to_mm(UsbError::ErrorOpeningDevice)?; // Claiming of interfaces is a purely logical operation. @@ -277,7 +277,7 @@ impl UsbDevice { fn endpoint_number(&self) -> u8 { self.device_info.interface_info.endpoint_number } } -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] pub struct UsbDeviceInfo { pub vendor_id: u16, pub product_id: u16, @@ -286,7 +286,7 @@ pub struct UsbDeviceInfo { pub interface_info: UsbDeviceInterfaceInfo, } -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] pub struct UsbDeviceInterfaceInfo { pub interface_number: u8, pub endpoint_number: u8, diff --git a/mm2src/trezor/src/transport/mod.rs b/mm2src/trezor/src/transport/mod.rs index eddb856118..30c16a4143 100644 --- a/mm2src/trezor/src/transport/mod.rs +++ b/mm2src/trezor/src/transport/mod.rs @@ -72,13 +72,11 @@ impl AsRef<[u8]> for SessionId { /// Wrapper to abstract connectivity to usb and emulator devices #[async_trait] pub trait ConnectableDeviceWrapper { - type T; + type TransportType: Transport + Sync + Send; async fn find_devices() -> TrezorResult> where Self: Sized; - async fn connect(self) -> TrezorResult - where - Self::T: Transport; + async fn connect(&self) -> TrezorResult; } diff --git a/mm2src/trezor/src/transport/udp.rs b/mm2src/trezor/src/transport/udp.rs index 45e6f3ab63..d47ae1f31c 100644 --- a/mm2src/trezor/src/transport/udp.rs +++ b/mm2src/trezor/src/transport/udp.rs @@ -43,8 +43,8 @@ pub struct UdpAvailableDevice { impl UdpAvailableDevice { /// Connect to the device. - async fn connect(self) -> TrezorResult { - let transport = UdpTransport::connect(&self).await?; + async fn connect(&self) -> TrezorResult { + let transport = UdpTransport::connect(self).await?; Ok(transport) } } @@ -160,14 +160,14 @@ impl Transport for UdpTransport { #[async_trait] impl ConnectableDeviceWrapper for UdpAvailableDevice { - type T = UdpTransport; + type TransportType = UdpTransport; async fn find_devices() -> TrezorResult> where Self: Sized, { - crate::transport::udp::find_devices().await + find_devices().await } - async fn connect(self) -> TrezorResult { UdpAvailableDevice::connect(self).await } + async fn connect(&self) -> TrezorResult { UdpAvailableDevice::connect(self).await } } diff --git a/mm2src/trezor/src/transport/usb.rs b/mm2src/trezor/src/transport/usb.rs index 751d5d8e2e..cfdba0d36c 100644 --- a/mm2src/trezor/src/transport/usb.rs +++ b/mm2src/trezor/src/transport/usb.rs @@ -73,7 +73,7 @@ pub struct UsbAvailableDevice(UsbAvailableDeviceImpl); impl UsbAvailableDevice { /// Please note [`hw_common::transport::libusb::UsbAvailableDevice::connect`] spawns a thread. - async fn connect(self) -> TrezorResult { + async fn connect(&self) -> TrezorResult { let link = UsbLink { device: self.0.connect()?, }; @@ -95,14 +95,14 @@ fn is_trezor(device: &UsbAvailableDeviceImpl) -> bool { #[async_trait] impl ConnectableDeviceWrapper for UsbAvailableDevice { - type T = UsbTransport; + type TransportType = UsbTransport; async fn find_devices() -> TrezorResult> where Self: Sized, { - crate::transport::usb::find_devices().await + find_devices().await } - async fn connect(self) -> TrezorResult { UsbAvailableDevice::connect(self).await } + async fn connect(&self) -> TrezorResult { UsbAvailableDevice::connect(self).await } }