├── .gitattributes ├── .gitignore ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── License.txt ├── README.md └── src ├── lib.rs ├── main.rs ├── nu └── mod.rs └── values ├── angle.rs ├── area.rs ├── data_storage.rs ├── data_transfer_rate.rs ├── energy.rs ├── force.rs ├── frequency.rs ├── fuel_economy.rs ├── length.rs ├── luminous_energy.rs ├── magnetomotive_force.rs ├── mass.rs ├── mod.rs ├── pressure.rs ├── speed.rs ├── temperature.rs ├── time.rs └── volume.rs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## April 30, 2024 - v0.1.6 4 | 5 | - Updated Nushell crates to fix broken state of plugin. 6 | 7 | ## April 5, 2024 - v0.1.5 8 | 9 | - Updated Nushell crates to fix broken state of plugin. 10 | 11 | ## December 23, 2024 - v0.1.4 12 | 13 | - Updated Nushell crates to fix broken state of plugin. 14 | 15 | ## November 1, 2024 - v0.1.3 16 | 17 | - Updated Nushell crates to fix broken state of plugin. 18 | 19 | ## August 23, 2024 - v0.1.2 20 | 21 | - Updated Nushell crates to fix broken state of plugin. 22 | 23 | ## May 22, 2024 - v0.1.1 24 | 25 | - Updated Nushell crates to fix broken state of plugin. 26 | 27 | ## November 26, 2023 - v0.1.0 28 | 29 | - Initial release. 30 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "adler2" 7 | version = "2.0.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" 10 | 11 | [[package]] 12 | name = "aho-corasick" 13 | version = "1.1.3" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 16 | dependencies = [ 17 | "memchr", 18 | ] 19 | 20 | [[package]] 21 | name = "alloc-no-stdlib" 22 | version = "2.0.4" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" 25 | 26 | [[package]] 27 | name = "alloc-stdlib" 28 | version = "0.2.2" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" 31 | dependencies = [ 32 | "alloc-no-stdlib", 33 | ] 34 | 35 | [[package]] 36 | name = "allocator-api2" 37 | version = "0.2.18" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" 40 | 41 | [[package]] 42 | name = "android-tzdata" 43 | version = "0.1.1" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" 46 | 47 | [[package]] 48 | name = "android_system_properties" 49 | version = "0.1.5" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 52 | dependencies = [ 53 | "libc", 54 | ] 55 | 56 | [[package]] 57 | name = "anyhow" 58 | version = "1.0.98" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" 61 | 62 | [[package]] 63 | name = "arrayvec" 64 | version = "0.7.6" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" 67 | 68 | [[package]] 69 | name = "autocfg" 70 | version = "1.4.0" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 73 | 74 | [[package]] 75 | name = "bindgen" 76 | version = "0.70.1" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" 79 | dependencies = [ 80 | "bitflags", 81 | "cexpr", 82 | "clang-sys", 83 | "itertools", 84 | "proc-macro2", 85 | "quote", 86 | "regex", 87 | "rustc-hash", 88 | "shlex", 89 | "syn", 90 | ] 91 | 92 | [[package]] 93 | name = "bit-set" 94 | version = "0.8.0" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" 97 | dependencies = [ 98 | "bit-vec", 99 | ] 100 | 101 | [[package]] 102 | name = "bit-vec" 103 | version = "0.8.0" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" 106 | 107 | [[package]] 108 | name = "bitflags" 109 | version = "2.6.0" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 112 | 113 | [[package]] 114 | name = "brotli" 115 | version = "7.0.0" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" 118 | dependencies = [ 119 | "alloc-no-stdlib", 120 | "alloc-stdlib", 121 | "brotli-decompressor", 122 | ] 123 | 124 | [[package]] 125 | name = "brotli-decompressor" 126 | version = "4.0.1" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" 129 | dependencies = [ 130 | "alloc-no-stdlib", 131 | "alloc-stdlib", 132 | ] 133 | 134 | [[package]] 135 | name = "bumpalo" 136 | version = "3.16.0" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 139 | 140 | [[package]] 141 | name = "byteorder" 142 | version = "1.5.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 145 | 146 | [[package]] 147 | name = "bytes" 148 | version = "1.8.0" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" 151 | 152 | [[package]] 153 | name = "cc" 154 | version = "1.1.31" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" 157 | dependencies = [ 158 | "shlex", 159 | ] 160 | 161 | [[package]] 162 | name = "cexpr" 163 | version = "0.6.0" 164 | source = "registry+https://github.com/rust-lang/crates.io-index" 165 | checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" 166 | dependencies = [ 167 | "nom", 168 | ] 169 | 170 | [[package]] 171 | name = "cfg-if" 172 | version = "1.0.0" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 175 | 176 | [[package]] 177 | name = "cfg_aliases" 178 | version = "0.2.1" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" 181 | 182 | [[package]] 183 | name = "chrono" 184 | version = "0.4.38" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" 187 | dependencies = [ 188 | "android-tzdata", 189 | "iana-time-zone", 190 | "num-traits", 191 | "pure-rust-locales", 192 | "serde", 193 | "windows-targets 0.52.6", 194 | ] 195 | 196 | [[package]] 197 | name = "chrono-humanize" 198 | version = "0.2.3" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "799627e6b4d27827a814e837b9d8a504832086081806d45b1afa34dc982b023b" 201 | dependencies = [ 202 | "chrono", 203 | ] 204 | 205 | [[package]] 206 | name = "clang-sys" 207 | version = "1.8.1" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" 210 | dependencies = [ 211 | "glob", 212 | "libc", 213 | "libloading", 214 | ] 215 | 216 | [[package]] 217 | name = "core-foundation-sys" 218 | version = "0.8.7" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" 221 | 222 | [[package]] 223 | name = "crc32fast" 224 | version = "1.4.2" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" 227 | dependencies = [ 228 | "cfg-if", 229 | ] 230 | 231 | [[package]] 232 | name = "crossbeam-deque" 233 | version = "0.8.5" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" 236 | dependencies = [ 237 | "crossbeam-epoch", 238 | "crossbeam-utils", 239 | ] 240 | 241 | [[package]] 242 | name = "crossbeam-epoch" 243 | version = "0.9.18" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 246 | dependencies = [ 247 | "crossbeam-utils", 248 | ] 249 | 250 | [[package]] 251 | name = "crossbeam-utils" 252 | version = "0.8.20" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" 255 | 256 | [[package]] 257 | name = "crossterm" 258 | version = "0.28.1" 259 | source = "registry+https://github.com/rust-lang/crates.io-index" 260 | checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" 261 | dependencies = [ 262 | "bitflags", 263 | "crossterm_winapi", 264 | "mio", 265 | "parking_lot", 266 | "rustix", 267 | "signal-hook", 268 | "signal-hook-mio", 269 | "winapi", 270 | ] 271 | 272 | [[package]] 273 | name = "crossterm_winapi" 274 | version = "0.9.1" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" 277 | dependencies = [ 278 | "winapi", 279 | ] 280 | 281 | [[package]] 282 | name = "dirs" 283 | version = "5.0.1" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" 286 | dependencies = [ 287 | "dirs-sys", 288 | ] 289 | 290 | [[package]] 291 | name = "dirs-sys" 292 | version = "0.4.1" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" 295 | dependencies = [ 296 | "libc", 297 | "option-ext", 298 | "redox_users", 299 | "windows-sys 0.48.0", 300 | ] 301 | 302 | [[package]] 303 | name = "doctest-file" 304 | version = "1.0.0" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562" 307 | 308 | [[package]] 309 | name = "either" 310 | version = "1.13.0" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" 313 | 314 | [[package]] 315 | name = "equivalent" 316 | version = "1.0.1" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 319 | 320 | [[package]] 321 | name = "erased-serde" 322 | version = "0.4.5" 323 | source = "registry+https://github.com/rust-lang/crates.io-index" 324 | checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" 325 | dependencies = [ 326 | "serde", 327 | "typeid", 328 | ] 329 | 330 | [[package]] 331 | name = "errno" 332 | version = "0.3.9" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" 335 | dependencies = [ 336 | "libc", 337 | "windows-sys 0.52.0", 338 | ] 339 | 340 | [[package]] 341 | name = "fancy-regex" 342 | version = "0.14.0" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298" 345 | dependencies = [ 346 | "bit-set", 347 | "regex-automata", 348 | "regex-syntax", 349 | ] 350 | 351 | [[package]] 352 | name = "flate2" 353 | version = "1.0.34" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" 356 | dependencies = [ 357 | "crc32fast", 358 | "miniz_oxide", 359 | ] 360 | 361 | [[package]] 362 | name = "foldhash" 363 | version = "0.1.3" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" 366 | 367 | [[package]] 368 | name = "getrandom" 369 | version = "0.2.15" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 372 | dependencies = [ 373 | "cfg-if", 374 | "libc", 375 | "wasi", 376 | ] 377 | 378 | [[package]] 379 | name = "glob" 380 | version = "0.3.1" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" 383 | 384 | [[package]] 385 | name = "hashbrown" 386 | version = "0.15.0" 387 | source = "registry+https://github.com/rust-lang/crates.io-index" 388 | checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" 389 | dependencies = [ 390 | "allocator-api2", 391 | "equivalent", 392 | "foldhash", 393 | ] 394 | 395 | [[package]] 396 | name = "heck" 397 | version = "0.5.0" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 400 | 401 | [[package]] 402 | name = "hex" 403 | version = "0.4.3" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 406 | 407 | [[package]] 408 | name = "iana-time-zone" 409 | version = "0.1.61" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" 412 | dependencies = [ 413 | "android_system_properties", 414 | "core-foundation-sys", 415 | "iana-time-zone-haiku", 416 | "js-sys", 417 | "wasm-bindgen", 418 | "windows-core 0.52.0", 419 | ] 420 | 421 | [[package]] 422 | name = "iana-time-zone-haiku" 423 | version = "0.1.2" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" 426 | dependencies = [ 427 | "cc", 428 | ] 429 | 430 | [[package]] 431 | name = "indexmap" 432 | version = "2.9.0" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" 435 | dependencies = [ 436 | "equivalent", 437 | "hashbrown", 438 | ] 439 | 440 | [[package]] 441 | name = "interprocess" 442 | version = "2.2.1" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "d2f4e4a06d42fab3e85ab1b419ad32b09eab58b901d40c57935ff92db3287a13" 445 | dependencies = [ 446 | "doctest-file", 447 | "libc", 448 | "recvmsg", 449 | "widestring", 450 | "windows-sys 0.52.0", 451 | ] 452 | 453 | [[package]] 454 | name = "inventory" 455 | version = "0.3.15" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" 458 | 459 | [[package]] 460 | name = "is_ci" 461 | version = "1.2.0" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" 464 | 465 | [[package]] 466 | name = "itertools" 467 | version = "0.13.0" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 470 | dependencies = [ 471 | "either", 472 | ] 473 | 474 | [[package]] 475 | name = "itoa" 476 | version = "1.0.11" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 479 | 480 | [[package]] 481 | name = "js-sys" 482 | version = "0.3.72" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" 485 | dependencies = [ 486 | "wasm-bindgen", 487 | ] 488 | 489 | [[package]] 490 | name = "libc" 491 | version = "0.2.169" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" 494 | 495 | [[package]] 496 | name = "libloading" 497 | version = "0.8.5" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" 500 | dependencies = [ 501 | "cfg-if", 502 | "windows-targets 0.52.6", 503 | ] 504 | 505 | [[package]] 506 | name = "libproc" 507 | version = "0.14.10" 508 | source = "registry+https://github.com/rust-lang/crates.io-index" 509 | checksum = "e78a09b56be5adbcad5aa1197371688dc6bb249a26da3bca2011ee2fb987ebfb" 510 | dependencies = [ 511 | "bindgen", 512 | "errno", 513 | "libc", 514 | ] 515 | 516 | [[package]] 517 | name = "libredox" 518 | version = "0.1.3" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" 521 | dependencies = [ 522 | "bitflags", 523 | "libc", 524 | ] 525 | 526 | [[package]] 527 | name = "linux-raw-sys" 528 | version = "0.4.14" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" 531 | 532 | [[package]] 533 | name = "lock_api" 534 | version = "0.4.12" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 537 | dependencies = [ 538 | "autocfg", 539 | "scopeguard", 540 | ] 541 | 542 | [[package]] 543 | name = "log" 544 | version = "0.4.22" 545 | source = "registry+https://github.com/rust-lang/crates.io-index" 546 | checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 547 | 548 | [[package]] 549 | name = "lru" 550 | version = "0.12.5" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" 553 | dependencies = [ 554 | "hashbrown", 555 | ] 556 | 557 | [[package]] 558 | name = "lscolors" 559 | version = "0.17.0" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "53304fff6ab1e597661eee37e42ea8c47a146fca280af902bb76bff8a896e523" 562 | dependencies = [ 563 | "nu-ansi-term", 564 | ] 565 | 566 | [[package]] 567 | name = "mach2" 568 | version = "0.4.2" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" 571 | dependencies = [ 572 | "libc", 573 | ] 574 | 575 | [[package]] 576 | name = "memchr" 577 | version = "2.7.4" 578 | source = "registry+https://github.com/rust-lang/crates.io-index" 579 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 580 | 581 | [[package]] 582 | name = "miette" 583 | version = "7.5.0" 584 | source = "registry+https://github.com/rust-lang/crates.io-index" 585 | checksum = "1a955165f87b37fd1862df2a59547ac542c77ef6d17c666f619d1ad22dd89484" 586 | dependencies = [ 587 | "cfg-if", 588 | "miette-derive", 589 | "owo-colors", 590 | "supports-color", 591 | "supports-hyperlinks", 592 | "supports-unicode", 593 | "terminal_size", 594 | "textwrap", 595 | "thiserror 1.0.66", 596 | "unicode-width", 597 | ] 598 | 599 | [[package]] 600 | name = "miette-derive" 601 | version = "7.5.0" 602 | source = "registry+https://github.com/rust-lang/crates.io-index" 603 | checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147" 604 | dependencies = [ 605 | "proc-macro2", 606 | "quote", 607 | "syn", 608 | ] 609 | 610 | [[package]] 611 | name = "minimal-lexical" 612 | version = "0.2.1" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 615 | 616 | [[package]] 617 | name = "miniz_oxide" 618 | version = "0.8.0" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" 621 | dependencies = [ 622 | "adler2", 623 | ] 624 | 625 | [[package]] 626 | name = "mio" 627 | version = "1.0.3" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" 630 | dependencies = [ 631 | "libc", 632 | "log", 633 | "wasi", 634 | "windows-sys 0.52.0", 635 | ] 636 | 637 | [[package]] 638 | name = "nix" 639 | version = "0.29.0" 640 | source = "registry+https://github.com/rust-lang/crates.io-index" 641 | checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" 642 | dependencies = [ 643 | "bitflags", 644 | "cfg-if", 645 | "cfg_aliases", 646 | "libc", 647 | ] 648 | 649 | [[package]] 650 | name = "nom" 651 | version = "7.1.3" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 654 | dependencies = [ 655 | "memchr", 656 | "minimal-lexical", 657 | ] 658 | 659 | [[package]] 660 | name = "ntapi" 661 | version = "0.4.1" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" 664 | dependencies = [ 665 | "winapi", 666 | ] 667 | 668 | [[package]] 669 | name = "nu-ansi-term" 670 | version = "0.50.1" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" 673 | dependencies = [ 674 | "windows-sys 0.52.0", 675 | ] 676 | 677 | [[package]] 678 | name = "nu-derive-value" 679 | version = "0.104.0" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "5fd0d8e358b6440d01fe4e617f180aea826bade72efb54f5dc1c22e0e8038b6f" 682 | dependencies = [ 683 | "heck", 684 | "proc-macro-error2", 685 | "proc-macro2", 686 | "quote", 687 | "syn", 688 | ] 689 | 690 | [[package]] 691 | name = "nu-engine" 692 | version = "0.104.0" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "0c2b01483e3d09460375f0c0da7a83b6dc26fb319ca09c55d0665087b2d587c7" 695 | dependencies = [ 696 | "log", 697 | "nu-glob", 698 | "nu-path", 699 | "nu-protocol", 700 | "nu-utils", 701 | ] 702 | 703 | [[package]] 704 | name = "nu-glob" 705 | version = "0.104.0" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "202ce25889336061efea24e69d4e0de7147c15fd9892cdd70533500d47db8364" 708 | 709 | [[package]] 710 | name = "nu-path" 711 | version = "0.104.0" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "41c68c7c06898a5c4c9f10038da63759661cb8ac8f301ce7d159173a595c8258" 714 | dependencies = [ 715 | "dirs", 716 | "omnipath", 717 | "pwd", 718 | "ref-cast", 719 | ] 720 | 721 | [[package]] 722 | name = "nu-plugin" 723 | version = "0.104.0" 724 | source = "registry+https://github.com/rust-lang/crates.io-index" 725 | checksum = "e00d2ccb35a1206c51740bea63b0deb72dc4c34ca6ceae6feac95f84d68370d2" 726 | dependencies = [ 727 | "log", 728 | "nix", 729 | "nu-engine", 730 | "nu-plugin-core", 731 | "nu-plugin-protocol", 732 | "nu-protocol", 733 | "nu-utils", 734 | "thiserror 2.0.12", 735 | ] 736 | 737 | [[package]] 738 | name = "nu-plugin-core" 739 | version = "0.104.0" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "30e416e6de2b62925ffc1924740a0e5340316a1630af3d2490d513bcb1f94e94" 742 | dependencies = [ 743 | "interprocess", 744 | "log", 745 | "nu-plugin-protocol", 746 | "nu-protocol", 747 | "rmp-serde", 748 | "serde", 749 | "serde_json", 750 | "windows", 751 | ] 752 | 753 | [[package]] 754 | name = "nu-plugin-protocol" 755 | version = "0.104.0" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "be7edbdee451bb29150b5e8184660d79d0c0801a6748b9f712b758cb78110305" 758 | dependencies = [ 759 | "nu-protocol", 760 | "nu-utils", 761 | "rmp-serde", 762 | "semver", 763 | "serde", 764 | "typetag", 765 | ] 766 | 767 | [[package]] 768 | name = "nu-protocol" 769 | version = "0.104.0" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "ab657b1947f1fad3c5052cb210fa311744736a4800a966ae21c4bc63de7c60ab" 772 | dependencies = [ 773 | "brotli", 774 | "bytes", 775 | "chrono", 776 | "chrono-humanize", 777 | "dirs", 778 | "dirs-sys", 779 | "fancy-regex", 780 | "heck", 781 | "indexmap", 782 | "log", 783 | "lru", 784 | "memchr", 785 | "miette", 786 | "nix", 787 | "nu-derive-value", 788 | "nu-glob", 789 | "nu-path", 790 | "nu-system", 791 | "nu-utils", 792 | "num-format", 793 | "os_pipe", 794 | "rmp-serde", 795 | "serde", 796 | "serde_json", 797 | "strum", 798 | "strum_macros", 799 | "thiserror 2.0.12", 800 | "typetag", 801 | "web-time", 802 | "windows-sys 0.48.0", 803 | ] 804 | 805 | [[package]] 806 | name = "nu-system" 807 | version = "0.104.0" 808 | source = "registry+https://github.com/rust-lang/crates.io-index" 809 | checksum = "f47094aaab4f1e3a86c3960400d82a50fcabde907f964ae095963ec95669577a" 810 | dependencies = [ 811 | "chrono", 812 | "itertools", 813 | "libc", 814 | "libproc", 815 | "log", 816 | "mach2", 817 | "nix", 818 | "ntapi", 819 | "procfs", 820 | "sysinfo", 821 | "web-time", 822 | "windows", 823 | ] 824 | 825 | [[package]] 826 | name = "nu-utils" 827 | version = "0.104.0" 828 | source = "registry+https://github.com/rust-lang/crates.io-index" 829 | checksum = "327999b774d78b301a6b68c33d312a1a8047c59fb8971b6552ebf823251f1481" 830 | dependencies = [ 831 | "crossterm", 832 | "crossterm_winapi", 833 | "fancy-regex", 834 | "log", 835 | "lscolors", 836 | "nix", 837 | "num-format", 838 | "serde", 839 | "serde_json", 840 | "strip-ansi-escapes", 841 | "sys-locale", 842 | "unicase", 843 | ] 844 | 845 | [[package]] 846 | name = "nu_plugin_units" 847 | version = "0.1.6" 848 | dependencies = [ 849 | "anyhow", 850 | "nu-ansi-term", 851 | "nu-plugin", 852 | "nu-protocol", 853 | "unit-conversions", 854 | ] 855 | 856 | [[package]] 857 | name = "num-format" 858 | version = "0.4.4" 859 | source = "registry+https://github.com/rust-lang/crates.io-index" 860 | checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" 861 | dependencies = [ 862 | "arrayvec", 863 | "itoa", 864 | ] 865 | 866 | [[package]] 867 | name = "num-traits" 868 | version = "0.2.19" 869 | source = "registry+https://github.com/rust-lang/crates.io-index" 870 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 871 | dependencies = [ 872 | "autocfg", 873 | ] 874 | 875 | [[package]] 876 | name = "omnipath" 877 | version = "0.1.6" 878 | source = "registry+https://github.com/rust-lang/crates.io-index" 879 | checksum = "80adb31078122c880307e9cdfd4e3361e6545c319f9b9dcafcb03acd3b51a575" 880 | 881 | [[package]] 882 | name = "once_cell" 883 | version = "1.20.2" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" 886 | 887 | [[package]] 888 | name = "option-ext" 889 | version = "0.2.0" 890 | source = "registry+https://github.com/rust-lang/crates.io-index" 891 | checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" 892 | 893 | [[package]] 894 | name = "os_pipe" 895 | version = "1.2.1" 896 | source = "registry+https://github.com/rust-lang/crates.io-index" 897 | checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" 898 | dependencies = [ 899 | "libc", 900 | "windows-sys 0.59.0", 901 | ] 902 | 903 | [[package]] 904 | name = "owo-colors" 905 | version = "4.1.0" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" 908 | 909 | [[package]] 910 | name = "parking_lot" 911 | version = "0.12.3" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 914 | dependencies = [ 915 | "lock_api", 916 | "parking_lot_core", 917 | ] 918 | 919 | [[package]] 920 | name = "parking_lot_core" 921 | version = "0.9.10" 922 | source = "registry+https://github.com/rust-lang/crates.io-index" 923 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 924 | dependencies = [ 925 | "cfg-if", 926 | "libc", 927 | "redox_syscall", 928 | "smallvec", 929 | "windows-targets 0.52.6", 930 | ] 931 | 932 | [[package]] 933 | name = "paste" 934 | version = "1.0.15" 935 | source = "registry+https://github.com/rust-lang/crates.io-index" 936 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 937 | 938 | [[package]] 939 | name = "proc-macro-error-attr2" 940 | version = "2.0.0" 941 | source = "registry+https://github.com/rust-lang/crates.io-index" 942 | checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" 943 | dependencies = [ 944 | "proc-macro2", 945 | "quote", 946 | ] 947 | 948 | [[package]] 949 | name = "proc-macro-error2" 950 | version = "2.0.1" 951 | source = "registry+https://github.com/rust-lang/crates.io-index" 952 | checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" 953 | dependencies = [ 954 | "proc-macro-error-attr2", 955 | "proc-macro2", 956 | "quote", 957 | "syn", 958 | ] 959 | 960 | [[package]] 961 | name = "proc-macro2" 962 | version = "1.0.92" 963 | source = "registry+https://github.com/rust-lang/crates.io-index" 964 | checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" 965 | dependencies = [ 966 | "unicode-ident", 967 | ] 968 | 969 | [[package]] 970 | name = "procfs" 971 | version = "0.17.0" 972 | source = "registry+https://github.com/rust-lang/crates.io-index" 973 | checksum = "cc5b72d8145275d844d4b5f6d4e1eef00c8cd889edb6035c21675d1bb1f45c9f" 974 | dependencies = [ 975 | "bitflags", 976 | "chrono", 977 | "flate2", 978 | "hex", 979 | "procfs-core", 980 | "rustix", 981 | ] 982 | 983 | [[package]] 984 | name = "procfs-core" 985 | version = "0.17.0" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "239df02d8349b06fc07398a3a1697b06418223b1c7725085e801e7c0fc6a12ec" 988 | dependencies = [ 989 | "bitflags", 990 | "chrono", 991 | "hex", 992 | ] 993 | 994 | [[package]] 995 | name = "pure-rust-locales" 996 | version = "0.8.1" 997 | source = "registry+https://github.com/rust-lang/crates.io-index" 998 | checksum = "1190fd18ae6ce9e137184f207593877e70f39b015040156b1e05081cdfe3733a" 999 | 1000 | [[package]] 1001 | name = "pwd" 1002 | version = "1.4.0" 1003 | source = "registry+https://github.com/rust-lang/crates.io-index" 1004 | checksum = "72c71c0c79b9701efe4e1e4b563b2016dd4ee789eb99badcb09d61ac4b92e4a2" 1005 | dependencies = [ 1006 | "libc", 1007 | "thiserror 1.0.66", 1008 | ] 1009 | 1010 | [[package]] 1011 | name = "quote" 1012 | version = "1.0.37" 1013 | source = "registry+https://github.com/rust-lang/crates.io-index" 1014 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 1015 | dependencies = [ 1016 | "proc-macro2", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "rayon" 1021 | version = "1.10.0" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" 1024 | dependencies = [ 1025 | "either", 1026 | "rayon-core", 1027 | ] 1028 | 1029 | [[package]] 1030 | name = "rayon-core" 1031 | version = "1.12.1" 1032 | source = "registry+https://github.com/rust-lang/crates.io-index" 1033 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" 1034 | dependencies = [ 1035 | "crossbeam-deque", 1036 | "crossbeam-utils", 1037 | ] 1038 | 1039 | [[package]] 1040 | name = "recvmsg" 1041 | version = "1.0.0" 1042 | source = "registry+https://github.com/rust-lang/crates.io-index" 1043 | checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" 1044 | 1045 | [[package]] 1046 | name = "redox_syscall" 1047 | version = "0.5.8" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" 1050 | dependencies = [ 1051 | "bitflags", 1052 | ] 1053 | 1054 | [[package]] 1055 | name = "redox_users" 1056 | version = "0.4.6" 1057 | source = "registry+https://github.com/rust-lang/crates.io-index" 1058 | checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" 1059 | dependencies = [ 1060 | "getrandom", 1061 | "libredox", 1062 | "thiserror 1.0.66", 1063 | ] 1064 | 1065 | [[package]] 1066 | name = "ref-cast" 1067 | version = "1.0.24" 1068 | source = "registry+https://github.com/rust-lang/crates.io-index" 1069 | checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" 1070 | dependencies = [ 1071 | "ref-cast-impl", 1072 | ] 1073 | 1074 | [[package]] 1075 | name = "ref-cast-impl" 1076 | version = "1.0.24" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" 1079 | dependencies = [ 1080 | "proc-macro2", 1081 | "quote", 1082 | "syn", 1083 | ] 1084 | 1085 | [[package]] 1086 | name = "regex" 1087 | version = "1.11.1" 1088 | source = "registry+https://github.com/rust-lang/crates.io-index" 1089 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 1090 | dependencies = [ 1091 | "aho-corasick", 1092 | "memchr", 1093 | "regex-automata", 1094 | "regex-syntax", 1095 | ] 1096 | 1097 | [[package]] 1098 | name = "regex-automata" 1099 | version = "0.4.8" 1100 | source = "registry+https://github.com/rust-lang/crates.io-index" 1101 | checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" 1102 | dependencies = [ 1103 | "aho-corasick", 1104 | "memchr", 1105 | "regex-syntax", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "regex-syntax" 1110 | version = "0.8.5" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 1113 | 1114 | [[package]] 1115 | name = "rmp" 1116 | version = "0.8.14" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" 1119 | dependencies = [ 1120 | "byteorder", 1121 | "num-traits", 1122 | "paste", 1123 | ] 1124 | 1125 | [[package]] 1126 | name = "rmp-serde" 1127 | version = "1.3.0" 1128 | source = "registry+https://github.com/rust-lang/crates.io-index" 1129 | checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" 1130 | dependencies = [ 1131 | "byteorder", 1132 | "rmp", 1133 | "serde", 1134 | ] 1135 | 1136 | [[package]] 1137 | name = "rustc-hash" 1138 | version = "1.1.0" 1139 | source = "registry+https://github.com/rust-lang/crates.io-index" 1140 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1141 | 1142 | [[package]] 1143 | name = "rustix" 1144 | version = "0.38.38" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" 1147 | dependencies = [ 1148 | "bitflags", 1149 | "errno", 1150 | "libc", 1151 | "linux-raw-sys", 1152 | "windows-sys 0.52.0", 1153 | ] 1154 | 1155 | [[package]] 1156 | name = "rustversion" 1157 | version = "1.0.20" 1158 | source = "registry+https://github.com/rust-lang/crates.io-index" 1159 | checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 1160 | 1161 | [[package]] 1162 | name = "ryu" 1163 | version = "1.0.18" 1164 | source = "registry+https://github.com/rust-lang/crates.io-index" 1165 | checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" 1166 | 1167 | [[package]] 1168 | name = "scopeguard" 1169 | version = "1.2.0" 1170 | source = "registry+https://github.com/rust-lang/crates.io-index" 1171 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1172 | 1173 | [[package]] 1174 | name = "semver" 1175 | version = "1.0.23" 1176 | source = "registry+https://github.com/rust-lang/crates.io-index" 1177 | checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" 1178 | 1179 | [[package]] 1180 | name = "serde" 1181 | version = "1.0.214" 1182 | source = "registry+https://github.com/rust-lang/crates.io-index" 1183 | checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" 1184 | dependencies = [ 1185 | "serde_derive", 1186 | ] 1187 | 1188 | [[package]] 1189 | name = "serde_derive" 1190 | version = "1.0.214" 1191 | source = "registry+https://github.com/rust-lang/crates.io-index" 1192 | checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" 1193 | dependencies = [ 1194 | "proc-macro2", 1195 | "quote", 1196 | "syn", 1197 | ] 1198 | 1199 | [[package]] 1200 | name = "serde_json" 1201 | version = "1.0.132" 1202 | source = "registry+https://github.com/rust-lang/crates.io-index" 1203 | checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" 1204 | dependencies = [ 1205 | "itoa", 1206 | "memchr", 1207 | "ryu", 1208 | "serde", 1209 | ] 1210 | 1211 | [[package]] 1212 | name = "shlex" 1213 | version = "1.3.0" 1214 | source = "registry+https://github.com/rust-lang/crates.io-index" 1215 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 1216 | 1217 | [[package]] 1218 | name = "signal-hook" 1219 | version = "0.3.17" 1220 | source = "registry+https://github.com/rust-lang/crates.io-index" 1221 | checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" 1222 | dependencies = [ 1223 | "libc", 1224 | "signal-hook-registry", 1225 | ] 1226 | 1227 | [[package]] 1228 | name = "signal-hook-mio" 1229 | version = "0.2.4" 1230 | source = "registry+https://github.com/rust-lang/crates.io-index" 1231 | checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" 1232 | dependencies = [ 1233 | "libc", 1234 | "mio", 1235 | "signal-hook", 1236 | ] 1237 | 1238 | [[package]] 1239 | name = "signal-hook-registry" 1240 | version = "1.4.2" 1241 | source = "registry+https://github.com/rust-lang/crates.io-index" 1242 | checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" 1243 | dependencies = [ 1244 | "libc", 1245 | ] 1246 | 1247 | [[package]] 1248 | name = "smallvec" 1249 | version = "1.13.2" 1250 | source = "registry+https://github.com/rust-lang/crates.io-index" 1251 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 1252 | 1253 | [[package]] 1254 | name = "strip-ansi-escapes" 1255 | version = "0.2.0" 1256 | source = "registry+https://github.com/rust-lang/crates.io-index" 1257 | checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa" 1258 | dependencies = [ 1259 | "vte", 1260 | ] 1261 | 1262 | [[package]] 1263 | name = "strum" 1264 | version = "0.26.3" 1265 | source = "registry+https://github.com/rust-lang/crates.io-index" 1266 | checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" 1267 | 1268 | [[package]] 1269 | name = "strum_macros" 1270 | version = "0.26.4" 1271 | source = "registry+https://github.com/rust-lang/crates.io-index" 1272 | checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" 1273 | dependencies = [ 1274 | "heck", 1275 | "proc-macro2", 1276 | "quote", 1277 | "rustversion", 1278 | "syn", 1279 | ] 1280 | 1281 | [[package]] 1282 | name = "supports-color" 1283 | version = "3.0.1" 1284 | source = "registry+https://github.com/rust-lang/crates.io-index" 1285 | checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" 1286 | dependencies = [ 1287 | "is_ci", 1288 | ] 1289 | 1290 | [[package]] 1291 | name = "supports-hyperlinks" 1292 | version = "3.0.0" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" 1295 | 1296 | [[package]] 1297 | name = "supports-unicode" 1298 | version = "3.0.0" 1299 | source = "registry+https://github.com/rust-lang/crates.io-index" 1300 | checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" 1301 | 1302 | [[package]] 1303 | name = "syn" 1304 | version = "2.0.91" 1305 | source = "registry+https://github.com/rust-lang/crates.io-index" 1306 | checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" 1307 | dependencies = [ 1308 | "proc-macro2", 1309 | "quote", 1310 | "unicode-ident", 1311 | ] 1312 | 1313 | [[package]] 1314 | name = "sys-locale" 1315 | version = "0.3.2" 1316 | source = "registry+https://github.com/rust-lang/crates.io-index" 1317 | checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" 1318 | dependencies = [ 1319 | "libc", 1320 | ] 1321 | 1322 | [[package]] 1323 | name = "sysinfo" 1324 | version = "0.33.1" 1325 | source = "registry+https://github.com/rust-lang/crates.io-index" 1326 | checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" 1327 | dependencies = [ 1328 | "core-foundation-sys", 1329 | "libc", 1330 | "memchr", 1331 | "ntapi", 1332 | "rayon", 1333 | "windows", 1334 | ] 1335 | 1336 | [[package]] 1337 | name = "terminal_size" 1338 | version = "0.4.1" 1339 | source = "registry+https://github.com/rust-lang/crates.io-index" 1340 | checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" 1341 | dependencies = [ 1342 | "rustix", 1343 | "windows-sys 0.59.0", 1344 | ] 1345 | 1346 | [[package]] 1347 | name = "textwrap" 1348 | version = "0.16.1" 1349 | source = "registry+https://github.com/rust-lang/crates.io-index" 1350 | checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" 1351 | dependencies = [ 1352 | "unicode-linebreak", 1353 | "unicode-width", 1354 | ] 1355 | 1356 | [[package]] 1357 | name = "thiserror" 1358 | version = "1.0.66" 1359 | source = "registry+https://github.com/rust-lang/crates.io-index" 1360 | checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede" 1361 | dependencies = [ 1362 | "thiserror-impl 1.0.66", 1363 | ] 1364 | 1365 | [[package]] 1366 | name = "thiserror" 1367 | version = "2.0.12" 1368 | source = "registry+https://github.com/rust-lang/crates.io-index" 1369 | checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" 1370 | dependencies = [ 1371 | "thiserror-impl 2.0.12", 1372 | ] 1373 | 1374 | [[package]] 1375 | name = "thiserror-impl" 1376 | version = "1.0.66" 1377 | source = "registry+https://github.com/rust-lang/crates.io-index" 1378 | checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5" 1379 | dependencies = [ 1380 | "proc-macro2", 1381 | "quote", 1382 | "syn", 1383 | ] 1384 | 1385 | [[package]] 1386 | name = "thiserror-impl" 1387 | version = "2.0.12" 1388 | source = "registry+https://github.com/rust-lang/crates.io-index" 1389 | checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" 1390 | dependencies = [ 1391 | "proc-macro2", 1392 | "quote", 1393 | "syn", 1394 | ] 1395 | 1396 | [[package]] 1397 | name = "typeid" 1398 | version = "1.0.2" 1399 | source = "registry+https://github.com/rust-lang/crates.io-index" 1400 | checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" 1401 | 1402 | [[package]] 1403 | name = "typetag" 1404 | version = "0.2.18" 1405 | source = "registry+https://github.com/rust-lang/crates.io-index" 1406 | checksum = "52ba3b6e86ffe0054b2c44f2d86407388b933b16cb0a70eea3929420db1d9bbe" 1407 | dependencies = [ 1408 | "erased-serde", 1409 | "inventory", 1410 | "once_cell", 1411 | "serde", 1412 | "typetag-impl", 1413 | ] 1414 | 1415 | [[package]] 1416 | name = "typetag-impl" 1417 | version = "0.2.18" 1418 | source = "registry+https://github.com/rust-lang/crates.io-index" 1419 | checksum = "70b20a22c42c8f1cd23ce5e34f165d4d37038f5b663ad20fb6adbdf029172483" 1420 | dependencies = [ 1421 | "proc-macro2", 1422 | "quote", 1423 | "syn", 1424 | ] 1425 | 1426 | [[package]] 1427 | name = "unicase" 1428 | version = "2.8.0" 1429 | source = "registry+https://github.com/rust-lang/crates.io-index" 1430 | checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" 1431 | 1432 | [[package]] 1433 | name = "unicode-ident" 1434 | version = "1.0.13" 1435 | source = "registry+https://github.com/rust-lang/crates.io-index" 1436 | checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" 1437 | 1438 | [[package]] 1439 | name = "unicode-linebreak" 1440 | version = "0.1.5" 1441 | source = "registry+https://github.com/rust-lang/crates.io-index" 1442 | checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" 1443 | 1444 | [[package]] 1445 | name = "unicode-width" 1446 | version = "0.1.14" 1447 | source = "registry+https://github.com/rust-lang/crates.io-index" 1448 | checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" 1449 | 1450 | [[package]] 1451 | name = "unit-conversions" 1452 | version = "0.1.16" 1453 | source = "registry+https://github.com/rust-lang/crates.io-index" 1454 | checksum = "af4a2df0c3075cdb0ace2ea9bd9f7f830776cf0c1741f4c585a6b7358ade095f" 1455 | 1456 | [[package]] 1457 | name = "utf8parse" 1458 | version = "0.2.2" 1459 | source = "registry+https://github.com/rust-lang/crates.io-index" 1460 | checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 1461 | 1462 | [[package]] 1463 | name = "vte" 1464 | version = "0.11.1" 1465 | source = "registry+https://github.com/rust-lang/crates.io-index" 1466 | checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" 1467 | dependencies = [ 1468 | "utf8parse", 1469 | "vte_generate_state_changes", 1470 | ] 1471 | 1472 | [[package]] 1473 | name = "vte_generate_state_changes" 1474 | version = "0.1.2" 1475 | source = "registry+https://github.com/rust-lang/crates.io-index" 1476 | checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" 1477 | dependencies = [ 1478 | "proc-macro2", 1479 | "quote", 1480 | ] 1481 | 1482 | [[package]] 1483 | name = "wasi" 1484 | version = "0.11.0+wasi-snapshot-preview1" 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" 1486 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1487 | 1488 | [[package]] 1489 | name = "wasm-bindgen" 1490 | version = "0.2.95" 1491 | source = "registry+https://github.com/rust-lang/crates.io-index" 1492 | checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" 1493 | dependencies = [ 1494 | "cfg-if", 1495 | "once_cell", 1496 | "wasm-bindgen-macro", 1497 | ] 1498 | 1499 | [[package]] 1500 | name = "wasm-bindgen-backend" 1501 | version = "0.2.95" 1502 | source = "registry+https://github.com/rust-lang/crates.io-index" 1503 | checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" 1504 | dependencies = [ 1505 | "bumpalo", 1506 | "log", 1507 | "once_cell", 1508 | "proc-macro2", 1509 | "quote", 1510 | "syn", 1511 | "wasm-bindgen-shared", 1512 | ] 1513 | 1514 | [[package]] 1515 | name = "wasm-bindgen-macro" 1516 | version = "0.2.95" 1517 | source = "registry+https://github.com/rust-lang/crates.io-index" 1518 | checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" 1519 | dependencies = [ 1520 | "quote", 1521 | "wasm-bindgen-macro-support", 1522 | ] 1523 | 1524 | [[package]] 1525 | name = "wasm-bindgen-macro-support" 1526 | version = "0.2.95" 1527 | source = "registry+https://github.com/rust-lang/crates.io-index" 1528 | checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" 1529 | dependencies = [ 1530 | "proc-macro2", 1531 | "quote", 1532 | "syn", 1533 | "wasm-bindgen-backend", 1534 | "wasm-bindgen-shared", 1535 | ] 1536 | 1537 | [[package]] 1538 | name = "wasm-bindgen-shared" 1539 | version = "0.2.95" 1540 | source = "registry+https://github.com/rust-lang/crates.io-index" 1541 | checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" 1542 | 1543 | [[package]] 1544 | name = "web-time" 1545 | version = "1.1.0" 1546 | source = "registry+https://github.com/rust-lang/crates.io-index" 1547 | checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" 1548 | dependencies = [ 1549 | "js-sys", 1550 | "wasm-bindgen", 1551 | ] 1552 | 1553 | [[package]] 1554 | name = "widestring" 1555 | version = "1.1.0" 1556 | source = "registry+https://github.com/rust-lang/crates.io-index" 1557 | checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" 1558 | 1559 | [[package]] 1560 | name = "winapi" 1561 | version = "0.3.9" 1562 | source = "registry+https://github.com/rust-lang/crates.io-index" 1563 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1564 | dependencies = [ 1565 | "winapi-i686-pc-windows-gnu", 1566 | "winapi-x86_64-pc-windows-gnu", 1567 | ] 1568 | 1569 | [[package]] 1570 | name = "winapi-i686-pc-windows-gnu" 1571 | version = "0.4.0" 1572 | source = "registry+https://github.com/rust-lang/crates.io-index" 1573 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1574 | 1575 | [[package]] 1576 | name = "winapi-x86_64-pc-windows-gnu" 1577 | version = "0.4.0" 1578 | source = "registry+https://github.com/rust-lang/crates.io-index" 1579 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1580 | 1581 | [[package]] 1582 | name = "windows" 1583 | version = "0.56.0" 1584 | source = "registry+https://github.com/rust-lang/crates.io-index" 1585 | checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" 1586 | dependencies = [ 1587 | "windows-core 0.56.0", 1588 | "windows-targets 0.52.6", 1589 | ] 1590 | 1591 | [[package]] 1592 | name = "windows-core" 1593 | version = "0.52.0" 1594 | source = "registry+https://github.com/rust-lang/crates.io-index" 1595 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 1596 | dependencies = [ 1597 | "windows-targets 0.52.6", 1598 | ] 1599 | 1600 | [[package]] 1601 | name = "windows-core" 1602 | version = "0.56.0" 1603 | source = "registry+https://github.com/rust-lang/crates.io-index" 1604 | checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" 1605 | dependencies = [ 1606 | "windows-implement", 1607 | "windows-interface", 1608 | "windows-result", 1609 | "windows-targets 0.52.6", 1610 | ] 1611 | 1612 | [[package]] 1613 | name = "windows-implement" 1614 | version = "0.56.0" 1615 | source = "registry+https://github.com/rust-lang/crates.io-index" 1616 | checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" 1617 | dependencies = [ 1618 | "proc-macro2", 1619 | "quote", 1620 | "syn", 1621 | ] 1622 | 1623 | [[package]] 1624 | name = "windows-interface" 1625 | version = "0.56.0" 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" 1627 | checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" 1628 | dependencies = [ 1629 | "proc-macro2", 1630 | "quote", 1631 | "syn", 1632 | ] 1633 | 1634 | [[package]] 1635 | name = "windows-result" 1636 | version = "0.1.2" 1637 | source = "registry+https://github.com/rust-lang/crates.io-index" 1638 | checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" 1639 | dependencies = [ 1640 | "windows-targets 0.52.6", 1641 | ] 1642 | 1643 | [[package]] 1644 | name = "windows-sys" 1645 | version = "0.48.0" 1646 | source = "registry+https://github.com/rust-lang/crates.io-index" 1647 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1648 | dependencies = [ 1649 | "windows-targets 0.48.5", 1650 | ] 1651 | 1652 | [[package]] 1653 | name = "windows-sys" 1654 | version = "0.52.0" 1655 | source = "registry+https://github.com/rust-lang/crates.io-index" 1656 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1657 | dependencies = [ 1658 | "windows-targets 0.52.6", 1659 | ] 1660 | 1661 | [[package]] 1662 | name = "windows-sys" 1663 | version = "0.59.0" 1664 | source = "registry+https://github.com/rust-lang/crates.io-index" 1665 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1666 | dependencies = [ 1667 | "windows-targets 0.52.6", 1668 | ] 1669 | 1670 | [[package]] 1671 | name = "windows-targets" 1672 | version = "0.48.5" 1673 | source = "registry+https://github.com/rust-lang/crates.io-index" 1674 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1675 | dependencies = [ 1676 | "windows_aarch64_gnullvm 0.48.5", 1677 | "windows_aarch64_msvc 0.48.5", 1678 | "windows_i686_gnu 0.48.5", 1679 | "windows_i686_msvc 0.48.5", 1680 | "windows_x86_64_gnu 0.48.5", 1681 | "windows_x86_64_gnullvm 0.48.5", 1682 | "windows_x86_64_msvc 0.48.5", 1683 | ] 1684 | 1685 | [[package]] 1686 | name = "windows-targets" 1687 | version = "0.52.6" 1688 | source = "registry+https://github.com/rust-lang/crates.io-index" 1689 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1690 | dependencies = [ 1691 | "windows_aarch64_gnullvm 0.52.6", 1692 | "windows_aarch64_msvc 0.52.6", 1693 | "windows_i686_gnu 0.52.6", 1694 | "windows_i686_gnullvm", 1695 | "windows_i686_msvc 0.52.6", 1696 | "windows_x86_64_gnu 0.52.6", 1697 | "windows_x86_64_gnullvm 0.52.6", 1698 | "windows_x86_64_msvc 0.52.6", 1699 | ] 1700 | 1701 | [[package]] 1702 | name = "windows_aarch64_gnullvm" 1703 | version = "0.48.5" 1704 | source = "registry+https://github.com/rust-lang/crates.io-index" 1705 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1706 | 1707 | [[package]] 1708 | name = "windows_aarch64_gnullvm" 1709 | version = "0.52.6" 1710 | source = "registry+https://github.com/rust-lang/crates.io-index" 1711 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1712 | 1713 | [[package]] 1714 | name = "windows_aarch64_msvc" 1715 | version = "0.48.5" 1716 | source = "registry+https://github.com/rust-lang/crates.io-index" 1717 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1718 | 1719 | [[package]] 1720 | name = "windows_aarch64_msvc" 1721 | version = "0.52.6" 1722 | source = "registry+https://github.com/rust-lang/crates.io-index" 1723 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1724 | 1725 | [[package]] 1726 | name = "windows_i686_gnu" 1727 | version = "0.48.5" 1728 | source = "registry+https://github.com/rust-lang/crates.io-index" 1729 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1730 | 1731 | [[package]] 1732 | name = "windows_i686_gnu" 1733 | version = "0.52.6" 1734 | source = "registry+https://github.com/rust-lang/crates.io-index" 1735 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1736 | 1737 | [[package]] 1738 | name = "windows_i686_gnullvm" 1739 | version = "0.52.6" 1740 | source = "registry+https://github.com/rust-lang/crates.io-index" 1741 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1742 | 1743 | [[package]] 1744 | name = "windows_i686_msvc" 1745 | version = "0.48.5" 1746 | source = "registry+https://github.com/rust-lang/crates.io-index" 1747 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1748 | 1749 | [[package]] 1750 | name = "windows_i686_msvc" 1751 | version = "0.52.6" 1752 | source = "registry+https://github.com/rust-lang/crates.io-index" 1753 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1754 | 1755 | [[package]] 1756 | name = "windows_x86_64_gnu" 1757 | version = "0.48.5" 1758 | source = "registry+https://github.com/rust-lang/crates.io-index" 1759 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1760 | 1761 | [[package]] 1762 | name = "windows_x86_64_gnu" 1763 | version = "0.52.6" 1764 | source = "registry+https://github.com/rust-lang/crates.io-index" 1765 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1766 | 1767 | [[package]] 1768 | name = "windows_x86_64_gnullvm" 1769 | version = "0.48.5" 1770 | source = "registry+https://github.com/rust-lang/crates.io-index" 1771 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1772 | 1773 | [[package]] 1774 | name = "windows_x86_64_gnullvm" 1775 | version = "0.52.6" 1776 | source = "registry+https://github.com/rust-lang/crates.io-index" 1777 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1778 | 1779 | [[package]] 1780 | name = "windows_x86_64_msvc" 1781 | version = "0.48.5" 1782 | source = "registry+https://github.com/rust-lang/crates.io-index" 1783 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1784 | 1785 | [[package]] 1786 | name = "windows_x86_64_msvc" 1787 | version = "0.52.6" 1788 | source = "registry+https://github.com/rust-lang/crates.io-index" 1789 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1790 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Joseph T Lyons "] 3 | description = "A Nushell plugin for easily converting between common units" 4 | edition = "2021" 5 | license = "GPL-3.0-only" 6 | name = "nu_plugin_units" 7 | repository = "https://github.com/JosephTLyons/nu_plugin_units" 8 | version = "0.1.6" 9 | 10 | [dependencies] 11 | anyhow = "1.0.98" 12 | nu-ansi-term = "0.50.1" 13 | nu-plugin = "0.104.0" 14 | nu-protocol = "0.104.0" 15 | unit-conversions = "0.1.16" 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Joseph T. Lyons 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nu_plugin_units 2 | 3 | A [Nushell](https://www.nushell.sh) plugin for easily converting between common units. 4 | 5 | ## Installation 6 | 7 | 1. Clone this repository 8 | 2. Build the target via `cargo build --release` 9 | 3. Add the plugin to nushell using the following nushell command `plugin add ./target/release/nu_plugin_units` 10 | 4. Reload the plugin using `plugin use units` 11 | 12 | ## Usage 13 | 14 | ```shell 15 | 〉units -c time -u years -v 1 16 | ╭────┬──────────────┬────────────────────────╮ 17 | │ # │ unit │ value │ 18 | ├────┼──────────────┼────────────────────────┤ 19 | │ 0 │ centuries │ 0.0100 │ 20 | │ 1 │ days │ 365.0000 │ 21 | │ 2 │ decades │ 0.1000 │ 22 | │ 3 │ hours │ 8760.0000 │ 23 | │ 4 │ microseconds │ 31540000000000.0000 │ 24 | │ 5 │ milliseconds │ 31556952000.0000 │ 25 | │ 6 │ minutes │ 525600.0000 │ 26 | │ 7 │ months │ 12.0000 │ 27 | │ 8 │ nanoseconds │ 31540000000000000.0000 │ 28 | │ 9 │ seconds │ 31536000.0000 │ 29 | │ 10 │ weeks │ 52.1430 │ 30 | │ 11 │ years │ 1.0000 │ 31 | ╰────┴──────────────┴────────────────────────╯ 32 | ``` 33 | 34 | You may want to consider adjusting the value of `float_precision` in your nushell config file. 35 | 36 | ```nu 37 | $env.config = { 38 | float_precision: 4 39 | ... 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod nu; 2 | 3 | mod values; 4 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, JsonSerializer}; 2 | use nu_plugin_units::nu::Units; 3 | 4 | fn main() { 5 | serve_plugin(&mut Units {}, JsonSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /src/nu/mod.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use crate::values::*; 4 | use nu_plugin::{EvaluatedCall, Plugin, PluginCommand, SimplePluginCommand}; 5 | use nu_protocol::{ 6 | Category as NU_CATEGORY, ErrorLabel, Example, LabeledError, Record, Signature, SyntaxShape, 7 | Value, 8 | }; 9 | 10 | pub struct Units; 11 | 12 | const CATEGORY_FLAG_NAME: &'static str = "category"; 13 | const UNIT_FLAG_NAME: &'static str = "unit"; 14 | const VALUE_FLAG_NAME: &'static str = "value"; 15 | 16 | impl Plugin for Units { 17 | fn commands(&self) -> Vec>> { 18 | vec![Box::new(Units)] 19 | } 20 | 21 | fn version(&self) -> String { 22 | env!("CARGO_PKG_VERSION").into() 23 | } 24 | } 25 | 26 | impl SimplePluginCommand for Units { 27 | type Plugin = Units; 28 | 29 | fn name(&self) -> &str { 30 | "units" 31 | } 32 | 33 | fn description(&self) -> &str { 34 | "Convert between units" 35 | } 36 | 37 | fn signature(&self) -> Signature { 38 | Signature::build(PluginCommand::name(self)) 39 | .required_named( 40 | CATEGORY_FLAG_NAME, 41 | SyntaxShape::String, 42 | "specify the category", 43 | Some('c'), 44 | ) 45 | .required_named( 46 | UNIT_FLAG_NAME, 47 | SyntaxShape::String, 48 | "specify the unit type", 49 | Some('u'), 50 | ) 51 | .required_named( 52 | VALUE_FLAG_NAME, 53 | SyntaxShape::Float, 54 | "specify the value", 55 | Some('v'), 56 | ) 57 | .category(NU_CATEGORY::Generators) 58 | } 59 | 60 | fn examples(&self) -> Vec { 61 | vec![Example { 62 | description: "units -c time -u years -v 1".into(), 63 | example: "Display various units of time equivalent to 1 year".into(), 64 | result: None, 65 | }] 66 | } 67 | 68 | fn run( 69 | &self, 70 | _: &Self::Plugin, 71 | _: &nu_plugin::EngineInterface, 72 | call: &EvaluatedCall, 73 | _: &Value, 74 | ) -> Result { 75 | let tag = call.head; 76 | 77 | // The `unwrap()`s are safe, since the flags, arguments, and arguments types are enforced by the signature 78 | // The `unwrap()`s here are to make sure the strings looked up matches the ones in the signature 79 | let category = call.get_flag_value(CATEGORY_FLAG_NAME).unwrap(); 80 | let category_span = category.span(); 81 | let category = category.into_string().unwrap(); 82 | 83 | let unit = call.get_flag_value(UNIT_FLAG_NAME).unwrap(); 84 | let unit_span = unit.span(); 85 | let unit = unit.into_string().unwrap(); 86 | 87 | let categories: HashMap<_, _> = HashMap::from_iter([ 88 | hash_map_tuple(Angle), 89 | hash_map_tuple(Area), 90 | hash_map_tuple(DataStorage), 91 | hash_map_tuple(DataTransferRate), 92 | hash_map_tuple(Energy), 93 | hash_map_tuple(Force), 94 | hash_map_tuple(Frequency), 95 | hash_map_tuple(FuelEconomy), 96 | hash_map_tuple(Length), 97 | hash_map_tuple(LuminousEnergy), 98 | hash_map_tuple(MagnetomotiveForce), 99 | hash_map_tuple(Mass), 100 | hash_map_tuple(Pressure), 101 | hash_map_tuple(Speed), 102 | hash_map_tuple(Temperature), 103 | hash_map_tuple(Time), 104 | hash_map_tuple(Volume), 105 | ]); 106 | 107 | let Some((values_function, units)) = categories.get(category.as_str()) else { 108 | let mut valid_categories = categories 109 | .keys() 110 | .map(|category| format!("{}", category)) 111 | .collect::>(); 112 | valid_categories.sort(); 113 | let valid_categories = valid_categories.join(", "); 114 | let text = format!("not a valid category."); 115 | let msg = format!("{} Options: {}", text, valid_categories); 116 | 117 | return Err(LabeledError { 118 | msg, 119 | labels: Box::new(vec![ErrorLabel { 120 | text, 121 | span: category_span, 122 | }]), 123 | code: None, 124 | url: None, 125 | help: None, 126 | inner: Box::new(vec![]), 127 | }); 128 | }; 129 | 130 | let value = call 131 | .get_flag_value(VALUE_FLAG_NAME) 132 | .unwrap() 133 | .as_float() 134 | .unwrap(); 135 | 136 | let Ok(mut values) = values_function(&unit, value) else { 137 | let valid_units = units.join(", "); 138 | let text = format!("not a valid unit."); 139 | let msg = format!("{} Options: {}", text, valid_units); 140 | 141 | return Err(LabeledError { 142 | msg, 143 | labels: Box::new(vec![ErrorLabel { 144 | text, 145 | span: unit_span, 146 | }]), 147 | code: None, 148 | url: None, 149 | help: None, 150 | inner: Box::new(vec![]), 151 | }); 152 | }; 153 | 154 | values.sort_by_key(|value| value.0.clone()); 155 | 156 | let values: Vec<_> = values 157 | .iter() 158 | .map(|(unit, value)| { 159 | let unit = unit.replace('-', " "); 160 | let record = Record::from_iter([ 161 | (UNIT_FLAG_NAME.into(), Value::string(unit, tag)), 162 | (VALUE_FLAG_NAME.into(), Value::float(*value, tag)), 163 | ]); 164 | Value::record(record, tag) 165 | }) 166 | .collect(); 167 | 168 | Ok(Value::list(values, tag)) 169 | } 170 | } 171 | 172 | // TODO: Extract tuple into type? 173 | fn hash_map_tuple(_: D) -> (&'static str, (ValuesFunction, Vec<&'static str>)) { 174 | (D::name(), (D::values, D::units())) 175 | } 176 | -------------------------------------------------------------------------------- /src/values/angle.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::angle::*; 4 | 5 | const DEGREES: &str = "degrees"; 6 | const GRADIANS: &str = "gradians"; 7 | const MILLIRADIANS: &str = "milliradians"; 8 | const MINUTE_OF_ARC: &str = "minute-of-arc"; 9 | const RADIANS: &str = "radians"; 10 | const SECONDS_OF_ARC: &str = "seconds-of-arc"; 11 | 12 | pub struct Angle; 13 | 14 | impl Category for Angle { 15 | fn name() -> &'static str { 16 | "angle" 17 | } 18 | fn conversion_function_map() -> ConversionFunctionMap { 19 | HashMap::from_iter([ 20 | ( 21 | DEGREES, 22 | HashMap::from_iter([ 23 | (DEGREES, identity as ConversionFunction), 24 | (GRADIANS, degrees::to_gradians), 25 | (MILLIRADIANS, degrees::to_milliradians), 26 | (MINUTE_OF_ARC, degrees::to_minute_of_arc), 27 | (RADIANS, degrees::to_radians), 28 | (SECONDS_OF_ARC, degrees::to_seconds_of_arc), 29 | ]), 30 | ), 31 | ( 32 | GRADIANS, 33 | HashMap::from_iter([ 34 | (DEGREES, gradians::to_degrees as ConversionFunction), 35 | (GRADIANS, identity), 36 | (MILLIRADIANS, gradians::to_milliradians), 37 | (MINUTE_OF_ARC, gradians::to_minute_of_arc), 38 | (RADIANS, gradians::to_radians), 39 | (SECONDS_OF_ARC, gradians::to_seconds_of_arc), 40 | ]), 41 | ), 42 | ( 43 | MILLIRADIANS, 44 | HashMap::from_iter([ 45 | (DEGREES, milliradians::to_degrees as ConversionFunction), 46 | (GRADIANS, milliradians::to_gradians), 47 | (MILLIRADIANS, identity), 48 | (MINUTE_OF_ARC, milliradians::to_minute_of_arc), 49 | (RADIANS, milliradians::to_radians), 50 | (SECONDS_OF_ARC, milliradians::to_seconds_of_arc), 51 | ]), 52 | ), 53 | ( 54 | MINUTE_OF_ARC, 55 | HashMap::from_iter([ 56 | (DEGREES, minute_of_arc::to_degrees as ConversionFunction), 57 | (GRADIANS, minute_of_arc::to_gradians), 58 | (MILLIRADIANS, minute_of_arc::to_milliradians), 59 | (MINUTE_OF_ARC, identity), 60 | (RADIANS, minute_of_arc::to_radians), 61 | (SECONDS_OF_ARC, minute_of_arc::to_seconds_of_arc), 62 | ]), 63 | ), 64 | ( 65 | RADIANS, 66 | HashMap::from_iter([ 67 | (DEGREES, radians::to_degrees as ConversionFunction), 68 | (GRADIANS, radians::to_gradians), 69 | (MILLIRADIANS, radians::to_milliradians), 70 | (MINUTE_OF_ARC, radians::to_minute_of_arc), 71 | (RADIANS, identity), 72 | (SECONDS_OF_ARC, radians::to_seconds_of_arc), 73 | ]), 74 | ), 75 | ( 76 | SECONDS_OF_ARC, 77 | HashMap::from_iter([ 78 | (DEGREES, seconds_of_arc::to_degrees as ConversionFunction), 79 | (GRADIANS, seconds_of_arc::to_gradians), 80 | (MILLIRADIANS, seconds_of_arc::to_milliradians), 81 | (MINUTE_OF_ARC, seconds_of_arc::to_minute_of_arc), 82 | (RADIANS, seconds_of_arc::to_radians), 83 | (SECONDS_OF_ARC, identity), 84 | ]), 85 | ), 86 | ]) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/values/area.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::area::*; 4 | 5 | const ACRES: &str = "acres"; 6 | const HECTARES: &str = "hectares"; 7 | const SQUARE_FEET: &str = "square-feet"; 8 | const SQUARE_INCHES: &str = "square-inches"; 9 | const SQUARE_KILOMETRES: &str = "square-kilometres"; 10 | const SQUARE_METRES: &str = "square-metres"; 11 | const SQUARE_MILES: &str = "square-miles"; 12 | 13 | pub struct Area; 14 | 15 | impl Category for Area { 16 | fn name() -> &'static str { 17 | "area" 18 | } 19 | fn conversion_function_map() -> ConversionFunctionMap { 20 | HashMap::from_iter([ 21 | ( 22 | ACRES, 23 | HashMap::from_iter([ 24 | (ACRES, identity as ConversionFunction), 25 | (HECTARES, acres::to_hectares), 26 | (SQUARE_FEET, acres::to_square_feet), 27 | (SQUARE_INCHES, acres::to_square_inches), 28 | (SQUARE_KILOMETRES, acres::to_square_kilometres), 29 | (SQUARE_METRES, acres::to_square_metres), 30 | (SQUARE_MILES, acres::to_square_miles), 31 | ]), 32 | ), 33 | ( 34 | HECTARES, 35 | HashMap::from_iter([ 36 | (ACRES, hectares::to_acres as ConversionFunction), 37 | (HECTARES, identity), 38 | (SQUARE_FEET, hectares::to_square_feet), 39 | (SQUARE_INCHES, hectares::to_square_inches), 40 | (SQUARE_KILOMETRES, hectares::to_square_kilometres), 41 | (SQUARE_METRES, hectares::to_square_metres), 42 | (SQUARE_MILES, hectares::to_square_miles), 43 | ]), 44 | ), 45 | ( 46 | SQUARE_FEET, 47 | HashMap::from_iter([ 48 | (ACRES, square_feet::to_acres as ConversionFunction), 49 | (HECTARES, square_feet::to_hectares), 50 | (SQUARE_FEET, identity), 51 | (SQUARE_INCHES, square_feet::to_square_inches), 52 | (SQUARE_KILOMETRES, square_feet::to_square_kilometres), 53 | (SQUARE_METRES, square_feet::to_square_metres), 54 | (SQUARE_MILES, square_feet::to_square_miles), 55 | ]), 56 | ), 57 | ( 58 | SQUARE_INCHES, 59 | HashMap::from_iter([ 60 | (ACRES, square_inches::to_acres as ConversionFunction), 61 | (HECTARES, square_inches::to_hectares), 62 | (SQUARE_FEET, square_inches::to_square_feet), 63 | (SQUARE_INCHES, identity), 64 | (SQUARE_KILOMETRES, square_inches::to_square_kilometres), 65 | (SQUARE_METRES, square_inches::to_square_metres), 66 | (SQUARE_MILES, square_inches::to_square_miles), 67 | ]), 68 | ), 69 | ( 70 | SQUARE_KILOMETRES, 71 | HashMap::from_iter([ 72 | (ACRES, square_kilometres::to_acres as ConversionFunction), 73 | (HECTARES, square_kilometres::to_hectares), 74 | (SQUARE_FEET, square_kilometres::to_square_feet), 75 | (SQUARE_INCHES, square_kilometres::to_square_inches), 76 | (SQUARE_KILOMETRES, identity), 77 | (SQUARE_METRES, square_kilometres::to_square_metres), 78 | (SQUARE_MILES, square_kilometres::to_square_miles), 79 | ]), 80 | ), 81 | ( 82 | SQUARE_METRES, 83 | HashMap::from_iter([ 84 | (ACRES, square_metres::to_acres as ConversionFunction), 85 | (HECTARES, square_metres::to_hectares), 86 | (SQUARE_FEET, square_metres::to_square_feet), 87 | (SQUARE_INCHES, square_metres::to_square_inches), 88 | (SQUARE_KILOMETRES, square_metres::to_square_kilometres), 89 | (SQUARE_METRES, identity), 90 | (SQUARE_MILES, square_metres::to_square_miles), 91 | ]), 92 | ), 93 | ( 94 | SQUARE_MILES, 95 | HashMap::from_iter([ 96 | (ACRES, square_miles::to_acres as ConversionFunction), 97 | (HECTARES, square_miles::to_hectares), 98 | (SQUARE_FEET, square_miles::to_square_feet), 99 | (SQUARE_INCHES, square_miles::to_square_inches), 100 | (SQUARE_KILOMETRES, square_miles::to_square_kilometres), 101 | (SQUARE_METRES, square_miles::to_square_metres), 102 | (SQUARE_MILES, identity), 103 | ]), 104 | ), 105 | ]) 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/values/data_storage.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::data_storage::*; 4 | 5 | const BITS: &str = "bits"; 6 | const GIGABITS: &str = "gigabits"; 7 | const GIGABYTES: &str = "gigabytes"; 8 | const KIBIBITS: &str = "kibibits"; 9 | const KILOBITS: &str = "kilobits"; 10 | const MEBIBITS: &str = "mebibits"; 11 | const MEGABITS: &str = "megabits"; 12 | const MEGABYTES: &str = "megabytes"; 13 | const TERABITS: &str = "terabits"; 14 | const TERABYTES: &str = "terabytes"; 15 | 16 | pub struct DataStorage; 17 | 18 | impl Category for DataStorage { 19 | fn name() -> &'static str { 20 | "data-storage" 21 | } 22 | fn conversion_function_map() -> ConversionFunctionMap { 23 | HashMap::from_iter([ 24 | ( 25 | BITS, 26 | HashMap::from_iter([ 27 | (BITS, identity as ConversionFunction), 28 | (GIGABITS, bits::to_gigabits), 29 | (GIGABYTES, bits::to_gigabytes), 30 | (KIBIBITS, bits::to_kibibits), 31 | (KILOBITS, bits::to_kilobits), 32 | (MEBIBITS, bits::to_mebibits), 33 | (MEGABITS, bits::to_megabits), 34 | (MEGABYTES, bits::to_megabytes), 35 | (TERABITS, bits::to_terabits), 36 | (TERABYTES, bits::to_terabytes), 37 | ]), 38 | ), 39 | ( 40 | GIGABITS, 41 | HashMap::from_iter([ 42 | (BITS, gigabits::to_bits as ConversionFunction), 43 | (GIGABITS, identity), 44 | (GIGABYTES, gigabits::to_gigabytes), 45 | (KIBIBITS, gigabits::to_kibibits), 46 | (KILOBITS, gigabits::to_kilobits), 47 | (MEBIBITS, gigabits::to_mebibits), 48 | (MEGABITS, gigabits::to_megabits), 49 | (MEGABYTES, gigabits::to_megabytes), 50 | (TERABITS, gigabits::to_terabits), 51 | (TERABYTES, gigabits::to_terabytes), 52 | ]), 53 | ), 54 | ( 55 | GIGABYTES, 56 | HashMap::from_iter([ 57 | (BITS, gigabytes::to_bits as ConversionFunction), 58 | (GIGABITS, gigabytes::to_gigabits), 59 | (GIGABYTES, identity), 60 | (KIBIBITS, gigabytes::to_kibibits), 61 | (KILOBITS, gigabytes::to_kilobits), 62 | (MEBIBITS, gigabytes::to_mebibits), 63 | (MEGABITS, gigabytes::to_megabits), 64 | (MEGABYTES, gigabytes::to_megabytes), 65 | (TERABITS, gigabytes::to_terabits), 66 | (TERABYTES, gigabytes::to_terabytes), 67 | ]), 68 | ), 69 | ( 70 | KIBIBITS, 71 | HashMap::from_iter([ 72 | (BITS, kibibits::to_bits as ConversionFunction), 73 | (GIGABITS, kibibits::to_gigabits), 74 | (GIGABYTES, kibibits::to_gigabytes), 75 | (KIBIBITS, identity), 76 | (KILOBITS, kibibits::to_kilobits), 77 | (MEBIBITS, kibibits::to_mebibits), 78 | (MEGABITS, kibibits::to_megabits), 79 | (MEGABYTES, kibibits::to_megabytes), 80 | (TERABITS, kibibits::to_terabits), 81 | (TERABYTES, kibibits::to_terabytes), 82 | ]), 83 | ), 84 | ( 85 | KILOBITS, 86 | HashMap::from_iter([ 87 | (BITS, kilobits::to_bits as ConversionFunction), 88 | (GIGABITS, kilobits::to_gigabits), 89 | (GIGABYTES, kilobits::to_gigabytes), 90 | (KIBIBITS, kilobits::to_kibibits), 91 | (KILOBITS, identity), 92 | (MEBIBITS, kilobits::to_mebibits), 93 | (MEGABITS, kilobits::to_megabits), 94 | (MEGABYTES, kilobits::to_megabytes), 95 | (TERABITS, kilobits::to_terabits), 96 | (TERABYTES, kilobits::to_terabytes), 97 | ]), 98 | ), 99 | ( 100 | MEBIBITS, 101 | HashMap::from_iter([ 102 | (BITS, mebibits::to_bits as ConversionFunction), 103 | (GIGABITS, mebibits::to_gigabits), 104 | (GIGABYTES, mebibits::to_gigabytes), 105 | (KIBIBITS, mebibits::to_kibibits), 106 | (KILOBITS, mebibits::to_kilobits), 107 | (MEBIBITS, identity), 108 | (MEGABITS, mebibits::to_megabits), 109 | (MEGABYTES, mebibits::to_megabytes), 110 | (TERABITS, mebibits::to_terabits), 111 | (TERABYTES, mebibits::to_terabytes), 112 | ]), 113 | ), 114 | ( 115 | MEGABITS, 116 | HashMap::from_iter([ 117 | (BITS, megabits::to_bits as ConversionFunction), 118 | (GIGABITS, megabits::to_gigabits), 119 | (GIGABYTES, megabits::to_gigabytes), 120 | (KIBIBITS, megabits::to_kibibits), 121 | (KILOBITS, megabits::to_kilobits), 122 | (MEBIBITS, megabits::to_mebibits), 123 | (MEGABITS, identity), 124 | (MEGABYTES, megabits::to_megabytes), 125 | (TERABITS, megabits::to_terabits), 126 | (TERABYTES, megabits::to_terabytes), 127 | ]), 128 | ), 129 | ( 130 | MEGABYTES, 131 | HashMap::from_iter([ 132 | (BITS, megabytes::to_bits as ConversionFunction), 133 | (GIGABITS, megabytes::to_gigabits), 134 | (GIGABYTES, megabytes::to_gigabytes), 135 | (KIBIBITS, megabytes::to_kibibits), 136 | (KILOBITS, megabytes::to_kilobits), 137 | (MEBIBITS, megabytes::to_mebibits), 138 | (MEGABITS, megabytes::to_megabits), 139 | (MEGABYTES, identity), 140 | (TERABITS, megabytes::to_terabits), 141 | (TERABYTES, megabytes::to_terabytes), 142 | ]), 143 | ), 144 | ( 145 | TERABITS, 146 | HashMap::from_iter([ 147 | (BITS, terabits::to_bits as ConversionFunction), 148 | (GIGABITS, terabits::to_gigabits), 149 | (GIGABYTES, terabits::to_gigabytes), 150 | (KIBIBITS, terabits::to_kibibits), 151 | (KILOBITS, terabits::to_kilobits), 152 | (MEBIBITS, terabits::to_mebibits), 153 | (MEGABITS, terabits::to_megabits), 154 | (MEGABYTES, terabits::to_megabytes), 155 | (TERABITS, identity), 156 | (TERABYTES, terabits::to_terabytes), 157 | ]), 158 | ), 159 | ( 160 | TERABYTES, 161 | HashMap::from_iter([ 162 | (BITS, terabytes::to_bits as ConversionFunction), 163 | (GIGABITS, terabytes::to_gigabits), 164 | (GIGABYTES, terabytes::to_gigabytes), 165 | (KIBIBITS, terabytes::to_kibibits), 166 | (KILOBITS, terabytes::to_kilobits), 167 | (MEBIBITS, terabytes::to_mebibits), 168 | (MEGABITS, terabytes::to_megabits), 169 | (MEGABYTES, terabytes::to_megabytes), 170 | (TERABITS, terabytes::to_terabits), 171 | (TERABYTES, identity), 172 | ]), 173 | ), 174 | ]) 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/values/data_transfer_rate.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::data_transfer_rate::*; 4 | 5 | const BITS_PER_SECOND: &str = "bits-per-second"; 6 | const GIGABITS_PER_SECOND: &str = "gigabits-per-second"; 7 | const GIGABYTES_PER_SECOND: &str = "gigabytes-per-second"; 8 | const KIBIBITS_PER_SECOND: &str = "kibibits-per-second"; 9 | const KILOBITS_PER_SECOND: &str = "kilobits-per-second"; 10 | const KILOBYTES_PER_SECOND: &str = "kilobytes-per-second"; 11 | const MEBIBITS_PER_SECOND: &str = "mebibits-per-second"; 12 | const MEGABITS_PER_SECOND: &str = "megabits-per-second"; 13 | const MEGABYTES_PER_SECOND: &str = "megabytes-per-second"; 14 | const TERABITS_PER_SECOND: &str = "terabits-per-second"; 15 | const TERABYTES_PER_SECOND: &str = "terabytes-per-second"; 16 | 17 | pub struct DataTransferRate; 18 | 19 | impl Category for DataTransferRate { 20 | fn name() -> &'static str { 21 | "data-transfer-rate" 22 | } 23 | fn conversion_function_map() -> ConversionFunctionMap { 24 | HashMap::from_iter([ 25 | ( 26 | BITS_PER_SECOND, 27 | HashMap::from_iter([ 28 | (BITS_PER_SECOND, identity as ConversionFunction), 29 | ( 30 | GIGABITS_PER_SECOND, 31 | bits_per_second::to_giga_bits_per_second, 32 | ), 33 | ( 34 | GIGABYTES_PER_SECOND, 35 | bits_per_second::to_giga_bytes_per_second, 36 | ), 37 | (KIBIBITS_PER_SECOND, bits_per_second::to_kibibits_per_second), 38 | ( 39 | KILOBITS_PER_SECOND, 40 | bits_per_second::to_kilo_bits_per_second, 41 | ), 42 | ( 43 | KILOBYTES_PER_SECOND, 44 | bits_per_second::to_kilo_bytes_per_second, 45 | ), 46 | (MEBIBITS_PER_SECOND, bits_per_second::to_mebibits_per_second), 47 | ( 48 | MEGABITS_PER_SECOND, 49 | bits_per_second::to_mega_bits_per_second, 50 | ), 51 | ( 52 | MEGABYTES_PER_SECOND, 53 | bits_per_second::to_mega_bytes_per_second, 54 | ), 55 | ( 56 | TERABITS_PER_SECOND, 57 | bits_per_second::to_tera_bits_per_second, 58 | ), 59 | ( 60 | TERABYTES_PER_SECOND, 61 | bits_per_second::to_tera_bytes_per_second, 62 | ), 63 | ]), 64 | ), 65 | ( 66 | GIGABITS_PER_SECOND, 67 | HashMap::from_iter([ 68 | ( 69 | BITS_PER_SECOND, 70 | giga_bits_per_second::to_bits_per_second as ConversionFunction, 71 | ), 72 | (GIGABITS_PER_SECOND, identity), 73 | ( 74 | GIGABYTES_PER_SECOND, 75 | giga_bits_per_second::to_giga_bytes_per_second, 76 | ), 77 | ( 78 | KIBIBITS_PER_SECOND, 79 | giga_bits_per_second::to_kibibits_per_second, 80 | ), 81 | ( 82 | KILOBITS_PER_SECOND, 83 | giga_bits_per_second::to_kilo_bits_per_second, 84 | ), 85 | ( 86 | KILOBYTES_PER_SECOND, 87 | giga_bits_per_second::to_kilo_bytes_per_second, 88 | ), 89 | ( 90 | MEBIBITS_PER_SECOND, 91 | giga_bits_per_second::to_mebibits_per_second, 92 | ), 93 | ( 94 | MEGABITS_PER_SECOND, 95 | giga_bits_per_second::to_mega_bits_per_second, 96 | ), 97 | ( 98 | MEGABYTES_PER_SECOND, 99 | giga_bits_per_second::to_mega_bytes_per_second, 100 | ), 101 | ( 102 | TERABITS_PER_SECOND, 103 | giga_bits_per_second::to_tera_bits_per_second, 104 | ), 105 | ( 106 | TERABYTES_PER_SECOND, 107 | giga_bits_per_second::to_tera_bytes_per_second, 108 | ), 109 | ]), 110 | ), 111 | ( 112 | GIGABYTES_PER_SECOND, 113 | HashMap::from_iter([ 114 | ( 115 | BITS_PER_SECOND, 116 | giga_bytes_per_second::to_bits_per_second as ConversionFunction, 117 | ), 118 | ( 119 | GIGABITS_PER_SECOND, 120 | giga_bytes_per_second::to_giga_bits_per_second, 121 | ), 122 | (GIGABYTES_PER_SECOND, identity), 123 | ( 124 | KIBIBITS_PER_SECOND, 125 | giga_bytes_per_second::to_kibibits_per_second, 126 | ), 127 | ( 128 | KILOBITS_PER_SECOND, 129 | giga_bytes_per_second::to_kilo_bits_per_second, 130 | ), 131 | ( 132 | KILOBYTES_PER_SECOND, 133 | giga_bytes_per_second::to_kilo_bytes_per_second, 134 | ), 135 | ( 136 | MEBIBITS_PER_SECOND, 137 | giga_bytes_per_second::to_mebibits_per_second, 138 | ), 139 | ( 140 | MEGABITS_PER_SECOND, 141 | giga_bytes_per_second::to_mega_bits_per_second, 142 | ), 143 | ( 144 | MEGABYTES_PER_SECOND, 145 | giga_bytes_per_second::to_mega_bytes_per_second, 146 | ), 147 | ( 148 | TERABITS_PER_SECOND, 149 | giga_bytes_per_second::to_tera_bits_per_second, 150 | ), 151 | ( 152 | TERABYTES_PER_SECOND, 153 | giga_bytes_per_second::to_tera_bytes_per_second, 154 | ), 155 | ]), 156 | ), 157 | ( 158 | KIBIBITS_PER_SECOND, 159 | HashMap::from_iter([ 160 | ( 161 | BITS_PER_SECOND, 162 | kibibits_per_second::to_bits_per_second as ConversionFunction, 163 | ), 164 | ( 165 | GIGABITS_PER_SECOND, 166 | kibibits_per_second::to_giga_bits_per_second, 167 | ), 168 | ( 169 | GIGABYTES_PER_SECOND, 170 | kibibits_per_second::to_giga_bytes_per_second, 171 | ), 172 | (KIBIBITS_PER_SECOND, identity), 173 | ( 174 | KILOBITS_PER_SECOND, 175 | kibibits_per_second::to_kilo_bits_per_second, 176 | ), 177 | ( 178 | KILOBYTES_PER_SECOND, 179 | kibibits_per_second::to_kilo_bytes_per_second, 180 | ), 181 | ( 182 | MEBIBITS_PER_SECOND, 183 | kibibits_per_second::to_mebibits_per_second, 184 | ), 185 | ( 186 | MEGABITS_PER_SECOND, 187 | kibibits_per_second::to_mega_bits_per_second, 188 | ), 189 | ( 190 | MEGABYTES_PER_SECOND, 191 | kibibits_per_second::to_mega_bytes_per_second, 192 | ), 193 | ( 194 | TERABITS_PER_SECOND, 195 | kibibits_per_second::to_tera_bits_per_second, 196 | ), 197 | ( 198 | TERABYTES_PER_SECOND, 199 | kibibits_per_second::to_tera_bytes_per_second, 200 | ), 201 | ]), 202 | ), 203 | ( 204 | KILOBITS_PER_SECOND, 205 | HashMap::from_iter([ 206 | ( 207 | BITS_PER_SECOND, 208 | kilo_bits_per_second::to_bits_per_second as ConversionFunction, 209 | ), 210 | ( 211 | GIGABITS_PER_SECOND, 212 | kilo_bits_per_second::to_giga_bits_per_second, 213 | ), 214 | ( 215 | GIGABYTES_PER_SECOND, 216 | kilo_bits_per_second::to_giga_bytes_per_second, 217 | ), 218 | ( 219 | KIBIBITS_PER_SECOND, 220 | kilo_bits_per_second::to_kibibits_per_second, 221 | ), 222 | (KILOBITS_PER_SECOND, identity), 223 | ( 224 | KILOBYTES_PER_SECOND, 225 | kilo_bits_per_second::to_kilo_bytes_per_second, 226 | ), 227 | ( 228 | MEBIBITS_PER_SECOND, 229 | kilo_bits_per_second::to_mebibits_per_second, 230 | ), 231 | ( 232 | MEGABITS_PER_SECOND, 233 | kilo_bits_per_second::to_mega_bits_per_second, 234 | ), 235 | ( 236 | MEGABYTES_PER_SECOND, 237 | kilo_bits_per_second::to_mega_bytes_per_second, 238 | ), 239 | ( 240 | TERABITS_PER_SECOND, 241 | kilo_bits_per_second::to_tera_bits_per_second, 242 | ), 243 | ( 244 | TERABYTES_PER_SECOND, 245 | kilo_bits_per_second::to_tera_bytes_per_second, 246 | ), 247 | ]), 248 | ), 249 | ( 250 | KILOBYTES_PER_SECOND, 251 | HashMap::from_iter([ 252 | ( 253 | BITS_PER_SECOND, 254 | kilo_bytes_per_second::to_bits_per_second as ConversionFunction, 255 | ), 256 | ( 257 | GIGABITS_PER_SECOND, 258 | kilo_bytes_per_second::to_giga_bits_per_second, 259 | ), 260 | ( 261 | GIGABYTES_PER_SECOND, 262 | kilo_bytes_per_second::to_giga_bytes_per_second, 263 | ), 264 | ( 265 | KIBIBITS_PER_SECOND, 266 | kilo_bytes_per_second::to_kibibits_per_second, 267 | ), 268 | ( 269 | KILOBITS_PER_SECOND, 270 | kilo_bytes_per_second::to_kilo_bits_per_second, 271 | ), 272 | (KILOBYTES_PER_SECOND, identity), 273 | ( 274 | MEBIBITS_PER_SECOND, 275 | kilo_bytes_per_second::to_mebibits_per_second, 276 | ), 277 | ( 278 | MEGABITS_PER_SECOND, 279 | kilo_bytes_per_second::to_mega_bits_per_second, 280 | ), 281 | ( 282 | MEGABYTES_PER_SECOND, 283 | kilo_bytes_per_second::to_mega_bytes_per_second, 284 | ), 285 | ( 286 | TERABITS_PER_SECOND, 287 | kilo_bytes_per_second::to_tera_bits_per_second, 288 | ), 289 | ( 290 | TERABYTES_PER_SECOND, 291 | kilo_bytes_per_second::to_tera_bytes_per_second, 292 | ), 293 | ]), 294 | ), 295 | ( 296 | MEBIBITS_PER_SECOND, 297 | HashMap::from_iter([ 298 | ( 299 | BITS_PER_SECOND, 300 | mebibits_per_second::to_bits_per_second as ConversionFunction, 301 | ), 302 | ( 303 | GIGABITS_PER_SECOND, 304 | mebibits_per_second::to_giga_bits_per_second, 305 | ), 306 | ( 307 | GIGABYTES_PER_SECOND, 308 | mebibits_per_second::to_giga_bytes_per_second, 309 | ), 310 | ( 311 | KIBIBITS_PER_SECOND, 312 | mebibits_per_second::to_kibibits_per_second, 313 | ), 314 | ( 315 | KILOBITS_PER_SECOND, 316 | mebibits_per_second::to_kilo_bits_per_second, 317 | ), 318 | ( 319 | KILOBYTES_PER_SECOND, 320 | mebibits_per_second::to_kilo_bytes_per_second, 321 | ), 322 | (MEBIBITS_PER_SECOND, identity), 323 | ( 324 | MEGABITS_PER_SECOND, 325 | mebibits_per_second::to_mega_bits_per_second, 326 | ), 327 | ( 328 | MEGABYTES_PER_SECOND, 329 | mebibits_per_second::to_mega_bytes_per_second, 330 | ), 331 | ( 332 | TERABITS_PER_SECOND, 333 | mebibits_per_second::to_tera_bits_per_second, 334 | ), 335 | ( 336 | TERABYTES_PER_SECOND, 337 | mebibits_per_second::to_tera_bytes_per_second, 338 | ), 339 | ]), 340 | ), 341 | ( 342 | MEGABITS_PER_SECOND, 343 | HashMap::from_iter([ 344 | ( 345 | BITS_PER_SECOND, 346 | mega_bits_per_second::to_bits_per_second as ConversionFunction, 347 | ), 348 | ( 349 | GIGABITS_PER_SECOND, 350 | mega_bits_per_second::to_giga_bits_per_second, 351 | ), 352 | ( 353 | GIGABYTES_PER_SECOND, 354 | mega_bits_per_second::to_giga_bytes_per_second, 355 | ), 356 | ( 357 | KIBIBITS_PER_SECOND, 358 | mega_bits_per_second::to_kibibits_per_second, 359 | ), 360 | ( 361 | KILOBITS_PER_SECOND, 362 | mega_bits_per_second::to_kilo_bits_per_second, 363 | ), 364 | ( 365 | KILOBYTES_PER_SECOND, 366 | mega_bits_per_second::to_kilo_bytes_per_second, 367 | ), 368 | ( 369 | MEBIBITS_PER_SECOND, 370 | mega_bits_per_second::to_mebibits_per_second, 371 | ), 372 | (MEGABITS_PER_SECOND, identity), 373 | ( 374 | MEGABYTES_PER_SECOND, 375 | mega_bits_per_second::to_mega_bytes_per_second, 376 | ), 377 | ( 378 | TERABITS_PER_SECOND, 379 | mega_bits_per_second::to_tera_bits_per_second, 380 | ), 381 | ( 382 | TERABYTES_PER_SECOND, 383 | mega_bits_per_second::to_tera_bytes_per_second, 384 | ), 385 | ]), 386 | ), 387 | ( 388 | MEGABYTES_PER_SECOND, 389 | HashMap::from_iter([ 390 | ( 391 | BITS_PER_SECOND, 392 | mega_bytes_per_second::to_bits_per_second as ConversionFunction, 393 | ), 394 | ( 395 | GIGABITS_PER_SECOND, 396 | mega_bytes_per_second::to_giga_bits_per_second, 397 | ), 398 | (GIGABYTES_PER_SECOND, identity), 399 | ( 400 | KIBIBITS_PER_SECOND, 401 | mega_bytes_per_second::to_kibibits_per_second, 402 | ), 403 | ( 404 | KILOBITS_PER_SECOND, 405 | mega_bytes_per_second::to_kilo_bits_per_second, 406 | ), 407 | ( 408 | KILOBYTES_PER_SECOND, 409 | mega_bytes_per_second::to_kilo_bytes_per_second, 410 | ), 411 | ( 412 | MEBIBITS_PER_SECOND, 413 | mega_bytes_per_second::to_mebibits_per_second, 414 | ), 415 | ( 416 | MEGABITS_PER_SECOND, 417 | mega_bytes_per_second::to_mega_bits_per_second, 418 | ), 419 | (MEGABYTES_PER_SECOND, identity), 420 | ( 421 | TERABITS_PER_SECOND, 422 | mega_bytes_per_second::to_tera_bits_per_second, 423 | ), 424 | ( 425 | TERABYTES_PER_SECOND, 426 | mega_bytes_per_second::to_tera_bytes_per_second, 427 | ), 428 | ]), 429 | ), 430 | ( 431 | TERABITS_PER_SECOND, 432 | HashMap::from_iter([ 433 | ( 434 | BITS_PER_SECOND, 435 | tera_bits_per_second::to_bits_per_second as ConversionFunction, 436 | ), 437 | ( 438 | GIGABITS_PER_SECOND, 439 | tera_bits_per_second::to_giga_bits_per_second, 440 | ), 441 | ( 442 | GIGABYTES_PER_SECOND, 443 | tera_bits_per_second::to_giga_bytes_per_second, 444 | ), 445 | ( 446 | KIBIBITS_PER_SECOND, 447 | tera_bits_per_second::to_kibibits_per_second, 448 | ), 449 | ( 450 | KILOBITS_PER_SECOND, 451 | tera_bits_per_second::to_kilo_bits_per_second, 452 | ), 453 | ( 454 | KILOBYTES_PER_SECOND, 455 | tera_bits_per_second::to_kilo_bytes_per_second, 456 | ), 457 | ( 458 | MEBIBITS_PER_SECOND, 459 | tera_bits_per_second::to_mebibits_per_second, 460 | ), 461 | ( 462 | MEGABITS_PER_SECOND, 463 | tera_bits_per_second::to_mega_bits_per_second, 464 | ), 465 | ( 466 | MEGABYTES_PER_SECOND, 467 | tera_bits_per_second::to_mega_bytes_per_second, 468 | ), 469 | (TERABITS_PER_SECOND, identity), 470 | ( 471 | TERABYTES_PER_SECOND, 472 | tera_bits_per_second::to_tera_bytes_per_second, 473 | ), 474 | ]), 475 | ), 476 | ( 477 | TERABYTES_PER_SECOND, 478 | HashMap::from_iter([ 479 | ( 480 | BITS_PER_SECOND, 481 | tera_bytes_per_second::to_bits_per_second as ConversionFunction, 482 | ), 483 | ( 484 | GIGABITS_PER_SECOND, 485 | tera_bytes_per_second::to_giga_bits_per_second, 486 | ), 487 | ( 488 | GIGABYTES_PER_SECOND, 489 | tera_bytes_per_second::to_giga_bytes_per_second, 490 | ), 491 | ( 492 | KIBIBITS_PER_SECOND, 493 | tera_bytes_per_second::to_kibibits_per_second, 494 | ), 495 | ( 496 | KILOBITS_PER_SECOND, 497 | tera_bytes_per_second::to_kilo_bits_per_second, 498 | ), 499 | ( 500 | KILOBYTES_PER_SECOND, 501 | tera_bytes_per_second::to_kilo_bytes_per_second, 502 | ), 503 | ( 504 | MEBIBITS_PER_SECOND, 505 | tera_bytes_per_second::to_mebibits_per_second, 506 | ), 507 | ( 508 | MEGABITS_PER_SECOND, 509 | tera_bytes_per_second::to_mega_bits_per_second, 510 | ), 511 | ( 512 | MEGABYTES_PER_SECOND, 513 | tera_bytes_per_second::to_mega_bytes_per_second, 514 | ), 515 | ( 516 | TERABITS_PER_SECOND, 517 | tera_bytes_per_second::to_tera_bits_per_second, 518 | ), 519 | (TERABYTES_PER_SECOND, identity), 520 | ]), 521 | ), 522 | ]) 523 | } 524 | } 525 | -------------------------------------------------------------------------------- /src/values/energy.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::energy::*; 4 | 5 | const BTU: &str = "btu"; 6 | const CALORIES: &str = "calories"; 7 | const ELECTRONVOLTS: &str = "electronvolts"; 8 | const FOOT_POUNDS: &str = "foot-pounds"; 9 | const JOULES: &str = "joules"; 10 | const KILOCALORIES: &str = "kilocalories"; 11 | const KILOJOULES: &str = "kilojoules"; 12 | const KILOWATT_HOURS: &str = "kilowatt-hours"; 13 | const US_THERMS: &str = "us-therms"; 14 | const WATT_HOURS: &str = "watt-hours"; 15 | 16 | pub struct Energy; 17 | 18 | impl Category for Energy { 19 | fn name() -> &'static str { 20 | "energy" 21 | } 22 | fn conversion_function_map() -> ConversionFunctionMap { 23 | HashMap::from_iter([ 24 | ( 25 | BTU, 26 | HashMap::from_iter([ 27 | (BTU, identity as ConversionFunction), 28 | (CALORIES, btu::to_calories), 29 | (ELECTRONVOLTS, btu::to_electronvolts), 30 | (FOOT_POUNDS, btu::to_foot_pounds), 31 | (JOULES, btu::to_joules), 32 | (KILOCALORIES, btu::to_kilocalories), 33 | (KILOJOULES, btu::to_kilojoules), 34 | (KILOWATT_HOURS, btu::to_kilowatt_hours), 35 | (US_THERMS, btu::to_u_s_therms), 36 | (WATT_HOURS, btu::to_watt_hours), 37 | ]), 38 | ), 39 | ( 40 | CALORIES, 41 | HashMap::from_iter([ 42 | (BTU, calories::to_btu as ConversionFunction), 43 | (CALORIES, identity), 44 | (ELECTRONVOLTS, calories::to_electronvolts), 45 | (FOOT_POUNDS, calories::to_foot_pounds), 46 | (JOULES, calories::to_joules), 47 | (KILOCALORIES, calories::to_kilocalories), 48 | (KILOJOULES, calories::to_kilojoules), 49 | (KILOWATT_HOURS, calories::to_kilowatt_hours), 50 | (US_THERMS, calories::to_u_s_therms), 51 | (WATT_HOURS, calories::to_watt_hours), 52 | ]), 53 | ), 54 | ( 55 | ELECTRONVOLTS, 56 | HashMap::from_iter([ 57 | (BTU, electronvolts::to_btu as ConversionFunction), 58 | (CALORIES, electronvolts::to_calories), 59 | (ELECTRONVOLTS, identity), 60 | (FOOT_POUNDS, electronvolts::to_foot_pounds), 61 | (JOULES, electronvolts::to_joules), 62 | (KILOCALORIES, electronvolts::to_kilocalories), 63 | (KILOJOULES, electronvolts::to_kilojoules), 64 | (KILOWATT_HOURS, electronvolts::to_kilowatt_hours), 65 | (US_THERMS, electronvolts::to_u_s_therms), 66 | (WATT_HOURS, electronvolts::to_watt_hours), 67 | ]), 68 | ), 69 | ( 70 | FOOT_POUNDS, 71 | HashMap::from_iter([ 72 | (BTU, foot_pounds::to_btu as ConversionFunction), 73 | (CALORIES, foot_pounds::to_calories), 74 | (ELECTRONVOLTS, foot_pounds::to_electronvolts), 75 | (FOOT_POUNDS, identity), 76 | (JOULES, foot_pounds::to_joules), 77 | (KILOCALORIES, foot_pounds::to_kilocalories), 78 | (KILOJOULES, foot_pounds::to_kilojoules), 79 | (KILOWATT_HOURS, foot_pounds::to_kilowatt_hours), 80 | (US_THERMS, foot_pounds::to_u_s_therms), 81 | (WATT_HOURS, foot_pounds::to_watt_hours), 82 | ]), 83 | ), 84 | ( 85 | JOULES, 86 | HashMap::from_iter([ 87 | (BTU, joules::to_btu as ConversionFunction), 88 | (CALORIES, joules::to_calories), 89 | (ELECTRONVOLTS, joules::to_electronvolts), 90 | (FOOT_POUNDS, joules::to_foot_pounds), 91 | (JOULES, identity), 92 | (KILOCALORIES, joules::to_kilocalories), 93 | (KILOJOULES, joules::to_kilojoules), 94 | (KILOWATT_HOURS, joules::to_kilowatt_hours), 95 | (US_THERMS, joules::to_u_s_therms), 96 | (WATT_HOURS, joules::to_watt_hours), 97 | ]), 98 | ), 99 | ( 100 | KILOCALORIES, 101 | HashMap::from_iter([ 102 | (BTU, kilocalories::to_btu as ConversionFunction), 103 | (CALORIES, kilocalories::to_calories), 104 | (ELECTRONVOLTS, kilocalories::to_electronvolts), 105 | (FOOT_POUNDS, kilocalories::to_foot_pounds), 106 | (JOULES, kilocalories::to_joules), 107 | (KILOCALORIES, identity), 108 | (KILOJOULES, kilocalories::to_kilojoules), 109 | (KILOWATT_HOURS, kilocalories::to_kilowatt_hours), 110 | (US_THERMS, kilocalories::to_u_s_therms), 111 | (WATT_HOURS, kilocalories::to_watt_hours), 112 | ]), 113 | ), 114 | ( 115 | "kilojoules", 116 | HashMap::from_iter([ 117 | (BTU, kilojoules::to_btu as ConversionFunction), 118 | (CALORIES, kilojoules::to_calories), 119 | (ELECTRONVOLTS, kilojoules::to_electronvolts), 120 | (FOOT_POUNDS, kilojoules::to_foot_pounds), 121 | (JOULES, kilojoules::to_joules), 122 | (KILOCALORIES, kilojoules::to_kilocalories), 123 | (KILOJOULES, identity), 124 | (KILOWATT_HOURS, kilojoules::to_kilowatt_hours), 125 | (US_THERMS, kilojoules::to_u_s_therms), 126 | (WATT_HOURS, kilojoules::to_watt_hours), 127 | ]), 128 | ), 129 | ( 130 | KILOWATT_HOURS, 131 | HashMap::from_iter([ 132 | (BTU, kilowatt_hours::to_btu as ConversionFunction), 133 | (CALORIES, kilowatt_hours::to_calories), 134 | (ELECTRONVOLTS, kilowatt_hours::to_electronvolts), 135 | (FOOT_POUNDS, kilowatt_hours::to_foot_pounds), 136 | (JOULES, kilowatt_hours::to_joules), 137 | (KILOCALORIES, kilowatt_hours::to_kilocalories), 138 | (KILOJOULES, kilowatt_hours::to_kilojoules), 139 | (KILOWATT_HOURS, identity), 140 | (US_THERMS, kilowatt_hours::to_u_s_therms), 141 | (WATT_HOURS, kilowatt_hours::to_watt_hours), 142 | ]), 143 | ), 144 | ( 145 | US_THERMS, 146 | HashMap::from_iter([ 147 | (BTU, u_s_therms::to_btu as ConversionFunction), 148 | (CALORIES, u_s_therms::to_calories), 149 | (ELECTRONVOLTS, u_s_therms::to_electronvolts), 150 | (FOOT_POUNDS, u_s_therms::to_foot_pounds), 151 | (JOULES, u_s_therms::to_joules), 152 | (KILOCALORIES, u_s_therms::to_kilocalories), 153 | (KILOJOULES, u_s_therms::to_kilojoules), 154 | (KILOWATT_HOURS, u_s_therms::to_kilowatt_hours), 155 | (US_THERMS, identity), 156 | (WATT_HOURS, u_s_therms::to_watt_hours), 157 | ]), 158 | ), 159 | ( 160 | WATT_HOURS, 161 | HashMap::from_iter([ 162 | (BTU, watt_hours::to_btu as ConversionFunction), 163 | (CALORIES, watt_hours::to_calories), 164 | (ELECTRONVOLTS, watt_hours::to_electronvolts), 165 | (FOOT_POUNDS, watt_hours::to_foot_pounds), 166 | (JOULES, watt_hours::to_joules), 167 | (KILOCALORIES, watt_hours::to_kilocalories), 168 | (KILOJOULES, watt_hours::to_kilojoules), 169 | (KILOWATT_HOURS, watt_hours::to_kilowatt_hours), 170 | (US_THERMS, watt_hours::to_u_s_therms), 171 | (WATT_HOURS, identity), 172 | ]), 173 | ), 174 | ]) 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/values/force.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::force::*; 4 | 5 | const DYNES: &str = "dynes"; 6 | const KILOGRAMFORCE: &str = "kilogramforce"; 7 | const NEWTONS: &str = "newtons"; 8 | const POUNDALS: &str = "poundals"; 9 | 10 | pub struct Force; 11 | 12 | impl Category for Force { 13 | fn name() -> &'static str { 14 | "force" 15 | } 16 | fn conversion_function_map() -> ConversionFunctionMap { 17 | HashMap::from_iter([ 18 | ( 19 | DYNES, 20 | HashMap::from_iter([ 21 | (DYNES, identity as ConversionFunction), 22 | (KILOGRAMFORCE, dynes::to_kilogramforce), 23 | (NEWTONS, dynes::to_newtons), 24 | (POUNDALS, dynes::to_poundals), 25 | ]), 26 | ), 27 | ( 28 | KILOGRAMFORCE, 29 | HashMap::from_iter([ 30 | (DYNES, kilogramforce::to_dynes as ConversionFunction), 31 | (KILOGRAMFORCE, identity), 32 | (NEWTONS, kilogramforce::to_newtons), 33 | (POUNDALS, kilogramforce::to_poundals), 34 | ]), 35 | ), 36 | ( 37 | NEWTONS, 38 | HashMap::from_iter([ 39 | (DYNES, newtons::to_dynes as ConversionFunction), 40 | (KILOGRAMFORCE, newtons::to_kilogramforce), 41 | (NEWTONS, identity), 42 | (POUNDALS, newtons::to_poundals), 43 | ]), 44 | ), 45 | ( 46 | POUNDALS, 47 | HashMap::from_iter([ 48 | (DYNES, poundals::to_dynes as ConversionFunction), 49 | (KILOGRAMFORCE, poundals::to_kilogramforce), 50 | (NEWTONS, poundals::to_newtons), 51 | (POUNDALS, identity), 52 | ]), 53 | ), 54 | ]) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/values/frequency.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::frequency::*; 4 | 5 | const GIGAHERTZ: &str = "gigahertz"; 6 | const HERTZ: &str = "hertz"; 7 | const KILOHERTZ: &str = "kilohertz"; 8 | const MEGAHERTZ: &str = "megahertz"; 9 | 10 | pub struct Frequency; 11 | 12 | impl Category for Frequency { 13 | fn name() -> &'static str { 14 | "frequency" 15 | } 16 | fn conversion_function_map() -> ConversionFunctionMap { 17 | HashMap::from_iter([ 18 | ( 19 | GIGAHERTZ, 20 | HashMap::from_iter([ 21 | (GIGAHERTZ, identity as ConversionFunction), 22 | (HERTZ, gigahertz::to_hertz), 23 | (KILOHERTZ, gigahertz::to_kilohertz), 24 | (MEGAHERTZ, gigahertz::to_megahertz), 25 | ]), 26 | ), 27 | ( 28 | HERTZ, 29 | HashMap::from_iter([ 30 | (GIGAHERTZ, hertz::to_gigahertz as ConversionFunction), 31 | (HERTZ, identity), 32 | (KILOHERTZ, hertz::to_kilohertz), 33 | (MEGAHERTZ, hertz::to_megahertz), 34 | ]), 35 | ), 36 | ( 37 | KILOHERTZ, 38 | HashMap::from_iter([ 39 | (GIGAHERTZ, kilohertz::to_gigahertz as ConversionFunction), 40 | (HERTZ, kilohertz::to_hertz), 41 | (KILOHERTZ, identity), 42 | (MEGAHERTZ, kilohertz::to_megahertz), 43 | ]), 44 | ), 45 | ( 46 | MEGAHERTZ, 47 | HashMap::from_iter([ 48 | (GIGAHERTZ, megahertz::to_gigahertz as ConversionFunction), 49 | (HERTZ, megahertz::to_hertz), 50 | (KILOHERTZ, megahertz::to_kilohertz), 51 | (MEGAHERTZ, identity), 52 | ]), 53 | ), 54 | ]) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/values/fuel_economy.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::fuel_economy::*; 4 | 5 | const KILOMETRES_PER_LITRE: &str = "kilometres-per-litre"; 6 | const LITRES_PER_100_KILOMETRES: &str = "litres-per-100-kilometres"; 7 | const MILES_PER_GALLON: &str = "miles-per-gallon"; 8 | const US_MILES_PER_GALLON: &str = "us-miles-per-gallon"; 9 | 10 | pub struct FuelEconomy; 11 | 12 | impl Category for FuelEconomy { 13 | fn name() -> &'static str { 14 | "fuel-economy" 15 | } 16 | fn conversion_function_map() -> ConversionFunctionMap { 17 | HashMap::from_iter([ 18 | ( 19 | KILOMETRES_PER_LITRE, 20 | HashMap::from_iter([ 21 | (KILOMETRES_PER_LITRE, identity as ConversionFunction), 22 | ( 23 | LITRES_PER_100_KILOMETRES, 24 | kilometre_per_litre::to_litres_per100_kilometres, 25 | ), 26 | (MILES_PER_GALLON, kilometre_per_litre::to_miles_per_gallon), 27 | ( 28 | US_MILES_PER_GALLON, 29 | kilometre_per_litre::to_u_s_miles_per_gallon, 30 | ), 31 | ]), 32 | ), 33 | ( 34 | LITRES_PER_100_KILOMETRES, 35 | HashMap::from_iter([ 36 | ( 37 | KILOMETRES_PER_LITRE, 38 | litres_per100_kilometres::to_kilometre_per_litre as ConversionFunction, 39 | ), 40 | (LITRES_PER_100_KILOMETRES, identity), 41 | ( 42 | MILES_PER_GALLON, 43 | litres_per100_kilometres::to_miles_per_gallon, 44 | ), 45 | ( 46 | US_MILES_PER_GALLON, 47 | litres_per100_kilometres::to_u_s_miles_per_gallon, 48 | ), 49 | ]), 50 | ), 51 | ( 52 | MILES_PER_GALLON, 53 | HashMap::from_iter([ 54 | ( 55 | KILOMETRES_PER_LITRE, 56 | miles_per_gallon::to_kilometre_per_litre as ConversionFunction, 57 | ), 58 | ( 59 | LITRES_PER_100_KILOMETRES, 60 | miles_per_gallon::to_litres_per100_kilometres, 61 | ), 62 | (MILES_PER_GALLON, identity), 63 | ( 64 | US_MILES_PER_GALLON, 65 | miles_per_gallon::to_u_s_miles_per_gallon, 66 | ), 67 | ]), 68 | ), 69 | ( 70 | US_MILES_PER_GALLON, 71 | HashMap::from_iter([ 72 | ( 73 | KILOMETRES_PER_LITRE, 74 | u_s_miles_per_gallon::to_kilometre_per_litre as ConversionFunction, 75 | ), 76 | ( 77 | LITRES_PER_100_KILOMETRES, 78 | u_s_miles_per_gallon::to_litres_per100_kilometres, 79 | ), 80 | (MILES_PER_GALLON, u_s_miles_per_gallon::to_miles_per_gallon), 81 | (US_MILES_PER_GALLON, identity), 82 | ]), 83 | ), 84 | ]) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/values/length.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::length::*; 4 | 5 | const CENTIMETRES: &str = "centimetres"; 6 | const FEET: &str = "feet"; 7 | const INCHES: &str = "inches"; 8 | const KILOMETRES: &str = "kilometres"; 9 | const METRES: &str = "metres"; 10 | const MILES: &str = "miles"; 11 | const MILLIMETRES: &str = "millimetres"; 12 | const NAUTICAL_MILES: &str = "nautical-miles"; 13 | const YARDS: &str = "yards"; 14 | 15 | pub struct Length; 16 | 17 | impl Category for Length { 18 | fn name() -> &'static str { 19 | "length" 20 | } 21 | fn conversion_function_map() -> ConversionFunctionMap { 22 | HashMap::from_iter([ 23 | ( 24 | CENTIMETRES, 25 | HashMap::from_iter([ 26 | (CENTIMETRES, identity as ConversionFunction), 27 | (FEET, centimetres::to_feet), 28 | (INCHES, centimetres::to_inches), 29 | (KILOMETRES, centimetres::to_kilometres), 30 | (METRES, centimetres::to_metres), 31 | (MILES, centimetres::to_miles), 32 | (MILLIMETRES, centimetres::to_millimetres), 33 | (NAUTICAL_MILES, centimetres::to_nautical_miles), 34 | (YARDS, centimetres::to_yards), 35 | ]), 36 | ), 37 | ( 38 | FEET, 39 | HashMap::from_iter([ 40 | (CENTIMETRES, feet::to_centimetres as ConversionFunction), 41 | (FEET, identity), 42 | (INCHES, feet::to_inches), 43 | (KILOMETRES, feet::to_kilometres), 44 | (METRES, feet::to_metres), 45 | (MILES, feet::to_miles), 46 | (MILLIMETRES, feet::to_millimetres), 47 | (NAUTICAL_MILES, feet::to_nautical_miles), 48 | (YARDS, feet::to_yards), 49 | ]), 50 | ), 51 | ( 52 | INCHES, 53 | HashMap::from_iter([ 54 | (CENTIMETRES, inches::to_centimetres as ConversionFunction), 55 | (FEET, inches::to_feet), 56 | (INCHES, identity), 57 | (KILOMETRES, inches::to_kilometres), 58 | (METRES, inches::to_metres), 59 | (MILES, inches::to_miles), 60 | (MILLIMETRES, inches::to_millimetres), 61 | (NAUTICAL_MILES, inches::to_nautical_miles), 62 | (YARDS, inches::to_yards), 63 | ]), 64 | ), 65 | ( 66 | KILOMETRES, 67 | HashMap::from_iter([ 68 | ( 69 | CENTIMETRES, 70 | kilometres::to_centimetres as ConversionFunction, 71 | ), 72 | (FEET, kilometres::to_feet), 73 | (INCHES, kilometres::to_inches), 74 | (KILOMETRES, identity), 75 | (METRES, kilometres::to_metres), 76 | (MILES, kilometres::to_miles), 77 | (MILLIMETRES, kilometres::to_millimetres), 78 | (NAUTICAL_MILES, kilometres::to_nautical_miles), 79 | (YARDS, kilometres::to_yards), 80 | ]), 81 | ), 82 | ( 83 | METRES, 84 | HashMap::from_iter([ 85 | (CENTIMETRES, metres::to_centimetres as ConversionFunction), 86 | (FEET, metres::to_feet), 87 | (INCHES, metres::to_inches), 88 | (KILOMETRES, metres::to_kilometres), 89 | (METRES, identity), 90 | (MILES, metres::to_miles), 91 | (MILLIMETRES, metres::to_millimetres), 92 | (NAUTICAL_MILES, metres::to_nautical_miles), 93 | (YARDS, metres::to_yards), 94 | ]), 95 | ), 96 | ( 97 | MILES, 98 | HashMap::from_iter([ 99 | (CENTIMETRES, miles::to_centimetres as ConversionFunction), 100 | (FEET, miles::to_feet), 101 | (INCHES, miles::to_inches), 102 | (KILOMETRES, miles::to_kilometres), 103 | (METRES, miles::to_metres), 104 | (MILES, identity), 105 | (MILLIMETRES, miles::to_millimetres), 106 | (NAUTICAL_MILES, miles::to_nautical_miles), 107 | (YARDS, miles::to_yards), 108 | ]), 109 | ), 110 | ( 111 | MILLIMETRES, 112 | HashMap::from_iter([ 113 | ( 114 | CENTIMETRES, 115 | millimetres::to_centimetres as ConversionFunction, 116 | ), 117 | (FEET, millimetres::to_feet), 118 | (INCHES, millimetres::to_inches), 119 | (KILOMETRES, millimetres::to_kilometres), 120 | (METRES, millimetres::to_metres), 121 | (MILES, millimetres::to_miles), 122 | (MILLIMETRES, identity), 123 | (NAUTICAL_MILES, millimetres::to_nautical_miles), 124 | (YARDS, millimetres::to_yards), 125 | ]), 126 | ), 127 | ( 128 | NAUTICAL_MILES, 129 | HashMap::from_iter([ 130 | ( 131 | CENTIMETRES, 132 | nautical_miles::to_centimetres as ConversionFunction, 133 | ), 134 | (FEET, nautical_miles::to_feet), 135 | (INCHES, nautical_miles::to_inches), 136 | (KILOMETRES, nautical_miles::to_kilometres), 137 | (METRES, nautical_miles::to_metres), 138 | (MILES, nautical_miles::to_miles), 139 | (MILLIMETRES, nautical_miles::to_millimetres), 140 | (NAUTICAL_MILES, identity), 141 | (YARDS, nautical_miles::to_yards), 142 | ]), 143 | ), 144 | ( 145 | YARDS, 146 | HashMap::from_iter([ 147 | (CENTIMETRES, yards::to_centimetres as ConversionFunction), 148 | (FEET, yards::to_feet), 149 | (INCHES, yards::to_inches), 150 | (KILOMETRES, yards::to_kilometres), 151 | (METRES, yards::to_metres), 152 | (MILES, yards::to_miles), 153 | (MILLIMETRES, yards::to_millimetres), 154 | (NAUTICAL_MILES, yards::to_nautical_miles), 155 | (YARDS, identity), 156 | ]), 157 | ), 158 | ]) 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/values/luminous_energy.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::luminous_energy::*; 4 | 5 | const LUMEN_HOURS: &str = "lumen-hours"; 6 | const LUMEN_MINUTES: &str = "lumen-minutes"; 7 | const LUMEN_SECONDS: &str = "lumen-seconds"; 8 | const TALBOTS: &str = "talbots"; 9 | 10 | pub struct LuminousEnergy; 11 | 12 | impl Category for LuminousEnergy { 13 | fn name() -> &'static str { 14 | "luminous-energy" 15 | } 16 | fn conversion_function_map() -> ConversionFunctionMap { 17 | HashMap::from_iter([ 18 | ( 19 | LUMEN_HOURS, 20 | HashMap::from_iter([ 21 | (LUMEN_HOURS, identity as ConversionFunction), 22 | (LUMEN_MINUTES, lumen_hour::to_lumen_minute), 23 | (LUMEN_SECONDS, lumen_hour::to_lumen_second), 24 | (TALBOTS, lumen_hour::to_talbot), 25 | ]), 26 | ), 27 | ( 28 | LUMEN_MINUTES, 29 | HashMap::from_iter([ 30 | ( 31 | LUMEN_HOURS, 32 | lumen_minute::to_lumen_hour as ConversionFunction, 33 | ), 34 | (LUMEN_MINUTES, identity), 35 | (LUMEN_SECONDS, lumen_minute::to_lumen_second), 36 | (TALBOTS, lumen_minute::to_talbot), 37 | ]), 38 | ), 39 | ( 40 | LUMEN_SECONDS, 41 | HashMap::from_iter([ 42 | ( 43 | LUMEN_HOURS, 44 | lumen_second::to_lumen_hour as ConversionFunction, 45 | ), 46 | (LUMEN_MINUTES, lumen_second::to_lumen_minute), 47 | (LUMEN_SECONDS, identity), 48 | (TALBOTS, lumen_second::to_talbot), 49 | ]), 50 | ), 51 | ( 52 | TALBOTS, 53 | HashMap::from_iter([ 54 | (LUMEN_HOURS, talbot::to_lumen_hour as ConversionFunction), 55 | (LUMEN_MINUTES, talbot::to_lumen_minute), 56 | (LUMEN_SECONDS, talbot::to_lumen_second), 57 | (TALBOTS, identity), 58 | ]), 59 | ), 60 | ]) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/values/magnetomotive_force.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::magnetomotive_force::*; 4 | 5 | const AMPERETURNS: &str = "ampereturns"; 6 | const GILBERTS: &str = "gilberts"; 7 | 8 | pub struct MagnetomotiveForce; 9 | 10 | impl Category for MagnetomotiveForce { 11 | fn name() -> &'static str { 12 | "magnetomotive-force" 13 | } 14 | fn conversion_function_map() -> ConversionFunctionMap { 15 | HashMap::from_iter([ 16 | ( 17 | AMPERETURNS, 18 | HashMap::from_iter([ 19 | (AMPERETURNS, identity as ConversionFunction), 20 | (GILBERTS, ampereturns::to_gilberts), 21 | ]), 22 | ), 23 | ( 24 | GILBERTS, 25 | HashMap::from_iter([ 26 | (AMPERETURNS, gilberts::to_ampereturns as ConversionFunction), 27 | (GILBERTS, identity), 28 | ]), 29 | ), 30 | ]) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/values/mass.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::mass::*; 4 | 5 | const CARATS: &str = "carats"; 6 | const GRAMS: &str = "grams"; 7 | const KILOGRAMS: &str = "kilograms"; 8 | const MILLIGRAMS: &str = "milligrams"; 9 | const OUNCES: &str = "ounces"; 10 | const POUNDS: &str = "pounds"; 11 | const STONES: &str = "stones"; 12 | const TONNES: &str = "tonnes"; 13 | 14 | pub struct Mass; 15 | 16 | impl Category for Mass { 17 | fn name() -> &'static str { 18 | "mass" 19 | } 20 | fn conversion_function_map() -> ConversionFunctionMap { 21 | HashMap::from_iter([ 22 | ( 23 | CARATS, 24 | HashMap::from_iter([ 25 | (CARATS, identity as ConversionFunction), 26 | (GRAMS, carats::to_grams), 27 | (KILOGRAMS, carats::to_kilograms), 28 | (MILLIGRAMS, carats::to_milligrams), 29 | (OUNCES, carats::to_ounces), 30 | (POUNDS, carats::to_pounds), 31 | (STONES, carats::to_stones), 32 | (TONNES, carats::to_tonnes), 33 | ]), 34 | ), 35 | ( 36 | GRAMS, 37 | HashMap::from_iter([ 38 | (CARATS, grams::to_carats as ConversionFunction), 39 | (GRAMS, identity), 40 | (KILOGRAMS, grams::to_kilograms), 41 | (MILLIGRAMS, grams::to_milligrams), 42 | (OUNCES, grams::to_ounces), 43 | (POUNDS, grams::to_pounds), 44 | (STONES, grams::to_stones), 45 | (TONNES, grams::to_tonnes), 46 | ]), 47 | ), 48 | ( 49 | KILOGRAMS, 50 | HashMap::from_iter([ 51 | (CARATS, kilograms::to_carats as ConversionFunction), 52 | (GRAMS, kilograms::to_grams), 53 | (KILOGRAMS, identity), 54 | (MILLIGRAMS, kilograms::to_milligrams), 55 | (OUNCES, kilograms::to_ounces), 56 | (POUNDS, kilograms::to_pounds), 57 | (STONES, kilograms::to_stones), 58 | (TONNES, kilograms::to_tonnes), 59 | ]), 60 | ), 61 | ( 62 | MILLIGRAMS, 63 | HashMap::from_iter([ 64 | (CARATS, milligrams::to_carats as ConversionFunction), 65 | (GRAMS, milligrams::to_grams), 66 | (KILOGRAMS, milligrams::to_kilograms), 67 | (MILLIGRAMS, identity), 68 | (OUNCES, milligrams::to_ounces), 69 | (POUNDS, milligrams::to_pounds), 70 | (STONES, milligrams::to_stones), 71 | (TONNES, milligrams::to_tonnes), 72 | ]), 73 | ), 74 | ( 75 | OUNCES, 76 | HashMap::from_iter([ 77 | (CARATS, ounces::to_carats as ConversionFunction), 78 | (GRAMS, ounces::to_grams), 79 | (KILOGRAMS, ounces::to_kilograms), 80 | (MILLIGRAMS, ounces::to_milligrams), 81 | (OUNCES, identity), 82 | (POUNDS, ounces::to_pounds), 83 | (STONES, ounces::to_stones), 84 | (TONNES, ounces::to_tonnes), 85 | ]), 86 | ), 87 | ( 88 | POUNDS, 89 | HashMap::from_iter([ 90 | (CARATS, pounds::to_carats as ConversionFunction), 91 | (GRAMS, pounds::to_grams), 92 | (KILOGRAMS, pounds::to_kilograms), 93 | (MILLIGRAMS, pounds::to_milligrams), 94 | (OUNCES, pounds::to_ounces), 95 | (POUNDS, identity), 96 | (STONES, pounds::to_stones), 97 | (TONNES, pounds::to_tonnes), 98 | ]), 99 | ), 100 | ( 101 | "stones", 102 | HashMap::from_iter([ 103 | (CARATS, stones::to_carats as ConversionFunction), 104 | (GRAMS, stones::to_grams), 105 | (KILOGRAMS, stones::to_kilograms), 106 | (MILLIGRAMS, stones::to_milligrams), 107 | (OUNCES, stones::to_ounces), 108 | (POUNDS, stones::to_pounds), 109 | (STONES, identity), 110 | (TONNES, stones::to_tonnes), 111 | ]), 112 | ), 113 | ( 114 | TONNES, 115 | HashMap::from_iter([ 116 | (CARATS, tonnes::to_carats as ConversionFunction), 117 | (GRAMS, tonnes::to_grams), 118 | (KILOGRAMS, tonnes::to_kilograms), 119 | (MILLIGRAMS, tonnes::to_milligrams), 120 | (OUNCES, tonnes::to_ounces), 121 | (POUNDS, tonnes::to_pounds), 122 | (STONES, tonnes::to_stones), 123 | (TONNES, identity), 124 | ]), 125 | ), 126 | ]) 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/values/mod.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | mod angle; 4 | mod area; 5 | mod data_storage; 6 | mod data_transfer_rate; 7 | mod energy; 8 | mod force; 9 | mod frequency; 10 | mod fuel_economy; 11 | mod length; 12 | mod luminous_energy; 13 | mod magnetomotive_force; 14 | mod mass; 15 | mod pressure; 16 | mod speed; 17 | mod temperature; 18 | mod time; 19 | mod volume; 20 | 21 | pub use angle::Angle; 22 | pub use area::Area; 23 | pub use data_storage::DataStorage; 24 | pub use data_transfer_rate::DataTransferRate; 25 | pub use energy::Energy; 26 | pub use force::Force; 27 | pub use frequency::Frequency; 28 | pub use fuel_economy::FuelEconomy; 29 | pub use length::Length; 30 | pub use luminous_energy::LuminousEnergy; 31 | pub use magnetomotive_force::MagnetomotiveForce; 32 | pub use mass::Mass; 33 | pub use pressure::Pressure; 34 | pub use speed::Speed; 35 | pub use temperature::Temperature; 36 | pub use time::Time; 37 | pub use volume::Volume; 38 | 39 | use anyhow::bail; 40 | 41 | // Rename or get rid of these all together - they might only be making things more confusing 42 | pub type ConversionFunction = fn(f64) -> f64; 43 | pub type ConversionFunctionMap = HashMap<&'static str, HashMap<&'static str, ConversionFunction>>; 44 | pub type ValuesFunctionReturn = anyhow::Result>; 45 | pub type ValuesFunction = fn(&str, f64) -> ValuesFunctionReturn; 46 | 47 | pub trait Category { 48 | fn name() -> &'static str; 49 | fn units() -> Vec<&'static str> { 50 | let mut units: Vec<_> = Self::conversion_function_map().into_keys().collect(); 51 | units.sort(); 52 | units 53 | } 54 | fn values(unit: &str, value: f64) -> ValuesFunctionReturn { 55 | let conversion_function_map = Self::conversion_function_map(); 56 | let Some(conversion_functions) = conversion_function_map.get(unit) else { 57 | bail!("{} is not a valid unit", unit) 58 | }; 59 | 60 | let values: Vec<(String, f64)> = conversion_functions 61 | .iter() 62 | .map(|(unit, conversion_function)| (unit.to_string(), conversion_function(value))) 63 | .collect(); 64 | 65 | Ok(values) 66 | } 67 | fn conversion_function_map() -> ConversionFunctionMap; 68 | } 69 | 70 | #[cfg(test)] 71 | mod tests { 72 | #[test] 73 | fn ensure_data_is_in_correct_format() { 74 | use super::*; 75 | 76 | let conversion_function_maps: [HashMap<&str, HashMap<&str, fn(f64) -> f64>>; 17] = [ 77 | angle::Angle::conversion_function_map(), 78 | area::Area::conversion_function_map(), 79 | data_storage::DataStorage::conversion_function_map(), 80 | data_transfer_rate::DataTransferRate::conversion_function_map(), 81 | energy::Energy::conversion_function_map(), 82 | force::Force::conversion_function_map(), 83 | frequency::Frequency::conversion_function_map(), 84 | fuel_economy::FuelEconomy::conversion_function_map(), 85 | length::Length::conversion_function_map(), 86 | luminous_energy::LuminousEnergy::conversion_function_map(), 87 | magnetomotive_force::MagnetomotiveForce::conversion_function_map(), 88 | mass::Mass::conversion_function_map(), 89 | pressure::Pressure::conversion_function_map(), 90 | speed::Speed::conversion_function_map(), 91 | temperature::Temperature::conversion_function_map(), 92 | time::Time::conversion_function_map(), 93 | volume::Volume::conversion_function_map(), 94 | ]; 95 | 96 | // TODO: Rename these for loop variables to be more readable and make sense 97 | for conversion_function_map in conversion_function_maps { 98 | for (from_unit, conversion_functions) in conversion_function_map { 99 | let illegal_characters = ['_', ' ']; 100 | let illegal_characters_text = illegal_characters 101 | .iter() 102 | .map(|character| format!("`{}`", character)) 103 | .collect::>() 104 | .join(", "); 105 | 106 | assert!( 107 | !from_unit.contains(illegal_characters), 108 | "Unit \"{}\" should not contain any of the following characters: {}. Use `-`", 109 | from_unit, 110 | illegal_characters_text 111 | ); 112 | 113 | for (to_unit, _) in conversion_functions { 114 | assert!( 115 | !to_unit.contains(illegal_characters), 116 | "Unit \"{}\" should not contain any of the following characters: {}. Use `-`", 117 | to_unit, 118 | illegal_characters_text 119 | ); 120 | } 121 | } 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/values/pressure.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::pressure::*; 4 | 5 | const ATMOSPHERES: &str = "atmospheres"; 6 | const BARS: &str = "bars"; 7 | const PASCALS: &str = "pascals"; 8 | const PSI: &str = "psi"; 9 | const TORRS: &str = "torrs"; 10 | 11 | pub struct Pressure; 12 | 13 | impl Category for Pressure { 14 | fn name() -> &'static str { 15 | "pressure" 16 | } 17 | fn conversion_function_map() -> ConversionFunctionMap { 18 | HashMap::from_iter([ 19 | ( 20 | ATMOSPHERES, 21 | HashMap::from_iter([ 22 | (ATMOSPHERES, identity as ConversionFunction), 23 | (BARS, atmospheres::to_bars), 24 | (PASCALS, atmospheres::to_pascals), 25 | (PSI, atmospheres::to_psi), 26 | (TORRS, atmospheres::to_torrs), 27 | ]), 28 | ), 29 | ( 30 | BARS, 31 | HashMap::from_iter([ 32 | (ATMOSPHERES, bars::to_atmospheres as ConversionFunction), 33 | (BARS, identity), 34 | (PASCALS, bars::to_pascals), 35 | (PSI, bars::to_psi), 36 | (TORRS, bars::to_torrs), 37 | ]), 38 | ), 39 | ( 40 | PASCALS, 41 | HashMap::from_iter([ 42 | (ATMOSPHERES, pascals::to_atmospheres as ConversionFunction), 43 | (BARS, pascals::to_bars), 44 | (PASCALS, identity), 45 | (PSI, pascals::to_psi), 46 | (TORRS, pascals::to_torrs), 47 | ]), 48 | ), 49 | ( 50 | PSI, 51 | HashMap::from_iter([ 52 | (ATMOSPHERES, psi::to_atmospheres as ConversionFunction), 53 | (BARS, psi::to_bars), 54 | (PASCALS, psi::to_pascals), 55 | (PSI, identity), 56 | (TORRS, psi::to_torrs), 57 | ]), 58 | ), 59 | ( 60 | TORRS, 61 | HashMap::from_iter([ 62 | (ATMOSPHERES, torrs::to_atmospheres as ConversionFunction), 63 | (BARS, torrs::to_bars), 64 | (PASCALS, torrs::to_pascals), 65 | (PSI, torrs::to_psi), 66 | (TORRS, identity), 67 | ]), 68 | ), 69 | ]) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/values/speed.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::speed::*; 4 | 5 | const FEET_PER_SECOND: &str = "feet-per-second"; 6 | const KILOMETRES_PER_HOUR: &str = "kilometres-per-hour"; 7 | const KNOTS: &str = "knots"; 8 | const METRES_PER_SECOND: &str = "metres-per-second"; 9 | const MILES_PER_HOUR: &str = "miles-per-hour"; 10 | 11 | pub struct Speed; 12 | 13 | impl Category for Speed { 14 | fn name() -> &'static str { 15 | "speed" 16 | } 17 | fn conversion_function_map() -> ConversionFunctionMap { 18 | HashMap::from_iter([ 19 | ( 20 | FEET_PER_SECOND, 21 | HashMap::from_iter([ 22 | (FEET_PER_SECOND, identity as ConversionFunction), 23 | (KILOMETRES_PER_HOUR, feet_per_second::to_kilometres_per_hour), 24 | (KNOTS, feet_per_second::to_knots), 25 | (METRES_PER_SECOND, feet_per_second::to_metres_per_second), 26 | (MILES_PER_HOUR, feet_per_second::to_miles_per_hour), 27 | ]), 28 | ), 29 | ( 30 | KILOMETRES_PER_HOUR, 31 | HashMap::from_iter([ 32 | ( 33 | FEET_PER_SECOND, 34 | kilometres_per_hour::to_feet_per_second as ConversionFunction, 35 | ), 36 | (KILOMETRES_PER_HOUR, identity), 37 | (KNOTS, kilometres_per_hour::to_knots), 38 | (METRES_PER_SECOND, kilometres_per_hour::to_metres_per_second), 39 | (MILES_PER_HOUR, kilometres_per_hour::to_miles_per_hour), 40 | ]), 41 | ), 42 | ( 43 | KNOTS, 44 | HashMap::from_iter([ 45 | ( 46 | FEET_PER_SECOND, 47 | knots::to_feet_per_second as ConversionFunction, 48 | ), 49 | (KILOMETRES_PER_HOUR, knots::to_kilometres_per_hour), 50 | (KNOTS, identity), 51 | (METRES_PER_SECOND, knots::to_metres_per_second), 52 | (MILES_PER_HOUR, knots::to_miles_per_hour), 53 | ]), 54 | ), 55 | ( 56 | METRES_PER_SECOND, 57 | HashMap::from_iter([ 58 | ( 59 | FEET_PER_SECOND, 60 | metres_per_second::to_feet_per_second as ConversionFunction, 61 | ), 62 | ( 63 | KILOMETRES_PER_HOUR, 64 | metres_per_second::to_kilometres_per_hour, 65 | ), 66 | (KNOTS, metres_per_second::to_knots), 67 | (METRES_PER_SECOND, identity), 68 | (MILES_PER_HOUR, metres_per_second::to_miles_per_hour), 69 | ]), 70 | ), 71 | ( 72 | MILES_PER_HOUR, 73 | HashMap::from_iter([ 74 | ( 75 | FEET_PER_SECOND, 76 | miles_per_hour::to_feet_per_second as ConversionFunction, 77 | ), 78 | (KILOMETRES_PER_HOUR, miles_per_hour::to_kilometres_per_hour), 79 | (KNOTS, miles_per_hour::to_knots), 80 | (METRES_PER_SECOND, miles_per_hour::to_metres_per_second), 81 | (MILES_PER_HOUR, identity), 82 | ]), 83 | ), 84 | ]) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/values/temperature.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::temperature::*; 4 | 5 | const CELSIUS: &str = "celsius"; 6 | const FAHRENHEIT: &str = "fahrenheit"; 7 | const KELVIN: &str = "kelvin"; 8 | const RANKINE: &str = "rankine"; 9 | 10 | pub struct Temperature; 11 | 12 | impl Category for Temperature { 13 | fn name() -> &'static str { 14 | "temperature" 15 | } 16 | fn conversion_function_map() -> ConversionFunctionMap { 17 | HashMap::from_iter([ 18 | ( 19 | CELSIUS, 20 | HashMap::from_iter([ 21 | (CELSIUS, identity as ConversionFunction), 22 | (FAHRENHEIT, celsius::to_fahrenheit), 23 | (KELVIN, celsius::to_kelvin), 24 | (RANKINE, celsius::to_rankine), 25 | ]), 26 | ), 27 | ( 28 | FAHRENHEIT, 29 | HashMap::from_iter([ 30 | (CELSIUS, fahrenheit::to_celsius as ConversionFunction), 31 | (FAHRENHEIT, identity), 32 | (KELVIN, fahrenheit::to_kelvin), 33 | (RANKINE, fahrenheit::to_rankine), 34 | ]), 35 | ), 36 | ( 37 | KELVIN, 38 | HashMap::from_iter([ 39 | (CELSIUS, kelvin::to_celsius as ConversionFunction), 40 | (FAHRENHEIT, kelvin::to_fahrenheit), 41 | (KELVIN, identity), 42 | (RANKINE, kelvin::to_rankine), 43 | ]), 44 | ), 45 | ( 46 | RANKINE, 47 | HashMap::from_iter([ 48 | (CELSIUS, rankine::to_celsius as ConversionFunction), 49 | (FAHRENHEIT, rankine::to_fahrenheit), 50 | (KELVIN, rankine::to_kelvin), 51 | (RANKINE, identity), 52 | ]), 53 | ), 54 | ]) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/values/time.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::time::*; 4 | 5 | const CENTURIES: &str = "centuries"; 6 | const DAYS: &str = "days"; 7 | const DECADES: &str = "decades"; 8 | const HOURS: &str = "hours"; 9 | const MICROSECONDS: &str = "microseconds"; 10 | const MILLISECONDS: &str = "milliseconds"; 11 | const MINUTES: &str = "minutes"; 12 | const MONTHS: &str = "months"; 13 | const NANOSECONDS: &str = "nanoseconds"; 14 | const SECONDS: &str = "seconds"; 15 | const WEEKS: &str = "weeks"; 16 | const YEARS: &str = "years"; 17 | 18 | pub struct Time; 19 | 20 | impl Category for Time { 21 | fn name() -> &'static str { 22 | "time" 23 | } 24 | fn conversion_function_map() -> ConversionFunctionMap { 25 | HashMap::from_iter([ 26 | ( 27 | CENTURIES, 28 | HashMap::from_iter([ 29 | (CENTURIES, identity as ConversionFunction), 30 | (DAYS, centuries::to_days), 31 | (DECADES, centuries::to_decades), 32 | (HOURS, centuries::to_hours), 33 | (MICROSECONDS, centuries::to_microseconds), 34 | (MILLISECONDS, centuries::to_milliseconds), 35 | (MINUTES, centuries::to_minutes), 36 | (MONTHS, centuries::to_months), 37 | (NANOSECONDS, centuries::to_nanoseconds), 38 | (SECONDS, centuries::to_seconds), 39 | (WEEKS, centuries::to_weeks), 40 | (YEARS, centuries::to_years), 41 | ]), 42 | ), 43 | ( 44 | DAYS, 45 | HashMap::from_iter([ 46 | (CENTURIES, days::to_centuries as ConversionFunction), 47 | (DAYS, identity), 48 | (DECADES, days::to_decades), 49 | (HOURS, days::to_hours), 50 | (MICROSECONDS, days::to_microseconds), 51 | (MILLISECONDS, days::to_milliseconds), 52 | (MINUTES, days::to_minutes), 53 | (MONTHS, days::to_months), 54 | (NANOSECONDS, days::to_nanoseconds), 55 | (SECONDS, days::to_seconds), 56 | (WEEKS, days::to_weeks), 57 | (YEARS, days::to_years), 58 | ]), 59 | ), 60 | ( 61 | DECADES, 62 | HashMap::from_iter([ 63 | (CENTURIES, decades::to_centuries as ConversionFunction), 64 | (DAYS, decades::to_days), 65 | (DECADES, identity), 66 | (HOURS, decades::to_hours), 67 | (MICROSECONDS, decades::to_microseconds), 68 | (MILLISECONDS, decades::to_milliseconds), 69 | (MINUTES, decades::to_minutes), 70 | (MONTHS, decades::to_months), 71 | (NANOSECONDS, decades::to_nanoseconds), 72 | (SECONDS, decades::to_seconds), 73 | (WEEKS, decades::to_weeks), 74 | (YEARS, decades::to_years), 75 | ]), 76 | ), 77 | ( 78 | HOURS, 79 | HashMap::from_iter([ 80 | (CENTURIES, hours::to_centuries as ConversionFunction), 81 | (DAYS, hours::to_days), 82 | (DECADES, hours::to_decades), 83 | (HOURS, identity), 84 | (MICROSECONDS, hours::to_microseconds), 85 | (MILLISECONDS, hours::to_milliseconds), 86 | (MINUTES, hours::to_minutes), 87 | (MONTHS, hours::to_months), 88 | (NANOSECONDS, hours::to_nanoseconds), 89 | (SECONDS, hours::to_seconds), 90 | (WEEKS, hours::to_weeks), 91 | (YEARS, hours::to_years), 92 | ]), 93 | ), 94 | ( 95 | MICROSECONDS, 96 | HashMap::from_iter([ 97 | (CENTURIES, microseconds::to_centuries as ConversionFunction), 98 | (DAYS, microseconds::to_days), 99 | (DECADES, microseconds::to_decades), 100 | (HOURS, microseconds::to_hours), 101 | (MICROSECONDS, identity), 102 | (MILLISECONDS, microseconds::to_milliseconds), 103 | (MINUTES, microseconds::to_minutes), 104 | (MONTHS, microseconds::to_months), 105 | (NANOSECONDS, microseconds::to_nanoseconds), 106 | (SECONDS, microseconds::to_seconds), 107 | (WEEKS, microseconds::to_weeks), 108 | (YEARS, microseconds::to_years), 109 | ]), 110 | ), 111 | ( 112 | MILLISECONDS, 113 | HashMap::from_iter([ 114 | (CENTURIES, milliseconds::to_centuries as ConversionFunction), 115 | (DAYS, milliseconds::to_days), 116 | (DECADES, milliseconds::to_decades), 117 | (HOURS, milliseconds::to_hours), 118 | (MICROSECONDS, milliseconds::to_microseconds), 119 | (MILLISECONDS, identity), 120 | (MINUTES, milliseconds::to_minutes), 121 | (MONTHS, milliseconds::to_months), 122 | (NANOSECONDS, milliseconds::to_nanoseconds), 123 | (SECONDS, milliseconds::to_seconds), 124 | (WEEKS, milliseconds::to_weeks), 125 | (YEARS, milliseconds::to_years), 126 | ]), 127 | ), 128 | ( 129 | MINUTES, 130 | HashMap::from_iter([ 131 | (CENTURIES, minutes::to_centuries as ConversionFunction), 132 | (DAYS, minutes::to_days), 133 | (DECADES, minutes::to_decades), 134 | (HOURS, minutes::to_hours), 135 | (MICROSECONDS, minutes::to_microseconds), 136 | (MILLISECONDS, minutes::to_milliseconds), 137 | (MINUTES, identity), 138 | (MONTHS, minutes::to_months), 139 | (NANOSECONDS, minutes::to_nanoseconds), 140 | (SECONDS, minutes::to_seconds), 141 | (WEEKS, minutes::to_weeks), 142 | (YEARS, minutes::to_years), 143 | ]), 144 | ), 145 | ( 146 | MONTHS, 147 | HashMap::from_iter([ 148 | (CENTURIES, months::to_centuries as ConversionFunction), 149 | (DAYS, months::to_days), 150 | (DECADES, months::to_decades), 151 | (HOURS, months::to_hours), 152 | (MICROSECONDS, months::to_microseconds), 153 | (MILLISECONDS, months::to_milliseconds), 154 | (MINUTES, months::to_minutes), 155 | (MONTHS, identity), 156 | (NANOSECONDS, months::to_nanoseconds), 157 | (SECONDS, months::to_seconds), 158 | (WEEKS, months::to_weeks), 159 | (YEARS, months::to_years), 160 | ]), 161 | ), 162 | ( 163 | NANOSECONDS, 164 | HashMap::from_iter([ 165 | (CENTURIES, nanoseconds::to_centuries as ConversionFunction), 166 | (DAYS, nanoseconds::to_days), 167 | (DECADES, nanoseconds::to_decades), 168 | (HOURS, nanoseconds::to_hours), 169 | (MICROSECONDS, nanoseconds::to_microseconds), 170 | (MILLISECONDS, nanoseconds::to_milliseconds), 171 | (MINUTES, nanoseconds::to_minutes), 172 | (MONTHS, nanoseconds::to_months), 173 | (NANOSECONDS, identity), 174 | (SECONDS, nanoseconds::to_seconds), 175 | (WEEKS, nanoseconds::to_weeks), 176 | (YEARS, nanoseconds::to_years), 177 | ]), 178 | ), 179 | ( 180 | SECONDS, 181 | HashMap::from_iter([ 182 | (CENTURIES, seconds::to_centuries as ConversionFunction), 183 | (DAYS, seconds::to_days), 184 | (DECADES, seconds::to_decades), 185 | (HOURS, seconds::to_hours), 186 | (MICROSECONDS, seconds::to_microseconds), 187 | (MILLISECONDS, seconds::to_milliseconds), 188 | (MINUTES, seconds::to_minutes), 189 | (MONTHS, seconds::to_months), 190 | (NANOSECONDS, seconds::to_nanoseconds), 191 | (SECONDS, identity), 192 | (WEEKS, seconds::to_weeks), 193 | (YEARS, seconds::to_years), 194 | ]), 195 | ), 196 | ( 197 | WEEKS, 198 | HashMap::from_iter([ 199 | (CENTURIES, weeks::to_centuries as ConversionFunction), 200 | (DAYS, weeks::to_days), 201 | (DECADES, weeks::to_decades), 202 | (HOURS, weeks::to_hours), 203 | (MICROSECONDS, weeks::to_microseconds), 204 | (MILLISECONDS, weeks::to_milliseconds), 205 | (MINUTES, weeks::to_minutes), 206 | (MONTHS, weeks::to_months), 207 | (NANOSECONDS, weeks::to_nanoseconds), 208 | (SECONDS, weeks::to_seconds), 209 | (WEEKS, identity), 210 | (YEARS, weeks::to_years), 211 | ]), 212 | ), 213 | ( 214 | YEARS, 215 | HashMap::from_iter([ 216 | (CENTURIES, years::to_centuries as ConversionFunction), 217 | (DAYS, years::to_days), 218 | (DECADES, years::to_decades), 219 | (HOURS, years::to_hours), 220 | (MICROSECONDS, years::to_microseconds), 221 | (MILLISECONDS, years::to_milliseconds), 222 | (MINUTES, years::to_minutes), 223 | (MONTHS, years::to_months), 224 | (NANOSECONDS, years::to_nanoseconds), 225 | (SECONDS, years::to_seconds), 226 | (WEEKS, years::to_weeks), 227 | (YEARS, identity), 228 | ]), 229 | ), 230 | ]) 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /src/values/volume.rs: -------------------------------------------------------------------------------- 1 | use super::{Category, ConversionFunction, ConversionFunctionMap}; 2 | use std::{collections::HashMap, convert::identity}; 3 | use unit_conversions::volume::*; 4 | 5 | const CUBIC_FEET: &str = "cubic-feet"; 6 | const CUBIC_INCHES: &str = "cubic-inches"; 7 | const CUBIC_METRES: &str = "cubic-metres"; 8 | const FLUID_OUNCES: &str = "fluid-ounces"; 9 | const GALLONS: &str = "gallons"; 10 | const KILOLITRES: &str = "kilolitres"; 11 | const LITRES: &str = "litres"; 12 | const MILLILITRES: &str = "millilitres"; 13 | const OIL_BARRELS: &str = "oil-barrels"; 14 | const PINTS: &str = "pints"; 15 | const QUARTS: &str = "quarts"; 16 | const TABLESPOONS: &str = "tablespoons"; 17 | const TEASPOONS: &str = "teaspoons"; 18 | const US_CUPS: &str = "us-cups"; 19 | const US_FLUID_OUNCES: &str = "us-fluid-ounces"; 20 | const US_GALLONS: &str = "us-gallons"; 21 | const US_PINTS: &str = "us-pints"; 22 | const US_QUARTS: &str = "us-quarts"; 23 | const US_TABLESPOONS: &str = "us-tablespoons"; 24 | const US_TEASPOONS: &str = "us-teaspoons"; 25 | 26 | pub struct Volume; 27 | 28 | impl Category for Volume { 29 | fn name() -> &'static str { 30 | "volume" 31 | } 32 | fn conversion_function_map() -> ConversionFunctionMap { 33 | HashMap::from_iter([ 34 | ( 35 | CUBIC_FEET, 36 | HashMap::from_iter([ 37 | (CUBIC_FEET, identity as ConversionFunction), 38 | (CUBIC_INCHES, cubic_feet::to_cubic_inches), 39 | (CUBIC_METRES, cubic_feet::to_cubic_metres), 40 | (FLUID_OUNCES, cubic_feet::to_fluid_ounces), 41 | (GALLONS, cubic_feet::to_gallons), 42 | (KILOLITRES, cubic_feet::to_kilolitres), 43 | (LITRES, cubic_feet::to_litres), 44 | (MILLILITRES, cubic_feet::to_millilitres), 45 | (OIL_BARRELS, cubic_feet::to_oil_barrels), 46 | (PINTS, cubic_feet::to_pints), 47 | (QUARTS, cubic_feet::to_quarts), 48 | (TABLESPOONS, cubic_feet::to_tablespoons), 49 | (TEASPOONS, cubic_feet::to_teaspoons), 50 | (US_CUPS, cubic_feet::to_u_s_cups), 51 | (US_FLUID_OUNCES, cubic_feet::to_u_s_fluid_ounces), 52 | (US_GALLONS, cubic_feet::to_u_s_gallons), 53 | (US_PINTS, cubic_feet::to_u_s_pints), 54 | (US_QUARTS, cubic_feet::to_u_s_quarts), 55 | (US_TABLESPOONS, cubic_feet::to_u_s_tablespoons), 56 | (US_TEASPOONS, cubic_feet::to_u_s_teaspoons), 57 | ]), 58 | ), 59 | ( 60 | CUBIC_INCHES, 61 | HashMap::from_iter([ 62 | ( 63 | CUBIC_FEET, 64 | cubic_inches::to_cubic_feet as ConversionFunction, 65 | ), 66 | (CUBIC_INCHES, identity), 67 | (CUBIC_METRES, cubic_inches::to_cubic_metres), 68 | (FLUID_OUNCES, cubic_inches::to_fluid_ounces), 69 | (GALLONS, cubic_inches::to_gallons), 70 | (KILOLITRES, cubic_inches::to_kilolitres), 71 | (LITRES, cubic_inches::to_litres), 72 | (MILLILITRES, cubic_inches::to_millilitres), 73 | (OIL_BARRELS, cubic_inches::to_oil_barrels), 74 | (PINTS, cubic_inches::to_pints), 75 | (QUARTS, cubic_inches::to_quarts), 76 | (TABLESPOONS, cubic_inches::to_tablespoons), 77 | (TEASPOONS, cubic_inches::to_teaspoons), 78 | (US_CUPS, cubic_inches::to_u_s_cups), 79 | (US_FLUID_OUNCES, cubic_inches::to_u_s_fluid_ounces), 80 | (US_GALLONS, cubic_inches::to_u_s_gallons), 81 | (US_PINTS, cubic_inches::to_u_s_pints), 82 | (US_QUARTS, cubic_inches::to_u_s_quarts), 83 | (US_TABLESPOONS, cubic_inches::to_u_s_tablespoons), 84 | (US_TEASPOONS, cubic_inches::to_u_s_teaspoons), 85 | ]), 86 | ), 87 | ( 88 | CUBIC_METRES, 89 | HashMap::from_iter([ 90 | ( 91 | CUBIC_FEET, 92 | cubic_metres::to_cubic_feet as ConversionFunction, 93 | ), 94 | (CUBIC_INCHES, cubic_metres::to_cubic_inches), 95 | (CUBIC_METRES, identity), 96 | (FLUID_OUNCES, cubic_metres::to_fluid_ounces), 97 | (GALLONS, cubic_metres::to_gallons), 98 | (KILOLITRES, cubic_metres::to_kilolitres), 99 | (LITRES, cubic_metres::to_litres), 100 | (MILLILITRES, cubic_metres::to_millilitres), 101 | (OIL_BARRELS, cubic_metres::to_oil_barrels), 102 | (PINTS, cubic_metres::to_pints), 103 | (QUARTS, cubic_metres::to_quarts), 104 | (TABLESPOONS, cubic_metres::to_tablespoons), 105 | (TEASPOONS, cubic_metres::to_teaspoons), 106 | (US_CUPS, cubic_metres::to_u_s_cups), 107 | (US_FLUID_OUNCES, cubic_metres::to_u_s_fluid_ounces), 108 | (US_GALLONS, cubic_metres::to_u_s_gallons), 109 | (US_PINTS, cubic_metres::to_u_s_pints), 110 | (US_QUARTS, cubic_metres::to_u_s_quarts), 111 | (US_TABLESPOONS, cubic_metres::to_u_s_tablespoons), 112 | (US_TEASPOONS, cubic_metres::to_u_s_teaspoons), 113 | ]), 114 | ), 115 | ( 116 | FLUID_OUNCES, 117 | HashMap::from_iter([ 118 | ( 119 | CUBIC_FEET, 120 | fluid_ounces::to_cubic_feet as ConversionFunction, 121 | ), 122 | (CUBIC_INCHES, fluid_ounces::to_cubic_inches), 123 | (CUBIC_METRES, fluid_ounces::to_cubic_metres), 124 | (FLUID_OUNCES, identity), 125 | (GALLONS, fluid_ounces::to_gallons), 126 | (KILOLITRES, fluid_ounces::to_kilolitres), 127 | (LITRES, fluid_ounces::to_litres), 128 | (MILLILITRES, fluid_ounces::to_millilitres), 129 | (OIL_BARRELS, fluid_ounces::to_oil_barrels), 130 | (PINTS, fluid_ounces::to_pints), 131 | (QUARTS, fluid_ounces::to_quarts), 132 | (TABLESPOONS, fluid_ounces::to_tablespoons), 133 | (TEASPOONS, fluid_ounces::to_teaspoons), 134 | (US_CUPS, fluid_ounces::to_u_s_cups), 135 | (US_FLUID_OUNCES, fluid_ounces::to_u_s_fluid_ounces), 136 | (US_GALLONS, fluid_ounces::to_u_s_gallons), 137 | (US_PINTS, fluid_ounces::to_u_s_pints), 138 | (US_QUARTS, fluid_ounces::to_u_s_quarts), 139 | (US_TABLESPOONS, fluid_ounces::to_u_s_tablespoons), 140 | (US_TEASPOONS, fluid_ounces::to_u_s_teaspoons), 141 | ]), 142 | ), 143 | ( 144 | GALLONS, 145 | HashMap::from_iter([ 146 | (CUBIC_FEET, gallons::to_cubic_feet as ConversionFunction), 147 | (CUBIC_INCHES, gallons::to_cubic_inches), 148 | (CUBIC_METRES, gallons::to_cubic_metres), 149 | (FLUID_OUNCES, gallons::to_fluid_ounces), 150 | (GALLONS, identity), 151 | (KILOLITRES, gallons::to_kilolitres), 152 | (LITRES, gallons::to_litres), 153 | (MILLILITRES, gallons::to_millilitres), 154 | (OIL_BARRELS, gallons::to_oil_barrels), 155 | (PINTS, gallons::to_pints), 156 | (QUARTS, gallons::to_quarts), 157 | (TABLESPOONS, gallons::to_tablespoons), 158 | (TEASPOONS, gallons::to_teaspoons), 159 | (US_CUPS, gallons::to_u_s_cups), 160 | (US_FLUID_OUNCES, gallons::to_u_s_fluid_ounces), 161 | (US_GALLONS, gallons::to_u_s_gallons), 162 | (US_PINTS, gallons::to_u_s_pints), 163 | (US_QUARTS, gallons::to_u_s_quarts), 164 | (US_TABLESPOONS, gallons::to_u_s_tablespoons), 165 | (US_TEASPOONS, gallons::to_u_s_teaspoons), 166 | ]), 167 | ), 168 | ( 169 | KILOLITRES, 170 | HashMap::from_iter([ 171 | (CUBIC_FEET, kilolitres::to_cubic_feet as ConversionFunction), 172 | (CUBIC_INCHES, kilolitres::to_cubic_inches), 173 | (CUBIC_METRES, kilolitres::to_cubic_metres), 174 | (FLUID_OUNCES, kilolitres::to_fluid_ounces), 175 | (GALLONS, kilolitres::to_gallons), 176 | (KILOLITRES, identity), 177 | (LITRES, kilolitres::to_litres), 178 | (MILLILITRES, kilolitres::to_millilitres), 179 | (OIL_BARRELS, kilolitres::to_oil_barrels), 180 | (PINTS, kilolitres::to_pints), 181 | (QUARTS, kilolitres::to_quarts), 182 | (TABLESPOONS, kilolitres::to_tablespoons), 183 | (TEASPOONS, kilolitres::to_teaspoons), 184 | (US_CUPS, kilolitres::to_u_s_cups), 185 | (US_FLUID_OUNCES, kilolitres::to_u_s_fluid_ounces), 186 | (US_GALLONS, kilolitres::to_u_s_gallons), 187 | (US_PINTS, kilolitres::to_u_s_pints), 188 | (US_QUARTS, kilolitres::to_u_s_quarts), 189 | (US_TABLESPOONS, kilolitres::to_u_s_tablespoons), 190 | (US_TEASPOONS, kilolitres::to_u_s_teaspoons), 191 | ]), 192 | ), 193 | ( 194 | LITRES, 195 | HashMap::from_iter([ 196 | (CUBIC_FEET, litres::to_cubic_feet as ConversionFunction), 197 | (CUBIC_INCHES, litres::to_cubic_inches), 198 | (CUBIC_METRES, litres::to_cubic_metres), 199 | (FLUID_OUNCES, litres::to_fluid_ounces), 200 | (GALLONS, litres::to_gallons), 201 | (KILOLITRES, litres::to_kilolitres), 202 | (LITRES, identity), 203 | (MILLILITRES, litres::to_millilitres), 204 | (OIL_BARRELS, litres::to_oil_barrels), 205 | (PINTS, litres::to_pints), 206 | (QUARTS, litres::to_quarts), 207 | (TABLESPOONS, litres::to_tablespoons), 208 | (TEASPOONS, litres::to_teaspoons), 209 | (US_CUPS, litres::to_u_s_cups), 210 | (US_FLUID_OUNCES, litres::to_u_s_fluid_ounces), 211 | (US_GALLONS, litres::to_u_s_gallons), 212 | (US_PINTS, litres::to_u_s_pints), 213 | (US_QUARTS, litres::to_u_s_quarts), 214 | (US_TABLESPOONS, litres::to_u_s_tablespoons), 215 | (US_TEASPOONS, litres::to_u_s_teaspoons), 216 | ]), 217 | ), 218 | ( 219 | MILLILITRES, 220 | HashMap::from_iter([ 221 | (CUBIC_FEET, millilitres::to_cubic_feet as ConversionFunction), 222 | (CUBIC_INCHES, millilitres::to_cubic_inches), 223 | (CUBIC_METRES, millilitres::to_cubic_metres), 224 | (FLUID_OUNCES, millilitres::to_fluid_ounces), 225 | (GALLONS, millilitres::to_gallons), 226 | (KILOLITRES, millilitres::to_kilolitres), 227 | (LITRES, millilitres::to_litres), 228 | (MILLILITRES, identity), 229 | (OIL_BARRELS, millilitres::to_oil_barrels), 230 | (PINTS, millilitres::to_pints), 231 | (QUARTS, millilitres::to_quarts), 232 | (TABLESPOONS, millilitres::to_tablespoons), 233 | (TEASPOONS, millilitres::to_teaspoons), 234 | (US_CUPS, millilitres::to_u_s_cups), 235 | (US_FLUID_OUNCES, millilitres::to_u_s_fluid_ounces), 236 | (US_GALLONS, millilitres::to_u_s_gallons), 237 | (US_PINTS, millilitres::to_u_s_pints), 238 | (US_QUARTS, millilitres::to_u_s_quarts), 239 | (US_TABLESPOONS, millilitres::to_u_s_tablespoons), 240 | (US_TEASPOONS, millilitres::to_u_s_teaspoons), 241 | ]), 242 | ), 243 | ( 244 | OIL_BARRELS, 245 | HashMap::from_iter([ 246 | (CUBIC_FEET, oil_barrels::to_cubic_feet as ConversionFunction), 247 | (CUBIC_INCHES, oil_barrels::to_cubic_inches), 248 | (CUBIC_METRES, oil_barrels::to_cubic_metres), 249 | (FLUID_OUNCES, oil_barrels::to_fluid_ounces), 250 | (GALLONS, oil_barrels::to_gallons), 251 | (KILOLITRES, oil_barrels::to_kilolitres), 252 | (LITRES, oil_barrels::to_litres), 253 | (MILLILITRES, oil_barrels::to_millilitres), 254 | (OIL_BARRELS, identity), 255 | (PINTS, oil_barrels::to_pints), 256 | (QUARTS, oil_barrels::to_quarts), 257 | (TABLESPOONS, oil_barrels::to_tablespoons), 258 | (TEASPOONS, oil_barrels::to_teaspoons), 259 | (US_CUPS, oil_barrels::to_u_s_cups), 260 | (US_FLUID_OUNCES, oil_barrels::to_u_s_fluid_ounces), 261 | (US_GALLONS, oil_barrels::to_u_s_gallons), 262 | (US_PINTS, oil_barrels::to_u_s_pints), 263 | (US_QUARTS, oil_barrels::to_u_s_quarts), 264 | (US_TABLESPOONS, oil_barrels::to_u_s_tablespoons), 265 | (US_TEASPOONS, oil_barrels::to_u_s_teaspoons), 266 | ]), 267 | ), 268 | ( 269 | PINTS, 270 | HashMap::from_iter([ 271 | (CUBIC_FEET, pints::to_cubic_feet as ConversionFunction), 272 | (CUBIC_INCHES, pints::to_cubic_inches), 273 | (CUBIC_METRES, pints::to_cubic_metres), 274 | (FLUID_OUNCES, pints::to_fluid_ounces), 275 | (GALLONS, pints::to_gallons), 276 | (KILOLITRES, pints::to_kilolitres), 277 | (LITRES, pints::to_litres), 278 | (MILLILITRES, pints::to_millilitres), 279 | (OIL_BARRELS, pints::to_oil_barrels), 280 | (PINTS, identity), 281 | (QUARTS, pints::to_quarts), 282 | (TABLESPOONS, pints::to_tablespoons), 283 | (TEASPOONS, pints::to_teaspoons), 284 | (US_CUPS, pints::to_u_s_cups), 285 | (US_FLUID_OUNCES, pints::to_u_s_fluid_ounces), 286 | (US_GALLONS, pints::to_u_s_gallons), 287 | (US_PINTS, pints::to_u_s_pints), 288 | (US_QUARTS, pints::to_u_s_quarts), 289 | (US_TABLESPOONS, pints::to_u_s_tablespoons), 290 | (US_TEASPOONS, pints::to_u_s_teaspoons), 291 | ]), 292 | ), 293 | ( 294 | QUARTS, 295 | HashMap::from_iter([ 296 | (CUBIC_FEET, quarts::to_cubic_feet as ConversionFunction), 297 | (CUBIC_INCHES, quarts::to_cubic_inches), 298 | (CUBIC_METRES, quarts::to_cubic_metres), 299 | (FLUID_OUNCES, quarts::to_fluid_ounces), 300 | (GALLONS, quarts::to_gallons), 301 | (KILOLITRES, quarts::to_kilolitres), 302 | (LITRES, quarts::to_litres), 303 | (MILLILITRES, quarts::to_millilitres), 304 | (OIL_BARRELS, quarts::to_oil_barrels), 305 | (PINTS, quarts::to_pints), 306 | (QUARTS, identity), 307 | (TABLESPOONS, quarts::to_tablespoons), 308 | (TEASPOONS, quarts::to_teaspoons), 309 | (US_CUPS, quarts::to_u_s_cups), 310 | (US_FLUID_OUNCES, quarts::to_u_s_fluid_ounces), 311 | (US_GALLONS, quarts::to_u_s_gallons), 312 | (US_PINTS, quarts::to_u_s_pints), 313 | (US_QUARTS, quarts::to_u_s_quarts), 314 | (US_TABLESPOONS, quarts::to_u_s_tablespoons), 315 | (US_TEASPOONS, quarts::to_u_s_teaspoons), 316 | ]), 317 | ), 318 | ( 319 | TABLESPOONS, 320 | HashMap::from_iter([ 321 | (CUBIC_FEET, tablespoons::to_cubic_feet as ConversionFunction), 322 | (CUBIC_INCHES, tablespoons::to_cubic_inches), 323 | (CUBIC_METRES, tablespoons::to_cubic_metres), 324 | (FLUID_OUNCES, tablespoons::to_fluid_ounces), 325 | (GALLONS, tablespoons::to_gallons), 326 | (KILOLITRES, tablespoons::to_kilolitres), 327 | (LITRES, tablespoons::to_litres), 328 | (MILLILITRES, tablespoons::to_millilitres), 329 | (OIL_BARRELS, tablespoons::to_oil_barrels), 330 | (PINTS, tablespoons::to_pints), 331 | (QUARTS, tablespoons::to_quarts), 332 | (TABLESPOONS, identity), 333 | (TEASPOONS, tablespoons::to_teaspoons), 334 | (US_CUPS, tablespoons::to_u_s_cups), 335 | (US_FLUID_OUNCES, tablespoons::to_u_s_fluid_ounces), 336 | (US_GALLONS, tablespoons::to_u_s_gallons), 337 | (US_PINTS, tablespoons::to_u_s_pints), 338 | (US_QUARTS, tablespoons::to_u_s_quarts), 339 | (US_TABLESPOONS, tablespoons::to_u_s_tablespoons), 340 | (US_TEASPOONS, tablespoons::to_u_s_teaspoons), 341 | ]), 342 | ), 343 | ( 344 | TEASPOONS, 345 | HashMap::from_iter([ 346 | (CUBIC_FEET, teaspoons::to_cubic_feet as ConversionFunction), 347 | (CUBIC_INCHES, teaspoons::to_cubic_inches), 348 | (CUBIC_METRES, teaspoons::to_cubic_metres), 349 | (FLUID_OUNCES, teaspoons::to_fluid_ounces), 350 | (GALLONS, teaspoons::to_gallons), 351 | (KILOLITRES, teaspoons::to_kilolitres), 352 | (LITRES, teaspoons::to_litres), 353 | (MILLILITRES, teaspoons::to_millilitres), 354 | (OIL_BARRELS, teaspoons::to_oil_barrels), 355 | (PINTS, teaspoons::to_pints), 356 | (QUARTS, teaspoons::to_quarts), 357 | (TABLESPOONS, teaspoons::to_tablespoons), 358 | (TEASPOONS, identity), 359 | (US_CUPS, teaspoons::to_u_s_cups), 360 | (US_FLUID_OUNCES, teaspoons::to_u_s_fluid_ounces), 361 | (US_GALLONS, teaspoons::to_u_s_gallons), 362 | (US_PINTS, teaspoons::to_u_s_pints), 363 | (US_QUARTS, teaspoons::to_u_s_quarts), 364 | (US_TABLESPOONS, teaspoons::to_u_s_tablespoons), 365 | (US_TEASPOONS, teaspoons::to_u_s_teaspoons), 366 | ]), 367 | ), 368 | ( 369 | US_CUPS, 370 | HashMap::from_iter([ 371 | (CUBIC_FEET, u_s_cups::to_cubic_feet as ConversionFunction), 372 | (CUBIC_INCHES, u_s_cups::to_cubic_inches), 373 | (CUBIC_METRES, u_s_cups::to_cubic_metres), 374 | (FLUID_OUNCES, u_s_cups::to_fluid_ounces), 375 | (GALLONS, u_s_cups::to_gallons), 376 | (KILOLITRES, u_s_cups::to_kilolitres), 377 | (LITRES, u_s_cups::to_litres), 378 | (MILLILITRES, u_s_cups::to_millilitres), 379 | (OIL_BARRELS, u_s_cups::to_oil_barrels), 380 | (PINTS, u_s_cups::to_pints), 381 | (QUARTS, u_s_cups::to_quarts), 382 | (TABLESPOONS, u_s_cups::to_tablespoons), 383 | (TEASPOONS, u_s_cups::to_teaspoons), 384 | (US_CUPS, identity), 385 | (US_FLUID_OUNCES, u_s_cups::to_u_s_fluid_ounces), 386 | (US_GALLONS, u_s_cups::to_u_s_gallons), 387 | (US_PINTS, u_s_cups::to_u_s_pints), 388 | (US_QUARTS, u_s_cups::to_u_s_quarts), 389 | (US_TABLESPOONS, u_s_cups::to_u_s_tablespoons), 390 | (US_TEASPOONS, u_s_cups::to_u_s_teaspoons), 391 | ]), 392 | ), 393 | ( 394 | US_FLUID_OUNCES, 395 | HashMap::from_iter([ 396 | ( 397 | CUBIC_FEET, 398 | u_s_fluid_ounces::to_cubic_feet as ConversionFunction, 399 | ), 400 | (CUBIC_INCHES, u_s_fluid_ounces::to_cubic_inches), 401 | (CUBIC_METRES, u_s_fluid_ounces::to_cubic_metres), 402 | (FLUID_OUNCES, u_s_fluid_ounces::to_fluid_ounces), 403 | (GALLONS, u_s_fluid_ounces::to_gallons), 404 | (KILOLITRES, u_s_fluid_ounces::to_kilolitres), 405 | (LITRES, u_s_fluid_ounces::to_litres), 406 | (MILLILITRES, u_s_fluid_ounces::to_millilitres), 407 | (OIL_BARRELS, u_s_fluid_ounces::to_oil_barrels), 408 | (PINTS, u_s_fluid_ounces::to_pints), 409 | (QUARTS, u_s_fluid_ounces::to_quarts), 410 | (TABLESPOONS, u_s_fluid_ounces::to_tablespoons), 411 | (TEASPOONS, u_s_fluid_ounces::to_teaspoons), 412 | (US_CUPS, u_s_fluid_ounces::to_u_s_cups), 413 | (US_FLUID_OUNCES, identity), 414 | (US_GALLONS, u_s_fluid_ounces::to_u_s_gallons), 415 | (US_PINTS, u_s_fluid_ounces::to_u_s_pints), 416 | (US_QUARTS, u_s_fluid_ounces::to_u_s_quarts), 417 | (US_TABLESPOONS, u_s_fluid_ounces::to_u_s_tablespoons), 418 | (US_TEASPOONS, u_s_fluid_ounces::to_u_s_teaspoons), 419 | ]), 420 | ), 421 | ( 422 | US_GALLONS, 423 | HashMap::from_iter([ 424 | (CUBIC_FEET, u_s_gallons::to_cubic_feet as ConversionFunction), 425 | (CUBIC_INCHES, u_s_gallons::to_cubic_inches), 426 | (CUBIC_METRES, u_s_gallons::to_cubic_metres), 427 | (FLUID_OUNCES, u_s_gallons::to_fluid_ounces), 428 | (GALLONS, u_s_gallons::to_gallons), 429 | (KILOLITRES, u_s_gallons::to_kilolitres), 430 | (LITRES, u_s_gallons::to_litres), 431 | (MILLILITRES, u_s_gallons::to_millilitres), 432 | (OIL_BARRELS, u_s_gallons::to_oil_barrels), 433 | (PINTS, u_s_gallons::to_pints), 434 | (QUARTS, u_s_gallons::to_quarts), 435 | (TABLESPOONS, u_s_gallons::to_tablespoons), 436 | (TEASPOONS, u_s_gallons::to_teaspoons), 437 | (US_CUPS, u_s_gallons::to_u_s_cups), 438 | (US_FLUID_OUNCES, u_s_gallons::to_u_s_fluid_ounces), 439 | (US_GALLONS, identity), 440 | (US_PINTS, u_s_gallons::to_u_s_pints), 441 | (US_QUARTS, u_s_gallons::to_u_s_quarts), 442 | (US_TABLESPOONS, u_s_gallons::to_u_s_tablespoons), 443 | (US_TEASPOONS, u_s_gallons::to_u_s_teaspoons), 444 | ]), 445 | ), 446 | ( 447 | US_PINTS, 448 | HashMap::from_iter([ 449 | (CUBIC_FEET, u_s_pints::to_cubic_feet as ConversionFunction), 450 | (CUBIC_INCHES, u_s_pints::to_cubic_inches), 451 | (CUBIC_METRES, u_s_pints::to_cubic_metres), 452 | (FLUID_OUNCES, u_s_pints::to_fluid_ounces), 453 | (GALLONS, u_s_pints::to_gallons), 454 | (KILOLITRES, u_s_pints::to_kilolitres), 455 | (LITRES, u_s_pints::to_litres), 456 | (MILLILITRES, u_s_pints::to_millilitres), 457 | (OIL_BARRELS, u_s_pints::to_oil_barrels), 458 | (PINTS, u_s_pints::to_pints), 459 | (QUARTS, u_s_pints::to_quarts), 460 | (TABLESPOONS, u_s_pints::to_tablespoons), 461 | (TEASPOONS, u_s_pints::to_teaspoons), 462 | (US_CUPS, u_s_pints::to_u_s_cups), 463 | (US_FLUID_OUNCES, u_s_pints::to_u_s_fluid_ounces), 464 | (US_GALLONS, u_s_pints::to_u_s_gallons), 465 | (US_PINTS, identity), 466 | (US_QUARTS, u_s_pints::to_u_s_quarts), 467 | (US_TABLESPOONS, u_s_pints::to_u_s_tablespoons), 468 | (US_TEASPOONS, u_s_pints::to_u_s_teaspoons), 469 | ]), 470 | ), 471 | ( 472 | US_QUARTS, 473 | HashMap::from_iter([ 474 | (CUBIC_FEET, u_s_quarts::to_cubic_feet as ConversionFunction), 475 | (CUBIC_INCHES, u_s_quarts::to_cubic_inches), 476 | (CUBIC_METRES, u_s_quarts::to_cubic_metres), 477 | (FLUID_OUNCES, u_s_quarts::to_fluid_ounces), 478 | (GALLONS, u_s_quarts::to_gallons), 479 | (KILOLITRES, u_s_quarts::to_kilolitres), 480 | (LITRES, u_s_quarts::to_litres), 481 | (MILLILITRES, u_s_quarts::to_millilitres), 482 | (OIL_BARRELS, u_s_quarts::to_oil_barrels), 483 | (PINTS, u_s_quarts::to_pints), 484 | (QUARTS, u_s_quarts::to_quarts), 485 | (TABLESPOONS, u_s_quarts::to_tablespoons), 486 | (TEASPOONS, u_s_quarts::to_teaspoons), 487 | (US_CUPS, u_s_quarts::to_u_s_cups), 488 | (US_FLUID_OUNCES, u_s_quarts::to_u_s_fluid_ounces), 489 | (US_GALLONS, u_s_quarts::to_u_s_gallons), 490 | (US_PINTS, u_s_quarts::to_u_s_pints), 491 | (US_QUARTS, identity), 492 | (US_TABLESPOONS, u_s_quarts::to_u_s_tablespoons), 493 | (US_TEASPOONS, u_s_quarts::to_u_s_teaspoons), 494 | ]), 495 | ), 496 | ( 497 | US_TABLESPOONS, 498 | HashMap::from_iter([ 499 | ( 500 | CUBIC_FEET, 501 | u_s_tablespoons::to_cubic_feet as ConversionFunction, 502 | ), 503 | (CUBIC_INCHES, u_s_tablespoons::to_cubic_inches), 504 | (CUBIC_METRES, u_s_tablespoons::to_cubic_metres), 505 | (FLUID_OUNCES, u_s_tablespoons::to_fluid_ounces), 506 | (GALLONS, u_s_tablespoons::to_gallons), 507 | (KILOLITRES, u_s_tablespoons::to_kilolitres), 508 | (LITRES, u_s_tablespoons::to_litres), 509 | (MILLILITRES, u_s_tablespoons::to_millilitres), 510 | (OIL_BARRELS, u_s_tablespoons::to_oil_barrels), 511 | (PINTS, u_s_tablespoons::to_pints), 512 | (QUARTS, u_s_tablespoons::to_quarts), 513 | (TABLESPOONS, u_s_tablespoons::to_tablespoons), 514 | (TEASPOONS, u_s_tablespoons::to_teaspoons), 515 | (US_CUPS, u_s_tablespoons::to_u_s_cups), 516 | (US_FLUID_OUNCES, u_s_tablespoons::to_u_s_fluid_ounces), 517 | (US_GALLONS, u_s_tablespoons::to_u_s_gallons), 518 | (US_PINTS, u_s_tablespoons::to_u_s_pints), 519 | (US_QUARTS, u_s_tablespoons::to_u_s_quarts), 520 | (US_TABLESPOONS, identity), 521 | (US_TEASPOONS, u_s_tablespoons::to_u_s_teaspoons), 522 | ]), 523 | ), 524 | ( 525 | US_TEASPOONS, 526 | HashMap::from_iter([ 527 | ( 528 | CUBIC_FEET, 529 | u_s_teaspoons::to_cubic_feet as ConversionFunction, 530 | ), 531 | (CUBIC_INCHES, u_s_teaspoons::to_cubic_inches), 532 | (CUBIC_METRES, u_s_teaspoons::to_cubic_metres), 533 | (FLUID_OUNCES, u_s_teaspoons::to_fluid_ounces), 534 | (GALLONS, u_s_teaspoons::to_gallons), 535 | (KILOLITRES, u_s_teaspoons::to_kilolitres), 536 | (LITRES, u_s_teaspoons::to_litres), 537 | (MILLILITRES, u_s_teaspoons::to_millilitres), 538 | (OIL_BARRELS, u_s_teaspoons::to_oil_barrels), 539 | (PINTS, u_s_teaspoons::to_pints), 540 | (QUARTS, u_s_teaspoons::to_quarts), 541 | (TABLESPOONS, u_s_teaspoons::to_tablespoons), 542 | (TEASPOONS, u_s_teaspoons::to_teaspoons), 543 | (US_CUPS, u_s_teaspoons::to_u_s_cups), 544 | (US_FLUID_OUNCES, u_s_teaspoons::to_u_s_fluid_ounces), 545 | (US_GALLONS, u_s_teaspoons::to_u_s_gallons), 546 | (US_PINTS, u_s_teaspoons::to_u_s_pints), 547 | (US_QUARTS, u_s_teaspoons::to_u_s_quarts), 548 | (US_TABLESPOONS, u_s_teaspoons::to_u_s_tablespoons), 549 | (US_TEASPOONS, identity), 550 | ]), 551 | ), 552 | ]) 553 | } 554 | } 555 | --------------------------------------------------------------------------------