From b5b68a76e256555ef362dceaa834d8bbcdcfff06 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Tue, 18 Jan 2022 13:38:59 -0800 Subject: [PATCH] feat(core-api): add weaver protobuf codegen #1556 Rust code now gets generated from the Weaver protocol buffer definitions Next step is to have the automated publishing set up. To test the rust build, you need to run either one of the following: `yarn lerna run proto:protoc-gen-rust` (from the project root) or a regular cargo build from the core-api package directory, e.g.: ```sh cd packages/cactus-core-api/ cargo build ``` Fixes #1556 Signed-off-by: Peter Somogyvari --- .gitignore | 1 + packages/cactus-core-api/Cargo.lock | 1250 +++++++++++++++++ packages/cactus-core-api/Cargo.toml | 30 + packages/cactus-core-api/Makefile | 6 + packages/cactus-core-api/build.rs | 20 + packages/cactus-core-api/package.json | 1 + .../rust/generated/proto-rs/common.ack.rs | 22 + .../rust/generated/proto-rs/common.query.rs | 22 + .../rust/generated/proto-rs/common.state.rs | 87 ++ .../rust/generated/proto-rs/driver.driver.rs | 176 +++ .../generated/proto-rs/networks.networks.rs | 309 ++++ .../generated/proto-rs/relay.datatransfer.rs | 295 ++++ packages/cactus-core-api/src/main/rust/pb.rs | 27 + 13 files changed, 2246 insertions(+) create mode 100644 packages/cactus-core-api/Cargo.lock create mode 100644 packages/cactus-core-api/Cargo.toml create mode 100644 packages/cactus-core-api/Makefile create mode 100644 packages/cactus-core-api/build.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/common.ack.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/common.query.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/common.state.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/driver.driver.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/networks.networks.rs create mode 100644 packages/cactus-core-api/src/main/rust/generated/proto-rs/relay.datatransfer.rs create mode 100644 packages/cactus-core-api/src/main/rust/pb.rs diff --git a/.gitignore b/.gitignore index d1f034e40e..cd7de2e07b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .config.json .nyc_output/ dist/ +target/ .DS_Store node_modules/ docs/main diff --git a/packages/cactus-core-api/Cargo.lock b/packages/cactus-core-api/Cargo.lock new file mode 100644 index 0000000000..7348328ff3 --- /dev/null +++ b/packages/cactus-core-api/Cargo.lock @@ -0,0 +1,1250 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" + +[[package]] +name = "async-stream" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "cc" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "fastrand" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" +dependencies = [ + "instant", +] + +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures-channel" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" + +[[package]] +name = "futures-sink" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" + +[[package]] +name = "futures-task" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" + +[[package]] +name = "futures-util" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite 0.2.8", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", + "tracing-futures", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "http" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" +dependencies = [ + "bytes 1.1.0", + "fnv", + "itoa 1.0.1", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.6", + "http", +] + +[[package]] +name = "httparse" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" + +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + +[[package]] +name = "hyper" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" +dependencies = [ + "bytes 0.5.6", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa 0.4.8", + "pin-project 1.0.10", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "js-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9615c18d31137579e9ff063499264ddc1278e7b1982757ebc111028c4d1dc909" +dependencies = [ + "pin-project-internal 0.4.29", +] + +[[package]] +name = "pin-project" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" +dependencies = [ + "pin-project-internal 1.0.10", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "044964427019eed9d49d9d5bbce6047ef18f37100ea400912a9fa4a3523ab12a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] +name = "pin-project-lite" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "prost" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" +dependencies = [ + "bytes 0.5.6", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" +dependencies = [ + "bytes 0.5.6", + "heck", + "itertools", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" +dependencies = [ + "bytes 0.5.6", + "prost", +] + +[[package]] +name = "quote" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "relay" +version = "0.0.1" +dependencies = [ + "prost", + "serde", + "tokio", + "tonic", + "tonic-build", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.9", +] + +[[package]] +name = "rustls" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "serde" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "tokio" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "memchr", + "mio", + "pin-project-lite 0.1.12", + "slab", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" +dependencies = [ + "futures-core", + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.12", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afef9ce97ea39593992cf3fa00ff33b1ad5eb07665b31355df63a690e38c736" +dependencies = [ + "async-stream", + "async-trait", + "base64", + "bytes 0.5.6", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "percent-encoding", + "pin-project 0.4.29", + "prost", + "prost-derive", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-balance", + "tower-load", + "tower-make", + "tower-service", + "tracing", + "tracing-futures", +] + +[[package]] +name = "tonic-build" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d8d21cb568e802d77055ab7fcd43f0992206de5028de95c8d3a41118d32e8e" +dependencies = [ + "proc-macro2", + "prost-build", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3169017c090b7a28fce80abaad0ab4f5566423677c9331bb320af7e49cfe62" +dependencies = [ + "futures-core", + "tower-buffer", + "tower-discover", + "tower-layer", + "tower-limit", + "tower-load-shed", + "tower-retry", + "tower-service", + "tower-timeout", + "tower-util", +] + +[[package]] +name = "tower-balance" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a792277613b7052448851efcf98a2c433e6f1d01460832dc60bef676bc275d4c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project 0.4.29", + "rand", + "slab", + "tokio", + "tower-discover", + "tower-layer", + "tower-load", + "tower-make", + "tower-ready-cache", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-buffer" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4887dc2a65d464c8b9b66e0e4d51c2fd6cf5b3373afc72805b0a60bce00446a" +dependencies = [ + "futures-core", + "pin-project 0.4.29", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-discover" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f6b5000c3c54d269cc695dff28136bb33d08cbf1df2c48129e143ab65bf3c2a" +dependencies = [ + "futures-core", + "pin-project 0.4.29", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" + +[[package]] +name = "tower-limit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c3040c5dbed68abffaa0d4517ac1a454cd741044f33ab0eefab6b8d1361404" +dependencies = [ + "futures-core", + "pin-project 0.4.29", + "tokio", + "tower-layer", + "tower-load", + "tower-service", +] + +[[package]] +name = "tower-load" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cc79fc3afd07492b7966d7efa7c6c50f8ed58d768a6075dd7ae6591c5d2017b" +dependencies = [ + "futures-core", + "log", + "pin-project 0.4.29", + "tokio", + "tower-discover", + "tower-service", +] + +[[package]] +name = "tower-load-shed" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f021e23900173dc315feb4b6922510dae3e79c689b74c089112066c11f0ae4e" +dependencies = [ + "futures-core", + "pin-project 0.4.29", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-make" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce50370d644a0364bf4877ffd4f76404156a248d104e2cc234cd391ea5cdc965" +dependencies = [ + "tokio", + "tower-service", +] + +[[package]] +name = "tower-ready-cache" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eabb6620e5481267e2ec832c780b31cad0c15dcb14ed825df5076b26b591e1f" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "log", + "tokio", + "tower-service", +] + +[[package]] +name = "tower-retry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6727956aaa2f8957d4d9232b308fe8e4e65d99db30f42b225646e86c9b6a952" +dependencies = [ + "futures-core", + "pin-project 0.4.29", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tower-timeout" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "127b8924b357be938823eaaec0608c482d40add25609481027b96198b2e4b31e" +dependencies = [ + "pin-project 0.4.29", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1093c19826d33807c72511e68f73b4a0469a3f22c2bd5f7d5212178b4b89674" +dependencies = [ + "futures-core", + "futures-util", + "pin-project 0.4.29", + "tower-service", +] + +[[package]] +name = "tracing" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite 0.2.8", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project 1.0.10", + "tracing", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasm-bindgen" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" + +[[package]] +name = "web-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/packages/cactus-core-api/Cargo.toml b/packages/cactus-core-api/Cargo.toml new file mode 100644 index 0000000000..a56dee2cf5 --- /dev/null +++ b/packages/cactus-core-api/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "relay" +version = "0.0.1" +authors = ["Antony Targett ", "Nick Waywood "] +edition = "2018" + +[lib] +name = "pb" +path = "src/main/rust/pb.rs" + + +[dependencies] +tonic = {version="0.2", features = ["tls"]} +prost = "0.6" +tokio = { version = "0.2", features = ["macros", "fs"] } +serde = {version="1.0.110", features = ["derive"]} + +# These upgraded versions compile fine as well, so we should upgrade them +# in the future: +# tonic = {version="0.6.2", features = ["tls"]} +# prost = "0.9" +# tokio = { version = "1.15.0", features = ["macros", "fs"] } +# serde = {version="1.0.110", features = ["derive"]} + +[build-dependencies] +tonic-build = "0.2" + + + + diff --git a/packages/cactus-core-api/Makefile b/packages/cactus-core-api/Makefile new file mode 100644 index 0000000000..d02388019e --- /dev/null +++ b/packages/cactus-core-api/Makefile @@ -0,0 +1,6 @@ +.PHONY: all +all: protos + +# Compiles the Rust bindings for the protocol buffer definitions. +protos: + cargo build diff --git a/packages/cactus-core-api/build.rs b/packages/cactus-core-api/build.rs new file mode 100644 index 0000000000..f69b7201c3 --- /dev/null +++ b/packages/cactus-core-api/build.rs @@ -0,0 +1,20 @@ +use std::env; + +fn main() -> Result<(), Box> { + env::set_var("OUT_DIR", "./src/main/rust/generated/proto-rs/"); + // tonic_build::compile_protos("protos/relay/datatransfer.proto").unwrap(); + // tonic_build::compile_protos("protos/networks/networks.proto").unwrap(); + tonic_build::configure() + .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") + .compile( + &[ + "./src/main/proto/weaver/common/protos/relay/datatransfer.proto", + "./src/main/proto/weaver/common/protos/networks/networks.proto", + "./src/main/proto/weaver/common/protos/driver/driver.proto", + ], + &[ + "./src/main/proto/weaver/common/protos/", + ], + )?; + Ok(()) +} diff --git a/packages/cactus-core-api/package.json b/packages/cactus-core-api/package.json index c62162c276..5447538e9e 100644 --- a/packages/cactus-core-api/package.json +++ b/packages/cactus-core-api/package.json @@ -16,6 +16,7 @@ "codegen:openapi": "npm run generate-sdk", "preproto:protoc-gen-ts": "make-dir ./src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/", "proto:protoc-gen-ts": "yarn run grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/.bin/protoc-gen-ts --ts_out=grpc_js:./src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/ --proto_path ./src/main/proto/weaver/common/protos/ ./src/main/proto/weaver/common/protos/common/*.proto ./src/main/proto/weaver/common/protos/corda/*.proto ./src/main/proto/weaver/common/protos/driver/*.proto ./src/main/proto/weaver/common/protos/networks/*.proto ./src/main/proto/weaver/common/protos/relay/*.proto", + "proto:protoc-gen-rust": "cargo build", "codegen:proto": "run-s proto:protoc-gen-ts", "codegen": "run-p 'codegen:*'", "watch": "npm-watch", diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.ack.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.ack.rs new file mode 100644 index 0000000000..99d8cf7b0b --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.ack.rs @@ -0,0 +1,22 @@ +/// This message respresents "ACKs" sent between relay-relay, +/// relay-driver and relay-network +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct Ack { + #[prost(enumeration = "ack::Status", tag = "2")] + pub status: i32, + #[prost(string, tag = "3")] + pub request_id: std::string::String, + /// an error can have an associated string + /// this is the best way to represent this in protobuf + #[prost(string, tag = "4")] + pub message: std::string::String, +} +pub mod ack { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + #[derive(serde::Serialize, serde::Deserialize)] + pub enum Status { + Ok = 0, + Error = 1, + } +} diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.query.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.query.rs new file mode 100644 index 0000000000..b1769f94d8 --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.query.rs @@ -0,0 +1,22 @@ +/// the payload to define the data that is being requested +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct Query { + #[prost(string, repeated, tag = "1")] + pub policy: ::std::vec::Vec, + #[prost(string, tag = "2")] + pub address: std::string::String, + #[prost(string, tag = "3")] + pub requesting_relay: std::string::String, + #[prost(string, tag = "4")] + pub requesting_network: std::string::String, + #[prost(string, tag = "5")] + pub certificate: std::string::String, + #[prost(string, tag = "6")] + pub requestor_signature: std::string::String, + #[prost(string, tag = "7")] + pub nonce: std::string::String, + #[prost(string, tag = "8")] + pub request_id: std::string::String, + #[prost(string, tag = "9")] + pub requesting_org: std::string::String, +} diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.state.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.state.rs new file mode 100644 index 0000000000..c0eea25802 --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/common.state.rs @@ -0,0 +1,87 @@ +/// Metadata for a View +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct Meta { + /// Underlying distributed ledger protocol. + #[prost(enumeration = "meta::Protocol", tag = "1")] + pub protocol: i32, + /// What notion of time? + /// If the observer and network are synchronizing on a global clock + /// there won't be a need to distinguish between static and dynamic views. + #[prost(string, tag = "2")] + pub timestamp: std::string::String, + /// Notorization, SPV, ZKP, etc. Possibly enum + #[prost(string, tag = "3")] + pub proof_type: std::string::String, + /// The data field's serialization format (e.g. JSON, XML, Protobuf) + #[prost(string, tag = "4")] + pub serialization_format: std::string::String, +} +pub mod meta { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + #[derive(serde::Serialize, serde::Deserialize)] + pub enum Protocol { + Bitcoin = 0, + Ethereum = 1, + Fabric = 3, + Corda = 4, + } +} +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct View { + #[prost(message, optional, tag = "1")] + pub meta: ::std::option::Option, + /// Represents the data playload of this view. + /// The representation of Fabric, Corda etc will be captured elsewhere. + /// For some protocols, like Bitcoin, the structure of an SPV proof is well known. + #[prost(bytes, tag = "2")] + pub data: std::vec::Vec, +} +/// View represents the response from a remote network +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct ViewPayload { + #[prost(string, tag = "1")] + pub request_id: std::string::String, + #[prost(oneof = "view_payload::State", tags = "2, 3")] + pub state: ::std::option::Option, +} +pub mod view_payload { + #[derive(Clone, PartialEq, ::prost::Oneof, serde::Serialize, serde::Deserialize)] + pub enum State { + #[prost(message, tag = "2")] + View(super::View), + #[prost(string, tag = "3")] + Error(std::string::String), + } +} +/// the payload that is used for the communication between the requesting relay +/// and its network +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct RequestState { + #[prost(string, tag = "1")] + pub request_id: std::string::String, + #[prost(enumeration = "request_state::Status", tag = "2")] + pub status: i32, + #[prost(oneof = "request_state::State", tags = "3, 4")] + pub state: ::std::option::Option, +} +pub mod request_state { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + #[derive(serde::Serialize, serde::Deserialize)] + pub enum Status { + /// pending ACK from remote relay + PendingAck = 0, + /// Received ACK, waiting for data to be sent from remote relay + Pending = 1, + Error = 2, + Completed = 3, + } + #[derive(Clone, PartialEq, ::prost::Oneof, serde::Serialize, serde::Deserialize)] + pub enum State { + #[prost(message, tag = "3")] + View(super::View), + #[prost(string, tag = "4")] + Error(std::string::String), + } +} diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/driver.driver.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/driver.driver.rs new file mode 100644 index 0000000000..7272f2e086 --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/driver.driver.rs @@ -0,0 +1,176 @@ +#[doc = r" Generated client implementations."] +pub mod driver_communication_client { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + pub struct DriverCommunicationClient { + inner: tonic::client::Grpc, + } + impl DriverCommunicationClient { + #[doc = r" Attempt to create a new client by connecting to a given endpoint."] + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl DriverCommunicationClient + where + T: tonic::client::GrpcService, + T::ResponseBody: Body + HttpBody + Send + 'static, + T::Error: Into, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); + Self { inner } + } + #[doc = " the remote relay sends a RequestDriverState request to its driver with a"] + #[doc = " query defining the data it wants to receive"] + pub async fn request_driver_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/driver.driver.DriverCommunication/RequestDriverState", + ); + self.inner.unary(request.into_request(), path, codec).await + } + } + impl Clone for DriverCommunicationClient { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } + } + impl std::fmt::Debug for DriverCommunicationClient { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "DriverCommunicationClient {{ ... }}") + } + } +} +#[doc = r" Generated server implementations."] +pub mod driver_communication_server { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = "Generated trait containing gRPC methods that should be implemented for use with DriverCommunicationServer."] + #[async_trait] + pub trait DriverCommunication: Send + Sync + 'static { + #[doc = " the remote relay sends a RequestDriverState request to its driver with a"] + #[doc = " query defining the data it wants to receive"] + async fn request_driver_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + } + #[derive(Debug)] + #[doc(hidden)] + pub struct DriverCommunicationServer { + inner: _Inner, + } + struct _Inner(Arc, Option); + impl DriverCommunicationServer { + pub fn new(inner: T) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, None); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, Some(interceptor.into())); + Self { inner } + } + } + impl Service> for DriverCommunicationServer + where + T: DriverCommunication, + B: HttpBody + Send + Sync + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = Never; + type Future = BoxFuture; + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/driver.driver.DriverCommunication/RequestDriverState" => { + #[allow(non_camel_case_types)] + struct RequestDriverStateSvc(pub Arc); + impl + tonic::server::UnaryService + for RequestDriverStateSvc + { + type Response = super::super::super::common::ack::Ack; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.request_driver_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = RequestDriverStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .body(tonic::body::BoxBody::empty()) + .unwrap()) + }), + } + } + } + impl Clone for DriverCommunicationServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { inner } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(self.0.clone(), self.1.clone()) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::transport::NamedService for DriverCommunicationServer { + const NAME: &'static str = "driver.driver.DriverCommunication"; + } +} diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/networks.networks.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/networks.networks.rs new file mode 100644 index 0000000000..78eeb5a51a --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/networks.networks.rs @@ -0,0 +1,309 @@ +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct DbName { + #[prost(string, tag = "1")] + pub name: std::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct RelayDatabase { + #[prost(map = "string, string", tag = "1")] + pub pairs: ::std::collections::HashMap, +} +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct GetStateMessage { + #[prost(string, tag = "1")] + pub request_id: std::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message, serde::Serialize, serde::Deserialize)] +pub struct NetworkQuery { + #[prost(string, repeated, tag = "1")] + pub policy: ::std::vec::Vec, + #[prost(string, tag = "2")] + pub address: std::string::String, + #[prost(string, tag = "3")] + pub requesting_relay: std::string::String, + #[prost(string, tag = "4")] + pub requesting_network: std::string::String, + #[prost(string, tag = "5")] + pub certificate: std::string::String, + #[prost(string, tag = "6")] + pub requestor_signature: std::string::String, + #[prost(string, tag = "7")] + pub nonce: std::string::String, + #[prost(string, tag = "8")] + pub requesting_org: std::string::String, +} +#[doc = r" Generated client implementations."] +pub mod network_client { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = " This service is the interface for how the network communicates with"] + #[doc = " its relay."] + pub struct NetworkClient { + inner: tonic::client::Grpc, + } + impl NetworkClient { + #[doc = r" Attempt to create a new client by connecting to a given endpoint."] + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl NetworkClient + where + T: tonic::client::GrpcService, + T::ResponseBody: Body + HttpBody + Send + 'static, + T::Error: Into, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); + Self { inner } + } + #[doc = " endpoint for a network to request remote relay state via local relay"] + pub async fn request_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/networks.networks.Network/RequestState"); + self.inner.unary(request.into_request(), path, codec).await + } + #[doc = " This rpc endpooint is for polling the local relay for request state."] + pub async fn get_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/networks.networks.Network/GetState"); + self.inner.unary(request.into_request(), path, codec).await + } + #[doc = " NOTE: This rpc is just for debugging."] + pub async fn request_database( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/networks.networks.Network/RequestDatabase"); + self.inner.unary(request.into_request(), path, codec).await + } + } + impl Clone for NetworkClient { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } + } + impl std::fmt::Debug for NetworkClient { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "NetworkClient {{ ... }}") + } + } +} +#[doc = r" Generated server implementations."] +pub mod network_server { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = "Generated trait containing gRPC methods that should be implemented for use with NetworkServer."] + #[async_trait] + pub trait Network: Send + Sync + 'static { + #[doc = " endpoint for a network to request remote relay state via local relay"] + async fn request_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + #[doc = " This rpc endpooint is for polling the local relay for request state."] + async fn get_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + #[doc = " NOTE: This rpc is just for debugging."] + async fn request_database( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + } + #[doc = " This service is the interface for how the network communicates with"] + #[doc = " its relay."] + #[derive(Debug)] + #[doc(hidden)] + pub struct NetworkServer { + inner: _Inner, + } + struct _Inner(Arc, Option); + impl NetworkServer { + pub fn new(inner: T) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, None); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, Some(interceptor.into())); + Self { inner } + } + } + impl Service> for NetworkServer + where + T: Network, + B: HttpBody + Send + Sync + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = Never; + type Future = BoxFuture; + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/networks.networks.Network/RequestState" => { + #[allow(non_camel_case_types)] + struct RequestStateSvc(pub Arc); + impl tonic::server::UnaryService for RequestStateSvc { + type Response = super::super::super::common::ack::Ack; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.request_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = RequestStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/networks.networks.Network/GetState" => { + #[allow(non_camel_case_types)] + struct GetStateSvc(pub Arc); + impl tonic::server::UnaryService for GetStateSvc { + type Response = super::super::super::common::state::RequestState; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.get_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = GetStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/networks.networks.Network/RequestDatabase" => { + #[allow(non_camel_case_types)] + struct RequestDatabaseSvc(pub Arc); + impl tonic::server::UnaryService for RequestDatabaseSvc { + type Response = super::RelayDatabase; + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.request_database(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = RequestDatabaseSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .body(tonic::body::BoxBody::empty()) + .unwrap()) + }), + } + } + } + impl Clone for NetworkServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { inner } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(self.0.clone(), self.1.clone()) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::transport::NamedService for NetworkServer { + const NAME: &'static str = "networks.networks.Network"; + } +} diff --git a/packages/cactus-core-api/src/main/rust/generated/proto-rs/relay.datatransfer.rs b/packages/cactus-core-api/src/main/rust/generated/proto-rs/relay.datatransfer.rs new file mode 100644 index 0000000000..59bf3fb897 --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/generated/proto-rs/relay.datatransfer.rs @@ -0,0 +1,295 @@ +#[doc = r" Generated client implementations."] +pub mod data_transfer_client { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = " definitions of all messages used in the datatransfer protocol"] + pub struct DataTransferClient { + inner: tonic::client::Grpc, + } + impl DataTransferClient { + #[doc = r" Attempt to create a new client by connecting to a given endpoint."] + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl DataTransferClient + where + T: tonic::client::GrpcService, + T::ResponseBody: Body + HttpBody + Send + 'static, + T::Error: Into, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); + Self { inner } + } + #[doc = " the requesting relay sends a RequestState request to the remote relay with a"] + #[doc = " query defining the data it wants to receive"] + pub async fn request_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/relay.datatransfer.DataTransfer/RequestState", + ); + self.inner.unary(request.into_request(), path, codec).await + } + #[doc = " the remote relay asynchronously sends back the requested data with"] + #[doc = " SendState"] + pub async fn send_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/relay.datatransfer.DataTransfer/SendState"); + self.inner.unary(request.into_request(), path, codec).await + } + #[doc = " Handling state sent from the driver."] + pub async fn send_driver_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/relay.datatransfer.DataTransfer/SendDriverState", + ); + self.inner.unary(request.into_request(), path, codec).await + } + } + impl Clone for DataTransferClient { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } + } + impl std::fmt::Debug for DataTransferClient { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "DataTransferClient {{ ... }}") + } + } +} +#[doc = r" Generated server implementations."] +pub mod data_transfer_server { + #![allow(unused_variables, dead_code, missing_docs)] + use tonic::codegen::*; + #[doc = "Generated trait containing gRPC methods that should be implemented for use with DataTransferServer."] + #[async_trait] + pub trait DataTransfer: Send + Sync + 'static { + #[doc = " the requesting relay sends a RequestState request to the remote relay with a"] + #[doc = " query defining the data it wants to receive"] + async fn request_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + #[doc = " the remote relay asynchronously sends back the requested data with"] + #[doc = " SendState"] + async fn send_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + #[doc = " Handling state sent from the driver."] + async fn send_driver_state( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + } + #[doc = " definitions of all messages used in the datatransfer protocol"] + #[derive(Debug)] + #[doc(hidden)] + pub struct DataTransferServer { + inner: _Inner, + } + struct _Inner(Arc, Option); + impl DataTransferServer { + pub fn new(inner: T) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, None); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { + let inner = Arc::new(inner); + let inner = _Inner(inner, Some(interceptor.into())); + Self { inner } + } + } + impl Service> for DataTransferServer + where + T: DataTransfer, + B: HttpBody + Send + Sync + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = Never; + type Future = BoxFuture; + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/relay.datatransfer.DataTransfer/RequestState" => { + #[allow(non_camel_case_types)] + struct RequestStateSvc(pub Arc); + impl + tonic::server::UnaryService + for RequestStateSvc + { + type Response = super::super::super::common::ack::Ack; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.request_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = RequestStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/relay.datatransfer.DataTransfer/SendState" => { + #[allow(non_camel_case_types)] + struct SendStateSvc(pub Arc); + impl + tonic::server::UnaryService + for SendStateSvc + { + type Response = super::super::super::common::ack::Ack; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request< + super::super::super::common::state::ViewPayload, + >, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.send_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = SendStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/relay.datatransfer.DataTransfer/SendDriverState" => { + #[allow(non_camel_case_types)] + struct SendDriverStateSvc(pub Arc); + impl + tonic::server::UnaryService + for SendDriverStateSvc + { + type Response = super::super::super::common::ack::Ack; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request< + super::super::super::common::state::ViewPayload, + >, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { inner.send_driver_state(request).await }; + Box::pin(fut) + } + } + let inner = self.inner.clone(); + let fut = async move { + let interceptor = inner.1.clone(); + let inner = inner.0; + let method = SendDriverStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = if let Some(interceptor) = interceptor { + tonic::server::Grpc::with_interceptor(codec, interceptor) + } else { + tonic::server::Grpc::new(codec) + }; + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .body(tonic::body::BoxBody::empty()) + .unwrap()) + }), + } + } + } + impl Clone for DataTransferServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { inner } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(self.0.clone(), self.1.clone()) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::transport::NamedService for DataTransferServer { + const NAME: &'static str = "relay.datatransfer.DataTransfer"; + } +} diff --git a/packages/cactus-core-api/src/main/rust/pb.rs b/packages/cactus-core-api/src/main/rust/pb.rs new file mode 100644 index 0000000000..bd9f4cb8e1 --- /dev/null +++ b/packages/cactus-core-api/src/main/rust/pb.rs @@ -0,0 +1,27 @@ +pub mod relay { + pub mod datatransfer { + include!(concat!("./generated/proto-rs", "/relay.datatransfer.rs")); + } +} +pub mod networks { + pub mod networks { + include!(concat!("./generated/proto-rs", "/networks.networks.rs")); + } +} +pub mod driver { + pub mod driver { + include!(concat!("./generated/proto-rs", "/driver.driver.rs")); + } +} + +pub mod common { + pub mod ack { + include!(concat!("./generated/proto-rs", "/common.ack.rs")); + } + pub mod state { + include!(concat!("./generated/proto-rs", "/common.state.rs")); + } + pub mod query { + include!(concat!("./generated/proto-rs", "/common.query.rs")); + } +}