From 5d905684dfd4cca561f4358532c634df61f62baf Mon Sep 17 00:00:00 2001 From: Leo Nash Date: Tue, 5 May 2026 23:48:46 +0000 Subject: [PATCH 1/2] Read `vss.proto` from the local repository instead of github We now read `vss.proto` from the local repository instead of dowloading it from a previous commit on github. We also update the checked-in `types.rs` file to match the one generated with the `genproto` flag, and now skip any formatting of this auto-generated file. --- rust/Cargo.lock | 724 ++---------------------------------------- rust/api/Cargo.toml | 1 - rust/api/build.rs | 17 +- rust/api/src/lib.rs | 1 + rust/api/src/types.rs | 614 +++++++++++++++++------------------ 5 files changed, 332 insertions(+), 1025 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index fc01bf82..9c67c152 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -35,7 +35,6 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "reqwest", ] [[package]] @@ -67,7 +66,7 @@ version = "0.1.0" dependencies = [ "api", "async-trait", - "base64 0.22.1", + "base64", "bitcoin_hashes 0.19.0", "hex-conservative 1.0.1", "jsonwebtoken", @@ -84,12 +83,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -137,12 +130,6 @@ dependencies = [ "bitcoin-internals", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.10.0" @@ -260,32 +247,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", -] - [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -326,12 +293,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "foreign-types" version = "0.3.2" @@ -347,15 +308,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "form_urlencoded" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" -dependencies = [ - "percent-encoding", -] - [[package]] name = "futures-channel" version = "0.3.31" @@ -372,12 +324,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - [[package]] name = "futures-sink" version = "0.3.31" @@ -397,13 +343,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", - "futures-io", "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", - "slab", ] [[package]] @@ -441,25 +384,6 @@ dependencies = [ "wasip2", ] -[[package]] -name = "h2" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -505,17 +429,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.4.0" @@ -526,17 +439,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -544,7 +446,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.4.0", + "http", ] [[package]] @@ -555,8 +457,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.4.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -572,30 +474,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "hyper" -version = "0.14.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.5.10", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.8.1" @@ -606,8 +484,8 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "http 1.4.0", - "http-body 1.0.1", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -617,20 +495,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.32", - "rustls", - "tokio", - "tokio-rustls", -] - [[package]] name = "hyper-util" version = "0.1.20" @@ -638,9 +502,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "bytes", - "http 1.4.0", - "http-body 1.0.1", - "hyper 1.8.1", + "http", + "http-body", + "hyper", "pin-project-lite", "tokio", ] @@ -669,108 +533,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" -dependencies = [ - "displaydoc", - "potential_utf", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locale_core" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" -dependencies = [ - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" - -[[package]] -name = "icu_properties" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" -dependencies = [ - "icu_collections", - "icu_locale_core", - "icu_properties_data", - "icu_provider", - "zerotrie", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" - -[[package]] -name = "icu_provider" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" -dependencies = [ - "displaydoc", - "icu_locale_core", - "writeable", - "yoke", - "zerofrom", - "zerotrie", - "zerovec", -] - -[[package]] -name = "idna" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" -dependencies = [ - "icu_normalizer", - "icu_properties", -] - [[package]] name = "impls" version = "0.1.0" @@ -796,12 +558,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "ipnet" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" - [[package]] name = "itertools" version = "0.10.5" @@ -833,7 +589,7 @@ version = "9.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" dependencies = [ - "base64 0.22.1", + "base64", "js-sys", "pem", "ring", @@ -860,7 +616,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ - "bitflags 2.10.0", + "bitflags", "libc", ] @@ -876,12 +632,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" -[[package]] -name = "litemap" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" - [[package]] name = "lock_api" version = "0.4.14" @@ -913,12 +663,6 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "mio" version = "1.1.1" @@ -999,7 +743,7 @@ version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ - "bitflags 2.10.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -1066,7 +810,7 @@ version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" dependencies = [ - "base64 0.22.1", + "base64", "serde_core", ] @@ -1141,7 +885,7 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee9dd5fe15055d2b6806f4736aa0c9637217074e224bbec46d4041b91bb9491" dependencies = [ - "base64 0.22.1", + "base64", "byteorder", "bytes", "fallible-iterator", @@ -1165,15 +909,6 @@ dependencies = [ "postgres-protocol", ] -[[package]] -name = "potential_utf" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" -dependencies = [ - "zerovec", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -1342,7 +1077,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.10.0", + "bitflags", ] [[package]] @@ -1374,47 +1109,6 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-rustls", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - [[package]] name = "ring" version = "0.17.14" @@ -1435,7 +1129,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.10.0", + "bitflags", "errno", "libc", "linux-raw-sys 0.4.15", @@ -1448,56 +1142,19 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" dependencies = [ - "bitflags 2.10.0", + "bitflags", "errno", "libc", "linux-raw-sys 0.11.0", "windows-sys 0.61.2", ] -[[package]] -name = "rustls" -version = "0.21.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring", - "rustls-webpki", - "sct", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" -[[package]] -name = "ryu" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" - [[package]] name = "schannel" version = "0.1.28" @@ -1513,16 +1170,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "secp256k1" version = "0.31.1" @@ -1549,7 +1196,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.10.0", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -1618,18 +1265,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha2" version = "0.10.9" @@ -1675,28 +1310,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" -[[package]] -name = "slab" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" - [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -[[package]] -name = "socket2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "socket2" version = "0.6.2" @@ -1707,12 +1326,6 @@ dependencies = [ "windows-sys 0.60.2", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - [[package]] name = "stringprep" version = "0.1.5" @@ -1752,44 +1365,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", -] - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tempfile" version = "3.24.0" @@ -1854,16 +1429,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinystr" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" version = "1.10.0" @@ -1890,7 +1455,7 @@ dependencies = [ "mio", "pin-project-lite", "signal-hook-registry", - "socket2 0.6.2", + "socket2", "tokio-macros", "windows-sys 0.61.2", ] @@ -1936,22 +1501,12 @@ dependencies = [ "postgres-protocol", "postgres-types", "rand 0.9.2", - "socket2 0.6.2", + "socket2", "tokio", "tokio-util", "whoami", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.18" @@ -1999,37 +1554,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.19.0" @@ -2069,24 +1593,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "url" -version = "2.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", -] - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "vcpkg" version = "0.2.15" @@ -2108,7 +1614,7 @@ dependencies = [ "bytes", "chrono", "http-body-util", - "hyper 1.8.1", + "hyper", "hyper-util", "impls", "log", @@ -2119,15 +1625,6 @@ dependencies = [ "toml", ] -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -2174,20 +1671,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f" -dependencies = [ - "cfg-if", - "futures-util", - "js-sys", - "once_cell", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.108" @@ -2230,12 +1713,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - [[package]] name = "which" version = "4.4.2" @@ -2318,15 +1795,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -2363,21 +1831,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -2411,12 +1864,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -2429,12 +1876,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -2447,12 +1888,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2477,12 +1912,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -2495,12 +1924,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -2513,12 +1936,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -2531,12 +1948,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2558,51 +1969,12 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -[[package]] -name = "writeable" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" - -[[package]] -name = "yoke" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" -dependencies = [ - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.8.37" @@ -2623,60 +1995,6 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "zerofrom" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", - "synstructure", -] - -[[package]] -name = "zerotrie" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", -] - -[[package]] -name = "zerovec" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", -] - [[package]] name = "zmij" version = "1.0.19" diff --git a/rust/api/Cargo.toml b/rust/api/Cargo.toml index c409591d..b34be8d7 100644 --- a/rust/api/Cargo.toml +++ b/rust/api/Cargo.toml @@ -12,7 +12,6 @@ rand = { version = "0.8.5", optional = true} [target.'cfg(genproto)'.build-dependencies] prost-build = { version = "0.11.3" } -reqwest = { version = "0.11.13", default-features = false, features = ["rustls-tls", "blocking"] } [dev-dependencies] diff --git a/rust/api/build.rs b/rust/api/build.rs index c916832d..fc231eb0 100644 --- a/rust/api/build.rs +++ b/rust/api/build.rs @@ -1,7 +1,7 @@ #[cfg(genproto)] extern crate prost_build; #[cfg(genproto)] -use std::{env, fs, fs::File, path::Path}; +use std::{env, fs, path::Path}; /// To generate updated proto objects, run `RUSTFLAGS="--cfg genproto" cargo build` fn main() { @@ -11,10 +11,8 @@ fn main() { #[cfg(genproto)] fn generate_protos() { - download_file( - "https://raw.githubusercontent.com/lightningdevkit/vss-server/7f492fcac0c561b212f49ca40f7d16075822440f/app/src/main/proto/vss.proto", - "src/proto/vss.proto", - ).unwrap(); + fs::create_dir_all("src/proto").unwrap(); + fs::copy("../../proto/vss.proto", "src/proto/vss.proto").unwrap(); prost_build::Config::new() .bytes(&["."]) @@ -24,12 +22,3 @@ fn generate_protos() { let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("vss.rs"); fs::copy(from_path, "src/types.rs").unwrap(); } - -#[cfg(genproto)] -fn download_file(url: &str, save_to: &str) -> Result<(), Box> { - let mut response = reqwest::blocking::get(url)?; - fs::create_dir_all(Path::new(save_to).parent().unwrap())?; - let mut out_file = File::create(save_to)?; - response.copy_to(&mut out_file)?; - Ok(()) -} diff --git a/rust/api/src/lib.rs b/rust/api/src/lib.rs index 8da2680b..2ecfe6de 100644 --- a/rust/api/src/lib.rs +++ b/rust/api/src/lib.rs @@ -20,6 +20,7 @@ pub mod error; pub mod kv_store; /// Contains request/response types generated from the API definition of VSS. +#[rustfmt::skip] pub mod types; #[cfg(feature = "_test_utils")] diff --git a/rust/api/src/types.rs b/rust/api/src/types.rs index 954afe94..4d7b3650 100644 --- a/rust/api/src/types.rs +++ b/rust/api/src/types.rs @@ -2,135 +2,135 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetObjectRequest { - /// `store_id` is a keyspace identifier. - /// Ref: ) - /// All APIs operate within a single `store_id`. - /// It is up to clients to use single or multiple stores for their use-case. - /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. - /// Authorization and billing can also be performed at the `store_id` level. - #[prost(string, tag = "1")] - pub store_id: ::prost::alloc::string::String, - /// The key of the value to be fetched. - /// - /// If the specified `key` does not exist, returns `ErrorCode.NO_SUCH_KEY_EXCEPTION` in the - /// the `ErrorResponse`. - /// - /// Consistency Guarantee: - /// Get(read) operations against a `key` are consistent reads and will reflect all previous writes, - /// since Put/Write provides read-after-write and read-after-update consistency guarantees. - /// - /// Read Isolation: - /// Get/Read operations against a `key` are ensured to have read-committed isolation. - /// Ref: )#Read_committed - #[prost(string, tag = "2")] - pub key: ::prost::alloc::string::String, + /// `store_id` is a keyspace identifier. + /// Ref: ) + /// All APIs operate within a single `store_id`. + /// It is up to clients to use single or multiple stores for their use-case. + /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. + /// Authorization and billing can also be performed at the `store_id` level. + #[prost(string, tag = "1")] + pub store_id: ::prost::alloc::string::String, + /// The key of the value to be fetched. + /// + /// If the specified `key` does not exist, returns `ErrorCode.NO_SUCH_KEY_EXCEPTION` in the + /// the `ErrorResponse`. + /// + /// Consistency Guarantee: + /// Get(read) operations against a `key` are consistent reads and will reflect all previous writes, + /// since Put/Write provides read-after-write and read-after-update consistency guarantees. + /// + /// Read Isolation: + /// Get/Read operations against a `key` are ensured to have read-committed isolation. + /// Ref: )#Read_committed + #[prost(string, tag = "2")] + pub key: ::prost::alloc::string::String, } /// Server response for `GetObject` API. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetObjectResponse { - /// Fetched `value` and `version` along with the corresponding `key` in the request. - #[prost(message, optional, tag = "2")] - pub value: ::core::option::Option, + /// Fetched `value` and `version` along with the corresponding `key` in the request. + #[prost(message, optional, tag = "2")] + pub value: ::core::option::Option, } /// Request payload to be used for `PutObject` API call to server. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PutObjectRequest { - /// `store_id` is a keyspace identifier. - /// Ref: ) - /// All APIs operate within a single `store_id`. - /// It is up to clients to use single or multiple stores for their use-case. - /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. - /// Authorization and billing can also be performed at the `store_id` level. - #[prost(string, tag = "1")] - pub store_id: ::prost::alloc::string::String, - /// `global_version` is a sequence-number/version of the whole store. This can be used for versioning - /// and ensures that multiple updates in case of multiple devices can only be done linearly, even - /// if those updates did not directly conflict with each other based on keys/`transaction_items`. - /// - /// If present, the write will only succeed if the current server-side `global_version` against - /// the `store_id` is same as in the request. - /// Clients are expected to store (client-side) the global version against `store_id`. - /// The request must contain their client-side value of `global_version` if global versioning and - /// conflict detection is desired. - /// - /// For the first write of the store, global version should be '0'. If the write succeeds, clients - /// must increment their global version (client-side) by 1. - /// The server increments `global_version` (server-side) for every successful write, hence this - /// client-side increment is required to ensure matching versions. This updated global version - /// should be used in subsequent `PutObjectRequest`s for the store. - /// - /// Requests with a conflicting version will fail with `CONFLICT_EXCEPTION` as ErrorCode. - #[prost(int64, optional, tag = "2")] - pub global_version: ::core::option::Option, - /// Items to be written as a result of this `PutObjectRequest`. - /// - /// In an item, each `key` is supplied with its corresponding `value` and `version`. - /// Clients can choose to encrypt the keys client-side in order to obfuscate their usage patterns. - /// If the write is successful, the previous `value` corresponding to the `key` will be overwritten. - /// - /// Multiple items in `transaction_items` and `delete_items` of a single `PutObjectRequest` are written in - /// a database-transaction in an all-or-nothing fashion. - /// All Items in a single `PutObjectRequest` must have distinct keys. - /// - /// Key-level versioning (Conditional Write): - /// Clients are expected to store a `version` against every `key`. - /// The write will succeed if the current DB version against the `key` is the same as in the request. - /// When initiating a `PutObjectRequest`, the request should contain their client-side `version` - /// for that key-value. - /// - /// For the first write of any `key`, the `version` should be '0'. If the write succeeds, the client - /// must increment their corresponding key versions (client-side) by 1. - /// The server increments key versions (server-side) for every successful write, hence this - /// client-side increment is required to ensure matching versions. These updated key versions should - /// be used in subsequent `PutObjectRequest`s for the keys. - /// - /// Requests with a conflicting/mismatched version will fail with `CONFLICT_EXCEPTION` as ErrorCode - /// for conditional writes. - /// - /// Skipping key-level versioning (Non-conditional Write): - /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. - /// This will perform a non-conditional write query, after which the `version` against the `key` - /// is reset to '1'. Hence, the next `PutObjectRequest` for the `key` can be either - /// a non-conditional write or a conditional write with `version` set to `1`. - /// - /// Considerations for transactions: - /// Transaction writes of multiple items have a performance overhead, hence it is recommended to use - /// them only if required by the client application to ensure logic/code correctness. - /// That is, `transaction_items` are not a substitute for batch-write of multiple unrelated items. - /// When a write of multiple unrelated items is desired, it is recommended to use separate - /// `PutObjectRequest`s. - /// - /// Consistency guarantee: - /// All `PutObjectRequest`s are strongly consistent i.e. they provide read-after-write and - /// read-after-update consistency guarantees. - #[prost(message, repeated, tag = "3")] - pub transaction_items: ::prost::alloc::vec::Vec, - /// Items to be deleted as a result of this `PutObjectRequest`. - /// - /// Each item in the `delete_items` field consists of a `key` and its corresponding `version`. - /// - /// Key-Level Versioning (Conditional Delete): - /// The `version` is used to perform a version check before deleting the item. - /// The delete will only succeed if the current database version against the `key` is the same as - /// the `version` specified in the request. - /// - /// Skipping key-level versioning (Non-conditional Delete): - /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. - /// This will perform a non-conditional delete query. - /// - /// Fails with `CONFLICT_EXCEPTION` as the ErrorCode if: - /// * The requested item does not exist. - /// * The requested item does exist but there is a version-number mismatch (in conditional delete) - /// with the one in the database. - /// - /// Multiple items in the `delete_items` field, along with the `transaction_items`, are written in a - /// database transaction in an all-or-nothing fashion. - /// - /// All items within a single `PutObjectRequest` must have distinct keys. - #[prost(message, repeated, tag = "4")] - pub delete_items: ::prost::alloc::vec::Vec, + /// `store_id` is a keyspace identifier. + /// Ref: ) + /// All APIs operate within a single `store_id`. + /// It is up to clients to use single or multiple stores for their use-case. + /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. + /// Authorization and billing can also be performed at the `store_id` level. + #[prost(string, tag = "1")] + pub store_id: ::prost::alloc::string::String, + /// `global_version` is a sequence-number/version of the whole store. This can be used for versioning + /// and ensures that multiple updates in case of multiple devices can only be done linearly, even + /// if those updates did not directly conflict with each other based on keys/`transaction_items`. + /// + /// If present, the write will only succeed if the current server-side `global_version` against + /// the `store_id` is same as in the request. + /// Clients are expected to store (client-side) the global version against `store_id`. + /// The request must contain their client-side value of `global_version` if global versioning and + /// conflict detection is desired. + /// + /// For the first write of the store, global version should be '0'. If the write succeeds, clients + /// must increment their global version (client-side) by 1. + /// The server increments `global_version` (server-side) for every successful write, hence this + /// client-side increment is required to ensure matching versions. This updated global version + /// should be used in subsequent `PutObjectRequest`s for the store. + /// + /// Requests with a conflicting version will fail with `CONFLICT_EXCEPTION` as ErrorCode. + #[prost(int64, optional, tag = "2")] + pub global_version: ::core::option::Option, + /// Items to be written as a result of this `PutObjectRequest`. + /// + /// In an item, each `key` is supplied with its corresponding `value` and `version`. + /// Clients can choose to encrypt the keys client-side in order to obfuscate their usage patterns. + /// If the write is successful, the previous `value` corresponding to the `key` will be overwritten. + /// + /// Multiple items in `transaction_items` and `delete_items` of a single `PutObjectRequest` are written in + /// a database-transaction in an all-or-nothing fashion. + /// All Items in a single `PutObjectRequest` must have distinct keys. + /// + /// Key-level versioning (Conditional Write): + /// Clients are expected to store a `version` against every `key`. + /// The write will succeed if the current DB version against the `key` is the same as in the request. + /// When initiating a `PutObjectRequest`, the request should contain their client-side `version` + /// for that key-value. + /// + /// For the first write of any `key`, the `version` should be '0'. If the write succeeds, the client + /// must increment their corresponding key versions (client-side) by 1. + /// The server increments key versions (server-side) for every successful write, hence this + /// client-side increment is required to ensure matching versions. These updated key versions should + /// be used in subsequent `PutObjectRequest`s for the keys. + /// + /// Requests with a conflicting/mismatched version will fail with `CONFLICT_EXCEPTION` as ErrorCode + /// for conditional writes. + /// + /// Skipping key-level versioning (Non-conditional Write): + /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. + /// This will perform a non-conditional write query, after which the `version` against the `key` + /// is reset to '1'. Hence, the next `PutObjectRequest` for the `key` can be either + /// a non-conditional write or a conditional write with `version` set to `1`. + /// + /// Considerations for transactions: + /// Transaction writes of multiple items have a performance overhead, hence it is recommended to use + /// them only if required by the client application to ensure logic/code correctness. + /// That is, `transaction_items` are not a substitute for batch-write of multiple unrelated items. + /// When a write of multiple unrelated items is desired, it is recommended to use separate + /// `PutObjectRequest`s. + /// + /// Consistency guarantee: + /// All `PutObjectRequest`s are strongly consistent i.e. they provide read-after-write and + /// read-after-update consistency guarantees. + #[prost(message, repeated, tag = "3")] + pub transaction_items: ::prost::alloc::vec::Vec, + /// Items to be deleted as a result of this `PutObjectRequest`. + /// + /// Each item in the `delete_items` field consists of a `key` and its corresponding `version`. + /// + /// Key-Level Versioning (Conditional Delete): + /// The `version` is used to perform a version check before deleting the item. + /// The delete will only succeed if the current database version against the `key` is the same as + /// the `version` specified in the request. + /// + /// Skipping key-level versioning (Non-conditional Delete): + /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. + /// This will perform a non-conditional delete query. + /// + /// Fails with `CONFLICT_EXCEPTION` as the ErrorCode if: + /// * The requested item does not exist. + /// * The requested item does exist but there is a version-number mismatch (in conditional delete) + /// with the one in the database. + /// + /// Multiple items in the `delete_items` field, along with the `transaction_items`, are written in a + /// database transaction in an all-or-nothing fashion. + /// + /// All items within a single `PutObjectRequest` must have distinct keys. + #[prost(message, repeated, tag = "4")] + pub delete_items: ::prost::alloc::vec::Vec, } /// Server response for `PutObject` API. #[allow(clippy::derive_partial_eq_without_eq)] @@ -140,32 +140,32 @@ pub struct PutObjectResponse {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteObjectRequest { - /// `store_id` is a keyspace identifier. - /// Ref: ) - /// All APIs operate within a single `store_id`. - /// It is up to clients to use single or multiple stores for their use-case. - /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. - /// Authorization and billing can also be performed at the `store_id` level. - #[prost(string, tag = "1")] - pub store_id: ::prost::alloc::string::String, - /// Item to be deleted as a result of this `DeleteObjectRequest`. - /// - /// An item consists of a `key` and its corresponding `version`. - /// - /// Key-level Versioning (Conditional Delete): - /// The item is only deleted if the current database version against the `key` is the same as - /// the `version` specified in the request. - /// - /// Skipping key-level versioning (Non-conditional Delete): - /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. - /// This will perform a non-conditional delete query. - /// - /// This operation is idempotent, that is, multiple delete calls for the same item will not fail. - /// - /// If the requested item does not exist, this operation will not fail. - /// If you wish to perform stricter checks while deleting an item, consider using `PutObject` API. - #[prost(message, optional, tag = "2")] - pub key_value: ::core::option::Option, + /// `store_id` is a keyspace identifier. + /// Ref: ) + /// All APIs operate within a single `store_id`. + /// It is up to clients to use single or multiple stores for their use-case. + /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. + /// Authorization and billing can also be performed at the `store_id` level. + #[prost(string, tag = "1")] + pub store_id: ::prost::alloc::string::String, + /// Item to be deleted as a result of this `DeleteObjectRequest`. + /// + /// An item consists of a `key` and its corresponding `version`. + /// + /// Key-level Versioning (Conditional Delete): + /// The item is only deleted if the current database version against the `key` is the same as + /// the `version` specified in the request. + /// + /// Skipping key-level versioning (Non-conditional Delete): + /// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'. + /// This will perform a non-conditional delete query. + /// + /// This operation is idempotent, that is, multiple delete calls for the same item will not fail. + /// + /// If the requested item does not exist, this operation will not fail. + /// If you wish to perform stricter checks while deleting an item, consider using `PutObject` API. + #[prost(message, optional, tag = "2")] + pub key_value: ::core::option::Option, } /// Server response for `DeleteObject` API. #[allow(clippy::derive_partial_eq_without_eq)] @@ -175,117 +175,117 @@ pub struct DeleteObjectResponse {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListKeyVersionsRequest { - /// `store_id` is a keyspace identifier. - /// Ref: ) - /// All APIs operate within a single `store_id`. - /// It is up to clients to use single or multiple stores for their use-case. - /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. - /// Authorization and billing can also be performed at the `store_id` level. - #[prost(string, tag = "1")] - pub store_id: ::prost::alloc::string::String, - /// A `key_prefix` is a string of characters at the beginning of the key. Prefixes can be used as - /// a way to organize key-values in a similar way to directories. - /// - /// If `key_prefix` is specified, the response results will be limited to those keys that begin with - /// the specified prefix. - /// - /// If no `key_prefix` is specified or it is empty (""), all the keys are eligible to be returned in - /// the response. - #[prost(string, optional, tag = "2")] - pub key_prefix: ::core::option::Option<::prost::alloc::string::String>, - /// `page_size` is used by clients to specify the maximum number of results that can be returned by - /// the server. - /// The server may further constrain the maximum number of results returned in a single page. - /// If the `page_size` is 0 or not set, the server will decide the number of results to be returned. - #[prost(int32, optional, tag = "3")] - pub page_size: ::core::option::Option, - /// `page_token` is a pagination token. - /// - /// To query for the first page of `ListKeyVersions`, `page_token` must not be specified. - /// - /// For subsequent pages, use the value that was returned as `next_page_token` in the previous - /// page's `ListKeyVersionsResponse`. - #[prost(string, optional, tag = "4")] - pub page_token: ::core::option::Option<::prost::alloc::string::String>, + /// `store_id` is a keyspace identifier. + /// Ref: ) + /// All APIs operate within a single `store_id`. + /// It is up to clients to use single or multiple stores for their use-case. + /// This can be used for client-isolation/ rate-limiting / throttling on the server-side. + /// Authorization and billing can also be performed at the `store_id` level. + #[prost(string, tag = "1")] + pub store_id: ::prost::alloc::string::String, + /// A `key_prefix` is a string of characters at the beginning of the key. Prefixes can be used as + /// a way to organize key-values in a similar way to directories. + /// + /// If `key_prefix` is specified, the response results will be limited to those keys that begin with + /// the specified prefix. + /// + /// If no `key_prefix` is specified or it is empty (""), all the keys are eligible to be returned in + /// the response. + #[prost(string, optional, tag = "2")] + pub key_prefix: ::core::option::Option<::prost::alloc::string::String>, + /// `page_size` is used by clients to specify the maximum number of results that can be returned by + /// the server. + /// The server may further constrain the maximum number of results returned in a single page. + /// If the `page_size` is 0 or not set, the server will decide the number of results to be returned. + #[prost(int32, optional, tag = "3")] + pub page_size: ::core::option::Option, + /// `page_token` is a pagination token. + /// + /// To query for the first page of `ListKeyVersions`, `page_token` must not be specified. + /// + /// For subsequent pages, use the value that was returned as `next_page_token` in the previous + /// page's `ListKeyVersionsResponse`. + #[prost(string, optional, tag = "4")] + pub page_token: ::core::option::Option<::prost::alloc::string::String>, } /// Server response for `ListKeyVersions` API. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListKeyVersionsResponse { - /// Fetched keys and versions, ordered by creation time (newest first). - /// Even though this API reuses the `KeyValue` struct, the `value` sub-field will not be set by the server. - #[prost(message, repeated, tag = "1")] - pub key_versions: ::prost::alloc::vec::Vec, - /// `next_page_token` is a pagination token, used to retrieve the next page of results. - /// Use this value to query for next-page of paginated `ListKeyVersions` operation, by specifying - /// this value as the `page_token` in the next request. - /// - /// Following AIP-158 (): - /// - /// If `next_page_token` is empty (""), then the "last page" of results has been processed and - /// there is no more data to be retrieved. - /// - /// If `next_page_token` is not empty, it does not necessarily mean that there is more data in the - /// result set. The only way to know when you have reached the end of the result set is when - /// `next_page_token` is empty. - /// - /// Caution: Clients must not assume a specific number of key_versions to be present in a page for - /// paginated response. - #[prost(string, optional, tag = "2")] - pub next_page_token: ::core::option::Option<::prost::alloc::string::String>, - /// `global_version` is a sequence-number/version of the whole store. - /// - /// `global_version` is only returned in response for the first page of the `ListKeyVersionsResponse` - /// and is guaranteed to be read before reading any key-versions. - /// - /// In case of refreshing the complete key-version view on the client-side, correct usage for - /// the returned `global_version` is as following: - /// 1. Read `global_version` from the first page of paginated response and save it as local variable. - /// 2. Update all the `key_versions` on client-side from all the pages of paginated response. - /// 3. Update `global_version` on client_side from the local variable saved in step-1. - /// This ensures that on client-side, all current `key_versions` were stored at `global_version` or later. - /// This guarantee is helpful for ensuring the versioning correctness if using the `global_version` - /// in `PutObject` API and can help avoid the race conditions related to it. - #[prost(int64, optional, tag = "3")] - pub global_version: ::core::option::Option, + /// Fetched keys and versions, ordered by creation time (newest first). + /// Even though this API reuses the `KeyValue` struct, the `value` sub-field will not be set by the server. + #[prost(message, repeated, tag = "1")] + pub key_versions: ::prost::alloc::vec::Vec, + /// `next_page_token` is a pagination token, used to retrieve the next page of results. + /// Use this value to query for next-page of paginated `ListKeyVersions` operation, by specifying + /// this value as the `page_token` in the next request. + /// + /// Following AIP-158 (): + /// + /// If `next_page_token` is empty (""), then the "last page" of results has been processed and + /// there is no more data to be retrieved. + /// + /// If `next_page_token` is not empty, it does not necessarily mean that there is more data in the + /// result set. The only way to know when you have reached the end of the result set is when + /// `next_page_token` is empty. + /// + /// Caution: Clients must not assume a specific number of key_versions to be present in a page for + /// paginated response. + #[prost(string, optional, tag = "2")] + pub next_page_token: ::core::option::Option<::prost::alloc::string::String>, + /// `global_version` is a sequence-number/version of the whole store. + /// + /// `global_version` is only returned in response for the first page of the `ListKeyVersionsResponse` + /// and is guaranteed to be read before reading any key-versions. + /// + /// In case of refreshing the complete key-version view on the client-side, correct usage for + /// the returned `global_version` is as following: + /// 1. Read `global_version` from the first page of paginated response and save it as local variable. + /// 2. Update all the `key_versions` on client-side from all the pages of paginated response. + /// 3. Update `global_version` on client_side from the local variable saved in step-1. + /// This ensures that on client-side, all current `key_versions` were stored at `global_version` or later. + /// This guarantee is helpful for ensuring the versioning correctness if using the `global_version` + /// in `PutObject` API and can help avoid the race conditions related to it. + #[prost(int64, optional, tag = "3")] + pub global_version: ::core::option::Option, } /// When HttpStatusCode is not ok (200), the response `content` contains a serialized `ErrorResponse` /// with the relevant `ErrorCode` and `message` #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ErrorResponse { - /// The error code uniquely identifying an error condition. - /// It is meant to be read and understood programmatically by code that detects/handles errors by - /// type. - #[prost(enumeration = "ErrorCode", tag = "1")] - pub error_code: i32, - /// The error message containing a generic description of the error condition in English. - /// It is intended for a human audience only and should not be parsed to extract any information - /// programmatically. Client-side code may use it for logging only. - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, + /// The error code uniquely identifying an error condition. + /// It is meant to be read and understood programmatically by code that detects/handles errors by + /// type. + #[prost(enumeration = "ErrorCode", tag = "1")] + pub error_code: i32, + /// The error message containing a generic description of the error condition in English. + /// It is intended for a human audience only and should not be parsed to extract any information + /// programmatically. Client-side code may use it for logging only. + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, } /// Represents a key-value pair to be stored or retrieved. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct KeyValue { - /// Key against which the value is stored. - #[prost(string, tag = "1")] - pub key: ::prost::alloc::string::String, - /// Version field is used for key-level versioning. - /// For first write of key, `version` should be '0'. If the write succeeds, clients must increment - /// their corresponding key version (client-side) by 1. - /// The server increments key version (server-side) for every successful write, hence this - /// client-side increment is required to ensure matching versions. These updated key versions should - /// be used in subsequent `PutObjectRequest`s for the keys. - #[prost(int64, tag = "2")] - pub version: i64, - /// Object value in bytes which is stored (in put) and fetched (in get). - /// Clients must encrypt the secret contents of this blob client-side before sending it over the - /// wire to the server in order to preserve privacy and security. - /// Clients may use a `Storable` object, serialize it and set it here. - #[prost(bytes = "bytes", tag = "3")] - pub value: ::prost::bytes::Bytes, + /// Key against which the value is stored. + #[prost(string, tag = "1")] + pub key: ::prost::alloc::string::String, + /// Version field is used for key-level versioning. + /// For first write of key, `version` should be '0'. If the write succeeds, clients must increment + /// their corresponding key version (client-side) by 1. + /// The server increments key version (server-side) for every successful write, hence this + /// client-side increment is required to ensure matching versions. These updated key versions should + /// be used in subsequent `PutObjectRequest`s for the keys. + #[prost(int64, tag = "2")] + pub version: i64, + /// Object value in bytes which is stored (in put) and fetched (in get). + /// Clients must encrypt the secret contents of this blob client-side before sending it over the + /// wire to the server in order to preserve privacy and security. + /// Clients may use a `Storable` object, serialize it and set it here. + #[prost(bytes = "bytes", tag = "3")] + pub value: ::prost::bytes::Bytes, } /// Represents a storable object that can be serialized and stored as `value` in `PutObjectRequest`. /// Only provided as a helper object for ease of use by clients. @@ -295,89 +295,89 @@ pub struct KeyValue { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Storable { - /// Represents an encrypted and serialized `PlaintextBlob`. MUST encrypt the whole `PlaintextBlob` - /// using client-side encryption before setting here. - #[prost(bytes = "bytes", tag = "1")] - pub data: ::prost::bytes::Bytes, - /// Represents encryption related metadata - #[prost(message, optional, tag = "2")] - pub encryption_metadata: ::core::option::Option, + /// Represents an encrypted and serialized `PlaintextBlob`. MUST encrypt the whole `PlaintextBlob` + /// using client-side encryption before setting here. + #[prost(bytes = "bytes", tag = "1")] + pub data: ::prost::bytes::Bytes, + /// Represents encryption related metadata + #[prost(message, optional, tag = "2")] + pub encryption_metadata: ::core::option::Option, } /// Represents encryption related metadata #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EncryptionMetadata { - /// The encryption algorithm used for encrypting the `PlaintextBlob`. - #[prost(string, tag = "1")] - pub cipher_format: ::prost::alloc::string::String, - /// The nonce used for encryption. Nonce is a random or unique value used to ensure that the same - /// plaintext results in different ciphertexts every time it is encrypted. - #[prost(bytes = "bytes", tag = "2")] - pub nonce: ::prost::bytes::Bytes, - /// The authentication tag used for encryption. It provides integrity and authenticity assurance - /// for the encrypted data. - #[prost(bytes = "bytes", tag = "3")] - pub tag: ::prost::bytes::Bytes, + /// The encryption algorithm used for encrypting the `PlaintextBlob`. + #[prost(string, tag = "1")] + pub cipher_format: ::prost::alloc::string::String, + /// The nonce used for encryption. Nonce is a random or unique value used to ensure that the same + /// plaintext results in different ciphertexts every time it is encrypted. + #[prost(bytes = "bytes", tag = "2")] + pub nonce: ::prost::bytes::Bytes, + /// The authentication tag used for encryption. It provides integrity and authenticity assurance + /// for the encrypted data. + #[prost(bytes = "bytes", tag = "3")] + pub tag: ::prost::bytes::Bytes, } /// Represents a data blob, which is encrypted, serialized and later used in `Storable.data`. /// Since the whole `Storable.data` is client-side encrypted, the server cannot understand this. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PlaintextBlob { - /// The unencrypted value. - #[prost(bytes = "bytes", tag = "1")] - pub value: ::prost::bytes::Bytes, - /// The version of the value. Can be used by client to verify version integrity. - #[prost(int64, tag = "2")] - pub version: i64, + /// The unencrypted value. + #[prost(bytes = "bytes", tag = "1")] + pub value: ::prost::bytes::Bytes, + /// The version of the value. Can be used by client to verify version integrity. + #[prost(int64, tag = "2")] + pub version: i64, } /// ErrorCodes to be used in `ErrorResponse` #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ErrorCode { - /// Default protobuf Enum value. Will not be used as `ErrorCode` by server. - Unknown = 0, - /// Used when the request contains mismatched version (either key or global) - /// in `PutObjectRequest`. For more info refer `PutObjectRequest`. - ConflictException = 1, - /// Used in the following cases: - /// - The request was missing a required argument. - /// - The specified argument was invalid, incomplete or in the wrong format. - /// - The request body of api cannot be deserialized into corresponding protobuf object. - InvalidRequestException = 2, - /// Used when an internal server error occurred, client is probably at no fault and can safely retry - /// this error with exponential backoff. - InternalServerException = 3, - /// Used when the specified `key` in a `GetObjectRequest` does not exist. - NoSuchKeyException = 4, - /// Used when authentication fails or in case of an unauthorized request. - AuthException = 5, + /// Default protobuf Enum value. Will not be used as `ErrorCode` by server. + Unknown = 0, + /// Used when the request contains mismatched version (either key or global) + /// in `PutObjectRequest`. For more info refer `PutObjectRequest`. + ConflictException = 1, + /// Used in the following cases: + /// - The request was missing a required argument. + /// - The specified argument was invalid, incomplete or in the wrong format. + /// - The request body of api cannot be deserialized into corresponding protobuf object. + InvalidRequestException = 2, + /// Used when an internal server error occurred, client is probably at no fault and can safely retry + /// this error with exponential backoff. + InternalServerException = 3, + /// Used when the specified `key` in a `GetObjectRequest` does not exist. + NoSuchKeyException = 4, + /// Used when authentication fails or in case of an unauthorized request. + AuthException = 5, } impl ErrorCode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - ErrorCode::Unknown => "UNKNOWN", - ErrorCode::ConflictException => "CONFLICT_EXCEPTION", - ErrorCode::InvalidRequestException => "INVALID_REQUEST_EXCEPTION", - ErrorCode::InternalServerException => "INTERNAL_SERVER_EXCEPTION", - ErrorCode::NoSuchKeyException => "NO_SUCH_KEY_EXCEPTION", - ErrorCode::AuthException => "AUTH_EXCEPTION", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNKNOWN" => Some(Self::Unknown), - "CONFLICT_EXCEPTION" => Some(Self::ConflictException), - "INVALID_REQUEST_EXCEPTION" => Some(Self::InvalidRequestException), - "INTERNAL_SERVER_EXCEPTION" => Some(Self::InternalServerException), - "NO_SUCH_KEY_EXCEPTION" => Some(Self::NoSuchKeyException), - "AUTH_EXCEPTION" => Some(Self::AuthException), - _ => None, - } - } + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ErrorCode::Unknown => "UNKNOWN", + ErrorCode::ConflictException => "CONFLICT_EXCEPTION", + ErrorCode::InvalidRequestException => "INVALID_REQUEST_EXCEPTION", + ErrorCode::InternalServerException => "INTERNAL_SERVER_EXCEPTION", + ErrorCode::NoSuchKeyException => "NO_SUCH_KEY_EXCEPTION", + ErrorCode::AuthException => "AUTH_EXCEPTION", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNKNOWN" => Some(Self::Unknown), + "CONFLICT_EXCEPTION" => Some(Self::ConflictException), + "INVALID_REQUEST_EXCEPTION" => Some(Self::InvalidRequestException), + "INTERNAL_SERVER_EXCEPTION" => Some(Self::InternalServerException), + "NO_SUCH_KEY_EXCEPTION" => Some(Self::NoSuchKeyException), + "AUTH_EXCEPTION" => Some(Self::AuthException), + _ => None, + } + } } From 87ddfe1d4c43926f4e29b7aafdcf0dd88f45e551 Mon Sep 17 00:00:00 2001 From: Leo Nash Date: Wed, 6 May 2026 00:14:20 +0000 Subject: [PATCH 2/2] Add /version endpoint This endpoint allows clients to check the version of the VSS API that the server is serving. It also serves as a health check. --- .github/workflows/build-and-deploy-rust.yml | 2 ++ proto/vss.proto | 17 ++++++++++ rust/api/src/types.rs | 37 +++++++++++++++++++++ rust/server/src/vss_service.rs | 10 +++++- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-rust.yml b/.github/workflows/build-and-deploy-rust.yml index 518cfe7f..43884f3c 100644 --- a/.github/workflows/build-and-deploy-rust.yml +++ b/.github/workflows/build-and-deploy-rust.yml @@ -45,6 +45,8 @@ jobs: run: | sleep 5 + [[ $(curl -f -s http://localhost:8080/vss/version | xxd -p) == "0801" ]] || { echo "Version check failed"; exit 1; } + # Put request with store='storeId' and key=k1 hex=0A0773746F726549641A150A026B3110FFFFFFFFFFFFFFFFFF011A046B317631 curl -f --data-binary "$(echo "$hex" | xxd -r -p)" http://localhost:8080/vss/putObjects diff --git a/proto/vss.proto b/proto/vss.proto index c0bacdde..89db8372 100644 --- a/proto/vss.proto +++ b/proto/vss.proto @@ -3,6 +3,23 @@ package vss; option java_multiple_files = true; option java_package = "org.vss"; +// Server response on the `/version` endpoint. +message VersionResponse { + + // The API version supported by the server. + Version version = 1; +} + +// Versions of the VSS API. +enum Version { + + // Default protobuf Enum value. Will not be used as `Version` by server. + VUNKNOWN = 0; + + // The initial version of the VSS API. + V1 = 1; +} + // Request payload to be used for `GetObject` API call to server. message GetObjectRequest { diff --git a/rust/api/src/types.rs b/rust/api/src/types.rs index 4d7b3650..ce58838c 100644 --- a/rust/api/src/types.rs +++ b/rust/api/src/types.rs @@ -1,3 +1,11 @@ +/// Server response on the `/version` endpoint. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VersionResponse { + /// The API version supported by the server. + #[prost(enumeration = "Version", tag = "1")] + pub version: i32, +} /// Request payload to be used for `GetObject` API call to server. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -331,6 +339,35 @@ pub struct PlaintextBlob { #[prost(int64, tag = "2")] pub version: i64, } +/// Versions of the VSS API. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Version { + /// Default protobuf Enum value. Will not be used as `Version` by server. + Vunknown = 0, + /// The initial version of the VSS API. + V1 = 1, +} +impl Version { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Version::Vunknown => "VUNKNOWN", + Version::V1 => "V1", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "VUNKNOWN" => Some(Self::Vunknown), + "V1" => Some(Self::V1), + _ => None, + } + } +} /// ErrorCodes to be used in `ErrorResponse` #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] diff --git a/rust/server/src/vss_service.rs b/rust/server/src/vss_service.rs index 55e52c2c..25acedb0 100644 --- a/rust/server/src/vss_service.rs +++ b/rust/server/src/vss_service.rs @@ -12,7 +12,7 @@ use api::kv_store::KvStore; use api::types::{ DeleteObjectRequest, DeleteObjectResponse, ErrorCode, ErrorResponse, GetObjectRequest, GetObjectResponse, ListKeyVersionsRequest, ListKeyVersionsResponse, PutObjectRequest, - PutObjectResponse, + PutObjectResponse, Version, VersionResponse, }; use std::future::Future; use std::pin::Pin; @@ -80,6 +80,14 @@ impl Service> for VssService { let prefix_stripped_path = path.strip_prefix(BASE_PATH_PREFIX).unwrap_or_default(); match prefix_stripped_path { + "/version" => { + let response = VersionResponse { version: Version::V1.into() }; + let response = Response::builder() + .body(Full::new(Bytes::from(response.encode_to_vec()))) + // unwrap safety: body only errors when previous chained calls failed. + .unwrap(); + Ok(response) + }, "/getObject" => { handle_request( store,