refactor: converge naming from main branch
This commit is contained in:
parent
20f68eaa60
commit
3fa2163366
2 changed files with 11 additions and 11 deletions
|
|
@ -7,21 +7,21 @@ use crate::app;
|
|||
const CYAN: Color = Color::from_rgb8(0, 255, 255);
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CpuGraph {
|
||||
pub struct Graph {
|
||||
pub cache: canvas::Cache,
|
||||
timeline: VecDeque<f32>,
|
||||
}
|
||||
|
||||
impl CpuGraph {
|
||||
pub fn update(&mut self, usage: f32) {
|
||||
self.timeline.push_back(usage);
|
||||
impl Graph {
|
||||
pub fn update(&mut self, value: f32) {
|
||||
self.timeline.push_back(value);
|
||||
if self.timeline.len() > 1000 {
|
||||
self.timeline.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl canvas::Program<app::Message, Theme, Renderer> for CpuGraph {
|
||||
impl canvas::Program<app::Message, Theme, Renderer> for Graph {
|
||||
type State = ();
|
||||
fn draw(
|
||||
&self,
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
use iced::{
|
||||
Color, Element, Length, Renderer, Task, Theme, application, futures::SinkExt, stream::channel,
|
||||
theme, widget,
|
||||
Color, Element, Length, Renderer, Task, Theme, application, futures::SinkExt, stream, theme,
|
||||
widget,
|
||||
};
|
||||
use smol::Timer;
|
||||
|
||||
use crate::app::cpu_graph::CpuGraph;
|
||||
use crate::app::graph::Graph;
|
||||
|
||||
mod cpu_graph;
|
||||
mod graph;
|
||||
|
||||
enum Message {
|
||||
Cpu(f32),
|
||||
}
|
||||
|
||||
struct State {
|
||||
cpu_graph: CpuGraph,
|
||||
cpu_graph: Graph,
|
||||
}
|
||||
|
||||
impl State {
|
||||
|
|
@ -23,7 +23,7 @@ impl State {
|
|||
cpu_graph: Default::default(),
|
||||
},
|
||||
Task::run(
|
||||
channel(1, async |mut sender| {
|
||||
stream::channel(1, async |mut sender| {
|
||||
let mut sys = sysinfo::System::new();
|
||||
let refreshes = sysinfo::RefreshKind::nothing()
|
||||
.with_cpu(sysinfo::CpuRefreshKind::nothing().with_cpu_usage());
|
||||
|
|
|
|||
Loading…
Reference in a new issue