@setoelkahfi / svara / commits / 6c63666

rust -_-

mellbacon committed Aug 11, 2022 at 17:31 UTC 6c63666e56914eb4435b5f53798975c7240ec250
3 files changed +257 -32
src-tauri/Cargo.lock
+214 -32
@@ -44,7 +44,7 @@ version = "0.12.1"
44 source = "registry+https://github.com/rust-lang/crates.io-index"
45 checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
46 dependencies = [
47 - "winapi",
47 + "winapi 0.3.9",
48 ]
49
50 [[package]]
@@ -57,10 +57,12 @@ checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
57 name = "app"
58 version = "0.1.0"
59 dependencies = [
60 + "notify",
61 "serde",
62 "serde_json",
63 "tauri",
64 "tauri-build",
65 + "winreg",
66 ]
67
68 [[package]]
@@ -267,6 +269,12 @@ dependencies = [
269 "smallvec",
270 ]
271
272 +[[package]]
273 +name = "cfg-if"
274 +version = "0.1.10"
275 +source = "registry+https://github.com/rust-lang/crates.io-index"
276 +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
277 +
278 [[package]]
279 name = "cfg-if"
280 version = "1.0.0"
@@ -382,7 +390,7 @@ version = "1.3.2"
390 source = "registry+https://github.com/rust-lang/crates.io-index"
391 checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
392 dependencies = [
385 - "cfg-if",
393 + "cfg-if 1.0.0",
394 ]
395
396 [[package]]
@@ -391,7 +399,7 @@ version = "0.5.5"
399 source = "registry+https://github.com/rust-lang/crates.io-index"
400 checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
401 dependencies = [
394 - "cfg-if",
402 + "cfg-if 1.0.0",
403 "crossbeam-utils",
404 ]
405
@@ -401,7 +409,7 @@ version = "0.8.10"
409 source = "registry+https://github.com/rust-lang/crates.io-index"
410 checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
411 dependencies = [
404 - "cfg-if",
412 + "cfg-if 1.0.0",
413 "once_cell",
414 ]
415
@@ -501,7 +509,7 @@ checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce"
509 dependencies = [
510 "libc",
511 "libdbus-sys",
504 - "winapi",
512 + "winapi 0.3.9",
513 ]
514
515 [[package]]
@@ -552,7 +560,7 @@ version = "2.0.0"
560 source = "registry+https://github.com/rust-lang/crates.io-index"
561 checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
562 dependencies = [
555 - "cfg-if",
563 + "cfg-if 1.0.0",
564 "dirs-sys-next",
565 ]
566
@@ -564,7 +572,7 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
572 dependencies = [
573 "libc",
574 "redox_users",
567 - "winapi",
575 + "winapi 0.3.9",
576 ]
577
578 [[package]]
@@ -632,7 +640,7 @@ version = "0.2.17"
640 source = "registry+https://github.com/rust-lang/crates.io-index"
641 checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c"
642 dependencies = [
635 - "cfg-if",
643 + "cfg-if 1.0.0",
644 "libc",
645 "redox_syscall",
646 "windows-sys",
@@ -679,6 +687,41 @@ dependencies = [
687 "percent-encoding",
688 ]
689
690 +[[package]]
691 +name = "fsevent"
692 +version = "0.4.0"
693 +source = "registry+https://github.com/rust-lang/crates.io-index"
694 +checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
695 +dependencies = [
696 + "bitflags",
697 + "fsevent-sys",
698 +]
699 +
700 +[[package]]
701 +name = "fsevent-sys"
702 +version = "2.0.1"
703 +source = "registry+https://github.com/rust-lang/crates.io-index"
704 +checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
705 +dependencies = [
706 + "libc",
707 +]
708 +
709 +[[package]]
710 +name = "fuchsia-zircon"
711 +version = "0.3.3"
712 +source = "registry+https://github.com/rust-lang/crates.io-index"
713 +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
714 +dependencies = [
715 + "bitflags",
716 + "fuchsia-zircon-sys",
717 +]
718 +
719 +[[package]]
720 +name = "fuchsia-zircon-sys"
721 +version = "0.3.3"
722 +source = "registry+https://github.com/rust-lang/crates.io-index"
723 +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
724 +
725 [[package]]
726 name = "futf"
727 version = "0.1.5"
@@ -884,7 +927,7 @@ dependencies = [
927 "libc",
928 "log",
929 "rustversion",
887 - "winapi",
930 + "winapi 0.3.9",
931 ]
932
933 [[package]]
@@ -903,7 +946,7 @@ version = "0.1.16"
946 source = "registry+https://github.com/rust-lang/crates.io-index"
947 checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
948 dependencies = [
906 - "cfg-if",
949 + "cfg-if 1.0.0",
950 "libc",
951 "wasi 0.9.0+wasi-snapshot-preview1",
952 ]
@@ -914,7 +957,7 @@ version = "0.2.7"
957 source = "registry+https://github.com/rust-lang/crates.io-index"
958 checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
959 dependencies = [
917 - "cfg-if",
960 + "cfg-if 1.0.0",
961 "libc",
962 "wasi 0.11.0+wasi-snapshot-preview1",
963 ]
@@ -946,7 +989,7 @@ dependencies = [
989 "gobject-sys",
990 "libc",
991 "system-deps 6.0.2",
949 - "winapi",
992 + "winapi 0.3.9",
993 ]
994
995 [[package]]
@@ -1227,13 +1270,42 @@ dependencies = [
1270 "adler32",
1271 ]
1272
1273 +[[package]]
1274 +name = "inotify"
1275 +version = "0.7.1"
1276 +source = "registry+https://github.com/rust-lang/crates.io-index"
1277 +checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
1278 +dependencies = [
1279 + "bitflags",
1280 + "inotify-sys",
1281 + "libc",
1282 +]
1283 +
1284 +[[package]]
1285 +name = "inotify-sys"
1286 +version = "0.1.5"
1287 +source = "registry+https://github.com/rust-lang/crates.io-index"
1288 +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
1289 +dependencies = [
1290 + "libc",
1291 +]
1292 +
1293 [[package]]
1294 name = "instant"
1295 version = "0.1.12"
1296 source = "registry+https://github.com/rust-lang/crates.io-index"
1297 checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
1298 dependencies = [
1236 - "cfg-if",
1299 + "cfg-if 1.0.0",
1300 +]
1301 +
1302 +[[package]]
1303 +name = "iovec"
1304 +version = "0.1.4"
1305 +source = "registry+https://github.com/rust-lang/crates.io-index"
1306 +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
1307 +dependencies = [
1308 + "libc",
1309 ]
1310
1311 [[package]]
@@ -1325,6 +1397,16 @@ dependencies = [
1397 "treediff",
1398 ]
1399
1400 +[[package]]
1401 +name = "kernel32-sys"
1402 +version = "0.2.2"
1403 +source = "registry+https://github.com/rust-lang/crates.io-index"
1404 +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
1405 +dependencies = [
1406 + "winapi 0.2.8",
1407 + "winapi-build",
1408 +]
1409 +
1410 [[package]]
1411 name = "kuchiki"
1412 version = "0.8.1"
@@ -1343,6 +1425,12 @@ version = "1.4.0"
1425 source = "registry+https://github.com/rust-lang/crates.io-index"
1426 checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
1427
1428 +[[package]]
1429 +name = "lazycell"
1430 +version = "1.3.0"
1431 +source = "registry+https://github.com/rust-lang/crates.io-index"
1432 +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
1433 +
1434 [[package]]
1435 name = "libc"
1436 version = "0.2.126"
@@ -1383,7 +1471,7 @@ version = "0.4.17"
1471 source = "registry+https://github.com/rust-lang/crates.io-index"
1472 checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
1473 dependencies = [
1386 - "cfg-if",
1474 + "cfg-if 1.0.0",
1475 ]
1476
1477 [[package]]
@@ -1392,7 +1480,7 @@ version = "0.5.6"
1480 source = "registry+https://github.com/rust-lang/crates.io-index"
1481 checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5"
1482 dependencies = [
1395 - "cfg-if",
1483 + "cfg-if 1.0.0",
1484 "generator",
1485 "scoped-tls",
1486 "serde",
@@ -1482,6 +1570,49 @@ dependencies = [
1570 "adler",
1571 ]
1572
1573 +[[package]]
1574 +name = "mio"
1575 +version = "0.6.23"
1576 +source = "registry+https://github.com/rust-lang/crates.io-index"
1577 +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
1578 +dependencies = [
1579 + "cfg-if 0.1.10",
1580 + "fuchsia-zircon",
1581 + "fuchsia-zircon-sys",
1582 + "iovec",
1583 + "kernel32-sys",
1584 + "libc",
1585 + "log",
1586 + "miow",
1587 + "net2",
1588 + "slab",
1589 + "winapi 0.2.8",
1590 +]
1591 +
1592 +[[package]]
1593 +name = "mio-extras"
1594 +version = "2.0.6"
1595 +source = "registry+https://github.com/rust-lang/crates.io-index"
1596 +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
1597 +dependencies = [
1598 + "lazycell",
1599 + "log",
1600 + "mio",
1601 + "slab",
1602 +]
1603 +
1604 +[[package]]
1605 +name = "miow"
1606 +version = "0.2.2"
1607 +source = "registry+https://github.com/rust-lang/crates.io-index"
1608 +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
1609 +dependencies = [
1610 + "kernel32-sys",
1611 + "net2",
1612 + "winapi 0.2.8",
1613 + "ws2_32-sys",
1614 +]
1615 +
1616 [[package]]
1617 name = "native-tls"
1618 version = "0.2.10"
@@ -1528,6 +1659,17 @@ dependencies = [
1659 "jni-sys",
1660 ]
1661
1662 +[[package]]
1663 +name = "net2"
1664 +version = "0.2.37"
1665 +source = "registry+https://github.com/rust-lang/crates.io-index"
1666 +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
1667 +dependencies = [
1668 + "cfg-if 0.1.10",
1669 + "libc",
1670 + "winapi 0.3.9",
1671 +]
1672 +
1673 [[package]]
1674 name = "new_debug_unreachable"
1675 version = "1.0.4"
@@ -1540,6 +1682,24 @@ version = "0.1.14"
1682 source = "registry+https://github.com/rust-lang/crates.io-index"
1683 checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
1684
1685 +[[package]]
1686 +name = "notify"
1687 +version = "4.0.17"
1688 +source = "registry+https://github.com/rust-lang/crates.io-index"
1689 +checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257"
1690 +dependencies = [
1691 + "bitflags",
1692 + "filetime",
1693 + "fsevent",
1694 + "fsevent-sys",
1695 + "inotify",
1696 + "libc",
1697 + "mio",
1698 + "mio-extras",
1699 + "walkdir",
1700 + "winapi 0.3.9",
1701 +]
1702 +
1703 [[package]]
1704 name = "notify-rust"
1705 version = "4.5.8"
@@ -1694,7 +1854,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1854 checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0"
1855 dependencies = [
1856 "bitflags",
1697 - "cfg-if",
1857 + "cfg-if 1.0.0",
1858 "foreign-types",
1859 "libc",
1860 "once_cell",
@@ -1740,7 +1900,7 @@ checksum = "0eca3ecae1481e12c3d9379ec541b238a16f0b75c9a409942daa8ec20dbfdb62"
1900 dependencies = [
1901 "log",
1902 "serde",
1743 - "winapi",
1903 + "winapi 0.3.9",
1904 ]
1905
1906 [[package]]
@@ -1750,7 +1910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1910 checksum = "2c92f2b54f081d635c77e7120862d48db8e91f7f21cef23ab1b4fe9971c59f55"
1911 dependencies = [
1912 "libc",
1753 - "winapi",
1913 + "winapi 0.3.9",
1914 ]
1915
1916 [[package]]
@@ -1811,12 +1971,12 @@ version = "0.8.5"
1971 source = "registry+https://github.com/rust-lang/crates.io-index"
1972 checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
1973 dependencies = [
1814 - "cfg-if",
1974 + "cfg-if 1.0.0",
1975 "instant",
1976 "libc",
1977 "redox_syscall",
1978 "smallvec",
1819 - "winapi",
1979 + "winapi 0.3.9",
1980 ]
1981
1982 [[package]]
@@ -1825,7 +1985,7 @@ version = "0.9.3"
1985 source = "registry+https://github.com/rust-lang/crates.io-index"
1986 checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
1987 dependencies = [
1828 - "cfg-if",
1988 + "cfg-if 1.0.0",
1989 "libc",
1990 "redox_syscall",
1991 "smallvec",
@@ -2225,7 +2385,7 @@ version = "0.5.3"
2385 source = "registry+https://github.com/rust-lang/crates.io-index"
2386 checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
2387 dependencies = [
2228 - "winapi",
2388 + "winapi 0.3.9",
2389 ]
2390
2391 [[package]]
@@ -2504,7 +2664,7 @@ version = "0.10.2"
2664 source = "registry+https://github.com/rust-lang/crates.io-index"
2665 checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676"
2666 dependencies = [
2507 - "cfg-if",
2667 + "cfg-if 1.0.0",
2668 "cpufeatures",
2669 "digest",
2670 ]
@@ -2525,7 +2685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2685 checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef"
2686 dependencies = [
2687 "libc",
2528 - "winapi",
2688 + "winapi 0.3.9",
2689 ]
2690
2691 [[package]]
@@ -2918,12 +3078,12 @@ version = "3.3.0"
3078 source = "registry+https://github.com/rust-lang/crates.io-index"
3079 checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
3080 dependencies = [
2921 - "cfg-if",
3081 + "cfg-if 1.0.0",
3082 "fastrand",
3083 "libc",
3084 "redox_syscall",
3085 "remove_dir_all",
2926 - "winapi",
3086 + "winapi 0.3.9",
3087 ]
3088
3089 [[package]]
@@ -3026,7 +3186,7 @@ version = "0.1.35"
3186 source = "registry+https://github.com/rust-lang/crates.io-index"
3187 checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
3188 dependencies = [
3029 - "cfg-if",
3189 + "cfg-if 1.0.0",
3190 "pin-project-lite",
3191 "tracing-attributes",
3192 "tracing-core",
@@ -3230,7 +3390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3390 checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
3391 dependencies = [
3392 "same-file",
3233 - "winapi",
3393 + "winapi 0.3.9",
3394 "winapi-util",
3395 ]
3396
@@ -3252,7 +3412,7 @@ version = "0.2.81"
3412 source = "registry+https://github.com/rust-lang/crates.io-index"
3413 checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
3414 dependencies = [
3255 - "cfg-if",
3415 + "cfg-if 1.0.0",
3416 "wasm-bindgen-macro",
3417 ]
3418
@@ -3277,7 +3437,7 @@ version = "0.4.31"
3437 source = "registry+https://github.com/rust-lang/crates.io-index"
3438 checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f"
3439 dependencies = [
3280 - "cfg-if",
3440 + "cfg-if 1.0.0",
3441 "js-sys",
3442 "wasm-bindgen",
3443 "web-sys",
@@ -3412,6 +3572,12 @@ version = "2.1.1"
3572 source = "registry+https://github.com/rust-lang/crates.io-index"
3573 checksum = "ee583bdc5ff1cf9db20e9db5bb3ff4c3089a8f6b8b31aff265c9aba85812db86"
3574
3575 +[[package]]
3576 +name = "winapi"
3577 +version = "0.2.8"
3578 +source = "registry+https://github.com/rust-lang/crates.io-index"
3579 +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
3580 +
3581 [[package]]
3582 name = "winapi"
3583 version = "0.3.9"
@@ -3422,6 +3588,12 @@ dependencies = [
3588 "winapi-x86_64-pc-windows-gnu",
3589 ]
3590
3591 +[[package]]
3592 +name = "winapi-build"
3593 +version = "0.1.1"
3594 +source = "registry+https://github.com/rust-lang/crates.io-index"
3595 +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
3596 +
3597 [[package]]
3598 name = "winapi-i686-pc-windows-gnu"
3599 version = "0.4.0"
@@ -3434,7 +3606,7 @@ version = "0.1.5"
3606 source = "registry+https://github.com/rust-lang/crates.io-index"
3607 checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
3608 dependencies = [
3437 - "winapi",
3609 + "winapi 0.3.9",
3610 ]
3611
3612 [[package]]
@@ -3604,7 +3776,7 @@ version = "0.10.1"
3776 source = "registry+https://github.com/rust-lang/crates.io-index"
3777 checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
3778 dependencies = [
3607 - "winapi",
3779 + "winapi 0.3.9",
3780 ]
3781
3782 [[package]]
@@ -3659,6 +3831,16 @@ dependencies = [
3831 "windows-implement",
3832 ]
3833
3834 +[[package]]
3835 +name = "ws2_32-sys"
3836 +version = "0.2.1"
3837 +source = "registry+https://github.com/rust-lang/crates.io-index"
3838 +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
3839 +dependencies = [
3840 + "winapi 0.2.8",
3841 + "winapi-build",
3842 +]
3843 +
3844 [[package]]
3845 name = "x11"
3846 version = "2.19.1"
src-tauri/Cargo.toml
+2
@@ -18,6 +18,8 @@ tauri-build = { version = "1.0.3", features = [] }
18 serde_json = "1.0"
19 serde = { version = "1.0", features = ["derive"] }
20 tauri = { version = "1.0.3", features = ["api-all"] }
21 +winreg = "0.10"
22 +notify = "4.0.0"
23
24 [features]
25 # by default Tauri runs in production mode
src-tauri/src/directory.rs new
+41
@@ -0,0 +1,41 @@
1 +extern crate winreg;
2 +use winreg::RegKey;
3 +use winreg::enums::*;
4 +
5 +use notify::{Watcher, RecursiveMode, watcher};
6 +use std::sync::mpsc::channel;
7 +use std::time::Duration;
8 +
9 +pub fn get_file_extensions(input: &str) -> &str {
10 + println!("File extensions, registered in system:");
11 + for i in RegKey::predef(HKEY_CLASSES_ROOT)
12 + .enum_keys().map(|x| x.unwrap())
13 + .filter(|x| x.starts_with("."))
14 + {
15 + println!("{}", i);
16 + }
17 + return input;
18 +}
19 +
20 +pub fn watch_directory(directory: &str) -> String {
21 + // Create a channel to receive the events.
22 + let (sender, receiver) = channel();
23 +
24 + // Create a watcher object, delivering debounced events.
25 + // The notification back-end is selected based on the platform.
26 + let mut watcher = watcher(sender, Duration::from_secs(10)).unwrap();
27 +
28 + // Add a path to be watched. All files and directories at that path and
29 + // below will be monitored for changes.
30 + watcher.watch(directory, RecursiveMode::Recursive).unwrap();
31 + loop {
32 + match receiver.recv() {
33 + Ok(event) => {
34 + println!("{:?}", event);
35 + let x = format!("{:?}", event);
36 + return x;
37 + },
38 + Err(e) => println!("watch error: {:?}", e),
39 + }
40 + }
41 +}
\ No newline at end of file