Moved some crate components around

This commit is contained in:
G2-Games 2024-01-31 15:01:45 -06:00
parent 4aee02c150
commit c563a41781
5 changed files with 10 additions and 12 deletions

View file

@ -10,11 +10,8 @@ license = "AGPL-3.0"
[dependencies] [dependencies]
hex = "0.4.3" hex = "0.4.3"
cross_usb = { path = "/home/g2/Documents/projects/code/rust/cross-usb/" } cross_usb = "0.1"
[target.'cfg(target_family = "wasm")'.dependencies] tokio = { version = "1.35.1", features = ["macros", "rt", "rt-multi-thread"] }
tokio = { version = "1.35.1", features = ["macros"] }
[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { version = "1.35.1", features = ["full"] }
[dependencies.minidisc_rs] [dependencies.minidisc_rs]
path = "minidisc-rs" path = "minidisc-rs"

View file

@ -21,7 +21,7 @@ unicode-normalization = "0.1.22"
hex = "0.4.3" hex = "0.4.3"
regex = "1.10.2" regex = "1.10.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
cross_usb = { path = "../../cross-usb/" } cross_usb = "0.1"
num-derive = "0.3.3" num-derive = "0.3.3"
num-traits = "0.2.14" num-traits = "0.2.14"
rand = "0.8.5" rand = "0.8.5"

View file

@ -12,7 +12,7 @@ use gloo::{
// USB stuff // USB stuff
//use nusb::transfer::{Control, ControlIn, ControlOut, ControlType, Recipient, RequestBuffer}; //use nusb::transfer::{Control, ControlIn, ControlOut, ControlType, Recipient, RequestBuffer};
use cross_usb::context::{UsbDevice, UsbInterface}; use cross_usb::{UsbDevice, UsbInterface};
use cross_usb::usb::{ControlIn, ControlOut, ControlType, Device, Interface, Recipient}; use cross_usb::usb::{ControlIn, ControlOut, ControlType, Device, Interface, Recipient};
//use nusb::{Device, DeviceInfo, Interface}; //use nusb::{Device, DeviceInfo, Interface};
@ -328,7 +328,7 @@ impl NetMD {
Ok(final_result) Ok(final_result)
} }
pub async fn write_bulk(&mut self, data: Vec<u8>) -> Result<usize, Box<dyn Error>> { pub async fn write_bulk(&mut self, data: &[u8]) -> Result<usize, Box<dyn Error>> {
self.usb_interface.bulk_out(BULK_WRITE_ENDPOINT, data).await self.usb_interface.bulk_out(BULK_WRITE_ENDPOINT, data).await
} }
} }

View file

@ -5,6 +5,7 @@ use crate::netmd::utils::{
half_width_to_full_width_range, length_after_encoding_to_jis, sanitize_full_width_title, half_width_to_full_width_range, length_after_encoding_to_jis, sanitize_full_width_title,
sanitize_half_width_title, time_to_duration, sanitize_half_width_title, time_to_duration,
}; };
use cross_usb::UsbDevice;
use encoding_rs::*; use encoding_rs::*;
use hex; use hex;
use magic_crypt::{new_magic_crypt, MagicCrypt, MagicCryptTrait, SecureBit}; use magic_crypt::{new_magic_crypt, MagicCrypt, MagicCryptTrait, SecureBit};
@ -204,7 +205,7 @@ impl NetMDInterface {
const MAX_INTERIM_READ_ATTEMPTS: u8 = 4; const MAX_INTERIM_READ_ATTEMPTS: u8 = 4;
const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100; const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100;
pub async fn new(device: &cross_usb::context::UsbDevice) -> Result<Self, Box<dyn Error>> { pub async fn new(device: &UsbDevice) -> Result<Self, Box<dyn Error>> {
let net_md_device = base::NetMD::new(device).await?; let net_md_device = base::NetMD::new(device).await?;
Ok(NetMDInterface { net_md_device }) Ok(NetMDInterface { net_md_device })
} }
@ -1042,7 +1043,7 @@ impl NetMDInterface {
(3, Descriptor::AudioUTOC4TD) (3, Descriptor::AudioUTOC4TD)
} }
false => { false => {
new_title = sanitize_half_width_title(title.clone()); new_title = sanitize_half_width_title(title);
(2, Descriptor::AudioUTOC1TD) (2, Descriptor::AudioUTOC1TD)
} }
}; };
@ -1533,7 +1534,7 @@ impl NetMDInterface {
} else { } else {
data.clone() data.clone()
}; };
self.net_md_device.write_bulk(binpack).await?; self.net_md_device.write_bulk(&binpack).await?;
_written_bytes += data.len(); _written_bytes += data.len();
} }

View file

@ -3,7 +3,7 @@ use cross_usb::usb::Device;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let device = cross_usb::context::get_device(0x054c, 0x0186).await.unwrap(); let device = cross_usb::get_device(0x054c, 0x0186).await.unwrap();
dbg!(device.vendor_id().await); dbg!(device.vendor_id().await);