From 04a39790b8237b1f11f4c7b3c9ce5d93eb4ed116 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 8 Nov 2024 10:05:24 +0100 Subject: [PATCH] [code] restructured into different crates --- Cargo.lock | 356 +++++++----------- Cargo.toml | 35 +- client.sh | 3 + crates/lanspread-client/Cargo.toml | 13 + .../lanspread-client/src/main.rs | 7 +- crates/lanspread-db/Cargo.toml | 11 + src/db.rs => crates/lanspread-db/src/lib.rs | 51 +-- crates/lanspread-server/Cargo.toml | 16 + .../lanspread-server/src/main.rs | 7 +- server.sh | 3 + src/lib.rs | 1 - 11 files changed, 202 insertions(+), 301 deletions(-) create mode 100755 client.sh create mode 100644 crates/lanspread-client/Cargo.toml rename src/bin/client.rs => crates/lanspread-client/src/main.rs (96%) create mode 100644 crates/lanspread-db/Cargo.toml rename src/db.rs => crates/lanspread-db/src/lib.rs (76%) create mode 100644 crates/lanspread-server/Cargo.toml rename src/bin/server.rs => crates/lanspread-server/src/main.rs (97%) create mode 100755 server.sh delete mode 100644 src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 93218e4..9012081 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -17,18 +17,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -44,55 +32,6 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" -[[package]] -name = "anstream" -version = "0.6.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" - -[[package]] -name = "anstyle-parse" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" -dependencies = [ - "anstyle", - "windows-sys", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -107,9 +46,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f95446d919226d587817a7d21379e6eb099b97b45110a7f272a444ca5c54070" +checksum = "cdd82dba44d209fddb11c190e0a94b78651f95299598e472215667417a03ff1d" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -120,9 +59,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3ddc4a5b231dd6958b140ff3151b6412b3f4321fab354f399eec8f14b06df62" +checksum = "df7a4168111d7eb622a31b214057b8509c0a7e1794f44c546d742330dc793972" dependencies = [ "bindgen", "cc", @@ -148,17 +87,11 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "bindgen" -version = "0.69.4" +version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ "bitflags", "cexpr", @@ -191,15 +124,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.22" +version = "1.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" dependencies = [ "jobserver", "libc", @@ -232,33 +165,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "4.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" -dependencies = [ - "clap_builder", -] - -[[package]] -name = "clap_builder" -version = "4.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_lex" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" - [[package]] name = "cmake" version = "0.1.51" @@ -268,12 +174,6 @@ dependencies = [ "cc", ] -[[package]] -name = "colorchoice" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" - [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -303,6 +203,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.9" @@ -329,6 +235,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "fs_extra" version = "1.3.0" @@ -337,9 +249,9 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -351,9 +263,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -361,21 +273,21 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -384,21 +296,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -436,9 +348,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -454,12 +366,13 @@ checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ - "ahash", "allocator-api2", + "equivalent", + "foldhash", ] [[package]] @@ -504,12 +417,6 @@ dependencies = [ "memoffset", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - [[package]] name = "itertools" version = "0.12.1" @@ -544,16 +451,36 @@ dependencies = [ ] [[package]] -name = "lanspread" +name = "lanspread-client" +version = "0.1.0" +dependencies = [ + "eyre", + "lanspread-db", + "s2n-quic", + "serde_json", + "tokio", +] + +[[package]] +name = "lanspread-db" +version = "0.1.0" +dependencies = [ + "eyre", + "semver", + "serde", + "serde_json", +] + +[[package]] +name = "lanspread-server" version = "0.1.0" dependencies = [ "bytes", - "clap", "eyre", "itertools 0.13.0", + "lanspread-db", "s2n-quic", "semver", - "serde", "serde_json", "tokio", ] @@ -572,9 +499,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libloading" @@ -588,9 +515,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "linux-raw-sys" @@ -703,18 +630,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "parking_lot" @@ -747,9 +674,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -768,9 +695,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", "syn", @@ -778,9 +705,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -867,18 +794,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -888,9 +815,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -899,9 +826,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ring" @@ -932,9 +859,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ "bitflags", "errno", @@ -945,9 +872,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "aws-lc-rs", "log", @@ -960,19 +887,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -994,9 +920,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "s2n-codec" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c100e27d5ae9a875be47f3e62be60e8319471b983d1d3ec534153047dcb7ab" +checksum = "f8165bf4141015264532689b7c6263365181e200c88f825baec567c5ee9487a6" dependencies = [ "byteorder", "bytes", @@ -1005,9 +931,9 @@ dependencies = [ [[package]] name = "s2n-quic" -version = "1.47.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dedce788a0dd9231dab321e95a67b8743911443d96d0e6904492088faa948a24" +checksum = "1fcbb9583aa44b6b68996bd78fdd9e8b862212d1596b796e7297549f2780c575" dependencies = [ "bytes", "cfg-if", @@ -1029,9 +955,9 @@ dependencies = [ [[package]] name = "s2n-quic-core" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63bf260a35cc2296b11d28c28b9b7868e404a6cca2e7a364cc1ad0e60676acda" +checksum = "8adb92a3782d3c57a6304661c4c1f7c046e858c6d13b9f9bb78b4b1b4cf840fb" dependencies = [ "atomic-waker", "byteorder", @@ -1050,9 +976,9 @@ dependencies = [ [[package]] name = "s2n-quic-crypto" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e4d7ae26844cb494cb9cf8cbd80e7c18f29c01662fe9c5f0df9b316162a1c7f" +checksum = "5d95aa09cb35dc2001d2ef98f7b411a478de5f4b1d955d4f848051693f64abbd" dependencies = [ "aws-lc-rs", "cfg-if", @@ -1064,9 +990,9 @@ dependencies = [ [[package]] name = "s2n-quic-platform" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "070eea4557ab46232b3e5d56352506721436cbdde3c25689339bb9baffc510ba" +checksum = "75fb8a181452b5b9bece0f60e05d2c7e13ad91c59e9f83cb2e787bd97bc5d3f7" dependencies = [ "cfg-if", "futures", @@ -1079,9 +1005,9 @@ dependencies = [ [[package]] name = "s2n-quic-rustls" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d8fadf4330ada6e063b0b7d57fe0ab726ee12bd6ac6199b5abe5ed04712aa9" +checksum = "6e5ace426f2d27479def5e188353f3a6674a29209dbbf6cb37896ab44d031d4d" dependencies = [ "bytes", "rustls", @@ -1093,9 +1019,9 @@ dependencies = [ [[package]] name = "s2n-quic-tls" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a273c5fee7660a7946fb359af906b5e4d2e575083770ec503357538cd5b171c0" +checksum = "b6b635f61c0acc54237bbd77763f93fc85eb01a09406f5690c42fe0b76308513" dependencies = [ "bytes", "errno", @@ -1108,9 +1034,9 @@ dependencies = [ [[package]] name = "s2n-quic-tls-default" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083617746b407372aeeece4b15688170d62e7107c97668bf673be58e8d7a0d26" +checksum = "f1d4c425b01d865fb9a8731ff9360c8bef6c5749d93211ca5d78704f863d4e68" dependencies = [ "s2n-quic-rustls", "s2n-quic-tls", @@ -1118,9 +1044,9 @@ dependencies = [ [[package]] name = "s2n-quic-transport" -version = "0.47.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881761020d8478eb8542d3138961cce8c909c2808baf63503e435157a3008bc6" +checksum = "69042997e1cd15fd68a9d4a09a1bab83ae190a487e0d34c7e740b774f5f0a69a" dependencies = [ "bytes", "futures-channel", @@ -1136,9 +1062,9 @@ dependencies = [ [[package]] name = "s2n-tls" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceb04a74dad1be76dd9fb30510eae14bbc6e1f6fdecee51405d9fe64db8c59a" +checksum = "55f90f5c53fe2a90b60911866e07f565129659801927ba478e2d4730575941f2" dependencies = [ "errno", "hex", @@ -1149,9 +1075,9 @@ dependencies = [ [[package]] name = "s2n-tls-sys" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ffe6ed8b2871ef333f939464cd23be948299976aaf97631e2427c787c94f03" +checksum = "aac0a58ff5958433ae66db8325506df91028f339d21f952fc77f42533581f58e" dependencies = [ "aws-lc-rs", "cc", @@ -1172,18 +1098,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", @@ -1192,9 +1118,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -1254,12 +1180,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - [[package]] name = "subtle" version = "2.6.1" @@ -1268,9 +1188,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.79" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -1279,9 +1199,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -1324,18 +1244,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 3994e0c..e58c805 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,23 +1,18 @@ -[package] -name = "lanspread" -version = "0.1.0" -edition = "2021" +[workspace] +members = [ + "crates/lanspread-db", + "crates/lanspread-server", + "crates/lanspread-client" +] +resolver = "2" -[[bin]] -name = "server" -path = "src/bin/server.rs" - -[[bin]] -name = "client" -path = "src/bin/client.rs" - -[dependencies] -bytes = "1.7.2" -clap = "4.5.18" -eyre = "0.6.12" +[workspace.dependencies] +bytes = "1.8" +clap = "4.5" +eyre = "0.6" itertools = "0.13" -s2n-quic = "1.47.0" +s2n-quic = "1.49" semver = "1.0" -serde = { version = "1.0.210", features = ["derive"] } -serde_json = "1.0.128" -tokio = { version = "1.40.0", features = ["full"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tokio = { version = "1.41", features = ["full"] } diff --git a/client.sh b/client.sh new file mode 100755 index 0000000..523ea17 --- /dev/null +++ b/client.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cargo run --release -p lanspread-client diff --git a/crates/lanspread-client/Cargo.toml b/crates/lanspread-client/Cargo.toml new file mode 100644 index 0000000..c28a582 --- /dev/null +++ b/crates/lanspread-client/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "lanspread-client" +version = "0.1.0" +edition = "2021" + +[dependencies] +# local +lanspread-db = { path = "../lanspread-db" } +# external +eyre = { workspace = true } +s2n-quic = { workspace = true } +serde_json = { workspace = true } +tokio = { workspace = true } diff --git a/src/bin/client.rs b/crates/lanspread-client/src/main.rs similarity index 96% rename from src/bin/client.rs rename to crates/lanspread-client/src/main.rs index e448917..240a131 100644 --- a/src/bin/client.rs +++ b/crates/lanspread-client/src/main.rs @@ -1,9 +1,10 @@ -use lanspread::db::{Game, GameDB}; -use s2n_quic::{client::Connect, Client as QuicClient}; use std::{net::SocketAddr, sync::Arc}; + +use lanspread_db::{Game, GameDB}; +use s2n_quic::{client::Connect, Client as QuicClient}; use tokio::{io::AsyncWriteExt as _, sync::Mutex}; -static CERT_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/cert.pem")); +static CERT_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../cert.pem")); const SERVER_ADDR: &str = "127.0.0.1"; const SERVER_PORT: u16 = 13337; diff --git a/crates/lanspread-db/Cargo.toml b/crates/lanspread-db/Cargo.toml new file mode 100644 index 0000000..a86fb90 --- /dev/null +++ b/crates/lanspread-db/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "lanspread-db" +version = "0.1.0" +edition = "2021" + +[dependencies] +# external +eyre = { workspace = true} +semver = { workspace = true} +serde = { workspace = true} +serde_json = { workspace = true} diff --git a/src/db.rs b/crates/lanspread-db/src/lib.rs similarity index 76% rename from src/db.rs rename to crates/lanspread-db/src/lib.rs index 6f2061e..0e30845 100644 --- a/src/db.rs +++ b/crates/lanspread-db/src/lib.rs @@ -1,6 +1,6 @@ -use std::fmt; use std::{ collections::HashMap, + fmt, fs::{File, OpenOptions}, path::Path, }; @@ -91,59 +91,12 @@ impl Ord for Game { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct GameDB { pub games: HashMap, next_id: u64, } -impl Serialize for GameDB { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - use serde::ser::SerializeSeq; - let mut seq = serializer.serialize_seq(Some(self.games.len()))?; - for game in self.games.values() { - seq.serialize_element(game)?; - } - seq.end() - } -} - -impl<'de> Deserialize<'de> for GameDB { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - struct GameDBVisitor; - - impl<'de> serde::de::Visitor<'de> for GameDBVisitor { - type Value = GameDB; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a sequence of Game objects") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: serde::de::SeqAccess<'de>, - { - let mut games = HashMap::new(); - let mut next_id = 0; - while let Some(game) = seq.next_element()? { - let game: Game = game; - next_id = next_id.max(game.id + 1); - games.insert(game.id, game); - } - Ok(GameDB { games, next_id }) - } - } - - deserializer.deserialize_seq(GameDBVisitor) - } -} - impl GameDB { pub fn new() -> Self { GameDB { diff --git a/crates/lanspread-server/Cargo.toml b/crates/lanspread-server/Cargo.toml new file mode 100644 index 0000000..6bc0836 --- /dev/null +++ b/crates/lanspread-server/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "lanspread-server" +version = "0.1.0" +edition = "2021" + +[dependencies] +# local +lanspread-db = { path = "../lanspread-db" } +# external +bytes = { workspace = true } +eyre = { workspace = true } +itertools = { workspace = true } +s2n-quic = { workspace = true } +serde_json = { workspace = true } +semver = { workspace = true } +tokio = { workspace = true } diff --git a/src/bin/server.rs b/crates/lanspread-server/src/main.rs similarity index 97% rename from src/bin/server.rs rename to crates/lanspread-server/src/main.rs index 892ab6e..57fa73e 100644 --- a/src/bin/server.rs +++ b/crates/lanspread-server/src/main.rs @@ -2,13 +2,12 @@ use std::{net::SocketAddr, path::PathBuf, sync::Arc}; use bytes::Bytes; use itertools::Itertools as _; +use lanspread_db::GameDB; use s2n_quic::Server as QuicServer; use tokio::sync::Mutex; -use lanspread::db::GameDB; - -static KEY_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/key.pem")); -static CERT_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/cert.pem")); +static KEY_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../key.pem")); +static CERT_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../cert.pem")); const SERVER_ADDR: &str = "0.0.0.0"; const SERVER_PORT: u16 = 13337; diff --git a/server.sh b/server.sh new file mode 100755 index 0000000..a3a04e2 --- /dev/null +++ b/server.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cargo run --release -p lanspread-server diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index dec1023..0000000 --- a/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod db;