Skip to content

Commit

Permalink
code format, color change
Browse files Browse the repository at this point in the history
  • Loading branch information
aeghn committed Jan 6, 2025
1 parent 773771c commit f651b22
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/resource/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Resource for ResDrive {
fn do_sensor(req: Self::Req) -> AResult<SensorResultType> {
let data = DriveData::new(&req);
let partitions = Partition::fetch()?;
Ok(SensorResultType::SyncResult(SensorRsp::DRIVE(
Ok(SensorResultType::SyncResult(SensorRsp::Drive(
ResDriveRsp {
data: data,
partitions: Some(partitions),
Expand Down
12 changes: 6 additions & 6 deletions src/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub enum SensorRsp {
CPU(CpuData),
Memory(MemoryData),
GPU(AResult<GpuData>),
DRIVE(ResDriveRsp),
Drive(ResDriveRsp),
Network(NetworkData),
Battery(Arc<BatteryData>),
Process(ProcessRsp),
Expand All @@ -127,10 +127,10 @@ impl SensorRsp {
match self {
SensorRsp::CPU(_) => "CPU",
SensorRsp::Memory(_) => "MEM",
SensorRsp::GPU(g) => g.as_ref().map_or("GPU=====", |e| &e.id),
SensorRsp::DRIVE(drive) => drive.data.inner.sysfs_path.as_path().to_str().unwrap(),
SensorRsp::Network(net) => net.hw_address.as_ref().unwrap(),
SensorRsp::Battery(bat) => bat.inner.sysfs_path.as_path().to_str().unwrap(),
SensorRsp::GPU(res) => res.as_ref().map_or("GPU", |e| &e.id),
SensorRsp::Drive(rsp) => rsp.data.inner.sysfs_path.as_path().to_str().unwrap_or("drive"),
SensorRsp::Network(data) => data.sysfs_path.as_str(),
SensorRsp::Battery(data) => data.inner.sysfs_path.as_path().to_str().unwrap_or("battery"),
SensorRsp::Process(_) => "process",
}
}
Expand Down Expand Up @@ -320,7 +320,7 @@ impl ResourceType {
}
}
}
SensorRsp::DRIVE(data) => {
SensorRsp::Drive(data) => {
if let ResourceType::Drive(rt) = self {
if rsp_id == rt.get_id() {
rt.update_data(data);
Expand Down
1 change: 1 addition & 0 deletions src/resource/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl Resource for ResNetwork {
is_virtual: _,
display_name: _,
hw_address: _,
sysfs_path: _,
} = data;

if let (Some(old_time), Some(old_received_bytes), Some(old_sent_bytes)) = (
Expand Down
4 changes: 2 additions & 2 deletions src/resource/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl ProcessCell {
None => {
return s_label(
&self.keep_width(conver_storage_width4(0.).as_str()),
Style::new().fg(Color::Gray),
Style::new().fg(Color::Blue),
)
}
},
Expand All @@ -363,7 +363,7 @@ impl ProcessCell {
None => {
return s_label(
&self.keep_width(conver_storage_width4(0.).as_str()),
Style::new().fg(Color::Gray),
Style::new().fg(Color::Blue),
)
}
},
Expand Down
7 changes: 3 additions & 4 deletions src/sensor/network.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::{
collections::HashMap,
ffi::OsString,
fmt::Display,
path::{Path, PathBuf},
collections::HashMap, ffi::OsString, fmt::Display, path::{Path, PathBuf}
};

use anyhow::{Context, Result};
Expand All @@ -13,6 +10,7 @@ use super::{pci::get_device, Sensor};

#[derive(Debug)]
pub struct NetworkData {
pub sysfs_path: String,
pub hw_address: Option<String>,
pub is_virtual: bool,
pub received_bytes: Result<usize>,
Expand All @@ -28,6 +26,7 @@ impl NetworkData {
let display_name = inner.display_name();

Self {
sysfs_path: inner.sysfs_path.to_filepath(),
hw_address: inner.hw_address.clone(),
is_virtual,
received_bytes,
Expand Down
2 changes: 1 addition & 1 deletion src/view/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Default for Theme {
fn default() -> Self {
Self {
fg: Color::Reset,
label_fg: Color::Gray,
label_fg: Color::DarkGray,
}
}
}
Expand Down

0 comments on commit f651b22

Please sign in to comment.