SQLite-backed Key / Value Store
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #8 from Tyrannican/safir-mem-split

Safir mem split

authored by

Graham Keenan and committed by
GitHub
da2512a3 2967275c

+2090 -610
+2
.gitignore
··· 1 1 /target 2 + safir/target 3 + safir-mem/target
+12
CHANGELOG.md safir/CHANGELOG.md
··· 2 2 3 3 Documenting changes between versions beginning from v0.3.0 4 4 5 + ## v0.6.0 6 + 7 + Removed the Safir Memcache and moved it to its own project. 8 + 9 + Addition of the Memcache functionality was making everything a bit messy to best to separate them both. 10 + They still operate the same, just different projects for each. 11 + 12 + Any changes here wil lbe made in the Memcache version also. 13 + 14 + * Removal of Memcache 15 + * Technically a reversion but meh 16 + 5 17 ## v0.5.0 6 18 7 19 Added the ability to operate Safir as a Memcache server (storing contents in-memory instead of on disk).
+220 -239
Cargo.lock
··· 3 3 version = 3 4 4 5 5 [[package]] 6 + name = "addr2line" 7 + version = "0.21.0" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" 10 + dependencies = [ 11 + "gimli", 12 + ] 13 + 14 + [[package]] 15 + name = "adler" 16 + version = "1.0.2" 17 + source = "registry+https://github.com/rust-lang/crates.io-index" 18 + checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 + 20 + [[package]] 6 21 name = "anstream" 7 - version = "0.3.2" 22 + version = "0.5.0" 8 23 source = "registry+https://github.com/rust-lang/crates.io-index" 9 - checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" 24 + checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" 10 25 dependencies = [ 11 26 "anstyle", 12 27 "anstyle-parse", 13 28 "anstyle-query", 14 29 "anstyle-wincon", 15 30 "colorchoice", 16 - "is-terminal", 17 31 "utf8parse", 18 32 ] 19 33 20 34 [[package]] 21 35 name = "anstyle" 22 - version = "1.0.0" 36 + version = "1.0.2" 23 37 source = "registry+https://github.com/rust-lang/crates.io-index" 24 - checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" 38 + checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" 25 39 26 40 [[package]] 27 41 name = "anstyle-parse" 28 - version = "0.2.0" 42 + version = "0.2.1" 29 43 source = "registry+https://github.com/rust-lang/crates.io-index" 30 - checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" 44 + checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" 31 45 dependencies = [ 32 46 "utf8parse", 33 47 ] ··· 38 52 source = "registry+https://github.com/rust-lang/crates.io-index" 39 53 checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 40 54 dependencies = [ 41 - "windows-sys 0.48.0", 55 + "windows-sys", 42 56 ] 43 57 44 58 [[package]] 45 59 name = "anstyle-wincon" 46 - version = "1.0.1" 60 + version = "2.1.0" 47 61 source = "registry+https://github.com/rust-lang/crates.io-index" 48 - checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" 62 + checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" 49 63 dependencies = [ 50 64 "anstyle", 51 - "windows-sys 0.48.0", 65 + "windows-sys", 52 66 ] 53 67 54 68 [[package]] 55 - name = "atty" 56 - version = "0.2.14" 69 + name = "autocfg" 70 + version = "1.1.0" 71 + source = "registry+https://github.com/rust-lang/crates.io-index" 72 + checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 73 + 74 + [[package]] 75 + name = "backtrace" 76 + version = "0.3.69" 57 77 source = "registry+https://github.com/rust-lang/crates.io-index" 58 - checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 78 + checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" 59 79 dependencies = [ 60 - "hermit-abi 0.1.19", 80 + "addr2line", 81 + "cc", 82 + "cfg-if", 61 83 "libc", 62 - "winapi", 84 + "miniz_oxide", 85 + "object", 86 + "rustc-demangle", 63 87 ] 64 88 65 89 [[package]] 66 - name = "autocfg" 67 - version = "1.1.0" 90 + name = "bitflags" 91 + version = "1.3.2" 68 92 source = "registry+https://github.com/rust-lang/crates.io-index" 69 - checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 93 + checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 70 94 71 95 [[package]] 72 96 name = "bitflags" 73 - version = "1.3.2" 97 + version = "2.4.0" 74 98 source = "registry+https://github.com/rust-lang/crates.io-index" 75 - checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 99 + checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" 76 100 77 101 [[package]] 78 102 name = "bytes" ··· 82 106 83 107 [[package]] 84 108 name = "cc" 85 - version = "1.0.79" 109 + version = "1.0.83" 86 110 source = "registry+https://github.com/rust-lang/crates.io-index" 87 - checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 111 + checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" 112 + dependencies = [ 113 + "libc", 114 + ] 88 115 89 116 [[package]] 90 117 name = "cfg-if" ··· 94 121 95 122 [[package]] 96 123 name = "clap" 97 - version = "4.3.1" 124 + version = "4.4.0" 98 125 source = "registry+https://github.com/rust-lang/crates.io-index" 99 - checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" 126 + checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" 100 127 dependencies = [ 101 128 "clap_builder", 102 129 "clap_derive", ··· 105 132 106 133 [[package]] 107 134 name = "clap_builder" 108 - version = "4.3.1" 135 + version = "4.4.0" 109 136 source = "registry+https://github.com/rust-lang/crates.io-index" 110 - checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" 137 + checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" 111 138 dependencies = [ 112 139 "anstream", 113 140 "anstyle", 114 - "bitflags", 115 141 "clap_lex", 116 142 "strsim", 117 143 ] 118 144 119 145 [[package]] 120 146 name = "clap_derive" 121 - version = "4.3.1" 147 + version = "4.4.0" 122 148 source = "registry+https://github.com/rust-lang/crates.io-index" 123 - checksum = "59e9ef9a08ee1c0e1f2e162121665ac45ac3783b0f897db7244ae75ad9a8f65b" 149 + checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" 124 150 dependencies = [ 125 151 "heck", 126 152 "proc-macro2", 127 153 "quote", 128 - "syn 2.0.18", 154 + "syn 2.0.29", 129 155 ] 130 156 131 157 [[package]] 132 158 name = "clap_lex" 133 - version = "0.5.0" 159 + version = "0.5.1" 134 160 source = "registry+https://github.com/rust-lang/crates.io-index" 135 - checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" 161 + checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" 136 162 137 163 [[package]] 138 164 name = "colorchoice" ··· 142 168 143 169 [[package]] 144 170 name = "colored" 145 - version = "2.0.0" 171 + version = "2.0.4" 146 172 source = "registry+https://github.com/rust-lang/crates.io-index" 147 - checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" 173 + checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" 148 174 dependencies = [ 149 - "atty", 175 + "is-terminal", 150 176 "lazy_static", 151 - "winapi", 177 + "windows-sys", 152 178 ] 153 179 154 180 [[package]] ··· 249 275 "libc", 250 276 "option-ext", 251 277 "redox_users", 252 - "windows-sys 0.48.0", 278 + "windows-sys", 253 279 ] 254 280 255 281 [[package]] 256 282 name = "either" 257 - version = "1.8.1" 283 + version = "1.9.0" 258 284 source = "registry+https://github.com/rust-lang/crates.io-index" 259 - checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" 285 + checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" 260 286 261 287 [[package]] 262 288 name = "errno" 263 - version = "0.3.1" 289 + version = "0.3.2" 264 290 source = "registry+https://github.com/rust-lang/crates.io-index" 265 - checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" 291 + checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" 266 292 dependencies = [ 267 293 "errno-dragonfly", 268 294 "libc", 269 - "windows-sys 0.48.0", 295 + "windows-sys", 270 296 ] 271 297 272 298 [[package]] ··· 281 307 282 308 [[package]] 283 309 name = "getrandom" 284 - version = "0.2.9" 310 + version = "0.2.10" 285 311 source = "registry+https://github.com/rust-lang/crates.io-index" 286 - checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" 312 + checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" 287 313 dependencies = [ 288 314 "cfg-if", 289 315 "libc", 290 316 "wasi", 291 317 ] 318 + 319 + [[package]] 320 + name = "gimli" 321 + version = "0.28.0" 322 + source = "registry+https://github.com/rust-lang/crates.io-index" 323 + checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" 292 324 293 325 [[package]] 294 326 name = "glob" ··· 304 336 305 337 [[package]] 306 338 name = "hermit-abi" 307 - version = "0.1.19" 308 - source = "registry+https://github.com/rust-lang/crates.io-index" 309 - checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 310 - dependencies = [ 311 - "libc", 312 - ] 313 - 314 - [[package]] 315 - name = "hermit-abi" 316 - version = "0.2.6" 317 - source = "registry+https://github.com/rust-lang/crates.io-index" 318 - checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 319 - dependencies = [ 320 - "libc", 321 - ] 322 - 323 - [[package]] 324 - name = "hermit-abi" 325 - version = "0.3.1" 326 - source = "registry+https://github.com/rust-lang/crates.io-index" 327 - checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 328 - 329 - [[package]] 330 - name = "io-lifetimes" 331 - version = "1.0.11" 339 + version = "0.3.2" 332 340 source = "registry+https://github.com/rust-lang/crates.io-index" 333 - checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" 334 - dependencies = [ 335 - "hermit-abi 0.3.1", 336 - "libc", 337 - "windows-sys 0.48.0", 338 - ] 341 + checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" 339 342 340 343 [[package]] 341 344 name = "is-terminal" 342 - version = "0.4.7" 345 + version = "0.4.9" 343 346 source = "registry+https://github.com/rust-lang/crates.io-index" 344 - checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" 347 + checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" 345 348 dependencies = [ 346 - "hermit-abi 0.3.1", 347 - "io-lifetimes", 349 + "hermit-abi", 348 350 "rustix", 349 - "windows-sys 0.48.0", 351 + "windows-sys", 350 352 ] 351 353 352 354 [[package]] 353 355 name = "itoa" 354 - version = "1.0.6" 356 + version = "1.0.9" 355 357 source = "registry+https://github.com/rust-lang/crates.io-index" 356 - checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 358 + checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" 357 359 358 360 [[package]] 359 361 name = "lazy_static" ··· 363 365 364 366 [[package]] 365 367 name = "libc" 366 - version = "0.2.144" 368 + version = "0.2.147" 367 369 source = "registry+https://github.com/rust-lang/crates.io-index" 368 - checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" 370 + checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" 369 371 370 372 [[package]] 371 373 name = "linux-raw-sys" 372 - version = "0.3.8" 374 + version = "0.4.5" 373 375 source = "registry+https://github.com/rust-lang/crates.io-index" 374 - checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" 376 + checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" 375 377 376 378 [[package]] 377 379 name = "lock_api" 378 - version = "0.4.9" 380 + version = "0.4.10" 379 381 source = "registry+https://github.com/rust-lang/crates.io-index" 380 - checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 382 + checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" 381 383 dependencies = [ 382 384 "autocfg", 383 385 "scopeguard", ··· 385 387 386 388 [[package]] 387 389 name = "log" 388 - version = "0.4.19" 390 + version = "0.4.20" 389 391 source = "registry+https://github.com/rust-lang/crates.io-index" 390 - checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" 392 + checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" 391 393 392 394 [[package]] 393 395 name = "mach" ··· 423 425 ] 424 426 425 427 [[package]] 428 + name = "miniz_oxide" 429 + version = "0.7.1" 430 + source = "registry+https://github.com/rust-lang/crates.io-index" 431 + checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" 432 + dependencies = [ 433 + "adler", 434 + ] 435 + 436 + [[package]] 426 437 name = "mio" 427 438 version = "0.8.8" 428 439 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 430 441 dependencies = [ 431 442 "libc", 432 443 "wasi", 433 - "windows-sys 0.48.0", 444 + "windows-sys", 434 445 ] 435 446 436 447 [[package]] ··· 439 450 source = "registry+https://github.com/rust-lang/crates.io-index" 440 451 checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" 441 452 dependencies = [ 442 - "bitflags", 453 + "bitflags 1.3.2", 443 454 "cc", 444 455 "cfg-if", 445 456 "libc", ··· 467 478 468 479 [[package]] 469 480 name = "num_cpus" 470 - version = "1.15.0" 481 + version = "1.16.0" 471 482 source = "registry+https://github.com/rust-lang/crates.io-index" 472 - checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 483 + checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 473 484 dependencies = [ 474 - "hermit-abi 0.2.6", 485 + "hermit-abi", 475 486 "libc", 476 487 ] 477 488 478 489 [[package]] 490 + name = "object" 491 + version = "0.32.0" 492 + source = "registry+https://github.com/rust-lang/crates.io-index" 493 + checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" 494 + dependencies = [ 495 + "memchr", 496 + ] 497 + 498 + [[package]] 479 499 name = "once_cell" 480 - version = "1.17.2" 500 + version = "1.18.0" 481 501 source = "registry+https://github.com/rust-lang/crates.io-index" 482 - checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" 502 + checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" 483 503 484 504 [[package]] 485 505 name = "option-ext" ··· 505 525 506 526 [[package]] 507 527 name = "parking_lot_core" 508 - version = "0.9.7" 528 + version = "0.9.8" 509 529 source = "registry+https://github.com/rust-lang/crates.io-index" 510 - checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" 530 + checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" 511 531 dependencies = [ 512 532 "cfg-if", 513 533 "libc", 514 - "redox_syscall", 534 + "redox_syscall 0.3.5", 515 535 "smallvec", 516 - "windows-sys 0.45.0", 536 + "windows-targets", 517 537 ] 518 538 519 539 [[package]] 520 540 name = "pin-project-lite" 521 - version = "0.2.9" 541 + version = "0.2.13" 522 542 source = "registry+https://github.com/rust-lang/crates.io-index" 523 - checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 543 + checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 524 544 525 545 [[package]] 526 546 name = "platforms" ··· 530 550 531 551 [[package]] 532 552 name = "proc-macro2" 533 - version = "1.0.59" 553 + version = "1.0.66" 534 554 source = "registry+https://github.com/rust-lang/crates.io-index" 535 - checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" 555 + checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" 536 556 dependencies = [ 537 557 "unicode-ident", 538 558 ] ··· 558 578 559 579 [[package]] 560 580 name = "quote" 561 - version = "1.0.28" 581 + version = "1.0.33" 562 582 source = "registry+https://github.com/rust-lang/crates.io-index" 563 - checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" 583 + checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 564 584 dependencies = [ 565 585 "proc-macro2", 566 586 ] ··· 593 613 source = "registry+https://github.com/rust-lang/crates.io-index" 594 614 checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 595 615 dependencies = [ 596 - "bitflags", 616 + "bitflags 1.3.2", 617 + ] 618 + 619 + [[package]] 620 + name = "redox_syscall" 621 + version = "0.3.5" 622 + source = "registry+https://github.com/rust-lang/crates.io-index" 623 + checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" 624 + dependencies = [ 625 + "bitflags 1.3.2", 597 626 ] 598 627 599 628 [[package]] ··· 603 632 checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 604 633 dependencies = [ 605 634 "getrandom", 606 - "redox_syscall", 635 + "redox_syscall 0.2.16", 607 636 "thiserror", 608 637 ] 609 638 ··· 621 650 ] 622 651 623 652 [[package]] 653 + name = "rustc-demangle" 654 + version = "0.1.23" 655 + source = "registry+https://github.com/rust-lang/crates.io-index" 656 + checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" 657 + 658 + [[package]] 624 659 name = "rustix" 625 - version = "0.37.19" 660 + version = "0.38.9" 626 661 source = "registry+https://github.com/rust-lang/crates.io-index" 627 - checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" 662 + checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" 628 663 dependencies = [ 629 - "bitflags", 664 + "bitflags 2.4.0", 630 665 "errno", 631 - "io-lifetimes", 632 666 "libc", 633 667 "linux-raw-sys", 634 - "windows-sys 0.48.0", 668 + "windows-sys", 635 669 ] 636 670 637 671 [[package]] 638 672 name = "ryu" 639 - version = "1.0.13" 673 + version = "1.0.15" 640 674 source = "registry+https://github.com/rust-lang/crates.io-index" 641 - checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" 675 + checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" 642 676 643 677 [[package]] 644 678 name = "safir" 645 - version = "0.5.0" 679 + version = "0.6.0" 680 + dependencies = [ 681 + "clap", 682 + "colored", 683 + "dirs", 684 + "rubin", 685 + "serde", 686 + "serde_json", 687 + "tokio", 688 + ] 689 + 690 + [[package]] 691 + name = "safir-mem" 692 + version = "0.1.0" 646 693 dependencies = [ 647 694 "clap", 648 695 "colored", ··· 658 705 659 706 [[package]] 660 707 name = "scopeguard" 661 - version = "1.1.0" 708 + version = "1.2.0" 662 709 source = "registry+https://github.com/rust-lang/crates.io-index" 663 - checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 710 + checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 664 711 665 712 [[package]] 666 713 name = "serde" 667 - version = "1.0.163" 714 + version = "1.0.188" 668 715 source = "registry+https://github.com/rust-lang/crates.io-index" 669 - checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" 716 + checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" 670 717 dependencies = [ 671 718 "serde_derive", 672 719 ] 673 720 674 721 [[package]] 675 722 name = "serde_derive" 676 - version = "1.0.163" 723 + version = "1.0.188" 677 724 source = "registry+https://github.com/rust-lang/crates.io-index" 678 - checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" 725 + checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" 679 726 dependencies = [ 680 727 "proc-macro2", 681 728 "quote", 682 - "syn 2.0.18", 729 + "syn 2.0.29", 683 730 ] 684 731 685 732 [[package]] 686 733 name = "serde_json" 687 - version = "1.0.96" 734 + version = "1.0.105" 688 735 source = "registry+https://github.com/rust-lang/crates.io-index" 689 - checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" 736 + checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" 690 737 dependencies = [ 691 738 "itoa", 692 739 "ryu", ··· 713 760 714 761 [[package]] 715 762 name = "smallvec" 716 - version = "1.10.0" 763 + version = "1.11.0" 717 764 source = "registry+https://github.com/rust-lang/crates.io-index" 718 - checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 765 + checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" 719 766 720 767 [[package]] 721 768 name = "socket2" 722 - version = "0.4.9" 769 + version = "0.5.3" 723 770 source = "registry+https://github.com/rust-lang/crates.io-index" 724 - checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" 771 + checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" 725 772 dependencies = [ 726 773 "libc", 727 - "winapi", 774 + "windows-sys", 728 775 ] 729 776 730 777 [[package]] ··· 746 793 747 794 [[package]] 748 795 name = "syn" 749 - version = "2.0.18" 796 + version = "2.0.29" 750 797 source = "registry+https://github.com/rust-lang/crates.io-index" 751 - checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" 798 + checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" 752 799 dependencies = [ 753 800 "proc-macro2", 754 801 "quote", ··· 757 804 758 805 [[package]] 759 806 name = "sysinfo" 760 - version = "0.29.3" 807 + version = "0.29.9" 761 808 source = "registry+https://github.com/rust-lang/crates.io-index" 762 - checksum = "5bcd0346f90b6bc83526c7b180039a8acd26a5c848cc556d457f6472eb148122" 809 + checksum = "a8d0e9cc2273cc8d31377bdd638d72e3ac3e5607b18621062b169d02787f1bab" 763 810 dependencies = [ 764 811 "cfg-if", 765 812 "core-foundation-sys", ··· 772 819 773 820 [[package]] 774 821 name = "thiserror" 775 - version = "1.0.40" 822 + version = "1.0.47" 776 823 source = "registry+https://github.com/rust-lang/crates.io-index" 777 - checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 824 + checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" 778 825 dependencies = [ 779 826 "thiserror-impl", 780 827 ] 781 828 782 829 [[package]] 783 830 name = "thiserror-impl" 784 - version = "1.0.40" 831 + version = "1.0.47" 785 832 source = "registry+https://github.com/rust-lang/crates.io-index" 786 - checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 833 + checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" 787 834 dependencies = [ 788 835 "proc-macro2", 789 836 "quote", 790 - "syn 2.0.18", 837 + "syn 2.0.29", 791 838 ] 792 839 793 840 [[package]] ··· 802 849 803 850 [[package]] 804 851 name = "tokio" 805 - version = "1.28.2" 852 + version = "1.32.0" 806 853 source = "registry+https://github.com/rust-lang/crates.io-index" 807 - checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" 854 + checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" 808 855 dependencies = [ 809 - "autocfg", 856 + "backtrace", 810 857 "bytes", 811 858 "libc", 812 859 "mio", ··· 816 863 "signal-hook-registry", 817 864 "socket2", 818 865 "tokio-macros", 819 - "windows-sys 0.48.0", 866 + "windows-sys", 820 867 ] 821 868 822 869 [[package]] ··· 827 874 dependencies = [ 828 875 "proc-macro2", 829 876 "quote", 830 - "syn 2.0.18", 877 + "syn 2.0.29", 831 878 ] 832 879 833 880 [[package]] ··· 850 897 dependencies = [ 851 898 "proc-macro2", 852 899 "quote", 853 - "syn 2.0.18", 900 + "syn 2.0.29", 854 901 ] 855 902 856 903 [[package]] ··· 896 943 897 944 [[package]] 898 945 name = "unicode-ident" 899 - version = "1.0.9" 946 + version = "1.0.11" 900 947 source = "registry+https://github.com/rust-lang/crates.io-index" 901 - checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" 948 + checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" 902 949 903 950 [[package]] 904 951 name = "utf8parse" ··· 953 1000 954 1001 [[package]] 955 1002 name = "windows-sys" 956 - version = "0.45.0" 957 - source = "registry+https://github.com/rust-lang/crates.io-index" 958 - checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 959 - dependencies = [ 960 - "windows-targets 0.42.2", 961 - ] 962 - 963 - [[package]] 964 - name = "windows-sys" 965 1003 version = "0.48.0" 966 1004 source = "registry+https://github.com/rust-lang/crates.io-index" 967 1005 checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 968 1006 dependencies = [ 969 - "windows-targets 0.48.0", 1007 + "windows-targets", 970 1008 ] 971 1009 972 1010 [[package]] 973 1011 name = "windows-targets" 974 - version = "0.42.2" 1012 + version = "0.48.5" 975 1013 source = "registry+https://github.com/rust-lang/crates.io-index" 976 - checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 1014 + checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 977 1015 dependencies = [ 978 - "windows_aarch64_gnullvm 0.42.2", 979 - "windows_aarch64_msvc 0.42.2", 980 - "windows_i686_gnu 0.42.2", 981 - "windows_i686_msvc 0.42.2", 982 - "windows_x86_64_gnu 0.42.2", 983 - "windows_x86_64_gnullvm 0.42.2", 984 - "windows_x86_64_msvc 0.42.2", 985 - ] 986 - 987 - [[package]] 988 - name = "windows-targets" 989 - version = "0.48.0" 990 - source = "registry+https://github.com/rust-lang/crates.io-index" 991 - checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" 992 - dependencies = [ 993 - "windows_aarch64_gnullvm 0.48.0", 994 - "windows_aarch64_msvc 0.48.0", 995 - "windows_i686_gnu 0.48.0", 996 - "windows_i686_msvc 0.48.0", 997 - "windows_x86_64_gnu 0.48.0", 998 - "windows_x86_64_gnullvm 0.48.0", 999 - "windows_x86_64_msvc 0.48.0", 1016 + "windows_aarch64_gnullvm", 1017 + "windows_aarch64_msvc", 1018 + "windows_i686_gnu", 1019 + "windows_i686_msvc", 1020 + "windows_x86_64_gnu", 1021 + "windows_x86_64_gnullvm", 1022 + "windows_x86_64_msvc", 1000 1023 ] 1001 1024 1002 1025 [[package]] 1003 1026 name = "windows_aarch64_gnullvm" 1004 - version = "0.42.2" 1005 - source = "registry+https://github.com/rust-lang/crates.io-index" 1006 - checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 1007 - 1008 - [[package]] 1009 - name = "windows_aarch64_gnullvm" 1010 - version = "0.48.0" 1011 - source = "registry+https://github.com/rust-lang/crates.io-index" 1012 - checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" 1013 - 1014 - [[package]] 1015 - name = "windows_aarch64_msvc" 1016 - version = "0.42.2" 1027 + version = "0.48.5" 1017 1028 source = "registry+https://github.com/rust-lang/crates.io-index" 1018 - checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 1029 + checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1019 1030 1020 1031 [[package]] 1021 1032 name = "windows_aarch64_msvc" 1022 - version = "0.48.0" 1033 + version = "0.48.5" 1023 1034 source = "registry+https://github.com/rust-lang/crates.io-index" 1024 - checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" 1035 + checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1025 1036 1026 1037 [[package]] 1027 1038 name = "windows_i686_gnu" 1028 - version = "0.42.2" 1039 + version = "0.48.5" 1029 1040 source = "registry+https://github.com/rust-lang/crates.io-index" 1030 - checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 1031 - 1032 - [[package]] 1033 - name = "windows_i686_gnu" 1034 - version = "0.48.0" 1035 - source = "registry+https://github.com/rust-lang/crates.io-index" 1036 - checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" 1041 + checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1037 1042 1038 1043 [[package]] 1039 1044 name = "windows_i686_msvc" 1040 - version = "0.42.2" 1041 - source = "registry+https://github.com/rust-lang/crates.io-index" 1042 - checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 1043 - 1044 - [[package]] 1045 - name = "windows_i686_msvc" 1046 - version = "0.48.0" 1045 + version = "0.48.5" 1047 1046 source = "registry+https://github.com/rust-lang/crates.io-index" 1048 - checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" 1047 + checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1049 1048 1050 1049 [[package]] 1051 1050 name = "windows_x86_64_gnu" 1052 - version = "0.42.2" 1051 + version = "0.48.5" 1053 1052 source = "registry+https://github.com/rust-lang/crates.io-index" 1054 - checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 1055 - 1056 - [[package]] 1057 - name = "windows_x86_64_gnu" 1058 - version = "0.48.0" 1059 - source = "registry+https://github.com/rust-lang/crates.io-index" 1060 - checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" 1061 - 1062 - [[package]] 1063 - name = "windows_x86_64_gnullvm" 1064 - version = "0.42.2" 1065 - source = "registry+https://github.com/rust-lang/crates.io-index" 1066 - checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 1053 + checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1067 1054 1068 1055 [[package]] 1069 1056 name = "windows_x86_64_gnullvm" 1070 - version = "0.48.0" 1071 - source = "registry+https://github.com/rust-lang/crates.io-index" 1072 - checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" 1073 - 1074 - [[package]] 1075 - name = "windows_x86_64_msvc" 1076 - version = "0.42.2" 1057 + version = "0.48.5" 1077 1058 source = "registry+https://github.com/rust-lang/crates.io-index" 1078 - checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1059 + checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1079 1060 1080 1061 [[package]] 1081 1062 name = "windows_x86_64_msvc" 1082 - version = "0.48.0" 1063 + version = "0.48.5" 1083 1064 source = "registry+https://github.com/rust-lang/crates.io-index" 1084 - checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" 1065 + checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+3 -29
Cargo.toml
··· 1 - [package] 2 - name = "safir" 3 - version = "0.5.0" 4 - edition = "2021" 5 - authors = ["Graham Keenan graham.keenan@outlook.com"] 6 - license = "MIT OR Apache-2.0" 7 - description = "Key/Value store to share values between different shell sessions" 8 - readme = "README.md" 9 - homepage = "https://github.com/Tyrannican/safir" 10 - repository = "https://github.com/Tyrannican/safir" 11 - keywords = ["cli", "terminal", "utility", "key-value", "store"] 12 - categories = ["command-line-utilities"] 13 - 14 - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 - 16 - [dependencies] 17 - clap = { version = "4.2.5" , features = ["derive"] } 18 - serde = { version = "1", features = ["derive"] } 19 - serde_json = "1" 20 - dirs = "5" 21 - colored = "2" 22 - rubin = "^0.3.1" 23 - tokio = { version = "1.28.2", features = ["full"] } 24 - psutil = { version = "3.2.2", optional = true } 25 - which = "4.4.0" 26 - sysinfo = "0.29.3" 27 - 28 - [target.'cfg(unix)'.dependencies] 29 - psutil = "3.2.2" 1 + [workspace] 2 + members = ["safir", "safir-mem"] 3 + resolver = "2"
LICENSE-APACHE safir/LICENSE-APACHE
LICENSE-MIT safir/LICENSE-MIT
+1 -86
README.md
··· 1 1 # Safir 2 2 3 - Simple CLI key/value store. 4 - 5 - Store key/value pairs in the terminal and retrieve them later for use like in different shell sessions. 6 - 7 - ## Install 8 - 9 - To install `safir`, run `cargo install safir`. 10 - 11 - To build from source, clone the repository and run: 12 - 13 - ```bash 14 - cargo build --release 15 - ``` 16 - 17 - Then move the binary to somewhere in your `$PATH` 18 - 19 - ## Usage 20 - 21 - When `safir` is run, it creates a store file in your `$HOME` directory (`$HOME/.safirstore/safirstore.json`). 22 - 23 - Run `safir --help` for usage: 24 - 25 - ```bash 26 - Key/Value store to share information between shell sessions 27 - 28 - Usage: safir <COMMAND> 29 - 30 - Commands: 31 - add Add a value to the store with the given key 32 - get Get a value from the store 33 - rm Remove values from the store 34 - alias Output the alias command for a key / value pair to be entered into a shell session 35 - export Output the export command for a key / value pair to be entered into a shell session 36 - clear Clear all keys/values from the store 37 - purge Purges the .safirstore directory, removing it and its contents 38 - mem Start or stop the Memcache (in-memory store) service 39 - help Print this message or the help of the given subcommand(s) 40 - 41 - Options: 42 - -h, --help Print help 43 - -V, --version Print version 44 - ``` 45 - 46 - ## Memcache service 47 - 48 - Safir offers the ability to run the store as a dedicate memcache service using in-memory storage. 49 - 50 - The service runs on `localhost` or `127.0.0.1` on dedicated port `9876`. 51 - Once activated, Safir will continue to act as before expect that all new values added are given to the memcache instead of being saved on disk. 52 - 53 - This can be enabled / diabled with the `start` and `stop` commands respectively. 54 - Note that when the memcache service is disabled, ALL data contained within it is lost so use wisely. 55 - 56 - In cases where you want to save the contents of the memcache, the `dump` command will allow for the contents to be saved out to disk in JSON format. 57 - This behaves as a snapshot as the contents of the cache persist after usage. 58 - 59 - ### Requirements 60 - 61 - Using this requires that the [Rubin CLI](https://crates.io/crates/rubin-cli) be installed. 62 - 63 - ```bash 64 - cargo install rubin-cli 65 - ``` 66 - 67 - ### Usage 68 - 69 - Start or stop the Memcache (in-memory store) service 70 - 71 - Usage: safir mem <COMMAND> 72 - 73 - Commands: 74 - start Start the Safir Memcache server 75 - stop Stop the Safir Memcache server 76 - dump Dump the Safir Memcache server to disk 77 - help Print this message or the help of the given subcommand(s) 78 - 79 - Options: 80 - -h, --help Print help 81 - -V, --version Print version 82 - 83 - ## v0.3.0 -> v0.4.0 84 - 85 - v0.4.0 introduces a breaking change which makes it incompatible with older versions of Safir. 86 - 87 - To prevent issues, please remove the old `.safirstore/` directory (store the old data somewhere) and re-run Safir. 88 - This should address any issues! 3 + Repo containing the source for `safir` and `safir-mem`.
+29
safir-mem/Cargo.toml
··· 1 + [package] 2 + name = "safir-mem" 3 + version = "0.1.0" 4 + edition = "2021" 5 + authors = ["Graham Keenan graham.keenan@outlook.com"] 6 + license = "MIT OR Apache-2.0" 7 + description = "In-memory key/value store to share values between different shell sessions" 8 + readme = "README.md" 9 + homepage = "https://github.com/Tyrannican/safir" 10 + repository = "https://github.com/Tyrannican/safir" 11 + keywords = ["cli", "terminal", "utility", "key-value", "store"] 12 + categories = ["command-line-utilities"] 13 + 14 + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 + 16 + [dependencies] 17 + clap = { version = "4.2.5" , features = ["derive"] } 18 + serde = { version = "1", features = ["derive"] } 19 + serde_json = "1" 20 + dirs = "5" 21 + colored = "2" 22 + rubin = "^0.3.1" 23 + tokio = { version = "1.28.2", features = ["full"] } 24 + psutil = { version = "3.2.2", optional = true } 25 + which = "4.4.0" 26 + sysinfo = "0.29.3" 27 + 28 + [target.'cfg(unix)'.dependencies] 29 + psutil = "3.2.2"
+201
safir-mem/LICENSE-APACHE
··· 1 + Apache License 2 + Version 2.0, January 2004 3 + http://www.apache.org/licenses/ 4 + 5 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 + 7 + 1. Definitions. 8 + 9 + "License" shall mean the terms and conditions for use, reproduction, 10 + and distribution as defined by Sections 1 through 9 of this document. 11 + 12 + "Licensor" shall mean the copyright owner or entity authorized by 13 + the copyright owner that is granting the License. 14 + 15 + "Legal Entity" shall mean the union of the acting entity and all 16 + other entities that control, are controlled by, or are under common 17 + control with that entity. For the purposes of this definition, 18 + "control" means (i) the power, direct or indirect, to cause the 19 + direction or management of such entity, whether by contract or 20 + otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 + outstanding shares, or (iii) beneficial ownership of such entity. 22 + 23 + "You" (or "Your") shall mean an individual or Legal Entity 24 + exercising permissions granted by this License. 25 + 26 + "Source" form shall mean the preferred form for making modifications, 27 + including but not limited to software source code, documentation 28 + source, and configuration files. 29 + 30 + "Object" form shall mean any form resulting from mechanical 31 + transformation or translation of a Source form, including but 32 + not limited to compiled object code, generated documentation, 33 + and conversions to other media types. 34 + 35 + "Work" shall mean the work of authorship, whether in Source or 36 + Object form, made available under the License, as indicated by a 37 + copyright notice that is included in or attached to the work 38 + (an example is provided in the Appendix below). 39 + 40 + "Derivative Works" shall mean any work, whether in Source or Object 41 + form, that is based on (or derived from) the Work and for which the 42 + editorial revisions, annotations, elaborations, or other modifications 43 + represent, as a whole, an original work of authorship. For the purposes 44 + of this License, Derivative Works shall not include works that remain 45 + separable from, or merely link (or bind by name) to the interfaces of, 46 + the Work and Derivative Works thereof. 47 + 48 + "Contribution" shall mean any work of authorship, including 49 + the original version of the Work and any modifications or additions 50 + to that Work or Derivative Works thereof, that is intentionally 51 + submitted to Licensor for inclusion in the Work by the copyright owner 52 + or by an individual or Legal Entity authorized to submit on behalf of 53 + the copyright owner. For the purposes of this definition, "submitted" 54 + means any form of electronic, verbal, or written communication sent 55 + to the Licensor or its representatives, including but not limited to 56 + communication on electronic mailing lists, source code control systems, 57 + and issue tracking systems that are managed by, or on behalf of, the 58 + Licensor for the purpose of discussing and improving the Work, but 59 + excluding communication that is conspicuously marked or otherwise 60 + designated in writing by the copyright owner as "Not a Contribution." 61 + 62 + "Contributor" shall mean Licensor and any individual or Legal Entity 63 + on behalf of whom a Contribution has been received by Licensor and 64 + subsequently incorporated within the Work. 65 + 66 + 2. Grant of Copyright License. Subject to the terms and conditions of 67 + this License, each Contributor hereby grants to You a perpetual, 68 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 + copyright license to reproduce, prepare Derivative Works of, 70 + publicly display, publicly perform, sublicense, and distribute the 71 + Work and such Derivative Works in Source or Object form. 72 + 73 + 3. Grant of Patent License. Subject to the terms and conditions of 74 + this License, each Contributor hereby grants to You a perpetual, 75 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 + (except as stated in this section) patent license to make, have made, 77 + use, offer to sell, sell, import, and otherwise transfer the Work, 78 + where such license applies only to those patent claims licensable 79 + by such Contributor that are necessarily infringed by their 80 + Contribution(s) alone or by combination of their Contribution(s) 81 + with the Work to which such Contribution(s) was submitted. If You 82 + institute patent litigation against any entity (including a 83 + cross-claim or counterclaim in a lawsuit) alleging that the Work 84 + or a Contribution incorporated within the Work constitutes direct 85 + or contributory patent infringement, then any patent licenses 86 + granted to You under this License for that Work shall terminate 87 + as of the date such litigation is filed. 88 + 89 + 4. Redistribution. You may reproduce and distribute copies of the 90 + Work or Derivative Works thereof in any medium, with or without 91 + modifications, and in Source or Object form, provided that You 92 + meet the following conditions: 93 + 94 + (a) You must give any other recipients of the Work or 95 + Derivative Works a copy of this License; and 96 + 97 + (b) You must cause any modified files to carry prominent notices 98 + stating that You changed the files; and 99 + 100 + (c) You must retain, in the Source form of any Derivative Works 101 + that You distribute, all copyright, patent, trademark, and 102 + attribution notices from the Source form of the Work, 103 + excluding those notices that do not pertain to any part of 104 + the Derivative Works; and 105 + 106 + (d) If the Work includes a "NOTICE" text file as part of its 107 + distribution, then any Derivative Works that You distribute must 108 + include a readable copy of the attribution notices contained 109 + within such NOTICE file, excluding those notices that do not 110 + pertain to any part of the Derivative Works, in at least one 111 + of the following places: within a NOTICE text file distributed 112 + as part of the Derivative Works; within the Source form or 113 + documentation, if provided along with the Derivative Works; or, 114 + within a display generated by the Derivative Works, if and 115 + wherever such third-party notices normally appear. The contents 116 + of the NOTICE file are for informational purposes only and 117 + do not modify the License. You may add Your own attribution 118 + notices within Derivative Works that You distribute, alongside 119 + or as an addendum to the NOTICE text from the Work, provided 120 + that such additional attribution notices cannot be construed 121 + as modifying the License. 122 + 123 + You may add Your own copyright statement to Your modifications and 124 + may provide additional or different license terms and conditions 125 + for use, reproduction, or distribution of Your modifications, or 126 + for any such Derivative Works as a whole, provided Your use, 127 + reproduction, and distribution of the Work otherwise complies with 128 + the conditions stated in this License. 129 + 130 + 5. Submission of Contributions. Unless You explicitly state otherwise, 131 + any Contribution intentionally submitted for inclusion in the Work 132 + by You to the Licensor shall be under the terms and conditions of 133 + this License, without any additional terms or conditions. 134 + Notwithstanding the above, nothing herein shall supersede or modify 135 + the terms of any separate license agreement you may have executed 136 + with Licensor regarding such Contributions. 137 + 138 + 6. Trademarks. This License does not grant permission to use the trade 139 + names, trademarks, service marks, or product names of the Licensor, 140 + except as required for reasonable and customary use in describing the 141 + origin of the Work and reproducing the content of the NOTICE file. 142 + 143 + 7. Disclaimer of Warranty. Unless required by applicable law or 144 + agreed to in writing, Licensor provides the Work (and each 145 + Contributor provides its Contributions) on an "AS IS" BASIS, 146 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 + implied, including, without limitation, any warranties or conditions 148 + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 + PARTICULAR PURPOSE. You are solely responsible for determining the 150 + appropriateness of using or redistributing the Work and assume any 151 + risks associated with Your exercise of permissions under this License. 152 + 153 + 8. Limitation of Liability. In no event and under no legal theory, 154 + whether in tort (including negligence), contract, or otherwise, 155 + unless required by applicable law (such as deliberate and grossly 156 + negligent acts) or agreed to in writing, shall any Contributor be 157 + liable to You for damages, including any direct, indirect, special, 158 + incidental, or consequential damages of any character arising as a 159 + result of this License or out of the use or inability to use the 160 + Work (including but not limited to damages for loss of goodwill, 161 + work stoppage, computer failure or malfunction, or any and all 162 + other commercial damages or losses), even if such Contributor 163 + has been advised of the possibility of such damages. 164 + 165 + 9. Accepting Warranty or Additional Liability. While redistributing 166 + the Work or Derivative Works thereof, You may choose to offer, 167 + and charge a fee for, acceptance of support, warranty, indemnity, 168 + or other liability obligations and/or rights consistent with this 169 + License. However, in accepting such obligations, You may act only 170 + on Your own behalf and on Your sole responsibility, not on behalf 171 + of any other Contributor, and only if You agree to indemnify, 172 + defend, and hold each Contributor harmless for any liability 173 + incurred by, or claims asserted against, such Contributor by reason 174 + of your accepting any such warranty or additional liability. 175 + 176 + END OF TERMS AND CONDITIONS 177 + 178 + APPENDIX: How to apply the Apache License to your work. 179 + 180 + To apply the Apache License to your work, attach the following 181 + boilerplate notice, with the fields enclosed by brackets "[]" 182 + replaced with your own identifying information. (Don't include 183 + the brackets!) The text should be enclosed in the appropriate 184 + comment syntax for the file format. We also recommend that a 185 + file or class name and description of purpose be included on the 186 + same "printed page" as the copyright notice for easier 187 + identification within third-party archives. 188 + 189 + Copyright [yyyy] [name of copyright owner] 190 + 191 + Licensed under the Apache License, Version 2.0 (the "License"); 192 + you may not use this file except in compliance with the License. 193 + You may obtain a copy of the License at 194 + 195 + http://www.apache.org/licenses/LICENSE-2.0 196 + 197 + Unless required by applicable law or agreed to in writing, software 198 + distributed under the License is distributed on an "AS IS" BASIS, 199 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 + See the License for the specific language governing permissions and 201 + limitations under the License.
+21
safir-mem/LICENSE-MIT
··· 1 + MIT License 2 + 3 + Copyright (c) 2023 Graham Keenan 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.
+49
safir-mem/README.md
··· 1 + # Safir-mem 2 + 3 + Simple in-memory CLI key/value store. 4 + 5 + The in-memory version of [Safir](https://crates.io/crates/safir)! 6 + 7 + `safir-mem` starts a service which runs on `localhost` or `127.0.0.1` on dedicated port `9876`. 8 + 9 + This can be enabled / diabled with the `start` and `stop` commands respectively. 10 + Note that when the memcache service is disabled, ALL data contained within it is lost so use wisely. 11 + 12 + In cases where you want to save the contents of the memcache, the `dump` command will allow for the contents to be saved out to disk in JSON format. 13 + This behaves as a snapshot as the contents of the cache persist after usage. 14 + 15 + ## Install 16 + 17 + To install `safir-mem`, run `cargo install safir-mem`. 18 + 19 + ### Requirements 20 + 21 + Using this requires that the [Rubin CLI](https://crates.io/crates/rubin-cli) be installed. 22 + 23 + ```bash 24 + cargo install rubin-cli 25 + ``` 26 + 27 + ## Usage 28 + 29 + ```bash 30 + In-memory key/value store to share information between shell sessions 31 + 32 + Usage: safir-mem <COMMAND> 33 + 34 + Commands: 35 + add Add a value to the store with the given key 36 + get Get a value from the store 37 + rm Remove values from the store 38 + alias Output the alias command for a key / value pair to be entered into a shell session 39 + export Output the export command for a key / value pair to be entered into a shell session 40 + clear Clear all keys/values from the store 41 + start Start the memcache server 42 + stop Stop the memcache server 43 + dump Dump contents of memcache to disk 44 + help Print this message or the help of the given subcommand(s) 45 + 46 + Options: 47 + -h, --help Print help 48 + -V, --version Print version 49 + ```
+85
safir-mem/src/cli.rs
··· 1 + //! CLI for using the Safir binary 2 + pub use clap::{Args, Parser, Subcommand}; 3 + 4 + /// CLI arguments for running the program 5 + #[derive(Parser, Debug)] 6 + #[command(author, version)] 7 + #[command(propagate_version = true)] 8 + #[command(about = "In-memory key/value store to share information between shell sessions", long_about = None)] 9 + pub struct Cli { 10 + /// Subcommands 11 + #[command(subcommand)] 12 + pub command: Commands, 13 + } 14 + 15 + /// Subcommands for running the program 16 + #[derive(Subcommand, Debug, PartialEq)] 17 + pub enum Commands { 18 + /// Add a value to the store with the given key 19 + Add(AddArgs), 20 + 21 + /// Get a value from the store 22 + Get(GetArgs), 23 + 24 + /// Remove values from the store 25 + Rm(RemoveArgs), 26 + 27 + /// Output the alias command for a key / value pair to be entered into a shell session 28 + Alias(SetArgs), 29 + 30 + /// Output the export command for a key / value pair to be entered into a shell session 31 + Export(SetArgs), 32 + 33 + /// Clear all keys/values from the store 34 + Clear, 35 + 36 + /// Start the memcache server 37 + Start, 38 + 39 + /// Stop the memcache server 40 + Stop, 41 + 42 + /// Dump contents of memcache to disk 43 + Dump(DumpArgs), 44 + } 45 + 46 + /// Arguments for adding a value to the store with a given key 47 + #[derive(Args, Debug, PartialEq)] 48 + pub struct AddArgs { 49 + /// Name of the item to store 50 + pub key: String, 51 + 52 + /// Value to store 53 + pub value: String, 54 + } 55 + 56 + /// Arguments for retrieving a value from the store with a given key 57 + #[derive(Args, Debug, PartialEq)] 58 + pub struct GetArgs { 59 + /// Name of the value to retrieve from the store 60 + /// 61 + /// Returns nothing if the key does not exist 62 + pub key: Option<String>, 63 + } 64 + 65 + /// Arguments for removing values from the store with given keys 66 + #[derive(Args, Debug, PartialEq)] 67 + pub struct RemoveArgs { 68 + /// Name of the keys to remove from the store 69 + /// 70 + /// Does nothing if the keys do not exist 71 + pub key: Vec<String>, 72 + } 73 + 74 + /// Arguments for outputting commands with a given prefix 75 + #[derive(Args, Debug, PartialEq)] 76 + pub struct SetArgs { 77 + /// Name of the keys to display (e.g. alias / export) 78 + pub keys: Vec<String>, 79 + } 80 + 81 + #[derive(Args, Debug, PartialEq)] 82 + pub struct DumpArgs { 83 + /// Path to save the store to 84 + pub path: String, 85 + }
+108
safir-mem/src/main.rs
··· 1 + mod cfg; 2 + mod cli; 3 + mod safir; 4 + mod utils; 5 + 6 + use cli::*; 7 + 8 + use std::process::{Command, Stdio}; 9 + 10 + #[tokio::main] 11 + async fn main() -> std::io::Result<()> { 12 + let cli = Cli::parse(); 13 + let store_dir = utils::create_safir_directory().await?; 14 + let safir_cfg = &store_dir.join("safir.cfg"); 15 + let mut cfg = utils::load_safir_config(&safir_cfg).await?; 16 + 17 + let safir_state = utils::is_safir_running(cfg.memcache_pid); 18 + let safir_mem = safir::SafirMemcache::new(safir_state); 19 + 20 + match &cli.command { 21 + Commands::Add(args) => safir_mem.add_entry(&args.key, &args.value).await?, 22 + Commands::Get(args) => { 23 + if let Some(key) = &args.key { 24 + safir_mem.get_string(key).await?; 25 + } else { 26 + utils::print_header(); 27 + utils::print_output("A key is required for memcache GET command!"); 28 + } 29 + } 30 + Commands::Rm(args) => { 31 + safir_mem.remove_entry(args.key.clone()).await?; 32 + } 33 + Commands::Alias(args) => { 34 + safir_mem.set_commands("alias", &args.keys).await; 35 + } 36 + Commands::Export(args) => { 37 + safir_mem.set_commands("export", &args.keys).await; 38 + } 39 + Commands::Clear => { 40 + safir_mem.clear_entries().await?; 41 + } 42 + Commands::Start => { 43 + if !utils::check_rubin_installed() { 44 + eprintln!( 45 + "The Rubin binary must be installed to use this feature, please install it via cargo using `cargo install rubin-cli`" 46 + ); 47 + return Ok(()); 48 + } 49 + 50 + if let Some(pid) = cfg.memcache_pid { 51 + println!( 52 + "Safir memcache service is already running on 127.0.0.1:9876 - PID {}", 53 + pid 54 + ); 55 + 56 + return Ok(()); 57 + } 58 + 59 + let child = Command::new("rubin") 60 + .args(["server"]) 61 + .stdout(Stdio::null()) 62 + .stderr(Stdio::null()) 63 + .stdin(Stdio::null()) 64 + .spawn() 65 + .expect("unable to spawn child process"); 66 + 67 + let pid = child.id(); 68 + cfg.memcache_pid = Some(pid); 69 + cfg.write(&safir_cfg).await?; 70 + println!( 71 + "Safir memcache service started at 127.0.0.1:9876 - PID {}", 72 + pid 73 + ); 74 + } 75 + Commands::Stop => { 76 + if !utils::check_rubin_installed() { 77 + eprintln!("The Rubin binary must be installed to use this feature, please install it via cargo using `cargo install rubin-cli`"); 78 + return Ok(()); 79 + } 80 + 81 + let pid = match cfg.memcache_pid { 82 + Some(pid) => pid, 83 + None => { 84 + println!("Safir memcache service does not seem to be running."); 85 + return Ok(()); 86 + } 87 + }; 88 + 89 + if let Err(err) = utils::kill_process(pid).await { 90 + eprintln!( 91 + "Safir memcache service failed to stop, manual removal may be necessary - {}", 92 + err 93 + ); 94 + } else { 95 + cfg.memcache_pid = None; 96 + cfg.write(&safir_cfg).await?; 97 + println!("Stopping Safir memcache service!"); 98 + } 99 + } 100 + Commands::Dump(args) => { 101 + if let Err(e) = safir_mem.dump_store(&args.path).await { 102 + eprintln!("unable to dump Safir memcache service: {}", e); 103 + } 104 + } 105 + } 106 + 107 + Ok(()) 108 + }
+112
safir-mem/src/safir.rs
··· 1 + use std::io::Result; 2 + 3 + use colored::*; 4 + 5 + use crate::utils::{confirm_entry, print_header, print_output}; 6 + use rubin::net::client::RubinClient; 7 + 8 + fn safir_offline() { 9 + eprintln!( 10 + "Safir Memcache does not appear to be online.\nStart it by running `safir-mem start`." 11 + ); 12 + } 13 + 14 + pub struct SafirMemcache { 15 + is_online: bool, 16 + client: RubinClient, 17 + } 18 + 19 + impl SafirMemcache { 20 + pub fn new(is_online: bool) -> Self { 21 + Self { 22 + is_online, 23 + client: RubinClient::new("127.0.0.1", 9876), 24 + } 25 + } 26 + 27 + pub async fn add_entry(&self, key: &str, value: &str) -> Result<()> { 28 + if !self.is_online { 29 + safir_offline(); 30 + return Ok(()); 31 + } 32 + 33 + self.client.insert_string(key, value).await?; 34 + Ok(()) 35 + } 36 + 37 + pub async fn get_string(&self, key: &str) -> Result<()> { 38 + if !self.is_online { 39 + safir_offline(); 40 + return Ok(()); 41 + } 42 + 43 + print_header(); 44 + let output = if let Ok(val) = self.client.get_string(key).await { 45 + format!("{}: \"{}\"", key.bold().yellow(), val) 46 + } else { 47 + format!("{}: ", key.bold().yellow()) 48 + }; 49 + 50 + print_output(&output); 51 + 52 + Ok(()) 53 + } 54 + 55 + pub async fn remove_entry(&self, keys: Vec<String>) -> Result<()> { 56 + if !self.is_online { 57 + safir_offline(); 58 + return Ok(()); 59 + } 60 + 61 + for key in &keys { 62 + self.client.remove_string(key).await?; 63 + } 64 + 65 + Ok(()) 66 + } 67 + 68 + pub async fn set_commands(&self, prefix: &str, keys: &Vec<String>) { 69 + if !self.is_online { 70 + safir_offline(); 71 + return; 72 + } 73 + 74 + print_header(); 75 + let prefix = match prefix { 76 + "alias" => "alias".bold().green(), 77 + "export" => "export".bold().magenta(), 78 + _ => prefix.bold(), 79 + }; 80 + 81 + for key in keys { 82 + if let Ok(value) = self.client.get_string(key).await { 83 + println!("{} {}=\"{}\"\n", prefix, key.bold().yellow(), value); 84 + } 85 + } 86 + } 87 + 88 + pub async fn clear_entries(&self) -> Result<()> { 89 + if !self.is_online { 90 + safir_offline(); 91 + return Ok(()); 92 + } 93 + 94 + if confirm_entry("Are you sure you want to clear the store?") { 95 + self.client.clear_strings().await?; 96 + } 97 + 98 + Ok(()) 99 + } 100 + 101 + pub async fn dump_store(&self, path: &str) -> Result<()> { 102 + if !self.is_online { 103 + safir_offline(); 104 + return Ok(()); 105 + } 106 + 107 + self.client.dump_store(path).await?; 108 + println!("Safir memcache dumped to {}", path); 109 + 110 + Ok(()) 111 + } 112 + }
+1084
safir/Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 3 4 + 5 + [[package]] 6 + name = "anstream" 7 + version = "0.3.2" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" 10 + dependencies = [ 11 + "anstyle", 12 + "anstyle-parse", 13 + "anstyle-query", 14 + "anstyle-wincon", 15 + "colorchoice", 16 + "is-terminal", 17 + "utf8parse", 18 + ] 19 + 20 + [[package]] 21 + name = "anstyle" 22 + version = "1.0.0" 23 + source = "registry+https://github.com/rust-lang/crates.io-index" 24 + checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" 25 + 26 + [[package]] 27 + name = "anstyle-parse" 28 + version = "0.2.0" 29 + source = "registry+https://github.com/rust-lang/crates.io-index" 30 + checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" 31 + dependencies = [ 32 + "utf8parse", 33 + ] 34 + 35 + [[package]] 36 + name = "anstyle-query" 37 + version = "1.0.0" 38 + source = "registry+https://github.com/rust-lang/crates.io-index" 39 + checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 40 + dependencies = [ 41 + "windows-sys 0.48.0", 42 + ] 43 + 44 + [[package]] 45 + name = "anstyle-wincon" 46 + version = "1.0.1" 47 + source = "registry+https://github.com/rust-lang/crates.io-index" 48 + checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" 49 + dependencies = [ 50 + "anstyle", 51 + "windows-sys 0.48.0", 52 + ] 53 + 54 + [[package]] 55 + name = "atty" 56 + version = "0.2.14" 57 + source = "registry+https://github.com/rust-lang/crates.io-index" 58 + checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 59 + dependencies = [ 60 + "hermit-abi 0.1.19", 61 + "libc", 62 + "winapi", 63 + ] 64 + 65 + [[package]] 66 + name = "autocfg" 67 + version = "1.1.0" 68 + source = "registry+https://github.com/rust-lang/crates.io-index" 69 + checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 70 + 71 + [[package]] 72 + name = "bitflags" 73 + version = "1.3.2" 74 + source = "registry+https://github.com/rust-lang/crates.io-index" 75 + checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 76 + 77 + [[package]] 78 + name = "bytes" 79 + version = "1.4.0" 80 + source = "registry+https://github.com/rust-lang/crates.io-index" 81 + checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 82 + 83 + [[package]] 84 + name = "cc" 85 + version = "1.0.79" 86 + source = "registry+https://github.com/rust-lang/crates.io-index" 87 + checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 88 + 89 + [[package]] 90 + name = "cfg-if" 91 + version = "1.0.0" 92 + source = "registry+https://github.com/rust-lang/crates.io-index" 93 + checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 94 + 95 + [[package]] 96 + name = "clap" 97 + version = "4.3.1" 98 + source = "registry+https://github.com/rust-lang/crates.io-index" 99 + checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" 100 + dependencies = [ 101 + "clap_builder", 102 + "clap_derive", 103 + "once_cell", 104 + ] 105 + 106 + [[package]] 107 + name = "clap_builder" 108 + version = "4.3.1" 109 + source = "registry+https://github.com/rust-lang/crates.io-index" 110 + checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" 111 + dependencies = [ 112 + "anstream", 113 + "anstyle", 114 + "bitflags", 115 + "clap_lex", 116 + "strsim", 117 + ] 118 + 119 + [[package]] 120 + name = "clap_derive" 121 + version = "4.3.1" 122 + source = "registry+https://github.com/rust-lang/crates.io-index" 123 + checksum = "59e9ef9a08ee1c0e1f2e162121665ac45ac3783b0f897db7244ae75ad9a8f65b" 124 + dependencies = [ 125 + "heck", 126 + "proc-macro2", 127 + "quote", 128 + "syn 2.0.18", 129 + ] 130 + 131 + [[package]] 132 + name = "clap_lex" 133 + version = "0.5.0" 134 + source = "registry+https://github.com/rust-lang/crates.io-index" 135 + checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" 136 + 137 + [[package]] 138 + name = "colorchoice" 139 + version = "1.0.0" 140 + source = "registry+https://github.com/rust-lang/crates.io-index" 141 + checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 142 + 143 + [[package]] 144 + name = "colored" 145 + version = "2.0.0" 146 + source = "registry+https://github.com/rust-lang/crates.io-index" 147 + checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" 148 + dependencies = [ 149 + "atty", 150 + "lazy_static", 151 + "winapi", 152 + ] 153 + 154 + [[package]] 155 + name = "core-foundation-sys" 156 + version = "0.8.4" 157 + source = "registry+https://github.com/rust-lang/crates.io-index" 158 + checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" 159 + 160 + [[package]] 161 + name = "crossbeam-channel" 162 + version = "0.5.8" 163 + source = "registry+https://github.com/rust-lang/crates.io-index" 164 + checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" 165 + dependencies = [ 166 + "cfg-if", 167 + "crossbeam-utils", 168 + ] 169 + 170 + [[package]] 171 + name = "crossbeam-deque" 172 + version = "0.8.3" 173 + source = "registry+https://github.com/rust-lang/crates.io-index" 174 + checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" 175 + dependencies = [ 176 + "cfg-if", 177 + "crossbeam-epoch", 178 + "crossbeam-utils", 179 + ] 180 + 181 + [[package]] 182 + name = "crossbeam-epoch" 183 + version = "0.9.15" 184 + source = "registry+https://github.com/rust-lang/crates.io-index" 185 + checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" 186 + dependencies = [ 187 + "autocfg", 188 + "cfg-if", 189 + "crossbeam-utils", 190 + "memoffset 0.9.0", 191 + "scopeguard", 192 + ] 193 + 194 + [[package]] 195 + name = "crossbeam-utils" 196 + version = "0.8.16" 197 + source = "registry+https://github.com/rust-lang/crates.io-index" 198 + checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" 199 + dependencies = [ 200 + "cfg-if", 201 + ] 202 + 203 + [[package]] 204 + name = "darwin-libproc" 205 + version = "0.1.2" 206 + source = "registry+https://github.com/rust-lang/crates.io-index" 207 + checksum = "9fb90051930c9a0f09e585762152048e23ac74d20c10590ef7cf01c0343c3046" 208 + dependencies = [ 209 + "darwin-libproc-sys", 210 + "libc", 211 + "memchr", 212 + ] 213 + 214 + [[package]] 215 + name = "darwin-libproc-sys" 216 + version = "0.1.2" 217 + source = "registry+https://github.com/rust-lang/crates.io-index" 218 + checksum = "57cebb5bde66eecdd30ddc4b9cd208238b15db4982ccc72db59d699ea10867c1" 219 + dependencies = [ 220 + "libc", 221 + ] 222 + 223 + [[package]] 224 + name = "derive_more" 225 + version = "0.99.17" 226 + source = "registry+https://github.com/rust-lang/crates.io-index" 227 + checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 228 + dependencies = [ 229 + "proc-macro2", 230 + "quote", 231 + "syn 1.0.109", 232 + ] 233 + 234 + [[package]] 235 + name = "dirs" 236 + version = "5.0.1" 237 + source = "registry+https://github.com/rust-lang/crates.io-index" 238 + checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" 239 + dependencies = [ 240 + "dirs-sys", 241 + ] 242 + 243 + [[package]] 244 + name = "dirs-sys" 245 + version = "0.4.1" 246 + source = "registry+https://github.com/rust-lang/crates.io-index" 247 + checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" 248 + dependencies = [ 249 + "libc", 250 + "option-ext", 251 + "redox_users", 252 + "windows-sys 0.48.0", 253 + ] 254 + 255 + [[package]] 256 + name = "either" 257 + version = "1.8.1" 258 + source = "registry+https://github.com/rust-lang/crates.io-index" 259 + checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" 260 + 261 + [[package]] 262 + name = "errno" 263 + version = "0.3.1" 264 + source = "registry+https://github.com/rust-lang/crates.io-index" 265 + checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" 266 + dependencies = [ 267 + "errno-dragonfly", 268 + "libc", 269 + "windows-sys 0.48.0", 270 + ] 271 + 272 + [[package]] 273 + name = "errno-dragonfly" 274 + version = "0.1.2" 275 + source = "registry+https://github.com/rust-lang/crates.io-index" 276 + checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 277 + dependencies = [ 278 + "cc", 279 + "libc", 280 + ] 281 + 282 + [[package]] 283 + name = "getrandom" 284 + version = "0.2.9" 285 + source = "registry+https://github.com/rust-lang/crates.io-index" 286 + checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" 287 + dependencies = [ 288 + "cfg-if", 289 + "libc", 290 + "wasi", 291 + ] 292 + 293 + [[package]] 294 + name = "glob" 295 + version = "0.3.1" 296 + source = "registry+https://github.com/rust-lang/crates.io-index" 297 + checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" 298 + 299 + [[package]] 300 + name = "heck" 301 + version = "0.4.1" 302 + source = "registry+https://github.com/rust-lang/crates.io-index" 303 + checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 304 + 305 + [[package]] 306 + name = "hermit-abi" 307 + version = "0.1.19" 308 + source = "registry+https://github.com/rust-lang/crates.io-index" 309 + checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 310 + dependencies = [ 311 + "libc", 312 + ] 313 + 314 + [[package]] 315 + name = "hermit-abi" 316 + version = "0.2.6" 317 + source = "registry+https://github.com/rust-lang/crates.io-index" 318 + checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 319 + dependencies = [ 320 + "libc", 321 + ] 322 + 323 + [[package]] 324 + name = "hermit-abi" 325 + version = "0.3.1" 326 + source = "registry+https://github.com/rust-lang/crates.io-index" 327 + checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 328 + 329 + [[package]] 330 + name = "io-lifetimes" 331 + version = "1.0.11" 332 + source = "registry+https://github.com/rust-lang/crates.io-index" 333 + checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" 334 + dependencies = [ 335 + "hermit-abi 0.3.1", 336 + "libc", 337 + "windows-sys 0.48.0", 338 + ] 339 + 340 + [[package]] 341 + name = "is-terminal" 342 + version = "0.4.7" 343 + source = "registry+https://github.com/rust-lang/crates.io-index" 344 + checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" 345 + dependencies = [ 346 + "hermit-abi 0.3.1", 347 + "io-lifetimes", 348 + "rustix", 349 + "windows-sys 0.48.0", 350 + ] 351 + 352 + [[package]] 353 + name = "itoa" 354 + version = "1.0.6" 355 + source = "registry+https://github.com/rust-lang/crates.io-index" 356 + checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 357 + 358 + [[package]] 359 + name = "lazy_static" 360 + version = "1.4.0" 361 + source = "registry+https://github.com/rust-lang/crates.io-index" 362 + checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 363 + 364 + [[package]] 365 + name = "libc" 366 + version = "0.2.144" 367 + source = "registry+https://github.com/rust-lang/crates.io-index" 368 + checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" 369 + 370 + [[package]] 371 + name = "linux-raw-sys" 372 + version = "0.3.8" 373 + source = "registry+https://github.com/rust-lang/crates.io-index" 374 + checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" 375 + 376 + [[package]] 377 + name = "lock_api" 378 + version = "0.4.9" 379 + source = "registry+https://github.com/rust-lang/crates.io-index" 380 + checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 381 + dependencies = [ 382 + "autocfg", 383 + "scopeguard", 384 + ] 385 + 386 + [[package]] 387 + name = "log" 388 + version = "0.4.19" 389 + source = "registry+https://github.com/rust-lang/crates.io-index" 390 + checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" 391 + 392 + [[package]] 393 + name = "mach" 394 + version = "0.3.2" 395 + source = "registry+https://github.com/rust-lang/crates.io-index" 396 + checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" 397 + dependencies = [ 398 + "libc", 399 + ] 400 + 401 + [[package]] 402 + name = "memchr" 403 + version = "2.5.0" 404 + source = "registry+https://github.com/rust-lang/crates.io-index" 405 + checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 406 + 407 + [[package]] 408 + name = "memoffset" 409 + version = "0.6.5" 410 + source = "registry+https://github.com/rust-lang/crates.io-index" 411 + checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 412 + dependencies = [ 413 + "autocfg", 414 + ] 415 + 416 + [[package]] 417 + name = "memoffset" 418 + version = "0.9.0" 419 + source = "registry+https://github.com/rust-lang/crates.io-index" 420 + checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" 421 + dependencies = [ 422 + "autocfg", 423 + ] 424 + 425 + [[package]] 426 + name = "mio" 427 + version = "0.8.8" 428 + source = "registry+https://github.com/rust-lang/crates.io-index" 429 + checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" 430 + dependencies = [ 431 + "libc", 432 + "wasi", 433 + "windows-sys 0.48.0", 434 + ] 435 + 436 + [[package]] 437 + name = "nix" 438 + version = "0.23.2" 439 + source = "registry+https://github.com/rust-lang/crates.io-index" 440 + checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" 441 + dependencies = [ 442 + "bitflags", 443 + "cc", 444 + "cfg-if", 445 + "libc", 446 + "memoffset 0.6.5", 447 + ] 448 + 449 + [[package]] 450 + name = "ntapi" 451 + version = "0.4.1" 452 + source = "registry+https://github.com/rust-lang/crates.io-index" 453 + checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" 454 + dependencies = [ 455 + "winapi", 456 + ] 457 + 458 + [[package]] 459 + name = "nu-ansi-term" 460 + version = "0.46.0" 461 + source = "registry+https://github.com/rust-lang/crates.io-index" 462 + checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" 463 + dependencies = [ 464 + "overload", 465 + "winapi", 466 + ] 467 + 468 + [[package]] 469 + name = "num_cpus" 470 + version = "1.15.0" 471 + source = "registry+https://github.com/rust-lang/crates.io-index" 472 + checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 473 + dependencies = [ 474 + "hermit-abi 0.2.6", 475 + "libc", 476 + ] 477 + 478 + [[package]] 479 + name = "once_cell" 480 + version = "1.17.2" 481 + source = "registry+https://github.com/rust-lang/crates.io-index" 482 + checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" 483 + 484 + [[package]] 485 + name = "option-ext" 486 + version = "0.2.0" 487 + source = "registry+https://github.com/rust-lang/crates.io-index" 488 + checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" 489 + 490 + [[package]] 491 + name = "overload" 492 + version = "0.1.1" 493 + source = "registry+https://github.com/rust-lang/crates.io-index" 494 + checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" 495 + 496 + [[package]] 497 + name = "parking_lot" 498 + version = "0.12.1" 499 + source = "registry+https://github.com/rust-lang/crates.io-index" 500 + checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 501 + dependencies = [ 502 + "lock_api", 503 + "parking_lot_core", 504 + ] 505 + 506 + [[package]] 507 + name = "parking_lot_core" 508 + version = "0.9.7" 509 + source = "registry+https://github.com/rust-lang/crates.io-index" 510 + checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" 511 + dependencies = [ 512 + "cfg-if", 513 + "libc", 514 + "redox_syscall", 515 + "smallvec", 516 + "windows-sys 0.45.0", 517 + ] 518 + 519 + [[package]] 520 + name = "pin-project-lite" 521 + version = "0.2.9" 522 + source = "registry+https://github.com/rust-lang/crates.io-index" 523 + checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 524 + 525 + [[package]] 526 + name = "platforms" 527 + version = "2.0.0" 528 + source = "registry+https://github.com/rust-lang/crates.io-index" 529 + checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" 530 + 531 + [[package]] 532 + name = "proc-macro2" 533 + version = "1.0.59" 534 + source = "registry+https://github.com/rust-lang/crates.io-index" 535 + checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" 536 + dependencies = [ 537 + "unicode-ident", 538 + ] 539 + 540 + [[package]] 541 + name = "psutil" 542 + version = "3.2.2" 543 + source = "registry+https://github.com/rust-lang/crates.io-index" 544 + checksum = "f866af2b0f8e4b0d2d00aad8a9c5fc48fad33466cd99a64cbb3a4c1505f1a62d" 545 + dependencies = [ 546 + "cfg-if", 547 + "darwin-libproc", 548 + "derive_more", 549 + "glob", 550 + "mach", 551 + "nix", 552 + "num_cpus", 553 + "once_cell", 554 + "platforms", 555 + "thiserror", 556 + "unescape", 557 + ] 558 + 559 + [[package]] 560 + name = "quote" 561 + version = "1.0.28" 562 + source = "registry+https://github.com/rust-lang/crates.io-index" 563 + checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" 564 + dependencies = [ 565 + "proc-macro2", 566 + ] 567 + 568 + [[package]] 569 + name = "rayon" 570 + version = "1.7.0" 571 + source = "registry+https://github.com/rust-lang/crates.io-index" 572 + checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" 573 + dependencies = [ 574 + "either", 575 + "rayon-core", 576 + ] 577 + 578 + [[package]] 579 + name = "rayon-core" 580 + version = "1.11.0" 581 + source = "registry+https://github.com/rust-lang/crates.io-index" 582 + checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" 583 + dependencies = [ 584 + "crossbeam-channel", 585 + "crossbeam-deque", 586 + "crossbeam-utils", 587 + "num_cpus", 588 + ] 589 + 590 + [[package]] 591 + name = "redox_syscall" 592 + version = "0.2.16" 593 + source = "registry+https://github.com/rust-lang/crates.io-index" 594 + checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 595 + dependencies = [ 596 + "bitflags", 597 + ] 598 + 599 + [[package]] 600 + name = "redox_users" 601 + version = "0.4.3" 602 + source = "registry+https://github.com/rust-lang/crates.io-index" 603 + checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 604 + dependencies = [ 605 + "getrandom", 606 + "redox_syscall", 607 + "thiserror", 608 + ] 609 + 610 + [[package]] 611 + name = "rubin" 612 + version = "0.3.1" 613 + source = "registry+https://github.com/rust-lang/crates.io-index" 614 + checksum = "42c54f8f7b8a32f0b361d6dab1933f931ea13e533f19cb33c09a6d1e7141d55b" 615 + dependencies = [ 616 + "serde", 617 + "serde_json", 618 + "tokio", 619 + "tracing", 620 + "tracing-subscriber", 621 + ] 622 + 623 + [[package]] 624 + name = "rustix" 625 + version = "0.37.19" 626 + source = "registry+https://github.com/rust-lang/crates.io-index" 627 + checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" 628 + dependencies = [ 629 + "bitflags", 630 + "errno", 631 + "io-lifetimes", 632 + "libc", 633 + "linux-raw-sys", 634 + "windows-sys 0.48.0", 635 + ] 636 + 637 + [[package]] 638 + name = "ryu" 639 + version = "1.0.13" 640 + source = "registry+https://github.com/rust-lang/crates.io-index" 641 + checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" 642 + 643 + [[package]] 644 + name = "safir" 645 + version = "0.5.0" 646 + dependencies = [ 647 + "clap", 648 + "colored", 649 + "dirs", 650 + "psutil", 651 + "rubin", 652 + "serde", 653 + "serde_json", 654 + "sysinfo", 655 + "tokio", 656 + "which", 657 + ] 658 + 659 + [[package]] 660 + name = "scopeguard" 661 + version = "1.1.0" 662 + source = "registry+https://github.com/rust-lang/crates.io-index" 663 + checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 664 + 665 + [[package]] 666 + name = "serde" 667 + version = "1.0.163" 668 + source = "registry+https://github.com/rust-lang/crates.io-index" 669 + checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" 670 + dependencies = [ 671 + "serde_derive", 672 + ] 673 + 674 + [[package]] 675 + name = "serde_derive" 676 + version = "1.0.163" 677 + source = "registry+https://github.com/rust-lang/crates.io-index" 678 + checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" 679 + dependencies = [ 680 + "proc-macro2", 681 + "quote", 682 + "syn 2.0.18", 683 + ] 684 + 685 + [[package]] 686 + name = "serde_json" 687 + version = "1.0.96" 688 + source = "registry+https://github.com/rust-lang/crates.io-index" 689 + checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" 690 + dependencies = [ 691 + "itoa", 692 + "ryu", 693 + "serde", 694 + ] 695 + 696 + [[package]] 697 + name = "sharded-slab" 698 + version = "0.1.4" 699 + source = "registry+https://github.com/rust-lang/crates.io-index" 700 + checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" 701 + dependencies = [ 702 + "lazy_static", 703 + ] 704 + 705 + [[package]] 706 + name = "signal-hook-registry" 707 + version = "1.4.1" 708 + source = "registry+https://github.com/rust-lang/crates.io-index" 709 + checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 710 + dependencies = [ 711 + "libc", 712 + ] 713 + 714 + [[package]] 715 + name = "smallvec" 716 + version = "1.10.0" 717 + source = "registry+https://github.com/rust-lang/crates.io-index" 718 + checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 719 + 720 + [[package]] 721 + name = "socket2" 722 + version = "0.4.9" 723 + source = "registry+https://github.com/rust-lang/crates.io-index" 724 + checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" 725 + dependencies = [ 726 + "libc", 727 + "winapi", 728 + ] 729 + 730 + [[package]] 731 + name = "strsim" 732 + version = "0.10.0" 733 + source = "registry+https://github.com/rust-lang/crates.io-index" 734 + checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 735 + 736 + [[package]] 737 + name = "syn" 738 + version = "1.0.109" 739 + source = "registry+https://github.com/rust-lang/crates.io-index" 740 + checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 741 + dependencies = [ 742 + "proc-macro2", 743 + "quote", 744 + "unicode-ident", 745 + ] 746 + 747 + [[package]] 748 + name = "syn" 749 + version = "2.0.18" 750 + source = "registry+https://github.com/rust-lang/crates.io-index" 751 + checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" 752 + dependencies = [ 753 + "proc-macro2", 754 + "quote", 755 + "unicode-ident", 756 + ] 757 + 758 + [[package]] 759 + name = "sysinfo" 760 + version = "0.29.3" 761 + source = "registry+https://github.com/rust-lang/crates.io-index" 762 + checksum = "5bcd0346f90b6bc83526c7b180039a8acd26a5c848cc556d457f6472eb148122" 763 + dependencies = [ 764 + "cfg-if", 765 + "core-foundation-sys", 766 + "libc", 767 + "ntapi", 768 + "once_cell", 769 + "rayon", 770 + "winapi", 771 + ] 772 + 773 + [[package]] 774 + name = "thiserror" 775 + version = "1.0.40" 776 + source = "registry+https://github.com/rust-lang/crates.io-index" 777 + checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 778 + dependencies = [ 779 + "thiserror-impl", 780 + ] 781 + 782 + [[package]] 783 + name = "thiserror-impl" 784 + version = "1.0.40" 785 + source = "registry+https://github.com/rust-lang/crates.io-index" 786 + checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 787 + dependencies = [ 788 + "proc-macro2", 789 + "quote", 790 + "syn 2.0.18", 791 + ] 792 + 793 + [[package]] 794 + name = "thread_local" 795 + version = "1.1.7" 796 + source = "registry+https://github.com/rust-lang/crates.io-index" 797 + checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" 798 + dependencies = [ 799 + "cfg-if", 800 + "once_cell", 801 + ] 802 + 803 + [[package]] 804 + name = "tokio" 805 + version = "1.28.2" 806 + source = "registry+https://github.com/rust-lang/crates.io-index" 807 + checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" 808 + dependencies = [ 809 + "autocfg", 810 + "bytes", 811 + "libc", 812 + "mio", 813 + "num_cpus", 814 + "parking_lot", 815 + "pin-project-lite", 816 + "signal-hook-registry", 817 + "socket2", 818 + "tokio-macros", 819 + "windows-sys 0.48.0", 820 + ] 821 + 822 + [[package]] 823 + name = "tokio-macros" 824 + version = "2.1.0" 825 + source = "registry+https://github.com/rust-lang/crates.io-index" 826 + checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" 827 + dependencies = [ 828 + "proc-macro2", 829 + "quote", 830 + "syn 2.0.18", 831 + ] 832 + 833 + [[package]] 834 + name = "tracing" 835 + version = "0.1.37" 836 + source = "registry+https://github.com/rust-lang/crates.io-index" 837 + checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 838 + dependencies = [ 839 + "cfg-if", 840 + "pin-project-lite", 841 + "tracing-attributes", 842 + "tracing-core", 843 + ] 844 + 845 + [[package]] 846 + name = "tracing-attributes" 847 + version = "0.1.26" 848 + source = "registry+https://github.com/rust-lang/crates.io-index" 849 + checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" 850 + dependencies = [ 851 + "proc-macro2", 852 + "quote", 853 + "syn 2.0.18", 854 + ] 855 + 856 + [[package]] 857 + name = "tracing-core" 858 + version = "0.1.31" 859 + source = "registry+https://github.com/rust-lang/crates.io-index" 860 + checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" 861 + dependencies = [ 862 + "once_cell", 863 + "valuable", 864 + ] 865 + 866 + [[package]] 867 + name = "tracing-log" 868 + version = "0.1.3" 869 + source = "registry+https://github.com/rust-lang/crates.io-index" 870 + checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" 871 + dependencies = [ 872 + "lazy_static", 873 + "log", 874 + "tracing-core", 875 + ] 876 + 877 + [[package]] 878 + name = "tracing-subscriber" 879 + version = "0.3.17" 880 + source = "registry+https://github.com/rust-lang/crates.io-index" 881 + checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" 882 + dependencies = [ 883 + "nu-ansi-term", 884 + "sharded-slab", 885 + "smallvec", 886 + "thread_local", 887 + "tracing-core", 888 + "tracing-log", 889 + ] 890 + 891 + [[package]] 892 + name = "unescape" 893 + version = "0.1.0" 894 + source = "registry+https://github.com/rust-lang/crates.io-index" 895 + checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e" 896 + 897 + [[package]] 898 + name = "unicode-ident" 899 + version = "1.0.9" 900 + source = "registry+https://github.com/rust-lang/crates.io-index" 901 + checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" 902 + 903 + [[package]] 904 + name = "utf8parse" 905 + version = "0.2.1" 906 + source = "registry+https://github.com/rust-lang/crates.io-index" 907 + checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 908 + 909 + [[package]] 910 + name = "valuable" 911 + version = "0.1.0" 912 + source = "registry+https://github.com/rust-lang/crates.io-index" 913 + checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 914 + 915 + [[package]] 916 + name = "wasi" 917 + version = "0.11.0+wasi-snapshot-preview1" 918 + source = "registry+https://github.com/rust-lang/crates.io-index" 919 + checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 920 + 921 + [[package]] 922 + name = "which" 923 + version = "4.4.0" 924 + source = "registry+https://github.com/rust-lang/crates.io-index" 925 + checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" 926 + dependencies = [ 927 + "either", 928 + "libc", 929 + "once_cell", 930 + ] 931 + 932 + [[package]] 933 + name = "winapi" 934 + version = "0.3.9" 935 + source = "registry+https://github.com/rust-lang/crates.io-index" 936 + checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 937 + dependencies = [ 938 + "winapi-i686-pc-windows-gnu", 939 + "winapi-x86_64-pc-windows-gnu", 940 + ] 941 + 942 + [[package]] 943 + name = "winapi-i686-pc-windows-gnu" 944 + version = "0.4.0" 945 + source = "registry+https://github.com/rust-lang/crates.io-index" 946 + checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 947 + 948 + [[package]] 949 + name = "winapi-x86_64-pc-windows-gnu" 950 + version = "0.4.0" 951 + source = "registry+https://github.com/rust-lang/crates.io-index" 952 + checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 953 + 954 + [[package]] 955 + name = "windows-sys" 956 + version = "0.45.0" 957 + source = "registry+https://github.com/rust-lang/crates.io-index" 958 + checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 959 + dependencies = [ 960 + "windows-targets 0.42.2", 961 + ] 962 + 963 + [[package]] 964 + name = "windows-sys" 965 + version = "0.48.0" 966 + source = "registry+https://github.com/rust-lang/crates.io-index" 967 + checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 968 + dependencies = [ 969 + "windows-targets 0.48.0", 970 + ] 971 + 972 + [[package]] 973 + name = "windows-targets" 974 + version = "0.42.2" 975 + source = "registry+https://github.com/rust-lang/crates.io-index" 976 + checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 977 + dependencies = [ 978 + "windows_aarch64_gnullvm 0.42.2", 979 + "windows_aarch64_msvc 0.42.2", 980 + "windows_i686_gnu 0.42.2", 981 + "windows_i686_msvc 0.42.2", 982 + "windows_x86_64_gnu 0.42.2", 983 + "windows_x86_64_gnullvm 0.42.2", 984 + "windows_x86_64_msvc 0.42.2", 985 + ] 986 + 987 + [[package]] 988 + name = "windows-targets" 989 + version = "0.48.0" 990 + source = "registry+https://github.com/rust-lang/crates.io-index" 991 + checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" 992 + dependencies = [ 993 + "windows_aarch64_gnullvm 0.48.0", 994 + "windows_aarch64_msvc 0.48.0", 995 + "windows_i686_gnu 0.48.0", 996 + "windows_i686_msvc 0.48.0", 997 + "windows_x86_64_gnu 0.48.0", 998 + "windows_x86_64_gnullvm 0.48.0", 999 + "windows_x86_64_msvc 0.48.0", 1000 + ] 1001 + 1002 + [[package]] 1003 + name = "windows_aarch64_gnullvm" 1004 + version = "0.42.2" 1005 + source = "registry+https://github.com/rust-lang/crates.io-index" 1006 + checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 1007 + 1008 + [[package]] 1009 + name = "windows_aarch64_gnullvm" 1010 + version = "0.48.0" 1011 + source = "registry+https://github.com/rust-lang/crates.io-index" 1012 + checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" 1013 + 1014 + [[package]] 1015 + name = "windows_aarch64_msvc" 1016 + version = "0.42.2" 1017 + source = "registry+https://github.com/rust-lang/crates.io-index" 1018 + checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 1019 + 1020 + [[package]] 1021 + name = "windows_aarch64_msvc" 1022 + version = "0.48.0" 1023 + source = "registry+https://github.com/rust-lang/crates.io-index" 1024 + checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" 1025 + 1026 + [[package]] 1027 + name = "windows_i686_gnu" 1028 + version = "0.42.2" 1029 + source = "registry+https://github.com/rust-lang/crates.io-index" 1030 + checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 1031 + 1032 + [[package]] 1033 + name = "windows_i686_gnu" 1034 + version = "0.48.0" 1035 + source = "registry+https://github.com/rust-lang/crates.io-index" 1036 + checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" 1037 + 1038 + [[package]] 1039 + name = "windows_i686_msvc" 1040 + version = "0.42.2" 1041 + source = "registry+https://github.com/rust-lang/crates.io-index" 1042 + checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 1043 + 1044 + [[package]] 1045 + name = "windows_i686_msvc" 1046 + version = "0.48.0" 1047 + source = "registry+https://github.com/rust-lang/crates.io-index" 1048 + checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" 1049 + 1050 + [[package]] 1051 + name = "windows_x86_64_gnu" 1052 + version = "0.42.2" 1053 + source = "registry+https://github.com/rust-lang/crates.io-index" 1054 + checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 1055 + 1056 + [[package]] 1057 + name = "windows_x86_64_gnu" 1058 + version = "0.48.0" 1059 + source = "registry+https://github.com/rust-lang/crates.io-index" 1060 + checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" 1061 + 1062 + [[package]] 1063 + name = "windows_x86_64_gnullvm" 1064 + version = "0.42.2" 1065 + source = "registry+https://github.com/rust-lang/crates.io-index" 1066 + checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 1067 + 1068 + [[package]] 1069 + name = "windows_x86_64_gnullvm" 1070 + version = "0.48.0" 1071 + source = "registry+https://github.com/rust-lang/crates.io-index" 1072 + checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" 1073 + 1074 + [[package]] 1075 + name = "windows_x86_64_msvc" 1076 + version = "0.42.2" 1077 + source = "registry+https://github.com/rust-lang/crates.io-index" 1078 + checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1079 + 1080 + [[package]] 1081 + name = "windows_x86_64_msvc" 1082 + version = "0.48.0" 1083 + source = "registry+https://github.com/rust-lang/crates.io-index" 1084 + checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
+23
safir/Cargo.toml
··· 1 + [package] 2 + name = "safir" 3 + version = "0.6.0" 4 + edition = "2021" 5 + authors = ["Graham Keenan graham.keenan@outlook.com"] 6 + license = "MIT OR Apache-2.0" 7 + description = "Key/Value store to share values between different shell sessions" 8 + readme = "README.md" 9 + homepage = "https://github.com/Tyrannican/safir" 10 + repository = "https://github.com/Tyrannican/safir" 11 + keywords = ["cli", "terminal", "utility", "key-value", "store"] 12 + categories = ["command-line-utilities"] 13 + 14 + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 + 16 + [dependencies] 17 + clap = { version = "4.2.5" , features = ["derive"] } 18 + serde = { version = "1", features = ["derive"] } 19 + serde_json = "1" 20 + dirs = "5" 21 + colored = "2" 22 + rubin = "^0.3.1" 23 + tokio = { version = "1.28.2", features = ["full"] }
+45
safir/README.md
··· 1 + # Safir 2 + 3 + Simple CLI key/value store. 4 + 5 + Store key/value pairs in the terminal and retrieve them later for use like in different shell sessions. 6 + 7 + ## Install 8 + 9 + To install `safir`, run `cargo install safir`. 10 + 11 + To build from source, clone the repository and run: 12 + 13 + ```bash 14 + cargo build --release 15 + ``` 16 + 17 + Then move the binary to somewhere in your `$PATH` 18 + 19 + ## Usage 20 + 21 + When `safir` is run, it creates a store file in your `$HOME` directory (`$HOME/.safirstore/safirstore.json`). 22 + 23 + Run `safir --help` for usage: 24 + 25 + ```bash 26 + Key/Value store to share information between shell sessions 27 + 28 + Usage: safir <COMMAND> 29 + 30 + Commands: 31 + add Add a value to the store with the given key 32 + get Get a value from the store 33 + rm Remove values from the store 34 + alias Output the alias command for a key / value pair to be entered into a shell session 35 + export Output the export command for a key / value pair to be entered into a shell session 36 + clear Clear all keys/values from the store 37 + purge Purges the .safirstore directory, removing it and its contents 38 + mem Start or stop the Memcache (in-memory store) service 39 + help Print this message or the help of the given subcommand(s) 40 + 41 + Options: 42 + -h, --help Print help 43 + -V, --version Print version 44 + ``` 45 +
+44
safir/src/main.rs
··· 1 + mod cli; 2 + mod safir; 3 + mod utils; 4 + 5 + use cli::*; 6 + 7 + #[tokio::main] 8 + async fn main() -> std::io::Result<()> { 9 + let cli = Cli::parse(); 10 + let store_dir = utils::create_safir_directory().await?; 11 + let mut safir = safir::Safir::init(&store_dir).await?; 12 + 13 + match &cli.command { 14 + Commands::Add(args) => { 15 + safir 16 + .add_entry(args.key.clone(), args.value.clone()) 17 + .await?; 18 + } 19 + Commands::Get(args) => { 20 + if let Some(key) = &args.key { 21 + safir.get_entry(key.clone())?; 22 + } else { 23 + safir.display_all(); 24 + } 25 + } 26 + Commands::Rm(args) => { 27 + safir.remove_entry(args.key.clone()).await?; 28 + } 29 + Commands::Alias(args) => { 30 + safir.set_commands("alias", &args.keys); 31 + } 32 + Commands::Export(args) => { 33 + safir.set_commands("export", &args.keys); 34 + } 35 + Commands::Clear => { 36 + safir.clear_entries().await?; 37 + } 38 + Commands::Purge => { 39 + safir.purge(); 40 + } 41 + } 42 + 43 + Ok(()) 44 + }
+41
safir/src/utils.rs
··· 1 + use std::io::{self, Write}; 2 + use std::path::PathBuf; 3 + 4 + use colored::*; 5 + use tokio::fs; 6 + 7 + pub async fn create_safir_directory() -> io::Result<PathBuf> { 8 + let home_dir = dirs::home_dir().unwrap(); 9 + let store_path = home_dir.join(".safirstore"); 10 + fs::create_dir_all(&store_path).await?; 11 + 12 + Ok(store_path) 13 + } 14 + 15 + /// Formats and prints the message to stdout 16 + pub fn print_output(msg: &str) { 17 + println!("{}\n", msg); 18 + } 19 + 20 + /// Prints the Safirstore header 21 + pub fn print_header() { 22 + println!("{}", "--=Safirstore=--\n".bold()); 23 + } 24 + 25 + /// Confirmation dialog for important calls 26 + pub fn confirm_entry(msg: &str) -> bool { 27 + let mut answer = String::new(); 28 + print!("{} (y/n) ", msg); 29 + std::io::stdout().flush().expect("failed to flush buffer"); 30 + 31 + let _ = std::io::stdin() 32 + .read_line(&mut answer) 33 + .expect("unable to get input from user"); 34 + 35 + let answer = answer.trim().to_lowercase(); 36 + if answer == "y" { 37 + return true; 38 + } 39 + 40 + false 41 + }
-11
src/cfg.rs safir-mem/src/cfg.rs
··· 5 5 #[derive(Default, Serialize, Deserialize, Debug)] 6 6 pub struct SafirConfig { 7 7 pub memcache_pid: Option<u32>, 8 - pub memcache_flag: bool, 9 8 } 10 9 11 10 impl SafirConfig { ··· 16 15 pub async fn load(cfg_path: impl AsRef<Path>) -> Result<Self> { 17 16 let cfg = fs::read_to_string(cfg_path).await?; 18 17 Ok(serde_json::from_str(&cfg).expect("unable to deserialize safir config")) 19 - } 20 - 21 - pub fn pid(mut self, pid: Option<u32>) -> Self { 22 - self.memcache_pid = pid; 23 - self 24 - } 25 - 26 - pub fn set_memcache(mut self, state: bool) -> Self { 27 - self.memcache_flag = state; 28 - self 29 18 } 30 19 31 20 pub async fn write(&self, cfg_path: impl AsRef<Path>) -> Result<()> {
-23
src/cli.rs safir/src/cli.rs
··· 35 35 36 36 /// Purges the .safirstore directory, removing it and its contents 37 37 Purge, 38 - 39 - /// Start or stop the Memcache (in-memory store) service 40 - #[clap(subcommand)] 41 - Mem(MemArgs), 42 38 } 43 39 44 40 /// Arguments for adding a value to the store with a given key ··· 75 71 /// Name of the keys to display (e.g. alias / export) 76 72 pub keys: Vec<String>, 77 73 } 78 - 79 - /// Arguments for the Mem sub command 80 - #[derive(Subcommand, Debug)] 81 - pub enum MemArgs { 82 - /// Start the Safir Memcache server 83 - Start, 84 - 85 - /// Stop the Safir Memcache server 86 - Stop, 87 - 88 - /// Dump the Safir Memcache server to disk 89 - Dump(DumpArgs), 90 - } 91 - 92 - #[derive(Args, Debug)] 93 - pub struct DumpArgs { 94 - /// Path to save the store to 95 - pub path: String, 96 - }
-153
src/main.rs
··· 1 - mod cfg; 2 - mod cli; 3 - mod safir; 4 - mod utils; 5 - 6 - use cli::*; 7 - 8 - use std::process::{Command, Stdio}; 9 - 10 - #[tokio::main] 11 - async fn main() -> std::io::Result<()> { 12 - let cli = Cli::parse(); 13 - let store_dir = utils::create_safir_directory().await?; 14 - let safir_cfg = &store_dir.join("safir.cfg"); 15 - 16 - let mut cfg = utils::load_safir_config(&safir_cfg).await?; 17 - 18 - // Should probably only initialise when not using memcache but meh... 19 - // Easier this way 20 - let mut safir = safir::Safir::init(&store_dir).await?; 21 - let safir_mem = safir::SafirMemcache::new(); 22 - 23 - match &cli.command { 24 - Commands::Add(args) => { 25 - if cfg.memcache_flag { 26 - safir_mem.add_entry(&args.key, &args.value).await? 27 - } else { 28 - safir 29 - .add_entry(args.key.clone(), args.value.clone()) 30 - .await?; 31 - } 32 - } 33 - Commands::Get(args) => { 34 - if cfg.memcache_flag { 35 - if let Some(key) = &args.key { 36 - safir_mem.get_string(key).await?; 37 - } else { 38 - utils::print_header(); 39 - utils::print_output("A key is required for memcache GET command!"); 40 - } 41 - } else if let Some(key) = &args.key { 42 - safir.get_entry(key.clone())?; 43 - } else { 44 - safir.display_all(); 45 - } 46 - } 47 - Commands::Rm(args) => { 48 - if cfg.memcache_flag { 49 - safir_mem.remove_entry(args.key.clone()).await?; 50 - } else { 51 - safir.remove_entry(args.key.clone()).await?; 52 - } 53 - } 54 - Commands::Alias(args) => { 55 - if cfg.memcache_flag { 56 - safir_mem.set_commands("alias", &args.keys).await; 57 - } else { 58 - safir.set_commands("alias", &args.keys); 59 - } 60 - } 61 - Commands::Export(args) => { 62 - if cfg.memcache_flag { 63 - safir_mem.set_commands("export", &args.keys).await; 64 - } else { 65 - safir.set_commands("export", &args.keys); 66 - } 67 - } 68 - Commands::Clear => { 69 - if cfg.memcache_flag { 70 - safir_mem.clear_entries().await?; 71 - } else { 72 - safir.clear_entries().await?; 73 - } 74 - } 75 - Commands::Purge => { 76 - if !cfg.memcache_flag { 77 - safir.purge(); 78 - } 79 - } 80 - Commands::Mem(args) => match args { 81 - MemArgs::Start => { 82 - if !utils::check_rubin_installed() { 83 - eprintln!( 84 - "The Rubin binary must be installed to use this feature, please install it via cargo using `cargo install rubin-cli`" 85 - ); 86 - return Ok(()); 87 - } 88 - 89 - if let Some(pid) = cfg.memcache_pid { 90 - println!( 91 - "Safir memcache service is already running on 127.0.0.1:9876 - PID {}", 92 - pid 93 - ); 94 - 95 - return Ok(()); 96 - } 97 - 98 - let child = Command::new("rubin") 99 - .args(["server"]) 100 - .stdout(Stdio::null()) 101 - .stderr(Stdio::null()) 102 - .stdin(Stdio::null()) 103 - .spawn() 104 - .expect("unable to spawn child process"); 105 - 106 - let pid = child.id(); 107 - cfg = cfg.pid(Some(pid)).set_memcache(true); 108 - cfg.write(&safir_cfg).await?; 109 - println!( 110 - "Safir memcache service started at 127.0.0.1:9876 - PID {}", 111 - pid 112 - ); 113 - } 114 - MemArgs::Stop => { 115 - if !utils::check_rubin_installed() { 116 - eprintln!("The Rubin binary must be installed to use this feature, please install it via cargo using `cargo install rubin-cli`"); 117 - return Ok(()); 118 - } 119 - 120 - let pid = match cfg.memcache_pid { 121 - Some(pid) => pid, 122 - None => { 123 - println!("Safir memcache service does not seem to be running."); 124 - return Ok(()); 125 - } 126 - }; 127 - 128 - if let Err(err) = utils::kill_process(pid).await { 129 - eprintln!( 130 - "Safir memcache service failed to stop, manual removal may be necessary - {}", 131 - err 132 - ); 133 - } else { 134 - cfg = cfg.pid(None).set_memcache(false); 135 - cfg.write(&safir_cfg).await?; 136 - println!("Stopping Safir memcache service!"); 137 - } 138 - } 139 - MemArgs::Dump(args) => { 140 - if cfg.memcache_pid.is_none() { 141 - println!("Safir memcache service does not seem to be running"); 142 - return Ok(()); 143 - } 144 - 145 - if let Err(e) = safir_mem.dump_store(&args.path).await { 146 - eprintln!("unable to dump Safir memcache service: {}", e); 147 - } 148 - } 149 - }, 150 - } 151 - 152 - Ok(()) 153 - }
+1 -69
src/safir.rs safir/src/safir.rs
··· 13 13 use colored::*; 14 14 15 15 use crate::utils::{confirm_entry, print_header, print_output}; 16 - use rubin::{net::client::RubinClient, store::persistence::PersistentStore}; 16 + use rubin::store::persistence::PersistentStore; 17 17 18 18 /// Safir Store (fancy wrapper around reading and writing to a JSON file) 19 19 pub struct Safir { ··· 109 109 } 110 110 } 111 111 } 112 - 113 - pub struct SafirMemcache { 114 - client: RubinClient, 115 - } 116 - 117 - impl SafirMemcache { 118 - pub fn new() -> Self { 119 - Self { 120 - client: RubinClient::new("127.0.0.1", 9876), 121 - } 122 - } 123 - 124 - pub async fn add_entry(&self, key: &str, value: &str) -> Result<()> { 125 - self.client.insert_string(key, value).await?; 126 - Ok(()) 127 - } 128 - 129 - pub async fn get_string(&self, key: &str) -> Result<()> { 130 - print_header(); 131 - let output = if let Ok(val) = self.client.get_string(key).await { 132 - format!("{}: \"{}\"", key.bold().yellow(), val) 133 - } else { 134 - format!("{}: ", key.bold().yellow()) 135 - }; 136 - 137 - print_output(&output); 138 - 139 - Ok(()) 140 - } 141 - 142 - pub async fn remove_entry(&self, keys: Vec<String>) -> Result<()> { 143 - for key in &keys { 144 - self.client.remove_string(key).await?; 145 - } 146 - 147 - Ok(()) 148 - } 149 - 150 - pub async fn set_commands(&self, prefix: &str, keys: &Vec<String>) { 151 - print_header(); 152 - let prefix = match prefix { 153 - "alias" => "alias".bold().green(), 154 - "export" => "export".bold().magenta(), 155 - _ => prefix.bold(), 156 - }; 157 - 158 - for key in keys { 159 - if let Ok(value) = self.client.get_string(key).await { 160 - println!("{} {}=\"{}\"\n", prefix, key.bold().yellow(), value); 161 - } 162 - } 163 - } 164 - 165 - pub async fn clear_entries(&self) -> Result<()> { 166 - if confirm_entry("Are you sure you want to clear the store?") { 167 - self.client.clear_strings().await?; 168 - } 169 - 170 - Ok(()) 171 - } 172 - 173 - pub async fn dump_store(&self, path: &str) -> Result<()> { 174 - self.client.dump_store(path).await?; 175 - println!("Safir memcache dumped to {}", path); 176 - 177 - Ok(()) 178 - } 179 - }
+9
src/utils.rs safir-mem/src/utils.rs
··· 25 25 false 26 26 } 27 27 28 + pub fn is_safir_running(pid: Option<u32>) -> bool { 29 + match pid { 30 + Some(pid) => { 31 + return check_process_running(pid); 32 + } 33 + None => false, 34 + } 35 + } 36 + 28 37 pub async fn path_exists(path: impl AsRef<Path>) -> bool { 29 38 path.as_ref().exists() 30 39 }