Skip to content

Commit 4f0a189

Browse files
committed
Fixed formatting in base.rs, fixed clippy warnings
1 parent 7630ca2 commit 4f0a189

File tree

5 files changed

+60
-261
lines changed

5 files changed

+60
-261
lines changed

src/netmd/base.rs

Lines changed: 48 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -14,238 +14,56 @@ use super::utils::cross_sleep;
1414
const BULK_WRITE_ENDPOINT: u8 = 0x02;
1515
const BULK_READ_ENDPOINT: u8 = 0x81;
1616

17+
nofmt::pls! { // Skip formatting the following info
1718
pub static DEVICE_IDS: &[DeviceId] = &[
18-
DeviceId {
19-
vendor_id: 0x04dd,
20-
product_id: 0x7202,
21-
name: Some("Sharp IM-MT899H"),
22-
},
23-
DeviceId {
24-
vendor_id: 0x04dd,
25-
product_id: 0x9013,
26-
name: Some("Sharp IM-DR400"),
27-
},
28-
DeviceId {
29-
vendor_id: 0x04dd,
30-
product_id: 0x9014,
31-
name: Some("Sharp IM-DR80"),
32-
},
33-
DeviceId {
34-
vendor_id: 0x054c,
35-
product_id: 0x0034,
36-
name: Some("Sony PCLK-XX"),
37-
},
38-
DeviceId {
39-
vendor_id: 0x054c,
40-
product_id: 0x0036,
41-
name: Some("Sony"),
42-
},
43-
DeviceId {
44-
vendor_id: 0x054c,
45-
product_id: 0x0075,
46-
name: Some("Sony MZ-N1"),
47-
},
48-
DeviceId {
49-
vendor_id: 0x054c,
50-
product_id: 0x007c,
51-
name: Some("Sony"),
52-
},
53-
DeviceId {
54-
vendor_id: 0x054c,
55-
product_id: 0x0080,
56-
name: Some("Sony LAM-1"),
57-
},
58-
DeviceId {
59-
vendor_id: 0x054c,
60-
product_id: 0x0081,
61-
name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780"),
62-
},
63-
DeviceId {
64-
vendor_id: 0x054c,
65-
product_id: 0x0084,
66-
name: Some("Sony MZ-N505"),
67-
},
68-
DeviceId {
69-
vendor_id: 0x054c,
70-
product_id: 0x0085,
71-
name: Some("Sony MZ-S1"),
72-
},
73-
DeviceId {
74-
vendor_id: 0x054c,
75-
product_id: 0x0086,
76-
name: Some("Sony MZ-N707"),
77-
},
78-
DeviceId {
79-
vendor_id: 0x054c,
80-
product_id: 0x008e,
81-
name: Some("Sony CMT-C7NT"),
82-
},
83-
DeviceId {
84-
vendor_id: 0x054c,
85-
product_id: 0x0097,
86-
name: Some("Sony PCGA-MDN1"),
87-
},
88-
DeviceId {
89-
vendor_id: 0x054c,
90-
product_id: 0x00ad,
91-
name: Some("Sony CMT-L7HD"),
92-
},
93-
DeviceId {
94-
vendor_id: 0x054c,
95-
product_id: 0x00c6,
96-
name: Some("Sony MZ-N10"),
97-
},
98-
DeviceId {
99-
vendor_id: 0x054c,
100-
product_id: 0x00c7,
101-
name: Some("Sony MZ-N910"),
102-
},
103-
DeviceId {
104-
vendor_id: 0x054c,
105-
product_id: 0x00c8,
106-
name: Some("Sony MZ-N710/NF810"),
107-
},
108-
DeviceId {
109-
vendor_id: 0x054c,
110-
product_id: 0x00c9,
111-
name: Some("Sony MZ-N510/N610"),
112-
},
113-
DeviceId {
114-
vendor_id: 0x054c,
115-
product_id: 0x00ca,
116-
name: Some("Sony MZ-NE410/NF520D"),
117-
},
118-
DeviceId {
119-
vendor_id: 0x054c,
120-
product_id: 0x00e7,
121-
name: Some("Sony CMT-M333NT/M373NT"),
122-
},
123-
DeviceId {
124-
vendor_id: 0x054c,
125-
product_id: 0x00eb,
126-
name: Some("Sony MZ-NE810/NE910"),
127-
},
128-
DeviceId {
129-
vendor_id: 0x054c,
130-
product_id: 0x0101,
131-
name: Some("Sony LAM"),
132-
},
133-
DeviceId {
134-
vendor_id: 0x054c,
135-
product_id: 0x0113,
136-
name: Some("Aiwa AM-NX1"),
137-
},
138-
DeviceId {
139-
vendor_id: 0x054c,
140-
product_id: 0x013f,
141-
name: Some("Sony MDS-S500"),
142-
},
143-
DeviceId {
144-
vendor_id: 0x054c,
145-
product_id: 0x014c,
146-
name: Some("Aiwa AM-NX9"),
147-
},
148-
DeviceId {
149-
vendor_id: 0x054c,
150-
product_id: 0x017e,
151-
name: Some("Sony MZ-NH1"),
152-
},
153-
DeviceId {
154-
vendor_id: 0x054c,
155-
product_id: 0x0180,
156-
name: Some("Sony MZ-NH3D"),
157-
},
158-
DeviceId {
159-
vendor_id: 0x054c,
160-
product_id: 0x0182,
161-
name: Some("Sony MZ-NH900"),
162-
},
163-
DeviceId {
164-
vendor_id: 0x054c,
165-
product_id: 0x0184,
166-
name: Some("Sony MZ-NH700/NH800"),
167-
},
168-
DeviceId {
169-
vendor_id: 0x054c,
170-
product_id: 0x0186,
171-
name: Some("Sony MZ-NH600"),
172-
},
173-
DeviceId {
174-
vendor_id: 0x054c,
175-
product_id: 0x0187,
176-
name: Some("Sony MZ-NH600D"),
177-
},
178-
DeviceId {
179-
vendor_id: 0x054c,
180-
product_id: 0x0188,
181-
name: Some("Sony MZ-N920"),
182-
},
183-
DeviceId {
184-
vendor_id: 0x054c,
185-
product_id: 0x018a,
186-
name: Some("Sony LAM-3"),
187-
},
188-
DeviceId {
189-
vendor_id: 0x054c,
190-
product_id: 0x01e9,
191-
name: Some("Sony MZ-DH10P"),
192-
},
193-
DeviceId {
194-
vendor_id: 0x054c,
195-
product_id: 0x0219,
196-
name: Some("Sony MZ-RH10"),
197-
},
198-
DeviceId {
199-
vendor_id: 0x054c,
200-
product_id: 0x021b,
201-
name: Some("Sony MZ-RH710/MZ-RH910"),
202-
},
203-
DeviceId {
204-
vendor_id: 0x054c,
205-
product_id: 0x021d,
206-
name: Some("Sony CMT-AH10"),
207-
},
208-
DeviceId {
209-
vendor_id: 0x054c,
210-
product_id: 0x022c,
211-
name: Some("Sony CMT-AH10"),
212-
},
213-
DeviceId {
214-
vendor_id: 0x054c,
215-
product_id: 0x023c,
216-
name: Some("Sony DS-HMD1"),
217-
},
218-
DeviceId {
219-
vendor_id: 0x054c,
220-
product_id: 0x0286,
221-
name: Some("Sony MZ-RH1"),
222-
},
223-
DeviceId {
224-
vendor_id: 0x054c,
225-
product_id: 0x011a,
226-
name: Some("Sony CMT-SE7"),
227-
},
228-
DeviceId {
229-
vendor_id: 0x054c,
230-
product_id: 0x0148,
231-
name: Some("Sony MDS-A1"),
232-
},
233-
DeviceId {
234-
vendor_id: 0x0b28,
235-
product_id: 0x1004,
236-
name: Some("Kenwood MDX-J9"),
237-
},
238-
DeviceId {
239-
vendor_id: 0x04da,
240-
product_id: 0x23b3,
241-
name: Some("Panasonic SJ-MR250"),
242-
},
243-
DeviceId {
244-
vendor_id: 0x04da,
245-
product_id: 0x23b6,
246-
name: Some("Panasonic SJ-MR270"),
247-
},
19+
DeviceId { vendor_id: 0x04dd, product_id: 0x7202, name: Some("Sharp IM-MT899H") },
20+
DeviceId { vendor_id: 0x04dd, product_id: 0x9013, name: Some("Sharp IM-DR400") },
21+
DeviceId { vendor_id: 0x04dd, product_id: 0x9014, name: Some("Sharp IM-DR80") },
22+
DeviceId { vendor_id: 0x054c, product_id: 0x0034, name: Some("Sony PCLK-XX") },
23+
DeviceId { vendor_id: 0x054c, product_id: 0x0036, name: Some("Sony") },
24+
DeviceId { vendor_id: 0x054c, product_id: 0x0075, name: Some("Sony MZ-N1") },
25+
DeviceId { vendor_id: 0x054c, product_id: 0x007c, name: Some("Sony") },
26+
DeviceId { vendor_id: 0x054c, product_id: 0x0080, name: Some("Sony LAM-1") },
27+
DeviceId { vendor_id: 0x054c, product_id: 0x0081, name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780") },
28+
DeviceId { vendor_id: 0x054c, product_id: 0x0084, name: Some("Sony MZ-N505") },
29+
DeviceId { vendor_id: 0x054c, product_id: 0x0085, name: Some("Sony MZ-S1") },
30+
DeviceId { vendor_id: 0x054c, product_id: 0x0086, name: Some("Sony MZ-N707") },
31+
DeviceId { vendor_id: 0x054c, product_id: 0x008e, name: Some("Sony CMT-C7NT") },
32+
DeviceId { vendor_id: 0x054c, product_id: 0x0097, name: Some("Sony PCGA-MDN1") },
33+
DeviceId { vendor_id: 0x054c, product_id: 0x00ad, name: Some("Sony CMT-L7HD") },
34+
DeviceId { vendor_id: 0x054c, product_id: 0x00c6, name: Some("Sony MZ-N10") },
35+
DeviceId { vendor_id: 0x054c, product_id: 0x00c7, name: Some("Sony MZ-N910") },
36+
DeviceId { vendor_id: 0x054c, product_id: 0x00c8, name: Some("Sony MZ-N710/NF810") },
37+
DeviceId { vendor_id: 0x054c, product_id: 0x00c9, name: Some("Sony MZ-N510/N610") },
38+
DeviceId { vendor_id: 0x054c, product_id: 0x00ca, name: Some("Sony MZ-NE410/NF520D") },
39+
DeviceId { vendor_id: 0x054c, product_id: 0x00e7, name: Some("Sony CMT-M333NT/M373NT") },
40+
DeviceId { vendor_id: 0x054c, product_id: 0x00eb, name: Some("Sony MZ-NE810/NE910") },
41+
DeviceId { vendor_id: 0x054c, product_id: 0x0101, name: Some("Sony LAM") },
42+
DeviceId { vendor_id: 0x054c, product_id: 0x0113, name: Some("Aiwa AM-NX1") },
43+
DeviceId { vendor_id: 0x054c, product_id: 0x013f, name: Some("Sony MDS-S500") },
44+
DeviceId { vendor_id: 0x054c, product_id: 0x014c, name: Some("Aiwa AM-NX9") },
45+
DeviceId { vendor_id: 0x054c, product_id: 0x017e, name: Some("Sony MZ-NH1") },
46+
DeviceId { vendor_id: 0x054c, product_id: 0x0180, name: Some("Sony MZ-NH3D") },
47+
DeviceId { vendor_id: 0x054c, product_id: 0x0182, name: Some("Sony MZ-NH900") },
48+
DeviceId { vendor_id: 0x054c, product_id: 0x0184, name: Some("Sony MZ-NH700/NH800") },
49+
DeviceId { vendor_id: 0x054c, product_id: 0x0186, name: Some("Sony MZ-NH600") },
50+
DeviceId { vendor_id: 0x054c, product_id: 0x0187, name: Some("Sony MZ-NH600D") },
51+
DeviceId { vendor_id: 0x054c, product_id: 0x0188, name: Some("Sony MZ-N920") },
52+
DeviceId { vendor_id: 0x054c, product_id: 0x018a, name: Some("Sony LAM-3") },
53+
DeviceId { vendor_id: 0x054c, product_id: 0x01e9, name: Some("Sony MZ-DH10P") },
54+
DeviceId { vendor_id: 0x054c, product_id: 0x0219, name: Some("Sony MZ-RH10") },
55+
DeviceId { vendor_id: 0x054c, product_id: 0x021b, name: Some("Sony MZ-RH710/MZ-RH910") },
56+
DeviceId { vendor_id: 0x054c, product_id: 0x021d, name: Some("Sony CMT-AH10") },
57+
DeviceId { vendor_id: 0x054c, product_id: 0x022c, name: Some("Sony CMT-AH10") },
58+
DeviceId { vendor_id: 0x054c, product_id: 0x023c, name: Some("Sony DS-HMD1") },
59+
DeviceId { vendor_id: 0x054c, product_id: 0x0286, name: Some("Sony MZ-RH1") },
60+
DeviceId { vendor_id: 0x054c, product_id: 0x011a, name: Some("Sony CMT-SE7") },
61+
DeviceId { vendor_id: 0x054c, product_id: 0x0148, name: Some("Sony MDS-A1") },
62+
DeviceId { vendor_id: 0x0b28, product_id: 0x1004, name: Some("Kenwood MDX-J9") },
63+
DeviceId { vendor_id: 0x04da, product_id: 0x23b3, name: Some("Panasonic SJ-MR250") },
64+
DeviceId { vendor_id: 0x04da, product_id: 0x23b6, name: Some("Panasonic SJ-MR270") },
24865
];
66+
}
24967

25068
pub static DEVICE_IDS_CROSSUSB: Lazy<Box<[cross_usb::DeviceFilter]>> = Lazy::new(|| {
25169
DEVICE_IDS

src/netmd/commands.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ impl NetMDContext {
409409
let old_raw_name = self.interface.raw_disc_title(false).await?;
410410
let old_raw_fw_name = self.interface.raw_disc_title(true).await?;
411411

412-
let has_groups = old_raw_name.find("//").is_some();
413-
let has_fw_groups = old_raw_fw_name.find("//").is_some();
412+
let has_groups = old_raw_name.contains("//");
413+
let has_fw_groups = old_raw_fw_name.contains("//");
414414

415415
let has_groups_and_title = old_raw_name.starts_with("0;");
416416
let has_fw_groups_and_title = old_raw_fw_name.starts_with("0;");
@@ -560,9 +560,7 @@ impl NetMDContext {
560560

561561
impl From<NetMDInterface> for NetMDContext {
562562
fn from(value: NetMDInterface) -> Self {
563-
Self {
564-
interface: value
565-
}
563+
Self { interface: value }
566564
}
567565
}
568566

src/netmd/encryption.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ use rand::RngCore;
44
use std::thread;
55
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
66

7-
#[cfg(target_family = "wasm")]
8-
use gloo::worker::{Spawnable, reactor::{reactor, ReactorScope}};
9-
#[cfg(target_family = "wasm")]
10-
use futures::{sink::SinkExt, StreamExt};
11-
127
use super::interface::DataEncryptorInput;
138

149
type DesEcbEnc = ecb::Decryptor<des::Des>;
@@ -18,7 +13,7 @@ pub fn new_thread_encryptor(
1813
_input: DataEncryptorInput,
1914
) -> UnboundedReceiver<(Vec<u8>, Vec<u8>, Vec<u8>)> {
2015
let (tx, rx) = unbounded_channel::<(Vec<u8>, Vec<u8>, Vec<u8>)>();
21-
let input = _input;
16+
let input = Box::from(_input);
2217

2318
thread::spawn(move || {
2419
let mut iv = [0u8; 8];
@@ -81,13 +76,3 @@ pub fn new_thread_encryptor(
8176

8277
rx
8378
}
84-
85-
#[cfg(target_family = "wasm")]
86-
#[reactor]
87-
async fn Encryptor(mut scope: ReactorScope<u64, u64>) {
88-
while let Some(m) = scope.next().await {
89-
if scope.send(m.pow(2)).await.is_err() {
90-
break;
91-
}
92-
}
93-
}

src/netmd/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ impl WireFormat {
5353
const fn frame_size(&self) -> u16 {
5454
match self {
5555
WireFormat::Pcm => 2048,
56-
WireFormat::L105kbps => 152,
5756
WireFormat::LP2 => 192,
57+
WireFormat::L105kbps => 152,
5858
WireFormat::LP4 => 96,
5959
}
6060
}

src/netmd/utils.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub fn sanitize_full_width_title(title: &str) -> String {
150150

151151
/// Convert a UTF-8 string to Shift-JIS for use on the player
152152
pub fn to_sjis(sjis_str: &str) -> Vec<u8> {
153-
let sjis_string = SHIFT_JIS.encode(&sjis_str).0;
153+
let sjis_string = SHIFT_JIS.encode(sjis_str).0;
154154

155155
if validate_sjis(sjis_string.clone().into()) {
156156
return agressive_sanitize_title(sjis_str).into();
@@ -203,7 +203,7 @@ pub fn create_aea_header(options: AeaOptions) -> Vec<u8> {
203203
.write_all(&vec![0; 256 - encoded_name.len()])
204204
.unwrap();
205205
header
206-
.write_u32::<LittleEndian>(options.sound_groups as u32)
206+
.write_u32::<LittleEndian>(options.sound_groups)
207207
.unwrap();
208208
header.write_all(&[options.channels as u8, 0]).unwrap();
209209

@@ -235,11 +235,9 @@ pub fn create_aea_header(options: AeaOptions) -> Vec<u8> {
235235

236236
header.write_u32::<LittleEndian>(0).unwrap();
237237

238+
header.write_u32::<LittleEndian>(options.encrypted).unwrap();
238239
header
239-
.write_u32::<LittleEndian>(options.encrypted as u32)
240-
.unwrap();
241-
header
242-
.write_u32::<LittleEndian>(options.group_start as u32)
240+
.write_u32::<LittleEndian>(options.group_start)
243241
.unwrap();
244242

245243
// return the header
@@ -295,9 +293,9 @@ pub struct RawTime {
295293
pub frames: u64,
296294
}
297295

298-
impl Into<Duration> for RawTime {
299-
fn into(self) -> std::time::Duration {
300-
self.as_duration()
296+
impl From<RawTime> for Duration {
297+
fn from(val: RawTime) -> Self {
298+
val.as_duration()
301299
}
302300
}
303301

0 commit comments

Comments
 (0)