├── .envrc ├── .github ├── CONTRIBUTING.md └── ISSUE_TEMPLATE │ └── panic-report.md ├── .gitignore ├── .rustfmt.toml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── flake.lock ├── flake.nix └── src ├── app ├── context.rs ├── event.rs ├── helper.rs ├── mod.rs └── ui │ ├── menu │ ├── authentication.rs │ ├── loading.rs │ └── mod.rs │ ├── mod.rs │ ├── popup │ ├── confirmation.rs │ ├── message.rs │ └── mod.rs │ ├── prelude.rs │ └── widget │ ├── button.rs │ ├── input.rs │ └── mod.rs ├── client ├── auth.rs ├── context.rs ├── event.rs ├── macros.rs └── mod.rs ├── error.rs ├── fs.rs └── main.rs /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please note: any contributions will be licensed under 4 | the repository license, which is the GNU GPL v3.0 license. 5 | 6 | ## Pull requests 7 | 8 | * Format commit messages to follow the following convensions 9 | 10 | ```error-be-gone 11 | (Section): (Brief summary) (Optional: Issue number if related) 12 | 13 | (Optional: Longer summary on what was changed or any additional information) 14 | ``` 15 | 16 | * Sections 17 | * `bug` - Bug fixed, link to issue at the end if there is one open 18 | * `ci` - Anything GitHub Actions related 19 | * `docs` - Anything documentation related 20 | * `feat` - New feature added 21 | * `impr` - Improved upon something without adding additional features 22 | 23 | * Valid examples 24 | * `feat: add popup config` 25 | * `bug: fix crash caused by menu size #1` 26 | * `ci: add format checking on commit/pr` 27 | * `impr: rewritten notification handler` 28 | 29 | * Invalid examples 30 | * `Feat: add popup config` 31 | * `feat: Add popup config` 32 | * `feat: add popup config.` 33 | * `feat: fix crash caused by menu size #1` 34 | * `bug: add popup config` 35 | 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/panic-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Panic report 3 | about: Create a report to help us improve Konoha 4 | title: "[BUG] " 5 | labels: bug - panic 6 | assignees: L3afMe 7 | 8 | --- 9 | 10 | **Description** 11 | 12 | 13 | **How To Reproduce** 14 | 20 | 21 | **Expected Behavior** 22 | 23 | 24 | **Additional Information** 25 | 26 | 27 |
28 | Backtrace 29 | 30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.direnv 3 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | array_width = 60 2 | attr_fn_like_width = 60 3 | binop_separator = "Front" 4 | blank_lines_lower_bound = 0 5 | blank_lines_upper_bound = 1 6 | brace_style = "PreferSameLine" 7 | chain_width = 60 8 | combine_control_expr = true 9 | comment_width = 60 10 | condense_wildcard_suffixes = true 11 | control_brace_style = "AlwaysSameLine" 12 | edition = "2018" 13 | empty_item_single_line = true 14 | enum_discrim_align_threshold = 12 15 | error_on_line_overflow = true 16 | error_on_unformatted = true 17 | fn_call_width = 60 18 | fn_single_line = false 19 | force_multiline_blocks = false 20 | format_code_in_doc_comments = true 21 | format_macro_matchers = true 22 | format_strings = false 23 | group_imports = "StdExternalCrate" 24 | hard_tabs = false 25 | hide_parse_errors = false 26 | ignore = [] 27 | imports_indent = "Block" 28 | imports_layout = "Mixed" 29 | indent_style = "Block" 30 | inline_attribute_width = 0 31 | match_arm_blocks = true 32 | match_arm_leading_pipes = "Never" 33 | match_block_trailing_comma = true 34 | max_width = 80 35 | imports_granularity = "Crate" 36 | newline_style = "Unix" 37 | normalize_comments = true 38 | normalize_doc_attributes = true 39 | overflow_delimited_expr = true 40 | remove_nested_parens = true 41 | reorder_impl_items = true 42 | reorder_imports = true 43 | reorder_modules = true 44 | single_line_if_else_max_width = 60 45 | space_after_colon = true 46 | space_before_colon = false 47 | spaces_around_ranges = false 48 | struct_field_align_threshold = 12 49 | struct_lit_single_line = false 50 | struct_lit_width = 0 51 | struct_variant_width = 0 52 | tab_spaces = 4 53 | trailing_comma = "Vertical" 54 | trailing_semicolon = true 55 | type_punctuation_density = "Wide" 56 | unstable_features = true 57 | use_field_init_shorthand = true 58 | use_try_shorthand = true 59 | where_single_line = false 60 | wrap_comments = true 61 | -------------------------------------------------------------------------------- /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 = "addr2line" 7 | version = "0.15.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" 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]] 21 | name = "aead" 22 | version = "0.3.2" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" 25 | dependencies = [ 26 | "generic-array", 27 | ] 28 | 29 | [[package]] 30 | name = "aes" 31 | version = "0.6.0" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" 34 | dependencies = [ 35 | "aes-soft", 36 | "aesni", 37 | "cipher", 38 | ] 39 | 40 | [[package]] 41 | name = "aes-ctr" 42 | version = "0.6.0" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" 45 | dependencies = [ 46 | "aes-soft", 47 | "aesni", 48 | "cipher", 49 | "ctr", 50 | ] 51 | 52 | [[package]] 53 | name = "aes-gcm" 54 | version = "0.8.0" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" 57 | dependencies = [ 58 | "aead", 59 | "aes", 60 | "cipher", 61 | "ctr", 62 | "ghash", 63 | "subtle", 64 | ] 65 | 66 | [[package]] 67 | name = "aes-soft" 68 | version = "0.6.4" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" 71 | dependencies = [ 72 | "cipher", 73 | "opaque-debug", 74 | ] 75 | 76 | [[package]] 77 | name = "aesni" 78 | version = "0.10.0" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" 81 | dependencies = [ 82 | "cipher", 83 | "opaque-debug", 84 | ] 85 | 86 | [[package]] 87 | name = "aho-corasick" 88 | version = "0.7.18" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 91 | dependencies = [ 92 | "memchr", 93 | ] 94 | 95 | [[package]] 96 | name = "ansi_term" 97 | version = "0.11.0" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 100 | dependencies = [ 101 | "winapi", 102 | ] 103 | 104 | [[package]] 105 | name = "ansi_term" 106 | version = "0.12.1" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 109 | dependencies = [ 110 | "winapi", 111 | ] 112 | 113 | [[package]] 114 | name = "assign" 115 | version = "1.1.1" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002" 118 | 119 | [[package]] 120 | name = "async-trait" 121 | version = "0.1.50" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" 124 | dependencies = [ 125 | "proc-macro2", 126 | "quote", 127 | "syn", 128 | ] 129 | 130 | [[package]] 131 | name = "atomic" 132 | version = "0.5.0" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" 135 | dependencies = [ 136 | "autocfg", 137 | ] 138 | 139 | [[package]] 140 | name = "atty" 141 | version = "0.2.14" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 144 | dependencies = [ 145 | "hermit-abi", 146 | "libc", 147 | "winapi", 148 | ] 149 | 150 | [[package]] 151 | name = "autocfg" 152 | version = "1.0.1" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 155 | 156 | [[package]] 157 | name = "backoff" 158 | version = "0.3.0" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "9fe17f59a06fe8b87a6fc8bf53bb70b3aba76d7685f432487a68cd5552853625" 161 | dependencies = [ 162 | "futures-core", 163 | "getrandom", 164 | "instant", 165 | "pin-project", 166 | "rand", 167 | "tokio", 168 | ] 169 | 170 | [[package]] 171 | name = "backtrace" 172 | version = "0.3.59" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" 175 | dependencies = [ 176 | "addr2line", 177 | "cc", 178 | "cfg-if", 179 | "libc", 180 | "miniz_oxide", 181 | "object", 182 | "rustc-demangle", 183 | ] 184 | 185 | [[package]] 186 | name = "base-x" 187 | version = "0.2.8" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" 190 | 191 | [[package]] 192 | name = "base64" 193 | version = "0.13.0" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 196 | 197 | [[package]] 198 | name = "bitflags" 199 | version = "1.2.1" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 202 | 203 | [[package]] 204 | name = "block-buffer" 205 | version = "0.9.0" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" 208 | dependencies = [ 209 | "generic-array", 210 | ] 211 | 212 | [[package]] 213 | name = "bumpalo" 214 | version = "3.6.1" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" 217 | 218 | [[package]] 219 | name = "byteorder" 220 | version = "1.4.3" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 223 | 224 | [[package]] 225 | name = "bytes" 226 | version = "1.0.1" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" 229 | 230 | [[package]] 231 | name = "cassowary" 232 | version = "0.3.0" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" 235 | 236 | [[package]] 237 | name = "cc" 238 | version = "1.0.68" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" 241 | 242 | [[package]] 243 | name = "cfg-if" 244 | version = "1.0.0" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 247 | 248 | [[package]] 249 | name = "chacha20" 250 | version = "0.6.0" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "ed8738f14471a99f0e316c327e68fc82a3611cc2895fcb604b89eedaf8f39d95" 253 | dependencies = [ 254 | "cipher", 255 | "zeroize", 256 | ] 257 | 258 | [[package]] 259 | name = "chacha20poly1305" 260 | version = "0.7.1" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "af1fc18e6d90c40164bf6c317476f2a98f04661e310e79830366b7e914c58a8e" 263 | dependencies = [ 264 | "aead", 265 | "chacha20", 266 | "cipher", 267 | "poly1305", 268 | "zeroize", 269 | ] 270 | 271 | [[package]] 272 | name = "chrono" 273 | version = "0.4.19" 274 | source = "registry+https://github.com/rust-lang/crates.io-index" 275 | checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" 276 | dependencies = [ 277 | "libc", 278 | "num-integer", 279 | "num-traits", 280 | "time 0.1.43", 281 | "winapi", 282 | ] 283 | 284 | [[package]] 285 | name = "cipher" 286 | version = "0.2.5" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" 289 | dependencies = [ 290 | "generic-array", 291 | ] 292 | 293 | [[package]] 294 | name = "clap" 295 | version = "2.33.3" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" 298 | dependencies = [ 299 | "ansi_term 0.11.0", 300 | "atty", 301 | "bitflags", 302 | "strsim", 303 | "textwrap", 304 | "unicode-width", 305 | "vec_map", 306 | ] 307 | 308 | [[package]] 309 | name = "cmake" 310 | version = "0.1.45" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" 313 | dependencies = [ 314 | "cc", 315 | ] 316 | 317 | [[package]] 318 | name = "const_fn" 319 | version = "0.4.8" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" 322 | 323 | [[package]] 324 | name = "core-foundation" 325 | version = "0.9.1" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" 328 | dependencies = [ 329 | "core-foundation-sys", 330 | "libc", 331 | ] 332 | 333 | [[package]] 334 | name = "core-foundation-sys" 335 | version = "0.8.2" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" 338 | 339 | [[package]] 340 | name = "cpufeatures" 341 | version = "0.1.4" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" 344 | dependencies = [ 345 | "libc", 346 | ] 347 | 348 | [[package]] 349 | name = "cpuid-bool" 350 | version = "0.2.0" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" 353 | 354 | [[package]] 355 | name = "crc32fast" 356 | version = "1.2.1" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" 359 | dependencies = [ 360 | "cfg-if", 361 | ] 362 | 363 | [[package]] 364 | name = "crossbeam-epoch" 365 | version = "0.9.4" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "52fb27eab85b17fbb9f6fd667089e07d6a2eb8743d02639ee7f6a7a7729c9c94" 368 | dependencies = [ 369 | "cfg-if", 370 | "crossbeam-utils", 371 | "lazy_static", 372 | "memoffset", 373 | "scopeguard", 374 | ] 375 | 376 | [[package]] 377 | name = "crossbeam-utils" 378 | version = "0.8.4" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" 381 | dependencies = [ 382 | "autocfg", 383 | "cfg-if", 384 | "lazy_static", 385 | ] 386 | 387 | [[package]] 388 | name = "crossterm" 389 | version = "0.19.0" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "7c36c10130df424b2f3552fcc2ddcd9b28a27b1e54b358b45874f88d1ca6888c" 392 | dependencies = [ 393 | "bitflags", 394 | "crossterm_winapi", 395 | "lazy_static", 396 | "libc", 397 | "mio", 398 | "parking_lot", 399 | "signal-hook", 400 | "winapi", 401 | ] 402 | 403 | [[package]] 404 | name = "crossterm_winapi" 405 | version = "0.7.0" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "0da8964ace4d3e4a044fd027919b2237000b24315a37c916f61809f1ff2140b9" 408 | dependencies = [ 409 | "winapi", 410 | ] 411 | 412 | [[package]] 413 | name = "crypto-mac" 414 | version = "0.10.0" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" 417 | dependencies = [ 418 | "generic-array", 419 | "subtle", 420 | ] 421 | 422 | [[package]] 423 | name = "ctr" 424 | version = "0.6.0" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" 427 | dependencies = [ 428 | "cipher", 429 | ] 430 | 431 | [[package]] 432 | name = "dashmap" 433 | version = "4.0.2" 434 | source = "registry+https://github.com/rust-lang/crates.io-index" 435 | checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" 436 | dependencies = [ 437 | "cfg-if", 438 | "num_cpus", 439 | ] 440 | 441 | [[package]] 442 | name = "digest" 443 | version = "0.9.0" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 446 | dependencies = [ 447 | "generic-array", 448 | ] 449 | 450 | [[package]] 451 | name = "dirs" 452 | version = "3.0.2" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" 455 | dependencies = [ 456 | "dirs-sys", 457 | ] 458 | 459 | [[package]] 460 | name = "dirs-sys" 461 | version = "0.3.6" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" 464 | dependencies = [ 465 | "libc", 466 | "redox_users", 467 | "winapi", 468 | ] 469 | 470 | [[package]] 471 | name = "discard" 472 | version = "1.0.4" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" 475 | 476 | [[package]] 477 | name = "encoding_rs" 478 | version = "0.8.28" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" 481 | dependencies = [ 482 | "cfg-if", 483 | ] 484 | 485 | [[package]] 486 | name = "fnv" 487 | version = "1.0.7" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 490 | 491 | [[package]] 492 | name = "foreign-types" 493 | version = "0.3.2" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 496 | dependencies = [ 497 | "foreign-types-shared", 498 | ] 499 | 500 | [[package]] 501 | name = "foreign-types-shared" 502 | version = "0.1.1" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 505 | 506 | [[package]] 507 | name = "form_urlencoded" 508 | version = "1.0.1" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 511 | dependencies = [ 512 | "matches", 513 | "percent-encoding", 514 | ] 515 | 516 | [[package]] 517 | name = "fs2" 518 | version = "0.4.3" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" 521 | dependencies = [ 522 | "libc", 523 | "winapi", 524 | ] 525 | 526 | [[package]] 527 | name = "futures" 528 | version = "0.3.15" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" 531 | dependencies = [ 532 | "futures-channel", 533 | "futures-core", 534 | "futures-executor", 535 | "futures-io", 536 | "futures-sink", 537 | "futures-task", 538 | "futures-util", 539 | ] 540 | 541 | [[package]] 542 | name = "futures-channel" 543 | version = "0.3.15" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" 546 | dependencies = [ 547 | "futures-core", 548 | "futures-sink", 549 | ] 550 | 551 | [[package]] 552 | name = "futures-core" 553 | version = "0.3.15" 554 | source = "registry+https://github.com/rust-lang/crates.io-index" 555 | checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" 556 | 557 | [[package]] 558 | name = "futures-executor" 559 | version = "0.3.15" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" 562 | dependencies = [ 563 | "futures-core", 564 | "futures-task", 565 | "futures-util", 566 | ] 567 | 568 | [[package]] 569 | name = "futures-io" 570 | version = "0.3.15" 571 | source = "registry+https://github.com/rust-lang/crates.io-index" 572 | checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" 573 | 574 | [[package]] 575 | name = "futures-locks" 576 | version = "0.6.0" 577 | source = "registry+https://github.com/rust-lang/crates.io-index" 578 | checksum = "50c4e684ddb2d8a4db5ca8a02b35156da129674ba4412b6f528698d58c594954" 579 | dependencies = [ 580 | "futures", 581 | ] 582 | 583 | [[package]] 584 | name = "futures-macro" 585 | version = "0.3.15" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" 588 | dependencies = [ 589 | "autocfg", 590 | "proc-macro-hack", 591 | "proc-macro2", 592 | "quote", 593 | "syn", 594 | ] 595 | 596 | [[package]] 597 | name = "futures-sink" 598 | version = "0.3.15" 599 | source = "registry+https://github.com/rust-lang/crates.io-index" 600 | checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" 601 | 602 | [[package]] 603 | name = "futures-task" 604 | version = "0.3.15" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" 607 | 608 | [[package]] 609 | name = "futures-timer" 610 | version = "3.0.2" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" 613 | dependencies = [ 614 | "gloo-timers", 615 | "send_wrapper", 616 | ] 617 | 618 | [[package]] 619 | name = "futures-util" 620 | version = "0.3.15" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" 623 | dependencies = [ 624 | "autocfg", 625 | "futures-channel", 626 | "futures-core", 627 | "futures-io", 628 | "futures-macro", 629 | "futures-sink", 630 | "futures-task", 631 | "memchr", 632 | "pin-project-lite", 633 | "pin-utils", 634 | "proc-macro-hack", 635 | "proc-macro-nested", 636 | "slab", 637 | ] 638 | 639 | [[package]] 640 | name = "fxhash" 641 | version = "0.2.1" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" 644 | dependencies = [ 645 | "byteorder", 646 | ] 647 | 648 | [[package]] 649 | name = "generic-array" 650 | version = "0.14.4" 651 | source = "registry+https://github.com/rust-lang/crates.io-index" 652 | checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" 653 | dependencies = [ 654 | "typenum", 655 | "version_check", 656 | ] 657 | 658 | [[package]] 659 | name = "getrandom" 660 | version = "0.2.3" 661 | source = "registry+https://github.com/rust-lang/crates.io-index" 662 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 663 | dependencies = [ 664 | "cfg-if", 665 | "js-sys", 666 | "libc", 667 | "wasi", 668 | "wasm-bindgen", 669 | ] 670 | 671 | [[package]] 672 | name = "ghash" 673 | version = "0.3.1" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" 676 | dependencies = [ 677 | "opaque-debug", 678 | "polyval", 679 | ] 680 | 681 | [[package]] 682 | name = "gimli" 683 | version = "0.24.0" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" 686 | 687 | [[package]] 688 | name = "gloo-timers" 689 | version = "0.2.1" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" 692 | dependencies = [ 693 | "futures-channel", 694 | "futures-core", 695 | "js-sys", 696 | "wasm-bindgen", 697 | "web-sys", 698 | ] 699 | 700 | [[package]] 701 | name = "h2" 702 | version = "0.3.3" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" 705 | dependencies = [ 706 | "bytes", 707 | "fnv", 708 | "futures-core", 709 | "futures-sink", 710 | "futures-util", 711 | "http", 712 | "indexmap", 713 | "slab", 714 | "tokio", 715 | "tokio-util", 716 | "tracing", 717 | ] 718 | 719 | [[package]] 720 | name = "hashbrown" 721 | version = "0.9.1" 722 | source = "registry+https://github.com/rust-lang/crates.io-index" 723 | checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" 724 | 725 | [[package]] 726 | name = "hermit-abi" 727 | version = "0.1.18" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" 730 | dependencies = [ 731 | "libc", 732 | ] 733 | 734 | [[package]] 735 | name = "hmac" 736 | version = "0.10.1" 737 | source = "registry+https://github.com/rust-lang/crates.io-index" 738 | checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" 739 | dependencies = [ 740 | "crypto-mac", 741 | "digest", 742 | ] 743 | 744 | [[package]] 745 | name = "http" 746 | version = "0.2.4" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" 749 | dependencies = [ 750 | "bytes", 751 | "fnv", 752 | "itoa", 753 | ] 754 | 755 | [[package]] 756 | name = "http-body" 757 | version = "0.4.2" 758 | source = "registry+https://github.com/rust-lang/crates.io-index" 759 | checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" 760 | dependencies = [ 761 | "bytes", 762 | "http", 763 | "pin-project-lite", 764 | ] 765 | 766 | [[package]] 767 | name = "httparse" 768 | version = "1.4.1" 769 | source = "registry+https://github.com/rust-lang/crates.io-index" 770 | checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" 771 | 772 | [[package]] 773 | name = "httpdate" 774 | version = "1.0.1" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" 777 | 778 | [[package]] 779 | name = "hyper" 780 | version = "0.14.8" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "d3f71a7eea53a3f8257a7b4795373ff886397178cd634430ea94e12d7fe4fe34" 783 | dependencies = [ 784 | "bytes", 785 | "futures-channel", 786 | "futures-core", 787 | "futures-util", 788 | "h2", 789 | "http", 790 | "http-body", 791 | "httparse", 792 | "httpdate", 793 | "itoa", 794 | "pin-project", 795 | "socket2", 796 | "tokio", 797 | "tower-service", 798 | "tracing", 799 | "want", 800 | ] 801 | 802 | [[package]] 803 | name = "hyper-tls" 804 | version = "0.5.0" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" 807 | dependencies = [ 808 | "bytes", 809 | "hyper", 810 | "native-tls", 811 | "tokio", 812 | "tokio-native-tls", 813 | ] 814 | 815 | [[package]] 816 | name = "idna" 817 | version = "0.2.3" 818 | source = "registry+https://github.com/rust-lang/crates.io-index" 819 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 820 | dependencies = [ 821 | "matches", 822 | "unicode-bidi", 823 | "unicode-normalization", 824 | ] 825 | 826 | [[package]] 827 | name = "indexmap" 828 | version = "1.6.2" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" 831 | dependencies = [ 832 | "autocfg", 833 | "hashbrown", 834 | "serde", 835 | ] 836 | 837 | [[package]] 838 | name = "instant" 839 | version = "0.1.9" 840 | source = "registry+https://github.com/rust-lang/crates.io-index" 841 | checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" 842 | dependencies = [ 843 | "cfg-if", 844 | "js-sys", 845 | "time 0.2.26", 846 | "wasm-bindgen", 847 | "web-sys", 848 | ] 849 | 850 | [[package]] 851 | name = "ipnet" 852 | version = "2.3.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" 855 | 856 | [[package]] 857 | name = "itoa" 858 | version = "0.4.7" 859 | source = "registry+https://github.com/rust-lang/crates.io-index" 860 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" 861 | 862 | [[package]] 863 | name = "js-sys" 864 | version = "0.3.51" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" 867 | dependencies = [ 868 | "wasm-bindgen", 869 | ] 870 | 871 | [[package]] 872 | name = "js_int" 873 | version = "0.2.0" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "fcae89e078a96b781b38f36225bb3a174b8f6e905dfec550dd16a13539c82acc" 876 | dependencies = [ 877 | "serde", 878 | ] 879 | 880 | [[package]] 881 | name = "konoha" 882 | version = "0.1.0" 883 | dependencies = [ 884 | "backtrace", 885 | "chrono", 886 | "clap", 887 | "crossterm", 888 | "dirs", 889 | "lazy_static", 890 | "matrix-sdk", 891 | "os_info", 892 | "regex", 893 | "reqwest", 894 | "serde", 895 | "serde_json", 896 | "tokio", 897 | "tracing-subscriber", 898 | "tui", 899 | "url", 900 | "urlencoding", 901 | ] 902 | 903 | [[package]] 904 | name = "lazy_static" 905 | version = "1.4.0" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 908 | 909 | [[package]] 910 | name = "libc" 911 | version = "0.2.94" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" 914 | 915 | [[package]] 916 | name = "lock_api" 917 | version = "0.4.4" 918 | source = "registry+https://github.com/rust-lang/crates.io-index" 919 | checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" 920 | dependencies = [ 921 | "scopeguard", 922 | ] 923 | 924 | [[package]] 925 | name = "log" 926 | version = "0.4.14" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 929 | dependencies = [ 930 | "cfg-if", 931 | ] 932 | 933 | [[package]] 934 | name = "maplit" 935 | version = "1.0.2" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" 938 | 939 | [[package]] 940 | name = "matchers" 941 | version = "0.0.1" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" 944 | dependencies = [ 945 | "regex-automata", 946 | ] 947 | 948 | [[package]] 949 | name = "matches" 950 | version = "0.1.8" 951 | source = "registry+https://github.com/rust-lang/crates.io-index" 952 | checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 953 | 954 | [[package]] 955 | name = "matrix-sdk" 956 | version = "0.2.0" 957 | source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=eece920#eece9209534865d2871c240552ad82291dda6d68" 958 | dependencies = [ 959 | "backoff", 960 | "bytes", 961 | "dashmap", 962 | "futures", 963 | "futures-timer", 964 | "http", 965 | "matrix-sdk-base", 966 | "matrix-sdk-common", 967 | "mime", 968 | "reqwest", 969 | "serde_json", 970 | "thiserror", 971 | "tokio", 972 | "tracing", 973 | "tracing-futures", 974 | "url", 975 | "zeroize", 976 | ] 977 | 978 | [[package]] 979 | name = "matrix-sdk-base" 980 | version = "0.2.0" 981 | source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=eece920#eece9209534865d2871c240552ad82291dda6d68" 982 | dependencies = [ 983 | "chacha20poly1305", 984 | "dashmap", 985 | "futures", 986 | "hmac", 987 | "matrix-sdk-common", 988 | "matrix-sdk-crypto", 989 | "pbkdf2", 990 | "rand", 991 | "serde", 992 | "serde_json", 993 | "sha2", 994 | "sled", 995 | "thiserror", 996 | "tokio", 997 | "tracing", 998 | "zeroize", 999 | ] 1000 | 1001 | [[package]] 1002 | name = "matrix-sdk-common" 1003 | version = "0.2.0" 1004 | source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=eece920#eece9209534865d2871c240552ad82291dda6d68" 1005 | dependencies = [ 1006 | "async-trait", 1007 | "futures", 1008 | "futures-locks", 1009 | "instant", 1010 | "ruma", 1011 | "serde", 1012 | "tokio", 1013 | "uuid", 1014 | "wasm-bindgen-futures", 1015 | ] 1016 | 1017 | [[package]] 1018 | name = "matrix-sdk-crypto" 1019 | version = "0.2.0" 1020 | source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=eece920#eece9209534865d2871c240552ad82291dda6d68" 1021 | dependencies = [ 1022 | "aes-ctr", 1023 | "aes-gcm", 1024 | "atomic", 1025 | "base64", 1026 | "byteorder", 1027 | "dashmap", 1028 | "futures", 1029 | "getrandom", 1030 | "hmac", 1031 | "matrix-sdk-common", 1032 | "olm-rs", 1033 | "pbkdf2", 1034 | "serde", 1035 | "serde_json", 1036 | "sha2", 1037 | "sled", 1038 | "thiserror", 1039 | "tracing", 1040 | "zeroize", 1041 | ] 1042 | 1043 | [[package]] 1044 | name = "memchr" 1045 | version = "2.4.0" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" 1048 | 1049 | [[package]] 1050 | name = "memoffset" 1051 | version = "0.6.3" 1052 | source = "registry+https://github.com/rust-lang/crates.io-index" 1053 | checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" 1054 | dependencies = [ 1055 | "autocfg", 1056 | ] 1057 | 1058 | [[package]] 1059 | name = "mime" 1060 | version = "0.3.16" 1061 | source = "registry+https://github.com/rust-lang/crates.io-index" 1062 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 1063 | 1064 | [[package]] 1065 | name = "miniz_oxide" 1066 | version = "0.4.4" 1067 | source = "registry+https://github.com/rust-lang/crates.io-index" 1068 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 1069 | dependencies = [ 1070 | "adler", 1071 | "autocfg", 1072 | ] 1073 | 1074 | [[package]] 1075 | name = "mio" 1076 | version = "0.7.11" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" 1079 | dependencies = [ 1080 | "libc", 1081 | "log", 1082 | "miow", 1083 | "ntapi", 1084 | "winapi", 1085 | ] 1086 | 1087 | [[package]] 1088 | name = "miow" 1089 | version = "0.3.7" 1090 | source = "registry+https://github.com/rust-lang/crates.io-index" 1091 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 1092 | dependencies = [ 1093 | "winapi", 1094 | ] 1095 | 1096 | [[package]] 1097 | name = "native-tls" 1098 | version = "0.2.7" 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" 1100 | checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" 1101 | dependencies = [ 1102 | "lazy_static", 1103 | "libc", 1104 | "log", 1105 | "openssl", 1106 | "openssl-probe", 1107 | "openssl-sys", 1108 | "schannel", 1109 | "security-framework", 1110 | "security-framework-sys", 1111 | "tempfile", 1112 | ] 1113 | 1114 | [[package]] 1115 | name = "ntapi" 1116 | version = "0.3.6" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 1119 | dependencies = [ 1120 | "winapi", 1121 | ] 1122 | 1123 | [[package]] 1124 | name = "num-integer" 1125 | version = "0.1.44" 1126 | source = "registry+https://github.com/rust-lang/crates.io-index" 1127 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 1128 | dependencies = [ 1129 | "autocfg", 1130 | "num-traits", 1131 | ] 1132 | 1133 | [[package]] 1134 | name = "num-traits" 1135 | version = "0.2.14" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 1138 | dependencies = [ 1139 | "autocfg", 1140 | ] 1141 | 1142 | [[package]] 1143 | name = "num_cpus" 1144 | version = "1.13.0" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 1147 | dependencies = [ 1148 | "hermit-abi", 1149 | "libc", 1150 | ] 1151 | 1152 | [[package]] 1153 | name = "object" 1154 | version = "0.24.0" 1155 | source = "registry+https://github.com/rust-lang/crates.io-index" 1156 | checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" 1157 | 1158 | [[package]] 1159 | name = "olm-rs" 1160 | version = "1.0.1" 1161 | source = "registry+https://github.com/rust-lang/crates.io-index" 1162 | checksum = "8962a1fc909accf520991dcda872888554ecf16320097e02d3bd9981844a24ae" 1163 | dependencies = [ 1164 | "getrandom", 1165 | "olm-sys", 1166 | "serde", 1167 | "serde_json", 1168 | "zeroize", 1169 | ] 1170 | 1171 | [[package]] 1172 | name = "olm-sys" 1173 | version = "1.1.1" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "9d29b3debd2916908e725d936ef5722d014a338a57c74e59dbf4c8c43855254d" 1176 | dependencies = [ 1177 | "cmake", 1178 | ] 1179 | 1180 | [[package]] 1181 | name = "once_cell" 1182 | version = "1.7.2" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" 1185 | 1186 | [[package]] 1187 | name = "opaque-debug" 1188 | version = "0.3.0" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 1191 | 1192 | [[package]] 1193 | name = "openssl" 1194 | version = "0.10.34" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "6d7830286ad6a3973c0f1d9b73738f69c76b739301d0229c4b96501695cbe4c8" 1197 | dependencies = [ 1198 | "bitflags", 1199 | "cfg-if", 1200 | "foreign-types", 1201 | "libc", 1202 | "once_cell", 1203 | "openssl-sys", 1204 | ] 1205 | 1206 | [[package]] 1207 | name = "openssl-probe" 1208 | version = "0.1.4" 1209 | source = "registry+https://github.com/rust-lang/crates.io-index" 1210 | checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" 1211 | 1212 | [[package]] 1213 | name = "openssl-sys" 1214 | version = "0.9.63" 1215 | source = "registry+https://github.com/rust-lang/crates.io-index" 1216 | checksum = "b6b0d6fb7d80f877617dfcb014e605e2b5ab2fb0afdf27935219bb6bd984cb98" 1217 | dependencies = [ 1218 | "autocfg", 1219 | "cc", 1220 | "libc", 1221 | "pkg-config", 1222 | "vcpkg", 1223 | ] 1224 | 1225 | [[package]] 1226 | name = "os_info" 1227 | version = "3.0.6" 1228 | source = "registry+https://github.com/rust-lang/crates.io-index" 1229 | checksum = "b3d2536ab8ff7605e8dc7044ec2f3eb0d49750cb559af9e5373c4564a3706cdd" 1230 | dependencies = [ 1231 | "log", 1232 | "serde", 1233 | "winapi", 1234 | ] 1235 | 1236 | [[package]] 1237 | name = "parking_lot" 1238 | version = "0.11.1" 1239 | source = "registry+https://github.com/rust-lang/crates.io-index" 1240 | checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" 1241 | dependencies = [ 1242 | "instant", 1243 | "lock_api", 1244 | "parking_lot_core", 1245 | ] 1246 | 1247 | [[package]] 1248 | name = "parking_lot_core" 1249 | version = "0.8.3" 1250 | source = "registry+https://github.com/rust-lang/crates.io-index" 1251 | checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" 1252 | dependencies = [ 1253 | "cfg-if", 1254 | "instant", 1255 | "libc", 1256 | "redox_syscall", 1257 | "smallvec", 1258 | "winapi", 1259 | ] 1260 | 1261 | [[package]] 1262 | name = "paste" 1263 | version = "1.0.5" 1264 | source = "registry+https://github.com/rust-lang/crates.io-index" 1265 | checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" 1266 | 1267 | [[package]] 1268 | name = "pbkdf2" 1269 | version = "0.6.0" 1270 | source = "registry+https://github.com/rust-lang/crates.io-index" 1271 | checksum = "b3b8c0d71734018084da0c0354193a5edfb81b20d2d57a92c5b154aefc554a4a" 1272 | dependencies = [ 1273 | "crypto-mac", 1274 | ] 1275 | 1276 | [[package]] 1277 | name = "percent-encoding" 1278 | version = "2.1.0" 1279 | source = "registry+https://github.com/rust-lang/crates.io-index" 1280 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 1281 | 1282 | [[package]] 1283 | name = "pin-project" 1284 | version = "1.0.7" 1285 | source = "registry+https://github.com/rust-lang/crates.io-index" 1286 | checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" 1287 | dependencies = [ 1288 | "pin-project-internal", 1289 | ] 1290 | 1291 | [[package]] 1292 | name = "pin-project-internal" 1293 | version = "1.0.7" 1294 | source = "registry+https://github.com/rust-lang/crates.io-index" 1295 | checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" 1296 | dependencies = [ 1297 | "proc-macro2", 1298 | "quote", 1299 | "syn", 1300 | ] 1301 | 1302 | [[package]] 1303 | name = "pin-project-lite" 1304 | version = "0.2.6" 1305 | source = "registry+https://github.com/rust-lang/crates.io-index" 1306 | checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" 1307 | 1308 | [[package]] 1309 | name = "pin-utils" 1310 | version = "0.1.0" 1311 | source = "registry+https://github.com/rust-lang/crates.io-index" 1312 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 1313 | 1314 | [[package]] 1315 | name = "pkg-config" 1316 | version = "0.3.19" 1317 | source = "registry+https://github.com/rust-lang/crates.io-index" 1318 | checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" 1319 | 1320 | [[package]] 1321 | name = "poly1305" 1322 | version = "0.6.2" 1323 | source = "registry+https://github.com/rust-lang/crates.io-index" 1324 | checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" 1325 | dependencies = [ 1326 | "cpuid-bool", 1327 | "universal-hash", 1328 | ] 1329 | 1330 | [[package]] 1331 | name = "polyval" 1332 | version = "0.4.5" 1333 | source = "registry+https://github.com/rust-lang/crates.io-index" 1334 | checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" 1335 | dependencies = [ 1336 | "cpuid-bool", 1337 | "opaque-debug", 1338 | "universal-hash", 1339 | ] 1340 | 1341 | [[package]] 1342 | name = "ppv-lite86" 1343 | version = "0.2.10" 1344 | source = "registry+https://github.com/rust-lang/crates.io-index" 1345 | checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" 1346 | 1347 | [[package]] 1348 | name = "proc-macro-crate" 1349 | version = "1.0.0" 1350 | source = "registry+https://github.com/rust-lang/crates.io-index" 1351 | checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92" 1352 | dependencies = [ 1353 | "thiserror", 1354 | "toml", 1355 | ] 1356 | 1357 | [[package]] 1358 | name = "proc-macro-hack" 1359 | version = "0.5.19" 1360 | source = "registry+https://github.com/rust-lang/crates.io-index" 1361 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 1362 | 1363 | [[package]] 1364 | name = "proc-macro-nested" 1365 | version = "0.1.7" 1366 | source = "registry+https://github.com/rust-lang/crates.io-index" 1367 | checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" 1368 | 1369 | [[package]] 1370 | name = "proc-macro2" 1371 | version = "1.0.27" 1372 | source = "registry+https://github.com/rust-lang/crates.io-index" 1373 | checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" 1374 | dependencies = [ 1375 | "unicode-xid", 1376 | ] 1377 | 1378 | [[package]] 1379 | name = "quote" 1380 | version = "1.0.9" 1381 | source = "registry+https://github.com/rust-lang/crates.io-index" 1382 | checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" 1383 | dependencies = [ 1384 | "proc-macro2", 1385 | ] 1386 | 1387 | [[package]] 1388 | name = "rand" 1389 | version = "0.8.3" 1390 | source = "registry+https://github.com/rust-lang/crates.io-index" 1391 | checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" 1392 | dependencies = [ 1393 | "libc", 1394 | "rand_chacha", 1395 | "rand_core", 1396 | "rand_hc", 1397 | ] 1398 | 1399 | [[package]] 1400 | name = "rand_chacha" 1401 | version = "0.3.0" 1402 | source = "registry+https://github.com/rust-lang/crates.io-index" 1403 | checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" 1404 | dependencies = [ 1405 | "ppv-lite86", 1406 | "rand_core", 1407 | ] 1408 | 1409 | [[package]] 1410 | name = "rand_core" 1411 | version = "0.6.2" 1412 | source = "registry+https://github.com/rust-lang/crates.io-index" 1413 | checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" 1414 | dependencies = [ 1415 | "getrandom", 1416 | ] 1417 | 1418 | [[package]] 1419 | name = "rand_hc" 1420 | version = "0.3.0" 1421 | source = "registry+https://github.com/rust-lang/crates.io-index" 1422 | checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" 1423 | dependencies = [ 1424 | "rand_core", 1425 | ] 1426 | 1427 | [[package]] 1428 | name = "redox_syscall" 1429 | version = "0.2.8" 1430 | source = "registry+https://github.com/rust-lang/crates.io-index" 1431 | checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" 1432 | dependencies = [ 1433 | "bitflags", 1434 | ] 1435 | 1436 | [[package]] 1437 | name = "redox_users" 1438 | version = "0.4.0" 1439 | source = "registry+https://github.com/rust-lang/crates.io-index" 1440 | checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" 1441 | dependencies = [ 1442 | "getrandom", 1443 | "redox_syscall", 1444 | ] 1445 | 1446 | [[package]] 1447 | name = "regex" 1448 | version = "1.5.4" 1449 | source = "registry+https://github.com/rust-lang/crates.io-index" 1450 | checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" 1451 | dependencies = [ 1452 | "aho-corasick", 1453 | "memchr", 1454 | "regex-syntax", 1455 | ] 1456 | 1457 | [[package]] 1458 | name = "regex-automata" 1459 | version = "0.1.9" 1460 | source = "registry+https://github.com/rust-lang/crates.io-index" 1461 | checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" 1462 | dependencies = [ 1463 | "byteorder", 1464 | "regex-syntax", 1465 | ] 1466 | 1467 | [[package]] 1468 | name = "regex-syntax" 1469 | version = "0.6.25" 1470 | source = "registry+https://github.com/rust-lang/crates.io-index" 1471 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 1472 | 1473 | [[package]] 1474 | name = "remove_dir_all" 1475 | version = "0.5.3" 1476 | source = "registry+https://github.com/rust-lang/crates.io-index" 1477 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 1478 | dependencies = [ 1479 | "winapi", 1480 | ] 1481 | 1482 | [[package]] 1483 | name = "reqwest" 1484 | version = "0.11.3" 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" 1486 | checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" 1487 | dependencies = [ 1488 | "base64", 1489 | "bytes", 1490 | "encoding_rs", 1491 | "futures-core", 1492 | "futures-util", 1493 | "http", 1494 | "http-body", 1495 | "hyper", 1496 | "hyper-tls", 1497 | "ipnet", 1498 | "js-sys", 1499 | "lazy_static", 1500 | "log", 1501 | "mime", 1502 | "native-tls", 1503 | "percent-encoding", 1504 | "pin-project-lite", 1505 | "serde", 1506 | "serde_json", 1507 | "serde_urlencoded", 1508 | "tokio", 1509 | "tokio-native-tls", 1510 | "url", 1511 | "wasm-bindgen", 1512 | "wasm-bindgen-futures", 1513 | "web-sys", 1514 | "winreg", 1515 | ] 1516 | 1517 | [[package]] 1518 | name = "ruma" 1519 | version = "0.0.3" 1520 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1521 | dependencies = [ 1522 | "assign", 1523 | "js_int", 1524 | "ruma-api", 1525 | "ruma-client-api", 1526 | "ruma-common", 1527 | "ruma-events", 1528 | "ruma-federation-api", 1529 | "ruma-identifiers", 1530 | "ruma-serde", 1531 | ] 1532 | 1533 | [[package]] 1534 | name = "ruma-api" 1535 | version = "0.17.0-alpha.4" 1536 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1537 | dependencies = [ 1538 | "bytes", 1539 | "http", 1540 | "percent-encoding", 1541 | "ruma-api-macros", 1542 | "ruma-identifiers", 1543 | "ruma-serde", 1544 | "serde", 1545 | "serde_json", 1546 | "thiserror", 1547 | ] 1548 | 1549 | [[package]] 1550 | name = "ruma-api-macros" 1551 | version = "0.17.0-alpha.4" 1552 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1553 | dependencies = [ 1554 | "proc-macro-crate", 1555 | "proc-macro2", 1556 | "quote", 1557 | "syn", 1558 | ] 1559 | 1560 | [[package]] 1561 | name = "ruma-client-api" 1562 | version = "0.10.0-alpha.3" 1563 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1564 | dependencies = [ 1565 | "assign", 1566 | "bytes", 1567 | "http", 1568 | "js_int", 1569 | "maplit", 1570 | "percent-encoding", 1571 | "ruma-api", 1572 | "ruma-common", 1573 | "ruma-events", 1574 | "ruma-identifiers", 1575 | "ruma-serde", 1576 | "serde", 1577 | "serde_json", 1578 | ] 1579 | 1580 | [[package]] 1581 | name = "ruma-common" 1582 | version = "0.5.0" 1583 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1584 | dependencies = [ 1585 | "indexmap", 1586 | "js_int", 1587 | "ruma-identifiers", 1588 | "ruma-serde", 1589 | "serde", 1590 | "serde_json", 1591 | "tracing", 1592 | "wildmatch", 1593 | ] 1594 | 1595 | [[package]] 1596 | name = "ruma-events" 1597 | version = "0.22.0-alpha.3" 1598 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1599 | dependencies = [ 1600 | "js_int", 1601 | "ruma-common", 1602 | "ruma-events-macros", 1603 | "ruma-identifiers", 1604 | "ruma-serde", 1605 | "serde", 1606 | "serde_json", 1607 | ] 1608 | 1609 | [[package]] 1610 | name = "ruma-events-macros" 1611 | version = "0.22.0-alpha.3" 1612 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1613 | dependencies = [ 1614 | "proc-macro-crate", 1615 | "proc-macro2", 1616 | "quote", 1617 | "syn", 1618 | ] 1619 | 1620 | [[package]] 1621 | name = "ruma-federation-api" 1622 | version = "0.1.0-alpha.2" 1623 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1624 | dependencies = [ 1625 | "js_int", 1626 | "ruma-api", 1627 | "ruma-common", 1628 | "ruma-events", 1629 | "ruma-identifiers", 1630 | "ruma-serde", 1631 | "serde", 1632 | "serde_json", 1633 | ] 1634 | 1635 | [[package]] 1636 | name = "ruma-identifiers" 1637 | version = "0.19.0" 1638 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1639 | dependencies = [ 1640 | "paste", 1641 | "ruma-identifiers-macros", 1642 | "ruma-identifiers-validation", 1643 | "ruma-serde", 1644 | "ruma-serde-macros", 1645 | "serde", 1646 | ] 1647 | 1648 | [[package]] 1649 | name = "ruma-identifiers-macros" 1650 | version = "0.19.0" 1651 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1652 | dependencies = [ 1653 | "quote", 1654 | "ruma-identifiers-validation", 1655 | "syn", 1656 | ] 1657 | 1658 | [[package]] 1659 | name = "ruma-identifiers-validation" 1660 | version = "0.3.0" 1661 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1662 | 1663 | [[package]] 1664 | name = "ruma-serde" 1665 | version = "0.3.1" 1666 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1667 | dependencies = [ 1668 | "bytes", 1669 | "form_urlencoded", 1670 | "itoa", 1671 | "js_int", 1672 | "ruma-serde-macros", 1673 | "serde", 1674 | "serde_json", 1675 | ] 1676 | 1677 | [[package]] 1678 | name = "ruma-serde-macros" 1679 | version = "0.3.1" 1680 | source = "git+https://github.com/ruma/ruma?rev=24154195a00390a33542603b968e94022487587c#24154195a00390a33542603b968e94022487587c" 1681 | dependencies = [ 1682 | "proc-macro-crate", 1683 | "proc-macro2", 1684 | "quote", 1685 | "syn", 1686 | ] 1687 | 1688 | [[package]] 1689 | name = "rustc-demangle" 1690 | version = "0.1.19" 1691 | source = "registry+https://github.com/rust-lang/crates.io-index" 1692 | checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" 1693 | 1694 | [[package]] 1695 | name = "rustc_version" 1696 | version = "0.2.3" 1697 | source = "registry+https://github.com/rust-lang/crates.io-index" 1698 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1699 | dependencies = [ 1700 | "semver", 1701 | ] 1702 | 1703 | [[package]] 1704 | name = "ryu" 1705 | version = "1.0.5" 1706 | source = "registry+https://github.com/rust-lang/crates.io-index" 1707 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 1708 | 1709 | [[package]] 1710 | name = "schannel" 1711 | version = "0.1.19" 1712 | source = "registry+https://github.com/rust-lang/crates.io-index" 1713 | checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" 1714 | dependencies = [ 1715 | "lazy_static", 1716 | "winapi", 1717 | ] 1718 | 1719 | [[package]] 1720 | name = "scopeguard" 1721 | version = "1.1.0" 1722 | source = "registry+https://github.com/rust-lang/crates.io-index" 1723 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1724 | 1725 | [[package]] 1726 | name = "security-framework" 1727 | version = "2.2.0" 1728 | source = "registry+https://github.com/rust-lang/crates.io-index" 1729 | checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" 1730 | dependencies = [ 1731 | "bitflags", 1732 | "core-foundation", 1733 | "core-foundation-sys", 1734 | "libc", 1735 | "security-framework-sys", 1736 | ] 1737 | 1738 | [[package]] 1739 | name = "security-framework-sys" 1740 | version = "2.2.0" 1741 | source = "registry+https://github.com/rust-lang/crates.io-index" 1742 | checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" 1743 | dependencies = [ 1744 | "core-foundation-sys", 1745 | "libc", 1746 | ] 1747 | 1748 | [[package]] 1749 | name = "semver" 1750 | version = "0.9.0" 1751 | source = "registry+https://github.com/rust-lang/crates.io-index" 1752 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1753 | dependencies = [ 1754 | "semver-parser", 1755 | ] 1756 | 1757 | [[package]] 1758 | name = "semver-parser" 1759 | version = "0.7.0" 1760 | source = "registry+https://github.com/rust-lang/crates.io-index" 1761 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1762 | 1763 | [[package]] 1764 | name = "send_wrapper" 1765 | version = "0.4.0" 1766 | source = "registry+https://github.com/rust-lang/crates.io-index" 1767 | checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" 1768 | 1769 | [[package]] 1770 | name = "serde" 1771 | version = "1.0.126" 1772 | source = "registry+https://github.com/rust-lang/crates.io-index" 1773 | checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" 1774 | dependencies = [ 1775 | "serde_derive", 1776 | ] 1777 | 1778 | [[package]] 1779 | name = "serde_derive" 1780 | version = "1.0.126" 1781 | source = "registry+https://github.com/rust-lang/crates.io-index" 1782 | checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" 1783 | dependencies = [ 1784 | "proc-macro2", 1785 | "quote", 1786 | "syn", 1787 | ] 1788 | 1789 | [[package]] 1790 | name = "serde_json" 1791 | version = "1.0.64" 1792 | source = "registry+https://github.com/rust-lang/crates.io-index" 1793 | checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" 1794 | dependencies = [ 1795 | "itoa", 1796 | "ryu", 1797 | "serde", 1798 | ] 1799 | 1800 | [[package]] 1801 | name = "serde_urlencoded" 1802 | version = "0.7.0" 1803 | source = "registry+https://github.com/rust-lang/crates.io-index" 1804 | checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" 1805 | dependencies = [ 1806 | "form_urlencoded", 1807 | "itoa", 1808 | "ryu", 1809 | "serde", 1810 | ] 1811 | 1812 | [[package]] 1813 | name = "sha1" 1814 | version = "0.6.0" 1815 | source = "registry+https://github.com/rust-lang/crates.io-index" 1816 | checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" 1817 | 1818 | [[package]] 1819 | name = "sha2" 1820 | version = "0.9.5" 1821 | source = "registry+https://github.com/rust-lang/crates.io-index" 1822 | checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" 1823 | dependencies = [ 1824 | "block-buffer", 1825 | "cfg-if", 1826 | "cpufeatures", 1827 | "digest", 1828 | "opaque-debug", 1829 | ] 1830 | 1831 | [[package]] 1832 | name = "sharded-slab" 1833 | version = "0.1.1" 1834 | source = "registry+https://github.com/rust-lang/crates.io-index" 1835 | checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" 1836 | dependencies = [ 1837 | "lazy_static", 1838 | ] 1839 | 1840 | [[package]] 1841 | name = "signal-hook" 1842 | version = "0.1.17" 1843 | source = "registry+https://github.com/rust-lang/crates.io-index" 1844 | checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" 1845 | dependencies = [ 1846 | "libc", 1847 | "mio", 1848 | "signal-hook-registry", 1849 | ] 1850 | 1851 | [[package]] 1852 | name = "signal-hook-registry" 1853 | version = "1.3.0" 1854 | source = "registry+https://github.com/rust-lang/crates.io-index" 1855 | checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" 1856 | dependencies = [ 1857 | "libc", 1858 | ] 1859 | 1860 | [[package]] 1861 | name = "slab" 1862 | version = "0.4.3" 1863 | source = "registry+https://github.com/rust-lang/crates.io-index" 1864 | checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" 1865 | 1866 | [[package]] 1867 | name = "sled" 1868 | version = "0.34.6" 1869 | source = "registry+https://github.com/rust-lang/crates.io-index" 1870 | checksum = "1d0132f3e393bcb7390c60bb45769498cf4550bcb7a21d7f95c02b69f6362cdc" 1871 | dependencies = [ 1872 | "crc32fast", 1873 | "crossbeam-epoch", 1874 | "crossbeam-utils", 1875 | "fs2", 1876 | "fxhash", 1877 | "libc", 1878 | "log", 1879 | "parking_lot", 1880 | ] 1881 | 1882 | [[package]] 1883 | name = "smallvec" 1884 | version = "1.6.1" 1885 | source = "registry+https://github.com/rust-lang/crates.io-index" 1886 | checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" 1887 | 1888 | [[package]] 1889 | name = "socket2" 1890 | version = "0.4.0" 1891 | source = "registry+https://github.com/rust-lang/crates.io-index" 1892 | checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" 1893 | dependencies = [ 1894 | "libc", 1895 | "winapi", 1896 | ] 1897 | 1898 | [[package]] 1899 | name = "standback" 1900 | version = "0.2.17" 1901 | source = "registry+https://github.com/rust-lang/crates.io-index" 1902 | checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" 1903 | dependencies = [ 1904 | "version_check", 1905 | ] 1906 | 1907 | [[package]] 1908 | name = "stdweb" 1909 | version = "0.4.20" 1910 | source = "registry+https://github.com/rust-lang/crates.io-index" 1911 | checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" 1912 | dependencies = [ 1913 | "discard", 1914 | "rustc_version", 1915 | "stdweb-derive", 1916 | "stdweb-internal-macros", 1917 | "stdweb-internal-runtime", 1918 | "wasm-bindgen", 1919 | ] 1920 | 1921 | [[package]] 1922 | name = "stdweb-derive" 1923 | version = "0.5.3" 1924 | source = "registry+https://github.com/rust-lang/crates.io-index" 1925 | checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" 1926 | dependencies = [ 1927 | "proc-macro2", 1928 | "quote", 1929 | "serde", 1930 | "serde_derive", 1931 | "syn", 1932 | ] 1933 | 1934 | [[package]] 1935 | name = "stdweb-internal-macros" 1936 | version = "0.2.9" 1937 | source = "registry+https://github.com/rust-lang/crates.io-index" 1938 | checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" 1939 | dependencies = [ 1940 | "base-x", 1941 | "proc-macro2", 1942 | "quote", 1943 | "serde", 1944 | "serde_derive", 1945 | "serde_json", 1946 | "sha1", 1947 | "syn", 1948 | ] 1949 | 1950 | [[package]] 1951 | name = "stdweb-internal-runtime" 1952 | version = "0.1.5" 1953 | source = "registry+https://github.com/rust-lang/crates.io-index" 1954 | checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" 1955 | 1956 | [[package]] 1957 | name = "strsim" 1958 | version = "0.8.0" 1959 | source = "registry+https://github.com/rust-lang/crates.io-index" 1960 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 1961 | 1962 | [[package]] 1963 | name = "subtle" 1964 | version = "2.4.0" 1965 | source = "registry+https://github.com/rust-lang/crates.io-index" 1966 | checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" 1967 | 1968 | [[package]] 1969 | name = "syn" 1970 | version = "1.0.72" 1971 | source = "registry+https://github.com/rust-lang/crates.io-index" 1972 | checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" 1973 | dependencies = [ 1974 | "proc-macro2", 1975 | "quote", 1976 | "unicode-xid", 1977 | ] 1978 | 1979 | [[package]] 1980 | name = "synstructure" 1981 | version = "0.12.4" 1982 | source = "registry+https://github.com/rust-lang/crates.io-index" 1983 | checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" 1984 | dependencies = [ 1985 | "proc-macro2", 1986 | "quote", 1987 | "syn", 1988 | "unicode-xid", 1989 | ] 1990 | 1991 | [[package]] 1992 | name = "tempfile" 1993 | version = "3.2.0" 1994 | source = "registry+https://github.com/rust-lang/crates.io-index" 1995 | checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" 1996 | dependencies = [ 1997 | "cfg-if", 1998 | "libc", 1999 | "rand", 2000 | "redox_syscall", 2001 | "remove_dir_all", 2002 | "winapi", 2003 | ] 2004 | 2005 | [[package]] 2006 | name = "textwrap" 2007 | version = "0.11.0" 2008 | source = "registry+https://github.com/rust-lang/crates.io-index" 2009 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 2010 | dependencies = [ 2011 | "unicode-width", 2012 | ] 2013 | 2014 | [[package]] 2015 | name = "thiserror" 2016 | version = "1.0.25" 2017 | source = "registry+https://github.com/rust-lang/crates.io-index" 2018 | checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" 2019 | dependencies = [ 2020 | "thiserror-impl", 2021 | ] 2022 | 2023 | [[package]] 2024 | name = "thiserror-impl" 2025 | version = "1.0.25" 2026 | source = "registry+https://github.com/rust-lang/crates.io-index" 2027 | checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" 2028 | dependencies = [ 2029 | "proc-macro2", 2030 | "quote", 2031 | "syn", 2032 | ] 2033 | 2034 | [[package]] 2035 | name = "thread_local" 2036 | version = "1.1.3" 2037 | source = "registry+https://github.com/rust-lang/crates.io-index" 2038 | checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" 2039 | dependencies = [ 2040 | "once_cell", 2041 | ] 2042 | 2043 | [[package]] 2044 | name = "time" 2045 | version = "0.1.43" 2046 | source = "registry+https://github.com/rust-lang/crates.io-index" 2047 | checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" 2048 | dependencies = [ 2049 | "libc", 2050 | "winapi", 2051 | ] 2052 | 2053 | [[package]] 2054 | name = "time" 2055 | version = "0.2.26" 2056 | source = "registry+https://github.com/rust-lang/crates.io-index" 2057 | checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372" 2058 | dependencies = [ 2059 | "const_fn", 2060 | "libc", 2061 | "standback", 2062 | "stdweb", 2063 | "time-macros", 2064 | "version_check", 2065 | "winapi", 2066 | ] 2067 | 2068 | [[package]] 2069 | name = "time-macros" 2070 | version = "0.1.1" 2071 | source = "registry+https://github.com/rust-lang/crates.io-index" 2072 | checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" 2073 | dependencies = [ 2074 | "proc-macro-hack", 2075 | "time-macros-impl", 2076 | ] 2077 | 2078 | [[package]] 2079 | name = "time-macros-impl" 2080 | version = "0.1.1" 2081 | source = "registry+https://github.com/rust-lang/crates.io-index" 2082 | checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" 2083 | dependencies = [ 2084 | "proc-macro-hack", 2085 | "proc-macro2", 2086 | "quote", 2087 | "standback", 2088 | "syn", 2089 | ] 2090 | 2091 | [[package]] 2092 | name = "tinyvec" 2093 | version = "1.2.0" 2094 | source = "registry+https://github.com/rust-lang/crates.io-index" 2095 | checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" 2096 | dependencies = [ 2097 | "tinyvec_macros", 2098 | ] 2099 | 2100 | [[package]] 2101 | name = "tinyvec_macros" 2102 | version = "0.1.0" 2103 | source = "registry+https://github.com/rust-lang/crates.io-index" 2104 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 2105 | 2106 | [[package]] 2107 | name = "tokio" 2108 | version = "1.6.0" 2109 | source = "registry+https://github.com/rust-lang/crates.io-index" 2110 | checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37" 2111 | dependencies = [ 2112 | "autocfg", 2113 | "bytes", 2114 | "libc", 2115 | "memchr", 2116 | "mio", 2117 | "num_cpus", 2118 | "pin-project-lite", 2119 | "tokio-macros", 2120 | ] 2121 | 2122 | [[package]] 2123 | name = "tokio-macros" 2124 | version = "1.2.0" 2125 | source = "registry+https://github.com/rust-lang/crates.io-index" 2126 | checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" 2127 | dependencies = [ 2128 | "proc-macro2", 2129 | "quote", 2130 | "syn", 2131 | ] 2132 | 2133 | [[package]] 2134 | name = "tokio-native-tls" 2135 | version = "0.3.0" 2136 | source = "registry+https://github.com/rust-lang/crates.io-index" 2137 | checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" 2138 | dependencies = [ 2139 | "native-tls", 2140 | "tokio", 2141 | ] 2142 | 2143 | [[package]] 2144 | name = "tokio-util" 2145 | version = "0.6.7" 2146 | source = "registry+https://github.com/rust-lang/crates.io-index" 2147 | checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" 2148 | dependencies = [ 2149 | "bytes", 2150 | "futures-core", 2151 | "futures-sink", 2152 | "log", 2153 | "pin-project-lite", 2154 | "tokio", 2155 | ] 2156 | 2157 | [[package]] 2158 | name = "toml" 2159 | version = "0.5.8" 2160 | source = "registry+https://github.com/rust-lang/crates.io-index" 2161 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 2162 | dependencies = [ 2163 | "serde", 2164 | ] 2165 | 2166 | [[package]] 2167 | name = "tower-service" 2168 | version = "0.3.1" 2169 | source = "registry+https://github.com/rust-lang/crates.io-index" 2170 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 2171 | 2172 | [[package]] 2173 | name = "tracing" 2174 | version = "0.1.26" 2175 | source = "registry+https://github.com/rust-lang/crates.io-index" 2176 | checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" 2177 | dependencies = [ 2178 | "cfg-if", 2179 | "pin-project-lite", 2180 | "tracing-attributes", 2181 | "tracing-core", 2182 | ] 2183 | 2184 | [[package]] 2185 | name = "tracing-attributes" 2186 | version = "0.1.15" 2187 | source = "registry+https://github.com/rust-lang/crates.io-index" 2188 | checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" 2189 | dependencies = [ 2190 | "proc-macro2", 2191 | "quote", 2192 | "syn", 2193 | ] 2194 | 2195 | [[package]] 2196 | name = "tracing-core" 2197 | version = "0.1.18" 2198 | source = "registry+https://github.com/rust-lang/crates.io-index" 2199 | checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" 2200 | dependencies = [ 2201 | "lazy_static", 2202 | ] 2203 | 2204 | [[package]] 2205 | name = "tracing-futures" 2206 | version = "0.2.5" 2207 | source = "registry+https://github.com/rust-lang/crates.io-index" 2208 | checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" 2209 | dependencies = [ 2210 | "pin-project", 2211 | "tracing", 2212 | ] 2213 | 2214 | [[package]] 2215 | name = "tracing-log" 2216 | version = "0.1.2" 2217 | source = "registry+https://github.com/rust-lang/crates.io-index" 2218 | checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" 2219 | dependencies = [ 2220 | "lazy_static", 2221 | "log", 2222 | "tracing-core", 2223 | ] 2224 | 2225 | [[package]] 2226 | name = "tracing-serde" 2227 | version = "0.1.2" 2228 | source = "registry+https://github.com/rust-lang/crates.io-index" 2229 | checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" 2230 | dependencies = [ 2231 | "serde", 2232 | "tracing-core", 2233 | ] 2234 | 2235 | [[package]] 2236 | name = "tracing-subscriber" 2237 | version = "0.2.18" 2238 | source = "registry+https://github.com/rust-lang/crates.io-index" 2239 | checksum = "aa5553bf0883ba7c9cbe493b085c29926bd41b66afc31ff72cf17ff4fb60dcd5" 2240 | dependencies = [ 2241 | "ansi_term 0.12.1", 2242 | "chrono", 2243 | "lazy_static", 2244 | "matchers", 2245 | "regex", 2246 | "serde", 2247 | "serde_json", 2248 | "sharded-slab", 2249 | "smallvec", 2250 | "thread_local", 2251 | "tracing", 2252 | "tracing-core", 2253 | "tracing-log", 2254 | "tracing-serde", 2255 | ] 2256 | 2257 | [[package]] 2258 | name = "try-lock" 2259 | version = "0.2.3" 2260 | source = "registry+https://github.com/rust-lang/crates.io-index" 2261 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 2262 | 2263 | [[package]] 2264 | name = "tui" 2265 | version = "0.15.0" 2266 | source = "registry+https://github.com/rust-lang/crates.io-index" 2267 | checksum = "861d8f3ad314ede6219bcb2ab844054b1de279ee37a9bc38e3d606f9d3fb2a71" 2268 | dependencies = [ 2269 | "bitflags", 2270 | "cassowary", 2271 | "crossterm", 2272 | "unicode-segmentation", 2273 | "unicode-width", 2274 | ] 2275 | 2276 | [[package]] 2277 | name = "typenum" 2278 | version = "1.13.0" 2279 | source = "registry+https://github.com/rust-lang/crates.io-index" 2280 | checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" 2281 | 2282 | [[package]] 2283 | name = "unicode-bidi" 2284 | version = "0.3.5" 2285 | source = "registry+https://github.com/rust-lang/crates.io-index" 2286 | checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" 2287 | dependencies = [ 2288 | "matches", 2289 | ] 2290 | 2291 | [[package]] 2292 | name = "unicode-normalization" 2293 | version = "0.1.17" 2294 | source = "registry+https://github.com/rust-lang/crates.io-index" 2295 | checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" 2296 | dependencies = [ 2297 | "tinyvec", 2298 | ] 2299 | 2300 | [[package]] 2301 | name = "unicode-segmentation" 2302 | version = "1.7.1" 2303 | source = "registry+https://github.com/rust-lang/crates.io-index" 2304 | checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" 2305 | 2306 | [[package]] 2307 | name = "unicode-width" 2308 | version = "0.1.8" 2309 | source = "registry+https://github.com/rust-lang/crates.io-index" 2310 | checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" 2311 | 2312 | [[package]] 2313 | name = "unicode-xid" 2314 | version = "0.2.2" 2315 | source = "registry+https://github.com/rust-lang/crates.io-index" 2316 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 2317 | 2318 | [[package]] 2319 | name = "universal-hash" 2320 | version = "0.4.0" 2321 | source = "registry+https://github.com/rust-lang/crates.io-index" 2322 | checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" 2323 | dependencies = [ 2324 | "generic-array", 2325 | "subtle", 2326 | ] 2327 | 2328 | [[package]] 2329 | name = "url" 2330 | version = "2.2.2" 2331 | source = "registry+https://github.com/rust-lang/crates.io-index" 2332 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 2333 | dependencies = [ 2334 | "form_urlencoded", 2335 | "idna", 2336 | "matches", 2337 | "percent-encoding", 2338 | ] 2339 | 2340 | [[package]] 2341 | name = "urlencoding" 2342 | version = "1.3.3" 2343 | source = "registry+https://github.com/rust-lang/crates.io-index" 2344 | checksum = "5a1f0175e03a0973cf4afd476bef05c26e228520400eb1fd473ad417b1c00ffb" 2345 | 2346 | [[package]] 2347 | name = "uuid" 2348 | version = "0.8.2" 2349 | source = "registry+https://github.com/rust-lang/crates.io-index" 2350 | checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" 2351 | dependencies = [ 2352 | "getrandom", 2353 | "serde", 2354 | ] 2355 | 2356 | [[package]] 2357 | name = "vcpkg" 2358 | version = "0.2.13" 2359 | source = "registry+https://github.com/rust-lang/crates.io-index" 2360 | checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa" 2361 | 2362 | [[package]] 2363 | name = "vec_map" 2364 | version = "0.8.2" 2365 | source = "registry+https://github.com/rust-lang/crates.io-index" 2366 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 2367 | 2368 | [[package]] 2369 | name = "version_check" 2370 | version = "0.9.3" 2371 | source = "registry+https://github.com/rust-lang/crates.io-index" 2372 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 2373 | 2374 | [[package]] 2375 | name = "want" 2376 | version = "0.3.0" 2377 | source = "registry+https://github.com/rust-lang/crates.io-index" 2378 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 2379 | dependencies = [ 2380 | "log", 2381 | "try-lock", 2382 | ] 2383 | 2384 | [[package]] 2385 | name = "wasi" 2386 | version = "0.10.2+wasi-snapshot-preview1" 2387 | source = "registry+https://github.com/rust-lang/crates.io-index" 2388 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 2389 | 2390 | [[package]] 2391 | name = "wasm-bindgen" 2392 | version = "0.2.74" 2393 | source = "registry+https://github.com/rust-lang/crates.io-index" 2394 | checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" 2395 | dependencies = [ 2396 | "cfg-if", 2397 | "serde", 2398 | "serde_json", 2399 | "wasm-bindgen-macro", 2400 | ] 2401 | 2402 | [[package]] 2403 | name = "wasm-bindgen-backend" 2404 | version = "0.2.74" 2405 | source = "registry+https://github.com/rust-lang/crates.io-index" 2406 | checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" 2407 | dependencies = [ 2408 | "bumpalo", 2409 | "lazy_static", 2410 | "log", 2411 | "proc-macro2", 2412 | "quote", 2413 | "syn", 2414 | "wasm-bindgen-shared", 2415 | ] 2416 | 2417 | [[package]] 2418 | name = "wasm-bindgen-futures" 2419 | version = "0.4.24" 2420 | source = "registry+https://github.com/rust-lang/crates.io-index" 2421 | checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" 2422 | dependencies = [ 2423 | "cfg-if", 2424 | "js-sys", 2425 | "wasm-bindgen", 2426 | "web-sys", 2427 | ] 2428 | 2429 | [[package]] 2430 | name = "wasm-bindgen-macro" 2431 | version = "0.2.74" 2432 | source = "registry+https://github.com/rust-lang/crates.io-index" 2433 | checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" 2434 | dependencies = [ 2435 | "quote", 2436 | "wasm-bindgen-macro-support", 2437 | ] 2438 | 2439 | [[package]] 2440 | name = "wasm-bindgen-macro-support" 2441 | version = "0.2.74" 2442 | source = "registry+https://github.com/rust-lang/crates.io-index" 2443 | checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" 2444 | dependencies = [ 2445 | "proc-macro2", 2446 | "quote", 2447 | "syn", 2448 | "wasm-bindgen-backend", 2449 | "wasm-bindgen-shared", 2450 | ] 2451 | 2452 | [[package]] 2453 | name = "wasm-bindgen-shared" 2454 | version = "0.2.74" 2455 | source = "registry+https://github.com/rust-lang/crates.io-index" 2456 | checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" 2457 | 2458 | [[package]] 2459 | name = "web-sys" 2460 | version = "0.3.51" 2461 | source = "registry+https://github.com/rust-lang/crates.io-index" 2462 | checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" 2463 | dependencies = [ 2464 | "js-sys", 2465 | "wasm-bindgen", 2466 | ] 2467 | 2468 | [[package]] 2469 | name = "wildmatch" 2470 | version = "2.1.0" 2471 | source = "registry+https://github.com/rust-lang/crates.io-index" 2472 | checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0" 2473 | 2474 | [[package]] 2475 | name = "winapi" 2476 | version = "0.3.9" 2477 | source = "registry+https://github.com/rust-lang/crates.io-index" 2478 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 2479 | dependencies = [ 2480 | "winapi-i686-pc-windows-gnu", 2481 | "winapi-x86_64-pc-windows-gnu", 2482 | ] 2483 | 2484 | [[package]] 2485 | name = "winapi-i686-pc-windows-gnu" 2486 | version = "0.4.0" 2487 | source = "registry+https://github.com/rust-lang/crates.io-index" 2488 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 2489 | 2490 | [[package]] 2491 | name = "winapi-x86_64-pc-windows-gnu" 2492 | version = "0.4.0" 2493 | source = "registry+https://github.com/rust-lang/crates.io-index" 2494 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 2495 | 2496 | [[package]] 2497 | name = "winreg" 2498 | version = "0.7.0" 2499 | source = "registry+https://github.com/rust-lang/crates.io-index" 2500 | checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" 2501 | dependencies = [ 2502 | "winapi", 2503 | ] 2504 | 2505 | [[package]] 2506 | name = "zeroize" 2507 | version = "1.3.0" 2508 | source = "registry+https://github.com/rust-lang/crates.io-index" 2509 | checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" 2510 | dependencies = [ 2511 | "zeroize_derive", 2512 | ] 2513 | 2514 | [[package]] 2515 | name = "zeroize_derive" 2516 | version = "1.1.0" 2517 | source = "registry+https://github.com/rust-lang/crates.io-index" 2518 | checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" 2519 | dependencies = [ 2520 | "proc-macro2", 2521 | "quote", 2522 | "syn", 2523 | "synstructure", 2524 | ] 2525 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "konoha" 3 | version = "0.1.0" 4 | description = "A user-friendly TUI client for Matrix." 5 | authors = [ "L3af " ] 6 | repository = "https://github.com/L3afMe/konoha" 7 | edition = "2018" 8 | 9 | [dependencies] 10 | clap = "2.33.3" 11 | crossterm = "0.19.0" 12 | dirs = "3.0.2" 13 | lazy_static = "1.4.0" 14 | regex = "1.5.4" 15 | serde_json = "1.0.64" 16 | url = "2.2.2" 17 | tracing-subscriber = "0.2.18" 18 | os_info = "3.0.6" 19 | backtrace = "0.3.59" 20 | urlencoding = "1.3.3" 21 | chrono = "0.4.19" 22 | 23 | [dependencies.matrix-sdk] 24 | git = "https://github.com/matrix-org/matrix-rust-sdk" 25 | rev = "eece920" 26 | features = [ "encryption" ] 27 | 28 | [dependencies.serde] 29 | version = "1.0.126" 30 | features = [ "derive" ] 31 | 32 | [dependencies.reqwest] 33 | version = "0.11.3" 34 | features = [ "json" ] 35 | 36 | [dependencies.tokio] 37 | version = "1.6.0" 38 | default-features = false 39 | features = [ "rt-multi-thread", "sync", "macros" ] 40 | 41 | [dependencies.tui] 42 | version = "0.15.0" 43 | default-features = false 44 | features = [ "crossterm" ] 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 4 |

Konoha

5 |

A user-friendly TUI client for Matrix written in Rust!

6 | 7 | # Notice: The client is currently not usable and is only hosted on GitHub for version control. 8 | 9 | ## If you want a working terminal client I would suggest [rumatui](https://github.com/DevinR528/rumatui) 10 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "locked": { 5 | "lastModified": 1620759905, 6 | "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", 7 | "owner": "numtide", 8 | "repo": "flake-utils", 9 | "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "numtide", 14 | "repo": "flake-utils", 15 | "type": "github" 16 | } 17 | }, 18 | "flake-utils_2": { 19 | "locked": { 20 | "lastModified": 1614513358, 21 | "narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=", 22 | "owner": "numtide", 23 | "repo": "flake-utils", 24 | "rev": "5466c5bbece17adaab2d82fae80b46e807611bf3", 25 | "type": "github" 26 | }, 27 | "original": { 28 | "owner": "numtide", 29 | "repo": "flake-utils", 30 | "type": "github" 31 | } 32 | }, 33 | "nixpkgs": { 34 | "locked": { 35 | "lastModified": 1621552131, 36 | "narHash": "sha256-AD/AEXv+QOYAg0PIqMYv2nbGOGTIwfOGKtz3rE+y+Tc=", 37 | "owner": "nixos", 38 | "repo": "nixpkgs", 39 | "rev": "d42cd445dde587e9a993cd9434cb43da07c4c5de", 40 | "type": "github" 41 | }, 42 | "original": { 43 | "owner": "nixos", 44 | "ref": "nixos-unstable", 45 | "repo": "nixpkgs", 46 | "type": "github" 47 | } 48 | }, 49 | "nixpkgs_2": { 50 | "locked": { 51 | "lastModified": 1617325113, 52 | "narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=", 53 | "owner": "nixos", 54 | "repo": "nixpkgs", 55 | "rev": "54c1e44240d8a527a8f4892608c4bce5440c3ecb", 56 | "type": "github" 57 | }, 58 | "original": { 59 | "owner": "NixOS", 60 | "repo": "nixpkgs", 61 | "type": "github" 62 | } 63 | }, 64 | "root": { 65 | "inputs": { 66 | "flake-utils": "flake-utils", 67 | "nixpkgs": "nixpkgs", 68 | "rust-overlay": "rust-overlay" 69 | } 70 | }, 71 | "rust-overlay": { 72 | "inputs": { 73 | "flake-utils": "flake-utils_2", 74 | "nixpkgs": "nixpkgs_2" 75 | }, 76 | "locked": { 77 | "lastModified": 1621564177, 78 | "narHash": "sha256-b9q+/LMIMIL2zq0PSt2cYFnDnMHNlYxoSsXxptLe3ac=", 79 | "owner": "oxalica", 80 | "repo": "rust-overlay", 81 | "rev": "98e706440e250f6e5c5a7f179b0fc1e7f6270bd5", 82 | "type": "github" 83 | }, 84 | "original": { 85 | "owner": "oxalica", 86 | "repo": "rust-overlay", 87 | "type": "github" 88 | } 89 | } 90 | }, 91 | "root": "root", 92 | "version": 7 93 | } 94 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "A user-friendly TUI client for Matrix written in Rust."; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 | rust-overlay.url = "github:oxalica/rust-overlay"; 7 | flake-utils.url = "github:numtide/flake-utils"; 8 | }; 9 | 10 | outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: 11 | flake-utils.lib.eachDefaultSystem (system: 12 | let 13 | overlays = [ (import rust-overlay) ]; 14 | pkgs = import nixpkgs { 15 | inherit system overlays; 16 | }; 17 | nightly = pkgs.rust-bin.nightly.latest.default.override { 18 | extensions = [ "rust-src" ]; 19 | }; 20 | in 21 | { 22 | devShell = pkgs.mkShell { 23 | buildInputs = with pkgs; [ 24 | nightly 25 | cargo 26 | cargo-edit 27 | cargo-watch 28 | rustfmt 29 | clippy 30 | openssl 31 | pkg-config 32 | cmake 33 | ]; 34 | 35 | RUST_SRC_PATH = "${nightly}/lib/rustlib/src/rust/library"; 36 | # RUST_BACKTRACE = 1; 37 | }; 38 | } 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /src/app/context.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | sync::mpsc::{self, Receiver, SendError, Sender}, 3 | time::Duration, 4 | }; 5 | 6 | use tokio::task::JoinHandle; 7 | 8 | use super::{ 9 | ui::prelude::{Menu, Popup}, 10 | App, 11 | }; 12 | use crate::client::{auth::AuthCreds, Client, ClientNotification}; 13 | 14 | pub enum Notification { 15 | QuitApplication(bool), 16 | SetLogin(AuthCreds), 17 | ShowPopup(Popup), 18 | HidePopup, 19 | SwitchMenu(Box), 20 | ClientError(String), 21 | } 22 | 23 | #[derive(Debug, Clone, Default)] 24 | pub struct ContextSettings { 25 | pub hide_help: bool, 26 | pub quit_application: bool, 27 | pub login_details: Option, 28 | } 29 | 30 | impl ContextSettings { 31 | pub fn toggle_help(&mut self) { 32 | self.hide_help = !self.hide_help; 33 | } 34 | } 35 | 36 | pub struct Context { 37 | notification_sender: Sender, 38 | client_notification_sender: Option>, 39 | pub settings: ContextSettings, 40 | } 41 | 42 | impl Context { 43 | pub fn new() -> (Self, Receiver) { 44 | let (notification_sender, notification_rec) = mpsc::channel(); 45 | 46 | let this = Self { 47 | notification_sender, 48 | client_notification_sender: None, 49 | settings: ContextSettings::default(), 50 | }; 51 | 52 | (this, notification_rec) 53 | } 54 | 55 | pub fn send_client_notification( 56 | &self, 57 | notification: ClientNotification, 58 | ) -> Result<(), SendError> { 59 | if let Some(sender) = &self.client_notification_sender { 60 | sender.send(notification) 61 | } else { 62 | Ok(()) 63 | } 64 | } 65 | 66 | pub fn send_notification( 67 | &self, 68 | notification: Notification, 69 | ) -> Result<(), SendError> { 70 | self.notification_sender.send(notification) 71 | } 72 | 73 | pub fn start_client(&mut self, credentials: AuthCreds) -> JoinHandle<()> { 74 | let sender = self.notification_sender.clone(); 75 | let (mut client, sender) = Client::new(credentials, sender); 76 | let handle = tokio::task::spawn(async move { client.login().await }); 77 | 78 | self.client_notification_sender = Some(sender); 79 | handle 80 | } 81 | } 82 | 83 | pub fn handle_notification(receiver: &Receiver, app: &mut App) { 84 | if let Ok(notification) = receiver.recv_timeout(Duration::from_millis(0)) { 85 | app.on_notification(notification); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/app/event.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | sync::mpsc::{self, Receiver}, 3 | thread::{self, JoinHandle}, 4 | time::{Duration, Instant}, 5 | }; 6 | 7 | use crossterm::event::{self, Event as CTEvent, KeyEvent, MouseEvent}; 8 | 9 | use super::App; 10 | 11 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] 12 | pub enum Event { 13 | Key(KeyEvent), 14 | Mouse(MouseEvent), 15 | Tick, 16 | } 17 | 18 | pub fn handle_event(receiver: &Receiver, app: &mut App) { 19 | if let Ok(event) = receiver.recv_timeout(Duration::ZERO) { 20 | match event { 21 | Event::Key(key) => app.on_key_press(key), 22 | Event::Mouse(event) => app.on_mouse(event), 23 | Event::Tick => app.on_tick(), 24 | } 25 | } 26 | } 27 | 28 | pub struct EventReceiver { 29 | pub key_handle: JoinHandle<()>, 30 | pub tick_handle: JoinHandle<()>, 31 | pub receiver: Receiver, 32 | } 33 | 34 | pub fn spawn_event_listener(tick_ms: u64) -> EventReceiver { 35 | let (sr, receiver) = mpsc::channel(); 36 | 37 | let key_handle = { 38 | let sr = sr.clone(); 39 | thread::spawn(move || { 40 | let tick_rate = Duration::from_millis(tick_ms); 41 | let mut last_tick = Instant::now(); 42 | 43 | loop { 44 | let timeout = tick_rate 45 | .checked_sub(last_tick.elapsed()) 46 | .unwrap_or_else(|| Duration::from_millis(0)); 47 | 48 | if event::poll(timeout).unwrap_or_default() { 49 | if let Ok(event) = event::read() { 50 | let term_event = match event { 51 | CTEvent::Key(event) => Event::Key(event), 52 | CTEvent::Mouse(event) => Event::Mouse(event), 53 | CTEvent::Resize(..) => continue, 54 | }; 55 | 56 | if let Err(_why) = sr.send(term_event) { 57 | // Handle why 58 | } 59 | } 60 | } 61 | if last_tick.elapsed() >= tick_rate { 62 | last_tick = Instant::now(); 63 | } 64 | } 65 | }) 66 | }; 67 | 68 | let tick_rate = Duration::from_millis(tick_ms); 69 | let tick_handle = { 70 | thread::spawn(move || loop { 71 | if let Err(_why) = sr.send(Event::Tick) { 72 | // Handle why 73 | } 74 | thread::sleep(tick_rate) 75 | }) 76 | }; 77 | 78 | EventReceiver { 79 | key_handle, 80 | tick_handle, 81 | receiver, 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/app/helper.rs: -------------------------------------------------------------------------------- 1 | use std::io::Stdout; 2 | 3 | use clap::crate_name; 4 | use crossterm::event::{KeyCode, KeyModifiers}; 5 | use tui::{ 6 | backend::CrosstermBackend, 7 | layout::{Alignment, Constraint, Direction, Layout, Rect}, 8 | widgets::{Block, Borders, Paragraph}, 9 | Frame, 10 | }; 11 | 12 | pub type CrosstermFrame<'a> = Frame<'a, CrosstermBackend>; 13 | 14 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] 15 | pub struct Spacing { 16 | pub top: u16, 17 | pub bottom: u16, 18 | pub left: u16, 19 | pub right: u16, 20 | } 21 | 22 | impl Spacing { 23 | pub fn new(top: u16, bottom: u16, left: u16, right: u16) -> Self { 24 | Self { 25 | top, 26 | bottom, 27 | left, 28 | right, 29 | } 30 | } 31 | } 32 | 33 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] 34 | pub enum CenterPosition { 35 | Percentage(u16, u16), 36 | AbsoluteInner(u16, u16), 37 | AbsoluteOutter(u16, u16), 38 | } 39 | 40 | pub fn centered_rect(position: CenterPosition, base: Rect) -> Rect { 41 | let (constraints_x, constraints_y) = match position { 42 | CenterPosition::AbsoluteInner(x, y) => ( 43 | [ 44 | Constraint::Length((base.width - x) / 2), 45 | Constraint::Length(x), 46 | Constraint::Length((base.width - x) / 2), 47 | ], 48 | [ 49 | Constraint::Length((base.height - y) / 2), 50 | Constraint::Length(y), 51 | Constraint::Length((base.height - y) / 2), 52 | ], 53 | ), 54 | CenterPosition::AbsoluteOutter(x, y) => ( 55 | [ 56 | Constraint::Length(x), 57 | Constraint::Length(base.width - (x * 2)), 58 | Constraint::Length(x), 59 | ], 60 | [ 61 | Constraint::Length(y), 62 | Constraint::Length(base.height - (y * 2)), 63 | Constraint::Length(y), 64 | ], 65 | ), 66 | CenterPosition::Percentage(x, y) => ( 67 | [ 68 | Constraint::Percentage((100 - x) / 2), 69 | Constraint::Percentage(x), 70 | Constraint::Percentage((100 - x) / 2), 71 | ], 72 | [ 73 | Constraint::Percentage((100 - y) / 2), 74 | Constraint::Percentage(y), 75 | Constraint::Percentage((100 - y) / 2), 76 | ], 77 | ), 78 | }; 79 | let popup_layout = Layout::default() 80 | .direction(Direction::Vertical) 81 | .constraints(constraints_y.as_ref()) 82 | .split(base); 83 | 84 | Layout::default() 85 | .direction(Direction::Horizontal) 86 | .constraints(constraints_x.as_ref()) 87 | .split(popup_layout[1])[1] 88 | } 89 | 90 | pub fn centered_line( 91 | width: u16, 92 | height: u16, 93 | top_padding: u16, 94 | base: Rect, 95 | ) -> Rect { 96 | let (constraints_x, constraints_y) = ( 97 | [ 98 | Constraint::Length((base.width - width) / 2), 99 | Constraint::Length(width), 100 | Constraint::Length((base.width - width) / 2), 101 | ], 102 | [ 103 | Constraint::Length(top_padding), 104 | Constraint::Length(height), 105 | Constraint::Length(base.height - height - top_padding), 106 | ], 107 | ); 108 | 109 | let popup_layout = Layout::default() 110 | .direction(Direction::Vertical) 111 | .constraints(constraints_y.as_ref()) 112 | .split(base); 113 | 114 | Layout::default() 115 | .direction(Direction::Horizontal) 116 | .constraints(constraints_x.as_ref()) 117 | .split(popup_layout[1])[1] 118 | } 119 | 120 | pub fn split_rect( 121 | left_percentage: u16, 122 | direction: Direction, 123 | rect: Rect, 124 | ) -> [Rect; 2] { 125 | let split = Layout::default() 126 | .direction(direction) 127 | .constraints([ 128 | Constraint::Percentage(left_percentage), 129 | Constraint::Percentage(100 - left_percentage), 130 | ]) 131 | .split(rect); 132 | 133 | [split[0], split[1]] 134 | } 135 | 136 | pub fn expand_area(mut area: Rect, spacing: Spacing) -> Rect { 137 | area.x -= spacing.left; 138 | area.y -= spacing.top; 139 | area.width += spacing.left + spacing.right; 140 | area.height += spacing.top + spacing.bottom; 141 | 142 | area 143 | } 144 | 145 | pub fn shrink_area(mut area: Rect, spacing: Spacing) -> Rect { 146 | area.x += spacing.left; 147 | area.y += spacing.top; 148 | area.width -= spacing.left + spacing.right; 149 | area.height -= spacing.top + spacing.bottom; 150 | 151 | area 152 | } 153 | 154 | // TODO: Tidy this 155 | // Returns the rect in which the rest of the app can be 156 | // drawn 157 | pub fn draw_help_menu( 158 | frame: &mut CrosstermFrame, 159 | mut menu_help: Vec<(KeyModifiers, KeyCode, String)>, 160 | max_size: Rect, 161 | ) -> Rect { 162 | menu_help.insert( 163 | 0, 164 | ( 165 | KeyModifiers::CONTROL, 166 | KeyCode::Char('h'), 167 | "Toggle help menu".to_string(), 168 | ), 169 | ); 170 | menu_help.insert( 171 | 1, 172 | ( 173 | KeyModifiers::CONTROL, 174 | KeyCode::Char('d'), 175 | format!("Exit {}", crate_name!()), 176 | ), 177 | ); 178 | let mapped = menu_help.into_iter().map(|(mods, key, msg)| { 179 | let mut mod_str = String::new(); 180 | if mods.contains(KeyModifiers::ALT) { 181 | mod_str += "Alt+"; 182 | } 183 | if mods.contains(KeyModifiers::CONTROL) { 184 | mod_str += "Ctrl+"; 185 | } 186 | if mods.contains(KeyModifiers::SHIFT) { 187 | mod_str += "Shft+"; 188 | } 189 | 190 | mod_str += format!("{} - {}", keycode_to_str(key), msg).as_ref(); 191 | 192 | mod_str 193 | }); 194 | let seperator = ", "; 195 | let mut text = mapped.collect::>().join(seperator); 196 | let mut split = split_text(&text, seperator, max_size.width as usize - 6); 197 | 198 | let mut lines = split.len() as u16; 199 | let mut longest = split 200 | .iter() 201 | .map(|line| line.len()) 202 | .reduce(|l1, l2| l1.max(l2)) 203 | .unwrap_or_else(|| text.len()) as u16; 204 | 205 | if longest + 4 > max_size.width { 206 | text = "Size too small to draw".to_string(); 207 | split = split_text(&text, " ", max_size.width as usize - 4); 208 | 209 | lines = split.len() as u16; 210 | longest = split 211 | .iter() 212 | .map(|line| line.len()) 213 | .reduce(|l1, l2| l1.max(l2)) 214 | .unwrap_or_else(|| text.len()) as u16; 215 | } 216 | 217 | let layouts = Layout::default() 218 | .direction(Direction::Vertical) 219 | .constraints([Constraint::Min(0), Constraint::Length(lines + 2)]) 220 | .split(max_size); 221 | let top = layouts[0]; 222 | let bottom = layouts[1]; 223 | 224 | // Append 4 extra; 2 for padding and 2 for the border 225 | let layout = centered_line(longest + 4, lines + 2, 0, bottom); 226 | 227 | let help_block = Block::default().title("Help").borders(Borders::ALL); 228 | frame.render_widget(help_block, layout); 229 | 230 | for (idx, line) in split.iter().enumerate() { 231 | let layout = centered_line(longest, 1, idx as u16 + 1, bottom); 232 | let paragraph = 233 | Paragraph::new(line.as_ref()).alignment(Alignment::Center); 234 | frame.render_widget(paragraph, layout); 235 | } 236 | 237 | top 238 | } 239 | 240 | fn keycode_to_str(key: KeyCode) -> String { 241 | match key { 242 | KeyCode::F(x) => format!("F{}", x), 243 | KeyCode::Char(x) => x.to_string().to_uppercase(), 244 | KeyCode::Up => "Up".to_string(), 245 | KeyCode::Down => "Down".to_string(), 246 | KeyCode::Left => "Left".to_string(), 247 | KeyCode::Right => "Right".to_string(), 248 | KeyCode::Delete => "Delete".to_string(), 249 | KeyCode::End => "End".to_string(), 250 | KeyCode::Enter => "Enter".to_string(), 251 | KeyCode::Esc => "Escape".to_string(), 252 | KeyCode::Home => "Home".to_string(), 253 | KeyCode::Insert => "Insert".to_string(), 254 | KeyCode::PageUp => "Page Up".to_string(), 255 | KeyCode::PageDown => "Page Down".to_string(), 256 | KeyCode::Tab => "Tab".to_string(), 257 | KeyCode::BackTab => "Backtab".to_string(), 258 | KeyCode::Backspace => "Backspace".to_string(), 259 | KeyCode::Null => String::default(), 260 | } 261 | } 262 | 263 | pub fn split_text(text: &str, sep: &str, max_size: usize) -> Vec { 264 | let mut output = Vec::new(); 265 | let mut input_remaining = text.to_string(); 266 | 267 | while input_remaining.len() > max_size { 268 | let (split, remaining) = 269 | input_remaining.split_at(input_remaining.len().min(max_size)); 270 | 271 | if split.contains(sep) { 272 | let (split, split_remaining) = split.rsplit_once(sep).unwrap(); 273 | output.push(split.trim_matches(' ').to_string()); 274 | input_remaining = (split_remaining.to_string() + remaining) 275 | .trim_matches(' ') 276 | .to_string(); 277 | } else if remaining.starts_with(' ') || split.ends_with(' ') { 278 | output.push(split.trim_matches(' ').to_string()); 279 | input_remaining = remaining.trim_matches(' ').to_string(); 280 | } 281 | } 282 | 283 | output.push(input_remaining); 284 | 285 | output 286 | } 287 | -------------------------------------------------------------------------------- /src/app/mod.rs: -------------------------------------------------------------------------------- 1 | use std::io::stdout; 2 | 3 | use crossterm::{ 4 | event::{ 5 | DisableMouseCapture, EnableMouseCapture, KeyCode, KeyEvent, 6 | KeyModifiers, MouseEvent, 7 | }, 8 | execute, 9 | terminal::{ 10 | disable_raw_mode, enable_raw_mode, EnterAlternateScreen, 11 | LeaveAlternateScreen, 12 | }, 13 | }; 14 | use tokio::task::JoinHandle; 15 | use tui::{ 16 | backend::CrosstermBackend, 17 | widgets::{Block, BorderType, Borders, Clear, Paragraph}, 18 | Terminal, 19 | }; 20 | 21 | use self::{ 22 | context::{Context, Notification}, 23 | event::Event, 24 | helper::{draw_help_menu, expand_area, split_text, CrosstermFrame}, 25 | ui::prelude::{ 26 | message::PopupMessageBuilder, new_confirm_popup, AuthenticateMenu, 27 | Menu, Popup, 28 | }, 29 | }; 30 | use crate::{ 31 | app::{ 32 | context::handle_notification, 33 | event::{handle_event, spawn_event_listener}, 34 | helper::Spacing, 35 | }, 36 | error::Result, 37 | }; 38 | 39 | pub mod context; 40 | pub mod event; 41 | mod helper; 42 | pub mod ui; 43 | 44 | pub struct App { 45 | pub client_handle: Option>, 46 | pub context: Context, 47 | pub menu: Box, 48 | pub popup: Option, 49 | } 50 | 51 | impl App { 52 | pub fn new(context: Context) -> Self { 53 | Self { 54 | context, 55 | client_handle: None, 56 | menu: Box::new(AuthenticateMenu::default()), 57 | popup: None, 58 | } 59 | } 60 | 61 | pub fn draw(&mut self, frame: &mut CrosstermFrame) { 62 | let area = if !self.context.settings.hide_help { 63 | let help_message = if let Some(popup) = &mut self.popup { 64 | popup.get_help_message(&self.context) 65 | } else { 66 | self.menu.get_help_message(&self.context) 67 | }; 68 | 69 | draw_help_menu(frame, help_message, frame.size()) 70 | } else { 71 | frame.size() 72 | }; 73 | 74 | let (min_width, min_height) = self.menu.get_minimum_size(); 75 | if min_width > area.width || min_height > area.height { 76 | let text = split_text( 77 | "Please resize your screen so there is more space to draw!", 78 | " ", 79 | area.width as usize - 2, 80 | ) 81 | .join("\n"); 82 | 83 | let block = Block::default().title("Error").borders(Borders::ALL); 84 | let error = Paragraph::new(text).block(block); 85 | frame.render_widget(error, area); 86 | } else { 87 | self.menu.draw(frame, area, &self.context); 88 | } 89 | 90 | if let Some(popup) = &mut self.popup { 91 | let popup_area = popup.get_area(area); 92 | let popup_block = Block::default() 93 | .borders(Borders::ALL) 94 | .border_type(BorderType::Rounded); 95 | 96 | let popup_border = 97 | expand_area(popup_area, Spacing::new(1, 1, 1, 1)); 98 | frame.render_widget(Clear, popup_border); 99 | frame.render_widget(popup_block, popup_border); 100 | 101 | popup.draw(frame, popup_area, &self.context); 102 | } 103 | } 104 | 105 | pub fn on_key_press(&mut self, key: KeyEvent) { 106 | if key.code == KeyCode::Char('h') && key.modifiers == KeyModifiers::CONTROL 107 | { 108 | self.context.settings.toggle_help(); 109 | return; 110 | } 111 | 112 | if key.code == KeyCode::Char('d') 113 | && key.modifiers == KeyModifiers::CONTROL 114 | { 115 | // TODO: Logging 116 | let _ = self 117 | .context 118 | .send_notification(Notification::QuitApplication(true)); 119 | return; 120 | } 121 | 122 | if let Some(popup) = &mut self.popup { 123 | popup.on_event(Event::Key(key), &self.context); 124 | } else { 125 | self.menu.on_event(Event::Key(key), &self.context); 126 | } 127 | } 128 | 129 | pub fn on_mouse(&mut self, event: MouseEvent) { 130 | if let Some(popup) = &mut self.popup { 131 | popup.on_event(Event::Mouse(event), &self.context); 132 | } else { 133 | self.menu.on_event(Event::Mouse(event), &self.context); 134 | } 135 | } 136 | 137 | pub fn on_tick(&mut self) { 138 | if let Some(popup) = &mut self.popup { 139 | popup.on_event(Event::Tick, &self.context); 140 | } 141 | 142 | self.menu.on_event(Event::Tick, &self.context); 143 | } 144 | 145 | pub fn on_notification(&mut self, notification: Notification) { 146 | match notification { 147 | Notification::QuitApplication(show_confirm) => { 148 | if show_confirm { 149 | self.popup = Some(new_confirm_popup( 150 | "Are you sure you want to exit?", 151 | |ctx| { 152 | // TODO: Logging 153 | let _ = ctx.send_notification( 154 | Notification::QuitApplication(false), 155 | ); 156 | }, 157 | )) 158 | } else { 159 | self.context.settings.quit_application = true; 160 | } 161 | }, 162 | Notification::SetLogin(login) => { 163 | self.client_handle = Some(self.context.start_client(login)) 164 | }, 165 | Notification::ShowPopup(popup) => self.popup = Some(popup), 166 | Notification::HidePopup => self.popup = None, 167 | Notification::SwitchMenu(menu) => self.menu = menu, 168 | Notification::ClientError(why) => { 169 | let popup = PopupMessageBuilder::new(why) 170 | .set_title(Some("Error")) 171 | .to_popup(); 172 | 173 | // TODO: Logging 174 | let _ = self 175 | .context 176 | .send_notification(Notification::ShowPopup(popup)); 177 | }, 178 | } 179 | } 180 | } 181 | 182 | pub fn start_app() -> Result<()> { 183 | let (context, noti_rec) = Context::new(); 184 | 185 | enable_raw_mode().expect("Unable to enable raw mode."); 186 | 187 | let mut out = stdout(); 188 | execute!(out, EnterAlternateScreen, EnableMouseCapture) 189 | .expect("Unable to enter new screen."); 190 | 191 | let backend = CrosstermBackend::new(out); 192 | let mut term = Terminal::new(backend)?; 193 | 194 | let mut app = App::new(context); 195 | 196 | term.clear().expect("Unable to clean terminal."); 197 | 198 | let key_listen_timout = 100; 199 | let event_rec = spawn_event_listener(key_listen_timout); 200 | 201 | loop { 202 | term.draw(|f| app.draw(f)).unwrap(); 203 | 204 | handle_event(&event_rec.receiver, &mut app); 205 | handle_notification(¬i_rec, &mut app); 206 | 207 | if app.context.settings.quit_application { 208 | break; 209 | } 210 | } 211 | 212 | let mut out = stdout(); 213 | disable_raw_mode().expect("Unable to disable raw mode."); 214 | execute!(out, LeaveAlternateScreen, DisableMouseCapture) 215 | .expect("Unable to restore screen."); 216 | 217 | Ok(()) 218 | } 219 | -------------------------------------------------------------------------------- /src/app/ui/menu/authentication.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; 2 | use lazy_static::lazy_static; 3 | use regex::Regex; 4 | use tui::{ 5 | layout::{Alignment, Constraint, Direction, Layout, Rect}, 6 | widgets::{Block, Borders}, 7 | }; 8 | 9 | use super::Menu; 10 | use crate::{ 11 | app::{ 12 | context::{Context, Notification}, 13 | event::Event, 14 | helper::{self, split_rect, CenterPosition, CrosstermFrame}, 15 | ui::prelude::{ 16 | message::PopupMessageBuilder, ButtonWidget, LabeledInputWidget, 17 | ValidationType, Widget, 18 | }, 19 | }, 20 | client::auth::AuthCreds, 21 | }; 22 | 23 | lazy_static! { 24 | static ref USERNAME_REGEX: Regex = Regex::new( 25 | "^@?(?P[a-zA-Z0-9_\\-\\.=/]{2,16}):\ 26 | (?P([a-zA-Z\\d-]+\\.){1,}[a-z]+)$" 27 | ) 28 | .unwrap(); 29 | } 30 | 31 | #[derive(Clone)] 32 | pub struct AuthenticateMenu { 33 | focus_index: u8, 34 | username: LabeledInputWidget, 35 | password: LabeledInputWidget, 36 | submit: ButtonWidget, 37 | } 38 | 39 | impl Default for AuthenticateMenu { 40 | fn default() -> Self { 41 | let username = LabeledInputWidget::new("Username") 42 | .set_selected(true) 43 | .set_validation(ValidationType::Functional(|username| { 44 | USERNAME_REGEX.is_match(&username) 45 | })) 46 | .to_owned(); 47 | 48 | let password = LabeledInputWidget::new("Password") 49 | .set_secret(true) 50 | .set_validation(ValidationType::Functional(|password| { 51 | !password.is_empty() 52 | })) 53 | .to_owned(); 54 | 55 | let submit = ButtonWidget::new("Login", |_| {}); 56 | 57 | Self { 58 | focus_index: 0, 59 | username, 60 | password, 61 | submit, 62 | } 63 | } 64 | } 65 | 66 | impl Menu for AuthenticateMenu { 67 | fn on_event(&mut self, event: Event, ctx: &Context) { 68 | match event { 69 | Event::Tick => self.on_tick(ctx), 70 | Event::Key(key) => self.handle_key(key, ctx), 71 | _ => {}, 72 | } 73 | } 74 | 75 | fn get_help_message( 76 | &mut self, 77 | _ctx: &Context, 78 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 79 | vec![ 80 | (KeyModifiers::NONE, KeyCode::Up, "Select up".to_string()), 81 | (KeyModifiers::NONE, KeyCode::Down, "Select down".to_string()), 82 | ( 83 | KeyModifiers::NONE, 84 | KeyCode::Enter, 85 | "Submit login".to_string(), 86 | ), 87 | (KeyModifiers::NONE, KeyCode::Tab, "Next field".to_string()), 88 | ] 89 | } 90 | 91 | fn draw( 92 | &mut self, 93 | frame: &mut CrosstermFrame, 94 | max_size: Rect, 95 | ctx: &Context, 96 | ) { 97 | if max_size.width >= 42 { 98 | // If help menu is shown, lower the max 99 | // size by 3 so that it 100 | // doesn't move when toggling the menu 101 | let max_size = if !ctx.settings.hide_help { 102 | Layout::default() 103 | .direction(Direction::Vertical) 104 | .constraints([Constraint::Length(3), Constraint::Min(1)]) 105 | .split(max_size)[1] 106 | } else { 107 | max_size 108 | }; 109 | 110 | let size = helper::centered_rect( 111 | CenterPosition::AbsoluteInner(40, 5), 112 | max_size, 113 | ); 114 | 115 | let button_chunk = split_rect( 116 | 40, 117 | Direction::Horizontal, 118 | helper::centered_line(36, 1, 3, size), 119 | )[1]; 120 | 121 | self.username 122 | .render(helper::centered_line(36, 1, 1, size), frame); 123 | self.password 124 | .render(helper::centered_line(36, 1, 2, size), frame); 125 | self.submit.render(button_chunk, frame); 126 | 127 | let frame_block = Block::default() 128 | .title("Login to Matrix") 129 | .borders(Borders::ALL); 130 | frame.render_widget(frame_block, size); 131 | } else { 132 | } 133 | } 134 | 135 | fn get_minimum_size(&mut self) -> (u16, u16) { 136 | (42, 6) 137 | } 138 | } 139 | 140 | impl AuthenticateMenu { 141 | pub fn new(credentials: AuthCreds) -> Self { 142 | let mut default = Self::default(); 143 | default.username.input.set_value(format!( 144 | "@{}:{}", 145 | credentials.username, credentials.homeserver 146 | )); 147 | default.password.input.set_value(credentials.password); 148 | 149 | default 150 | } 151 | 152 | fn on_tick(&mut self, ctx: &Context) { 153 | self.username.on_tick(ctx); 154 | self.password.on_tick(ctx); 155 | self.submit.on_tick(ctx); 156 | } 157 | 158 | fn handle_key(&mut self, key: KeyEvent, ctx: &Context) { 159 | match key.code { 160 | KeyCode::Up | KeyCode::BackTab => { 161 | if self.focus_index == 0 { 162 | self.focus_index = 2; 163 | } else { 164 | self.focus_index -= 1; 165 | } 166 | 167 | self.username.set_selected(self.focus_index == 0); 168 | self.password.set_selected(self.focus_index == 1); 169 | self.submit.set_selected(self.focus_index == 2); 170 | 171 | return; 172 | }, 173 | KeyCode::Down | KeyCode::Tab => { 174 | self.focus_index += 1; 175 | self.focus_index %= 3; 176 | 177 | self.username.set_selected(self.focus_index == 0); 178 | self.password.set_selected(self.focus_index == 1); 179 | self.submit.set_selected(self.focus_index == 2); 180 | 181 | return; 182 | }, 183 | KeyCode::Enter => { 184 | let error = if !self.username.input.is_valid() { 185 | Some("Username should match '@user:domain'.") 186 | } else if !self.password.input.is_valid() { 187 | Some("No password specified.") 188 | } else { 189 | None 190 | }; 191 | 192 | if let Some(msg) = error { 193 | let mut popup_builder = PopupMessageBuilder::new(msg); 194 | let popup = popup_builder 195 | .set_title(Some("Invalid Credentials")) 196 | .set_message_align(Alignment::Center) 197 | .to_popup(); 198 | // TODO: Logging 199 | let _ = 200 | ctx.send_notification(Notification::ShowPopup(popup)); 201 | 202 | return; 203 | } 204 | 205 | let capture = USERNAME_REGEX 206 | .captures(&self.username.input.value) 207 | .expect("Couldn't capture username regex."); 208 | 209 | let un_group = capture.name("un").unwrap(); 210 | let username = un_group.as_str().to_string(); 211 | 212 | let hs_group = capture.name("hs").unwrap(); 213 | let homeserver = hs_group.as_str().to_string(); 214 | 215 | let credentials = AuthCreds { 216 | username, 217 | homeserver, 218 | password: self.password.input.value.clone(), 219 | }; 220 | 221 | // TODO: Logging 222 | let _ = 223 | ctx.send_notification(Notification::SetLogin(credentials)); 224 | }, 225 | _ => {}, 226 | } 227 | 228 | self.username.on_key(ctx, key); 229 | self.password.on_key(ctx, key); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/app/ui/menu/loading.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyModifiers}; 2 | use tui::{ 3 | layout::{Alignment, Constraint, Direction, Layout, Rect}, 4 | widgets::Paragraph, 5 | }; 6 | 7 | use super::{Event, Menu}; 8 | use crate::app::{ 9 | context::Context, 10 | helper::{centered_rect, CenterPosition, CrosstermFrame}, 11 | }; 12 | 13 | #[derive(Debug, Clone)] 14 | pub struct LoadingMenu { 15 | text: String, 16 | tick: u16, 17 | progress: u16, 18 | } 19 | 20 | // Ticks per progress 21 | static BAR_TICK_SPEED: u16 = 1; 22 | static BAR_LENGTH: u16 = 20; 23 | 24 | impl Menu for LoadingMenu { 25 | fn on_event(&mut self, event: Event, ctx: &Context) { 26 | if Event::Tick == event { 27 | self.on_tick(ctx) 28 | } 29 | } 30 | 31 | fn get_help_message( 32 | &mut self, 33 | _ctx: &Context, 34 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 35 | vec![] 36 | } 37 | 38 | fn draw( 39 | &mut self, 40 | frame: &mut CrosstermFrame, 41 | max_size: Rect, 42 | _ctx: &Context, 43 | ) { 44 | let width = (BAR_LENGTH + 2).max(self.text.len() as u16); 45 | let text_height = self.text.split('\n').count() as u16; 46 | let height = 2 + text_height; 47 | 48 | let center = centered_rect( 49 | CenterPosition::AbsoluteInner(width, height), 50 | max_size, 51 | ); 52 | let chunks = Layout::default() 53 | .direction(Direction::Vertical) 54 | .constraints([ 55 | Constraint::Length(text_height), 56 | Constraint::Length(1), // Padding in the middle 57 | Constraint::Length(1), 58 | ]) 59 | .split(center); 60 | 61 | let title = 62 | Paragraph::new(self.text.clone()).alignment(Alignment::Center); 63 | frame.render_widget(title, chunks[0]); 64 | 65 | let progress_bar_text = { 66 | let len = BAR_LENGTH as usize; 67 | let tick = self.progress as usize; 68 | if tick <= len { 69 | "█".repeat(tick) + &" ".repeat(len - tick) 70 | } else { 71 | let tick = tick - len; 72 | " ".repeat(tick) + &"█".repeat(len - tick) 73 | } 74 | }; 75 | let progress_bar = 76 | Paragraph::new(progress_bar_text).alignment(Alignment::Center); 77 | frame.render_widget(progress_bar, chunks[2]); 78 | } 79 | 80 | fn get_minimum_size(&mut self) -> (u16, u16) { 81 | let split = self.text.split('\n').collect::>(); 82 | let longest = split 83 | .iter() 84 | .map(|line| line.len()) 85 | .reduce(|l1, l2| l1.max(l2)) 86 | .unwrap_or_else(|| self.text.len()) as u16; 87 | 88 | let min_width = (BAR_LENGTH + 2).max(longest); 89 | let min_height = split.len() as u16; 90 | 91 | (min_width, min_height) 92 | } 93 | } 94 | 95 | impl LoadingMenu { 96 | pub fn new(text: T) -> Self { 97 | Self { 98 | text: text.to_string(), 99 | tick: 0, 100 | progress: 0, 101 | } 102 | } 103 | 104 | fn on_tick(&mut self, _ctx: &Context) { 105 | self.tick += 1; 106 | self.tick %= BAR_TICK_SPEED; 107 | if self.tick == 0 { 108 | self.progress += 1; 109 | } 110 | self.progress %= BAR_LENGTH * 2; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/app/ui/menu/mod.rs: -------------------------------------------------------------------------------- 1 | use std::ops::DerefMut; 2 | 3 | use crossterm::event::{KeyCode, KeyModifiers}; 4 | use tui::layout::Rect; 5 | 6 | use super::super::{context::Context, helper::CrosstermFrame}; 7 | use crate::app::event::Event; 8 | 9 | pub mod authentication; 10 | pub mod loading; 11 | 12 | pub trait Menu { 13 | fn on_event(&mut self, event: Event, ctx: &Context); 14 | 15 | fn draw( 16 | &mut self, 17 | frame: &mut CrosstermFrame, 18 | max_size: Rect, 19 | ctx: &Context, 20 | ); 21 | 22 | fn get_help_message( 23 | &mut self, 24 | ctx: &Context, 25 | ) -> Vec<(KeyModifiers, KeyCode, String)>; 26 | 27 | fn get_minimum_size(&mut self) -> (u16, u16); 28 | } 29 | 30 | impl Menu for Box { 31 | fn on_event(&mut self, event: Event, ctx: &Context) { 32 | self.deref_mut().on_event(event, ctx) 33 | } 34 | 35 | fn draw( 36 | &mut self, 37 | frame: &mut CrosstermFrame, 38 | max_size: Rect, 39 | ctx: &Context, 40 | ) { 41 | self.deref_mut().draw(frame, max_size, ctx) 42 | } 43 | 44 | fn get_help_message( 45 | &mut self, 46 | ctx: &Context, 47 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 48 | self.deref_mut().get_help_message(ctx) 49 | } 50 | 51 | fn get_minimum_size(&mut self) -> (u16, u16) { 52 | self.deref_mut().get_minimum_size() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/app/ui/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod menu; 2 | pub mod popup; 3 | pub mod prelude; 4 | pub mod widget; 5 | -------------------------------------------------------------------------------- /src/app/ui/popup/confirmation.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; 2 | use lazy_static::lazy_static; 3 | use tui::{ 4 | layout::{Alignment, Constraint, Direction, Layout, Rect}, 5 | style::{Modifier, Style}, 6 | widgets::{Paragraph, Wrap}, 7 | }; 8 | 9 | use super::{Popup, PopupArea, PopupPosition}; 10 | use crate::app::{ 11 | context::{Context, Notification}, 12 | event::Event, 13 | helper::{shrink_area, split_rect, CrosstermFrame, Spacing}, 14 | ui::prelude::{ButtonWidget, Menu, Widget}, 15 | }; 16 | 17 | lazy_static! { 18 | static ref CONFIRM_TITLE: String = "Confirm".to_string(); 19 | static ref TITLE_SPACING: Spacing = Spacing::new(0, 0, 8, 8); 20 | static ref MESSAGE_SPACING: Spacing = Spacing::new(1, 1, 4, 4); 21 | } 22 | 23 | pub fn new_confirm_popup( 24 | message: T, 25 | callback: fn(&Context), 26 | ) -> Popup { 27 | let area = { 28 | let (message_width, message_height) = 29 | format_padding(&message.to_string(), TITLE_SPACING.to_owned()); 30 | let (title_width, title_height) = 31 | format_padding(&CONFIRM_TITLE, MESSAGE_SPACING.to_owned()); 32 | 33 | let width = title_width.max(message_width); 34 | // 1 for button line 35 | let height = title_height + message_height + 1; 36 | 37 | PopupArea::Absolute(width, height, PopupPosition::Center) 38 | }; 39 | 40 | Popup { 41 | menu: Box::new(ConfirmMenu::new(message.to_string(), callback)), 42 | area, 43 | } 44 | } 45 | 46 | struct ConfirmMenu { 47 | message: String, 48 | cancel_button: ButtonWidget, 49 | confirm_button: ButtonWidget, 50 | focus_index: u8, 51 | } 52 | 53 | impl ConfirmMenu { 54 | fn new(message: String, callback: fn(&Context)) -> Self { 55 | let cancel_button = ButtonWidget::new("Cancel", |_| {}) 56 | .set_selected(true) 57 | .to_owned(); 58 | let confirm_button = ButtonWidget::new("Confirm", callback); 59 | 60 | Self { 61 | message, 62 | cancel_button, 63 | confirm_button, 64 | focus_index: 0, 65 | } 66 | } 67 | 68 | fn handle_key(&mut self, key: KeyEvent, ctx: &Context) { 69 | match key.code { 70 | KeyCode::Left => { 71 | if self.focus_index == 0 { 72 | self.focus_index = 1; 73 | } else { 74 | self.focus_index -= 1; 75 | } 76 | 77 | self.cancel_button.set_selected(self.focus_index == 0); 78 | self.confirm_button.set_selected(self.focus_index == 1); 79 | }, 80 | KeyCode::Right => { 81 | self.focus_index += 1; 82 | self.focus_index %= 2; 83 | 84 | self.cancel_button.set_selected(self.focus_index == 0); 85 | self.confirm_button.set_selected(self.focus_index == 1); 86 | }, 87 | KeyCode::Enter => { 88 | self.cancel_button.on_key(ctx, key); 89 | self.confirm_button.on_key(ctx, key); 90 | 91 | // TODO: Logging 92 | let _ = ctx.send_notification(Notification::HidePopup); 93 | }, 94 | _ => {}, 95 | } 96 | } 97 | } 98 | 99 | impl Menu for ConfirmMenu { 100 | fn on_event(&mut self, event: Event, ctx: &Context) { 101 | if let Event::Key(key) = event { 102 | self.handle_key(key, ctx); 103 | } 104 | } 105 | 106 | fn get_help_message( 107 | &mut self, 108 | _ctx: &Context, 109 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 110 | vec![ 111 | (KeyModifiers::NONE, KeyCode::Left, "Select left".to_string()), 112 | ( 113 | KeyModifiers::NONE, 114 | KeyCode::Right, 115 | "Select right".to_string(), 116 | ), 117 | ( 118 | KeyModifiers::NONE, 119 | KeyCode::Enter, 120 | "Confirm selection".to_string(), 121 | ), 122 | ] 123 | } 124 | 125 | fn draw( 126 | &mut self, 127 | frame: &mut CrosstermFrame, 128 | mut max_size: Rect, 129 | _ctx: &Context, 130 | ) { 131 | let (_title_width, title_height) = 132 | format_padding(&CONFIRM_TITLE.to_owned(), TITLE_SPACING.to_owned()); 133 | let split = Layout::default() 134 | .constraints([ 135 | Constraint::Length(title_height), 136 | Constraint::Min(1), 137 | Constraint::Length(1), 138 | ]) 139 | .direction(tui::layout::Direction::Vertical) 140 | .split(max_size); 141 | 142 | let title_block = Paragraph::new(CONFIRM_TITLE.to_owned()) 143 | .wrap(Wrap { 144 | trim: true, 145 | }) 146 | .alignment(Alignment::Center) 147 | .style(Style::default().add_modifier(Modifier::BOLD)); 148 | frame.render_widget( 149 | title_block, 150 | shrink_area(split[0], TITLE_SPACING.to_owned()), 151 | ); 152 | 153 | max_size = split[1]; 154 | 155 | let block = Paragraph::new(self.message.clone()) 156 | .wrap(Wrap { 157 | trim: false, 158 | }) 159 | .alignment(Alignment::Center); 160 | frame.render_widget( 161 | block, 162 | shrink_area(max_size, MESSAGE_SPACING.to_owned()), 163 | ); 164 | 165 | let button_split = split_rect(50, Direction::Horizontal, split[2]); 166 | self.confirm_button.render(button_split[0], frame); 167 | self.cancel_button.render(button_split[1], frame); 168 | } 169 | 170 | fn get_minimum_size(&mut self) -> (u16, u16) { 171 | // TODO: Placeholder 172 | (0, 0) 173 | } 174 | } 175 | 176 | fn format_padding(message: &str, padding: Spacing) -> (u16, u16) { 177 | let lines = message.split('\n'); 178 | let longest_line = lines 179 | .clone() 180 | .map(|line| line.len()) 181 | .reduce(|curr_len, new_len| new_len.max(curr_len)) 182 | .unwrap_or(0); 183 | 184 | let width = longest_line as u16 + padding.left + padding.right; 185 | let height = lines.count() as u16 + padding.top + padding.bottom; 186 | 187 | (width, height) 188 | } 189 | -------------------------------------------------------------------------------- /src/app/ui/popup/message.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyModifiers}; 2 | use tui::{ 3 | layout::{Alignment, Constraint, Layout, Rect}, 4 | style::{Modifier, Style}, 5 | widgets::{Paragraph, Wrap}, 6 | }; 7 | 8 | use super::{Popup, PopupArea, PopupPosition}; 9 | use crate::app::{ 10 | context::Context, 11 | event::Event, 12 | helper::{shrink_area, CrosstermFrame, Spacing}, 13 | ui::prelude::Menu, 14 | }; 15 | 16 | #[derive(Debug, Clone)] 17 | pub struct PopupMessageBuilder { 18 | title: Option, 19 | title_align: Alignment, 20 | message: String, 21 | message_align: Alignment, 22 | position: PopupPosition, 23 | message_padding: Spacing, 24 | title_padding: Spacing, 25 | } 26 | 27 | #[allow(dead_code)] 28 | impl PopupMessageBuilder { 29 | pub fn new(message: T) -> Self 30 | where 31 | T: ToString, { 32 | Self { 33 | title: None, 34 | title_align: Alignment::Center, 35 | message: message.to_string(), 36 | message_align: Alignment::Left, 37 | position: PopupPosition::Center, 38 | message_padding: Spacing::new(1, 1, 4, 4), 39 | title_padding: Spacing::default(), 40 | } 41 | } 42 | 43 | pub fn to_popup(&self) -> Popup { 44 | let area = { 45 | let (message_width, message_height) = 46 | format_padding(&self.message, self.message_padding); 47 | let (title_width, title_height) = if let Some(title) = &self.title { 48 | format_padding(title, self.title_padding) 49 | } else { 50 | (0, 0) 51 | }; 52 | 53 | let width = title_width.max(message_width); 54 | let height = title_height + message_height; 55 | 56 | PopupArea::Absolute(width, height, self.position) 57 | }; 58 | 59 | Popup { 60 | menu: Box::new(MessageMenu { 61 | message: self.message.clone(), 62 | message_align: self.message_align, 63 | message_padding: self.message_padding, 64 | title: self.title.clone(), 65 | title_align: self.title_align, 66 | title_padding: self.title_padding, 67 | }), 68 | area, 69 | } 70 | } 71 | 72 | pub fn set_title(&mut self, title: Option) -> &mut Self 73 | where 74 | T: ToString, { 75 | self.title = title.map(|title| title.to_string()); 76 | self 77 | } 78 | 79 | pub fn set_title_align(&mut self, title_align: Alignment) -> &mut Self { 80 | self.title_align = title_align; 81 | self 82 | } 83 | 84 | pub fn set_message(&mut self, message: T) -> &mut Self 85 | where 86 | T: ToString, { 87 | self.message = message.to_string(); 88 | self 89 | } 90 | 91 | pub fn set_message_align(&mut self, message_align: Alignment) -> &mut Self { 92 | self.message_align = message_align; 93 | self 94 | } 95 | 96 | pub fn set_message_padding( 97 | &mut self, 98 | top: u16, 99 | bottom: u16, 100 | left: u16, 101 | right: u16, 102 | ) -> &mut Self { 103 | self.message_padding = Spacing { 104 | top, 105 | bottom, 106 | left, 107 | right, 108 | }; 109 | self 110 | } 111 | 112 | pub fn set_title_padding( 113 | &mut self, 114 | top: u16, 115 | bottom: u16, 116 | left: u16, 117 | right: u16, 118 | ) -> &mut Self { 119 | self.title_padding = Spacing { 120 | top, 121 | bottom, 122 | left, 123 | right, 124 | }; 125 | self 126 | } 127 | } 128 | 129 | struct MessageMenu { 130 | message: String, 131 | message_align: Alignment, 132 | title: Option, 133 | title_align: Alignment, 134 | message_padding: Spacing, 135 | title_padding: Spacing, 136 | } 137 | 138 | impl Menu for MessageMenu { 139 | fn draw( 140 | &mut self, 141 | frame: &mut CrosstermFrame, 142 | mut max_size: Rect, 143 | _ctx: &Context, 144 | ) { 145 | if let Some(title) = &self.title { 146 | let (_title_width, title_height) = 147 | format_padding(title, self.title_padding); 148 | let split = Layout::default() 149 | .constraints([ 150 | Constraint::Length(title_height), 151 | Constraint::Min(1), 152 | ]) 153 | .direction(tui::layout::Direction::Vertical) 154 | .split(max_size); 155 | 156 | let title_block = Paragraph::new(title.clone()) 157 | .wrap(Wrap { 158 | trim: true, 159 | }) 160 | .alignment(self.title_align) 161 | .style(Style::default().add_modifier(Modifier::BOLD)); 162 | frame.render_widget( 163 | title_block, 164 | shrink_area(split[0], self.title_padding), 165 | ); 166 | 167 | max_size = split[1]; 168 | } 169 | 170 | let block = Paragraph::new(self.message.clone()) 171 | .wrap(Wrap { 172 | trim: false, 173 | }) 174 | .alignment(self.message_align); 175 | frame.render_widget(block, shrink_area(max_size, self.message_padding)); 176 | } 177 | 178 | fn on_event(&mut self, event: Event, ctx: &Context) { 179 | if let Event::Key(key) = event { 180 | if key.code == KeyCode::Esc { 181 | // TODO: Logging 182 | let _ = ctx.send_notification( 183 | crate::app::context::Notification::HidePopup, 184 | ); 185 | } 186 | } 187 | } 188 | 189 | fn get_help_message( 190 | &mut self, 191 | _ctx: &Context, 192 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 193 | vec![(KeyModifiers::NONE, KeyCode::Esc, "Close popup".to_string())] 194 | } 195 | 196 | fn get_minimum_size(&mut self) -> (u16, u16) { 197 | // TODO: Padding 198 | (0, 0) 199 | } 200 | } 201 | 202 | fn format_padding(message: &str, padding: Spacing) -> (u16, u16) { 203 | let lines = message.split('\n'); 204 | let longest_line = lines 205 | .clone() 206 | .map(|line| line.len()) 207 | .reduce(|curr_len, new_len| new_len.max(curr_len)) 208 | .unwrap_or(0); 209 | 210 | let width = longest_line as u16 + padding.left + padding.right; 211 | let height = lines.count() as u16 + padding.top + padding.bottom; 212 | 213 | (width, height) 214 | } 215 | -------------------------------------------------------------------------------- /src/app/ui/popup/mod.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyModifiers}; 2 | use tui::layout::{Constraint, Direction, Layout, Rect}; 3 | 4 | use super::prelude::Menu; 5 | use crate::app::{ 6 | context::Context, 7 | event::Event, 8 | helper::{centered_rect, CenterPosition, CrosstermFrame}, 9 | }; 10 | 11 | pub mod confirmation; 12 | pub mod message; 13 | 14 | #[allow(dead_code)] 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] 16 | pub enum PopupPosition { 17 | TopLeft, 18 | Top, 19 | TopRight, 20 | Left, 21 | Center, 22 | Right, 23 | BottomLeft, 24 | Bottom, 25 | BottomRight, 26 | } 27 | 28 | impl Default for PopupPosition { 29 | fn default() -> Self { 30 | Self::Center 31 | } 32 | } 33 | 34 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] 35 | pub enum PopupArea { 36 | // The absolute x, y and position 37 | Absolute(u16, u16, PopupPosition), 38 | // Takes in the maximum size (usually screen 39 | // size minus the help menu) and return the 40 | // desired size 41 | Dynamic(fn(Rect) -> Rect), 42 | // 43 | } 44 | 45 | impl Default for PopupArea { 46 | fn default() -> Self { 47 | Self::Dynamic(|area| { 48 | centered_rect(CenterPosition::Percentage(60, 40), area) 49 | }) 50 | } 51 | } 52 | 53 | pub struct Popup { 54 | menu: Box, 55 | area: PopupArea, 56 | } 57 | 58 | impl Popup { 59 | pub fn get_area(&self, frame_size: Rect) -> Rect { 60 | match self.area { 61 | PopupArea::Dynamic(func) => func(frame_size), 62 | PopupArea::Absolute(width, height, pos) => { 63 | let max_size = centered_rect( 64 | CenterPosition::AbsoluteOutter(2, 2), 65 | frame_size, 66 | ); 67 | 68 | match pos { 69 | PopupPosition::TopLeft => { 70 | let top = Layout::default() 71 | .direction(Direction::Vertical) 72 | .constraints([ 73 | Constraint::Length(height), 74 | Constraint::Min(0), 75 | ]) 76 | .split(max_size)[0]; 77 | 78 | Layout::default() 79 | .direction(Direction::Horizontal) 80 | .constraints([ 81 | Constraint::Length(width), 82 | Constraint::Min(0), 83 | ]) 84 | .split(top)[0] 85 | }, 86 | PopupPosition::Top => { 87 | let top = Layout::default() 88 | .direction(Direction::Vertical) 89 | .constraints([ 90 | Constraint::Length(height), 91 | Constraint::Min(0), 92 | ]) 93 | .split(max_size)[0]; 94 | 95 | centered_rect( 96 | CenterPosition::AbsoluteInner(width, height), 97 | top, 98 | ) 99 | }, 100 | PopupPosition::TopRight => { 101 | let top = Layout::default() 102 | .direction(Direction::Vertical) 103 | .constraints([ 104 | Constraint::Length(height), 105 | Constraint::Min(0), 106 | ]) 107 | .split(max_size)[0]; 108 | 109 | Layout::default() 110 | .direction(Direction::Horizontal) 111 | .constraints([ 112 | Constraint::Min(0), 113 | Constraint::Length(width), 114 | ]) 115 | .split(top)[1] 116 | }, 117 | PopupPosition::Left => { 118 | let left = Layout::default() 119 | .direction(Direction::Horizontal) 120 | .constraints([ 121 | Constraint::Length(width), 122 | Constraint::Min(0), 123 | ]) 124 | .split(max_size)[0]; 125 | 126 | centered_rect( 127 | CenterPosition::AbsoluteInner(width, height), 128 | left, 129 | ) 130 | }, 131 | PopupPosition::Center => centered_rect( 132 | CenterPosition::AbsoluteInner(width, height), 133 | max_size, 134 | ), 135 | PopupPosition::Right => { 136 | let right = Layout::default() 137 | .direction(Direction::Horizontal) 138 | .constraints([ 139 | Constraint::Min(0), 140 | Constraint::Length(width), 141 | ]) 142 | .split(max_size)[1]; 143 | 144 | centered_rect( 145 | CenterPosition::AbsoluteInner(width, height), 146 | right, 147 | ) 148 | }, 149 | PopupPosition::BottomLeft => { 150 | let bottom = Layout::default() 151 | .direction(Direction::Vertical) 152 | .constraints([ 153 | Constraint::Min(0), 154 | Constraint::Length(height), 155 | ]) 156 | .split(max_size)[1]; 157 | 158 | Layout::default() 159 | .direction(Direction::Horizontal) 160 | .constraints([ 161 | Constraint::Length(width), 162 | Constraint::Min(0), 163 | ]) 164 | .split(bottom)[0] 165 | }, 166 | PopupPosition::Bottom => { 167 | let bottom = Layout::default() 168 | .direction(Direction::Vertical) 169 | .constraints([ 170 | Constraint::Min(0), 171 | Constraint::Length(height), 172 | ]) 173 | .split(max_size)[1]; 174 | 175 | centered_rect( 176 | CenterPosition::AbsoluteInner(width, height), 177 | bottom, 178 | ) 179 | }, 180 | PopupPosition::BottomRight => { 181 | let bottom = Layout::default() 182 | .direction(Direction::Vertical) 183 | .constraints([ 184 | Constraint::Min(0), 185 | Constraint::Length(height), 186 | ]) 187 | .split(max_size)[1]; 188 | 189 | Layout::default() 190 | .direction(Direction::Horizontal) 191 | .constraints([ 192 | Constraint::Min(0), 193 | Constraint::Length(width), 194 | ]) 195 | .split(bottom)[1] 196 | }, 197 | } 198 | }, 199 | } 200 | } 201 | } 202 | 203 | impl Menu for Popup { 204 | fn draw( 205 | &mut self, 206 | frame: &mut CrosstermFrame, 207 | max_size: Rect, 208 | ctx: &Context, 209 | ) { 210 | self.menu.draw(frame, max_size, ctx) 211 | } 212 | 213 | fn on_event(&mut self, event: Event, ctx: &Context) { 214 | self.menu.on_event(event, ctx) 215 | } 216 | 217 | fn get_help_message( 218 | &mut self, 219 | ctx: &Context, 220 | ) -> Vec<(KeyModifiers, KeyCode, String)> { 221 | self.menu.get_help_message(ctx) 222 | } 223 | 224 | fn get_minimum_size(&mut self) -> (u16, u16) { 225 | self.menu.get_minimum_size() 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /src/app/ui/prelude.rs: -------------------------------------------------------------------------------- 1 | pub use super::{ 2 | menu::{authentication::*, loading::*, *}, 3 | popup::{confirmation::*, *}, 4 | widget::{button::*, input::*, *}, 5 | }; 6 | -------------------------------------------------------------------------------- /src/app/ui/widget/button.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyEvent}; 2 | use tui::{ 3 | layout::{Alignment, Rect}, 4 | style::{Modifier, Style}, 5 | widgets::Paragraph, 6 | }; 7 | 8 | use super::Widget; 9 | use crate::app::{context::Context, helper::CrosstermFrame}; 10 | 11 | #[derive(Clone)] 12 | pub struct ButtonWidget { 13 | pub text: String, 14 | pub submit_fn: fn(&Context), 15 | pub selected: bool, 16 | pub enabled: bool, 17 | pub inner_padding: usize, 18 | pub outter_padding: usize, 19 | pub alignment: Alignment, 20 | } 21 | 22 | #[allow(dead_code)] 23 | impl ButtonWidget { 24 | pub fn new(text: T, submit_fn: fn(&Context)) -> Self { 25 | Self { 26 | text: text.to_string(), 27 | submit_fn, 28 | ..Default::default() 29 | } 30 | } 31 | 32 | pub fn set_enabled(&mut self, enabled: bool) -> &mut Self { 33 | self.enabled = enabled; 34 | self 35 | } 36 | 37 | pub fn set_selected(&mut self, selected: bool) -> &mut Self { 38 | if selected != self.selected { 39 | self.on_focus(selected); 40 | } 41 | self 42 | } 43 | 44 | pub fn set_inner_padding(&mut self, inner_padding: usize) -> &mut Self { 45 | self.inner_padding = inner_padding; 46 | self 47 | } 48 | 49 | pub fn set_outter_padding(&mut self, outter_padding: usize) -> &mut Self { 50 | self.outter_padding = outter_padding; 51 | self 52 | } 53 | 54 | pub fn set_alignment(&mut self, alignment: Alignment) -> &mut Self { 55 | self.alignment = alignment; 56 | self 57 | } 58 | } 59 | 60 | impl Default for ButtonWidget { 61 | fn default() -> Self { 62 | Self { 63 | text: String::default(), 64 | submit_fn: |_| {}, 65 | selected: bool::default(), 66 | enabled: true, 67 | inner_padding: usize::default(), 68 | outter_padding: usize::default(), 69 | alignment: Alignment::Center, 70 | } 71 | } 72 | } 73 | 74 | impl Widget for ButtonWidget { 75 | fn render(&mut self, area: Rect, frame: &mut CrosstermFrame) { 76 | let inner_padding = " ".repeat(self.inner_padding); 77 | let outter_padding = " ".repeat(self.outter_padding); 78 | 79 | let mut label = format!( 80 | "{}[{}{}{}]{}", 81 | outter_padding, 82 | inner_padding, 83 | self.text, 84 | inner_padding, 85 | outter_padding 86 | ); 87 | 88 | if label.len() < area.width as usize { 89 | let difference = area.width as usize - label.len(); 90 | match self.alignment { 91 | Alignment::Left => { 92 | label = label + &" ".repeat(difference); 93 | }, 94 | Alignment::Center => { 95 | let left = if difference % 2 == 0 { 96 | difference / 2 97 | } else { 98 | (difference + 1) / 2 99 | }; 100 | label = " ".repeat(left) 101 | + &label 102 | + &" ".repeat(difference - left); 103 | }, 104 | Alignment::Right => { 105 | label = " ".repeat(difference) + &label; 106 | }, 107 | } 108 | } 109 | 110 | let mut style = Style::default(); 111 | if self.selected { 112 | if self.enabled { 113 | style = style.add_modifier(Modifier::BOLD); 114 | } 115 | } else if !self.enabled { 116 | style = style.add_modifier(Modifier::DIM); 117 | }; 118 | 119 | let block = Paragraph::new(label).style(style); 120 | frame.render_widget(block, area); 121 | } 122 | 123 | fn on_key(&mut self, ctx: &Context, key: KeyEvent) { 124 | if self.selected && self.enabled && KeyCode::Enter == key.code { 125 | (self.submit_fn)(ctx); 126 | } 127 | } 128 | 129 | fn on_tick(&mut self, _ctx: &Context) {} 130 | 131 | fn on_focus(&mut self, arrive: bool) { 132 | self.selected = arrive; 133 | } 134 | 135 | fn has_focus(&mut self) -> bool { 136 | self.selected 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/app/ui/widget/input.rs: -------------------------------------------------------------------------------- 1 | use crossterm::event::{KeyCode, KeyEvent}; 2 | use tui::{ 3 | layout::{Alignment, Direction, Rect}, 4 | style::{Color, Style}, 5 | widgets::Paragraph, 6 | }; 7 | 8 | use super::Widget; 9 | use crate::app::{ 10 | context::Context, 11 | helper::{split_rect, CrosstermFrame}, 12 | }; 13 | 14 | const CURSOR_BLINK_TICKS: u8 = 6; 15 | 16 | #[derive(Debug, Clone)] 17 | pub enum ValidationType { 18 | Manual(bool), 19 | Functional(fn(String) -> bool), 20 | } 21 | 22 | impl Default for ValidationType { 23 | fn default() -> Self { 24 | Self::Manual(true) 25 | } 26 | } 27 | 28 | #[derive(Debug, Clone, Default)] 29 | pub struct InputWidget { 30 | pub value: String, 31 | pub max_len: usize, 32 | pub secret: bool, 33 | pub validation: ValidationType, 34 | pub selected: bool, 35 | pub cursor_pos: usize, 36 | scroll_pos: usize, 37 | tick_count: u8, 38 | } 39 | 40 | #[allow(dead_code)] 41 | impl InputWidget { 42 | pub fn set_value(&mut self, value: T) -> &mut Self { 43 | self.value = value.to_string(); 44 | self 45 | } 46 | 47 | pub fn set_max_len(&mut self, len: usize) -> &mut Self { 48 | self.max_len = len; 49 | self 50 | } 51 | 52 | pub fn set_secret(&mut self, secret: bool) -> &mut Self { 53 | self.secret = secret; 54 | self 55 | } 56 | 57 | pub fn set_validation(&mut self, validation: ValidationType) -> &mut Self { 58 | self.validation = validation; 59 | self 60 | } 61 | 62 | pub fn set_selected(&mut self, selected: bool) -> &mut Self { 63 | if selected != self.selected { 64 | self.on_focus(selected); 65 | } 66 | self 67 | } 68 | 69 | pub fn set_cursor_pos(&mut self, pos: usize) -> &mut Self { 70 | self.cursor_pos = pos; 71 | self 72 | } 73 | 74 | pub fn is_valid(&mut self) -> bool { 75 | match self.validation { 76 | ValidationType::Manual(value) => value, 77 | ValidationType::Functional(func) => func(self.value.clone()), 78 | } 79 | } 80 | } 81 | 82 | impl Widget for InputWidget { 83 | fn render(&mut self, area: Rect, frame: &mut CrosstermFrame) { 84 | let max_len = area.width as usize; 85 | 86 | let mut value_text = if self.secret { 87 | "*".repeat(self.value.len()) 88 | } else { 89 | self.value.clone() 90 | }; 91 | 92 | self.scroll_pos = if value_text.len() < max_len { 93 | 0 94 | } else if self.cursor_pos < self.scroll_pos { 95 | self.cursor_pos 96 | } else if max_len + self.scroll_pos <= self.cursor_pos { 97 | self.cursor_pos - max_len + 1 98 | } else { 99 | self.scroll_pos 100 | }; 101 | 102 | if self.scroll_pos > 0 { 103 | let start_pos = self.scroll_pos; 104 | let end_pos = (start_pos + max_len).min(value_text.len()); 105 | value_text = value_text[start_pos..end_pos].to_string(); 106 | } 107 | 108 | let placeholder_text = "_".repeat( 109 | // use min to ensure value isn't over max_len 110 | max_len - value_text.len().min(max_len), 111 | ); 112 | 113 | let mut text = format!("{}{}", value_text, placeholder_text); 114 | 115 | if self.selected && self.tick_count < CURSOR_BLINK_TICKS { 116 | // TODO: Better way to do this 117 | let mut chars: Vec = text.chars().collect(); 118 | let cursor_pos = self.cursor_pos - self.scroll_pos; 119 | 120 | // Ensure that no panic 121 | if chars.get(cursor_pos as usize).is_some() { 122 | chars.remove(cursor_pos); 123 | chars.insert(cursor_pos, '█'); 124 | 125 | text = String::default(); 126 | for c in chars { 127 | text += &c.to_string(); 128 | } 129 | } 130 | } 131 | 132 | let block = 133 | Paragraph::new(text).style(Style::default().fg( 134 | if self.is_valid() { Color::Indexed(8) } else { Color::Red }, 135 | )); 136 | 137 | frame.render_widget(block, area); 138 | } 139 | 140 | fn on_key(&mut self, _ctx: &Context, key: KeyEvent) { 141 | if self.selected { 142 | match key.code { 143 | KeyCode::Char(key) => { 144 | let split = ( 145 | self.value 146 | .chars() 147 | .take(self.cursor_pos) 148 | .collect::(), 149 | self.value 150 | .chars() 151 | .skip(self.cursor_pos) 152 | .collect::(), 153 | ); 154 | self.value = format!("{}{}{}", split.0, key, split.1); 155 | 156 | self.cursor_pos += 1; 157 | }, 158 | KeyCode::Left => self.cursor_pos = self.cursor_pos.max(1) - 1, 159 | KeyCode::Right => { 160 | self.cursor_pos = 161 | (self.cursor_pos + 1).min(self.value.len()) 162 | }, 163 | KeyCode::Backspace => { 164 | if self.cursor_pos != 0 { 165 | self.cursor_pos -= 1; 166 | self.value.remove(self.cursor_pos); 167 | } 168 | }, 169 | KeyCode::Delete => { 170 | if self.value.len() > self.cursor_pos { 171 | self.value.remove(self.cursor_pos); 172 | } 173 | }, 174 | _ => { 175 | // Return so tick count doesn't get 176 | // reset 177 | return; 178 | }, 179 | } 180 | 181 | self.tick_count = 0; 182 | } 183 | } 184 | 185 | fn on_tick(&mut self, _ctx: &Context) { 186 | if self.selected { 187 | self.tick_count += 1; 188 | self.tick_count %= CURSOR_BLINK_TICKS * 2; 189 | } else { 190 | self.tick_count = 0; 191 | } 192 | } 193 | 194 | fn on_focus(&mut self, arrive: bool) { 195 | self.selected = arrive; 196 | } 197 | 198 | fn has_focus(&mut self) -> bool { 199 | self.selected 200 | } 201 | } 202 | 203 | #[derive(Debug, Clone)] 204 | pub struct LabeledInputWidget { 205 | pub label: String, 206 | pub label_align: Alignment, 207 | pub split_percentage: u16, 208 | pub input: InputWidget, 209 | } 210 | 211 | #[allow(dead_code)] 212 | impl LabeledInputWidget { 213 | pub fn new(label: T) -> Self { 214 | Self { 215 | label: label.to_string(), 216 | label_align: Alignment::Left, 217 | split_percentage: 40, 218 | input: InputWidget::default(), 219 | } 220 | } 221 | 222 | pub fn set_selected(&mut self, selected: bool) -> &mut Self { 223 | if selected != self.input.selected { 224 | self.on_focus(selected); 225 | } 226 | self 227 | } 228 | 229 | pub fn set_alignment(&mut self, alignment: Alignment) -> &mut Self { 230 | self.label_align = alignment; 231 | self 232 | } 233 | 234 | pub fn set_split(&mut self, percentage: u16) -> &mut Self { 235 | self.split_percentage = percentage; 236 | self 237 | } 238 | 239 | pub fn set_input( 240 | &mut self, 241 | input_fn: fn(&mut InputWidget) -> &mut InputWidget, 242 | ) -> &mut Self { 243 | self.input = input_fn(&mut self.input).clone(); 244 | self 245 | } 246 | 247 | pub fn set_validation(&mut self, validation: ValidationType) -> &mut Self { 248 | self.input.set_validation(validation); 249 | self 250 | } 251 | 252 | pub fn set_secret(&mut self, secret: bool) -> &mut Self { 253 | self.input.set_secret(secret); 254 | self 255 | } 256 | } 257 | 258 | impl Widget for LabeledInputWidget { 259 | fn on_tick(&mut self, ctx: &Context) { 260 | self.input.on_tick(ctx); 261 | } 262 | 263 | fn on_key(&mut self, ctx: &Context, key: KeyEvent) { 264 | self.input.on_key(ctx, key); 265 | } 266 | 267 | fn render(&mut self, area: Rect, frame: &mut CrosstermFrame) { 268 | let split = 269 | split_rect(self.split_percentage, Direction::Horizontal, area); 270 | 271 | let label = 272 | Paragraph::new(self.label.clone()).alignment(self.label_align); 273 | frame.render_widget(label, split[0]); 274 | self.input.render(split[1], frame); 275 | } 276 | 277 | fn on_focus(&mut self, arrive: bool) { 278 | self.input.on_focus(arrive); 279 | } 280 | 281 | fn has_focus(&mut self) -> bool { 282 | self.input.selected 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /src/app/ui/widget/mod.rs: -------------------------------------------------------------------------------- 1 | use std::ops::DerefMut; 2 | 3 | use crossterm::event::KeyEvent; 4 | use tui::layout::Rect; 5 | 6 | use crate::app::{context::Context, helper::CrosstermFrame}; 7 | 8 | pub mod button; 9 | pub mod input; 10 | 11 | pub trait Widget { 12 | fn on_key(&mut self, ctx: &Context, key: KeyEvent); 13 | fn on_tick(&mut self, ctx: &Context); 14 | 15 | fn render(&mut self, area: Rect, frame: &mut CrosstermFrame); 16 | fn has_focus(&mut self) -> bool; 17 | fn on_focus(&mut self, arrive: bool); 18 | } 19 | 20 | impl Widget for Box { 21 | fn render(&mut self, area: Rect, frame: &mut CrosstermFrame) { 22 | self.deref_mut().render(area, frame) 23 | } 24 | 25 | fn on_key(&mut self, ctx: &Context, key: KeyEvent) { 26 | self.deref_mut().on_key(ctx, key) 27 | } 28 | 29 | fn on_tick(&mut self, ctx: &Context) { 30 | self.deref_mut().on_tick(ctx) 31 | } 32 | 33 | fn has_focus(&mut self) -> bool { 34 | self.deref_mut().has_focus() 35 | } 36 | 37 | fn on_focus(&mut self, arrive: bool) { 38 | self.deref_mut().on_focus(arrive) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/client/auth.rs: -------------------------------------------------------------------------------- 1 | use matrix_sdk::{Client as MatrixClient, ClientConfig}; 2 | use serde::Deserialize; 3 | use url::Url; 4 | 5 | use super::{context::ClientSettings, CLIENT_ID}; 6 | use crate::{fs::DATA_DIRECTORY, handle_login_section}; 7 | 8 | #[derive(Debug, Clone)] 9 | pub struct AuthCreds { 10 | pub username: String, 11 | pub homeserver: String, 12 | pub password: String, 13 | } 14 | 15 | pub async fn get_home_server( 16 | settings: &ClientSettings, 17 | credentials: &AuthCreds, 18 | ) -> Result { 19 | let url = format!( 20 | "https://{}/.well-known/matrix/client", 21 | credentials.homeserver 22 | ); 23 | 24 | let result = handle_login_section!( 25 | settings, 26 | reqwest::get(url).await, 27 | "Unable to connect to home server." 28 | ); 29 | 30 | let text = handle_login_section!( 31 | settings, 32 | result.text().await, 33 | "Unable to get home server response." 34 | ); 35 | 36 | let home_server = handle_login_section!( 37 | settings, 38 | serde_json::from_str::(&text), 39 | "Unable to parse home server response." 40 | ); 41 | 42 | let url = handle_login_section!( 43 | settings, 44 | Url::parse(&home_server.homeserver.url), 45 | "Home server returned malformed URL." 46 | ); 47 | 48 | Ok(url) 49 | } 50 | 51 | pub async fn login( 52 | settings: &ClientSettings, 53 | credentials: &AuthCreds, 54 | home_server: Url, 55 | ) -> Result { 56 | let store_path = DATA_DIRECTORY.as_ref().unwrap(); 57 | let config = ClientConfig::default().store_path(store_path); 58 | 59 | let client = MatrixClient::new_with_config(home_server, config).unwrap(); 60 | let login = client 61 | .login( 62 | &credentials.username.to_lowercase(), 63 | &credentials.password, 64 | None, 65 | Some(&CLIENT_ID), 66 | ) 67 | .await; 68 | 69 | handle_login_section!( 70 | settings, 71 | login, 72 | "Unable to login with provided credentials." 73 | ); 74 | 75 | Ok(client) 76 | } 77 | 78 | #[derive(Deserialize, Debug)] 79 | struct UrlWrapper { 80 | #[serde(rename = "base_url")] 81 | url: String, 82 | } 83 | 84 | #[derive(Deserialize, Debug)] 85 | struct HomeServerResponse { 86 | #[serde(rename = "m.homeserver")] 87 | homeserver: UrlWrapper, 88 | #[serde(rename = "m.identity_server")] 89 | identity_server: UrlWrapper, 90 | } 91 | -------------------------------------------------------------------------------- /src/client/context.rs: -------------------------------------------------------------------------------- 1 | use std::sync::mpsc::{Receiver, SendError, Sender}; 2 | 3 | use super::ClientNotification; 4 | use crate::app::context::Notification; 5 | 6 | #[derive(Debug, Default, Clone)] 7 | pub struct ClientSettings { 8 | pub verbose: bool, 9 | } 10 | 11 | pub struct Context { 12 | sender: Sender, 13 | receiver: Receiver, 14 | pub settings: ClientSettings, 15 | } 16 | 17 | impl Context { 18 | pub fn new( 19 | sender: Sender, 20 | receiver: Receiver, 21 | ) -> Self { 22 | Self { 23 | sender, 24 | receiver, 25 | settings: ClientSettings::default(), 26 | } 27 | } 28 | 29 | pub fn send_notification( 30 | &self, 31 | notification: Notification, 32 | ) -> Result<(), SendError> { 33 | self.sender.send(notification) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/client/event.rs: -------------------------------------------------------------------------------- 1 | use matrix_sdk::EventHandler; 2 | 3 | pub struct EventCallback; 4 | 5 | impl EventHandler for EventCallback {} 6 | -------------------------------------------------------------------------------- /src/client/macros.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! handle_login { 3 | ($client:expr, $val:expr, $msg:expr) => {{ 4 | // TODO: Logging 5 | let menu = LoadingMenu::new($msg); 6 | let notification = Notification::SwitchMenu(Box::new(menu)); 7 | let _ = $client.context.send_notification(notification); 8 | 9 | match $val.await { 10 | Ok(val) => val, 11 | Err(why) => { 12 | // TODO: Logging 13 | let menu = AuthenticateMenu::new($client.credentials.clone()); 14 | let notification = Notification::SwitchMenu(Box::new(menu)); 15 | let _ = $client.context.send_notification(notification); 16 | 17 | // TODO: Logging 18 | let notification = Notification::ClientError(why); 19 | let _ = $client.context.send_notification(notification); 20 | 21 | return; 22 | }, 23 | } 24 | }}; 25 | } 26 | 27 | #[macro_export] 28 | macro_rules! handle_login_section { 29 | ($ctx:expr, $val:expr, $msg:expr) => { 30 | match $val { 31 | Ok(value) => value, 32 | Err(why) => { 33 | return Err(if $ctx.verbose { 34 | format!("{}\n{}", $msg, why) 35 | } else { 36 | $msg.to_string() 37 | }); 38 | }, 39 | } 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /src/client/mod.rs: -------------------------------------------------------------------------------- 1 | use std::sync::mpsc::{self, Sender}; 2 | 3 | use clap::{crate_name, crate_version}; 4 | use lazy_static::lazy_static; 5 | use matrix_sdk::SyncSettings; 6 | 7 | use self::{ 8 | auth::{get_home_server, login, AuthCreds}, 9 | context::Context, 10 | }; 11 | use crate::{ 12 | app::{ 13 | context::Notification, 14 | ui::prelude::{AuthenticateMenu, LoadingMenu}, 15 | }, 16 | handle_login, 17 | }; 18 | 19 | pub mod auth; 20 | mod context; 21 | mod event; 22 | pub mod macros; 23 | 24 | pub enum ClientNotification { 25 | Test, 26 | } 27 | 28 | lazy_static! { 29 | pub static ref CLIENT_ID: String = format!( 30 | "{} v{} ({})", 31 | crate_name!(), 32 | crate_version!(), 33 | if cfg!(windows) { 34 | "Windows" 35 | } else if cfg!(macos) { 36 | "macOS" 37 | } else { 38 | "Linux" 39 | } 40 | ); 41 | } 42 | 43 | pub struct Client { 44 | credentials: AuthCreds, 45 | pub context: Context, 46 | } 47 | 48 | impl Client { 49 | pub fn new( 50 | credentials: AuthCreds, 51 | sender: Sender, 52 | ) -> (Self, Sender) { 53 | let (app_sender, receiver) = mpsc::channel(); 54 | let context = Context::new(sender, receiver); 55 | 56 | ( 57 | Self { 58 | credentials, 59 | context, 60 | }, 61 | app_sender, 62 | ) 63 | } 64 | 65 | pub async fn login(&mut self) { 66 | let settings = &self.context.settings; 67 | 68 | let home_server = handle_login!( 69 | self, 70 | get_home_server(settings, &self.credentials), 71 | "Fetching home server" 72 | ); 73 | 74 | let client = handle_login!( 75 | self, 76 | login(&settings, &self.credentials, home_server), 77 | "Logging in" 78 | ); 79 | 80 | // TODO: Logging 81 | let menu = LoadingMenu::new("Syncing data (this may take a while)"); 82 | let notification = Notification::SwitchMenu(Box::new(menu)); 83 | let _ = self.context.send_notification(notification); 84 | 85 | client.sync(SyncSettings::default()).await; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | error::Error as StdError, 3 | fmt::{self, Write}, 4 | io::{stdout, Error as IoError}, 5 | panic::PanicInfo, 6 | result::Result as StdResult, 7 | }; 8 | 9 | use backtrace::Backtrace; 10 | use crossterm::{ 11 | event::DisableMouseCapture, 12 | execute, 13 | terminal::{disable_raw_mode, LeaveAlternateScreen}, 14 | }; 15 | 16 | use crate::fs::{save_log, LogType}; 17 | 18 | pub type Result = StdResult; 19 | 20 | #[derive(Debug)] 21 | pub enum Error { 22 | ConfigError(String), 23 | OtherError(String), 24 | IoError(IoError), 25 | } 26 | 27 | impl fmt::Display for Error { 28 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 29 | match self { 30 | Self::OtherError(s) | Self::ConfigError(s) => f.write_str(s), 31 | Self::IoError(e) => fmt::Display::fmt(e, f), 32 | } 33 | } 34 | } 35 | 36 | impl StdError for Error { 37 | fn cause(&self) -> Option<&dyn StdError> { 38 | match self { 39 | Self::IoError(e) => Some(e), 40 | _ => None, 41 | } 42 | } 43 | } 44 | 45 | impl From for Error { 46 | fn from(e: IoError) -> Self { 47 | Self::IoError(e) 48 | } 49 | } 50 | 51 | impl From<&str> for Error { 52 | fn from(msg: &str) -> Self { 53 | Self::OtherError(msg.to_string()) 54 | } 55 | } 56 | 57 | // This was heavily inspired by https://crates.io/crates/human-panic 58 | pub fn handle_panic(info: &PanicInfo) { 59 | disable_raw_mode().expect("Unable to disable raw mode."); 60 | execute!(stdout(), LeaveAlternateScreen, DisableMouseCapture) 61 | .expect("Unable to restore screen."); 62 | 63 | let name = env!("CARGO_PKG_NAME"); 64 | let version = env!("CARGO_PKG_VERSION"); 65 | let repo = env!("CARGO_PKG_REPOSITORY"); 66 | 67 | let os_info = os_info::get().to_string(); 68 | 69 | let trace = get_trace(); 70 | let panic_message = info 71 | .message() 72 | .map(|m| format!("{}", m)) 73 | .map_or_else(|| "Unknown".to_string(), |msg| msg); 74 | 75 | let mut buffer = String::new(); 76 | 77 | let _ = write!( 78 | buffer, 79 | "Version: {}\n\ 80 | System: {}\n\ 81 | Cause: {}\n\ 82 | \n\ 83 | Trace: \n\ 84 | {}", 85 | version, os_info, panic_message, trace 86 | ); 87 | 88 | let path = match save_log(LogType::Crash, buffer) { 89 | Ok(path) => format!("A trace log has been saved to '{}'.", path), 90 | Err(why) => format!("Error creating log file: {}", why), 91 | }; 92 | 93 | let submit_url = format!( 94 | "{}/issues/new\ 95 | ?assignees=L3afMe\ 96 | &template=panic-report.md\ 97 | &title=[BUG]%20{}", 98 | repo, 99 | urlencoding::encode(&panic_message), 100 | ); 101 | 102 | println!( 103 | "Oh, no! It seems like {} has crashed, this is kind of embarrassing.\n\ 104 | \n\ 105 | {}\n\ 106 | \n\ 107 | Due to the nature of {}, we respect your privacy and as such\n\ 108 | crash reports are never sent automatically. If you would like\n\ 109 | to help up diagnose this issue, please submit an issue at \n\ 110 | {}\n\ 111 | \n\ 112 | The report contains some basic information about your system\n\ 113 | like the OS and arch type, this can help with diagnosing what\n\ 114 | went wrong, if you don't want this to be sent feel free to\n\ 115 | remove it before submitting.\n", 116 | name, 117 | path, 118 | name, 119 | submit_url, 120 | ); 121 | } 122 | 123 | fn get_trace() -> String { 124 | // https://github.com/rust-cli/human-panic/blob/master/src/report.rs#L47-L51 125 | const SKIP_FRAMES_NUM: usize = 8; 126 | const HEX_WIDTH: usize = std::mem::size_of::() + 2; 127 | 128 | let mut trace = String::new(); 129 | 130 | for (idx, frame) in Backtrace::new() 131 | .frames() 132 | .iter() 133 | .skip(SKIP_FRAMES_NUM) 134 | .enumerate() 135 | { 136 | let newline = if idx == 0 { "" } else { "\n" }; 137 | let ip = frame.ip(); 138 | let _ = write!(trace, "{}{:3}: {:3$?}", newline, idx, ip, HEX_WIDTH); 139 | 140 | let symbols = frame.symbols(); 141 | if symbols.is_empty() { 142 | let _ = write!(trace, " - "); 143 | continue; 144 | } 145 | 146 | for (idx, symbol) in symbols.iter().enumerate() { 147 | if idx != 0 { 148 | let _ = write!(trace, "\n "); 149 | } 150 | 151 | let name = symbol.name().map_or_else( 152 | || "".to_string(), 153 | |symbol| symbol.to_string(), 154 | ); 155 | let _ = write!(trace, " - {}", name); 156 | 157 | if let (Some(file), Some(line), Some(col)) = 158 | (symbol.filename(), symbol.lineno(), symbol.colno()) 159 | { 160 | let _ = write!( 161 | trace, 162 | "\n at {}:{}:{}", 163 | file.display(), 164 | line, 165 | col, 166 | ); 167 | } 168 | } 169 | } 170 | 171 | trace 172 | } 173 | -------------------------------------------------------------------------------- /src/fs.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{create_dir_all, File}, 3 | io::Write, 4 | path::PathBuf, 5 | }; 6 | 7 | use chrono::Local; 8 | use clap::crate_name; 9 | use lazy_static::lazy_static; 10 | 11 | use crate::error::{Error, Result}; 12 | 13 | lazy_static! { 14 | pub static ref CONFIG_DIRECTORY: Result = { 15 | let path = dirs::config_dir() 16 | .ok_or_else(|| Error::ConfigError(String::new()))? 17 | .join(format!(".{}", crate_name!())); 18 | 19 | Ok(path) 20 | }; 21 | pub static ref DATA_DIRECTORY: Result = { 22 | let path = dirs::data_dir() 23 | .ok_or_else(|| Error::ConfigError(String::new()))? 24 | .join(crate_name!()); 25 | 26 | Ok(path) 27 | }; 28 | pub static ref CACHE_DIRECTORY: Result = { 29 | let path = dirs::cache_dir() 30 | .ok_or_else(|| Error::ConfigError(String::new()))? 31 | .join(crate_name!()); 32 | 33 | Ok(path) 34 | }; 35 | } 36 | 37 | pub fn create_directories() -> Result<()> { 38 | let config_dir = CONFIG_DIRECTORY.as_ref().map_err(|_| { 39 | Error::ConfigError("unable to get config directory".to_string()) 40 | })?; 41 | if !config_dir.exists() { 42 | create_dir_all(config_dir)?; 43 | } 44 | 45 | let cache_dir = CACHE_DIRECTORY.as_ref().map_err(|_| { 46 | Error::ConfigError("unable to get cache directory".to_string()) 47 | })?; 48 | if !cache_dir.exists() { 49 | create_dir_all(cache_dir)?; 50 | } 51 | 52 | let data_dir = DATA_DIRECTORY.as_ref().map_err(|_| { 53 | Error::ConfigError("unable to get data directory".to_string()) 54 | })?; 55 | if !data_dir.exists() { 56 | create_dir_all(data_dir)?; 57 | } 58 | 59 | Ok(()) 60 | } 61 | 62 | // More logs to come 63 | pub enum LogType { 64 | Crash, 65 | } 66 | 67 | pub fn save_log(log_type: LogType, log: String) -> Result { 68 | let mut dir = DATA_DIRECTORY.as_ref().unwrap().clone(); 69 | dir.push("logs"); 70 | 71 | if !dir.exists() { 72 | create_dir_all(&dir)?; 73 | } 74 | 75 | let now = Local::now().format("%Y-%m-%d_%H-%M-%S%.3f"); 76 | 77 | match log_type { 78 | LogType::Crash => { 79 | dir.push(format!("crash-report_{}.log", now)); 80 | 81 | let mut file = File::create(&dir)?; 82 | file.write_all(log.as_bytes())?; 83 | 84 | Ok(dir.display().to_string()) 85 | }, 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![feature(panic_info_message)] 2 | 3 | use crate::error::handle_panic; 4 | 5 | mod app; 6 | mod client; 7 | mod error; 8 | mod fs; 9 | 10 | #[tokio::main] 11 | async fn main() { 12 | if let Err(why) = run().await { 13 | eprintln!("{}", why); 14 | } 15 | } 16 | 17 | async fn run() -> error::Result<()> { 18 | if std::env::var("RUST_BACKTRACE").is_err() { 19 | std::panic::set_hook(Box::new(handle_panic)); 20 | } 21 | 22 | fs::create_directories()?; 23 | 24 | app::start_app() 25 | } 26 | --------------------------------------------------------------------------------