| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 2 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, |
| 3 | timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#}, |
| 4 | }; |
| 5 | |
| 6 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{ |
| 7 | Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, |
| 8 | layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::{Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#, Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}, |
| 9 | stylerust-analyzer cargo ratatui-core 0.1.2 style/::Stylerust-analyzer cargo ratatui-core 0.1.2 style/Style#, |
| 10 | }; |
| 11 | use rustc_hashrust-analyzer cargo rustc-hash 2.1.3 crate/::FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#; |
| 12 | use timelessrust-analyzer cargo timeless 0.1.0 crate/::datarust-analyzer cargo timeless 0.1.0 data/::ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#; |
| 13 | |
| 14 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 15 | apprust-analyzer cargo bottom 0.14.9 app/::Apprust-analyzer cargo bottom 0.14.9 app/App#, |
| 16 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 17 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 18 | componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::time_seriesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/::{AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#, ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#, GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#, LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#}, |
| 19 | drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label()., |
| 20 | }, |
| 21 | componentsrust-analyzer cargo bottom 0.14.9 components/::time_seriesrust-analyzer cargo bottom 0.14.9 components/time_series/::GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#, |
| 22 | optionsrust-analyzer cargo bottom 0.14.9 options/::configrust-analyzer cargo bottom 0.14.9 options/config/::disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/::DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#, |
| 23 | utilsrust-analyzer cargo bottom 0.14.9 utils/::data_unitsrust-analyzer cargo bottom 0.14.9 utils/data_units/::*, |
| 24 | }; |
| 25 | |
| 26 | impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# { |
| 27 | pub fn draw_disk_io_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/impl#[Painter]draw_disk_io_graph().( |
| 28 | &self, f: &mut Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#<'_>, app_state: &mut Apprust-analyzer cargo bottom 0.14.9 app/App#, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64, |
| 29 | ) { |
| 30 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_state) = app_state |
| 31 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 32 | .disk_io_graph_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#disk_io_graph_state. |
| 33 | .get_mut_widget_staterust-analyzer cargo bottom 0.14.9 app/states/impl#[DiskIoGraphStates]get_mut_widget_state().(widget_id) |
| 34 | { |
| 35 | let shared_data = app_state.data_storerust-analyzer cargo bottom 0.14.9 app/App#data_store..get_datarust-analyzer cargo bottom 0.14.9 app/data/store/impl#[DataStore]get_data().(); |
| 36 | let read_data = &shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read.; |
| 37 | let write_data = &shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..disk_io_writerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_write.; |
| 38 | let times = &shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time.; |
| 39 | |
| 40 | let mount_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<&str, &str> = shared_data |
| 41 | .disk_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#disk_harvest. |
| 42 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 43 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|d| (d.namerust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#name..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), d.mount_pointrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#mount_point..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())) |
| 44 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 45 | |
| 46 | let border_style = self.get_border_stylerust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_border_style().(widget_id, app_state.current_widgetrust-analyzer cargo bottom 0.14.9 app/App#current_widget..widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.); |
| 47 | let graph_state = widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#graph..state_mutrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]state_mut().(); |
| 48 | let hide_x_labels = should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label().( |
| 49 | app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..hide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#hide_time., |
| 50 | app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..autohide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#autohide_time., |
| 51 | graph_state.autohide_timer_mutrust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]autohide_timer_mut().(), |
| 52 | draw_loc, |
| 53 | ); |
| 54 | let current_display_time = graph_state.current_display_timerust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]current_display_time().(); |
| 55 | |
| 56 | let show_read = widget_state.show_readrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#show_read.; |
| 57 | let show_write = widget_state.show_writerust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#show_write.; |
| 58 | let use_log = widget_state.use_logrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#use_log.; |
| 59 | let legend_type = &widget_state.legendrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#legend.; |
| 60 | |
| 61 | let mut device_names: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = read_data |
| 62 | .keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().() |
| 63 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|name| { |
| 64 | let has_read_data = || { |
| 65 | read_data |
| 66 | .getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name) |
| 67 | .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|d| has_data_in_windowrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/has_data_in_window().(d, times, current_display_time)) |
| 68 | }; |
| 69 | |
| 70 | // If there is a mount point and we're in mount legend mode, it must be non-empty |
| 71 | // (i.e. actually mounted), or we will short-circuit and ignore it. |
| 72 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mount_point) = mount_map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) { |
| 73 | match legend_type { |
| 74 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Diskrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Disk# => true, |
| 75 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Mountrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Mount# => !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().mount_point.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() && has_read_data(), |
| 76 | } |
| 77 | } else { |
| 78 | match legend_type { |
| 79 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Diskrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Disk# => { |
| 80 | // Otherwise, it may have _previously_ been a valid mount point, so keep showing it until it ages out. |
| 81 | has_read_data() |
| 82 | } |
| 83 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Mountrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Mount# => { |
| 84 | // Since it would be misleading in this case, just skip it in mount mode. |
| 85 | false |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | }) |
| 90 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 91 | device_names.sort_unstablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]sort_unstable().(); |
| 92 | |
| 93 | // Compute y_max across all visible series. |
| 94 | let mut visible_sources: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&_> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 95 | for name in &device_names { |
| 96 | if show_read && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data) = read_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name) { |
| 97 | visible_sources.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(data); |
| 98 | } |
| 99 | if show_write && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data) = write_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name) { |
| 100 | visible_sources.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(data); |
| 101 | } |
| 102 | } |
| 103 | let y_max = widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#graph..y_maxrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]y_max().(visible_sources.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), times); |
| 104 | |
| 105 | let (adjusted_y_max, y_labels) = if use_log { |
| 106 | adjust_disk_io_logrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/adjust_disk_io_log().(y_max) |
| 107 | } else { |
| 108 | adjust_disk_io_linearrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/adjust_disk_io_linear().(y_max) |
| 109 | }; |
| 110 | |
| 111 | let legend_constraints = LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints# { |
| 112 | widthrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#width.: Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Ratiorust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Ratio#(9, 10), |
| 113 | heightrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints#height.: Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Ratiorust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Ratio#(1, 2), |
| 114 | }; |
| 115 | |
| 116 | // Removed devices still visible in the window show "N/A". |
| 117 | // TODO: Maybe should make it so the colour is based on entry name? As then it may shift. |
| 118 | let read_colours = &self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..disk_io_read_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#disk_io_read_colour_styles.; |
| 119 | let write_colours = &self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..disk_io_write_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#disk_io_write_colour_styles.; |
| 120 | |
| 121 | // Pad the device/mount labels to the widest visible one so the rate columns |
| 122 | // line up in the legend (the rate itself is already fixed-width). |
| 123 | let name_width = device_names |
| 124 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 125 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|name| match legend_type { |
| 126 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Diskrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Disk# => name.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(), |
| 127 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Mountrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Mount# => mount_map |
| 128 | .getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) |
| 129 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|mount| mount.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()) |
| 130 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0), |
| 131 | }) |
| 132 | .maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max().() |
| 133 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0); |
| 134 | |
| 135 | let mut graph_data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#<'_, f64>> = |
| 136 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(device_names.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2); |
| 137 | |
| 138 | for (idx, name) in device_names.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 139 | let display_name = match legend_type { |
| 140 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Diskrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Disk# => name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), |
| 141 | DiskGraphLegendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#::Mountrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskGraphLegend#Mount# => match mount_map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()).copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() { |
| 142 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mount) => mount, |
| 143 | // This wouldn't trigger anyway, we filter out devices without mount points in mount legend mode. |
| 144 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue, |
| 145 | }, |
| 146 | }; |
| 147 | |
| 148 | let is_active = mount_map.contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()); |
| 149 | |
| 150 | let read_values = show_read.thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| read_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name)).flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Option<T>>`]flatten().(); |
| 151 | let write_values = show_write.thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| write_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name)).flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Option<T>>`]flatten().(); |
| 152 | |
| 153 | let read_style = if read_colours.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 154 | Stylerust-analyzer cargo ratatui-core 0.1.2 style/Style#::defaultrust-analyzer cargo ratatui-core 0.1.2 style/impl#[Style][Default]default().() |
| 155 | } else { |
| 156 | read_colours[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().read_colours.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 157 | }; |
| 158 | let write_style = if write_colours.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 159 | Stylerust-analyzer cargo ratatui-core 0.1.2 style/Style#::defaultrust-analyzer cargo ratatui-core 0.1.2 style/impl#[Style][Default]default().() |
| 160 | } else { |
| 161 | write_colours[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().write_colours.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 162 | }; |
| 163 | |
| 164 | // TODO: Combine into one line; probably need to add some kind of multi-styled GraphData. |
| 165 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(values) = read_values { |
| 166 | let rate = if is_active { |
| 167 | format_rate_fixedrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/format_rate_fixed().(values.lastrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]last().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0.0)) |
| 168 | } else { |
| 169 | " N/A".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 170 | }; |
| 171 | graph_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().( |
| 172 | GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`][Default]default().() |
| 173 | .namerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]name().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{display_name:<name_width$} R:{rate}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 174 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(read_style) |
| 175 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 176 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(values), |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(values) = write_values { |
| 181 | let rate = if is_active { |
| 182 | format_rate_fixedrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/format_rate_fixed().(values.lastrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]last().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0.0)) |
| 183 | } else { |
| 184 | " N/A".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 185 | }; |
| 186 | graph_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().( |
| 187 | GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`][Default]default().() |
| 188 | .namerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]name().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{display_name:<name_width$} W:{rate}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 189 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(write_style) |
| 190 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 191 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(values), |
| 192 | ); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | let marker = self.get_markerrust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_marker().(app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_dotrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_dot.); |
| 197 | let y_bounds = AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#::Maxrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#Max#(adjusted_y_max); |
| 198 | let scaling = if use_log { |
| 199 | ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#::Log2rust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#Log2# |
| 200 | } else { |
| 201 | ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#::Linearrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#Linear# |
| 202 | }; |
| 203 | let y_labels: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> = y_labels.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 204 | |
| 205 | widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#graph..drawrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]draw().( |
| 206 | f, |
| 207 | draw_loc, |
| 208 | GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx# { |
| 209 | titlerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title.: " Disk I/O ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 210 | border_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_style., |
| 211 | title_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..widget_title_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#widget_title_style., |
| 212 | graph_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#graph_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..graph_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#graph_style., |
| 213 | general_widget_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#general_widget_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..general_widget_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#general_widget_style., |
| 214 | border_typerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_type.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..border_typerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#border_type., |
| 215 | markerrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#marker., |
| 216 | hide_x_labelsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#hide_x_labels., |
| 217 | is_selectedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_selected.: app_state.current_widgetrust-analyzer cargo bottom 0.14.9 app/App#current_widget..widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().widget_id, |
| 218 | is_expandedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_expanded.: app_state.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded., |
| 219 | legend_positionrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_position.: app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..disk_io_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disk_io_legend_position., |
| 220 | legend_constraintsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_constraints.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(legend_constraints), |
| 221 | }, |
| 222 | y_bounds, |
| 223 | &y_labels, |
| 224 | scaling, |
| 225 | graph_data, |
| 226 | ); |
| 227 | } |
| 228 | |
| 229 | if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() |
| 230 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget) = app_state.widget_maprust-analyzer cargo bottom 0.14.9 app/App#widget_map..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&widget_id) |
| 231 | { |
| 232 | widget.top_left_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#top_left_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.)); |
| 233 | widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = |
| 234 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.)); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | /// Returns true if `data` has at least one real (non-gap) data point within the |
| 240 | /// visible time window defined by `current_display_time` milliseconds from the end |
| 241 | /// of `times`. |
| 242 | fn has_data_in_windowrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/has_data_in_window().<F: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64>>( |
| 243 | data: &ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<F>, times: &[Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#], current_display_time: u64, |
| 244 | ) -> bool { |
| 245 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&last_time) = times.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() else { |
| 246 | return false; |
| 247 | }; |
| 248 | let display_duration = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(current_display_time); |
| 249 | let oldest = last_time.checked_subrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]checked_sub().(display_duration).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(last_time); |
| 250 | data.iter_along_baserust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]iter_along_base().(times) |
| 251 | .next_backrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedDataIter<I>`][DoubleEndedIterator]next_back().() |
| 252 | .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|(t, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().oldest) |
| 253 | } |
| 254 | |
| 255 | /// Format a byte/s rate as a fixed-width string (always 11 chars, right-aligned) |
| 256 | /// to keep legend labels a stable width and prevent legend box shifting between frames. |
| 257 | fn format_rate_fixedrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/format_rate_fixed().(bytes_per_sec: f64) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 258 | let (val, unit) = if bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().KIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KIBI_LIMIT_F64. { |
| 259 | (bytes_per_sec, "B/s") |
| 260 | } else if bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().MEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEBI_LIMIT_F64. { |
| 261 | (bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().KIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KIBI_LIMIT_F64., "KiB/s") |
| 262 | } else if bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().GIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIBI_LIMIT_F64. { |
| 263 | (bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().MEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEBI_LIMIT_F64., "MiB/s") |
| 264 | } else if bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().TEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TEBI_LIMIT_F64. { |
| 265 | (bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().GIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIBI_LIMIT_F64., "GiB/s") |
| 266 | } else { |
| 267 | (bytes_per_sec rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().TEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TEBI_LIMIT_F64., "TiB/s") |
| 268 | }; |
| 269 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:>11}", formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{val:.1}{unit}")) |
| 270 | } |
| 271 | |
| 272 | fn adjust_disk_io_linearrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/adjust_disk_io_linear().(max_entry: f64) -> (f64, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 273 | let max_entry_upper = if max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().0.0 { |
| 274 | 1.0 |
| 275 | } else { |
| 276 | max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1.5 |
| 277 | }; |
| 278 | |
| 279 | let (max_value_scaled, unit) = if max_entry_upper rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().KIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KIBI_LIMIT_F64. { |
| 280 | (max_entry, "B/s") |
| 281 | } else if max_entry_upper rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().MEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEBI_LIMIT_F64. { |
| 282 | (max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().KIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KIBI_LIMIT_F64., "KiB/s") |
| 283 | } else if max_entry_upper rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().GIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIBI_LIMIT_F64. { |
| 284 | (max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().MEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEBI_LIMIT_F64., "MiB/s") |
| 285 | } else if max_entry_upper rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().TEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TEBI_LIMIT_F64. { |
| 286 | (max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().GIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIBI_LIMIT_F64., "GiB/s") |
| 287 | } else { |
| 288 | (max_entry rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().TEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TEBI_LIMIT_F64., "TiB/s") |
| 289 | }; |
| 290 | |
| 291 | let labels = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 292 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("0{unit}"), |
| 293 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", max_value_scaled *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). 0.5), |
| 294 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", max_value_scaled), |
| 295 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", max_value_scaled *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). 1.5), |
| 296 | ] |
| 297 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 298 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{s:>8}")) |
| 299 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 300 | |
| 301 | (max_entry_upper, labels) |
| 302 | } |
| 303 | |
| 304 | fn adjust_disk_io_logrust-analyzer cargo bottom 0.14.9 canvas/widgets/disk_io_graph/adjust_disk_io_log().(max_entry: f64) -> (f64, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 305 | use craterust-analyzer cargo bottom 0.14.9 crate/::utilsrust-analyzer cargo bottom 0.14.9 utils/::generalrust-analyzer cargo bottom 0.14.9 utils/general/::saturating_log2rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log2().; |
| 306 | |
| 307 | let log_max = saturating_log2rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log2().(max_entry); |
| 308 | |
| 309 | if log_max rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().LOG_MEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_MEBI_LIMIT. { |
| 310 | ( |
| 311 | LOG_MEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_MEBI_LIMIT., |
| 312 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![" 0B/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "1KiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "1MiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()], |
| 313 | ) |
| 314 | } else if log_max rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().LOG_GIBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_GIBI_LIMIT. { |
| 315 | ( |
| 316 | LOG_GIBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_GIBI_LIMIT., |
| 317 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 318 | " 0B/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 319 | "1KiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 320 | "1MiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 321 | "1GiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 322 | ], |
| 323 | ) |
| 324 | } else if log_max rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().LOG_TEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_TEBI_LIMIT. { |
| 325 | ( |
| 326 | LOG_TEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_TEBI_LIMIT., |
| 327 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 328 | " 0B/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 329 | "1KiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 330 | "1MiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 331 | "1GiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 332 | "1TiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 333 | ], |
| 334 | ) |
| 335 | } else { |
| 336 | ( |
| 337 | LOG_PEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_PEBI_LIMIT., |
| 338 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 339 | " 0B/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 340 | "1KiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 341 | "1MiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 342 | "1GiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 343 | "1TiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 344 | "1PiB/s".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 345 | ], |
| 346 | ) |
| 347 | } |
| 348 | } |