refactor: generalize CpuGraph -> Graph
This commit is contained in:
parent
93de64f4b9
commit
96a972f9f0
2 changed files with 14 additions and 14 deletions
|
|
@ -4,9 +4,9 @@ use iced::{
|
|||
};
|
||||
use smol::Timer;
|
||||
|
||||
use crate::{app::cpu_graph::CpuGraph, sysinfo_snapshot::SysinfoSnapshot};
|
||||
use crate::{app::graph::Graph, sysinfo_snapshot::SysinfoSnapshot};
|
||||
|
||||
mod cpu_graph;
|
||||
mod graph;
|
||||
|
||||
enum Message {
|
||||
Info(SysinfoSnapshot),
|
||||
|
|
@ -14,8 +14,8 @@ enum Message {
|
|||
|
||||
#[derive(Default)]
|
||||
struct State {
|
||||
total_cpu_graph: CpuGraph,
|
||||
cpu_graphs: Vec<CpuGraph>,
|
||||
total_cpu_graph: Graph,
|
||||
cpu_graphs: Vec<Graph>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
|
|
@ -51,12 +51,12 @@ impl State {
|
|||
self.cpu_graphs = snapshot
|
||||
.cpus
|
||||
.into_iter()
|
||||
.map(|usage| CpuGraph::new(usage))
|
||||
.map(|value| Graph::new(value))
|
||||
.collect();
|
||||
} else {
|
||||
for (graph, usage) in self.cpu_graphs.iter_mut().zip(snapshot.cpus.into_iter())
|
||||
for (graph, value) in self.cpu_graphs.iter_mut().zip(snapshot.cpus.into_iter())
|
||||
{
|
||||
graph.update(usage);
|
||||
graph.update(value);
|
||||
graph.cache.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue