| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::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#; |
| 2 | |
| 3 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{ |
| 4 | Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, |
| 5 | layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::{Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#, Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#, Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#, Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}, |
| 6 | textrust-analyzer cargo ratatui-core 0.1.2 text/::Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#, |
| 7 | widgetsrust-analyzer cargo ratatui 0.30.2 widgets/::{Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#, Tablerust-analyzer cargo ratatui-widgets 0.3.2 table/Table#}, |
| 8 | }; |
| 9 | |
| 10 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 11 | apprust-analyzer cargo bottom 0.14.9 app/::{Apprust-analyzer cargo bottom 0.14.9 app/App#, AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#, AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#}, |
| 12 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 13 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 14 | 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#}, |
| 15 | 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()., widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block().}, |
| 16 | widgetsrust-analyzer cargo bottom 0.14.9 canvas/widgets/::{PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#, calculate_packet_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/calculate_packet_info().}, |
| 17 | }, |
| 18 | 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#, |
| 19 | utilsrust-analyzer cargo bottom 0.14.9 utils/::{ |
| 20 | data_unitsrust-analyzer cargo bottom 0.14.9 utils/data_units/::*, |
| 21 | generalrust-analyzer cargo bottom 0.14.9 utils/general/::{saturating_log2rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log2()., saturating_log10rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log10().}, |
| 22 | }, |
| 23 | }; |
| 24 | |
| 25 | impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# { |
| 26 | pub fn draw_networkrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_network().( |
| 27 | &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, |
| 28 | ) { |
| 29 | if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_old_network_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_old_network_legend. { |
| 30 | const LEGEND_HEIGHTrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/LEGEND_HEIGHT.: u16 = 4; |
| 31 | let network_chunk = Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#::defaultrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout][Default]default().() |
| 32 | .directionrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]direction().(Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#::Verticalrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#Vertical#) |
| 33 | .marginrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]margin().(0) |
| 34 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().([ |
| 35 | Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]saturating_sub().(LEGEND_HEIGHTrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/LEGEND_HEIGHT.)), |
| 36 | Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(LEGEND_HEIGHTrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/LEGEND_HEIGHT.), |
| 37 | ]) |
| 38 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc); |
| 39 | |
| 40 | self.draw_network_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_network_graph().(f, app_state, network_chunk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., widget_id); |
| 41 | self.draw_old_network_labelsrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_old_network_labels().(f, app_state, network_chunk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., widget_id); |
| 42 | } else { |
| 43 | self.draw_network_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_network_graph().(f, app_state, draw_loc, widget_id); |
| 44 | } |
| 45 | |
| 46 | if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() { |
| 47 | // Update draw loc in widget map |
| 48 | // Note that in both cases, we always go to the same widget id so it's fine to |
| 49 | // do it like this lol. |
| 50 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network_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) { |
| 51 | network_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.)); |
| 52 | network_widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = |
| 53 | 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.)); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | pub fn draw_network_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_network_graph().( |
| 59 | &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, |
| 60 | ) { |
| 61 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network_widget_state) = |
| 62 | app_state.statesrust-analyzer cargo bottom 0.14.9 app/App#states..net_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#net_state..widget_statesrust-analyzer cargo bottom 0.14.9 app/states/NetState#widget_states..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) |
| 63 | { |
| 64 | 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().(); |
| 65 | let network_latest_data = &(shared_data.network_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#network_harvest.); |
| 66 | let rx_points = &(shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..rxrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#rx.); |
| 67 | let tx_points = &(shared_data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..txrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#tx.); |
| 68 | 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.); |
| 69 | |
| 70 | 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.); |
| 71 | let hide_x_labels = should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label().( |
| 72 | 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., |
| 73 | 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., |
| 74 | network_widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/network_graph/NetWidgetState#graph..state_mutrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]state_mut().().autohide_timer_mutrust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]autohide_timer_mut().(), |
| 75 | draw_loc, |
| 76 | ); |
| 77 | |
| 78 | let y_max = network_widget_state |
| 79 | .graphrust-analyzer cargo bottom 0.14.9 widgets/network_graph/NetWidgetState#graph. |
| 80 | .y_maxrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]y_max().([rx_points, tx_points].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().(), times); |
| 81 | let (adjusted_y_max, y_labels) = |
| 82 | adjust_network_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/adjust_network_data_point().(y_max, &app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields.); |
| 83 | 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); |
| 84 | |
| 85 | let use_old_network_legend = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_old_network_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_old_network_legend.; |
| 86 | let legend_constraints = if use_old_network_legend { |
| 87 | // Always hide it. Note that I could pass in `None` to the position as well but |
| 88 | // eh this works. |
| 89 | LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints# { |
| 90 | 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#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(0), |
| 91 | 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#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(0), |
| 92 | } |
| 93 | } else { |
| 94 | // Hide the legend if the width is 90% of the total widget width |
| 95 | // or the height is greater than 75% of the total widget height. |
| 96 | LegendConstraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/LegendConstraints# { |
| 97 | 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), |
| 98 | 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#(3, 4), |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | // TODO: Add support for clicking on legend to only show that value on chart. |
| 103 | let use_binary_prefix = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_use_binary_prefix.; |
| 104 | let unit_type = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_unit_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_unit_type.; |
| 105 | let unit = match unit_type { |
| 106 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte# => "B/s", |
| 107 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Bitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Bit# => "b/s", |
| 108 | }; |
| 109 | |
| 110 | let rx = get_unit_prefixrust-analyzer cargo bottom 0.14.9 utils/data_units/get_unit_prefix().(network_latest_data.rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx., use_binary_prefix); |
| 111 | let tx = get_unit_prefixrust-analyzer cargo bottom 0.14.9 utils/data_units/get_unit_prefix().(network_latest_data.txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx., use_binary_prefix); |
| 112 | let total_rx = convert_bitsrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bits().(network_latest_data.total_rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_rx., use_binary_prefix); |
| 113 | let total_tx = convert_bitsrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bits().(network_latest_data.total_txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_tx., use_binary_prefix); |
| 114 | |
| 115 | let graph_data = if use_old_network_legend { |
| 116 | let mut graph_data = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 117 | 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().() |
| 118 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 119 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(rx_points) |
| 120 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 121 | 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().() |
| 122 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 123 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(tx_points) |
| 124 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 125 | ]; |
| 126 | |
| 127 | graph_data.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().([ |
| 128 | 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().().stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_rx_style.), |
| 129 | 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().().stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_tx_style.), |
| 130 | ]); |
| 131 | |
| 132 | graph_data |
| 133 | } else { |
| 134 | let rx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}{}", rx.0, rx.1, unit); |
| 135 | let tx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}{}", tx.0, tx.1, unit); |
| 136 | let total_rx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", total_rx.0, total_rx.1); |
| 137 | let total_tx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", total_tx.0, total_tx.1); |
| 138 | |
| 139 | // Add packets information if enabled and there's enough room. |
| 140 | const MAX_LEGEND_WIDTHrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/MAX_LEGEND_WIDTH.: u16 = 70; |
| 141 | let approx_legend_width = draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().4; |
| 142 | |
| 143 | // FIXME: I'm not really a huge fan of this - I think it may be better to just |
| 144 | // not support this and allow for more easily spawning a |
| 145 | // separate legend table (basically old legend). |
| 146 | if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_show_packetsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_show_packets. |
| 147 | && approx_legend_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().MAX_LEGEND_WIDTHrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/MAX_LEGEND_WIDTH. |
| 148 | { |
| 149 | let PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo# { |
| 150 | rx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#rx_packet_rate., |
| 151 | tx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#tx_packet_rate., |
| 152 | avg_rx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_rx_packet_size., |
| 153 | avg_tx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_tx_packet_size., |
| 154 | } = calculate_packet_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/calculate_packet_info().(network_latest_data, use_binary_prefix); |
| 155 | |
| 156 | let avg_rx_packet_size_label = |
| 157 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", avg_rx_packet_size.0, avg_rx_packet_size.1); |
| 158 | let avg_tx_packet_size_label = |
| 159 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", avg_tx_packet_size.0, avg_tx_packet_size.1); |
| 160 | |
| 161 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 162 | 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().() |
| 163 | .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!!("RX: {rx_label:<10} All: {total_rx_label:<8} Packets: {rx_packet_rate:>8}pkt/s Avg: {avg_rx_packet_size_label}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 164 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 165 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(rx_points) |
| 166 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 167 | 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().() |
| 168 | .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!!("TX: {tx_label:<10} All: {total_tx_label:<8} Packets: {tx_packet_rate:>8}pkt/s Avg: {avg_tx_packet_size_label}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 169 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 170 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(tx_points) |
| 171 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 172 | ] |
| 173 | } else { |
| 174 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 175 | 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().() |
| 176 | .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!!("RX: {rx_label:<10} All: {total_rx_label}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 177 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 178 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(rx_points) |
| 179 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 180 | 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().() |
| 181 | .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!!("TX: {tx_label:<10} All: {total_tx_label}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 182 | .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(times) |
| 183 | .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(tx_points) |
| 184 | .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 185 | ] |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | 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.); |
| 190 | |
| 191 | let scaling = match app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_scale_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_scale_type. { |
| 192 | AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Logrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Log# => { |
| 193 | // TODO: I might change this behaviour later. |
| 194 | if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_use_binary_prefix. { |
| 195 | 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# |
| 196 | } else { |
| 197 | ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#::Log10rust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#Log10# |
| 198 | } |
| 199 | } |
| 200 | AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Linearrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Linear# => 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#, |
| 201 | }; |
| 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 | network_widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/network_graph/NetWidgetState#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.: " Network ".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..network_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_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 | |
| 230 | fn draw_old_network_labelsrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/impl#[Painter]draw_old_network_labels().( |
| 231 | &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, |
| 232 | ) { |
| 233 | let network_latest_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().().network_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#network_harvest.); |
| 234 | let use_binary_prefix = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_use_binary_prefix.; |
| 235 | let unit_type = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_unit_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_unit_type.; |
| 236 | let unit = match unit_type { |
| 237 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte# => "B/s", |
| 238 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Bitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Bit# => "b/s", |
| 239 | }; |
| 240 | |
| 241 | let rx = get_unit_prefixrust-analyzer cargo bottom 0.14.9 utils/data_units/get_unit_prefix().(network_latest_data.rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx., use_binary_prefix); |
| 242 | let tx = get_unit_prefixrust-analyzer cargo bottom 0.14.9 utils/data_units/get_unit_prefix().(network_latest_data.txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx., use_binary_prefix); |
| 243 | |
| 244 | let rx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}{}", rx.0, rx.1, unit); |
| 245 | let tx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}{}", tx.0, tx.1, unit); |
| 246 | |
| 247 | let total_rx = convert_bitsrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bits().(network_latest_data.total_rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_rx., use_binary_prefix); |
| 248 | let total_tx = convert_bitsrust-analyzer cargo bottom 0.14.9 utils/data_units/convert_bits().(network_latest_data.total_txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_tx., use_binary_prefix); |
| 249 | let total_rx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", total_rx.0, total_rx.1); |
| 250 | let total_tx_label = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", total_tx.0, total_tx.1); |
| 251 | |
| 252 | let total_network = if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_show_packetsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_show_packets. { |
| 253 | let PacketInforust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo# { |
| 254 | rx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#rx_packet_rate., |
| 255 | tx_packet_raterust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#tx_packet_rate., |
| 256 | avg_rx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_rx_packet_size., |
| 257 | avg_tx_packet_sizerust-analyzer cargo bottom 0.14.9 canvas/widgets/PacketInfo#avg_tx_packet_size., |
| 258 | } = calculate_packet_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/calculate_packet_info().(network_latest_data, use_binary_prefix); |
| 259 | |
| 260 | let avg_rx_packet_size_label = |
| 261 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", avg_rx_packet_size.0, avg_rx_packet_size.1); |
| 262 | let avg_tx_packet_size_label = |
| 263 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}{}", avg_tx_packet_size.0, avg_tx_packet_size.1); |
| 264 | |
| 265 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]new().([ |
| 266 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(rx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 267 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(tx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 268 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(total_rx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_rx_style.), |
| 269 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(total_tx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_tx_style.), |
| 270 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{rx_packet_rate}pkt/s"), self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 271 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{tx_packet_rate}pkt/s"), self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 272 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(avg_rx_packet_size_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 273 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(avg_tx_packet_size_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 274 | ])] |
| 275 | } else { |
| 276 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]new().([ |
| 277 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(rx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#rx_style.), |
| 278 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(tx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#tx_style.), |
| 279 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(total_rx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_rx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_rx_style.), |
| 280 | Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::styledrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]styled().(total_tx_label, self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..total_tx_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#total_tx_style.), |
| 281 | ])] |
| 282 | }; |
| 283 | |
| 284 | let headers = if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..network_show_packetsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_show_packets. { |
| 285 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 286 | "RX", "TX", "Total RX", "Total TX", "RX Pkts", "TX Pkts", "Avg RX", "Avg TX", |
| 287 | ] |
| 288 | } else { |
| 289 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["RX", "TX", "Total RX", "Total TX"] |
| 290 | }; |
| 291 | let num_columns = headers.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 292 | |
| 293 | let column_width = draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]saturating_sub().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().num_columns as u16; |
| 294 | |
| 295 | // Draw |
| 296 | let current_border_style = if 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 { |
| 297 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..highlighted_border_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#highlighted_border_style. |
| 298 | } else { |
| 299 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..border_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#border_style. |
| 300 | }; |
| 301 | let block = widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block().( |
| 302 | app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_basic_moderust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_basic_mode., |
| 303 | 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, |
| 304 | 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., |
| 305 | 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., |
| 306 | ) |
| 307 | .border_stylerust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]border_style().(current_border_style); |
| 308 | |
| 309 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().( |
| 310 | Tablerust-analyzer cargo ratatui-widgets 0.3.2 table/Table#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]new().( |
| 311 | total_network, |
| 312 | &((stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeat_nrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat_n/repeat_n().(column_width, num_columns)) |
| 313 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#) |
| 314 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()), |
| 315 | ) |
| 316 | .headerrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]header().(Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]new().(headers).stylerust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..table_header_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#table_header_style.)) |
| 317 | .blockrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]block().(block) |
| 318 | .stylerust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style.), |
| 319 | draw_loc, |
| 320 | ); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /// Returns the required labels. |
| 325 | /// |
| 326 | /// TODO: This is _really_ ugly... also there might be a bug with certain |
| 327 | /// heights and too many labels. We may need to take draw height into account, |
| 328 | /// either here, or in the time graph itself. |
| 329 | fn adjust_network_data_pointrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/adjust_network_data_point().(max_entry: f64, config: &AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#) -> (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#>) { |
| 330 | // So, we're going with an approach like this for linear data: |
| 331 | // - Main goal is to maximize the amount of information displayed given a |
| 332 | // specific height. We don't want to drown out some data if the ranges are too |
| 333 | // far though! Nor do we want to filter out too much data... |
| 334 | // - Change the y-axis unit (kilo/kibi, mega/mebi...) dynamically based on max |
| 335 | // load. |
| 336 | // |
| 337 | // The idea is we take the top value, build our scale such that each "point" is |
| 338 | // a scaled version of that. So for example, let's say I use 390 Mb/s. If I |
| 339 | // drew 4 segments, it would be 97.5, 195, 292.5, 390, and |
| 340 | // probably something like 438.75? |
| 341 | // |
| 342 | // So, how do we do this in ratatui? Well, if we are using intervals that tie |
| 343 | // in perfectly to the max value we want... then it's actually not that |
| 344 | // hard. Since ratatui accepts a vector as labels and will properly space |
| 345 | // them all out... we just work with that and space it out properly. |
| 346 | // |
| 347 | // Dynamic chart idea based off of FreeNAS's chart design. |
| 348 | // |
| 349 | // --- |
| 350 | // |
| 351 | // For log data, we just use the old method of log intervals |
| 352 | // (kilo/mega/giga/etc.). Keep it nice and simple. |
| 353 | |
| 354 | // Now just check the largest unit we correspond to... then proceed to build |
| 355 | // some entries from there! |
| 356 | |
| 357 | let scale_type = config.network_scale_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_scale_type.; |
| 358 | let use_binary_prefix = config.network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_use_binary_prefix.; |
| 359 | let network_unit_type = config.network_unit_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_unit_type.; |
| 360 | |
| 361 | let unit_char = match network_unit_type { |
| 362 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte# => "B", |
| 363 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Bitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Bit# => "b", |
| 364 | }; |
| 365 | |
| 366 | match scale_type { |
| 367 | AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Linearrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Linear# => { |
| 368 | let (k_limit, m_limit, g_limit, t_limit) = if use_binary_prefix { |
| 369 | ( |
| 370 | KIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KIBI_LIMIT_F64., |
| 371 | MEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEBI_LIMIT_F64., |
| 372 | GIBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIBI_LIMIT_F64., |
| 373 | TEBI_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TEBI_LIMIT_F64., |
| 374 | ) |
| 375 | } else { |
| 376 | ( |
| 377 | KILO_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/KILO_LIMIT_F64., |
| 378 | MEGA_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/MEGA_LIMIT_F64., |
| 379 | GIGA_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/GIGA_LIMIT_F64., |
| 380 | TERA_LIMIT_F64rust-analyzer cargo bottom 0.14.9 utils/data_units/TERA_LIMIT_F64., |
| 381 | ) |
| 382 | }; |
| 383 | |
| 384 | 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 { |
| 385 | // If it's 0, then just use a very low value so the labels aren't just "0.0" 4 |
| 386 | // times. This _also_ prevents the y-axis height range ever |
| 387 | // being 0. |
| 388 | 1.0 |
| 389 | } else { |
| 390 | 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 // We use the bumped up version to calculate our unit type. |
| 391 | }; |
| 392 | |
| 393 | let (max_value_scaled, unit_prefix, unit_type): (f64, &str, &str) = { |
| 394 | 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().k_limit { |
| 395 | (max_entry, "", unit_char) |
| 396 | } 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().m_limit { |
| 397 | ( |
| 398 | 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().k_limit, |
| 399 | if use_binary_prefix { "Ki" } else { "K" }, |
| 400 | unit_char, |
| 401 | ) |
| 402 | } 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().g_limit { |
| 403 | ( |
| 404 | 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().m_limit, |
| 405 | if use_binary_prefix { "Mi" } else { "M" }, |
| 406 | unit_char, |
| 407 | ) |
| 408 | } 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().t_limit { |
| 409 | ( |
| 410 | 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().g_limit, |
| 411 | if use_binary_prefix { "Gi" } else { "G" }, |
| 412 | unit_char, |
| 413 | ) |
| 414 | } else { |
| 415 | ( |
| 416 | 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().t_limit, |
| 417 | if use_binary_prefix { "Ti" } else { "T" }, |
| 418 | unit_char, |
| 419 | ) |
| 420 | } |
| 421 | }; |
| 422 | |
| 423 | // Finally, build an acceptable range starting from there, using the given |
| 424 | // height! Note we try to put more of a weight on the bottom section |
| 425 | // vs. the top, since the top has less data. |
| 426 | let base_unit = max_value_scaled; |
| 427 | let labels: 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#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 428 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("0{unit_prefix}{unit_type}"), |
| 429 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", base_unit *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). 0.5), |
| 430 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", base_unit), |
| 431 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1}", base_unit *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). 1.5), |
| 432 | ] |
| 433 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 434 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| { |
| 435 | // Pull 5 as the longest legend value is generally going to be 5 digits (if they |
| 436 | // somehow hit over 5 terabits per second) |
| 437 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{s:>5}") |
| 438 | }) |
| 439 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 440 | |
| 441 | (max_entry_upper, labels) |
| 442 | } |
| 443 | AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Logrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Log# => { |
| 444 | let (m_limit, g_limit, t_limit) = if use_binary_prefix { |
| 445 | (LOG_MEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_MEBI_LIMIT., LOG_GIBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_GIBI_LIMIT., LOG_TEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_TEBI_LIMIT.) |
| 446 | } else { |
| 447 | (LOG_MEGA_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_MEGA_LIMIT., LOG_GIGA_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_GIGA_LIMIT., LOG_TERA_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_TERA_LIMIT.) |
| 448 | }; |
| 449 | |
| 450 | // Remember to do saturating log checks as otherwise 0.0 becomes inf, and you |
| 451 | // get gaps! |
| 452 | let max_entry = if use_binary_prefix { |
| 453 | saturating_log2rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log2().(max_entry) |
| 454 | } else { |
| 455 | saturating_log10rust-analyzer cargo bottom 0.14.9 utils/general/saturating_log10().(max_entry) |
| 456 | }; |
| 457 | |
| 458 | fn get_zerorust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_zero().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 459 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 460 | "{}0{}", |
| 461 | if network_use_binary_prefix { " " } else { " " }, |
| 462 | unit_char |
| 463 | ) |
| 464 | } |
| 465 | |
| 466 | fn get_krust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_k().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 467 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 468 | "1{}{}", |
| 469 | if network_use_binary_prefix { "Ki" } else { "K" }, |
| 470 | unit_char |
| 471 | ) |
| 472 | } |
| 473 | |
| 474 | fn get_mrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_m().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 475 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 476 | "1{}{}", |
| 477 | if network_use_binary_prefix { "Mi" } else { "M" }, |
| 478 | unit_char |
| 479 | ) |
| 480 | } |
| 481 | |
| 482 | fn get_grust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_g().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 483 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 484 | "1{}{}", |
| 485 | if network_use_binary_prefix { "Gi" } else { "G" }, |
| 486 | unit_char |
| 487 | ) |
| 488 | } |
| 489 | |
| 490 | fn get_trust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_t().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 491 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 492 | "1{}{}", |
| 493 | if network_use_binary_prefix { "Ti" } else { "T" }, |
| 494 | unit_char |
| 495 | ) |
| 496 | } |
| 497 | |
| 498 | fn get_prust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_p().(network_use_binary_prefix: bool, unit_char: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 499 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 500 | "1{}{}", |
| 501 | if network_use_binary_prefix { "Pi" } else { "P" }, |
| 502 | unit_char |
| 503 | ) |
| 504 | } |
| 505 | |
| 506 | if max_entry 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().m_limit { |
| 507 | ( |
| 508 | m_limit, |
| 509 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 510 | get_zerorust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_zero().(use_binary_prefix, unit_char), |
| 511 | get_krust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_k().(use_binary_prefix, unit_char), |
| 512 | get_mrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_m().(use_binary_prefix, unit_char), |
| 513 | ], |
| 514 | ) |
| 515 | } else if max_entry 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().g_limit { |
| 516 | ( |
| 517 | g_limit, |
| 518 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 519 | get_zerorust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_zero().(use_binary_prefix, unit_char), |
| 520 | get_krust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_k().(use_binary_prefix, unit_char), |
| 521 | get_mrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_m().(use_binary_prefix, unit_char), |
| 522 | get_grust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_g().(use_binary_prefix, unit_char), |
| 523 | ], |
| 524 | ) |
| 525 | } else if max_entry 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().t_limit { |
| 526 | ( |
| 527 | t_limit, |
| 528 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 529 | get_zerorust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_zero().(use_binary_prefix, unit_char), |
| 530 | get_krust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_k().(use_binary_prefix, unit_char), |
| 531 | get_mrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_m().(use_binary_prefix, unit_char), |
| 532 | get_grust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_g().(use_binary_prefix, unit_char), |
| 533 | get_trust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_t().(use_binary_prefix, unit_char), |
| 534 | ], |
| 535 | ) |
| 536 | } else { |
| 537 | // I really doubt anyone's transferring beyond petabyte speeds... |
| 538 | ( |
| 539 | if use_binary_prefix { |
| 540 | LOG_PEBI_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_PEBI_LIMIT. |
| 541 | } else { |
| 542 | LOG_PETA_LIMITrust-analyzer cargo bottom 0.14.9 utils/data_units/LOG_PETA_LIMIT. |
| 543 | }, |
| 544 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 545 | get_zerorust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_zero().(use_binary_prefix, unit_char), |
| 546 | get_krust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_k().(use_binary_prefix, unit_char), |
| 547 | get_mrust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_m().(use_binary_prefix, unit_char), |
| 548 | get_grust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_g().(use_binary_prefix, unit_char), |
| 549 | get_trust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_t().(use_binary_prefix, unit_char), |
| 550 | get_prust-analyzer cargo bottom 0.14.9 canvas/widgets/network_graph/get_p().(use_binary_prefix, unit_char), |
| 551 | ], |
| 552 | ) |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | } |