Skip to content

Commit 6b6f774

Browse files
fix: resolve clippy warnings - use derive macros and strip_prefix
1 parent 1b25168 commit 6b6f774

2 files changed

Lines changed: 9 additions & 49 deletions

File tree

src/adapters/secondary/system/linux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ impl LinuxSystemInfoProvider {
213213
existing_firmware: Option<String>,
214214
) -> (Option<String>, Option<String>) {
215215
// Extract controller name: "nvme0n1" -> "nvme0"
216-
let controller = if device_name.starts_with("nvme") {
217-
if let Some(pos) = device_name[4..].find('n') {
216+
let controller = if let Some(stripped) = device_name.strip_prefix("nvme") {
217+
if let Some(pos) = stripped.find('n') {
218218
&device_name[..4 + pos]
219219
} else {
220220
device_name

src/domain/entities.rs

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub struct HardwareInfo {
160160
}
161161

162162
/// CPU information
163-
#[derive(Debug, Serialize, Deserialize, Clone)]
163+
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
164164
pub struct CpuInfo {
165165
/// CPU model name
166166
pub model: String,
@@ -213,31 +213,6 @@ pub struct CpuInfo {
213213
pub detection_methods: Vec<String>,
214214
}
215215

216-
impl Default for CpuInfo {
217-
fn default() -> Self {
218-
Self {
219-
model: String::new(),
220-
cores: 0,
221-
threads: 0,
222-
sockets: 0,
223-
speed: String::new(),
224-
vendor: String::new(),
225-
architecture: String::new(),
226-
frequency_mhz: 0,
227-
frequency_min_mhz: None,
228-
frequency_max_mhz: None,
229-
cache_l1d_kb: None,
230-
cache_l1i_kb: None,
231-
cache_l2_kb: None,
232-
cache_l3_kb: None,
233-
flags: Vec::new(),
234-
microarchitecture: None,
235-
caches: Vec::new(),
236-
detection_methods: Vec::new(),
237-
}
238-
}
239-
}
240-
241216
impl CpuInfo {
242217
/// Set speed string from frequency_mhz
243218
pub fn set_speed_string(&mut self) {
@@ -313,7 +288,7 @@ pub struct StorageInfo {
313288
}
314289

315290
/// Storage type classification
316-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
291+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
317292
pub enum StorageType {
318293
/// NVMe SSD
319294
Nvme,
@@ -326,6 +301,7 @@ pub enum StorageType {
326301
/// Virtual device (should be filtered)
327302
Virtual,
328303
/// Unknown type
304+
#[default]
329305
Unknown,
330306
}
331307

@@ -358,12 +334,6 @@ impl StorageType {
358334
}
359335
}
360336

361-
impl Default for StorageType {
362-
fn default() -> Self {
363-
StorageType::Unknown
364-
}
365-
}
366-
367337
/// Storage device information
368338
#[derive(Debug, Serialize, Deserialize, Clone)]
369339
pub struct StorageDevice {
@@ -457,7 +427,7 @@ pub struct GpuInfo {
457427
}
458428

459429
/// GPU vendor classification
460-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
430+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
461431
pub enum GpuVendor {
462432
/// NVIDIA GPU
463433
Nvidia,
@@ -468,6 +438,7 @@ pub enum GpuVendor {
468438
/// Apple GPU (Apple Silicon)
469439
Apple,
470440
/// Unknown vendor
441+
#[default]
471442
Unknown,
472443
}
473444

@@ -494,12 +465,6 @@ impl GpuVendor {
494465
}
495466
}
496467

497-
impl Default for GpuVendor {
498-
fn default() -> Self {
499-
GpuVendor::Unknown
500-
}
501-
}
502-
503468
/// GPU device information
504469
#[derive(Debug, Serialize, Deserialize, Clone)]
505470
pub struct GpuDevice {
@@ -584,7 +549,7 @@ pub struct NetworkInfo {
584549
}
585550

586551
/// Network interface type classification
587-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
552+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
588553
pub enum NetworkInterfaceType {
589554
/// Physical Ethernet interface
590555
Ethernet,
@@ -607,15 +572,10 @@ pub enum NetworkInterfaceType {
607572
/// Macvlan interface
608573
Macvlan,
609574
/// Unknown type
575+
#[default]
610576
Unknown,
611577
}
612578

613-
impl Default for NetworkInterfaceType {
614-
fn default() -> Self {
615-
NetworkInterfaceType::Unknown
616-
}
617-
}
618-
619579
/// Network interface information
620580
#[derive(Debug, Serialize, Deserialize, Clone)]
621581
pub struct NetworkInterface {

0 commit comments

Comments
 (0)