## Upcoming Changes
+## 0.1.12
+
+Some refactoring of the code related to colorizing the netgraph.
+
## 0.1.11
Use pango markup to colorize the netgraph, making it look cleaner.
mod proc;
mod swaybar_object;
+use std::fmt::Write as FMTWrite;
use std::io::{self, Write};
use std::time::Duration;
use swaybar_object::*;
for item in graph_items.iter() {
match item.get_value_type() {
proc::GraphItemType::Download => {
- text += &("<span color=\"#ff8888ff\">".to_owned()
- + &item.get_value().to_string()
- + "</span>");
+ write!(
+ &mut text,
+ "<span color=\"#ff8888ff\">{}</span>",
+ item.get_value()
+ )?;
}
proc::GraphItemType::Upload => {
- text += &("<span color=\"#88ff88ff\">".to_owned()
- + &item.get_value().to_string()
- + "</span>");
+ write!(
+ &mut text,
+ "<span color=\"#88ff88ff\">{}</span>",
+ item.get_value()
+ )?;
}
proc::GraphItemType::Both => {
- text += &("<span color=\"#ffff88ff\">".to_owned()
- + &item.get_value().to_string()
- + "</span>");
+ write!(
+ &mut text,
+ "<span color=\"#ffff88ff\">{}</span>",
+ item.get_value()
+ )?;
}
}
}
pub fn get_netstring(
&mut self,
graph_max_opt: Option<f64>,
- ) -> Result<(String, Vec<GraphItem>, usize, String), Error> {
+ ) -> Result<(String, &Vec<GraphItem>, usize, String), Error> {
let down_diff: f64 = if self.down > self.prev_down {
let value = (self.down - self.prev_down) as f64;
self.prev_down = self.down;
}
}
- Ok((output, self.graph.clone(), history_max_idx, diff_max_string))
+ Ok((output, &self.graph, history_max_idx, diff_max_string))
}
}