| 1 | use std::time::Instant; |
| 2 | |
| 3 | use crate::{ |
| 4 | components::time_series::{AutoYAxisTimeGraph, TimeseriesConfig}, |
| 5 | options::config::disk_io_graph::DiskGraphLegend, |
| 6 | }; |
| 7 | |
| 8 | /// Runtime state for a disk I/O graph widget. |
| 9 | pub struct DiskIoGraphWidgetState { |
| 10 | /// The underlying time-series graph with automatic y-axis scaling. |
| 11 | pub graph: AutoYAxisTimeGraph, |
| 12 | /// Whether the read rate line is currently shown. |
| 13 | pub show_read: bool, |
| 14 | /// Whether the write rate line is currently shown. |
| 15 | pub show_write: bool, |
| 16 | /// Whether legend entries use device names or mount points. |
| 17 | pub legend: DiskGraphLegend, |
| 18 | /// Whether the y-axis uses a logarithmic scale. |
| 19 | pub use_log: bool, |
| 20 | } |
| 21 | |
| 22 | impl DiskIoGraphWidgetState { |
| 23 | pub fn new( |
| 24 | config: TimeseriesConfig, autohide_timer: Option<Instant>, show_read: bool, |
| 25 | show_write: bool, legend: DiskGraphLegend, use_log: bool, |
| 26 | ) -> Self { |
| 27 | Self { |
| 28 | graph: AutoYAxisTimeGraph::new(config, autohide_timer), |
| 29 | show_read, |
| 30 | show_write, |
| 31 | legend, |
| 32 | use_log, |
| 33 | } |
| 34 | } |
| 35 | } |