Fixed formatting in base.rs, fixed clippy warnings

This commit is contained in:
G2-Games 2024-06-19 10:53:48 -05:00
parent 7630ca23a0
commit 4f0a189080
5 changed files with 60 additions and 261 deletions

View file

@ -14,238 +14,56 @@ use super::utils::cross_sleep;
const BULK_WRITE_ENDPOINT: u8 = 0x02; const BULK_WRITE_ENDPOINT: u8 = 0x02;
const BULK_READ_ENDPOINT: u8 = 0x81; const BULK_READ_ENDPOINT: u8 = 0x81;
nofmt::pls! { // Skip formatting the following info
pub static DEVICE_IDS: &[DeviceId] = &[ pub static DEVICE_IDS: &[DeviceId] = &[
DeviceId { DeviceId { vendor_id: 0x04dd, product_id: 0x7202, name: Some("Sharp IM-MT899H") },
vendor_id: 0x04dd, DeviceId { vendor_id: 0x04dd, product_id: 0x9013, name: Some("Sharp IM-DR400") },
product_id: 0x7202, DeviceId { vendor_id: 0x04dd, product_id: 0x9014, name: Some("Sharp IM-DR80") },
name: Some("Sharp IM-MT899H"), DeviceId { vendor_id: 0x054c, product_id: 0x0034, name: Some("Sony PCLK-XX") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x0036, name: Some("Sony") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x0075, name: Some("Sony MZ-N1") },
vendor_id: 0x04dd, DeviceId { vendor_id: 0x054c, product_id: 0x007c, name: Some("Sony") },
product_id: 0x9013, DeviceId { vendor_id: 0x054c, product_id: 0x0080, name: Some("Sony LAM-1") },
name: Some("Sharp IM-DR400"), DeviceId { vendor_id: 0x054c, product_id: 0x0081, name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x0084, name: Some("Sony MZ-N505") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x0085, name: Some("Sony MZ-S1") },
vendor_id: 0x04dd, DeviceId { vendor_id: 0x054c, product_id: 0x0086, name: Some("Sony MZ-N707") },
product_id: 0x9014, DeviceId { vendor_id: 0x054c, product_id: 0x008e, name: Some("Sony CMT-C7NT") },
name: Some("Sharp IM-DR80"), DeviceId { vendor_id: 0x054c, product_id: 0x0097, name: Some("Sony PCGA-MDN1") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x00ad, name: Some("Sony CMT-L7HD") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x00c6, name: Some("Sony MZ-N10") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x00c7, name: Some("Sony MZ-N910") },
product_id: 0x0034, DeviceId { vendor_id: 0x054c, product_id: 0x00c8, name: Some("Sony MZ-N710/NF810") },
name: Some("Sony PCLK-XX"), DeviceId { vendor_id: 0x054c, product_id: 0x00c9, name: Some("Sony MZ-N510/N610") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x00ca, name: Some("Sony MZ-NE410/NF520D") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x00e7, name: Some("Sony CMT-M333NT/M373NT") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x00eb, name: Some("Sony MZ-NE810/NE910") },
product_id: 0x0036, DeviceId { vendor_id: 0x054c, product_id: 0x0101, name: Some("Sony LAM") },
name: Some("Sony"), DeviceId { vendor_id: 0x054c, product_id: 0x0113, name: Some("Aiwa AM-NX1") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x013f, name: Some("Sony MDS-S500") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x014c, name: Some("Aiwa AM-NX9") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x017e, name: Some("Sony MZ-NH1") },
product_id: 0x0075, DeviceId { vendor_id: 0x054c, product_id: 0x0180, name: Some("Sony MZ-NH3D") },
name: Some("Sony MZ-N1"), DeviceId { vendor_id: 0x054c, product_id: 0x0182, name: Some("Sony MZ-NH900") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x0184, name: Some("Sony MZ-NH700/NH800") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x0186, name: Some("Sony MZ-NH600") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x0187, name: Some("Sony MZ-NH600D") },
product_id: 0x007c, DeviceId { vendor_id: 0x054c, product_id: 0x0188, name: Some("Sony MZ-N920") },
name: Some("Sony"), DeviceId { vendor_id: 0x054c, product_id: 0x018a, name: Some("Sony LAM-3") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x01e9, name: Some("Sony MZ-DH10P") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x0219, name: Some("Sony MZ-RH10") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x021b, name: Some("Sony MZ-RH710/MZ-RH910") },
product_id: 0x0080, DeviceId { vendor_id: 0x054c, product_id: 0x021d, name: Some("Sony CMT-AH10") },
name: Some("Sony LAM-1"), DeviceId { vendor_id: 0x054c, product_id: 0x022c, name: Some("Sony CMT-AH10") },
}, DeviceId { vendor_id: 0x054c, product_id: 0x023c, name: Some("Sony DS-HMD1") },
DeviceId { DeviceId { vendor_id: 0x054c, product_id: 0x0286, name: Some("Sony MZ-RH1") },
vendor_id: 0x054c, DeviceId { vendor_id: 0x054c, product_id: 0x011a, name: Some("Sony CMT-SE7") },
product_id: 0x0081, DeviceId { vendor_id: 0x054c, product_id: 0x0148, name: Some("Sony MDS-A1") },
name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780"), DeviceId { vendor_id: 0x0b28, product_id: 0x1004, name: Some("Kenwood MDX-J9") },
}, DeviceId { vendor_id: 0x04da, product_id: 0x23b3, name: Some("Panasonic SJ-MR250") },
DeviceId { DeviceId { vendor_id: 0x04da, product_id: 0x23b6, name: Some("Panasonic SJ-MR270") },
vendor_id: 0x054c,
product_id: 0x0084,
name: Some("Sony MZ-N505"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0085,
name: Some("Sony MZ-S1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0086,
name: Some("Sony MZ-N707"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x008e,
name: Some("Sony CMT-C7NT"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0097,
name: Some("Sony PCGA-MDN1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00ad,
name: Some("Sony CMT-L7HD"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00c6,
name: Some("Sony MZ-N10"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00c7,
name: Some("Sony MZ-N910"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00c8,
name: Some("Sony MZ-N710/NF810"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00c9,
name: Some("Sony MZ-N510/N610"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00ca,
name: Some("Sony MZ-NE410/NF520D"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00e7,
name: Some("Sony CMT-M333NT/M373NT"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x00eb,
name: Some("Sony MZ-NE810/NE910"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0101,
name: Some("Sony LAM"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0113,
name: Some("Aiwa AM-NX1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x013f,
name: Some("Sony MDS-S500"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x014c,
name: Some("Aiwa AM-NX9"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x017e,
name: Some("Sony MZ-NH1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0180,
name: Some("Sony MZ-NH3D"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0182,
name: Some("Sony MZ-NH900"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0184,
name: Some("Sony MZ-NH700/NH800"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0186,
name: Some("Sony MZ-NH600"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0187,
name: Some("Sony MZ-NH600D"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0188,
name: Some("Sony MZ-N920"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x018a,
name: Some("Sony LAM-3"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x01e9,
name: Some("Sony MZ-DH10P"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0219,
name: Some("Sony MZ-RH10"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x021b,
name: Some("Sony MZ-RH710/MZ-RH910"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x021d,
name: Some("Sony CMT-AH10"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x022c,
name: Some("Sony CMT-AH10"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x023c,
name: Some("Sony DS-HMD1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0286,
name: Some("Sony MZ-RH1"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x011a,
name: Some("Sony CMT-SE7"),
},
DeviceId {
vendor_id: 0x054c,
product_id: 0x0148,
name: Some("Sony MDS-A1"),
},
DeviceId {
vendor_id: 0x0b28,
product_id: 0x1004,
name: Some("Kenwood MDX-J9"),
},
DeviceId {
vendor_id: 0x04da,
product_id: 0x23b3,
name: Some("Panasonic SJ-MR250"),
},
DeviceId {
vendor_id: 0x04da,
product_id: 0x23b6,
name: Some("Panasonic SJ-MR270"),
},
]; ];
}
pub static DEVICE_IDS_CROSSUSB: Lazy<Box<[cross_usb::DeviceFilter]>> = Lazy::new(|| { pub static DEVICE_IDS_CROSSUSB: Lazy<Box<[cross_usb::DeviceFilter]>> = Lazy::new(|| {
DEVICE_IDS DEVICE_IDS

View file

@ -409,8 +409,8 @@ impl NetMDContext {
let old_raw_name = self.interface.raw_disc_title(false).await?; let old_raw_name = self.interface.raw_disc_title(false).await?;
let old_raw_fw_name = self.interface.raw_disc_title(true).await?; let old_raw_fw_name = self.interface.raw_disc_title(true).await?;
let has_groups = old_raw_name.find("//").is_some(); let has_groups = old_raw_name.contains("//");
let has_fw_groups = old_raw_fw_name.find("").is_some(); let has_fw_groups = old_raw_fw_name.contains("");
let has_groups_and_title = old_raw_name.starts_with("0;"); let has_groups_and_title = old_raw_name.starts_with("0;");
let has_fw_groups_and_title = old_raw_fw_name.starts_with(""); let has_fw_groups_and_title = old_raw_fw_name.starts_with("");
@ -560,9 +560,7 @@ impl NetMDContext {
impl From<NetMDInterface> for NetMDContext { impl From<NetMDInterface> for NetMDContext {
fn from(value: NetMDInterface) -> Self { fn from(value: NetMDInterface) -> Self {
Self { Self { interface: value }
interface: value
}
} }
} }

View file

@ -4,11 +4,6 @@ use rand::RngCore;
use std::thread; use std::thread;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver}; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
#[cfg(target_family = "wasm")]
use gloo::worker::{Spawnable, reactor::{reactor, ReactorScope}};
#[cfg(target_family = "wasm")]
use futures::{sink::SinkExt, StreamExt};
use super::interface::DataEncryptorInput; use super::interface::DataEncryptorInput;
type DesEcbEnc = ecb::Decryptor<des::Des>; type DesEcbEnc = ecb::Decryptor<des::Des>;
@ -18,7 +13,7 @@ pub fn new_thread_encryptor(
_input: DataEncryptorInput, _input: DataEncryptorInput,
) -> UnboundedReceiver<(Vec<u8>, Vec<u8>, Vec<u8>)> { ) -> UnboundedReceiver<(Vec<u8>, Vec<u8>, Vec<u8>)> {
let (tx, rx) = unbounded_channel::<(Vec<u8>, Vec<u8>, Vec<u8>)>(); let (tx, rx) = unbounded_channel::<(Vec<u8>, Vec<u8>, Vec<u8>)>();
let input = _input; let input = Box::from(_input);
thread::spawn(move || { thread::spawn(move || {
let mut iv = [0u8; 8]; let mut iv = [0u8; 8];
@ -81,13 +76,3 @@ pub fn new_thread_encryptor(
rx rx
} }
#[cfg(target_family = "wasm")]
#[reactor]
async fn Encryptor(mut scope: ReactorScope<u64, u64>) {
while let Some(m) = scope.next().await {
if scope.send(m.pow(2)).await.is_err() {
break;
}
}
}

View file

@ -53,8 +53,8 @@ impl WireFormat {
const fn frame_size(&self) -> u16 { const fn frame_size(&self) -> u16 {
match self { match self {
WireFormat::Pcm => 2048, WireFormat::Pcm => 2048,
WireFormat::L105kbps => 152,
WireFormat::LP2 => 192, WireFormat::LP2 => 192,
WireFormat::L105kbps => 152,
WireFormat::LP4 => 96, WireFormat::LP4 => 96,
} }
} }

View file

@ -150,7 +150,7 @@ pub fn sanitize_full_width_title(title: &str) -> String {
/// Convert a UTF-8 string to Shift-JIS for use on the player /// Convert a UTF-8 string to Shift-JIS for use on the player
pub fn to_sjis(sjis_str: &str) -> Vec<u8> { pub fn to_sjis(sjis_str: &str) -> Vec<u8> {
let sjis_string = SHIFT_JIS.encode(&sjis_str).0; let sjis_string = SHIFT_JIS.encode(sjis_str).0;
if validate_sjis(sjis_string.clone().into()) { if validate_sjis(sjis_string.clone().into()) {
return agressive_sanitize_title(sjis_str).into(); return agressive_sanitize_title(sjis_str).into();
@ -203,7 +203,7 @@ pub fn create_aea_header(options: AeaOptions) -> Vec<u8> {
.write_all(&vec![0; 256 - encoded_name.len()]) .write_all(&vec![0; 256 - encoded_name.len()])
.unwrap(); .unwrap();
header header
.write_u32::<LittleEndian>(options.sound_groups as u32) .write_u32::<LittleEndian>(options.sound_groups)
.unwrap(); .unwrap();
header.write_all(&[options.channels as u8, 0]).unwrap(); header.write_all(&[options.channels as u8, 0]).unwrap();
@ -235,11 +235,9 @@ pub fn create_aea_header(options: AeaOptions) -> Vec<u8> {
header.write_u32::<LittleEndian>(0).unwrap(); header.write_u32::<LittleEndian>(0).unwrap();
header.write_u32::<LittleEndian>(options.encrypted).unwrap();
header header
.write_u32::<LittleEndian>(options.encrypted as u32) .write_u32::<LittleEndian>(options.group_start)
.unwrap();
header
.write_u32::<LittleEndian>(options.group_start as u32)
.unwrap(); .unwrap();
// return the header // return the header
@ -295,9 +293,9 @@ pub struct RawTime {
pub frames: u64, pub frames: u64,
} }
impl Into<Duration> for RawTime { impl From<RawTime> for Duration {
fn into(self) -> std::time::Duration { fn from(val: RawTime) -> Self {
self.as_duration() val.as_duration()
} }
} }