diff --git a/Cargo.lock b/Cargo.lock index 03159d4..1e3c551 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,7 +99,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -110,7 +110,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -252,21 +252,6 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.5.0" @@ -337,7 +322,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -363,76 +348,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] -name = "cpufeatures" -version = "0.2.12" +name = "duct" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c" dependencies = [ "libc", + "once_cell", + "os_pipe", + "shared_child", ] [[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.19" +name = "either" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "duct" -version = "0.13.7" +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "once_cell", - "os_pipe", - "shared_child", + "windows-sys 0.52.0", ] [[package]] -name = "equivalent" -version = "1.0.1" +name = "fastrand" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] -name = "flate2" -version = "1.0.28" +name = "fixedbitset" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "miniz_oxide", -] +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "fnv" @@ -488,16 +447,6 @@ dependencies = [ "pin-utils", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.12" @@ -527,7 +476,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.11", - "indexmap 2.2.2", + "indexmap 2.2.3", "slab", "tokio", "tokio-util", @@ -546,7 +495,7 @@ dependencies = [ "futures-sink", "futures-util", "http 1.0.0", - "indexmap 2.2.2", + "indexmap 2.2.3", "slab", "tokio", "tokio-util", @@ -573,9 +522,18 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] [[package]] name = "http" @@ -728,13 +686,21 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", - "serde", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", ] [[package]] @@ -749,6 +715,12 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.20" @@ -773,16 +745,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "miniz_oxide" version = "0.7.2" @@ -803,6 +765,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "nix" version = "0.27.1" @@ -855,6 +823,16 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.2.3", +] + [[package]] name = "pin-project" version = "1.1.4" @@ -872,7 +850,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -894,27 +872,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] -name = "proc-macro-error" -version = "1.0.4" +name = "prettyplease" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ - "proc-macro-error-attr", "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", + "syn", ] [[package]] @@ -933,6 +897,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +dependencies = [ + "prost", ] [[package]] @@ -1014,65 +1023,45 @@ name = "rsjudge" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.7.4", "cgroups", "clap", "clap_complete", "clap_mangen", "duct", "nix", + "rsjudge-grpc", + "rsjudge-rest", "rsjudge-runner", "serde", "strfmt", "tokio", "toml", - "tonic", - "utoipa", - "utoipa-swagger-ui", "uzers", ] [[package]] -name = "rsjudge-runner" +name = "rsjudge-grpc" version = "0.1.0" dependencies = [ "anyhow", - "nix", - "uzers", -] - -[[package]] -name = "rust-embed" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82c0bbc10308ed323529fd3c1dce8badda635aa319a5ff0e6466f33b8101e3f" -dependencies = [ - "rust-embed-impl", - "rust-embed-utils", - "walkdir", + "tonic", + "tonic-build", ] [[package]] -name = "rust-embed-impl" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6227c01b1783cdfee1bcf844eb44594cd16ec71c35305bf1c9fb5aade2735e16" +name = "rsjudge-rest" +version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", - "rust-embed-utils", - "syn 2.0.48", - "walkdir", + "axum 0.7.4", ] [[package]] -name = "rust-embed-utils" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb0a25bfbb2d4b4402179c2cf030387d9990857ce08a32592c6238db9fa8665" +name = "rsjudge-runner" +version = "0.1.0" dependencies = [ - "sha2", - "walkdir", + "anyhow", + "nix", + "uzers", ] [[package]] @@ -1081,6 +1070,19 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -1093,15 +1095,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "serde" version = "1.0.196" @@ -1119,7 +1112,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -1164,17 +1157,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "shared_child" version = "1.0.0" @@ -1216,16 +1198,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.48" @@ -1243,6 +1215,18 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "tempfile" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "tokio" version = "1.36.0" @@ -1278,7 +1262,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -1329,11 +1313,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" +checksum = "99e68c159e8f5ba8a28c4eb7b0c0c190d77bb479047ca713270048145a9ad28a" dependencies = [ - "indexmap 2.2.2", + "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", @@ -1367,6 +1351,19 @@ dependencies = [ "tracing", ] +[[package]] +name = "tonic-build" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn", +] + [[package]] name = "tower" version = "0.4.13" @@ -1419,7 +1416,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -1437,21 +1434,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-ident" version = "1.0.12" @@ -1464,47 +1446,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "utoipa" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "272ebdfbc99111033031d2f10e018836056e4d2c8e2acda76450ec7974269fa7" -dependencies = [ - "indexmap 2.2.2", - "serde", - "serde_json", - "utoipa-gen", -] - -[[package]] -name = "utoipa-gen" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c9f4d08338c1bfa70dde39412a040a884c6f318b3d09aaaf3437a1e52027fc" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "regex", - "syn 2.0.48", -] - -[[package]] -name = "utoipa-swagger-ui" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b39868d43c011961e04b41623e050aedf2cc93652562ff7935ce0f819aaf2da" -dependencies = [ - "axum 0.7.4", - "mime_guess", - "regex", - "rust-embed", - "serde", - "serde_json", - "utoipa", - "zip", -] - [[package]] name = "uzers" version = "0.11.3" @@ -1515,22 +1456,6 @@ dependencies = [ "log", ] -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "want" version = "0.3.1" @@ -1546,6 +1471,18 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1562,15 +1499,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1711,9 +1639,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.39" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +checksum = "6b1dbce9e90e5404c5a52ed82b1d13fc8cfbdad85033b6f57546ffd1265f8451" dependencies = [ "memchr", ] @@ -1743,15 +1671,3 @@ dependencies = [ "serde_json", "xshell", ] - -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", -] diff --git a/Cargo.toml b/Cargo.toml index 4889aa7..0b1bb76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/rsjudge-runner", "xtask"] +members = ["crates/rsjudge-grpc", "crates/rsjudge-rest", "crates/rsjudge-runner", "xtask"] [workspace.package] version = "0.1.0" @@ -73,6 +73,7 @@ cgroups = "0.1.0" clap = { version = "4.5.0", features = ["derive"] } duct = "0.13.7" nix = { version = "0.27.1", features = ["fs"] } +rsjudge-runner = { version = "0.1.0", path = "crates/rsjudge-runner" } serde = { version = "1.0.196", features = ["derive"] } strfmt = "0.2.4" tokio = { version = "1.36.0", features = ["fs"] } @@ -80,19 +81,15 @@ toml = "0.8.10" uzers = "0.11.3" # Optional dependencies -axum = { version = "0.7.4", optional = true } -rsjudge-runner = { version = "0.1.0", path = "crates/rsjudge-runner" } -tonic = { version = "0.11.0", optional = true } -utoipa = { version = "4.2.0", features = ["axum_extras"], optional = true } -utoipa-swagger-ui = { version = "6.0.0", features = ["axum"], optional = true } +rsjudge-grpc = { version = "0.1.0", path = "crates/rsjudge-grpc", optional = true } +rsjudge-rest = { version = "0.1.0", path = "crates/rsjudge-rest", optional = true } [dev-dependencies] tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } [features] -grpc = ["dep:tonic"] -rest = ["dep:axum"] -openapi = ["rest", "dep:utoipa", "dep:utoipa-swagger-ui"] +grpc = ["dep:rsjudge-grpc"] +rest = ["dep:rsjudge-rest"] default = ["grpc"] [build-dependencies] diff --git a/crates/rsjudge-grpc/Cargo.toml b/crates/rsjudge-grpc/Cargo.toml new file mode 100644 index 0000000..48dd08a --- /dev/null +++ b/crates/rsjudge-grpc/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "rsjudge-grpc" +version.workspace = true +authors.workspace = true +edition = "2021" +license.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tonic = "0.11.0" + +[build-dependencies] +anyhow = "1.0.79" +tonic-build = "0.11.0" diff --git a/crates/rsjudge-grpc/build.rs b/crates/rsjudge-grpc/build.rs new file mode 100644 index 0000000..edbfdd1 --- /dev/null +++ b/crates/rsjudge-grpc/build.rs @@ -0,0 +1,6 @@ +use tonic_build::compile_protos; + +fn main() -> anyhow::Result<()> { + compile_protos("proto/rsjudge/v1/rsjudge.proto")?; + Ok(()) +} diff --git a/crates/rsjudge-grpc/proto/buf.yaml b/crates/rsjudge-grpc/proto/buf.yaml new file mode 100644 index 0000000..c5c013e --- /dev/null +++ b/crates/rsjudge-grpc/proto/buf.yaml @@ -0,0 +1,8 @@ +version: v1 +breaking: + use: + - FILE +lint: + use: + - DEFAULT + - COMMENTS diff --git a/crates/rsjudge-grpc/proto/rsjudge/v1/rsjudge.proto b/crates/rsjudge-grpc/proto/rsjudge/v1/rsjudge.proto new file mode 100644 index 0000000..06c10e1 --- /dev/null +++ b/crates/rsjudge-grpc/proto/rsjudge/v1/rsjudge.proto @@ -0,0 +1,123 @@ +syntax = "proto3"; + +package rsjudge.v1; + +// The judging service definition. +service JudgeService { + // Sends a self-test request. + rpc SelfTest(SelfTestRequest) returns (stream SelfTestResponse); + // Sends a judge request. + rpc Submit(SubmitRequest) returns (stream SubmitResponse); +} + +// The request of self-test info, containing user's code and input. +message SelfTestRequest { + // The language of the code. + string language = 1; + // The code to be tested. + string code = 2; + // The input of the program. + string stdin = 3; +} + +// The response message containing the self-test results. +message SelfTestResponse { + // The type of the response. + oneof self_test_response_type { + // Message indicating the compile result. + CompileInfo compile_info = 1; + // Message indicating the self-test result. + SelfTestSummary summary = 2; + } +} + +// Message indicating the compile result. +message CompileInfo { + // Compiler exit status. + // + // 0 indicates the compiler exited normally. + // For interpreted languages, a non-zero exit status indicates semantic errors found in the code. + // For compiled languages, it means compilation errors. + int32 exit_status = 1; + // Compiler stdout. + string stdout = 2; + // Compiler stderr. + string stderr = 3; +} + +// Message indicating the self-test result. +message SelfTestSummary { + // The exit status of the user's program. + // + // 0 indicates the program exited normally. + int32 exit_status = 1; + // The stdout of the program. + string stdout = 2; + // The stderr of the program. + // + // This is not used by the judge system, but may be useful for debugging. + string stderr = 3; +} + +// The request containing the user's code and judge info. +// +// We only showed part of the fields. +message SubmitRequest { + // The language of the code. + string language = 1; + // The code to be judged. + string code = 2; + // The test case id. + // + // If the test case is updated, the test case id MUST be changed, so that the judger can request the latest test case. + int32 test_case_id = 3; +} + +// The response message containing the judge results. +message SubmitResponse { + // The type of the response. + oneof submit_response_type { + // Message indicating the compile result. + CompileInfo compile_info = 1; + // Message indicating the single case judge result. + // + // Case info may not be sent in order, so case id SHOULD be checked. + CaseInfo case_info = 2; + // Message indicating the judge result of all cases. + CasesSummary cases_summary = 3; + } +} + +// Message indicating the single case judge result. +message CaseInfo { + // The ID of the test case, usually starting from 1. + int32 case_id = 1; + // The exit status of the user's program. + int32 exit_status = 2; + // The judge result of the program. + JudgeResult result = 3; + // The score of the case. + int32 score = 4; +} + +// Message indicating the judge result of all cases. +message CasesSummary { + // The judge result of the program. + JudgeResult result = 1; + // The score of the program. + int32 score = 2; +} + +// The judge result. +enum JudgeResult { + // The judge result is unspecified. + // + // This is considered error and SHOULD NOT happen. + JUDGE_RESULT_UNSPECIFIED = 0; + // The judge result is Accepted (AC). + JUDGE_RESULT_ACCEPTED = 1; + // The judge result is Wrong Answer (WA). + JUDGE_RESULT_WRONG_ANSWER = 2; + // The judge result is Runtime Error (RE). + JUDGE_RESULT_RUNTIME_ERROR = 3; +} diff --git a/crates/rsjudge-grpc/src/lib.rs b/crates/rsjudge-grpc/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/crates/rsjudge-grpc/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/crates/rsjudge-rest/Cargo.toml b/crates/rsjudge-rest/Cargo.toml new file mode 100644 index 0000000..6eb8153 --- /dev/null +++ b/crates/rsjudge-rest/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "rsjudge-rest" +edition = "2021" +version.workspace = true +authors.workspace = true +license.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +axum = "0.7.4" diff --git a/crates/rsjudge-rest/src/lib.rs b/crates/rsjudge-rest/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/crates/rsjudge-rest/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/main.rs b/src/main.rs index c6477e9..5ba6d0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use clap::Parser; +use toml::Value; use crate::cli::Args; mod cli; @@ -7,5 +8,10 @@ fn main() -> anyhow::Result<()> { let args = Args::try_parse()?; println!("{:?}", args); + println!( + "Config:\n{:#?}", + toml::from_str::(include_str!("../templates/executors.toml"))? + ); + Ok(()) }