diff --git a/Cargo.lock b/Cargo.lock index 53e2280..d9ed418 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,12 +51,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -255,15 +249,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "atoi" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" -dependencies = [ - "num-traits", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -372,14 +357,13 @@ dependencies = [ "openssl", "rand 0.8.5", "ring-compat", + "rusqlite", "serde", "serde_json", - "sqlx", "tauri", "tauri-build", "tauri-plugin-fs", "tauri-plugin-opener", - "tauri-plugin-sql", "tauri-sys", "tokio", ] @@ -803,21 +787,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - [[package]] name = "crc32fast" version = "1.4.2" @@ -836,15 +805,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -996,7 +956,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -1041,9 +1000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", ] [[package]] @@ -1128,12 +1085,6 @@ dependencies = [ "syn 2.0.98", ] -[[package]] -name = "dotenvy" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" - [[package]] name = "dpi" version = "0.1.1" @@ -1202,9 +1153,6 @@ name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -dependencies = [ - "serde", -] [[package]] name = "either_of" @@ -1307,17 +1255,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "etcetera" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" -dependencies = [ - "cfg-if", - "home", - "windows-sys 0.48.0", -] - [[package]] name = "event-listener" version = "5.4.0" @@ -1339,6 +1276,18 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "2.3.0" @@ -1384,17 +1333,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "flume" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" -dependencies = [ - "futures-core", - "futures-sink", - "spin", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1511,17 +1449,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "futures-intrusive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" -dependencies = [ - "futures-core", - "lock_api", - "parking_lot", -] - [[package]] name = "futures-io" version = "0.3.31" @@ -1960,8 +1887,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "allocator-api2", - "equivalent", "foldhash", ] @@ -2004,33 +1929,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "home" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "html-escape" version = "0.2.13" @@ -2531,9 +2429,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "leptos" @@ -2735,12 +2630,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" - [[package]] name = "libredox" version = "0.1.3" @@ -2753,9 +2642,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.30.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +checksum = "ad8935b44e7c13394a179a438e0cebba0fe08fe01b54f152e29a93b5cf993fd4" dependencies = [ "cc", "pkg-config", @@ -2866,16 +2755,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] - [[package]] name = "memchr" version = "2.7.4" @@ -3015,49 +2894,12 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.5", - "smallvec", - "zeroize", -] - [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -3065,7 +2907,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -3579,15 +3420,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -3771,17 +3603,6 @@ dependencies = [ "futures-io", ] -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -4358,26 +4179,6 @@ dependencies = [ "signature", ] -[[package]] -name = "rsa" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "signature", - "spki", - "subtle", - "zeroize", -] - [[package]] name = "rstml" version = "0.12.1" @@ -4393,6 +4194,20 @@ dependencies = [ "thiserror 2.0.12", ] +[[package]] +name = "rusqlite" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6d5e5acb6f6129fe3f7ba0a7fc77bca1942cb568535e18e7bc40262baf3110" +dependencies = [ + "bitflags 2.8.0", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -4808,17 +4623,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" version = "0.10.8" @@ -4851,7 +4655,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", "rand_core 0.6.4", ] @@ -4896,9 +4699,6 @@ name = "smallvec" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" -dependencies = [ - "serde", -] [[package]] name = "socket2" @@ -4958,15 +4758,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "spki" version = "0.7.3" @@ -4977,197 +4768,6 @@ dependencies = [ "der", ] -[[package]] -name = "sqlx" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4410e73b3c0d8442c5f99b425d7a435b5ee0ae4167b3196771dd3f7a01be745f" -dependencies = [ - "sqlx-core", - "sqlx-macros", - "sqlx-mysql", - "sqlx-postgres", - "sqlx-sqlite", -] - -[[package]] -name = "sqlx-core" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0" -dependencies = [ - "bytes", - "crc", - "crossbeam-queue", - "either", - "event-listener", - "futures-core", - "futures-intrusive", - "futures-io", - "futures-util", - "hashbrown 0.15.2", - "hashlink", - "indexmap 2.7.1", - "log", - "memchr", - "once_cell", - "percent-encoding", - "serde", - "serde_json", - "sha2", - "smallvec", - "thiserror 2.0.12", - "time", - "tokio", - "tokio-stream", - "tracing", - "url", -] - -[[package]] -name = "sqlx-macros" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3112e2ad78643fef903618d78cf0aec1cb3134b019730edb039b69eaf531f310" -dependencies = [ - "proc-macro2", - "quote", - "sqlx-core", - "sqlx-macros-core", - "syn 2.0.98", -] - -[[package]] -name = "sqlx-macros-core" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9f90acc5ab146a99bf5061a7eb4976b573f560bc898ef3bf8435448dd5e7ad" -dependencies = [ - "dotenvy", - "either", - "heck 0.5.0", - "hex", - "once_cell", - "proc-macro2", - "quote", - "serde", - "serde_json", - "sha2", - "sqlx-core", - "sqlx-mysql", - "sqlx-postgres", - "sqlx-sqlite", - "syn 2.0.98", - "tempfile", - "tokio", - "url", -] - -[[package]] -name = "sqlx-mysql" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4560278f0e00ce64938540546f59f590d60beee33fffbd3b9cd47851e5fff233" -dependencies = [ - "atoi", - "base64 0.22.1", - "bitflags 2.8.0", - "byteorder", - "bytes", - "crc", - "digest", - "dotenvy", - "either", - "futures-channel", - "futures-core", - "futures-io", - "futures-util", - "generic-array", - "hex", - "hkdf", - "hmac", - "itoa 1.0.14", - "log", - "md-5", - "memchr", - "once_cell", - "percent-encoding", - "rand 0.8.5", - "rsa", - "serde", - "sha1", - "sha2", - "smallvec", - "sqlx-core", - "stringprep", - "thiserror 2.0.12", - "time", - "tracing", - "whoami", -] - -[[package]] -name = "sqlx-postgres" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b98a57f363ed6764d5b3a12bfedf62f07aa16e1856a7ddc2a0bb190a959613" -dependencies = [ - "atoi", - "base64 0.22.1", - "bitflags 2.8.0", - "byteorder", - "crc", - "dotenvy", - "etcetera", - "futures-channel", - "futures-core", - "futures-util", - "hex", - "hkdf", - "hmac", - "home", - "itoa 1.0.14", - "log", - "md-5", - "memchr", - "once_cell", - "rand 0.8.5", - "serde", - "serde_json", - "sha2", - "smallvec", - "sqlx-core", - "stringprep", - "thiserror 2.0.12", - "time", - "tracing", - "whoami", -] - -[[package]] -name = "sqlx-sqlite" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540" -dependencies = [ - "atoi", - "flume", - "futures-channel", - "futures-core", - "futures-executor", - "futures-intrusive", - "futures-util", - "libsqlite3-sys", - "log", - "percent-encoding", - "serde", - "serde_urlencoded", - "sqlx-core", - "time", - "tracing", - "url", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -5205,17 +4805,6 @@ dependencies = [ "quote", ] -[[package]] -name = "stringprep" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" -dependencies = [ - "unicode-bidi", - "unicode-normalization", - "unicode-properties", -] - [[package]] name = "strsim" version = "0.11.1" @@ -5570,25 +5159,6 @@ dependencies = [ "zbus", ] -[[package]] -name = "tauri-plugin-sql" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ccca89ded6bd2ff49fdad9a5b34bcd624aa223fdfddbab83c85706ee3a4948" -dependencies = [ - "futures-core", - "indexmap 2.7.1", - "log", - "serde", - "serde_json", - "sqlx", - "tauri", - "tauri-plugin", - "thiserror 2.0.12", - "time", - "tokio", -] - [[package]] name = "tauri-runtime" version = "2.3.0" @@ -5859,17 +5429,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-stream" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.13" @@ -5986,7 +5545,6 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -6124,33 +5682,12 @@ dependencies = [ "unic-common", ] -[[package]] -name = "unicode-bidi" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" - [[package]] name = "unicode-ident" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-properties" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" - [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -6305,12 +5842,6 @@ dependencies = [ "wit-bindgen-rt", ] -[[package]] -name = "wasite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" - [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -6504,16 +6035,6 @@ dependencies = [ "windows-core 0.58.0", ] -[[package]] -name = "whoami" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" -dependencies = [ - "redox_syscall", - "wasite", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 1699701..64749bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,7 @@ server = [ "dep:tauri", "dep:tauri-plugin-opener", "dep:tauri-plugin-fs", - "dep:tauri-plugin-sql", - "dep:sqlx", + "dep:rusqlite", "dep:rand", "dep:chrono", "dep:tokio", @@ -27,7 +26,7 @@ crate-type = ["staticlib", "cdylib", "rlib"] name = "bkbh" [build-dependencies] -tauri-build = { version = "2", features = ["config-toml"] } +tauri-build = { version = "2", features = [] } [dependencies] console_error_panic_hook = { version = "0.1.7" } @@ -47,9 +46,11 @@ ring-compat = { version = "^0.8", features = [ "signature", "rand_core", ], optional = true } -sqlx = { version = "^0.8", features = ["sqlite"], optional = true } -tauri = { version = "2", features = ["config-toml"], optional = true } +rusqlite = { version = "^0.33", features = [ + "backup", + "bundled", +], optional = true } +tauri = { version = "2", features = [], optional = true } tauri-plugin-fs = { version = "2", optional = true } tauri-plugin-opener = { version = "2", optional = true } -tauri-plugin-sql = { version = "2", features = ["sqlite"], optional = true } tokio = { version = "^1.43", optional = true } diff --git a/Tauri.toml b/Tauri.toml deleted file mode 100644 index 8780e66..0000000 --- a/Tauri.toml +++ /dev/null @@ -1,26 +0,0 @@ -"$schema" = "https://schema.tauri.app/config/2" -identifier = "de.mathebau.bkbh" -productName = "Nein!" -version = "0.1.0" - -[build] -before-build-command = "cd bkbh && trunk build" -before-dev-command = "cd bkbh && trunk serve" -dev-url = "http://localhost:1420" -features = ["tauri"] -frontend-dist = "www" - -[app] -windows = [{ title = "Nein zur Bezahlkarte!", width = 800, height = 600 }] -with-global-tauri = true - -[bundle] -active = true -icon = [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico", -] -targets = "all" diff --git a/capabilities/Default.toml b/capabilities/Default.toml deleted file mode 100644 index e17bc89..0000000 --- a/capabilities/Default.toml +++ /dev/null @@ -1,11 +0,0 @@ -"$schema" = "../gen/schemas/desktop-schema.json" -description = "Capability for the main window" -identifier = "default" -permissions = [ - "core:default", - "opener:default", - "fs:default", - "sql:default", - "sql:allow-execute", -] -windows = ["main"] diff --git a/capabilities/default.json b/capabilities/default.json new file mode 100644 index 0000000..d93117c --- /dev/null +++ b/capabilities/default.json @@ -0,0 +1,13 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": [ + "main" + ], + "permissions": [ + "core:default", + "opener:default", + "fs:default" + ] +} diff --git a/src/server/app_state.rs b/src/server/app_state.rs index a67f163..df2c61a 100644 --- a/src/server/app_state.rs +++ b/src/server/app_state.rs @@ -1,7 +1,7 @@ use rand::prelude::*; use ring_compat::signature::ed25519::SigningKey; +use rusqlite::Connection; use tokio::sync::Mutex; -use sqlx::sqlite::SqliteConnection as Connection; pub struct AppState { pub db: Connection, @@ -12,8 +12,20 @@ pub struct AppState { impl AppState { pub fn new() -> Self { - todo!() - let db = unimplemented!(); + let db = Connection::open_in_memory() + .expect("Failed to create DB."); + db.execute( + "CREATE TABLE swap ( + rand INTEGER, + store INTEGER, + account INTEGER, + submitter INTEGER, + time INTEGER, + cancellation BOOL + )", + (), + ) + .unwrap(); let mut rng = rand::thread_rng(); let last_sync = i64::MIN; let id = rng.r#gen(); diff --git a/src/server/data_door.rs b/src/server/data_door.rs index 9ebb419..ad8844c 100644 --- a/src/server/data_door.rs +++ b/src/server/data_door.rs @@ -2,6 +2,7 @@ use chrono::offset::Utc; use curl::{easy, easy::Easy2}; use rand::prelude::*; use ring_compat::signature::ed25519::SigningKey; +use rusqlite::{Connection, DatabaseName}; use tauri::{Manager, State}; use tokio::sync::Mutex; @@ -60,21 +61,19 @@ fn data_client(file: &str) -> Result, ()> { "https://cloud.seebruecke.org/public.php/webdav/data/{}", file ); - client.url(&url) - .map_err(|e| println!("{:?}", e))?; + client.url(&url).map_err(|_| ())?; client.username(include_str!("cloud_user.txt")) - .map_err(|e| println!("{:?}", e))?; + .map_err(|_| ())?; client.http_auth(easy::Auth::new().auto(true)) - .map_err(|e| println!("{:?}", e))?; + .map_err(|_| ())?; client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem")) - .map_err(|e| println!("{:?}", e))?; + .map_err(|_| ())?; Ok(client) } fn put_client(file: &str, payload: &[u8]) -> Result, ()> { let mut client = data_client(&file)?; - client.put(true) - .map_err(|e| println!("{:?}", e))?; + client.put(true).map_err(|_| ())?; client.get_mut().1.extend_from_slice(payload); client.in_filesize(payload.len() as u64) .map_err(|e| println!("{:?}", e))?; @@ -87,10 +86,8 @@ pub async fn pull_data( _state: State<'_, Mutex>, ) -> Result { let mut client = data_client("")?; - client.custom_request("PROPFIND") - .map_err(|e| println!("{:?}", e))?; - client.perform() - .map_err(|e| println!("{:?}", e))?; + client.custom_request("PROPFIND").map_err(|_| ())?; + client.perform().map_err(|_| ())?; let content = &client.get_ref().0; Ok(String::from_utf8_lossy(content).to_string()) } @@ -103,6 +100,20 @@ async fn push_key(id: &u64, key: &SigningKey) -> Result<(), ()> { Ok(()) } +fn push_db(id: &u64, db: &Connection, app: tauri::AppHandle) -> Result<(), ()> { + let filename = format!("{:016X}.sqlite", id); + let path = app + .path() + .resolve(&filename, tauri::path::BaseDirectory::Temp) + .map_err(|e| println!("{:?}", e))?; + db.backup(DatabaseName::Main, &path, None) + .map_err(|e| println!("{:?}", e))?; + let buf = std::fs::read(&path).map_err(|e| println!("{:?}", e))?; + let client = put_client(&filename, buf.as_ref())?; + let _perf = client.perform().map_err(|e| println!("{:?}", e))?; + Ok(()) +} + #[tauri::command] pub async fn push_data( app: tauri::AppHandle, @@ -110,5 +121,6 @@ pub async fn push_data( ) -> Result<(), ()> { let state = state.lock().await; push_key(&state.id, &state.key).await?; + push_db(&state.id, &state.db, app)?; Ok(()) } diff --git a/src/server/mod.rs b/src/server/mod.rs index 715c3f3..27a877c 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -2,7 +2,6 @@ use chrono::offset::Utc; use std::collections::HashMap; use tauri::State; use tokio::sync::Mutex; -use sqlx::sqlite::SqliteConnection as Connection; use crate::types::*; @@ -80,7 +79,7 @@ pub async fn swap( pub async fn count(state: State<'_, Mutex>) -> Result { let state = state.lock().await; let mut stmt = - state.db.prepare_with("SELECT COUNT(*) FROM swap") + state.db.prepare("SELECT COUNT(*) FROM swap") .map_err(|e| println!("{:?}", e))?; let mut rows = stmt.query([]).map_err(|e| println!("{:?}", e))?; let row = rows.next().map_err(|e| println!("{:?}", e))?; diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000..36e0800 --- /dev/null +++ b/src/types.rs @@ -0,0 +1,135 @@ +#[cfg(feature = "server")] +use rusqlite::{types::ToSqlOutput, ToSql}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum Store { + Aldi, + Edeka, + Dm, + Lidl, + Rewe, + Tegut, +} + +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum Account { + Sumpf, + Heinersyndikat, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Inventory { + pub acc: Account, + pub cash: i64, + pub vouchers: Vec, +} + +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub struct VoucherInventory { + pub store: Store, + pub count: i64, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct Cash(i64); + +impl std::str::FromStr for Cash { + type Err = (); + + fn from_str(s: &str) -> Result { + let split: Vec<&str> = s.split(".").collect(); + let i = i64::from_str(split.get(0).ok_or(())?) + .map_err(|e| println!("{:?}", e))?; + let f = match split.get(1) { + None => 0, + Some(fs) => i64::from_str(&format!("00{}", fs)[0..2]) + .map_err(|e| println!("{:?}", e))?, + }; + Ok(Cash(i * 100 + f)) + } +} + +impl Into for &Store { + fn into(self) -> String { + String::from(match *self { + Store::Aldi => "aldi", + Store::Edeka => "edeka", + Store::Dm => "dm", + Store::Lidl => "lidl", + Store::Rewe => "rewe", + Store::Tegut => "tegut", + }) + } +} + +impl TryFrom<&str> for Store { + type Error = (); + + fn try_from(s: &str) -> Result { + match s { + "aldi" => Ok(Store::Aldi), + "edeka" => Ok(Store::Edeka), + "dm" => Ok(Store::Dm), + "lidl" => Ok(Store::Lidl), + "rewe" => Ok(Store::Rewe), + "tegut" => Ok(Store::Tegut), + _ => Err(()), + } + } +} + +impl TryFrom<&str> for Account { + type Error = (); + + fn try_from(s: &str) -> Result { + match s { + "sumpf" => Ok(Account::Sumpf), + "hs" => Ok(Account::Heinersyndikat), + _ => Err(()), + } + } +} + +impl Into for &Account { + fn into(self) -> String { + String::from(match *self { + Account::Sumpf => "sumpf", + Account::Heinersyndikat => "hs", + }) + } +} + +impl std::fmt::Display for Account { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + Account::Sumpf => "Sumpf", + Account::Heinersyndikat => "Heinersyndikat", + } + .fmt(f) + } +} + +#[cfg(feature = "server")] +impl ToSql for Store { + fn to_sql(&self) -> rusqlite::Result> { + match self { + Store::Aldi => 0.to_sql(), + Store::Edeka => 1.to_sql(), + Store::Dm => 2.to_sql(), + Store::Lidl => 3.to_sql(), + Store::Rewe => 4.to_sql(), + Store::Tegut => 5.to_sql(), + } + } +} + +#[cfg(feature = "server")] +impl ToSql for Account { + fn to_sql(&self) -> rusqlite::Result> { + match self { + Account::Sumpf => 0.to_sql(), + Account::Heinersyndikat => 1.to_sql(), + } + } +} diff --git a/src/types/account.rs b/src/types/account.rs deleted file mode 100644 index 8b89bb9..0000000 --- a/src/types/account.rs +++ /dev/null @@ -1,39 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] -#[cfg_attr(features = "dep:sqlx", derive(sqlx::Type))] -pub enum Account { - Sumpf, - Heinersyndikat, -} - -impl TryFrom<&str> for Account { - type Error = (); - - fn try_from(s: &str) -> Result { - match s { - "sumpf" => Ok(Account::Sumpf), - "hs" => Ok(Account::Heinersyndikat), - _ => Err(()), - } - } -} - -impl Into for &Account { - fn into(self) -> String { - String::from(match *self { - Account::Sumpf => "sumpf", - Account::Heinersyndikat => "hs", - }) - } -} - -impl std::fmt::Display for Account { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match *self { - Account::Sumpf => "Sumpf", - Account::Heinersyndikat => "Heinersyndikat", - } - .fmt(f) - } -} \ No newline at end of file diff --git a/src/types/cash.rs b/src/types/cash.rs deleted file mode 100644 index d73255e..0000000 --- a/src/types/cash.rs +++ /dev/null @@ -1,23 +0,0 @@ -use serde::{Deserialize, Serialize}; - -/// An amount of cash, -/// measured as an integer multiple -/// of 0.01 €. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub struct Cash(i64); - -impl std::str::FromStr for Cash { - type Err = (); - - fn from_str(s: &str) -> Result { - let split: Vec<&str> = s.split(".").collect(); - let i = i64::from_str(split.get(0).ok_or(())?) - .map_err(|e| println!("{:?}", e))?; - let f = match split.get(1) { - None => 0, - Some(fs) => i64::from_str(&format!("00{}", fs)[0..2]) - .map_err(|e| println!("{:?}", e))?, - }; - Ok(Cash(i * 100 + f)) - } -} \ No newline at end of file diff --git a/src/types/mod.rs b/src/types/mod.rs deleted file mode 100644 index 0fa5794..0000000 --- a/src/types/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -use serde::{Deserialize, Serialize}; - -mod store; -mod account; -mod cash; - -pub use store::Store; -pub use account::Account; -pub use cash::Cash; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct Inventory { - pub acc: Account, - pub cash: Cash, - pub vouchers: Vec, -} - -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] -pub struct VoucherInventory { - pub store: Store, - pub count: i64, -} diff --git a/src/types/store.rs b/src/types/store.rs deleted file mode 100644 index 2531000..0000000 --- a/src/types/store.rs +++ /dev/null @@ -1,41 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "server", derive(sqlx::Type))] -pub enum Store { - Aldi, - Edeka, - Dm, - Lidl, - Rewe, - Tegut, -} - -impl Into for &Store { - fn into(self) -> String { - String::from(match *self { - Store::Aldi => "aldi", - Store::Edeka => "edeka", - Store::Dm => "dm", - Store::Lidl => "lidl", - Store::Rewe => "rewe", - Store::Tegut => "tegut", - }) - } -} - -impl TryFrom<&str> for Store { - type Error = (); - - fn try_from(s: &str) -> Result { - match s { - "aldi" => Ok(Store::Aldi), - "edeka" => Ok(Store::Edeka), - "dm" => Ok(Store::Dm), - "lidl" => Ok(Store::Lidl), - "rewe" => Ok(Store::Rewe), - "tegut" => Ok(Store::Tegut), - _ => Err(()), - } - } -} diff --git a/tauri.conf.json b/tauri.conf.json new file mode 100644 index 0000000..5ef499e --- /dev/null +++ b/tauri.conf.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Nein!", + "version": "0.1.0", + "identifier": "de.mathebau.bkbh", + "build": { + "beforeDevCommand": "cd bkbh && trunk serve", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "cd bkbh && trunk build", + "frontendDist": "www", + "features": ["tauri"] + }, + "app": { + "withGlobalTauri": true, + "windows": [ + { + "title": "Nein zur Bezahlkarte!", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +}