Repo of no-std crates for my personal embedded projects

feat: Config builder crate

Changed files
+678 -10
sachy-config
+492 -10
Cargo.lock
··· 3 3 version = 4 4 4 5 5 [[package]] 6 + name = "addr2line" 7 + version = "0.25.1" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" 10 + dependencies = [ 11 + "gimli", 12 + ] 13 + 14 + [[package]] 15 + name = "adler2" 16 + version = "2.0.1" 17 + source = "registry+https://github.com/rust-lang/crates.io-index" 18 + checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" 19 + 20 + [[package]] 6 21 name = "aho-corasick" 7 22 version = "1.1.4" 8 23 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 22 37 version = "1.5.0" 23 38 source = "registry+https://github.com/rust-lang/crates.io-index" 24 39 checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" 40 + 41 + [[package]] 42 + name = "backtrace" 43 + version = "0.3.76" 44 + source = "registry+https://github.com/rust-lang/crates.io-index" 45 + checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" 46 + dependencies = [ 47 + "addr2line", 48 + "cfg-if", 49 + "libc", 50 + "miniz_oxide", 51 + "object", 52 + "rustc-demangle", 53 + "windows-link", 54 + ] 55 + 56 + [[package]] 57 + name = "backtrace-ext" 58 + version = "0.2.1" 59 + source = "registry+https://github.com/rust-lang/crates.io-index" 60 + checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" 61 + dependencies = [ 62 + "backtrace", 63 + ] 25 64 26 65 [[package]] 27 66 name = "bitflags" ··· 424 463 ] 425 464 426 465 [[package]] 466 + name = "facet" 467 + version = "0.34.0" 468 + source = "registry+https://github.com/rust-lang/crates.io-index" 469 + checksum = "72ee49c69f8a398d01d9b160e3e6288c1a5f7d756e8377f0530bbb4019aa1616" 470 + dependencies = [ 471 + "autocfg", 472 + "facet-core", 473 + "facet-macros", 474 + "static_assertions", 475 + ] 476 + 477 + [[package]] 478 + name = "facet-core" 479 + version = "0.34.0" 480 + source = "registry+https://github.com/rust-lang/crates.io-index" 481 + checksum = "87ca85b6f8c289d86e5a0daa6b402ed1edf4001ad9b6ead357cc047fff680e0d" 482 + dependencies = [ 483 + "autocfg", 484 + "impls", 485 + ] 486 + 487 + [[package]] 488 + name = "facet-kdl" 489 + version = "0.34.0" 490 + source = "registry+https://github.com/rust-lang/crates.io-index" 491 + checksum = "5b52d9f35c93a85109d9d1d9042fbc1b02972c28eaceb36374995e9d166f4019" 492 + dependencies = [ 493 + "facet", 494 + "facet-core", 495 + "facet-reflect", 496 + "facet-singularize", 497 + "facet-solver", 498 + "kdl", 499 + "log", 500 + "miette", 501 + ] 502 + 503 + [[package]] 504 + name = "facet-macro-parse" 505 + version = "0.34.0" 506 + source = "registry+https://github.com/rust-lang/crates.io-index" 507 + checksum = "294183c810413075f9c3f075c0b3554d04ad06207dad18debc649a48779321f6" 508 + dependencies = [ 509 + "facet-macro-types", 510 + "proc-macro2", 511 + "quote", 512 + ] 513 + 514 + [[package]] 515 + name = "facet-macro-types" 516 + version = "0.34.0" 517 + source = "registry+https://github.com/rust-lang/crates.io-index" 518 + checksum = "8335dd3290eb5780aa40fb5b0da6c1a1c08980af6ada54c2e0d8cbbcd52b8f33" 519 + dependencies = [ 520 + "proc-macro2", 521 + "quote", 522 + "unsynn", 523 + ] 524 + 525 + [[package]] 526 + name = "facet-macros" 527 + version = "0.34.0" 528 + source = "registry+https://github.com/rust-lang/crates.io-index" 529 + checksum = "54f7c8e20f24f6c933290da20e76ce8b62a28ea7f16ea173a1aa21cb2ebf61f0" 530 + dependencies = [ 531 + "facet-macros-impl", 532 + ] 533 + 534 + [[package]] 535 + name = "facet-macros-impl" 536 + version = "0.34.0" 537 + source = "registry+https://github.com/rust-lang/crates.io-index" 538 + checksum = "fc36ba0859bb5fc539e9fb9ed4dab7a5af3b9dbf080e92adaeb5041c58971fcb" 539 + dependencies = [ 540 + "facet-macro-parse", 541 + "facet-macro-types", 542 + "proc-macro2", 543 + "quote", 544 + "strsim", 545 + "unsynn", 546 + ] 547 + 548 + [[package]] 549 + name = "facet-reflect" 550 + version = "0.34.0" 551 + source = "registry+https://github.com/rust-lang/crates.io-index" 552 + checksum = "d6ab47f7ccaed7b782b4cdbfa3482f16720c0e7e31c38bf5f7da8b8f8c988690" 553 + dependencies = [ 554 + "facet-core", 555 + "miette", 556 + ] 557 + 558 + [[package]] 559 + name = "facet-singularize" 560 + version = "0.34.0" 561 + source = "registry+https://github.com/rust-lang/crates.io-index" 562 + checksum = "cd14cadea48902b862d1f9256f1eac9102680d3fc105e5888008e219f2de6023" 563 + 564 + [[package]] 565 + name = "facet-solver" 566 + version = "0.34.0" 567 + source = "registry+https://github.com/rust-lang/crates.io-index" 568 + checksum = "e7a23bcde5d4f562dfed81ca31c15c241536b1b6ef0a6e46cc17d8963b9f9f33" 569 + dependencies = [ 570 + "facet-core", 571 + "facet-reflect", 572 + "strsim", 573 + ] 574 + 575 + [[package]] 427 576 name = "fastrand" 428 577 version = "2.3.0" 429 578 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 480 629 "r-efi", 481 630 "wasip2", 482 631 ] 632 + 633 + [[package]] 634 + name = "gimli" 635 + version = "0.32.3" 636 + source = "registry+https://github.com/rust-lang/crates.io-index" 637 + checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" 483 638 484 639 [[package]] 485 640 name = "gpio-cdev" ··· 578 733 checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 579 734 580 735 [[package]] 736 + name = "impls" 737 + version = "1.0.3" 738 + source = "registry+https://github.com/rust-lang/crates.io-index" 739 + checksum = "7a46645bbd70538861a90d0f26c31537cdf1e44aae99a794fb75a664b70951bc" 740 + 741 + [[package]] 581 742 name = "indexmap" 582 743 version = "2.12.1" 583 744 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 598 759 ] 599 760 600 761 [[package]] 762 + name = "is_ci" 763 + version = "1.2.0" 764 + source = "registry+https://github.com/rust-lang/crates.io-index" 765 + checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" 766 + 767 + [[package]] 601 768 name = "itertools" 602 769 version = "0.14.0" 603 770 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 611 778 version = "1.0.15" 612 779 source = "registry+https://github.com/rust-lang/crates.io-index" 613 780 checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 781 + 782 + [[package]] 783 + name = "kdl" 784 + version = "6.5.0" 785 + source = "registry+https://github.com/rust-lang/crates.io-index" 786 + checksum = "81a29e7b50079ff44549f68c0becb1c73d7f6de2a4ea952da77966daf3d4761e" 787 + dependencies = [ 788 + "miette", 789 + "num", 790 + "winnow 0.6.24", 791 + ] 614 792 615 793 [[package]] 616 794 name = "libc" ··· 706 884 ] 707 885 708 886 [[package]] 887 + name = "miette" 888 + version = "7.6.0" 889 + source = "registry+https://github.com/rust-lang/crates.io-index" 890 + checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" 891 + dependencies = [ 892 + "backtrace", 893 + "backtrace-ext", 894 + "cfg-if", 895 + "miette-derive", 896 + "owo-colors", 897 + "supports-color", 898 + "supports-hyperlinks", 899 + "supports-unicode", 900 + "terminal_size", 901 + "textwrap", 902 + "unicode-width 0.1.14", 903 + ] 904 + 905 + [[package]] 906 + name = "miette-derive" 907 + version = "7.6.0" 908 + source = "registry+https://github.com/rust-lang/crates.io-index" 909 + checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" 910 + dependencies = [ 911 + "proc-macro2", 912 + "quote", 913 + "syn", 914 + ] 915 + 916 + [[package]] 917 + name = "miniz_oxide" 918 + version = "0.8.9" 919 + source = "registry+https://github.com/rust-lang/crates.io-index" 920 + checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" 921 + dependencies = [ 922 + "adler2", 923 + ] 924 + 925 + [[package]] 709 926 name = "multimap" 710 927 version = "0.10.1" 711 928 source = "registry+https://github.com/rust-lang/crates.io-index" 712 929 checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" 713 930 714 931 [[package]] 932 + name = "mutants" 933 + version = "0.0.3" 934 + source = "registry+https://github.com/rust-lang/crates.io-index" 935 + checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126" 936 + 937 + [[package]] 715 938 name = "nb" 716 939 version = "0.1.3" 717 940 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 764 987 ] 765 988 766 989 [[package]] 990 + name = "num" 991 + version = "0.4.3" 992 + source = "registry+https://github.com/rust-lang/crates.io-index" 993 + checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" 994 + dependencies = [ 995 + "num-bigint", 996 + "num-complex", 997 + "num-integer", 998 + "num-iter", 999 + "num-rational", 1000 + "num-traits", 1001 + ] 1002 + 1003 + [[package]] 1004 + name = "num-bigint" 1005 + version = "0.4.6" 1006 + source = "registry+https://github.com/rust-lang/crates.io-index" 1007 + checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" 1008 + dependencies = [ 1009 + "num-integer", 1010 + "num-traits", 1011 + ] 1012 + 1013 + [[package]] 1014 + name = "num-complex" 1015 + version = "0.4.6" 1016 + source = "registry+https://github.com/rust-lang/crates.io-index" 1017 + checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" 1018 + dependencies = [ 1019 + "num-traits", 1020 + ] 1021 + 1022 + [[package]] 767 1023 name = "num-derive" 768 1024 version = "0.4.2" 769 1025 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 775 1031 ] 776 1032 777 1033 [[package]] 1034 + name = "num-integer" 1035 + version = "0.1.46" 1036 + source = "registry+https://github.com/rust-lang/crates.io-index" 1037 + checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 1038 + dependencies = [ 1039 + "num-traits", 1040 + ] 1041 + 1042 + [[package]] 1043 + name = "num-iter" 1044 + version = "0.1.45" 1045 + source = "registry+https://github.com/rust-lang/crates.io-index" 1046 + checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" 1047 + dependencies = [ 1048 + "autocfg", 1049 + "num-integer", 1050 + "num-traits", 1051 + ] 1052 + 1053 + [[package]] 778 1054 name = "num-modular" 779 1055 version = "0.6.1" 780 1056 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 790 1066 ] 791 1067 792 1068 [[package]] 1069 + name = "num-rational" 1070 + version = "0.4.2" 1071 + source = "registry+https://github.com/rust-lang/crates.io-index" 1072 + checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" 1073 + dependencies = [ 1074 + "num-bigint", 1075 + "num-integer", 1076 + "num-traits", 1077 + ] 1078 + 1079 + [[package]] 793 1080 name = "num-traits" 794 1081 version = "0.2.19" 795 1082 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 799 1086 ] 800 1087 801 1088 [[package]] 1089 + name = "object" 1090 + version = "0.37.3" 1091 + source = "registry+https://github.com/rust-lang/crates.io-index" 1092 + checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" 1093 + dependencies = [ 1094 + "memchr", 1095 + ] 1096 + 1097 + [[package]] 802 1098 name = "once_cell" 803 1099 version = "1.21.3" 804 1100 source = "registry+https://github.com/rust-lang/crates.io-index" 805 1101 checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" 1102 + 1103 + [[package]] 1104 + name = "owo-colors" 1105 + version = "4.2.3" 1106 + source = "registry+https://github.com/rust-lang/crates.io-index" 1107 + checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" 806 1108 807 1109 [[package]] 808 1110 name = "pest" ··· 1041 1343 version = "0.8.8" 1042 1344 source = "registry+https://github.com/rust-lang/crates.io-index" 1043 1345 checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" 1346 + 1347 + [[package]] 1348 + name = "rustc-demangle" 1349 + version = "0.1.26" 1350 + source = "registry+https://github.com/rust-lang/crates.io-index" 1351 + checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" 1352 + 1353 + [[package]] 1354 + name = "rustc-hash" 1355 + version = "2.1.1" 1356 + source = "registry+https://github.com/rust-lang/crates.io-index" 1357 + checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" 1044 1358 1045 1359 [[package]] 1046 1360 name = "rustix" ··· 1088 1402 ] 1089 1403 1090 1404 [[package]] 1405 + name = "sachy-config" 1406 + version = "0.1.0" 1407 + dependencies = [ 1408 + "facet", 1409 + "facet-kdl", 1410 + "miette", 1411 + ] 1412 + 1413 + [[package]] 1091 1414 name = "sachy-esphome" 1092 1415 version = "0.1.0" 1093 1416 dependencies = [ ··· 1126 1449 "defmt 1.0.1", 1127 1450 "embassy-time", 1128 1451 "sachy-fmt", 1129 - "winnow", 1452 + "winnow 0.7.14", 1130 1453 ] 1131 1454 1132 1455 [[package]] ··· 1267 1590 checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" 1268 1591 1269 1592 [[package]] 1593 + name = "static_assertions" 1594 + version = "1.1.0" 1595 + source = "registry+https://github.com/rust-lang/crates.io-index" 1596 + checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1597 + 1598 + [[package]] 1270 1599 name = "strsim" 1271 1600 version = "0.11.1" 1272 1601 source = "registry+https://github.com/rust-lang/crates.io-index" 1273 1602 checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 1274 1603 1275 1604 [[package]] 1605 + name = "supports-color" 1606 + version = "3.0.2" 1607 + source = "registry+https://github.com/rust-lang/crates.io-index" 1608 + checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" 1609 + dependencies = [ 1610 + "is_ci", 1611 + ] 1612 + 1613 + [[package]] 1614 + name = "supports-hyperlinks" 1615 + version = "3.2.0" 1616 + source = "registry+https://github.com/rust-lang/crates.io-index" 1617 + checksum = "e396b6523b11ccb83120b115a0b7366de372751aa6edf19844dfb13a6af97e91" 1618 + 1619 + [[package]] 1620 + name = "supports-unicode" 1621 + version = "3.0.0" 1622 + source = "registry+https://github.com/rust-lang/crates.io-index" 1623 + checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" 1624 + 1625 + [[package]] 1276 1626 name = "syn" 1277 1627 version = "2.0.111" 1278 1628 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1303 1653 "once_cell", 1304 1654 "rustix 1.1.2", 1305 1655 "windows-sys 0.61.2", 1656 + ] 1657 + 1658 + [[package]] 1659 + name = "terminal_size" 1660 + version = "0.4.3" 1661 + source = "registry+https://github.com/rust-lang/crates.io-index" 1662 + checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" 1663 + dependencies = [ 1664 + "rustix 1.1.2", 1665 + "windows-sys 0.60.2", 1666 + ] 1667 + 1668 + [[package]] 1669 + name = "textwrap" 1670 + version = "0.16.2" 1671 + source = "registry+https://github.com/rust-lang/crates.io-index" 1672 + checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" 1673 + dependencies = [ 1674 + "unicode-linebreak", 1675 + "unicode-width 0.2.2", 1306 1676 ] 1307 1677 1308 1678 [[package]] ··· 1373 1743 checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" 1374 1744 1375 1745 [[package]] 1746 + name = "unicode-linebreak" 1747 + version = "0.1.5" 1748 + source = "registry+https://github.com/rust-lang/crates.io-index" 1749 + checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" 1750 + 1751 + [[package]] 1752 + name = "unicode-width" 1753 + version = "0.1.14" 1754 + source = "registry+https://github.com/rust-lang/crates.io-index" 1755 + checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" 1756 + 1757 + [[package]] 1758 + name = "unicode-width" 1759 + version = "0.2.2" 1760 + source = "registry+https://github.com/rust-lang/crates.io-index" 1761 + checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" 1762 + 1763 + [[package]] 1764 + name = "unsynn" 1765 + version = "0.3.0" 1766 + source = "registry+https://github.com/rust-lang/crates.io-index" 1767 + checksum = "501a7adf1a4bd9951501e5c66621e972ef8874d787628b7f90e64f936ef7ec0a" 1768 + dependencies = [ 1769 + "mutants", 1770 + "proc-macro2", 1771 + "rustc-hash", 1772 + ] 1773 + 1774 + [[package]] 1376 1775 name = "version_check" 1377 1776 version = "0.9.5" 1378 1777 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1417 1816 source = "registry+https://github.com/rust-lang/crates.io-index" 1418 1817 checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1419 1818 dependencies = [ 1420 - "windows-targets", 1819 + "windows-targets 0.52.6", 1820 + ] 1821 + 1822 + [[package]] 1823 + name = "windows-sys" 1824 + version = "0.60.2" 1825 + source = "registry+https://github.com/rust-lang/crates.io-index" 1826 + checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 1827 + dependencies = [ 1828 + "windows-targets 0.53.5", 1421 1829 ] 1422 1830 1423 1831 [[package]] ··· 1435 1843 source = "registry+https://github.com/rust-lang/crates.io-index" 1436 1844 checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1437 1845 dependencies = [ 1438 - "windows_aarch64_gnullvm", 1439 - "windows_aarch64_msvc", 1440 - "windows_i686_gnu", 1441 - "windows_i686_gnullvm", 1442 - "windows_i686_msvc", 1443 - "windows_x86_64_gnu", 1444 - "windows_x86_64_gnullvm", 1445 - "windows_x86_64_msvc", 1846 + "windows_aarch64_gnullvm 0.52.6", 1847 + "windows_aarch64_msvc 0.52.6", 1848 + "windows_i686_gnu 0.52.6", 1849 + "windows_i686_gnullvm 0.52.6", 1850 + "windows_i686_msvc 0.52.6", 1851 + "windows_x86_64_gnu 0.52.6", 1852 + "windows_x86_64_gnullvm 0.52.6", 1853 + "windows_x86_64_msvc 0.52.6", 1854 + ] 1855 + 1856 + [[package]] 1857 + name = "windows-targets" 1858 + version = "0.53.5" 1859 + source = "registry+https://github.com/rust-lang/crates.io-index" 1860 + checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 1861 + dependencies = [ 1862 + "windows-link", 1863 + "windows_aarch64_gnullvm 0.53.1", 1864 + "windows_aarch64_msvc 0.53.1", 1865 + "windows_i686_gnu 0.53.1", 1866 + "windows_i686_gnullvm 0.53.1", 1867 + "windows_i686_msvc 0.53.1", 1868 + "windows_x86_64_gnu 0.53.1", 1869 + "windows_x86_64_gnullvm 0.53.1", 1870 + "windows_x86_64_msvc 0.53.1", 1446 1871 ] 1447 1872 1448 1873 [[package]] ··· 1452 1877 checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1453 1878 1454 1879 [[package]] 1880 + name = "windows_aarch64_gnullvm" 1881 + version = "0.53.1" 1882 + source = "registry+https://github.com/rust-lang/crates.io-index" 1883 + checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" 1884 + 1885 + [[package]] 1455 1886 name = "windows_aarch64_msvc" 1456 1887 version = "0.52.6" 1457 1888 source = "registry+https://github.com/rust-lang/crates.io-index" 1458 1889 checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1459 1890 1460 1891 [[package]] 1892 + name = "windows_aarch64_msvc" 1893 + version = "0.53.1" 1894 + source = "registry+https://github.com/rust-lang/crates.io-index" 1895 + checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 1896 + 1897 + [[package]] 1461 1898 name = "windows_i686_gnu" 1462 1899 version = "0.52.6" 1463 1900 source = "registry+https://github.com/rust-lang/crates.io-index" 1464 1901 checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1465 1902 1466 1903 [[package]] 1904 + name = "windows_i686_gnu" 1905 + version = "0.53.1" 1906 + source = "registry+https://github.com/rust-lang/crates.io-index" 1907 + checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" 1908 + 1909 + [[package]] 1467 1910 name = "windows_i686_gnullvm" 1468 1911 version = "0.52.6" 1469 1912 source = "registry+https://github.com/rust-lang/crates.io-index" 1470 1913 checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1471 1914 1472 1915 [[package]] 1916 + name = "windows_i686_gnullvm" 1917 + version = "0.53.1" 1918 + source = "registry+https://github.com/rust-lang/crates.io-index" 1919 + checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 1920 + 1921 + [[package]] 1473 1922 name = "windows_i686_msvc" 1474 1923 version = "0.52.6" 1475 1924 source = "registry+https://github.com/rust-lang/crates.io-index" 1476 1925 checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1477 1926 1478 1927 [[package]] 1928 + name = "windows_i686_msvc" 1929 + version = "0.53.1" 1930 + source = "registry+https://github.com/rust-lang/crates.io-index" 1931 + checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 1932 + 1933 + [[package]] 1479 1934 name = "windows_x86_64_gnu" 1480 1935 version = "0.52.6" 1481 1936 source = "registry+https://github.com/rust-lang/crates.io-index" 1482 1937 checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1483 1938 1484 1939 [[package]] 1940 + name = "windows_x86_64_gnu" 1941 + version = "0.53.1" 1942 + source = "registry+https://github.com/rust-lang/crates.io-index" 1943 + checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 1944 + 1945 + [[package]] 1485 1946 name = "windows_x86_64_gnullvm" 1486 1947 version = "0.52.6" 1487 1948 source = "registry+https://github.com/rust-lang/crates.io-index" 1488 1949 checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1950 + 1951 + [[package]] 1952 + name = "windows_x86_64_gnullvm" 1953 + version = "0.53.1" 1954 + source = "registry+https://github.com/rust-lang/crates.io-index" 1955 + checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 1489 1956 1490 1957 [[package]] 1491 1958 name = "windows_x86_64_msvc" 1492 1959 version = "0.52.6" 1493 1960 source = "registry+https://github.com/rust-lang/crates.io-index" 1494 1961 checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1962 + 1963 + [[package]] 1964 + name = "windows_x86_64_msvc" 1965 + version = "0.53.1" 1966 + source = "registry+https://github.com/rust-lang/crates.io-index" 1967 + checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" 1968 + 1969 + [[package]] 1970 + name = "winnow" 1971 + version = "0.6.24" 1972 + source = "registry+https://github.com/rust-lang/crates.io-index" 1973 + checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" 1974 + dependencies = [ 1975 + "memchr", 1976 + ] 1495 1977 1496 1978 [[package]] 1497 1979 name = "winnow"
+1
Cargo.toml
··· 3 3 members = [ 4 4 "sachy-battery", 5 5 "sachy-bthome", 6 + "sachy-config", 6 7 "sachy-esphome", 7 8 "sachy-fmt", 8 9 "sachy-fnv",
+13
sachy-config/Cargo.toml
··· 1 + [package] 2 + name = "sachy-config" 3 + authors.workspace = true 4 + edition.workspace = true 5 + repository.workspace = true 6 + license.workspace = true 7 + version.workspace = true 8 + rust-version.workspace = true 9 + 10 + [dependencies] 11 + facet = "0.34" 12 + facet-kdl = "0.34" 13 + miette = { version = "7", features = ["fancy"] }
+172
sachy-config/src/lib.rs
··· 1 + use std::io::Write; 2 + 3 + use facet::Facet; 4 + use facet_kdl as kdl; 5 + use miette::{IntoDiagnostic, Result}; 6 + 7 + #[derive(Facet, Default)] 8 + #[facet(default)] 9 + pub struct ConfigDoc { 10 + #[facet(kdl::child, default)] 11 + pub constants: Constants, 12 + #[facet(kdl::child, default)] 13 + pub statics: Statics, 14 + } 15 + 16 + #[derive(Facet, Default)] 17 + #[facet(default)] 18 + pub struct Statics { 19 + #[facet(kdl::children, default)] 20 + statics: Vec<Static>, 21 + } 22 + 23 + #[derive(Facet, Default)] 24 + #[facet(default)] 25 + pub struct Constants { 26 + #[facet(kdl::children, default)] 27 + pub constants: Vec<Constant>, 28 + } 29 + 30 + #[derive(Facet)] 31 + pub struct Static { 32 + #[facet(kdl::node_name)] 33 + pub name: String, 34 + #[facet(kdl::argument)] 35 + pub value: String, 36 + } 37 + 38 + #[derive(Facet)] 39 + pub struct Constant { 40 + #[facet(kdl::node_name)] 41 + pub name: String, 42 + #[facet(kdl::argument)] 43 + pub kind: String, 44 + #[facet(kdl::argument)] 45 + pub value: String, 46 + } 47 + 48 + pub fn parse_config(config: &str) -> Result<String> { 49 + let config_doc: ConfigDoc = kdl::from_str_owned(config)?; 50 + let mut output = String::new(); 51 + 52 + for static_value in config_doc.statics.statics.iter() { 53 + let static_output = format!( 54 + "pub static {}: &str = \"{}\";\n", 55 + &static_value.name, &static_value.value 56 + ); 57 + output.push_str(&static_output); 58 + } 59 + 60 + for constant_value in config_doc.constants.constants.iter() { 61 + let constant_output = format!( 62 + "pub const {}: {} = {};\n", 63 + &constant_value.name, &constant_value.kind, &constant_value.value, 64 + ); 65 + output.push_str(&constant_output); 66 + } 67 + 68 + Ok(output) 69 + } 70 + 71 + pub fn output_config<W: Write>(config: &str, mut writer: W) -> Result<()> { 72 + let output = parse_config(config)?; 73 + 74 + writer.write_all(output.as_bytes()).into_diagnostic()?; 75 + 76 + Ok(()) 77 + } 78 + 79 + #[cfg(test)] 80 + mod tests { 81 + use std::io::BufWriter; 82 + 83 + use super::*; 84 + 85 + #[test] 86 + fn it_parses_config() -> Result<()> { 87 + let input = r#"constants { 88 + FIRST "u8" "2" 89 + VALUE "u64" "42" 90 + } 91 + statics { 92 + EXAMPLE "thing" 93 + }"#; 94 + let expected = r#"pub static EXAMPLE: &str = "thing"; 95 + pub const FIRST: u8 = 2; 96 + pub const VALUE: u64 = 42; 97 + "#; 98 + 99 + let output = parse_config(input)?; 100 + 101 + assert_eq!(&output, expected); 102 + 103 + Ok(()) 104 + } 105 + 106 + #[test] 107 + fn it_handles_only_statics() -> Result<()> { 108 + let input = r#"statics { 109 + EXAMPLE "thing" 110 + }"#; 111 + 112 + let expected = "pub static EXAMPLE: &str = \"thing\";\n"; 113 + 114 + let output = parse_config(input)?; 115 + 116 + assert_eq!(&output, expected); 117 + 118 + Ok(()) 119 + } 120 + 121 + #[test] 122 + fn it_handles_only_constants() -> Result<()> { 123 + let input = r#"constants { 124 + FIRST "u8" "42" 125 + }"#; 126 + 127 + let expected = "pub const FIRST: u8 = 42;\n"; 128 + 129 + let output = parse_config(input)?; 130 + 131 + assert_eq!(&output, expected); 132 + 133 + Ok(()) 134 + } 135 + 136 + #[test] 137 + fn it_handles_empty_config() -> Result<()> { 138 + let input = r#"statics {} 139 + constants {}"#; 140 + 141 + let expected = ""; 142 + 143 + let output = parse_config(input)?; 144 + 145 + assert_eq!(&output, expected); 146 + 147 + Ok(()) 148 + } 149 + 150 + #[test] 151 + fn it_outputs_to_file() -> Result<()> { 152 + let input = r#"constants { 153 + FIRST "u8" "2" 154 + VALUE "u64" "42" 155 + } 156 + statics { 157 + EXAMPLE "thing" 158 + }"#; 159 + let expected = r#"pub static EXAMPLE: &str = "thing"; 160 + pub const FIRST: u8 = 2; 161 + pub const VALUE: u64 = 42; 162 + "#; 163 + let output: Vec<u8> = Vec::new(); 164 + let mut buffer = BufWriter::new(output); 165 + 166 + output_config(input, &mut buffer)?; 167 + 168 + assert_eq!(buffer.buffer(), expected.as_bytes()); 169 + 170 + Ok(()) 171 + } 172 + }