| 1 | //! How to handle config files and arguments. |
| 2 | |
| 3 | // TODO: Break this apart or do something a bit smarter. |
| 4 | |
| 5 | pub mod argsrust-analyzer cargo bottom 0.14.9 options/args/; |
| 6 | pub mod configrust-analyzer cargo bottom 0.14.9 options/config/; |
| 7 | mod errorrust-analyzer cargo bottom 0.14.9 options/error/; |
| 8 | |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 10 | convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryIntorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#, |
| 11 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/, |
| 12 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 13 | pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#}, |
| 14 | strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#, |
| 15 | 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#}, |
| 16 | }; |
| 17 | |
| 18 | use anyhowrust-analyzer cargo anyhow 1.0.104 crate/::{Contextrust-analyzer cargo anyhow 1.0.104 Context#, Resultrust-analyzer cargo anyhow 1.0.104 Result#}; |
| 19 | pub use configrust-analyzer cargo bottom 0.14.9 options/config/::Configrust-analyzer cargo bottom 0.14.9 options/config/Config#; |
| 20 | use configrust-analyzer cargo bottom 0.14.9 options/config/::stylerust-analyzer cargo bottom 0.14.9 options/config/style/::Stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#; |
| 21 | use datarust-analyzer cargo bottom 0.14.9 app/data/::TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#; |
| 22 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) use errorrust-analyzer cargo bottom 0.14.9 options/error/::{OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#, OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#}; |
| 23 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::IndexSetrust-analyzer cargo indexmap 2.14.0 set/IndexSet#; |
| 24 | use regexrust-analyzer cargo regex 1.13.1 crate/::Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#; |
| 25 | use rustc_hashrust-analyzer cargo rustc-hash 2.1.3 crate/::{FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#, FxHashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#}; |
| 26 | #[cfg(feature = "battery")] |
| 27 | use starship_batteryrust-analyzer cargo starship-battery 0.11.1 crate/::Managerrust-analyzer cargo starship-battery 0.11.1 types/manager/Manager#; |
| 28 | |
| 29 | use selfrust-analyzer cargo bottom 0.14.9 options/::{ |
| 30 | argsrust-analyzer cargo bottom 0.14.9 options/args/::BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, |
| 31 | configrust-analyzer cargo bottom 0.14.9 options/config/::{IgnoreListrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#, StringOrNumrust-analyzer cargo bottom 0.14.9 options/config/StringOrNum#, layoutrust-analyzer cargo bottom 0.14.9 options/config/layout/::Rowrust-analyzer cargo bottom 0.14.9 options/config/layout/Row#}, |
| 32 | }; |
| 33 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 34 | apprust-analyzer cargo bottom 0.14.9 app/::{filterrust-analyzer cargo bottom 0.14.9 app/filter/::Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#, layout_managerrust-analyzer cargo bottom 0.14.9 app/layout_manager/::*, *}, |
| 35 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::time_seriesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/::LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#, |
| 36 | componentsrust-analyzer cargo bottom 0.14.9 components/::time_seriesrust-analyzer cargo bottom 0.14.9 components/time_series/::TimeseriesConfigrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#, |
| 37 | constantsrust-analyzer cargo bottom 0.14.9 constants/::*, |
| 38 | utilsrust-analyzer cargo bottom 0.14.9 utils/::data_unitsrust-analyzer cargo bottom 0.14.9 utils/data_units/::DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#, |
| 39 | widgetsrust-analyzer cargo bottom 0.14.9 widgets/::*, |
| 40 | }; |
| 41 | |
| 42 | /// Macro to check whether a flag is enabled, either as an arg or in the config file. |
| 43 | macro_rules! is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled! { |
| 44 | ($flag_name:ident, $arg:expr, $config:expr) => { |
| 45 | if $arg.$flag_name { |
| 46 | true |
| 47 | } else if let Some(flags) = &$config.flags { |
| 48 | flags.$flag_name.unwrap_or(false) |
| 49 | } else { |
| 50 | false |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | ($cmd_flag:literal, $cfg_flag:ident, $matches:expr, $config:expr) => { |
| 55 | if $matches.get_flag($cmd_flag) { |
| 56 | true |
| 57 | } else if let Some(flags) = &$config.flags { |
| 58 | flags.$cfg_flag.unwrap_or(false) |
| 59 | } else { |
| 60 | false |
| 61 | } |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | /// A version of [`is_flag_enabled`] which instead expects the user to pass |
| 66 | /// in `config_section`, which is the section the flag is located, rather than |
| 67 | /// defaulting to `config.flags` where `config` is passed in. |
| 68 | macro_rules! is_flag_enabled_inrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled_in! { |
| 69 | ($flag_name:ident, $arg:expr, $config_section:expr) => { |
| 70 | if $arg.$flag_name { |
| 71 | true |
| 72 | } else if let Some(options) = &$config_section { |
| 73 | options.$flag_name.unwrap_or(false) |
| 74 | } else { |
| 75 | false |
| 76 | } |
| 77 | }; |
| 78 | } |
| 79 | |
| 80 | /// A version of [`is_flag_enabled`] which should be used to deprecate old config flags. |
| 81 | macro_rules! enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated! { |
| 82 | ($arg:expr, $config:expr, $section:ident . $field:ident, $flags:ident . $deprecated_flag:ident $(,)?) => { |
| 83 | if $arg { |
| 84 | true |
| 85 | } else if let Some(section) = &$config.$section { |
| 86 | section.$field.unwrap_or(false) |
| 87 | } else if let Some(flags) = &$config.flags { |
| 88 | flags |
| 89 | .$deprecated_flag |
| 90 | .inspect(|_| { |
| 91 | deprecated_warning(stringify!($deprecated_flag), stringify!($section.$field)) |
| 92 | }) |
| 93 | .unwrap_or(false) |
| 94 | } else { |
| 95 | false |
| 96 | } |
| 97 | }; |
| 98 | ($arg:expr, $config:expr, $section:ident . $field:ident, $flags:ident . $deprecated_flag:ident, $alias:literal $(,)?) => { |
| 99 | if $arg { |
| 100 | true |
| 101 | } else if let Some(section) = &$config.$section { |
| 102 | section.$field.unwrap_or(false) |
| 103 | } else if let Some(flags) = &$config.flags { |
| 104 | flags |
| 105 | .$deprecated_flag |
| 106 | .inspect(|_| { |
| 107 | deprecated_warning_with_alias( |
| 108 | stringify!($deprecated_flag), |
| 109 | stringify!($section.$field), |
| 110 | $alias, |
| 111 | ) |
| 112 | }) |
| 113 | .unwrap_or(false) |
| 114 | } else { |
| 115 | false |
| 116 | } |
| 117 | }; |
| 118 | } |
| 119 | |
| 120 | /// Get the value of a field for a specific section in the config file if set. If not set, the default is used. |
| 121 | macro_rules! config_or_defaultrust-analyzer cargo bottom 0.14.9 options/config_or_default! { |
| 122 | ($config:expr, $section:ident . $field:ident) => { |
| 123 | $config |
| 124 | .$section |
| 125 | .as_ref() |
| 126 | .map(|s| s.$field) |
| 127 | .unwrap_or_default() |
| 128 | }; |
| 129 | } |
| 130 | |
| 131 | /// Get the value of a field for a specific section in the config file if set. If not set, |
| 132 | /// the provided default is used. |
| 133 | macro_rules! config_orrust-analyzer cargo bottom 0.14.9 options/config_or! { |
| 134 | ($config:expr, $section:ident . $field:ident, $default:expr) => { |
| 135 | $config |
| 136 | .$section |
| 137 | .as_ref() |
| 138 | .and_then(|s| s.$field) |
| 139 | .unwrap_or($default) |
| 140 | }; |
| 141 | } |
| 142 | |
| 143 | /// The default config file sub-path. |
| 144 | const DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.: &str = "bottom/bottom.toml"; |
| 145 | |
| 146 | /// Returns the config path to use. If `override_config_path` is specified, then |
| 147 | /// we will use that. If not, then return the "default" config path, which is: |
| 148 | /// |
| 149 | /// - If a path already exists at `<HOME>/bottom/bottom.toml`, then use that for |
| 150 | /// legacy reasons. |
| 151 | /// - Otherwise, use `<SYSTEM_CONFIG_FOLDER>/bottom/bottom.toml`. |
| 152 | /// |
| 153 | /// For more details on this, see [dirs](https://docs.rs/dirs/latest/dirs/fn.config_dir.html)' |
| 154 | /// documentation. |
| 155 | /// |
| 156 | /// XXX: For macOS, we additionally will manually check `$XDG_CONFIG_HOME` as |
| 157 | /// well first before falling back to `dirs`. |
| 158 | fn get_config_pathrust-analyzer cargo bottom 0.14.9 options/get_config_path().(override_config_path: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 159 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(conf_loc) = override_config_path { |
| 160 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(conf_loc.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().()); |
| 161 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(home_path) = dirsrust-analyzer cargo dirs 6.0.0 crate/::home_dirrust-analyzer cargo dirs 6.0.0 home_dir().() { |
| 162 | let mut old_home_path = home_path; |
| 163 | old_home_path.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(".config/"); |
| 164 | old_home_path.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.); |
| 165 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(res) = old_home_path.try_existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]try_exists().() |
| 166 | && res |
| 167 | { |
| 168 | // We used to create it at `<HOME>/DEFAULT_CONFIG_FILE_PATH`, but changed it |
| 169 | // to be more correct later. However, for legacy reasons, if it already exists, |
| 170 | // use the old one. |
| 171 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(old_home_path); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | let config_path = dirsrust-analyzer cargo dirs 6.0.0 crate/::config_dirrust-analyzer cargo dirs 6.0.0 config_dir().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|mut path| { |
| 176 | path.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.); |
| 177 | path |
| 178 | }); |
| 179 | |
| 180 | if cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(target_os = "macos") |
| 181 | && let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(xdg_config_path) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("XDG_CONFIG_HOME") |
| 182 | && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().xdg_config_path.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() |
| 183 | { |
| 184 | // If XDG_CONFIG_HOME exists and is non-empty, _but_ we previously used the |
| 185 | // Library-based path for a config and it exists, then use that |
| 186 | // instead for backwards-compatibility. |
| 187 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(old_macos_path) = &config_path |
| 188 | && let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(res) = old_macos_path.try_existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]try_exists().() |
| 189 | && res |
| 190 | { |
| 191 | return config_path; |
| 192 | } |
| 193 | |
| 194 | // Otherwise, try and use the XDG_CONFIG_HOME-based path. |
| 195 | let mut cfg_path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]new().(); |
| 196 | cfg_path.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(xdg_config_path); |
| 197 | cfg_path.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.); |
| 198 | |
| 199 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg_path); |
| 200 | } |
| 201 | |
| 202 | config_path |
| 203 | } |
| 204 | |
| 205 | fn create_config_at_pathrust-analyzer cargo bottom 0.14.9 options/create_config_at_path().(path: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> anyhowrust-analyzer cargo anyhow 1.0.104 crate/::Resultrust-analyzer cargo anyhow 1.0.104 Result#<Configrust-analyzer cargo bottom 0.14.9 options/config/Config#> { |
| 206 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent_path) = path.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().() { |
| 207 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::create_dir_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir_all().(parent_path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 208 | } |
| 209 | |
| 210 | let mut file = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 211 | file.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(CONFIG_TEXTrust-analyzer cargo bottom 0.14.9 constants/CONFIG_TEXT..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 212 | |
| 213 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().()) |
| 214 | } |
| 215 | |
| 216 | /// Get the config at `config_path`. If there is no config file at the specified |
| 217 | /// path, it will try to create a new file with the default settings, and return |
| 218 | /// the default config. |
| 219 | /// |
| 220 | /// We're going to use the following behaviour on when we'll return an error |
| 221 | /// rather than just "silently" continuing on: |
| 222 | /// - If the user passed in a path explicitly, then we will be loud and error |
| 223 | /// out. |
| 224 | /// - If the user does NOT pass in a path explicitly, then just show a warning, |
| 225 | /// but continue. This is in case they do not want to write a default config |
| 226 | /// file at the XDG locations, for example. |
| 227 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn get_or_create_configrust-analyzer cargo bottom 0.14.9 options/get_or_create_config().(config_path: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>) -> anyhowrust-analyzer cargo anyhow 1.0.104 crate/::Resultrust-analyzer cargo anyhow 1.0.104 Result#<Configrust-analyzer cargo bottom 0.14.9 options/config/Config#> { |
| 228 | let adjusted_config_path = get_config_pathrust-analyzer cargo bottom 0.14.9 options/get_config_path().(config_path); |
| 229 | |
| 230 | match &adjusted_config_path { |
| 231 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) => { |
| 232 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(config_string) = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().(path) { |
| 233 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(toml_editrust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 crate/::derust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 de/::from_strrust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 de/from_str().(&config_string)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 234 | } else { |
| 235 | match create_config_at_pathrust-analyzer cargo bottom 0.14.9 options/create_config_at_path().(path) { |
| 236 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(cfg) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(cfg), |
| 237 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 238 | let path = path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(); |
| 239 | if config_path.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 240 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err.contextrust-analyzer cargo anyhow 1.0.104 error/impl#[Error]context().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 241 | "bottom could not create a new config file at '{path}'.", |
| 242 | ))) |
| 243 | } else { |
| 244 | indocrust-analyzer cargo indoc 2.0.7 crate/::eprintdocrust-analyzer cargo indoc 2.0.7 eprintdoc!!( |
| 245 | "Note: bottom couldn't create a default config file at '{path}', and the \ |
| 246 | application has fallen back to the default configuration. |
| 247 | |
| 248 | Caused by: |
| 249 | {err} |
| 250 | ", |
| 251 | ); |
| 252 | |
| 253 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().()) |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 260 | // If we somehow don't have any config path, then just assume the default config |
| 261 | // but don't write to any file. |
| 262 | // |
| 263 | // TODO: For now, just print a message to stderr indicating this. In the future, |
| 264 | // probably show in-app (too). |
| 265 | |
| 266 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!( |
| 267 | "Note: bottom couldn't find a location to create or read a config file, so \ |
| 268 | the application has fallen back to the default configuration. \ |
| 269 | This could be for a variety of reasons, such as issues with file permissions." |
| 270 | ); |
| 271 | |
| 272 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().()) |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | /// Initialize the app. |
| 278 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn init_apprust-analyzer cargo bottom 0.14.9 options/init_app().(args: BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> Resultrust-analyzer cargo anyhow 1.0.104 Result#<(Apprust-analyzer cargo bottom 0.14.9 app/App#, BottomLayoutrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#, Stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#)> { |
| 279 | use BottomWidgetTyperust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#::*; |
| 280 | |
| 281 | // Since everything takes a reference, but we want to take ownership here to |
| 282 | // drop matches/config later... |
| 283 | let args = &args; |
| 284 | let config = &config; |
| 285 | |
| 286 | let styling = Stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#::newrust-analyzer cargo bottom 0.14.9 options/config/style/impl#[Styles]new().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 287 | |
| 288 | let (widget_layout, default_widget_id, default_widget_type_option) = |
| 289 | get_widget_layoutrust-analyzer cargo bottom 0.14.9 options/get_widget_layout().(args, config) |
| 290 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Found an issue while trying to build the widget layout.")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 291 | |
| 292 | let retention_ms = get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 293 | let autohide_time = is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(autohide_timerust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#autohide_time., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config); |
| 294 | let default_time_value = get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(args, config, retention_ms)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 295 | |
| 296 | let use_basic_mode = is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(basicrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#basic., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config); |
| 297 | let expanded = is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(expandedrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#expanded., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config); |
| 298 | |
| 299 | #[cfg(feature = "zfs")] |
| 300 | let free_arc = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 301 | args.memoryrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#memory..free_arcrust-analyzer cargo bottom 0.14.9 options/args/MemoryArgs#free_arc., |
| 302 | config, |
| 303 | memory_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#memory_graph..free_arcrust-analyzer cargo bottom 0.14.9 options/config/memory_graph/MemoryGraphConfig#free_arc., |
| 304 | flags.free_arcrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#free_arc., |
| 305 | "memory.free_arc", |
| 306 | ); |
| 307 | |
| 308 | // For processes |
| 309 | let is_grouped = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 310 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..group_processesrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#group_processes., |
| 311 | config, |
| 312 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..default_groupedrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#default_grouped., |
| 313 | flags.group_processesrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#group_processes., |
| 314 | ); |
| 315 | let is_case_sensitive = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 316 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..case_sensitiverust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#case_sensitive., |
| 317 | config, |
| 318 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..case_sensitiverust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#case_sensitive., |
| 319 | flags.case_sensitiverust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#case_sensitive., |
| 320 | ); |
| 321 | let is_match_whole_word = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 322 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..whole_wordrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#whole_word., |
| 323 | config, |
| 324 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..whole_wordrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#whole_word., |
| 325 | flags.whole_wordrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#whole_word., |
| 326 | ); |
| 327 | let is_use_regex = |
| 328 | enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!(args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..regexrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#regex., config, processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..regexrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#regex., flags.regexrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#regex.,); |
| 329 | let is_default_tree = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 330 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..treerust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#tree., |
| 331 | config, |
| 332 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..default_treerust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#default_tree., |
| 333 | flags.treerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#tree., |
| 334 | ); |
| 335 | let is_default_command = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 336 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..process_commandrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#process_command., |
| 337 | config, |
| 338 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..process_commandrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#process_command., |
| 339 | flags.process_commandrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#process_command., |
| 340 | ); |
| 341 | #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] |
| 342 | let is_advanced_kill = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 343 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..disable_advanced_killrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#disable_advanced_kill., |
| 344 | config, |
| 345 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..disable_advanced_killrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#disable_advanced_kill., |
| 346 | flags.disable_advanced_killrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#disable_advanced_kill., |
| 347 | )); |
| 348 | let is_read_only = is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(read_onlyrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#read_only., args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process., config); |
| 349 | #[cfg(target_os = "linux")] |
| 350 | let hide_k_threads = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 351 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..hide_k_threadsrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#hide_k_threads., |
| 352 | config, |
| 353 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..hide_k_threadsrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#hide_k_threads., |
| 354 | flags.hide_k_threadsrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#hide_k_threads., |
| 355 | ); |
| 356 | |
| 357 | let process_memory_as_value = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 358 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..process_memory_as_valuerust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#process_memory_as_value., |
| 359 | config, |
| 360 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..default_memory_valuerust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#default_memory_value., |
| 361 | flags.process_memory_as_valuerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#process_memory_as_value., |
| 362 | ); |
| 363 | let is_default_tree_collapsed = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 364 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..tree_collapserust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#tree_collapse., |
| 365 | config, |
| 366 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..tree_collapserust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#tree_collapse., |
| 367 | flags.tree_collapserust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#tree_collapse., |
| 368 | ); |
| 369 | |
| 370 | // For CPU |
| 371 | let default_cpu_selection = get_default_cpu_selectionrust-analyzer cargo bottom 0.14.9 options/get_default_cpu_selection().(args, config); |
| 372 | |
| 373 | let mut widget_map = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 374 | let mut cpu_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, CpuWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 375 | let mut mem_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, MemWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/mem_graph/MemWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 376 | let mut net_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, NetWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/network_graph/NetWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 377 | let mut proc_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, ProcWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 378 | let mut temp_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, TempWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/temperature_table/TempWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 379 | let mut temp_graph_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, TempGraphWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 380 | let mut disk_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, DiskTableWidgetrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskTableWidget#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 381 | let mut disk_io_graph_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, DiskIoGraphWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 382 | let mut battery_state_map: FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<u64, BatteryWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/battery_info/BatteryWidgetState#> = FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 383 | |
| 384 | let autohide_timer = if autohide_time { |
| 385 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().()) |
| 386 | } else { |
| 387 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 388 | }; |
| 389 | |
| 390 | let mut initial_widget_id: u64 = default_widget_id; |
| 391 | let mut initial_widget_type = Procrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Proc#; |
| 392 | let is_custom_layout = config.rowrust-analyzer cargo bottom 0.14.9 options/config/Config#row..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(); |
| 393 | let mut used_widget_set = FxHashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 394 | |
| 395 | let network_unit_type = get_network_unit_typerust-analyzer cargo bottom 0.14.9 options/get_network_unit_type().(args, config); |
| 396 | let network_scale_type = get_network_scale_typerust-analyzer cargo bottom 0.14.9 options/get_network_scale_type().(args, config); |
| 397 | // Use + update this again after deprecation |
| 398 | // let network_use_binary_prefix = is_flag_enabled!(network_use_binary_prefix, args.network, config); |
| 399 | let network_use_binary_prefix = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 400 | args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network..network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#network_use_binary_prefix., |
| 401 | config, |
| 402 | network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph..use_binary_prefixrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#use_binary_prefix., |
| 403 | flags.network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#network_use_binary_prefix., |
| 404 | "network.use_binary_prefix", |
| 405 | ); |
| 406 | let network_show_packets = |
| 407 | is_flag_enabled_inrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled_in!!(show_packetsrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#show_packets., args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network., config.network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph.); |
| 408 | let network_start_zeroed = if args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network..network_start_zeroedrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#network_start_zeroed. { |
| 409 | true |
| 410 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network_graph) = &config.network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph. { |
| 411 | network_graph.start_zeroedrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#start_zeroed..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 412 | } else { |
| 413 | false |
| 414 | }; |
| 415 | |
| 416 | let proc_columns: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<IndexSetrust-analyzer cargo indexmap 2.14.0 set/IndexSet#<ProcWidgetColumnrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetColumn#>> = { |
| 417 | config.processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| { |
| 418 | if cfg.columnsrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#columns..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 419 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 420 | } else { |
| 421 | // TODO: Should we be using an indexmap? Or maybe allow dupes. |
| 422 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IndexSetrust-analyzer cargo indexmap 2.14.0 set/IndexSet#::from_iterrust-analyzer cargo indexmap 2.14.0 set/impl#[`IndexSet<T, S>`][`FromIterator<T>`]from_iter().( |
| 423 | cfg.columnsrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#columns..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(ProcWidgetColumnrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetColumn#::fromrust-analyzer cargo bottom 0.14.9 widgets/process_table/process_columns/impl#[ProcWidgetColumn][`From<&ProcColumn>`]from().), |
| 424 | )) |
| 425 | } |
| 426 | }) |
| 427 | }; |
| 428 | |
| 429 | let network_legend_position = get_network_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_network_legend_position().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 430 | let memory_legend_position = get_memory_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_memory_legend_position().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 431 | let temperature_legend_position = get_temperature_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_temperature_legend_position().(config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 432 | let disk_io_legend_position = get_disk_io_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_disk_io_legend_position().(config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 433 | let disk_io_name_filter = match &config.disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. { |
| 434 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg) => get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.name_filterrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#name_filter.) |
| 435 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'disk_io_graph.name_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 436 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 437 | }; |
| 438 | let disk_show_unmounted = config |
| 439 | .diskrust-analyzer cargo bottom 0.14.9 options/config/Config#disk. |
| 440 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 441 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.include_unmountedrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#include_unmounted.) |
| 442 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false); |
| 443 | let disk_io_graph_show_unmounted = config |
| 444 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 445 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 446 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.include_unmountedrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#include_unmounted.) |
| 447 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false); |
| 448 | |
| 449 | let enable_cache_memory = get_enable_cache_memoryrust-analyzer cargo bottom 0.14.9 options/get_enable_cache_memory().(args, config); |
| 450 | let enable_gpu = get_enable_gpurust-analyzer cargo bottom 0.14.9 options/get_enable_gpu().(args, config); |
| 451 | |
| 452 | // TODO: Can probably just reuse the options struct. |
| 453 | let app_config_fields = AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields# { |
| 454 | update_raterust-analyzer cargo bottom 0.14.9 app/AppConfigFields#update_rate.: get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 455 | temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type.: get_temperaturerust-analyzer cargo bottom 0.14.9 options/get_temperature().(args, config) |
| 456 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'temperature_type' in your config file.")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 457 | show_average_cpurust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_average_cpu.: get_show_average_cpurust-analyzer cargo bottom 0.14.9 options/get_show_average_cpu().(args, config), |
| 458 | show_cpu_decimalrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_cpu_decimal.: config_orrust-analyzer cargo bottom 0.14.9 options/config_or!!(config, cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu..show_decimalrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#show_decimal., false), |
| 459 | use_dotrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_dot.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(dot_markerrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#dot_marker., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config), |
| 460 | cpu_left_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#cpu_left_legend.: enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 461 | args.cpurust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#cpu..cpu_left_legendrust-analyzer cargo bottom 0.14.9 options/args/CpuArgs#cpu_left_legend., |
| 462 | config, |
| 463 | cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu..left_legendrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#left_legend., |
| 464 | flags.cpu_left_legendrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#cpu_left_legend., |
| 465 | ), |
| 466 | use_current_cpu_totalrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_current_cpu_total.: enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 467 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..current_usagerust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#current_usage., |
| 468 | config, |
| 469 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..current_usagerust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#current_usage., |
| 470 | flags.current_usagerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#current_usage., |
| 471 | ), |
| 472 | unnormalized_cpurust-analyzer cargo bottom 0.14.9 app/AppConfigFields#unnormalized_cpu.: enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 473 | args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..unnormalized_cpurust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#unnormalized_cpu., |
| 474 | config, |
| 475 | processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..unnormalized_cpurust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#unnormalized_cpu., |
| 476 | flags.unnormalized_cpurust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#unnormalized_cpu., |
| 477 | ), |
| 478 | get_process_threadsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#get_process_threads.: is_flag_enabled_inrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled_in!!(get_threadsrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#get_threads., args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process., config.processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes.), |
| 479 | use_basic_moderust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_basic_mode., |
| 480 | default_time_valuerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_time_value., |
| 481 | time_intervalrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#time_interval.: get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(args, config, retention_ms)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 482 | hide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#hide_time.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(hide_timerust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#hide_time., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config), |
| 483 | autohide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#autohide_time., |
| 484 | use_old_network_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_old_network_legend.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(use_old_network_legendrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#use_old_network_legend., args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network., config), |
| 485 | table_gaprust-analyzer cargo bottom 0.14.9 app/AppConfigFields#table_gap.: config_or_defaultrust-analyzer cargo bottom 0.14.9 options/config_or_default!!(config, flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags..table_gaprust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#table_gap.), |
| 486 | disable_clickrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disable_click.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(disable_clickrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#disable_click., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config), |
| 487 | disable_keysrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disable_keys.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(disable_keysrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#disable_keys., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config), |
| 488 | enable_gpurust-analyzer cargo bottom 0.14.9 app/AppConfigFields#enable_gpu., |
| 489 | short_gpu_namesrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#short_gpu_names.: get_short_gpu_namesrust-analyzer cargo bottom 0.14.9 options/get_short_gpu_names().(args, config), |
| 490 | enable_cache_memoryrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#enable_cache_memory., |
| 491 | show_table_scroll_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_table_scroll_position.: is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!( |
| 492 | show_table_scroll_positionrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#show_table_scroll_position., |
| 493 | args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., |
| 494 | config |
| 495 | ), |
| 496 | show_table_scroll_barrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_table_scroll_bar.: config_orrust-analyzer cargo bottom 0.14.9 options/config_or!!(config, flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags..show_table_scroll_barrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#show_table_scroll_bar., false), |
| 497 | #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] |
| 498 | is_advanced_killrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#is_advanced_kill., |
| 499 | is_read_onlyrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#is_read_only., |
| 500 | #[cfg(target_os = "linux")] |
| 501 | hide_k_threadsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#hide_k_threads., |
| 502 | memory_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#memory_legend_position., |
| 503 | network_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_legend_position., |
| 504 | network_scale_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_scale_type., |
| 505 | network_unit_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_unit_type., |
| 506 | network_use_binary_prefixrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_use_binary_prefix., |
| 507 | network_show_packetsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_show_packets., |
| 508 | network_start_zeroedrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#network_start_zeroed., |
| 509 | retention_msrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#retention_ms., |
| 510 | dedicated_average_rowrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#dedicated_average_row.: enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 511 | false, |
| 512 | config, |
| 513 | cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu..basic_average_cpu_rowrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#basic_average_cpu_row., |
| 514 | flags.average_cpu_rowrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#average_cpu_row., |
| 515 | ), |
| 516 | default_tree_collapserust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_tree_collapse.: is_default_tree_collapsed, |
| 517 | #[cfg(feature = "zfs")] |
| 518 | free_arcrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#free_arc., |
| 519 | default_temp_sort_columnrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_temp_sort_column.: config |
| 520 | .temperaturerust-analyzer cargo bottom 0.14.9 options/config/Config#temperature. |
| 521 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 522 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.default_sortrust-analyzer cargo bottom 0.14.9 options/config/temperature/TempConfig#default_sort..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()), |
| 523 | default_temp_sort_orderrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_temp_sort_order.: config |
| 524 | .temperaturerust-analyzer cargo bottom 0.14.9 options/config/Config#temperature. |
| 525 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 526 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|cfg| cfg.sort_orderrust-analyzer cargo bottom 0.14.9 options/config/temperature/TempConfig#sort_order.) |
| 527 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 528 | default_disk_sort_columnrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_disk_sort_column.: config |
| 529 | .diskrust-analyzer cargo bottom 0.14.9 options/config/Config#disk. |
| 530 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 531 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.default_sortrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#default_sort..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()), |
| 532 | default_disk_sort_orderrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_disk_sort_order.: config |
| 533 | .diskrust-analyzer cargo bottom 0.14.9 options/config/Config#disk. |
| 534 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 535 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|cfg| cfg.sort_orderrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#sort_order.) |
| 536 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 537 | temperature_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_legend_position., |
| 538 | disk_io_legend_positionrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disk_io_legend_position., |
| 539 | disk_show_unmountedrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disk_show_unmounted., |
| 540 | disk_io_graph_show_unmountedrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#disk_io_graph_show_unmounted., |
| 541 | }; |
| 542 | |
| 543 | let process_default_sort = match &args.processrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#process..process_default_sortrust-analyzer cargo bottom 0.14.9 options/args/ProcessArgs#process_default_sort. { |
| 544 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ProcColumnrust-analyzer cargo bottom 0.14.9 widgets/process_table/process_columns/ProcColumn#::parse_column_namerust-analyzer cargo bottom 0.14.9 widgets/process_table/process_columns/impl#[ProcColumn]parse_column_name().(name).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 545 | OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::argrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]arg().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 546 | "'{name}' is not a valid process column for '--process_default_sort'" |
| 547 | )) |
| 548 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 549 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => config.processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.default_sortrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#default_sort.), |
| 550 | }; |
| 551 | |
| 552 | let ts_config = TimeseriesConfigrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig# { |
| 553 | time_intervalrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#time_interval.: app_config_fields.time_intervalrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#time_interval., |
| 554 | retention_msrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#retention_ms.: app_config_fields.retention_msrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#retention_ms., |
| 555 | autohide_timerust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#autohide_time.: app_config_fields.autohide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#autohide_time., |
| 556 | default_time_valuerust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#default_time_value.: app_config_fields.default_time_valuerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#default_time_value., |
| 557 | }; |
| 558 | |
| 559 | let process_default_sort_order = config.processesrust-analyzer cargo bottom 0.14.9 options/config/Config#processes..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.sort_orderrust-analyzer cargo bottom 0.14.9 options/config/process/ProcessesConfig#sort_order.); |
| 560 | |
| 561 | let table_config = ProcTableConfigrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig# { |
| 562 | is_case_sensitiverust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#is_case_sensitive., |
| 563 | is_match_whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#is_match_whole_word., |
| 564 | is_use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#is_use_regex., |
| 565 | show_memory_as_valuesrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#show_memory_as_values.: process_memory_as_value, |
| 566 | is_commandrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#is_command.: is_default_command, |
| 567 | default_sortrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#default_sort.: process_default_sort, |
| 568 | sort_orderrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcTableConfig#sort_order.: process_default_sort_order, |
| 569 | }; |
| 570 | |
| 571 | for row in &widget_layout.rowsrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#rows. { |
| 572 | for col in &row.childrenrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomRow#children. { |
| 573 | for col_row in &col.childrenrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomCol#children. { |
| 574 | for widget in &col_row.childrenrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomColRow#children. { |
| 575 | widget_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., widget.clonerust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidget][Clone]clone().()); |
| 576 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(default_widget_type) = &default_widget_type_option |
| 577 | && (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_custom_layout || use_basic_mode) |
| 578 | { |
| 579 | match widget.widget_typerust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_type. { |
| 580 | BasicCpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicCpu# => { |
| 581 | if let Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu# = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().default_widget_type { |
| 582 | initial_widget_id = widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.; |
| 583 | initial_widget_type = Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu#; |
| 584 | } |
| 585 | } |
| 586 | BasicMemrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicMem# => { |
| 587 | if let Memrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Mem# = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().default_widget_type { |
| 588 | initial_widget_id = widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.; |
| 589 | initial_widget_type = Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu#; |
| 590 | } |
| 591 | } |
| 592 | BasicNetrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicNet# => { |
| 593 | if let Netrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Net# = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().default_widget_type { |
| 594 | initial_widget_id = widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.; |
| 595 | initial_widget_type = Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu#; |
| 596 | } |
| 597 | } |
| 598 | _ => { |
| 599 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().default_widget_type rust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidgetType][`PartialEq<Self>`]eq().==rust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidgetType][`PartialEq<Self>`]eq(). rust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidgetType][`PartialEq<Self>`]eq().widget.widget_typerust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_type. { |
| 600 | initial_widget_id = widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id.; |
| 601 | initial_widget_type = widget.widget_typerust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_type..clonerust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidgetType][Clone]clone().(); |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | used_widget_set.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(widget.widget_typerust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_type..clonerust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidgetType][Clone]clone().()); |
| 608 | |
| 609 | match widget.widget_typerust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_type. { |
| 610 | Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu# => { |
| 611 | cpu_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 612 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 613 | CpuWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#::newrust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/impl#[CpuWidgetState]new().( |
| 614 | &app_config_fields, |
| 615 | default_cpu_selection, |
| 616 | autohide_timer, |
| 617 | &styling, |
| 618 | ), |
| 619 | ); |
| 620 | } |
| 621 | Memrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Mem# => { |
| 622 | mem_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 623 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 624 | MemWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/mem_graph/MemWidgetState#::initrust-analyzer cargo bottom 0.14.9 widgets/mem_graph/impl#[MemWidgetState]init().(ts_config, autohide_timer), |
| 625 | ); |
| 626 | } |
| 627 | Netrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Net# => { |
| 628 | net_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 629 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 630 | NetWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/network_graph/NetWidgetState#::initrust-analyzer cargo bottom 0.14.9 widgets/network_graph/impl#[NetWidgetState]init().(ts_config, autohide_timer), |
| 631 | ); |
| 632 | } |
| 633 | Procrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Proc# => { |
| 634 | let mode = if is_grouped { |
| 635 | ProcWidgetModerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#::Groupedrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#Grouped# |
| 636 | } else if is_default_tree { |
| 637 | ProcWidgetModerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#::Treerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#Tree#(TreeCollapsedrust-analyzer cargo bottom 0.14.9 widgets/process_table/TreeCollapsed#::newrust-analyzer cargo bottom 0.14.9 widgets/process_table/impl#[TreeCollapsed]new().(is_default_tree_collapsed)) |
| 638 | } else { |
| 639 | ProcWidgetModerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#::Normalrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetMode#Normal# |
| 640 | }; |
| 641 | |
| 642 | proc_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 643 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 644 | ProcWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#::newrust-analyzer cargo bottom 0.14.9 widgets/process_table/impl#[ProcWidgetState]new().( |
| 645 | &app_config_fields, |
| 646 | mode, |
| 647 | table_config, |
| 648 | &styling, |
| 649 | &proc_columns, |
| 650 | ), |
| 651 | ); |
| 652 | } |
| 653 | Diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Disk# => { |
| 654 | disk_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 655 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 656 | DiskTableWidgetrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskTableWidget#::newrust-analyzer cargo bottom 0.14.9 widgets/disk_table/impl#[DiskTableWidget]new().( |
| 657 | &app_config_fields, |
| 658 | &styling, |
| 659 | config.diskrust-analyzer cargo bottom 0.14.9 options/config/Config#disk..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.columnsrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#columns..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()), |
| 660 | disk_show_unmounted, |
| 661 | ), |
| 662 | ); |
| 663 | } |
| 664 | Temprust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Temp# => { |
| 665 | temp_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 666 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 667 | TempWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/temperature_table/TempWidgetState#::newrust-analyzer cargo bottom 0.14.9 widgets/temperature_table/impl#[TempWidgetState]new().(&app_config_fields, &styling), |
| 668 | ); |
| 669 | } |
| 670 | TempGraphrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#TempGraph# => { |
| 671 | let upper_limit = config |
| 672 | .temperature_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#temperature_graph. |
| 673 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 674 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.max_temprust-analyzer cargo bottom 0.14.9 options/config/temperature_graph/TempGraphConfig#max_temp.) |
| 675 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| v as f32); |
| 676 | temp_graph_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 677 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 678 | TempGraphWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/TempGraphWidgetState#::newrust-analyzer cargo bottom 0.14.9 widgets/temperature_graph/impl#[TempGraphWidgetState]new().(ts_config, autohide_timer, upper_limit), |
| 679 | ); |
| 680 | } |
| 681 | DiskIoGraphrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#DiskIoGraph# => { |
| 682 | let show_read = config |
| 683 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 684 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 685 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|c| c.show_readrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#show_read.) |
| 686 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(true); |
| 687 | |
| 688 | let show_write = config |
| 689 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 690 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 691 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|c| c.show_writerust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#show_write.) |
| 692 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(true); |
| 693 | |
| 694 | let legend = config |
| 695 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 696 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 697 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|c| c.legendrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#legend..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().()) |
| 698 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 699 | |
| 700 | let use_log = config |
| 701 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 702 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 703 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|c| c.use_logrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#use_log.) |
| 704 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false); |
| 705 | |
| 706 | disk_io_graph_state_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().( |
| 707 | widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., |
| 708 | DiskIoGraphWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/DiskIoGraphWidgetState#::newrust-analyzer cargo bottom 0.14.9 widgets/disk_io_graph/impl#[DiskIoGraphWidgetState]new().( |
| 709 | ts_config, |
| 710 | autohide_timer, |
| 711 | show_read, |
| 712 | show_write, |
| 713 | legend, |
| 714 | use_log, |
| 715 | ), |
| 716 | ); |
| 717 | } |
| 718 | Batteryrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Battery# => { |
| 719 | battery_state_map |
| 720 | .insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(widget.widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id., BatteryWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/battery_info/BatteryWidgetState#::defaultrust-analyzer cargo bottom 0.14.9 widgets/battery_info/impl#[BatteryWidgetState][Default]default().()); |
| 721 | } |
| 722 | // FIXME: This is kind of a hack that we have these cases at all. |
| 723 | Emptyrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Empty# | BasicCpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicCpu# | BasicMemrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicMem# | BasicNetrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicNet# | BasicTablesrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicTables# | CpuLegendrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#CpuLegend# |
| 724 | | ProcSortrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#ProcSort# | ProcSearchrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#ProcSearch# => {} |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | let basic_table_widget_state = if use_basic_mode { |
| 732 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(match initial_widget_type { |
| 733 | Procrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Proc# | Diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Disk# | Temprust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Temp# => BasicTableWidgetStaterust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState# { |
| 734 | currently_displayed_widget_typerust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#currently_displayed_widget_type.: initial_widget_type, |
| 735 | currently_displayed_widget_idrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#currently_displayed_widget_id.: initial_widget_id, |
| 736 | left_tlcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#left_tlc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 737 | left_brcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#left_brc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 738 | right_tlcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#right_tlc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 739 | right_brcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#right_brc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 740 | }, |
| 741 | _ => BasicTableWidgetStaterust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState# { |
| 742 | currently_displayed_widget_typerust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#currently_displayed_widget_type.: Procrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Proc#, |
| 743 | currently_displayed_widget_idrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#currently_displayed_widget_id.: DEFAULT_WIDGET_IDrust-analyzer cargo bottom 0.14.9 constants/DEFAULT_WIDGET_ID., |
| 744 | left_tlcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#left_tlc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 745 | left_brcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#left_brc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 746 | right_tlcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#right_tlc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 747 | right_brcrust-analyzer cargo bottom 0.14.9 app/states/BasicTableWidgetState#right_brc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 748 | }, |
| 749 | }) |
| 750 | } else { |
| 751 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 752 | }; |
| 753 | |
| 754 | let use_mem = used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Memrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Mem#) || used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&BasicMemrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicMem#); |
| 755 | let used_widgets = UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets# { |
| 756 | use_cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cpu.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Cpu#) || used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&BasicCpurust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicCpu#), |
| 757 | use_memrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_mem., |
| 758 | use_cacherust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cache.: use_mem && enable_cache_memory, |
| 759 | use_gpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_gpu.: enable_gpu, |
| 760 | use_netrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_net.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Netrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Net#) || used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&BasicNetrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#BasicNet#), |
| 761 | use_procrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_proc.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Procrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Proc#), |
| 762 | use_diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_disk.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Disk#), |
| 763 | use_temprust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Temprust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Temp#), |
| 764 | use_temp_graphrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp_graph.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&TempGraphrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#TempGraph#), |
| 765 | use_disk_io_graphrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_disk_io_graph.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&DiskIoGraphrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#DiskIoGraph#), |
| 766 | use_batteryrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_battery.: used_widget_set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&Batteryrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Battery#), |
| 767 | }; |
| 768 | |
| 769 | let (disk_name_filter, disk_mount_filter) = { |
| 770 | match &config.diskrust-analyzer cargo bottom 0.14.9 options/config/Config#disk. { |
| 771 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg) => { |
| 772 | let df = get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.name_filterrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#name_filter.) |
| 773 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'disk.name_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 774 | let mf = get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.mount_filterrust-analyzer cargo bottom 0.14.9 options/config/disk/DiskConfig#mount_filter.) |
| 775 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'disk.mount_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 776 | |
| 777 | (df, mf) |
| 778 | } |
| 779 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 780 | } |
| 781 | }; |
| 782 | let temp_sensor_filter = match &config.temperaturerust-analyzer cargo bottom 0.14.9 options/config/Config#temperature. { |
| 783 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg) => get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.sensor_filterrust-analyzer cargo bottom 0.14.9 options/config/temperature/TempConfig#sensor_filter.) |
| 784 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'temperature.sensor_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 785 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 786 | }; |
| 787 | let temp_graph_sensor_filter = match &config.temperature_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#temperature_graph. { |
| 788 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg) => get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.sensor_filterrust-analyzer cargo bottom 0.14.9 options/config/temperature_graph/TempGraphConfig#sensor_filter.) |
| 789 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'temperature_graph.sensor_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 790 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 791 | }; |
| 792 | let net_interface_filter = match &config.network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph. { |
| 793 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cfg) => get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(&cfg.interface_filterrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#interface_filter.) |
| 794 | .contextrust-analyzer cargo anyhow 1.0.104 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("Update 'network_graph.interface_filter' in your config file")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 795 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 796 | }; |
| 797 | |
| 798 | let states = AppWidgetStatesrust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates# { |
| 799 | cpu_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#cpu_state.: CpuStaterust-analyzer cargo bottom 0.14.9 app/states/CpuState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[CpuState]init().(cpu_state_map), |
| 800 | mem_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#mem_state.: MemStaterust-analyzer cargo bottom 0.14.9 app/states/MemState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[MemState]init().(mem_state_map), |
| 801 | net_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#net_state.: NetStaterust-analyzer cargo bottom 0.14.9 app/states/NetState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[NetState]init().(net_state_map), |
| 802 | proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state.: ProcStaterust-analyzer cargo bottom 0.14.9 app/states/ProcState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[ProcState]init().(proc_state_map), |
| 803 | temp_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#temp_state.: TempStaterust-analyzer cargo bottom 0.14.9 app/states/TempState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[TempState]init().(temp_state_map), |
| 804 | temp_graph_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#temp_graph_state.: TempGraphStatesrust-analyzer cargo bottom 0.14.9 app/states/TempGraphStates#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[TempGraphStates]init().(temp_graph_state_map), |
| 805 | disk_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#disk_state.: DiskStaterust-analyzer cargo bottom 0.14.9 app/states/DiskState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[DiskState]init().(disk_state_map), |
| 806 | disk_io_graph_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#disk_io_graph_state.: DiskIoGraphStatesrust-analyzer cargo bottom 0.14.9 app/states/DiskIoGraphStates#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[DiskIoGraphStates]init().(disk_io_graph_state_map), |
| 807 | battery_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#battery_state.: AppBatteryStaterust-analyzer cargo bottom 0.14.9 app/states/AppBatteryState#::initrust-analyzer cargo bottom 0.14.9 app/states/impl#[AppBatteryState]init().(battery_state_map), |
| 808 | basic_table_widget_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#basic_table_widget_state., |
| 809 | }; |
| 810 | |
| 811 | let current_widget = widget_map |
| 812 | .getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&initial_widget_id) |
| 813 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("widget map should have the initial widget ID") |
| 814 | .clonerust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomWidget][Clone]clone().(); |
| 815 | let filters = DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters# { |
| 816 | disk_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#disk_filter.: disk_name_filter, |
| 817 | mount_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#mount_filter.: disk_mount_filter, |
| 818 | temp_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_filter.: temp_sensor_filter, |
| 819 | temp_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_graph_filter.: temp_graph_sensor_filter, |
| 820 | disk_io_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#disk_io_graph_filter.: disk_io_name_filter, |
| 821 | net_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#net_filter.: net_interface_filter, |
| 822 | }; |
| 823 | let is_expanded = expanded && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().use_basic_mode; |
| 824 | |
| 825 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(( |
| 826 | Apprust-analyzer cargo bottom 0.14.9 app/App#::newrust-analyzer cargo bottom 0.14.9 app/impl#[App]new().( |
| 827 | app_config_fields, |
| 828 | states, |
| 829 | widget_map, |
| 830 | current_widget, |
| 831 | used_widgets, |
| 832 | filters, |
| 833 | is_expanded, |
| 834 | ), |
| 835 | widget_layout, |
| 836 | styling, |
| 837 | )) |
| 838 | } |
| 839 | |
| 840 | fn get_widget_layoutrust-analyzer cargo bottom 0.14.9 options/get_widget_layout().( |
| 841 | args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, |
| 842 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<(BottomLayoutrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#, u64, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BottomWidgetTyperust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#>)> { |
| 843 | let cpu_left_legend = enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 844 | args.cpurust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#cpu..cpu_left_legendrust-analyzer cargo bottom 0.14.9 options/args/CpuArgs#cpu_left_legend., |
| 845 | config, |
| 846 | cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu..left_legendrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#left_legend., |
| 847 | flags.cpu_left_legendrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#cpu_left_legend., |
| 848 | ); |
| 849 | |
| 850 | let (default_widget_type, mut default_widget_count) = |
| 851 | get_default_widget_and_countrust-analyzer cargo bottom 0.14.9 options/get_default_widget_and_count().(args, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 852 | let mut default_widget_id = 1; |
| 853 | |
| 854 | let bottom_layout = if is_flag_enabledrust-analyzer cargo bottom 0.14.9 options/is_flag_enabled!!(basicrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#basic., args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general., config) { |
| 855 | default_widget_id = DEFAULT_WIDGET_IDrust-analyzer cargo bottom 0.14.9 constants/DEFAULT_WIDGET_ID.; |
| 856 | |
| 857 | BottomLayoutrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#::init_basic_defaultrust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomLayout]init_basic_default().(get_use_batteryrust-analyzer cargo bottom 0.14.9 options/get_use_battery().(args, config)) |
| 858 | } else { |
| 859 | let ref_row: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Rowrust-analyzer cargo bottom 0.14.9 options/config/layout/Row#>; // Required to handle reference |
| 860 | let rows = match &config.rowrust-analyzer cargo bottom 0.14.9 options/config/Config#row. { |
| 861 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(r) => r, |
| 862 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 863 | ref_row = toml_editrust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 crate/::derust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 de/::from_strrust-analyzer cargo toml_edit 0.25.12+spec-1.1.0 de/from_str().::<Configrust-analyzer cargo bottom 0.14.9 options/config/Config#>(if get_use_batteryrust-analyzer cargo bottom 0.14.9 options/get_use_battery().(args, config) { |
| 864 | DEFAULT_BATTERY_LAYOUTrust-analyzer cargo bottom 0.14.9 constants/DEFAULT_BATTERY_LAYOUT. |
| 865 | } else { |
| 866 | DEFAULT_LAYOUTrust-analyzer cargo bottom 0.14.9 constants/DEFAULT_LAYOUT. |
| 867 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 868 | .rowrust-analyzer cargo bottom 0.14.9 options/config/Config#row. |
| 869 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("This cannot (like it really shouldn't) fail!"); |
| 870 | &ref_row |
| 871 | } |
| 872 | }; |
| 873 | |
| 874 | let mut iter_id = 0; // A lazy way of forcing unique IDs *shrugs* |
| 875 | let mut total_height_ratio = 0; |
| 876 | |
| 877 | let mut ret_bottom_layout = BottomLayoutrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout# { |
| 878 | rowsrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#rows.: rows |
| 879 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 880 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|row| { |
| 881 | row.convert_row_to_bottom_rowrust-analyzer cargo bottom 0.14.9 options/config/layout/impl#[Row]convert_row_to_bottom_row().( |
| 882 | &mut iter_id, |
| 883 | &mut total_height_ratio, |
| 884 | &mut default_widget_id, |
| 885 | &default_widget_type, |
| 886 | &mut default_widget_count, |
| 887 | cpu_left_legend, |
| 888 | ) |
| 889 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::configrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]config().(err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 890 | }) |
| 891 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 892 | total_row_height_ratiorust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomLayout#total_row_height_ratio.: total_height_ratio, |
| 893 | }; |
| 894 | |
| 895 | // Confirm that we have at least ONE widget left - if not, error out! |
| 896 | if iter_id rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 897 | ret_bottom_layout.get_movement_mappingsrust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[BottomLayout]get_movement_mappings().(); |
| 898 | ret_bottom_layout |
| 899 | } else { |
| 900 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::configrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]config().( |
| 901 | "have at least one widget under the '[[row]]' section.", |
| 902 | )); |
| 903 | } |
| 904 | }; |
| 905 | |
| 906 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((bottom_layout, default_widget_id, default_widget_type)) |
| 907 | } |
| 908 | |
| 909 | #[inline] |
| 910 | fn try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(s: &str) -> Resultrust-analyzer cargo anyhow 1.0.104 Result#<u64, ()> { |
| 911 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(val) = humantimerust-analyzer cargo humantime 2.3.0 crate/::parse_durationrust-analyzer cargo humantime 2.3.0 duration/parse_duration().(s) { |
| 912 | val.as_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_millis().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| ())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 913 | } else if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(val) = s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<u64>() { |
| 914 | val |
| 915 | } else { |
| 916 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()); |
| 917 | }) |
| 918 | } |
| 919 | |
| 920 | macro_rules! parse_arg_valuerust-analyzer cargo bottom 0.14.9 options/parse_arg_value! { |
| 921 | ($to_try:expr, $flag:literal) => { |
| 922 | $to_try.map_err(|_| OptionError::invalid_arg_value($flag)) |
| 923 | }; |
| 924 | } |
| 925 | |
| 926 | macro_rules! parse_config_valuerust-analyzer cargo bottom 0.14.9 options/parse_config_value! { |
| 927 | ($to_try:expr, $setting:literal) => { |
| 928 | $to_try.map_err(|_| OptionError::invalid_config_value($setting)) |
| 929 | }; |
| 930 | } |
| 931 | |
| 932 | macro_rules! parse_ms_optionrust-analyzer cargo bottom 0.14.9 options/parse_ms_option! { |
| 933 | ($arg_expr:expr, $config_expr:expr, $default_value:expr, $setting:literal, $low:expr, $high:expr $(,)?) => {{ |
| 934 | use humantime::format_duration; |
| 935 | |
| 936 | if let Some(to_parse) = $arg_expr { |
| 937 | let value = parse_arg_value!(try_parse_ms(to_parse), $setting)?; |
| 938 | |
| 939 | if let Some(limit) = $low { |
| 940 | if value < limit { |
| 941 | return Err(OptionError::arg(format!( |
| 942 | "'--{}' must be greater than {}", |
| 943 | $setting, |
| 944 | format_duration(Duration::from_millis(limit)) |
| 945 | ))); |
| 946 | } |
| 947 | } |
| 948 | |
| 949 | if let Some(limit) = $high { |
| 950 | if value > limit { |
| 951 | return Err(OptionError::arg(format!( |
| 952 | "'--{}' must be less than {}", |
| 953 | $setting, |
| 954 | format_duration(Duration::from_millis(limit)) |
| 955 | ))); |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | Ok(value) |
| 960 | } else if let Some(to_parse) = $config_expr { |
| 961 | let value = match to_parse { |
| 962 | StringOrNum::String(s) => parse_config_value!(try_parse_ms(s), $setting)?, |
| 963 | StringOrNum::Num(n) => *n, |
| 964 | }; |
| 965 | |
| 966 | if let Some(limit) = $low { |
| 967 | if value < limit { |
| 968 | return Err(OptionError::arg(format!( |
| 969 | "'{}' must be greater than {}", |
| 970 | $setting, |
| 971 | format_duration(Duration::from_millis(limit)) |
| 972 | ))); |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | if let Some(limit) = $high { |
| 977 | if value > limit { |
| 978 | return Err(OptionError::arg(format!( |
| 979 | "'{}' must be less than {}", |
| 980 | $setting, |
| 981 | format_duration(Duration::from_millis(limit)) |
| 982 | ))); |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | Ok(value) |
| 987 | } else { |
| 988 | Ok($default_value) |
| 989 | } |
| 990 | }}; |
| 991 | } |
| 992 | |
| 993 | /// Mark a config option field as deprecated, and what to use instead. |
| 994 | #[inline] |
| 995 | fn deprecated_warningrust-analyzer cargo bottom 0.14.9 options/deprecated_warning().(deprecated_field: &str, new_field: &str) { |
| 996 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!( |
| 997 | "Warning: The config option '{deprecated_field}' is deprecated and will eventually be removed. Please use '{new_field}' instead.", |
| 998 | ); |
| 999 | } |
| 1000 | |
| 1001 | /// Mark a config option field as deprecated, and what to use instead with an alias. |
| 1002 | #[inline] |
| 1003 | fn deprecated_warning_with_aliasrust-analyzer cargo bottom 0.14.9 options/deprecated_warning_with_alias().(deprecated_field: &str, new_field: &str, alias: &str) { |
| 1004 | eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!( |
| 1005 | "Warning: The config option '{deprecated_field}' is deprecated and will eventually be removed. Please use '{new_field}' or '{alias}' instead.", |
| 1006 | ); |
| 1007 | } |
| 1008 | |
| 1009 | /// How quickly we update data. |
| 1010 | #[inline] |
| 1011 | fn get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<u64> { |
| 1012 | const DEFAULT_REFRESH_RATE_IN_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_REFRESH_RATE_IN_MILLISECONDS.: u64 = 1000; |
| 1013 | |
| 1014 | parse_ms_optionrust-analyzer cargo bottom 0.14.9 options/parse_ms_option!!( |
| 1015 | &args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..raterust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#rate., |
| 1016 | config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.raterust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#rate..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1017 | DEFAULT_REFRESH_RATE_IN_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_REFRESH_RATE_IN_MILLISECONDS., |
| 1018 | "rate", |
| 1019 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(250), |
| 1020 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1021 | ) |
| 1022 | } |
| 1023 | |
| 1024 | fn get_temperaturerust-analyzer cargo bottom 0.14.9 options/get_temperature().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#> { |
| 1025 | if args.temperaturerust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#temperature..fahrenheitrust-analyzer cargo bottom 0.14.9 options/args/TemperatureArgs#fahrenheit. { |
| 1026 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Fahrenheitrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Fahrenheit#); |
| 1027 | } else if args.temperaturerust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#temperature..kelvinrust-analyzer cargo bottom 0.14.9 options/args/TemperatureArgs#kelvin. { |
| 1028 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Kelvinrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Kelvin#); |
| 1029 | } else if args.temperaturerust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#temperature..celsiusrust-analyzer cargo bottom 0.14.9 options/args/TemperatureArgs#celsius. { |
| 1030 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Celsiusrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Celsius#); |
| 1031 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1032 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(temp_type) = &flags.temperature_typerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#temperature_type. |
| 1033 | { |
| 1034 | return parse_config_valuerust-analyzer cargo bottom 0.14.9 options/parse_config_value!!(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::from_strrust-analyzer cargo bottom 0.14.9 app/data/temperature/impl#[TemperatureType][FromStr]from_str().(temp_type), "temperature_type"); |
| 1035 | } |
| 1036 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TemperatureTyperust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#::Celsiusrust-analyzer cargo bottom 0.14.9 app/data/temperature/TemperatureType#Celsius#) |
| 1037 | } |
| 1038 | |
| 1039 | /// Yes, this function gets whether to show average CPU (true) or not (false). |
| 1040 | fn get_show_average_cpurust-analyzer cargo bottom 0.14.9 options/get_show_average_cpu().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1041 | if args.cpurust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#cpu..hide_avg_cpurust-analyzer cargo bottom 0.14.9 options/args/CpuArgs#hide_avg_cpu. { |
| 1042 | return false; |
| 1043 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu) = &config.cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu. { |
| 1044 | return !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cpu.hide_avg_cpurust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#hide_avg_cpu..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false); |
| 1045 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1046 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hide) = flags.hide_avg_cpurust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#hide_avg_cpu. |
| 1047 | { |
| 1048 | deprecated_warningrust-analyzer cargo bottom 0.14.9 options/deprecated_warning().("hide_avg_cpu", "cpu.hide_avg_cpu"); |
| 1049 | return !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().hide; |
| 1050 | } |
| 1051 | |
| 1052 | true |
| 1053 | } |
| 1054 | |
| 1055 | // I hate this too. |
| 1056 | fn get_default_cpu_selectionrust-analyzer cargo bottom 0.14.9 options/get_default_cpu_selection().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> configrust-analyzer cargo bottom 0.14.9 options/config/::cpurust-analyzer cargo bottom 0.14.9 options/config/cpu/::CpuDefaultrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuDefault# { |
| 1057 | match &args.cpurust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#cpu..default_cpu_entryrust-analyzer cargo bottom 0.14.9 options/args/CpuArgs#default_cpu_entry. { |
| 1058 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(default) => match default { |
| 1059 | argsrust-analyzer cargo bottom 0.14.9 options/args/::CpuDefaultrust-analyzer cargo bottom 0.14.9 options/args/CpuDefault#::Allrust-analyzer cargo bottom 0.14.9 options/args/CpuDefault#All# => configrust-analyzer cargo bottom 0.14.9 options/config/::cpurust-analyzer cargo bottom 0.14.9 options/config/cpu/::CpuDefaultrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuDefault#::Allrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuDefault#All#, |
| 1060 | argsrust-analyzer cargo bottom 0.14.9 options/args/::CpuDefaultrust-analyzer cargo bottom 0.14.9 options/args/CpuDefault#::Averagerust-analyzer cargo bottom 0.14.9 options/args/CpuDefault#Average# => configrust-analyzer cargo bottom 0.14.9 options/config/::cpurust-analyzer cargo bottom 0.14.9 options/config/cpu/::CpuDefaultrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuDefault#::Averagerust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuDefault#Average#, |
| 1061 | }, |
| 1062 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => config.cpurust-analyzer cargo bottom 0.14.9 options/config/Config#cpu..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|c| c.defaultrust-analyzer cargo bottom 0.14.9 options/config/cpu/CpuConfig#default.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | #[inline] |
| 1067 | fn get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().( |
| 1068 | args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, retention_ms: u64, |
| 1069 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<u64> { |
| 1070 | const DEFAULT_TIME_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_TIME_MILLISECONDS.: u64 = 60 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1000; // Defaults to 1 min. |
| 1071 | |
| 1072 | parse_ms_optionrust-analyzer cargo bottom 0.14.9 options/parse_ms_option!!( |
| 1073 | &args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..default_time_valuerust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#default_time_value., |
| 1074 | config |
| 1075 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1076 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1077 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.default_time_valuerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_time_value..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1078 | DEFAULT_TIME_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_TIME_MILLISECONDS., |
| 1079 | "default_time_value", |
| 1080 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(30000), |
| 1081 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(retention_ms), |
| 1082 | ) |
| 1083 | } |
| 1084 | |
| 1085 | #[inline] |
| 1086 | fn get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, retention_ms: u64) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<u64> { |
| 1087 | const TIME_CHANGE_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/TIME_CHANGE_MILLISECONDS.: u64 = 15 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1000; // How much to increment each time |
| 1088 | |
| 1089 | parse_ms_optionrust-analyzer cargo bottom 0.14.9 options/parse_ms_option!!( |
| 1090 | &args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..time_deltarust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#time_delta., |
| 1091 | config |
| 1092 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1093 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1094 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.time_deltarust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#time_delta..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1095 | TIME_CHANGE_MILLISECONDSrust-analyzer cargo bottom 0.14.9 options/TIME_CHANGE_MILLISECONDS., |
| 1096 | "time_delta", |
| 1097 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1000), |
| 1098 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(retention_ms), |
| 1099 | ) |
| 1100 | } |
| 1101 | |
| 1102 | fn get_default_widget_and_countrust-analyzer cargo bottom 0.14.9 options/get_default_widget_and_count().( |
| 1103 | args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, |
| 1104 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BottomWidgetTyperust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#>, u64)> { |
| 1105 | let widget_type = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type) = &args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..default_widget_typerust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#default_widget_type. { |
| 1106 | let parsed_widget = parse_arg_valuerust-analyzer cargo bottom 0.14.9 options/parse_arg_value!!(widget_type.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), "default_widget_type")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1107 | if let BottomWidgetTyperust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#::Emptyrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Empty# = parsed_widget { |
| 1108 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 1109 | } else { |
| 1110 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parsed_widget) |
| 1111 | } |
| 1112 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. { |
| 1113 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type) = &flags.default_widget_typerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_widget_type. { |
| 1114 | let parsed_widget = parse_config_valuerust-analyzer cargo bottom 0.14.9 options/parse_config_value!!(widget_type.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), "default_widget_type")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1115 | if let BottomWidgetTyperust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#::Emptyrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidgetType#Empty# = parsed_widget { |
| 1116 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 1117 | } else { |
| 1118 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parsed_widget) |
| 1119 | } |
| 1120 | } else { |
| 1121 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 1122 | } |
| 1123 | } else { |
| 1124 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 1125 | }; |
| 1126 | |
| 1127 | let widget_count: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u128> = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_count) = args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..default_widget_countrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#default_widget_count. { |
| 1128 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_count.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1129 | } else { |
| 1130 | config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| { |
| 1131 | flags |
| 1132 | .default_widget_countrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_widget_count. |
| 1133 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|widget_count| widget_count.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1134 | }) |
| 1135 | }; |
| 1136 | |
| 1137 | match (widget_type, widget_count) { |
| 1138 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_count)) => { |
| 1139 | let widget_count = widget_count.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::otherrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]other().( |
| 1140 | "set your widget count to be at most 18446744073709551615.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 1141 | ))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1142 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type), widget_count)) |
| 1143 | } |
| 1144 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget_type), 1)), |
| 1145 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_widget_count)) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::otherrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]other().( |
| 1146 | "cannot set 'default_widget_count' by itself, it must be used with 'default_widget_type'.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1147 | )), |
| 1148 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, 1)) |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | #[cfg(feature = "battery")] |
| 1153 | fn get_use_batteryrust-analyzer cargo bottom 0.14.9 options/get_use_battery().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1154 | // TODO: Move this so it's dynamic in the app itself and automatically hide if |
| 1155 | // there are no batteries? |
| 1156 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(battery_manager) = Managerrust-analyzer cargo starship-battery 0.11.1 types/manager/Manager#::newrust-analyzer cargo starship-battery 0.11.1 types/manager/impl#[Manager]new().() |
| 1157 | && let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(batteries) = battery_manager.batteriesrust-analyzer cargo starship-battery 0.11.1 types/manager/impl#[Manager]batteries().() |
| 1158 | && batteries.countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 |
| 1159 | { |
| 1160 | return false; |
| 1161 | } |
| 1162 | |
| 1163 | if args.batteryrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#battery..batteryrust-analyzer cargo bottom 0.14.9 options/args/BatteryArgs#battery. { |
| 1164 | return true; |
| 1165 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1166 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(battery) = flags.batteryrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#battery. |
| 1167 | { |
| 1168 | return battery; |
| 1169 | } |
| 1170 | |
| 1171 | false |
| 1172 | } |
| 1173 | |
| 1174 | #[cfg(not(feature = "battery"))] |
| 1175 | fn get_use_battery(_args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, _config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1176 | false |
| 1177 | } |
| 1178 | |
| 1179 | #[cfg(feature = "gpu")] |
| 1180 | fn get_enable_gpurust-analyzer cargo bottom 0.14.9 options/get_enable_gpu().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1181 | if args.gpurust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#gpu..disable_gpurust-analyzer cargo bottom 0.14.9 options/args/GpuArgs#disable_gpu. { |
| 1182 | return false; |
| 1183 | } |
| 1184 | |
| 1185 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().config |
| 1186 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1187 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1188 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|f| f.disable_gpurust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#disable_gpu.) |
| 1189 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 1190 | } |
| 1191 | |
| 1192 | #[cfg(not(feature = "gpu"))] |
| 1193 | fn get_enable_gpu(_: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, _: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1194 | false |
| 1195 | } |
| 1196 | |
| 1197 | #[cfg(feature = "gpu")] |
| 1198 | fn get_short_gpu_namesrust-analyzer cargo bottom 0.14.9 options/get_short_gpu_names().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1199 | if args.memoryrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#memory..short_gpu_namesrust-analyzer cargo bottom 0.14.9 options/args/MemoryArgs#short_gpu_names. { |
| 1200 | return true; |
| 1201 | } |
| 1202 | |
| 1203 | config |
| 1204 | .memory_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#memory_graph. |
| 1205 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1206 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|m| m.short_gpu_namesrust-analyzer cargo bottom 0.14.9 options/config/memory_graph/MemoryGraphConfig#short_gpu_names.) |
| 1207 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 1208 | } |
| 1209 | |
| 1210 | #[cfg(not(feature = "gpu"))] |
| 1211 | fn get_short_gpu_names(_: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, _: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1212 | false |
| 1213 | } |
| 1214 | |
| 1215 | #[cfg(not(target_os = "windows"))] |
| 1216 | fn get_enable_cache_memoryrust-analyzer cargo bottom 0.14.9 options/get_enable_cache_memory().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1217 | enabled_option_with_deprecatedrust-analyzer cargo bottom 0.14.9 options/enabled_option_with_deprecated!!( |
| 1218 | args.memoryrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#memory..enable_cache_memoryrust-analyzer cargo bottom 0.14.9 options/args/MemoryArgs#enable_cache_memory., |
| 1219 | config, |
| 1220 | memory_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#memory_graph..cache_memoryrust-analyzer cargo bottom 0.14.9 options/config/memory_graph/MemoryGraphConfig#cache_memory., |
| 1221 | flags.enable_cache_memoryrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#enable_cache_memory., |
| 1222 | "memory.cache_memory", |
| 1223 | ) |
| 1224 | } |
| 1225 | |
| 1226 | #[cfg(target_os = "windows")] |
| 1227 | fn get_enable_cache_memory(_args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, _config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> bool { |
| 1228 | false |
| 1229 | } |
| 1230 | |
| 1231 | fn get_ignore_listrust-analyzer cargo bottom 0.14.9 options/get_ignore_list().(ignore_list: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<IgnoreListrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#>) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#>> { |
| 1232 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ignore_list) = ignore_list { |
| 1233 | let list: Resultrust-analyzer cargo anyhow 1.0.104 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _> = ignore_list |
| 1234 | .listrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#list. |
| 1235 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 1236 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|name| { |
| 1237 | let escaped_string: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 1238 | let res = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 1239 | "{}{}{}{}", |
| 1240 | if ignore_list.whole_wordrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#whole_word. { "^" } else { "" }, |
| 1241 | if ignore_list.case_sensitiverust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#case_sensitive. { |
| 1242 | "" |
| 1243 | } else { |
| 1244 | "(?i)" |
| 1245 | }, |
| 1246 | if ignore_list.regexrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#regex. { |
| 1247 | name |
| 1248 | } else { |
| 1249 | escaped_string = regexrust-analyzer cargo regex 1.13.1 crate/::escaperust-analyzer cargo regex 1.13.1 escape().(name); |
| 1250 | &escaped_string |
| 1251 | }, |
| 1252 | if ignore_list.whole_wordrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#whole_word. { "$" } else { "" }, |
| 1253 | ); |
| 1254 | |
| 1255 | Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#::newrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]new().(&res) |
| 1256 | }) |
| 1257 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1258 | |
| 1259 | let list = list.map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::configrust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]config().(err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1260 | |
| 1261 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#::newrust-analyzer cargo bottom 0.14.9 app/filter/impl#[Filter]new().(ignore_list.is_list_ignoredrust-analyzer cargo bottom 0.14.9 options/config/ignore_list/IgnoreList#is_list_ignored., list))) |
| 1262 | } else { |
| 1263 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | fn get_network_unit_typerust-analyzer cargo bottom 0.14.9 options/get_network_unit_type().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit# { |
| 1268 | if args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network..network_use_bytesrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#network_use_bytes. { |
| 1269 | return DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte#; |
| 1270 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(use_bytes) = config.network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.use_bytesrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#use_bytes.) { |
| 1271 | if use_bytes { |
| 1272 | return DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte#; |
| 1273 | } |
| 1274 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1275 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network_use_bytes) = flags.network_use_bytesrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#network_use_bytes. |
| 1276 | { |
| 1277 | deprecated_warning_with_aliasrust-analyzer cargo bottom 0.14.9 options/deprecated_warning_with_alias().( |
| 1278 | "network_use_bytes", |
| 1279 | "network_graph.use_bytes", |
| 1280 | "network.use_bytes", |
| 1281 | ); |
| 1282 | |
| 1283 | if network_use_bytes { |
| 1284 | return DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Byterust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Byte#; |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | DataUnitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#::Bitrust-analyzer cargo bottom 0.14.9 utils/data_units/DataUnit#Bit# |
| 1289 | } |
| 1290 | |
| 1291 | fn get_network_scale_typerust-analyzer cargo bottom 0.14.9 options/get_network_scale_type().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling# { |
| 1292 | if args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network..network_use_logrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#network_use_log. { |
| 1293 | return AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Logrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Log#; |
| 1294 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(use_log) = config.network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.use_logrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#use_log.) { |
| 1295 | if use_log { |
| 1296 | return AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Logrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Log#; |
| 1297 | } |
| 1298 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags) = &config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1299 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network_use_log) = flags.network_use_logrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#network_use_log. |
| 1300 | { |
| 1301 | deprecated_warning_with_aliasrust-analyzer cargo bottom 0.14.9 options/deprecated_warning_with_alias().( |
| 1302 | "network_use_log", |
| 1303 | "network_graph.use_log", |
| 1304 | "network.use_log", |
| 1305 | ); |
| 1306 | |
| 1307 | if network_use_log { |
| 1308 | return AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Logrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Log#; |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | AxisScalingrust-analyzer cargo bottom 0.14.9 app/AxisScaling#::Linearrust-analyzer cargo bottom 0.14.9 app/AxisScaling#Linear# |
| 1313 | } |
| 1314 | |
| 1315 | fn get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention().(args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<u64> { |
| 1316 | const DEFAULT_RETENTION_MSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_RETENTION_MS.: u64 = 600 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1000; // Keep 10 minutes of data. |
| 1317 | |
| 1318 | parse_ms_optionrust-analyzer cargo bottom 0.14.9 options/parse_ms_option!!( |
| 1319 | &args.generalrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#general..retentionrust-analyzer cargo bottom 0.14.9 options/args/GeneralArgs#retention., |
| 1320 | config |
| 1321 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1322 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1323 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.retentionrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#retention..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1324 | DEFAULT_RETENTION_MSrust-analyzer cargo bottom 0.14.9 options/DEFAULT_RETENTION_MS., |
| 1325 | "retention", |
| 1326 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1327 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1328 | ) |
| 1329 | } |
| 1330 | |
| 1331 | #[inline] |
| 1332 | fn parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().( |
| 1333 | arg: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, cfg: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, deprecated_cfg: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'static str)>, |
| 1334 | setting: &'static str, alias: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'static str>, |
| 1335 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1336 | #[inline] |
| 1337 | fn parse_position_or_errrust-analyzer cargo bottom 0.14.9 options/parse_position_or_err().<F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(&'static str) -> OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#>( |
| 1338 | s: &str, setting: &'static str, err_fn: F, |
| 1339 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1340 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match s.to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().().trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().() { |
| 1341 | "none" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1342 | position => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(position.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| err_fn(setting))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 1343 | }) |
| 1344 | } |
| 1345 | |
| 1346 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = arg { |
| 1347 | parse_position_or_errrust-analyzer cargo bottom 0.14.9 options/parse_position_or_err().(s, setting, OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::invalid_arg_valuerust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]invalid_arg_value().) |
| 1348 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = cfg { |
| 1349 | parse_position_or_errrust-analyzer cargo bottom 0.14.9 options/parse_position_or_err().(s, setting, OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::invalid_config_valuerust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]invalid_config_value().) |
| 1350 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((s, name)) = deprecated_cfg { |
| 1351 | // Remove the deprecated args/code paths and copy back to the function above later. |
| 1352 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(alias) = alias { |
| 1353 | deprecated_warning_with_aliasrust-analyzer cargo bottom 0.14.9 options/deprecated_warning_with_alias().(name, setting, alias); |
| 1354 | } else { |
| 1355 | deprecated_warningrust-analyzer cargo bottom 0.14.9 options/deprecated_warning().(name, setting); |
| 1356 | } |
| 1357 | parse_position_or_errrust-analyzer cargo bottom 0.14.9 options/parse_position_or_err().(s, setting, OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::invalid_config_valuerust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]invalid_config_value().) |
| 1358 | } else { |
| 1359 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/impl#[LegendPosition][Default]default().())) |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | fn get_network_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_network_legend_position().( |
| 1364 | args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, |
| 1365 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1366 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().( |
| 1367 | args.networkrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#network..network_legendrust-analyzer cargo bottom 0.14.9 options/args/NetworkArgs#network_legend..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 1368 | config |
| 1369 | .network_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#network_graph. |
| 1370 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1371 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.legend_positionrust-analyzer cargo bottom 0.14.9 options/config/network_graph/NetworkGraphConfig#legend_position..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1372 | config |
| 1373 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1374 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1375 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.network_legendrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#network_legend..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()) |
| 1376 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| (s, "network_legend")), |
| 1377 | "network_graph.legend_position", |
| 1378 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("network.legend_position"), |
| 1379 | ) |
| 1380 | } |
| 1381 | |
| 1382 | fn get_memory_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_memory_legend_position().( |
| 1383 | args: &BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#, |
| 1384 | ) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1385 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().( |
| 1386 | args.memoryrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#memory..memory_legendrust-analyzer cargo bottom 0.14.9 options/args/MemoryArgs#memory_legend..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 1387 | config |
| 1388 | .memory_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#memory_graph. |
| 1389 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1390 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|cfg| cfg.legend_positionrust-analyzer cargo bottom 0.14.9 options/config/memory_graph/MemoryGraphConfig#legend_position..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1391 | config |
| 1392 | .flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. |
| 1393 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1394 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|flags| flags.memory_legendrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#memory_legend..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()) |
| 1395 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| (s, "memory_legend")), |
| 1396 | "memory_graph.legend_position", |
| 1397 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("memory.legend_position"), |
| 1398 | ) |
| 1399 | } |
| 1400 | |
| 1401 | fn get_temperature_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_temperature_legend_position().(config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1402 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().( |
| 1403 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1404 | config |
| 1405 | .temperature_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#temperature_graph. |
| 1406 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1407 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|settings| settings.legend_positionrust-analyzer cargo bottom 0.14.9 options/config/temperature_graph/TempGraphConfig#legend_position..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1408 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1409 | "legend_position", |
| 1410 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1411 | ) |
| 1412 | } |
| 1413 | |
| 1414 | fn get_disk_io_legend_positionrust-analyzer cargo bottom 0.14.9 options/get_disk_io_legend_position().(config: &Configrust-analyzer cargo bottom 0.14.9 options/config/Config#) -> OptionResultrust-analyzer cargo bottom 0.14.9 options/error/OptionResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#>> { |
| 1415 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().( |
| 1416 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1417 | config |
| 1418 | .disk_io_graphrust-analyzer cargo bottom 0.14.9 options/config/Config#disk_io_graph. |
| 1419 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 1420 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|settings| settings.legend_positionrust-analyzer cargo bottom 0.14.9 options/config/disk_io_graph/DiskIoGraphConfig#legend_position..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()), |
| 1421 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1422 | "disk_io_graph.legend_position", |
| 1423 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1424 | ) |
| 1425 | } |
| 1426 | |
| 1427 | #[cfg(test)] |
| 1428 | mod testrust-analyzer cargo bottom 0.14.9 options/test/ { |
| 1429 | use claprust-analyzer cargo clap 4.6.6 crate/::Parserrust-analyzer cargo clap_builder 4.6.6 derive/Parser#; |
| 1430 | |
| 1431 | use superrust-analyzer cargo bottom 0.14.9 options/::*; |
| 1432 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 1433 | apprust-analyzer cargo bottom 0.14.9 app/::Apprust-analyzer cargo bottom 0.14.9 app/App#, |
| 1434 | argsrust-analyzer cargo bottom 0.14.9 options/args/::BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#, |
| 1435 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::time_seriesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/::LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#, |
| 1436 | optionsrust-analyzer cargo bottom 0.14.9 options/::{ |
| 1437 | OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#, configrust-analyzer cargo bottom 0.14.9 options/config/::flagsrust-analyzer cargo bottom 0.14.9 options/config/flags/::GeneralConfigrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#, get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value()., get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention()., |
| 1438 | get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate()., parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position()., try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms()., |
| 1439 | }, |
| 1440 | }; |
| 1441 | |
| 1442 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1443 | fn verify_try_parse_msrust-analyzer cargo bottom 0.14.9 options/test/verify_try_parse_ms().() { |
| 1444 | let a = "100s"; |
| 1445 | let b = "100"; |
| 1446 | let c = "1 min"; |
| 1447 | let d = "1 hour 1 min"; |
| 1448 | |
| 1449 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(a), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(100 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000)); |
| 1450 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(b), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(100)); |
| 1451 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(c), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000)); |
| 1452 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(d), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(3660 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000)); |
| 1453 | |
| 1454 | let a_bad = "1 test"; |
| 1455 | let b_bad = "-100"; |
| 1456 | |
| 1457 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(a_bad).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1458 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_msrust-analyzer cargo bottom 0.14.9 options/try_parse_ms().(b_bad).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1459 | } |
| 1460 | |
| 1461 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1462 | fn verify_parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/test/verify_parse_legend_position().() { |
| 1463 | let setting = "network_legend"; |
| 1464 | |
| 1465 | // No arg, no config. |
| 1466 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1467 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1468 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/impl#[LegendPosition][Default]default().())) |
| 1469 | ); |
| 1470 | |
| 1471 | // Arg takes precedence and is parsed (case-insensitive, trimmed). |
| 1472 | let arg = " ToP-lEfT ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1473 | let cfg = "bottom-right".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1474 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1475 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&arg), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&cfg), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1476 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#::TopLeftrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#TopLeft#)) |
| 1477 | ); |
| 1478 | |
| 1479 | // "none" disables the legend, from either source. |
| 1480 | let none_arg = "None".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1481 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1482 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&none_arg), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1483 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 1484 | ); |
| 1485 | let none_cfg = "none".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1486 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1487 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&none_cfg), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1488 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 1489 | ); |
| 1490 | |
| 1491 | // Config value is used when no arg is provided. |
| 1492 | let cfg_only = "left".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1493 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1494 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&cfg_only), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1495 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(LegendPositionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#::Leftrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/LegendPosition#Left#)) |
| 1496 | ); |
| 1497 | |
| 1498 | // Invalid arg value. |
| 1499 | let bad_arg = "bad".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1500 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1501 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&bad_arg), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1502 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::invalid_arg_valuerust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]invalid_arg_value().(setting)) |
| 1503 | ); |
| 1504 | |
| 1505 | // Invalid config value. |
| 1506 | let bad_cfg = "bad".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1507 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1508 | parse_legend_positionrust-analyzer cargo bottom 0.14.9 options/parse_legend_position().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&bad_cfg), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, setting, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1509 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(OptionErrorrust-analyzer cargo bottom 0.14.9 options/error/OptionError#::invalid_config_valuerust-analyzer cargo bottom 0.14.9 options/error/impl#[OptionError]invalid_config_value().(setting)) |
| 1510 | ); |
| 1511 | } |
| 1512 | |
| 1513 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1514 | fn matches_human_timesrust-analyzer cargo bottom 0.14.9 options/test/matches_human_times().() { |
| 1515 | let config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1516 | |
| 1517 | { |
| 1518 | let delta_args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["btm", "--time_delta", "2 min"]; |
| 1519 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(delta_args); |
| 1520 | |
| 1521 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1522 | get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1523 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(2 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1524 | ); |
| 1525 | } |
| 1526 | |
| 1527 | { |
| 1528 | let default_time_args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["btm", "--default_time_value", "300s"]; |
| 1529 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(default_time_args); |
| 1530 | |
| 1531 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1532 | get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1533 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1534 | ); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1539 | fn matches_number_timesrust-analyzer cargo bottom 0.14.9 options/test/matches_number_times().() { |
| 1540 | let config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1541 | |
| 1542 | { |
| 1543 | let delta_args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["btm", "--time_delta", "120000"]; |
| 1544 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(delta_args); |
| 1545 | |
| 1546 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1547 | get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1548 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(2 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1549 | ); |
| 1550 | } |
| 1551 | |
| 1552 | { |
| 1553 | let default_time_args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["btm", "--default_time_value", "300000"]; |
| 1554 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(default_time_args); |
| 1555 | |
| 1556 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1557 | get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1558 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1559 | ); |
| 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1564 | fn config_human_timesrust-analyzer cargo bottom 0.14.9 options/test/config_human_times().() { |
| 1565 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(["btm"]); |
| 1566 | |
| 1567 | let mut config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1568 | let flags = GeneralConfigrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig# { |
| 1569 | time_deltarust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#time_delta.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("2 min".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1570 | default_time_valuerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_time_value.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("300s".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1571 | raterust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#rate.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1s".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1572 | retentionrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#retention.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("10m".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1573 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[GeneralConfig][Default]default().() |
| 1574 | }; |
| 1575 | |
| 1576 | config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags); |
| 1577 | |
| 1578 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1579 | get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1580 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(2 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1581 | ); |
| 1582 | |
| 1583 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1584 | get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1585 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1586 | ); |
| 1587 | |
| 1588 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(1000)); |
| 1589 | |
| 1590 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(600000)); |
| 1591 | } |
| 1592 | |
| 1593 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1594 | fn config_number_times_as_stringrust-analyzer cargo bottom 0.14.9 options/test/config_number_times_as_string().() { |
| 1595 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(["btm"]); |
| 1596 | |
| 1597 | let mut config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1598 | let flags = GeneralConfigrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig# { |
| 1599 | time_deltarust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#time_delta.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("120000".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1600 | default_time_valuerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_time_value.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("300000".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1601 | raterust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#rate.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("1000".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1602 | retentionrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#retention.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("600000".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1603 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[GeneralConfig][Default]default().() |
| 1604 | }; |
| 1605 | |
| 1606 | config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags); |
| 1607 | |
| 1608 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1609 | get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1610 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(2 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1611 | ); |
| 1612 | |
| 1613 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1614 | get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1615 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1616 | ); |
| 1617 | |
| 1618 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(1000)); |
| 1619 | |
| 1620 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(600000)); |
| 1621 | } |
| 1622 | |
| 1623 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1624 | fn config_number_times_as_numrust-analyzer cargo bottom 0.14.9 options/test/config_number_times_as_num().() { |
| 1625 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(["btm"]); |
| 1626 | |
| 1627 | let mut config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1628 | let flags = GeneralConfigrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig# { |
| 1629 | time_deltarust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#time_delta.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(120000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1630 | default_time_valuerust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#default_time_value.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(300000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1631 | raterust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#rate.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1632 | retentionrust-analyzer cargo bottom 0.14.9 options/config/flags/GeneralConfig#retention.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(600000.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1633 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[GeneralConfig][Default]default().() |
| 1634 | }; |
| 1635 | |
| 1636 | config.flagsrust-analyzer cargo bottom 0.14.9 options/config/Config#flags. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(flags); |
| 1637 | |
| 1638 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1639 | get_time_intervalrust-analyzer cargo bottom 0.14.9 options/get_time_interval().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1640 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(2 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1641 | ); |
| 1642 | |
| 1643 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1644 | get_default_time_valuerust-analyzer cargo bottom 0.14.9 options/get_default_time_value().(&args, &config, 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000), |
| 1645 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 60 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). 1000) |
| 1646 | ); |
| 1647 | |
| 1648 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_update_raterust-analyzer cargo bottom 0.14.9 options/get_update_rate().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(1000)); |
| 1649 | |
| 1650 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_retentionrust-analyzer cargo bottom 0.14.9 options/get_retention().(&args, &config), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(600000)); |
| 1651 | } |
| 1652 | |
| 1653 | fn create_apprust-analyzer cargo bottom 0.14.9 options/test/create_app().(args: BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#) -> Apprust-analyzer cargo bottom 0.14.9 app/App# { |
| 1654 | let config = Configrust-analyzer cargo bottom 0.14.9 options/config/Config#::defaultrust-analyzer cargo bottom 0.14.9 options/config/impl#[Config][Default]default().(); |
| 1655 | superrust-analyzer cargo bottom 0.14.9 options/::init_apprust-analyzer cargo bottom 0.14.9 options/init_app().(args, config).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().0 |
| 1656 | } |
| 1657 | |
| 1658 | // TODO: There's probably a better way to create clap options AND unify together |
| 1659 | // to avoid the possibility of typos/mixing up. Use proc macros to unify on |
| 1660 | // one struct? |
| 1661 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1662 | fn verify_cli_options_buildrust-analyzer cargo bottom 0.14.9 options/test/verify_cli_options_build().() { |
| 1663 | let app = craterust-analyzer cargo bottom 0.14.9 crate/::argsrust-analyzer cargo bottom 0.14.9 options/args/::build_cmdrust-analyzer cargo bottom 0.14.9 options/args/build_cmd().(); |
| 1664 | |
| 1665 | let default_app = create_apprust-analyzer cargo bottom 0.14.9 options/test/create_app().(BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(["btm"])); |
| 1666 | |
| 1667 | // Skip battery since it's tricky to test depending on the platform/features |
| 1668 | // we're testing with. |
| 1669 | let skip = ["help", "version", "celsius", "battery", "generate_schema"]; |
| 1670 | |
| 1671 | for arg in app.get_argumentsrust-analyzer cargo clap_builder 4.6.6 builder/command/impl#[Command]get_arguments().().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#<_>>() { |
| 1672 | let arg_name = arg |
| 1673 | .get_long_and_visible_aliasesrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_long_and_visible_aliases().() |
| 1674 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 1675 | .firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() |
| 1676 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 1677 | .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().(); |
| 1678 | |
| 1679 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().arg.get_actionrust-analyzer cargo clap_builder 4.6.6 builder/arg/impl#[Arg]get_action().().takes_valuesrust-analyzer cargo clap_builder 4.6.6 builder/action/impl#[ArgAction]takes_values().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().skip.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&arg_name) { |
| 1680 | let arg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("--{arg_name}"); |
| 1681 | |
| 1682 | let arguments = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["btm", &arg]; |
| 1683 | let args = BottomArgsrust-analyzer cargo bottom 0.14.9 options/args/BottomArgs#::parse_fromrust-analyzer cargo clap_builder 4.6.6 derive/Parser#parse_from().(arguments); |
| 1684 | let testing_app = create_apprust-analyzer cargo bottom 0.14.9 options/test/create_app().(args); |
| 1685 | |
| 1686 | if (default_app.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields. rust-analyzer cargo bottom 0.14.9 app/impl#[AppConfigFields][`PartialEq<Self>`]eq().==rust-analyzer cargo bottom 0.14.9 app/impl#[AppConfigFields][`PartialEq<Self>`]eq(). rust-analyzer cargo bottom 0.14.9 app/impl#[AppConfigFields][`PartialEq<Self>`]eq().testing_app.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields.) |
| 1687 | && default_app.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().testing_app.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded. |
| 1688 | && default_app |
| 1689 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 1690 | .proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state. |
| 1691 | .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states. |
| 1692 | .iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 1693 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(testing_app.statesrust-analyzer cargo bottom 0.14.9 app/App#states..proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state..widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().()) |
| 1694 | .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|(a, b)| a.1.test_equalityrust-analyzer cargo bottom 0.14.9 widgets/process_table/impl#[ProcWidgetState]test_equality().(b.1)) |
| 1695 | { |
| 1696 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("failed on {arg_name}"); |
| 1697 | } |
| 1698 | } |
| 1699 | } |
| 1700 | } |
| 1701 | |
| 1702 | /// This one has slightly more complex behaviour due to `dirs` not |
| 1703 | /// respecting XDG on macOS, so we manually handle it. However, to |
| 1704 | /// ensure backwards-compatibility, we also have to do some special cases. |
| 1705 | #[cfg(target_os = "macos")] |
| 1706 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1707 | fn test_get_config_path_macos() { |
| 1708 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#; |
| 1709 | |
| 1710 | use superrust-analyzer cargo bottom 0.14.9 options/::{DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION., get_config_pathrust-analyzer cargo bottom 0.14.9 options/get_config_path().}; |
| 1711 | |
| 1712 | // Case three: no previous config, no XDG var. |
| 1713 | // SAFETY: This is fine, this is just a test, and no other test affects env |
| 1714 | // vars. |
| 1715 | unsafe { |
| 1716 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("XDG_CONFIG_HOME"); |
| 1717 | } |
| 1718 | |
| 1719 | let case_1 = dirsrust-analyzer cargo dirs 6.0.0 crate/::config_dirrust-analyzer cargo dirs 6.0.0 config_dir().() |
| 1720 | .map(|mut path| { |
| 1721 | path.push(DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.); |
| 1722 | path |
| 1723 | }) |
| 1724 | .unwrap(); |
| 1725 | |
| 1726 | // Skip this test if the file already exists. |
| 1727 | if !case_1.exists() { |
| 1728 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_config_path(None), Some(case_1)); |
| 1729 | } |
| 1730 | |
| 1731 | // Case two: no previous config, XDG var exists. |
| 1732 | // SAFETY: This is fine, this is just a test, and no other test affects env |
| 1733 | // vars. |
| 1734 | unsafe { |
| 1735 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("XDG_CONFIG_HOME", "/tmp"); |
| 1736 | } |
| 1737 | let mut case_2 = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::new(); |
| 1738 | case_2.push("/tmp"); |
| 1739 | case_2.push(DEFAULT_CONFIG_FILE_LOCATIONrust-analyzer cargo bottom 0.14.9 options/DEFAULT_CONFIG_FILE_LOCATION.); |
| 1740 | |
| 1741 | // Skip this test if the file already exists. |
| 1742 | if !case_2.exists() { |
| 1743 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_config_path(None), Some(case_2)); |
| 1744 | } |
| 1745 | |
| 1746 | // Case one: old non-XDG exists already, XDG var exists. |
| 1747 | // let case_3 = case_1; |
| 1748 | // assert_eq!(get_config_path(None), Some(case_1)); |
| 1749 | } |
| 1750 | } |