diff --git a/.github/workflows/build_docker.yaml b/.github/workflows/build_docker.yaml index a1c2093a..26e67fb4 100644 --- a/.github/workflows/build_docker.yaml +++ b/.github/workflows/build_docker.yaml @@ -51,8 +51,6 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v6 - with: - submodules: "recursive" - name: Determine Rust version id: rust-version diff --git a/.github/workflows/check_lint_build_release.yaml b/.github/workflows/check_lint_build_release.yaml index 3e8feae6..62ec0ca3 100644 --- a/.github/workflows/check_lint_build_release.yaml +++ b/.github/workflows/check_lint_build_release.yaml @@ -44,13 +44,29 @@ jobs: # import formatting is nightly only run: cargo +nightly fmt --all -- --check + check-buf-generate: + name: Check buf generate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - uses: bufbuild/buf-action@v1 + with: + setup_only: true + + - name: Verify generated files are up to date + # If this fails: someone hand-edited `lib/proto/generated/`, + # or the proto/plugin pins changed without regenerating. Run + # `buf generate --clean` locally and commit the result. + run: | + buf generate --clean + git diff --exit-code -- lib/proto/generated/ + check-clippy-nightly: name: Check Clippy (nightly) runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - with: - submodules: "recursive" - uses: dtolnay/rust-toolchain@master with: @@ -71,8 +87,6 @@ jobs: steps: - uses: actions/checkout@v6 - with: - submodules: "recursive" # Must happen /after/ the checkout step, to pick up the toolchain # from the `rust-toolchain.toml` file. @@ -234,8 +248,6 @@ jobs: cargo build --locked --release - uses: actions/checkout@v6 - with: - submodules: "recursive" # `rustup` is already installed on GitHub Actions runners, so # this reads the content from our `rust-toolchain.toml` file. @@ -306,8 +318,6 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v6 - with: - submodules: "recursive" # Must happen /after/ the checkout step, to pick up the toolchain - run: rustup target add ${{ matrix.name }} diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 758d2b20..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "cusf_sidechain_proto"] - path = cusf_sidechain_proto - url = https://github.com/LayerTwo-Labs/cusf_sidechain_proto diff --git a/Cargo.lock b/Cargo.lock index 053a0d1a..7a614a1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,7 +124,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -135,7 +135,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -180,6 +180,18 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-compression" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79b3f8a79cccc2898f31920fc69f304859b3bd567490f75ebf51ae1c792a9ac" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-io" version = "2.6.0" @@ -275,10 +287,13 @@ checksum = "8b52af3cb4058c895d37317bb27508dccc8e5f2d39454016b297bf4a400597b8" dependencies = [ "axum-core", "bytes", + "form_urlencoded", "futures-util", "http", "http-body", "http-body-util", + "hyper", + "hyper-util", "itoa", "matchit", "memchr", @@ -286,10 +301,15 @@ dependencies = [ "percent-encoding", "pin-project-lite", "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", "sync_wrapper", + "tokio", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -308,6 +328,7 @@ dependencies = [ "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -429,12 +450,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" - [[package]] name = "bincode" version = "1.3.3" @@ -448,11 +463,15 @@ dependencies = [ name = "bip300301_enforcer" version = "0.3.4" dependencies = [ + "axum", "bdk_wallet", "bip300301_enforcer_lib", "bitcoin", "bitcoin-jsonrpsee", + "buffa", "clap", + "connectrpc", + "connectrpc-health", "cusf-enforcer-mempool", "educe", "either", @@ -464,15 +483,13 @@ dependencies = [ "thiserror 2.0.18", "tokio", "tokio-util", - "tonic", - "tonic-health", - "tonic-reflection", "tower", "tower-http", "tracing", "tracing-appender", "tracing-log", "tracing-subscriber", + "url", "uuid", ] @@ -485,13 +502,17 @@ dependencies = [ "bip300301_enforcer_lib", "bitcoin", "bitcoin-jsonrpsee", + "buffa", + "buffa-types", "cfg-if", "clap", + "connectrpc", "cusf-enforcer-mempool", "dotenvy", "either", "futures", "hex", + "http", "indicatif", "jsonrpsee", "libtest-mimic", @@ -504,7 +525,6 @@ dependencies = [ "thiserror 2.0.18", "tokio", "tokio-stream", - "tonic", "tracing", "tracing-indicatif", "tracing-subscriber", @@ -525,8 +545,11 @@ dependencies = [ "bitcoin", "bitcoin-jsonrpsee", "bitcoin-send-tx-p2p", + "buffa", + "buffa-types", "byteorder", "clap", + "connectrpc", "cusf-enforcer-mempool", "derive_more", "either", @@ -537,6 +560,7 @@ dependencies = [ "heed", "heed-types", "hex", + "http-body", "jiff", "jsonrpsee", "miette", @@ -545,10 +569,6 @@ dependencies = [ "ordermap", "ouroboros", "parking_lot", - "prost", - "prost-build", - "prost-types", - "protox", "rand 0.10.1", "reqwest 0.13.3", "rusqlite", @@ -563,9 +583,6 @@ dependencies = [ "tokio-rusqlite", "tokio-stream", "tokio-util", - "tonic", - "tonic-prost", - "tonic-prost-build", "tracing", "tracing-appender", "tracing-subscriber", @@ -705,6 +722,34 @@ dependencies = [ "generic-array", ] +[[package]] +name = "buffa" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941c714734a660caa93a210c531dec553cc0ef417890409914d24032c94ab840" +dependencies = [ + "base64 0.22.1", + "bytes", + "hashbrown 0.15.5", + "once_cell", + "serde", + "serde_json", + "thiserror 2.0.18", +] + +[[package]] +name = "buffa-types" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc84fac1e7efc335e74934a4ebe0534a30411ec2ea6a5a17ed294201c6b3b23c" +dependencies = [ + "buffa", + "bytes", + "serde", + "serde_json", + "thiserror 2.0.18", +] + [[package]] name = "bumpalo" version = "3.19.1" @@ -728,6 +773,9 @@ name = "bytes" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +dependencies = [ + "serde", +] [[package]] name = "cc" @@ -859,6 +907,25 @@ dependencies = [ "memchr", ] +[[package]] +name = "compression-codecs" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" +dependencies = [ + "compression-core", + "flate2", + "memchr", + "zstd", + "zstd-safe", +] + +[[package]] +name = "compression-core" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -868,6 +935,54 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "connectrpc" +version = "0.6.0" +source = "git+https://github.com/torkelrogstad/connect-rust.git?rev=dfde93dd1b48d6aa5accd68fbe3231a85f330ef6#dfde93dd1b48d6aa5accd68fbe3231a85f330ef6" +dependencies = [ + "async-compression", + "async-trait", + "axum", + "base64 0.22.1", + "buffa", + "bytes", + "flate2", + "futures", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "libc", + "percent-encoding", + "pin-project", + "serde", + "serde_json", + "thiserror 2.0.18", + "tokio", + "tokio-util", + "tower", + "tower-http", + "tracing", + "wasm-bindgen-futures", + "zstd", +] + +[[package]] +name = "connectrpc-health" +version = "0.6.0" +source = "git+https://github.com/torkelrogstad/connect-rust.git?rev=dfde93dd1b48d6aa5accd68fbe3231a85f330ef6#dfde93dd1b48d6aa5accd68fbe3231a85f330ef6" +dependencies = [ + "buffa", + "connectrpc", + "futures", + "http-body", + "serde", + "serde_json", + "tokio", + "tokio-stream", +] + [[package]] name = "console" version = "0.16.2" @@ -933,6 +1048,15 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -1201,7 +1325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1335,12 +1459,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - [[package]] name = "file-guard" version = "0.2.0" @@ -1358,10 +1476,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" [[package]] -name = "fixedbitset" -version = "0.5.7" +name = "flate2" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] [[package]] name = "fnv" @@ -1687,6 +1810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "foldhash 0.1.5", + "serde", ] [[package]] @@ -1889,19 +2013,6 @@ dependencies = [ "webpki-roots 1.0.5", ] -[[package]] -name = "hyper-timeout" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" -dependencies = [ - "hyper", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.19" @@ -2157,15 +2268,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.17" @@ -2512,40 +2614,6 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" -[[package]] -name = "logos" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154" -dependencies = [ - "logos-derive", -] - -[[package]] -name = "logos-codegen" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c" -dependencies = [ - "beef", - "fnv", - "lazy_static", - "proc-macro2", - "quote", - "regex-syntax", - "rustc_version", - "syn 2.0.117", -] - -[[package]] -name = "logos-derive" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470" -dependencies = [ - "logos-codegen", -] - [[package]] name = "lru-slab" version = "0.1.2" @@ -2643,6 +2711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -2678,12 +2747,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - [[package]] name = "never-say-never" version = "6.6.666" @@ -2732,7 +2795,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2848,7 +2911,7 @@ version = "0.18.0" source = "git+https://github.com/erikjohnston/ouroboros.git?rev=ea82b33947f60c511dac6eb3815b6af3f6c3f555#ea82b33947f60c511dac6eb3815b6af3f6c3f555" dependencies = [ "heck 0.4.1", - "itertools 0.11.0", + "itertools", "proc-macro-error", "proc-macro2", "quote", @@ -2923,17 +2986,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", -] - [[package]] name = "phf" version = "0.11.3" @@ -3137,118 +3189,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" -dependencies = [ - "heck 0.4.1", - "itertools 0.14.0", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "pulldown-cmark", - "pulldown-cmark-to-cmark", - "regex", - "syn 2.0.117", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" -dependencies = [ - "anyhow", - "itertools 0.14.0", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "prost-reflect" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89455ef41ed200cafc47c76c552ee7792370ac420497e551f16123a9135f76e" -dependencies = [ - "logos", - "miette", - "prost", - "prost-types", -] - -[[package]] -name = "prost-types" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" -dependencies = [ - "prost", -] - -[[package]] -name = "protox" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f25a07a73c6717f0b9bbbd685918f5df9815f7efba450b83d9c9dea41f0e3a1" -dependencies = [ - "bytes", - "miette", - "prost", - "prost-reflect", - "prost-types", - "protox-parse", - "thiserror 2.0.18", -] - -[[package]] -name = "protox-parse" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "072eee358134396a4643dff81cfff1c255c9fbd3fb296be14bdb6a26f9156366" -dependencies = [ - "logos", - "miette", - "prost-types", - "thiserror 2.0.18", -] - -[[package]] -name = "pulldown-cmark" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0" -dependencies = [ - "bitflags", - "memchr", - "unicase", -] - -[[package]] -name = "pulldown-cmark-to-cmark" -version = "22.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50793def1b900256624a709439404384204a5dc3a6ec580281bfaac35e882e90" -dependencies = [ - "pulldown-cmark", -] - [[package]] name = "quinn" version = "0.11.9" @@ -3601,7 +3541,7 @@ dependencies = [ "errno 0.3.14", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3865,6 +3805,17 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3936,10 +3887,16 @@ version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ - "errno 0.2.8", + "errno 0.3.14", "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + [[package]] name = "siphasher" version = "1.0.1" @@ -3988,7 +3945,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4150,19 +4107,6 @@ name = "temp-dir" version = "0.2.0" source = "git+https://gitlab.com/A-Manning/leonhard-llc-ops.git?branch=temp-dir-leak#1894242ca67ccfb922ebacfefa8b521f486bd640" -[[package]] -name = "tempfile" -version = "3.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" -dependencies = [ - "fastrand", - "getrandom 0.3.4", - "once_cell", - "rustix", - "windows-sys 0.52.0", -] - [[package]] name = "terminal_size" version = "0.4.3" @@ -4393,101 +4337,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tonic" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef" -dependencies = [ - "async-trait", - "axum", - "base64 0.22.1", - "bytes", - "h2", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-timeout", - "hyper-util", - "percent-encoding", - "pin-project", - "socket2", - "sync_wrapper", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic-build" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f61875ac5293cf72e6c8cf0158086428c82c37229e98c840878f1706b0322" -dependencies = [ - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "tonic-health" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcfab99db777fba2802f0dfa861d1628d1ae916fb199d29819941f139ae85082" -dependencies = [ - "prost", - "tokio", - "tokio-stream", - "tonic", - "tonic-prost", -] - -[[package]] -name = "tonic-prost" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0" -dependencies = [ - "bytes", - "prost", - "tonic", -] - -[[package]] -name = "tonic-prost-build" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "654e5643eff75d7f8c99197ce1440ed19a3474eada74c12bbac488b2cafdae27" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build", - "prost-types", - "quote", - "syn 2.0.117", - "tempfile", - "tonic-build", -] - -[[package]] -name = "tonic-reflection" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acccd136a4bf19810a1fde9c74edc6129b42a66b44d0c1c8aaa67aeb49a146a7" -dependencies = [ - "prost", - "prost-types", - "tokio", - "tokio-stream", - "tonic", - "tonic-prost", -] - [[package]] name = "tower" version = "0.5.3" @@ -4496,9 +4345,7 @@ checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", - "indexmap", "pin-project-lite", - "slab", "sync_wrapper", "tokio", "tokio-util", @@ -4518,6 +4365,7 @@ dependencies = [ "futures-util", "http", "http-body", + "http-body-util", "pin-project-lite", "tower", "tower-layer", @@ -4545,6 +4393,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4684,12 +4533,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "unicase" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" - [[package]] name = "unicode-ident" version = "1.0.22" @@ -5062,7 +4905,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5598,8 +5441,42 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "zlib-rs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513" + [[package]] name = "zmij" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e0d8dffbae3d840f64bda38e28391faef673a7b5a6017840f2a106c8145868" + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index b72031e1..f7bb4c8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,15 +20,20 @@ anyhow = "1.0.102" argon2 = "0.5.3" async-broadcast = "0.7.1" async-lock = "3.4.0" +axum = { version = "0.8", features = ["http2"] } bdk_chain = "0.23.3" bdk_electrum = { version = "0.24.0", default-features = false } bdk_wallet = "3.0.0" bdk_esplora = { version = "0.22.2", default-features = false } bitcoin = "0.32.9" bitcoin-send-tx-p2p = "0.3.0" +buffa = { version = "0.6", features = ["json"] } +buffa-types = { version = "0.6", features = ["json"] } byteorder = "1.5.0" cfg-if = "1.0.0" clap = { version = "4.5.60", default-features = false } +connectrpc = { version = "0.6", features = ["axum", "client", "server"] } +connectrpc-health = { git = "https://github.com/torkelrogstad/connect-rust.git", rev = "dfde93dd1b48d6aa5accd68fbe3231a85f330ef6" } derive_more = "2.0.1" dotenvy = "0.15.7" either = "1.13.0" @@ -40,6 +45,7 @@ heed = "0.22.0" heed-types = "0.21.0" hex = "0.4.3" http = "1.2.0" +http-body = "1.0" indicatif = "0.18.4" jiff = { version = "0.2.24", default-features = false } jsonrpsee = "0.26.0" @@ -49,10 +55,6 @@ nom = "8.0.0" nonempty = "0.12.0" ordermap = "1.2.0" parking_lot = "0.12.3" -prost = "0.14.3" -prost-build = "0.14.3" -prost-types = "0.14.3" -protox = "0.9.0" rand = "0.10.1" reqwest = { version = "0.13.3", default-features = false, features = ["json"] } reserve-port = "2.4.0" @@ -71,11 +73,6 @@ tokio = { version = "1.52.3", default-features = false } tokio-rusqlite = "0.5.1" tokio-stream = "0.1.15" tokio-util = "0.7.18" -tonic = "0.14.6" -tonic-health = "0.14.6" -tonic-prost = "0.14.5" -tonic-prost-build = "0.14.6" -tonic-reflection = "0.14.6" # needs to line up with jsonrpsee tower version... tower = "0.5.3" tower-http = "0.6.11" @@ -130,7 +127,14 @@ branch = "2026-02-28-flush-tcpstream" git = "https://gitlab.com/A-Manning/leonhard-llc-ops.git" branch = "temp-dir-leak" -# Have to use a patch here. Depending directly on the fork breaks macros. +# Have to use a patch here. Depending directly on the fork breaks macros. [patch.crates-io.tracing-appender] git = "https://github.com/torkelrogstad/tokio-tracing.git" branch = "log-rotation-size" + +# Use the torkelrogstad fork until upstream connectrpc 0.6.0 + connectrpc-health +# are published to crates.io. Rev is pinned to the tip of the +# `2026-05-21-health` branch. +[patch.crates-io.connectrpc] +git = "https://github.com/torkelrogstad/connect-rust.git" +rev = "dfde93dd1b48d6aa5accd68fbe3231a85f330ef6" diff --git a/Justfile b/Justfile index 68ef7862..a916c070 100644 --- a/Justfile +++ b/Justfile @@ -1,6 +1,9 @@ default: @just --list +generate: + buf generate --clean + clippy: cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged -- --deny warnings cargo +nightly clippy -- -A clippy::all -D unqualified_local_imports -Zcrate-attr="feature(unqualified_local_imports)" diff --git a/README.md b/README.md index 023e6161..883b1b40 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ $ cargo build # See available options $ cargo run -- --help -# Starts the gRPC server at localhost:50001 +# Starts the Connect RPC server at localhost:50001 # Adjust these parameters to match your local Bitcoin # Core instance $ cargo run -- \ @@ -36,7 +36,7 @@ $ cargo run -- \ --node-zmq-addr-sequence=tcp://0.0.0.0:29000 # You should now be able to fetch data from the server! -$ buf curl --http2-prior-knowledge --protocol grpc \ +$ curl -H 'application/json' \ http://localhost:50051/cusf.validator.v1.ValidatorService/GetChainInfo { "network": "NETWORK_SIGNET" @@ -45,17 +45,18 @@ $ buf curl --http2-prior-knowledge --protocol grpc \ # Interacting with the enforcer -The CUSF enforcer exposes multiple gRPC services. These can be interacted with -using a gRPC client of your choice, for example +The CUSF enforcer exposes multiple [Connect](https://connectrpc.com/) (gRPC) +services. These can be interacted with using either plain `curl` or a +Connect/gRPC client of your choice, for example [`buf curl`](https://buf.build/docs/installation/) or [`grpcurl`](https://github.com/fullstorydev/grpcurl). -Some examples of interacting with the enforcer using `buf curl`, assuming you -expose the server at the default address `localhost:50051`: +Some examples of interacting with the enforcer using `curl`, assuming you expose +the server at the default address `localhost:50051`: ```bash # Define an alias for ease of use -$ alias buf_curl='buf curl --http2-prior-knowledge --protocol grpc --emit-defaults' +$ alias enforcer_curl='curl -X POST -H "Content-Type: application/json"' # List all the available RPCs $ buf_curl --list-methods http://localhost:50051 @@ -68,14 +69,14 @@ cusf.mainchain.v1.WalletService/CreateSidechainProposal ... list continues # Fetching data with a RPC that takes no input data -$ buf_curl http://localhost:50051/cusf.mainchain.v1.ValidatorService/GetChainInfo +$ enforcer_curl http://localhost:50051/cusf.mainchain.v1.ValidatorService/GetChainInfo { "network": "NETWORK_SIGNET" } # Fetching data with a RPC that takes input data $ request='{"block_hash": {"hex": "000002a78fc54150bb2d4cdb0fb19bcf744f2877faf90a172972fca5daf5fe92"}}' -$ buf_curl -d "$request" http://localhost:50051/cusf.mainchain.v1.ValidatorService/GetBlockHeaderInfo +$ enforcer_curl -d "$request" http://localhost:50051/cusf.mainchain.v1.ValidatorService/GetBlockHeaderInfo { "headerInfo": { "blockHash": { @@ -90,11 +91,6 @@ $ buf_curl -d "$request" http://localhost:50051/cusf.mainchain.v1.ValidatorServi } } } - -# Note that the request can also be read from a file. This can come in handy if -# you're working on more complex requests that's hard to write out on the terminal -echo "$request" > request.json -$ buf_curl -d @request.json http://localhost:50051/cusf.mainchain.v1.ValidatorService/GetBlockHeaderInfo ``` # Regtest @@ -139,16 +135,9 @@ $ RUST_LOG=info,bip300301_enforcer=debug cargo run ... # Working with the proto files -Code is generated with [protox](https://github.com/andrewhickman/protox), and -happens automatically as part of the build process. - -Files are linted with [protolint](https://github.com/yoheimuta/protolint). - -To lint the files, run: - -```bash -$ protolint lint --fix proto/validator/v1/validator.proto -``` +The proto files live in the +[cusf_sidechain_proto](https://github.com/LayerTwo-Labs/cusf_sidechain_proto) +repo. Code is generated with `buf` and checked into Git. # Code formatting diff --git a/app/Cargo.toml b/app/Cargo.toml index 005d61c1..7dbe5af3 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -6,7 +6,9 @@ publish.workspace = true version.workspace = true [dependencies] +axum = { workspace = true } bdk_wallet = { workspace = true } +buffa = { workspace = true } bip300301_enforcer_lib = { path = "../lib", default-features = false } bitcoin = { workspace = true } bitcoin-jsonrpsee = { workspace = true } @@ -22,16 +24,16 @@ reqwest = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread"] } tokio-util = { workspace = true } -tonic = { workspace = true } -tonic-health = { workspace = true } -tonic-reflection = { workspace = true } +connectrpc = { workspace = true } +connectrpc-health = { workspace = true } # needs to line up with jsonrpsee tower version... -tower = { workspace = true } +tower = { workspace = true, features = ["limit"] } tower-http = { workspace = true, features = ["trace", "request-id"] } tracing = { workspace = true } tracing-appender = { workspace = true } tracing-log = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } +url = { workspace = true } uuid = { workspace = true } [features] diff --git a/app/error.rs b/app/error.rs index 5ad19268..dabc5401 100644 --- a/app/error.rs +++ b/app/error.rs @@ -7,16 +7,19 @@ use miette::Diagnostic; use thiserror::Error; #[derive(Debug, Diagnostic, Error)] -pub enum GrpcServer { - #[error("unable to serve gRPC at `{addr}`")] - #[diagnostic(code(grpc_server::serve))] +pub enum ConnectServer { + #[error("unable to bind ConnectRPC server to `{addr}`: {source}")] + #[diagnostic(code(connectrpc_server::bind))] + Bind { + addr: SocketAddr, + source: std::io::Error, + }, + #[error("unable to serve ConnectRPC at `{addr}`: {source}")] + #[diagnostic(code(connectrpc_server::serve))] Serve { addr: SocketAddr, - source: tonic::transport::Error, + source: std::io::Error, }, - #[error("unable to build reflection service")] - #[diagnostic(code(grpc_server::reflection))] - Reflection(#[from] tonic_reflection::server::Error), } #[derive(educe::Educe, Diagnostic, Error)] diff --git a/app/main.rs b/app/main.rs index f4aaa5e3..662eb1d7 100644 --- a/app/main.rs +++ b/app/main.rs @@ -1,4 +1,4 @@ -use std::{net::SocketAddr, time::Duration}; +use std::{net::SocketAddr, sync::Arc, time::Duration}; use bdk_wallet::bip39::{Language, Mnemonic}; use bip300301_enforcer_lib::{ @@ -6,11 +6,10 @@ use bip300301_enforcer_lib::{ errors::ErrorChain, p2p::compute_signet_magic, proto::{ - self, - crypto::crypto_service_server::CryptoServiceServer, - mainchain::{ - validator_service_server::ValidatorServiceServer, - wallet_service_server::WalletServiceServer, + crypto_service::{CRYPTO_SERVICE_SERVICE_NAME, CryptoServiceExt}, + mainchain_service::{ + VALIDATOR_SERVICE_SERVICE_NAME, ValidatorServiceExt, WALLET_SERVICE_SERVICE_NAME, + WalletServiceExt, }, }, rpc_client, server, @@ -25,6 +24,8 @@ use bip300301_enforcer_lib::{ use bitcoin::ScriptBuf; use bitcoin_jsonrpsee::{MainClient, jsonrpsee::http_client::transport}; use clap::Parser; +use connectrpc::Router; +use connectrpc_health::{HealthExt, HealthService, StaticChecker}; use either::Either; use futures::{StreamExt, TryFutureExt as _, channel::oneshot}; use http::{Request, header::HeaderName}; @@ -34,11 +35,9 @@ use reqwest::Url; use thiserror::Error; use tokio::net::TcpStream; use tokio_util::sync::CancellationToken; -use tonic::{server::NamedService, transport::Server}; -use tower::ServiceBuilder; use tower_http::{ - request_id::{MakeRequestId, PropagateRequestIdLayer, RequestId, SetRequestIdLayer}, - trace::{DefaultOnFailure, DefaultOnResponse, TraceLayer}, + request_id::{MakeRequestId, RequestId, SetRequestIdLayer}, + trace::{DefaultOnFailure, TraceLayer}, }; use tracing::Instrument; use wallet::Wallet; @@ -93,182 +92,303 @@ fn set_request_id_layer() -> SetRequestIdLayer { SetRequestIdLayer::new(HeaderName::from_static(REQUEST_ID_HEADER), RequestIdMaker) } -fn propagate_request_id_layer() -> PropagateRequestIdLayer { - PropagateRequestIdLayer::new(HeaderName::from_static(REQUEST_ID_HEADER)) +/// Build the shared HTTP-level tower stack for our jsonrpsee servers +/// (request-id stamping + propagation + per-request tracing span + +/// structured response event). +/// +/// Returns the *inner* `tower::Layer` (post-`into_inner()`), so callers +/// can compose it with additional layers (e.g. `ConcurrencyLimitLayer`). +/// +/// A macro rather than a fn because (a) `tracing::span!` needs a literal +/// span name and (b) the layered `ServiceBuilder>` return type +/// is impractical to spell out. +macro_rules! jsonrpsee_tracer { + ($span_name:literal) => {{ + // Ordering here matters! Order here is from official docs on request IDs tracings + // https://docs.rs/tower-http/latest/tower_http/request_id/index.html#using-trace + tower::ServiceBuilder::new() + .layer(set_request_id_layer()) + .layer( + TraceLayer::new_for_http() + .make_span_with(|request: &http::Request<_>| { + let request_id = request + .headers() + .get(http::HeaderName::from_static(REQUEST_ID_HEADER)) + .and_then(|h| h.to_str().ok()) + .filter(|s| !s.is_empty()); + tracing::span!(tracing::Level::DEBUG, $span_name, request_id) + }) + .on_request(()) + .on_eos(()) + .on_response( + |response: &http::Response<_>, + duration: std::time::Duration, + _span: &tracing::Span| { + tracing::info!( + server = $span_name, + status = response.status().as_u16(), + duration_ms = duration.as_millis(), + "served JSON-RPC request", + ); + }, + ) + .on_failure(DefaultOnFailure::new().level(tracing::Level::ERROR)), + ) + .layer(tower_http::request_id::PropagateRequestIdLayer::new( + http::HeaderName::from_static(REQUEST_ID_HEADER), + )) + .into_inner() + }}; } -#[derive(Debug, Clone)] -struct FailureHandler; -use tower_http::classify::GrpcFailureClass; - -impl tower_http::trace::OnFailure for FailureHandler { - fn on_failure(&mut self, failure: GrpcFailureClass, latency: Duration, _span: &tracing::Span) { - let code = match failure { - GrpcFailureClass::Code(code) => tonic::Code::from_i32(code.into()), - GrpcFailureClass::Error(err) => { - tracing::warn!("unexpected gRPC failure class: {err}"); - tonic::Code::Internal - } - }; - tracing::error!( - latency = ?latency, - code = ?code, - "gRPC server responding with error", - ); +async fn connect_rpc_access_log( + req: axum::extract::Request, + next: axum::middleware::Next, +) -> axum::response::Response { + /// Cap how much error-response body we buffer for logging. + const ERROR_BODY_LOG_LIMIT: usize = 4 * 1024; + + let uri = req.uri().clone(); + let request_id_header = http::HeaderName::from_static(REQUEST_ID_HEADER); + let request_id = req.headers().get(&request_id_header).cloned(); + + let started = std::time::Instant::now(); + let mut response = next.run(req).await; + let duration_ms = started.elapsed().as_millis(); + let http_status = response.status(); + + // Stamp the request id on the response so the caller sees it back. + // Connect dispatchers don't preserve headers added by inner tower + // layers, so we mirror it here unconditionally. + if let Some(ref id) = request_id { + response.headers_mut().insert(request_id_header, id.clone()); } -} -async fn spawn_json_rpc_server( - validator: Either, - serve_addr: SocketAddr, -) -> miette::Result { - let methods = match validator { - Either::Left(validator) => { - server::validator::json_rpc::RpcServer::into_rpc(validator).into() - } - Either::Right(wallet) => { - let mut methods: jsonrpsee::server::Methods = - server::validator::json_rpc::RpcServer::into_rpc(wallet.validator().clone()).into(); - methods - .merge(server::wallet::json_rpc::RpcServer::into_rpc(wallet)) - .into_diagnostic()?; - methods + let request_id = request_id + .as_ref() + .and_then(|h| h.to_str().ok()) + .unwrap_or_default() + .to_owned(); + + // Connect procedure: `/package.Service/Method`. Logged as-is rather + // than split — the connect router may be mounted under a non-root + // path, in which case the URL path carries a prefix we don't want to + // mis-interpret as the service component. + let procedure = uri.path().to_owned(); + + // On non-2xx, buffer the body so we can pull the Connect error code + // and message out of it. Bodies are small JSON like + // `{"code":"invalid_argument","message":"..."}`. + if http_status.is_client_error() || http_status.is_server_error() { + let (parts, body) = response.into_parts(); + let body_bytes = axum::body::to_bytes(body, ERROR_BODY_LOG_LIMIT) + .await + .unwrap_or_else(|err| { + tracing::warn!( + procedure, %http_status, duration_ms, request_id, + "connect_rpc: failed to buffer error body: {err:#}", + ); + axum::body::Bytes::from_static(b"{}") + }); + let (connect_code, message) = + match buffa::serde_json::from_slice::(&body_bytes) { + Ok(err) => ( + err.code.as_str().to_owned(), + err.message.unwrap_or_default(), + ), + Err(_) => ( + "unknown".to_owned(), + String::from_utf8_lossy(&body_bytes).into_owned(), + ), + }; + if http_status.is_server_error() { + tracing::error!( + procedure, code = %connect_code, duration_ms, + request_id, message = %message, "connect_rpc", + ); + } else { + tracing::warn!( + procedure, code = %connect_code, duration_ms, + request_id, message = %message, "connect_rpc", + ); } - }; + return axum::response::Response::from_parts(parts, axum::body::Body::from(body_bytes)); + } + + tracing::info!( + procedure, + code = "ok", + duration_ms, + request_id, + "connect_rpc", + ); + response +} - tracing::info!("Listening for JSON-RPC on {}", serve_addr); +/// Treat a POST with no body the same as a POST with `{}`, so +/// `curl $url` works the same as `curl -d '{}' $url` +/// for RPCs without parameters. +/// +/// Streaming RPCs uses `application/connect+json` / +/// `application/connect+proto`, so we leave those alone. +async fn fill_empty_json_body( + req: axum::extract::Request, + next: axum::middleware::Next, +) -> axum::response::Response { + let is_unary_json = req.method() == http::Method::POST + && req + .headers() + .get(http::header::CONTENT_TYPE) + .and_then(|v| v.to_str().ok()) + .is_some_and(|v| { + v.split(';') + .next() + .unwrap_or("") + .trim() + .eq_ignore_ascii_case("application/json") + }); + // Missing or zero Content-Length on a unary JSON POST → assume empty body. + // (A well-behaved JSON client always sends Content-Length for a fixed payload.) + let is_empty = req + .headers() + .get(http::header::CONTENT_LENGTH) + .is_none_or(|v| v.to_str().ok().and_then(|s| s.parse::().ok()) == Some(0)); + if !is_unary_json || !is_empty { + return next.run(req).await; + } - // Ordering here matters! Order here is from official docs on request IDs tracings - // https://docs.rs/tower-http/latest/tower_http/request_id/index.html#using-trace - let tracer = tower::ServiceBuilder::new() - .layer(set_request_id_layer()) - .layer( - TraceLayer::new_for_http() - .make_span_with(move |request: &http::Request<_>| { - let request_id = request - .headers() - .get(http::HeaderName::from_static(REQUEST_ID_HEADER)) - .and_then(|h| h.to_str().ok()) - .filter(|s| !s.is_empty()); - - tracing::span!( - tracing::Level::DEBUG, - "json_rpc_server", - request_id, // this is needed for the record call below to work - ) - }) - .on_request(()) - .on_eos(()) - .on_response(DefaultOnResponse::new().level(tracing::Level::INFO)) - .on_failure(DefaultOnFailure::new().level(tracing::Level::ERROR)), - ) - .layer(propagate_request_id_layer()) - .into_inner(); + let (mut parts, _body) = req.into_parts(); + parts.headers.insert( + http::header::CONTENT_LENGTH, + http::HeaderValue::from_static("2"), + ); + next.run(axum::extract::Request::from_parts( + parts, + axum::body::Body::from("{}"), + )) + .await +} - let http_middleware = tower::ServiceBuilder::new().layer(tracer); - let rpc_middleware = RpcServiceBuilder::new().rpc_logger(1024); +/// For Connect unary GETs, default `encoding` to `json` and `message` to `{}` +/// when the client omitted them. Other query params are left untouched. +/// This makes it possible to do a simple curl invocation of GET endpoints: +/// +/// curl -H 'content-type: application/json' http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalance +/// +/// As opposed to: +/// curl -H 'content-type: application/json' http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalance?encoding=json=message={} +async fn fill_connect_get_defaults( + req: axum::extract::Request, + next: axum::middleware::Next, +) -> axum::response::Response { + if req.method() != http::Method::GET { + return next.run(req).await; + } - let handle = jsonrpsee::server::Server::builder() - .set_http_middleware(http_middleware) - .set_rpc_middleware(rpc_middleware) - .build(serve_addr) + let existing = req.uri().query().unwrap_or(""); + let mut has_encoding = false; + let mut has_message = false; + for pair in existing.split('&').filter(|s| !s.is_empty()) { + let key = pair.split('=').next().unwrap_or(""); + match key { + "encoding" => has_encoding = true, + "message" => has_message = true, + _ => {} + } + } + if has_encoding && has_message { + return next.run(req).await; + } + + let mut new_query = existing.to_string(); + if !has_encoding { + if !new_query.is_empty() { + new_query.push('&'); + } + new_query.push_str("encoding=json"); + } + if !has_message { + if !new_query.is_empty() { + new_query.push('&'); + } + let empty_message: String = url::form_urlencoded::byte_serialize(b"{}").collect(); + new_query.push_str(&format!("message={empty_message}")); + } + + let mut uri_parts = req.uri().clone().into_parts(); + let path = uri_parts + .path_and_query + .as_ref() + .map(|pq| pq.path()) + .unwrap_or("/"); + uri_parts.path_and_query = Some( + format!("{path}?{new_query}") + .parse() + .expect("valid path+query"), + ); + let new_uri = http::Uri::from_parts(uri_parts).expect("valid uri"); + + let (mut parts, body) = req.into_parts(); + parts.uri = new_uri; + next.run(axum::extract::Request::from_parts(parts, body)) .await - .map_err(|err| miette!("initialize JSON-RPC server at `{serve_addr}`: {err:#}"))? - .start(methods); - Ok(handle) } -async fn run_grpc_server( +async fn run_connect_server( validator: Either, cancel: CancellationToken, addr: SocketAddr, -) -> Result<()> { - // Ordering here matters! Order here is from official docs on request IDs tracings - // https://docs.rs/tower-http/latest/tower_http/request_id/index.html#using-trace - let tracer = ServiceBuilder::new() - .layer(set_request_id_layer()) - .layer( - TraceLayer::new_for_grpc() - .make_span_with(move |request: &Request<_>| { - let request_id = request - .headers() - .get(HeaderName::from_static(REQUEST_ID_HEADER)) - .and_then(|h| h.to_str().ok()) - .filter(|s| !s.is_empty()); - - tracing::span!( - tracing::Level::DEBUG, - "grpc_server", - method = %request.method(), - uri = %request.uri(), - request_id , // this is needed for the record call below to work - ) - }) - .on_request(()) - .on_eos(()) - // Set this to a low log level. Quickly leads to enormous log files, as our GUI - // implementations are sending a lof of requests /all/ the time. - .on_response(DefaultOnResponse::new().level(tracing::Level::TRACE)) - .on_failure(FailureHandler), - ) - .layer(propagate_request_id_layer()) - .into_inner(); - - let crypto_service = CryptoServiceServer::new(server::crypto::CryptoServiceServer); - let mut builder = Server::builder() - .layer(tracer) - .add_service(crypto_service) - .add_service(ValidatorServiceServer::new({ - let validator = match validator { - Either::Left(ref validator) => validator, - Either::Right(ref wallet) => wallet.validator(), - }; - server::validator::Server::new(validator.clone(), cancel.clone()) - })); - - let mut reflection_service_builder = tonic_reflection::server::Builder::configure() - .with_service_name(CryptoServiceServer::::NAME) - .with_service_name(ValidatorServiceServer::::NAME) - .register_encoded_file_descriptor_set(proto::ENCODED_FILE_DESCRIPTOR_SET); - - if let Either::Right(wallet) = validator.clone() { - tracing::info!("gRPC: enabling wallet service"); - let wallet_service = WalletServiceServer::new(wallet); - builder = builder.add_service(wallet_service); - reflection_service_builder = - reflection_service_builder.with_service_name(WalletServiceServer::::NAME); - } +) -> Result<(), error::ConnectServer> { + let (inner_validator, wallet) = match validator { + Either::Left(v) => (v, None), + Either::Right(w) => (w.validator().clone(), Some(w)), + }; + let router = Router::new(); + let router = Arc::new(server::crypto::CryptoServiceServer).register(router); + let router = Arc::new(server::validator::Server::new( + inner_validator, + cancel.clone(), + )) + .register(router); + + let mut services: Vec<&'static str> = + vec![CRYPTO_SERVICE_SERVICE_NAME, VALIDATOR_SERVICE_SERVICE_NAME]; + let router = if let Some(wallet) = wallet { + services.push(WALLET_SERVICE_SERVICE_NAME); + Arc::new(wallet).register(router) + } else { + router + }; - let (health_reporter, health_service) = tonic_health::server::health_reporter(); - - // Set all services to have the "serving" status. - // TODO: somehow expose the health reporter to the running services, and - // dynamically update if we're running into issues. - for service in [ - ValidatorServiceServer::::NAME, - WalletServiceServer::::NAME, - CryptoServiceServer::::NAME, - ] { - tracing::debug!("Setting health status for service: {service}"); - health_reporter - .set_service_status(service, tonic_health::ServingStatus::Serving) - .await; - } + let health_checker = Arc::new(StaticChecker::with_services(services)); + let router = Arc::new(HealthService::from_arc(Arc::clone(&health_checker))).register(router); - tracing::info!("Listening for gRPC on {addr} with reflection"); + let app = axum::Router::new() + .fallback_service(router.into_axum_service()) + .layer( + tower::ServiceBuilder::new() + .layer(set_request_id_layer()) + .layer(axum::middleware::from_fn(connect_rpc_access_log)) + .layer(axum::middleware::from_fn(fill_empty_json_body)) + .layer(axum::middleware::from_fn(fill_connect_get_defaults)), + ); - let server = builder - .add_service( - reflection_service_builder - .build_v1() - .map_err(error::GrpcServer::Reflection)?, - ) - .add_service(health_service); + let listener = tokio::net::TcpListener::bind(addr) + .await + .map_err(|err| error::ConnectServer::Bind { addr, source: err })?; - server - .serve_with_shutdown(addr, cancel.clone().cancelled()) + tracing::info!("Listening for Connect RPC on {addr}"); + + let cancel_clone = cancel.clone(); + let res = axum::serve(listener, app) + .with_graceful_shutdown(async move { cancel_clone.cancelled().await }) .await - .map_err(|err| miette::Report::from_err(error::GrpcServer::Serve { addr, source: err })) + .map_err(|err| error::ConnectServer::Serve { addr, source: err }); + + // Mark all services as not serving when we're shutting down + health_checker.shutdown(); + + res } async fn spawn_gbt_server( @@ -290,39 +410,12 @@ where .join(", ") ); - // Ordering here matters! Order here is from official docs on request IDs tracings - // https://docs.rs/tower-http/latest/tower_http/request_id/index.html#using-trace - let tracer = tower::ServiceBuilder::new() - .layer(set_request_id_layer()) - .layer( - TraceLayer::new_for_http() - .make_span_with(move |request: &http::Request<_>| { - let request_id = request - .headers() - .get(http::HeaderName::from_static(REQUEST_ID_HEADER)) - .and_then(|h| h.to_str().ok()) - .filter(|s| !s.is_empty()); - - tracing::span!( - tracing::Level::DEBUG, - "gbt_server", - request_id, // this is needed for the record call below to work - ) - }) - .on_request(()) - .on_eos(()) - .on_response(DefaultOnResponse::new().level(tracing::Level::INFO)) - .on_failure(DefaultOnFailure::new().level(tracing::Level::ERROR)), - ) - .layer(propagate_request_id_layer()) - .into_inner(); - let http_middleware = tower::ServiceBuilder::new() // Limit the gbt_server to 1 concurrent request, preventing runaway // callers (e.g. a stuck signet miner subprocess) from hammering // the endpoint with parallel requests. .layer(tower::limit::ConcurrencyLimitLayer::new(1)) - .layer(tracer); + .layer(jsonrpsee_tracer!("gbt_server")); let rpc_middleware = RpcServiceBuilder::new().rpc_logger(1024); use cusf_enforcer_mempool::server::RpcServer; @@ -934,10 +1027,6 @@ async fn main() -> Result<()> { } else { Either::Left(validator) }; - // Start JSON-RPC server - let json_rpc_server_handle = spawn_json_rpc_server(enforcer.clone(), cli.serve_json_rpc_addr) - .await - .map_err(|err| miette!("Failed to spawn JSON-RPC server: {err:#}"))?; let cancel = CancellationToken::new(); @@ -1008,19 +1097,10 @@ async fn main() -> Result<()> { let enforcer = enforcer.clone(); let addr = cli.serve_grpc_addr; tasks.spawn(async move { - let res = run_grpc_server(enforcer, cancel, addr).await; - ("gRPC server", res) - }); - } - - { - let cancel = cancel.clone(); - tasks.spawn(async move { - cancel.cancelled().await; - let res = json_rpc_server_handle - .stop() - .map_err(|err| miette!("error stopping JSON-RPC server: {err:#}")); - ("JSON-RPC server", res) + let res = run_connect_server(enforcer, cancel, addr) + .await + .map_err(miette::Report::from_err); + ("Connect RPC server", res) }); } diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..2791c54b --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,21 @@ +# https://buf.build/docs/configuration/v2/buf-gen-yaml/ +version: v2 + +inputs: + - git_repo: https://github.com/LayerTwo-Labs/cusf_sidechain_proto.git + ref: 3012c02cc1ac3d2d8f2384172e96b7018413fb3a + subdir: proto + +plugins: + - remote: buf.build/anthropics/buffa:v0.6.0 + out: lib/proto/generated/buffa + opt: + - file_per_package=true # needed for remote generation to work + - unknown_fields=false # makes destructuring more ergonomic + - json=true # serde impls for the Connect JSON wire format + - views=true # zero-copy *View types used by handler signatures + - remote: buf.build/anthropics/connect-rust:v0.6.0 + out: lib/proto/generated/connect + opt: + - file_per_package + - buffa_module=crate::proto::generated::buffa diff --git a/buf.yaml b/buf.yaml deleted file mode 100644 index ece40a92..00000000 --- a/buf.yaml +++ /dev/null @@ -1,4 +0,0 @@ -version: v2 -modules: - - path: proto - name: buf.build/LayerTwo-Labs/validator diff --git a/cusf_sidechain_proto b/cusf_sidechain_proto deleted file mode 160000 index 583965e3..00000000 --- a/cusf_sidechain_proto +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 583965e30d1117df3e92c39fc823ea25efe69528 diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 9aa82ab5..68732487 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -11,6 +11,8 @@ bdk_wallet = { workspace = true } bip300301_enforcer_lib = { path = "../lib", default-features = false } bitcoin-jsonrpsee = { workspace = true } bitcoin = { workspace = true } +buffa = { workspace = true } +buffa-types = { workspace = true } cfg-if = { workspace = true } cusf-enforcer-mempool = { workspace = true } dotenvy = { workspace = true } @@ -26,7 +28,8 @@ serde_json = { workspace = true } strum = { workspace = true, features = ["derive"] } temp-dir = { workspace = true } tokio = { workspace = true } -tonic = { workspace = true } +connectrpc = { workspace = true } +http = { workspace = true } tracing = { workspace = true } tracing-indicatif = { workspace = true } tokio-stream = { workspace = true } @@ -35,7 +38,7 @@ serde = { workspace = true, features = ["derive"] } [dev-dependencies] clap = { workspace = true } -tracing-subscriber = { workspace = true } +tracing-subscriber = { workspace = true, features = ["env-filter"] } tokio = { workspace = true, features = ["rt-multi-thread"] } [features] diff --git a/integration_tests/integration_test.rs b/integration_tests/integration_test.rs index 851c260f..d8a8919b 100644 --- a/integration_tests/integration_test.rs +++ b/integration_tests/integration_test.rs @@ -13,7 +13,7 @@ use bip300301_enforcer_lib::{ }, }; use bitcoin::Amount; -use futures::{FutureExt as _, StreamExt as _, TryStreamExt as _, channel::mpsc}; +use futures::{FutureExt as _, StreamExt as _, channel::mpsc}; use tokio::time::sleep; use tokio_stream::wrappers::IntervalStream; use tracing::Instrument as _; @@ -139,42 +139,38 @@ where { tracing::info!("Proposing sidechain"); let create_sidechain_proposal_request = { - let sidechain_declaration = - proto::mainchain::sidechain_declaration::SidechainDeclaration::V0( - proto::mainchain::sidechain_declaration::V0 { - title: Some("sidechain".to_owned()), - description: Some("sidechain".to_owned()), - hash_id_1: Some(ConsensusHex::encode(&[0; 32])), - hash_id_2: Some(Hex::encode(&[0u8; 20])), - }, - ); + let v0 = proto::mainchain::sidechain_declaration::V0 { + title: proto::wrap_string("sidechain"), + description: proto::wrap_string("sidechain"), + hash_id_1: buffa::MessageField::some(ConsensusHex::encode(&[0; 32])), + hash_id_2: buffa::MessageField::some(Hex::encode(&[0u8; 20])), + }; let declaration = proto::mainchain::SidechainDeclaration { - sidechain_declaration: Some(sidechain_declaration), + sidechain_declaration: Some(v0.into()), }; CreateSidechainProposalRequest { - sidechain_id: Some(S::SIDECHAIN_NUMBER.0.into()), - declaration: Some(declaration), + sidechain_id: proto::wrap_u32(S::SIDECHAIN_NUMBER.0.into()), + declaration: buffa::MessageField::some(declaration), } }; let mut create_sidechain_proposal_resp = post_setup .wallet_service_client .create_sidechain_proposal(create_sidechain_proposal_request) - .await? - .into_inner(); + .await?; // Wait before mining sleep(std::time::Duration::from_secs(1)).await; tracing::debug!("Mining 1 block"); let () = mine::(post_setup, 1, Some(true)).await?; - let Some(_) = create_sidechain_proposal_resp.try_next().await? else { + let Some(_) = create_sidechain_proposal_resp.message().await? else { anyhow::bail!("Expected response when proposing sidechain"); }; tracing::debug!("Proposed sidechain"); tracing::debug!("Checking sidechain proposals"); let sidechain_proposals_resp = post_setup .validator_service_client - .get_sidechain_proposals(GetSidechainProposalsRequest {}) + .get_sidechain_proposals(GetSidechainProposalsRequest::default()) .await? - .into_inner(); + .into_owned(); if sidechain_proposals_resp.sidechain_proposals.len() != 1 { anyhow::bail!("Expected 1 sidechain proposal") } @@ -189,9 +185,9 @@ where tracing::debug!("Checking that 0 sidechains are active"); let sidechains_resp = post_setup .validator_service_client - .get_sidechains(GetSidechainsRequest {}) + .get_sidechains(GetSidechainsRequest::default()) .await? - .into_inner(); + .into_owned(); if !sidechains_resp.sidechains.is_empty() { anyhow::bail!("unexpected sidechains resp: `{sidechains_resp:?}`") }; @@ -202,9 +198,9 @@ where tracing::debug!("Checking that exactly 1 sidechain is active"); let sidechains_resp = post_setup .validator_service_client - .get_sidechains(GetSidechainsRequest {}) + .get_sidechains(GetSidechainsRequest::default()) .await? - .into_inner(); + .into_owned(); if sidechains_resp.sidechains.len() != 1 { anyhow::bail!("Expected 1 active sidechain") } @@ -246,9 +242,9 @@ where Network::Regtest => { let address = post_setup .wallet_service_client - .create_new_address(CreateNewAddressRequest {}) + .create_new_address(CreateNewAddressRequest::default()) .await? - .into_inner() + .into_owned() .address; post_setup @@ -295,14 +291,15 @@ where let deposit_txid: bitcoin::Txid = post_setup .wallet_service_client .create_deposit_transaction(CreateDepositTransactionRequest { - sidechain_id: Some(S::SIDECHAIN_NUMBER.0.into()), - address: Some(sidechain_address.to_owned()), - value_sats: Some(deposit_amount.to_sat()), - fee_sats: Some(deposit_fee.to_sat()), + sidechain_id: proto::wrap_u32(S::SIDECHAIN_NUMBER.0.into()), + address: proto::wrap_string(sidechain_address.to_owned()), + value_sats: proto::wrap_u64(deposit_amount.to_sat()), + fee_sats: proto::wrap_u64(deposit_fee.to_sat()), }) .await? - .into_inner() + .into_owned() .txid + .into_option() .ok_or_else(|| proto::Error::missing_field::("txid"))? .decode::("txid")?; tracing::debug!("Deposit TXID: {deposit_txid}"); @@ -316,6 +313,7 @@ where [ block_info::Event { event: Some(block_info::event::Event::Deposit(_)), + .. }, ] => Ok(()), events => anyhow::bail!("Expected deposit event, found `{events:?}`"), @@ -331,21 +329,25 @@ where fn expect_withdrawal_bundle_event( event: &block_info::Event, ) -> anyhow::Result<(&ConsensusHex, &withdrawal_bundle_event::event::Event)> { - match event { - block_info::Event { - event: - Some(block_info::event::Event::WithdrawalBundle( - proto::mainchain::WithdrawalBundleEvent { - m6id: Some(event_m6id), - event: - Some(proto::mainchain::withdrawal_bundle_event::Event { - event: Some(event), - }), - }, - )), - } => Ok((event_m6id, event)), - _ => anyhow::bail!("Expected withdrawal bundle event"), - } + let block_info::event::Event::WithdrawalBundle(wbe) = event + .event + .as_ref() + .ok_or_else(|| anyhow::anyhow!("block_info::Event missing inner event"))? + else { + anyhow::bail!("Expected withdrawal bundle event"); + }; + let event_m6id = wbe + .m6id + .as_option() + .ok_or_else(|| anyhow::anyhow!("withdrawal bundle event missing m6id"))?; + let inner_event = wbe + .event + .as_option() + .ok_or_else(|| anyhow::anyhow!("withdrawal bundle event missing event wrapper"))? + .event + .as_ref() + .ok_or_else(|| anyhow::anyhow!("withdrawal bundle event missing oneof"))?; + Ok((event_m6id, inner_event)) } const WITHDRAW_AMOUNT_0: Amount = Amount::from_sat(18_000_000); @@ -384,10 +386,7 @@ where { [event] => { let (event_m6id, event) = expect_withdrawal_bundle_event(event)?; - let withdrawal_bundle_event::event::Event::Submitted( - withdrawal_bundle_event::event::Submitted {}, - ) = event - else { + let withdrawal_bundle_event::event::Event::Submitted(_) = event else { anyhow::bail!("Expected withdrawal bundle submitted event, found `{event:?}`") }; anyhow::ensure!(*event_m6id == ConsensusHex::encode(&m6id.0)); @@ -403,10 +402,7 @@ where match (seq, block_info.events.as_slice()) { (10, [event]) => { let (event_m6id, event) = expect_withdrawal_bundle_event(event)?; - let withdrawal_bundle_event::event::Event::Failed( - withdrawal_bundle_event::event::Failed {}, - ) = event - else { + let withdrawal_bundle_event::event::Event::Failed(_) = event else { anyhow::bail!("Expected withdrawal bundle failed event, found `{event:?}`") }; anyhow::ensure!(*event_m6id == ConsensusHex::encode(&m6id.0)); @@ -450,10 +446,7 @@ where { [event] => { let (event_m6id, event) = expect_withdrawal_bundle_event(event)?; - let withdrawal_bundle_event::event::Event::Submitted( - withdrawal_bundle_event::event::Submitted {}, - ) = event - else { + let withdrawal_bundle_event::event::Event::Submitted(_) = event else { anyhow::bail!("Expected withdrawal bundle submitted event, found `{event:?}`") }; anyhow::ensure!(*event_m6id == ConsensusHex::encode(&m6id.0)); @@ -482,13 +475,7 @@ where match (seq, block_info.events.as_slice()) { (6, [event]) => { let (event_m6id, event) = expect_withdrawal_bundle_event(event)?; - let withdrawal_bundle_event::event::Event::Succeeded( - withdrawal_bundle_event::event::Succeeded { - sequence_number: _, - transaction: _, - }, - ) = event - else { + let withdrawal_bundle_event::event::Event::Succeeded(_) = event else { anyhow::bail!("Expected withdrawal bundle success event, found `{event:?}`") }; anyhow::ensure!(*event_m6id == ConsensusHex::encode(&m6id.0)); diff --git a/integration_tests/mine.rs b/integration_tests/mine.rs index 9b267536..9af95002 100644 --- a/integration_tests/mine.rs +++ b/integration_tests/mine.rs @@ -8,14 +8,14 @@ use bip300301_enforcer_lib::{ self, ToStatus, mainchain::{ BlockHeaderInfo, GenerateBlocksRequest, GenerateBlocksResponse, SubscribeEventsRequest, + SubscribeEventsResponse, subscribe_events_response, subscribe_events_response::event::ConnectBlock, }, - sidechain::{SubscribeEventsResponse, subscribe_events_response}, }, }; use bitcoin::Address; +use connectrpc::ConnectError; use either::Either; -use futures::TryStreamExt as _; use thiserror::Error; use crate::{ @@ -62,7 +62,7 @@ pub enum MineGbtError { #[error("Submitting block failed with error: `{err_msg}`")] SubmitBlock { err_msg: String }, #[error(transparent)] - ValidatorClient(#[from] tonic::Status), + ValidatorClient(#[from] ConnectError), #[error(transparent)] Var(#[from] Arc), } @@ -124,14 +124,12 @@ async fn mine_gbt(post_setup: &mut PostSetup) -> Result() -> SubscribeEventsRequest { + SubscribeEventsRequest { + sidechain_id: proto::wrap_u32(S::SIDECHAIN_NUMBER.0.into()), + } +} + +fn proto_err_to_connect(err: proto::Error) -> ConnectError { + err.builder().to_connect_error() } // Mine blocks, running a check after each block @@ -165,41 +173,42 @@ where .ok_or(either::Left(MineSignetError::NoSignetMiner))?; let mut stream = post_setup .validator_service_client - .subscribe_events(SubscribeEventsRequest { - sidechain_id: Some(S::SIDECHAIN_NUMBER.0.into()), - }) + .subscribe_events(subscribe_request::()) .await - .map_err(|err| Either::Left(err.into()))? - .into_inner(); + .map_err(|err| Either::Left(err.into()))?; for _ in 0..blocks { let () = mine_single_signet(signet_miner, &post_setup.mining_address) .await .map_err(|err| Either::Left(err.into()))?; - let Some(resp) = stream - .try_next() + let Some(view) = stream + .message() .await .map_err(|err| Either::Left(err.into()))? else { return Err(Either::Left(MineSignetError::NoBlockEvent)); }; + let resp: SubscribeEventsResponse = view.to_owned_message(); let resp_event = resp .event + .into_option() .ok_or_else(|| proto::Error::missing_field::("event")) - .map_err(|err| Either::Left(err.builder().to_status().into()))? + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))? .event .ok_or_else(|| proto::Error::missing_field::("event")) - .map_err(|err| Either::Left(err.builder().to_status().into()))?; + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))?; match resp_event { Event::ConnectBlock(connect_block) => { let header_info = connect_block .header_info + .into_option() .ok_or_else(|| proto::Error::missing_field::("header_info")) - .map_err(|err| Either::Left(err.builder().to_status().into()))?; + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))?; let block_hash = header_info .block_hash + .into_option() .ok_or_else(|| proto::Error::missing_field::("block_hash")) - .map_err(|err| Either::Left(err.builder().to_status().into()))? - .decode_tonic::("block_hash") + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))? + .decode_status::("block_hash") .map_err(|err| Either::Left(err.into()))?; check(block_hash).map_err(Either::Right)? } @@ -224,39 +233,40 @@ where use proto::mainchain::subscribe_events_response::event::Event; let mut stream = post_setup .validator_service_client - .subscribe_events(SubscribeEventsRequest { - sidechain_id: Some(S::SIDECHAIN_NUMBER.0.into()), - }) + .subscribe_events(subscribe_request::()) .await - .map_err(|err| Either::Left(err.into()))? - .into_inner(); + .map_err(|err| Either::Left(err.into()))?; for _ in 0..blocks { let _block_hash = mine_gbt(post_setup).await.map_err(Either::Left)?; - let Some(resp) = stream - .try_next() + let Some(view) = stream + .message() .await .map_err(|err| Either::Left(err.into()))? else { return Err(Either::Left(MineGbtError::NoBlockEvent)); }; + let resp: SubscribeEventsResponse = view.to_owned_message(); let resp_event = resp .event + .into_option() .ok_or_else(|| proto::Error::missing_field::("event")) - .map_err(|err| Either::Left(err.builder().to_status().into()))? + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))? .event .ok_or_else(|| proto::Error::missing_field::("event")) - .map_err(|err| Either::Left(err.builder().to_status().into()))?; + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))?; match resp_event { Event::ConnectBlock(connect_block) => { let header_info = connect_block .header_info + .into_option() .ok_or_else(|| proto::Error::missing_field::("header_info")) - .map_err(|err| Either::Left(err.builder().to_status().into()))?; + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))?; let block_hash = header_info .block_hash + .into_option() .ok_or_else(|| proto::Error::missing_field::("block_hash")) - .map_err(|err| Either::Left(err.builder().to_status().into()))? - .decode_tonic::("block_hash") + .map_err(|err| Either::Left(proto_err_to_connect(err).into()))? + .decode_status::("block_hash") .map_err(|err| Either::Left(err.into()))?; check(block_hash).map_err(Either::Right)? } @@ -272,28 +282,27 @@ pub async fn mine_generateblocks_check( blocks: u32, ack_all_proposals: Option, mut check: F, -) -> Result<(), Either> +) -> Result<(), Either> where F: FnMut(bitcoin::BlockHash) -> Result<(), Err>, { let request = GenerateBlocksRequest { - blocks: Some(blocks), + blocks: proto::wrap_u32(blocks), ack_all_proposals: ack_all_proposals.unwrap_or(false), }; let mut stream = post_setup .wallet_service_client .generate_blocks(request) .await - .map_err(Either::Left)? - .into_inner(); - while let Some(resp) = stream.try_next().await.map_err(Either::Left)? { - let GenerateBlocksResponse { block_hash } = resp; + .map_err(Either::Left)?; + while let Some(view) = stream.message().await.map_err(Either::Left)? { + let resp: GenerateBlocksResponse = view.to_owned_message(); + let GenerateBlocksResponse { block_hash, .. } = resp; let block_hash = block_hash - .ok_or_else(|| { - proto::Error::missing_field::("block_hash").into() - }) - .map_err(Either::Left)? - .decode_tonic::("block_hash") + .into_option() + .ok_or_else(|| proto::Error::missing_field::("block_hash")) + .map_err(|err| Either::Left(proto_err_to_connect(err)))? + .decode_status::("block_hash") .map_err(Either::Left)?; let () = check(block_hash).map_err(Either::Right)?; } @@ -303,7 +312,7 @@ where #[derive(Debug, Error)] pub enum MineError { #[error(transparent)] - GenerateBlocks(tonic::Status), + GenerateBlocks(ConnectError), #[error(transparent)] Gbt(MineGbtError), #[error(transparent)] @@ -363,27 +372,23 @@ where tracing::debug!("Mining {blocks} block(s)"); let mut events = post_setup .validator_service_client - .subscribe_events(SubscribeEventsRequest { - sidechain_id: Some(S::SIDECHAIN_NUMBER.0.into()), - }) - .await? - .into_inner(); + .subscribe_events(subscribe_request::()) + .await?; for blocks_mined in 0..blocks { let () = mine::(post_setup, 1, ack_all_proposals).await?; - let Some(event) = events - .try_next() - .await? - .and_then(|event| event.event) - .and_then(|event| event.event) - else { + let Some(view) = events.message().await? else { anyhow::bail!("Expected a block event") }; + let resp: SubscribeEventsResponse = view.to_owned_message(); + let Some(event) = resp.event.into_option().and_then(|inner| inner.event) else { + anyhow::bail!("Expected event") + }; let proto::mainchain::subscribe_events_response::event::Event::ConnectBlock(connect_block) = event else { anyhow::bail!("Expected connect block event") }; - let Some(block_info) = connect_block.block_info else { + let Some(block_info) = connect_block.block_info.into_option() else { anyhow::bail!("Expected block info") }; let () = check(blocks_mined, block_info)?; diff --git a/integration_tests/setup.rs b/integration_tests/setup.rs index 07edf2e0..93ef3eec 100644 --- a/integration_tests/setup.rs +++ b/integration_tests/setup.rs @@ -15,16 +15,17 @@ use bip300301_enforcer_lib::{ bins::{self, CommandExt as _}, proto::{ self, - mainchain::{ - BroadcastWithdrawalBundleRequest, BroadcastWithdrawalBundleResponse, - validator_service_client::ValidatorServiceClient, - wallet_service_client::WalletServiceClient, - }, + mainchain::{BroadcastWithdrawalBundleRequest, BroadcastWithdrawalBundleResponse}, + mainchain_service::{ValidatorServiceClient, WalletServiceClient}, }, types::{BlindedM6, BlindedM6Error, M6id, SidechainNumber}, }; use bitcoin::{Address, Txid}; -use futures::{FutureExt as _, StreamExt, channel::mpsc, future}; +use connectrpc::{ + ConnectError, + client::{ClientConfig, HttpClient}, +}; +use futures::{channel::mpsc, future}; use reserve_port::ReservedPort; use temp_dir::TempDir; use thiserror::Error; @@ -239,7 +240,6 @@ pub struct ReservedPorts { pub electrs_electrum_http: ReservedPort, pub electrs_monitoring: ReservedPort, pub enforcer_serve_grpc: ReservedPort, - pub enforcer_serve_json_rpc: ReservedPort, pub enforcer_serve_rpc: ReservedPort, } @@ -253,7 +253,6 @@ impl ReservedPorts { electrs_electrum_http: ReservedPort::random()?, electrs_monitoring: ReservedPort::random()?, enforcer_serve_grpc: ReservedPort::random()?, - enforcer_serve_json_rpc: ReservedPort::random()?, enforcer_serve_rpc: ReservedPort::random()?, }) } @@ -341,7 +340,18 @@ pub struct Tasks { _bitcoind: AbortOnDrop<()>, } -type Transport = tonic::transport::Channel; +type Transport = HttpClient; + +/// Construct a connectrpc transport/config pair for a plaintext gRPC endpoint +/// served by our enforcer. +fn make_client(port: u16) -> anyhow::Result<(HttpClient, ClientConfig)> { + let uri: http::Uri = format!("http://127.0.0.1:{port}") + .parse() + .map_err(|err| anyhow!("invalid client URI: {err}"))?; + let http = HttpClient::plaintext(); + let config = ClientConfig::new(uri); + Ok((http, config)) +} #[derive(Clone, Debug)] pub struct Directories { @@ -592,7 +602,6 @@ impl PostSetup { node_rpc_port: bitcoind.rpc_port, node_zmq_sequence_port: bitcoind.zmq_sequence_port, serve_grpc_port: reserved_ports.enforcer_serve_grpc.port(), - serve_json_rpc_port: reserved_ports.enforcer_serve_json_rpc.port(), serve_rpc_port: reserved_ports.enforcer_serve_rpc.port(), wallet_electrum_rpc_port: electrs.electrum_rpc_port, wallet_electrum_http_port: electrs.electrum_http_port, @@ -600,7 +609,7 @@ impl PostSetup { let enforcer_task = enforcer.spawn_command_with_args( [( "RUST_LOG", - "h2=info,hyper_util=info,jsonrpsee-client=debug,jsonrpsee-http=debug,tonic=debug,trace", + "h2=info,hyper_util=info,jsonrpsee-client=debug,jsonrpsee-http=debug,connectrpc=debug,trace", )], opts.enforcer_args, move |err| { @@ -627,16 +636,9 @@ impl PostSetup { if let Some(signet_miner) = signet_miner.as_mut() { let () = SignetSetup::configure_miner(signet_miner, &dirs.base_dir, &enforcer)?; } - let validator_service_client = ValidatorServiceClient::connect(format!( - "http://127.0.0.1:{}", - enforcer.serve_grpc_port - )) - .await - .map_err(|err| anyhow!("failed to create validator service client: {err:#}"))?; - let wallet_service_client = - WalletServiceClient::connect(format!("http://127.0.0.1:{}", enforcer.serve_grpc_port)) - .await - .map_err(|err| anyhow!("failed to create wallet service client: {err:#}"))?; + let (http, config) = make_client(enforcer.serve_grpc_port)?; + let validator_service_client = ValidatorServiceClient::new(http.clone(), config.clone()); + let wallet_service_client = WalletServiceClient::new(http, config); let bitcoin_util = { let path = match bin_paths.bitcoin_util() { Ok(path) => Ok(path.clone()), @@ -754,19 +756,25 @@ pub enum DummySidechainError { #[error(transparent)] BlindedM6(#[from] BlindedM6Error), #[error(transparent)] - Grpc(Box), + Grpc(Box), #[error("Event stream was cancelled due to earlier error")] EventStreamCancelled, #[error("Event stream was closed unexpectedly")] EventStreamClosed, } -impl From for DummySidechainError { - fn from(err: tonic::Status) -> Self { +impl From for DummySidechainError { + fn from(err: ConnectError) -> Self { Self::Grpc(Box::new(err)) } } +impl From for DummySidechainError { + fn from(err: proto::Error) -> Self { + Self::Grpc(Box::new(err.into())) + } +} + /// Dummy implementation of `Sidechain` pub struct DummySidechain { /// If a withdrawal fails, add the value here until another withdrawal @@ -776,7 +784,15 @@ pub struct DummySidechain { /// is created pending_withdrawal_fee: bitcoin::Amount, withdrawal_bundles: HashMap>, - event_stream: Option>, + /// Receiver for SubscribeEvents stream items. The producer is a + /// background task spawned in `setup` that pumps a connectrpc + /// `ServerStream` into this channel. `None` after the stream errors or + /// closes. + event_rx: Option< + tokio::sync::mpsc::UnboundedReceiver< + Result, + >, + >, } impl DummySidechain { @@ -812,23 +828,21 @@ impl DummySidechain { /// Extract withdrawal bundle events from block info events fn extract_withdrawal_bundle_event( block_event: proto::mainchain::block_info::Event, - ) -> Result, tonic::Status> { - use proto::{ToStatus, mainchain::block_info::event::Event}; + ) -> Result, proto::Error> { + use proto::mainchain::block_info::event::Event; let event = block_event.event.ok_or_else(|| { proto::Error::missing_field::("event") - .builder() - .to_status() })?; match event { Event::Deposit(_) => Ok(None), - Event::WithdrawalBundle(withdrawal_bundle_event) => Ok(Some(withdrawal_bundle_event)), + Event::WithdrawalBundle(wbe) => Ok(Some(*wbe)), } } - /// Consume ready chunks from event stream + /// Drain any currently-ready events from the channel (non-blocking). fn update_from_events(&mut self) -> Result<(), DummySidechainError> { use bip300301_enforcer_lib::proto::{ - self, ToStatus, + self, mainchain::{ SubscribeEventsResponse, WithdrawalBundleEvent, subscribe_events_response::{ @@ -838,75 +852,63 @@ impl DummySidechain { withdrawal_bundle_event, }, }; - let Some(events_stream) = self.event_stream.take() else { + use tokio::sync::mpsc::error::TryRecvError; + let Some(rx) = self.event_rx.as_mut() else { return Err(DummySidechainError::EventStreamCancelled); }; - // Arbitrary, just needs to be 'big enough' - const EVENT_STREAM_CHUNK_SIZE: usize = 1024; - let mut events_stream = events_stream.ready_chunks(EVENT_STREAM_CHUNK_SIZE); - let events = events_stream - .next() - .map(|chunk| chunk.ok_or(DummySidechainError::EventStreamClosed)) - .now_or_never() - .transpose()? - .unwrap_or_default(); - self.event_stream = Some(events_stream.into_inner()); - for event in events { - let SubscribeEventsResponse { event } = match event { + loop { + let item = match rx.try_recv() { + Ok(item) => item, + Err(TryRecvError::Empty) => break, + Err(TryRecvError::Disconnected) => { + self.event_rx = None; + return Err(DummySidechainError::EventStreamClosed); + } + }; + let SubscribeEventsResponse { event, .. } = match item { Ok(event) => event, Err(err) => { - self.event_stream = None; + self.event_rx = None; return Err(err.into()); } }; - let subscribe_events_response::Event { event } = event.ok_or_else(|| { - proto::Error::missing_field::("event") - .builder() - .to_status() - })?; + let subscribe_events_response::Event { event, .. } = event + .into_option() + .ok_or_else(|| proto::Error::missing_field::("event"))?; let event: subscribe_events_response::event::Event = event.ok_or_else(|| { proto::Error::missing_field::("event") - .builder() - .to_status() })?; match event { Event::ConnectBlock(connect_block_event) => { - let block_info = connect_block_event.block_info.ok_or_else(|| { - proto::Error::missing_field::("block_info") - .builder() - .to_status() - })?; + let block_info = connect_block_event + .block_info + .into_option() + .ok_or_else(|| proto::Error::missing_field::("block_info"))?; 'inner: for event in block_info.events { - let Some(withdrawal_bundle_event) = - Self::extract_withdrawal_bundle_event(event)? - else { + let Some(wbe) = Self::extract_withdrawal_bundle_event(event)? else { continue 'inner; }; - let m6id = withdrawal_bundle_event + let m6id = wbe .m6id + .into_option() .ok_or_else(|| { proto::Error::missing_field::("m6id") - .builder() - .to_status() })? - .decode_tonic::("m6id") + .decode::("m6id") .map(M6id)?; - let withdrawal_bundle_event = withdrawal_bundle_event + let wbe_inner = wbe .event + .into_option() .ok_or_else(|| { proto::Error::missing_field::("event") - .builder() - .to_status() })? .event .ok_or_else(|| { proto::Error::missing_field::( "event", ) - .builder() - .to_status() })?; - match withdrawal_bundle_event { + match wbe_inner { withdrawal_bundle_event::event::Event::Failed(_) => { let failed_withdrawal = &self.withdrawal_bundles[&m6id]; self.pending_withdrawal_fee += *failed_withdrawal.fee(); @@ -929,7 +931,7 @@ impl Sidechain for DummySidechain { type Init = (); - type SetupError = tonic::Status; + type SetupError = ConnectError; async fn setup( _: Self::Init, @@ -938,19 +940,36 @@ impl Sidechain for DummySidechain { ) -> Result { use bip300301_enforcer_lib::proto::mainchain::SubscribeEventsRequest; let subscribe_events_request = SubscribeEventsRequest { - sidechain_id: Some(Self::SIDECHAIN_NUMBER.0.into()), + sidechain_id: proto::wrap_u32(Self::SIDECHAIN_NUMBER.0.into()), }; - let event_stream = post_setup + let mut stream = post_setup .validator_service_client - .clone() .subscribe_events(subscribe_events_request) - .await? - .into_inner(); + .await?; + // Pump the connect-rust ServerStream into a tokio mpsc so the + // existing non-blocking `try_recv`-based event drain works as before. + let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); + tokio::spawn(async move { + loop { + match stream.message().await { + Ok(Some(view)) => { + if tx.send(Ok(view.to_owned_message())).is_err() { + break; + } + } + Ok(None) => break, + Err(err) => { + drop(tx.send(Err(err))); + break; + } + } + } + }); Ok(Self { pending_withdrawal_fee: bitcoin::Amount::ZERO, pending_withdrawal_value: bitcoin::Amount::ZERO, withdrawal_bundles: HashMap::new(), - event_stream: Some(event_stream), + event_rx: Some(rx), }) } @@ -1004,14 +1023,17 @@ impl Sidechain for DummySidechain { ); let withdrawal_bundle_tx = blinded_m6.clone().tx().into_owned(); self.withdrawal_bundles.insert(m6id, blinded_m6); - let BroadcastWithdrawalBundleResponse {} = post_setup + let _resp: BroadcastWithdrawalBundleResponse = post_setup .wallet_service_client .broadcast_withdrawal_bundle(BroadcastWithdrawalBundleRequest { - sidechain_id: Some(Self::SIDECHAIN_NUMBER.0.into()), - transaction: Some(bitcoin::consensus::serialize(&withdrawal_bundle_tx)), + sidechain_id: proto::wrap_u32(Self::SIDECHAIN_NUMBER.0.into()), + transaction: buffa::MessageField::some(buffa_types::google::protobuf::BytesValue { + value: bitcoin::consensus::serialize(&withdrawal_bundle_tx), + ..Default::default() + }), }) .await? - .into_inner(); + .into_owned(); Ok(m6id) } } diff --git a/integration_tests/test_file_based_block_parser.rs b/integration_tests/test_file_based_block_parser.rs index aecf3e37..5f3998e4 100644 --- a/integration_tests/test_file_based_block_parser.rs +++ b/integration_tests/test_file_based_block_parser.rs @@ -2,11 +2,14 @@ use std::time::Duration; use bip300301_enforcer_lib::{ bins::CommandExt as _, - proto::mainchain::{GetChainTipRequest, validator_service_client::ValidatorServiceClient}, + proto::{mainchain::GetChainTipRequest, mainchain_service::ValidatorServiceClient}, +}; +use connectrpc::{ + client::{ClientConfig, HttpClient}, + error::ErrorCode, }; use futures::channel::mpsc; use tokio::time::sleep; -use tonic::Code; use crate::{ setup::{PreSetup, new_bitcoind, wait_for_port}, @@ -89,7 +92,6 @@ pub async fn test_file_based_block_parser(setup: PreSetup) -> anyhow::Result<()> node_rpc_port: bitcoind.rpc_port, node_zmq_sequence_port: bitcoind.zmq_sequence_port, serve_grpc_port: setup.reserved_ports.enforcer_serve_grpc.port(), - serve_json_rpc_port: setup.reserved_ports.enforcer_serve_json_rpc.port(), serve_rpc_port: setup.reserved_ports.enforcer_serve_rpc.port(), wallet_electrum_rpc_port: 0, wallet_electrum_http_port: 0, @@ -99,7 +101,7 @@ pub async fn test_file_based_block_parser(setup: PreSetup) -> anyhow::Result<()> let _enforcer_task = enforcer.spawn_command_with_args::<_, String, _, _, _>( [( "RUST_LOG", - "h2=info,hyper_util=info,jsonrpsee-client=debug,jsonrpsee-http=debug,tonic=debug,trace", + "h2=info,hyper_util=info,jsonrpsee-client=debug,jsonrpsee-http=debug,connectrpc=debug,trace", )], [], move |err| { @@ -118,20 +120,22 @@ pub async fn test_file_based_block_parser(setup: PreSetup) -> anyhow::Result<()> // verify we were able to sync - let mut client = - ValidatorServiceClient::connect(format!("http://127.0.0.1:{}", enforcer.serve_grpc_port)) - .await?; + let uri: http::Uri = format!("http://127.0.0.1:{}", enforcer.serve_grpc_port).parse()?; + let http = HttpClient::plaintext(); + let config = ClientConfig::new(uri); + let client = ValidatorServiceClient::new(http, config); let header_info = loop { - match client.get_chain_tip(GetChainTipRequest {}).await { + match client.get_chain_tip(GetChainTipRequest::default()).await { Ok(enforcer_tip) => { break enforcer_tip - .into_inner() + .into_owned() .block_header_info + .into_option() .expect("no block header info"); } // validator is not synced - Err(err) if err.code() == Code::Unavailable => { + Err(err) if err.code == ErrorCode::Unavailable => { tracing::debug!("Validator is not synced yet, retrying..."); sleep(Duration::from_millis(100)).await; continue; @@ -147,9 +151,12 @@ pub async fn test_file_based_block_parser(setup: PreSetup) -> anyhow::Result<()> *generated_blocks.last().expect("no last block"), header_info .block_hash + .into_option() .expect("no block hash") .hex - .expect("no hex"), + .into_option() + .expect("no hex") + .value, ); // Verify we did it by parsing the block files diff --git a/integration_tests/test_peer_bmm_request.rs b/integration_tests/test_peer_bmm_request.rs index c05e3d5b..df6afa33 100644 --- a/integration_tests/test_peer_bmm_request.rs +++ b/integration_tests/test_peer_bmm_request.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use bip300301_enforcer_lib::{ bins::CommandExt, proto::{ + self, common::ConsensusHex, mainchain::{ BlockHeaderInfo, CreateBmmCriticalDataTransactionRequest, CreateNewAddressRequest, @@ -10,6 +11,7 @@ use bip300301_enforcer_lib::{ }, }, }; +use buffa::MessageField; use futures::{StreamExt as _, channel::mpsc}; use tokio::time::sleep; use tracing::Instrument as _; @@ -156,21 +158,23 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result let sender_addr = post_setup .sender .wallet_service_client - .create_new_address(CreateNewAddressRequest {}) + .create_new_address(CreateNewAddressRequest::default()) .await? - .into_inner() + .into_owned() .address; if post_setup .miner .wallet_service_client .send_transaction(SendTransactionRequest { - destinations: HashMap::from([(sender_addr, 123_456_u64)]), + destinations: HashMap::from([(sender_addr, 123_456_u64)]) + .into_iter() + .collect(), ..Default::default() }) .await? - .into_inner() + .into_owned() .txid - .is_none() + .is_unset() { anyhow::bail!("Failed to create a tx to fund sender wallet") }; @@ -180,9 +184,9 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result let sender_balance = post_setup .sender .wallet_service_client - .get_balance(GetBalanceRequest {}) + .get_balance(GetBalanceRequest::default()) .await? - .into_inner(); + .into_owned(); anyhow::ensure!(sender_balance.confirmed_sats > 0); tracing::info!("Funded enforcer successfully (sender)"); @@ -192,17 +196,20 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result height: tip_height, work: _, timestamp: _, + .. } = post_setup .sender .validator_service_client - .get_chain_tip(GetChainTipRequest {}) + .get_chain_tip(GetChainTipRequest::default()) .await? - .into_inner() + .into_owned() .block_header_info + .into_option() .ok_or_else(|| { anyhow::anyhow!("Expected `block_header_info field` in GetChainInfoResponse") })?; let tip_block_hash = tip_block_hash + .into_option() .ok_or_else(|| anyhow::anyhow!("Expected `block_hash field` in BlockHeaderInfo"))?; let sidechain_block_hash: [u8; 32] = { use bitcoin::hashes::Hash; @@ -212,16 +219,17 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result .sender .wallet_service_client .create_bmm_critical_data_transaction(CreateBmmCriticalDataTransactionRequest { - sidechain_id: Some(DummySidechain::SIDECHAIN_NUMBER.0.into()), - value_sats: Some(10_000), - height: Some(tip_height), - critical_hash: Some(ConsensusHex::encode(&sidechain_block_hash)), - prev_bytes: Some(tip_block_hash), + sidechain_id: proto::wrap_u32(DummySidechain::SIDECHAIN_NUMBER.0.into()), + value_sats: proto::wrap_u64(10_000), + height: proto::wrap_u32(tip_height), + critical_hash: MessageField::some(ConsensusHex::encode(&sidechain_block_hash)), + prev_bytes: MessageField::some(tip_block_hash), }) .await? - .into_inner() + .into_owned() .txid - .and_then(|txid| txid.hex) + .into_option() + .and_then(|txid| proto::unwrap_string(txid.hex)) else { anyhow::bail!("Failed to create BMM critical data tx") }; @@ -244,6 +252,7 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result |_, block_info| { let bmm_commitment = block_info .bmm_commitment + .into_option() .ok_or_else(|| anyhow::anyhow!("Expected a BMM commitment"))?; let expected_bmm_commitment = ConsensusHex::encode(&sidechain_block_hash); anyhow::ensure!(bmm_commitment == expected_bmm_commitment); diff --git a/integration_tests/test_unconfirmed_transactions.rs b/integration_tests/test_unconfirmed_transactions.rs index f1bad70e..d2aaeede 100644 --- a/integration_tests/test_unconfirmed_transactions.rs +++ b/integration_tests/test_unconfirmed_transactions.rs @@ -16,32 +16,34 @@ pub async fn test_unconfirmed_transactions(mut post_setup: PostSetup) -> anyhow: let txs_pre = post_setup .wallet_service_client - .list_transactions(ListTransactionsRequest {}) + .list_transactions(ListTransactionsRequest::default()) .await? - .into_inner(); + .into_owned(); let utxos_pre = post_setup .wallet_service_client - .list_unspent_outputs(ListUnspentOutputsRequest {}) + .list_unspent_outputs(ListUnspentOutputsRequest::default()) .await? - .into_inner(); + .into_owned(); let destination_address = "bcrt1quzsfstj6aspah0yqzumnek9s2nmeh2ctax8tgy"; let send_tx_res = post_setup .wallet_service_client .send_transaction(SendTransactionRequest { - destinations: HashMap::from([(destination_address.to_string(), 123_456_u64)]), + destinations: HashMap::from([(destination_address.to_string(), 123_456_u64)]) + .into_iter() + .collect(), ..Default::default() }) .await? - .into_inner(); + .into_owned(); let txs_post = post_setup .wallet_service_client - .list_transactions(ListTransactionsRequest {}) + .list_transactions(ListTransactionsRequest::default()) .await? - .into_inner(); + .into_owned(); assert!(txs_post.transactions.len() == txs_pre.transactions.len() + 1); @@ -63,9 +65,9 @@ pub async fn test_unconfirmed_transactions(mut post_setup: PostSetup) -> anyhow: let unspent_post = post_setup .wallet_service_client - .list_unspent_outputs(ListUnspentOutputsRequest {}) + .list_unspent_outputs(ListUnspentOutputsRequest::default()) .await? - .into_inner(); + .into_owned(); let new_utxos = unspent_post .outputs diff --git a/integration_tests/util.rs b/integration_tests/util.rs index 02558d28..8b722f70 100644 --- a/integration_tests/util.rs +++ b/integration_tests/util.rs @@ -739,7 +739,6 @@ pub struct Enforcer { pub node_rpc_port: u16, pub node_zmq_sequence_port: u16, pub serve_grpc_port: u16, - pub serve_json_rpc_port: u16, pub serve_rpc_port: u16, pub wallet_electrum_rpc_port: u16, pub wallet_electrum_http_port: u16, @@ -767,10 +766,6 @@ impl Enforcer { format!("--node-rpc-pass={}", self.node_rpc_pass), "--log-level=trace".to_owned(), format!("--serve-grpc-addr=127.0.0.1:{}", self.serve_grpc_port), - format!( - "--serve-json-rpc-addr=127.0.0.1:{}", - self.serve_json_rpc_port - ), format!("--serve-rpc-addr=127.0.0.1:{}", self.serve_rpc_port), ]; diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 67ba90ea..26a22a3d 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -5,12 +5,6 @@ edition.workspace = true publish.workspace = true version.workspace = true -[build-dependencies] -prost = { workspace = true } -prost-build = { workspace = true } -protox = { workspace = true } -tonic-prost-build = { workspace = true } - [dependencies] aes-gcm = { workspace = true, features = ["std"] } argon2 = { workspace = true, features = ["std"] } @@ -23,7 +17,11 @@ bdk_wallet = { workspace = true, features = ["keys-bip39", "rusqlite"] } bitcoin = { workspace = true } bitcoin-jsonrpsee = { workspace = true } bitcoin-send-tx-p2p = { workspace = true } +buffa = { workspace = true } +buffa-types = { workspace = true } byteorder = { workspace = true } +connectrpc = { workspace = true } +http-body = { workspace = true } clap = { workspace = true, features = ["derive", "string", "std"] } cusf-enforcer-mempool = { workspace = true } derive_more = { workspace = true, features = ["debug", "display"] } @@ -43,8 +41,6 @@ nonempty = { workspace = true } ordermap = { workspace = true, features = ["serde"] } ouroboros = { workspace = true } parking_lot = { workspace = true, features = ["send_guard"] } -prost = { workspace = true } -prost-types = { workspace = true } rand = { workspace = true } reqwest = { workspace = true } # needs to line up with BDK version @@ -60,8 +56,6 @@ tokio = { workspace = true, features = ["macros"] } tokio-rusqlite = { workspace = true } tokio-stream = { workspace = true } tokio-util = { workspace = true } -tonic = { workspace = true } -tonic-prost = { workspace = true } tracing = { workspace = true } tracing-appender = { workspace = true } tracing-subscriber = { workspace = true, features = ["json"] } @@ -85,6 +79,3 @@ name = "bip300301_enforcer_lib" path = "lib.rs" doctest = false -[package.metadata.cargo-shear] -# Used by tonic-prost-build generated code in OUT_DIR, which cargo-shear can't see. -ignored = ["tonic-prost"] diff --git a/lib/build.rs b/lib/build.rs index 364afb81..aa266566 100644 --- a/lib/build.rs +++ b/lib/build.rs @@ -1,10 +1,4 @@ -use std::{ - env, fs, - path::{Path, PathBuf}, - process::Command, -}; - -use prost::Message; +use std::process::Command; fn get_git_hash() -> Result> { let args = ["describe", "--always", "--dirty"]; @@ -14,33 +8,10 @@ fn get_git_hash() -> Result> { return Err(format!("Failed to execute `git {}`", args.join(" ")).into()); } - let hash = String::from_utf8(output.stdout)?.trim().to_string(); - - Ok(hash) -} - -fn compile_protos_with_config( - file_descriptor_path: impl AsRef, - protos: &[P], - includes: &[P], - config_fn: F, -) -> Result<(), Box> -where - F: FnOnce(&mut prost_build::Config) -> Result<(), Box>, - P: AsRef, -{ - let mut config = prost_build::Config::new(); - config.enable_type_names(); - let () = config_fn(&mut config)?; - tonic_prost_build::configure() - .skip_protoc_run() - .file_descriptor_set_path(file_descriptor_path) - .compile_with_config(config, protos, includes)?; - Ok(()) + Ok(String::from_utf8(output.stdout)?.trim().to_string()) } -fn main() -> Result<(), Box> { - // Set git hash as environment variable for runtime access +fn main() { match get_git_hash() { Ok(hash) => { println!("cargo:rustc-env=GIT_HASH={hash}"); @@ -52,45 +23,4 @@ fn main() -> Result<(), Box> { println!("cargo:rustc-env=GIT_HASH=unknown"); } } - - const COMMON_PROTO: &str = "../cusf_sidechain_proto/proto/cusf/common/v1/common.proto"; - const CRYPTO_PROTO: &str = "../cusf_sidechain_proto/proto/cusf/crypto/v1/crypto.proto"; - const MAINCHAIN_COMMON_PROTO: &str = - "../cusf_sidechain_proto/proto/cusf/mainchain/v1/common.proto"; - const SIDECHAIN_PROTO: &str = "../cusf_sidechain_proto/proto/cusf/sidechain/v1/sidechain.proto"; - const VALIDATOR_PROTO: &str = "../cusf_sidechain_proto/proto/cusf/mainchain/v1/validator.proto"; - const WALLET_PROTO: &str = "../cusf_sidechain_proto/proto/cusf/mainchain/v1/wallet.proto"; - const ALL_PROTOS: &[&str] = &[ - COMMON_PROTO, - CRYPTO_PROTO, - MAINCHAIN_COMMON_PROTO, - SIDECHAIN_PROTO, - VALIDATOR_PROTO, - WALLET_PROTO, - ]; - const INCLUDES: &[&str] = &["../cusf_sidechain_proto/proto"]; - let file_descriptors = protox::compile(ALL_PROTOS, INCLUDES)?; - let file_descriptor_path = - PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR environment variable not set")) - .join("file_descriptor_set.bin"); - fs::write(&file_descriptor_path, file_descriptors.encode_to_vec())?; - - let () = - compile_protos_with_config(&file_descriptor_path, &[COMMON_PROTO], INCLUDES, |_| Ok(()))?; - let () = compile_protos_with_config( - &file_descriptor_path, - &[ - CRYPTO_PROTO, - MAINCHAIN_COMMON_PROTO, - SIDECHAIN_PROTO, - VALIDATOR_PROTO, - WALLET_PROTO, - ], - INCLUDES, - |config| { - config.extern_path(".cusf.common.v1", "crate::proto::common"); - Ok(()) - }, - )?; - Ok(()) } diff --git a/lib/cli.rs b/lib/cli.rs index efd6fbe5..83473c8c 100644 --- a/lib/cli.rs +++ b/lib/cli.rs @@ -370,8 +370,6 @@ pub enum RollingLoggerError { const DEFAULT_SERVE_RPC_ADDR: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 8122)); -const DEFAULT_SERVE_JSON_RPC_ADDR: SocketAddr = - SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 8123)); const DEFAULT_SERVE_GRPC_ADDR: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 50_051)); @@ -422,9 +420,6 @@ pub struct Config { /// Serve RPCs such as `getblocktemplate` on this address #[arg(default_value_t = DEFAULT_SERVE_RPC_ADDR, long)] pub serve_rpc_addr: SocketAddr, - /// Serve other JSON-RPC methods on this address - #[arg(default_value_t = DEFAULT_SERVE_JSON_RPC_ADDR, long)] - pub serve_json_rpc_addr: SocketAddr, /// Serve gRPCs on this address #[arg(default_value_t = DEFAULT_SERVE_GRPC_ADDR, long)] pub serve_grpc_addr: SocketAddr, diff --git a/lib/proto.rs b/lib/proto.rs index 2911aeef..cc83a0f3 100644 --- a/lib/proto.rs +++ b/lib/proto.rs @@ -1,17 +1,141 @@ +use bitcoin::OutPoint; +use buffa::MessageField; +use buffa_types::google::protobuf::{StringValue, Timestamp, UInt32Value, UInt64Value}; +use connectrpc::{ConnectError, error::ErrorCode}; use thiserror::Error; -/// Encoded file descriptor set, for gRPC reflection -pub static ENCODED_FILE_DESCRIPTOR_SET: &[u8] = - tonic::include_file_descriptor_set!("file_descriptor_set"); +use crate::{ + messages::{ + CoinbaseMessage, M1ProposeSidechain, M2AckSidechain, M3ProposeBundle, M4AckBundles, + }, + proto::{ + common::{ConsensusHex, Hex, ReverseHex}, + mainchain::{ + BlockHeaderInfo, BlockInfo, Deposit, Network, SidechainDeclaration, + WithdrawalBundleEvent, block_info, deposit, get_coinbase_psbt_request, + get_sidechains_response, get_two_way_peg_data_response, send_transaction_request, + sidechain_declaration, subscribe_events_response, wallet_transaction, + withdrawal_bundle_event, + }, + }, + types::SidechainNumber, +}; + +/// Wiring for `file_per_package=true` codegen. +/// +/// `buf generate` emits one self-contained `.rs` per proto +/// package under `lib/proto/generated/{buffa,connect}/`. This module +/// arranges them into a `cusf::::v1::*` tree via `include!()` so +/// the rest of the crate can reach types by their proto package path. +/// +/// The wiring lives here because anything inside the codegen output +/// directories is wiped by `buf generate --clean`. Keeping it in +/// `lib/proto.rs` makes the build survive a clean regen. +/// +/// `#![allow(...)]` mirrors `buffa_codegen::ALLOW_LINTS`. Copy in any +/// new lint that fires under `cargo clippy -D warnings` after a regen. +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod generated { + pub mod buffa { + pub mod cusf { + pub mod common { + pub mod v1 { + include!("proto/generated/buffa/cusf.common.v1.rs"); + } + } + pub mod crypto { + pub mod v1 { + include!("proto/generated/buffa/cusf.crypto.v1.rs"); + } + } + pub mod mainchain { + pub mod v1 { + include!("proto/generated/buffa/cusf.mainchain.v1.rs"); + } + } + pub mod sidechain { + pub mod v1 { + include!("proto/generated/buffa/cusf.sidechain.v1.rs"); + } + } + } + } + + pub mod connect { + pub mod cusf { + // `cusf.common.v1` has no services, so no connect-side file. + pub mod crypto { + pub mod v1 { + include!("proto/generated/connect/cusf.crypto.v1.rs"); + } + } + pub mod mainchain { + pub mod v1 { + include!("proto/generated/connect/cusf.mainchain.v1.rs"); + } + } + pub mod sidechain { + pub mod v1 { + include!("proto/generated/connect/cusf.sidechain.v1.rs"); + } + } + } + } +} + +pub mod common { + pub use crate::proto::generated::buffa::cusf::common::v1::*; +} + +pub mod crypto { + pub use crate::proto::generated::buffa::cusf::crypto::v1::*; +} + +pub mod mainchain { + pub use crate::proto::generated::buffa::cusf::mainchain::v1::*; + + #[derive(Copy, Clone, Debug)] + pub struct HeaderSyncProgress { + pub current_height: Option, + } + + impl From for SubscribeHeaderSyncProgressResponse { + fn from(progress: HeaderSyncProgress) -> Self { + Self { + current_height: progress + .current_height + .map(super::wrap_u32) + .unwrap_or_default(), + } + } + } +} + +pub mod sidechain { + pub use crate::proto::generated::buffa::cusf::sidechain::v1::*; +} + +pub use crate::proto::generated::connect::cusf::{ + crypto::v1 as crypto_service, mainchain::v1 as mainchain_service, +}; pub trait ToStatus { fn builder(&self) -> StatusBuilder<'_>; } -/// Construct a `tonic::Status` from an Error +/// Construct a `ConnectError` from an Error. pub struct StatusBuilder<'a> { - pub code: tonic::Code, - /// Defines the message, without source + pub code: ErrorCode, pub fmt_message: Box) -> std::fmt::Result + 'a>, pub source: Option>, &'a (dyn std::error::Error + 'static)>>, @@ -32,13 +156,13 @@ impl<'a> StatusBuilder<'a> { E: std::error::Error, { Self { - code: tonic::Code::Unknown, + code: ErrorCode::Unknown, fmt_message: Box::new(move |f| std::fmt::Display::fmt(err, f)), source: err.source().map(either::Right), } } - pub fn code(mut self, code: tonic::Code) -> Self { + pub fn code(mut self, code: ErrorCode) -> Self { self.code = code; self } @@ -100,18 +224,18 @@ impl<'a> StatusBuilder<'a> { } } - pub fn to_status(&self) -> tonic::Status { + pub fn to_connect_error(&self) -> ConnectError { let msg = format!( "{:#}", crate::display::DisplayFn::new(|f| self.status_message(f)) ); - tonic::Status::new(self.code, msg) + ConnectError::new(self.code, msg) } } -impl From> for tonic::Status { +impl From> for ConnectError { fn from(builder: StatusBuilder<'_>) -> Self { - builder.to_status() + builder.to_connect_error() } } @@ -154,833 +278,769 @@ pub enum Error { } impl Error { - pub fn invalid_enum_variant(field_name: &str, variant_name: &str) -> Self - where - Message: prost::Name, - { + pub fn invalid_enum_variant( + field_name: &str, + variant_name: &str, + ) -> Self { Self::InvalidEnumVariant { field_name: field_name.to_owned(), - message_name: Message::full_name(), + message_name: Message::FULL_NAME.to_owned(), variant_name: variant_name.to_owned(), } } - pub fn invalid_field_value(field_name: &str, value: &str, source: Error) -> Self + pub fn invalid_field_value( + field_name: &str, + value: &str, + source: Error, + ) -> Self where - Message: prost::Name, Error: std::error::Error + Send + Sync + 'static, { Self::InvalidFieldValue { field_name: field_name.to_owned(), - message_name: Message::full_name(), + message_name: Message::FULL_NAME.to_owned(), value: value.to_owned(), source: Box::new(source), } } - pub fn invalid_repeated_value(field_name: &str, value: &str) -> Self - where - Message: prost::Name, - { + pub fn invalid_repeated_value( + field_name: &str, + value: &str, + ) -> Self { Self::InvalidRepeatedValue { field_name: field_name.to_owned(), - message_name: Message::full_name(), + message_name: Message::FULL_NAME.to_owned(), value: value.to_owned(), } } - pub fn missing_field(field_name: &str) -> Self - where - Message: prost::Name, - { + pub fn missing_field(field_name: &str) -> Self { Self::MissingField { field_name: field_name.to_owned(), - message_name: Message::full_name(), + message_name: Message::FULL_NAME.to_owned(), } } } impl ToStatus for Error { fn builder(&self) -> StatusBuilder<'_> { - StatusBuilder::new(self).code(tonic::Code::InvalidArgument) + StatusBuilder::new(self).code(ErrorCode::InvalidArgument) } } -impl From for tonic::Status { +impl From for ConnectError { fn from(err: Error) -> Self { err.builder().into() } } -pub mod common { - use std::error::Error as _; - - tonic::include_proto!("cusf.common.v1"); - - impl ConsensusHex { - pub fn decode(self, field_name: &str) -> Result - where - Message: prost::Name, - T: bitcoin::consensus::Decodable, - { - let Self { hex } = self; - let hex = hex.ok_or_else(|| super::Error::missing_field::("hex"))?; - bitcoin::consensus::encode::deserialize_hex(&hex).map_err(|err| { - super::Error::invalid_field_value::(field_name, &hex, err) - }) - } - - /// Variant of [`Self::decode`] that returns a `tonic::Status` error - pub fn decode_tonic(self, field_name: &str) -> Result - where - Message: prost::Name, - T: bitcoin::consensus::Decodable, - { - self.decode::(field_name).map_err(|err| { - let mut msg = err.to_string(); - if let Some(source) = err.source() { - msg = format!("{msg}: {source:#}") - } - tonic::Status::new(tonic::Code::InvalidArgument, msg) - }) - } - - pub fn encode(value: &T) -> Self - where - T: bitcoin::consensus::Encodable, - { - let hex = bitcoin::consensus::encode::serialize_hex(value); - Self { hex: Some(hex) } - } - } - - impl Hex { - pub fn decode(self, field_name: &str) -> Result - where - Message: prost::Name, - T: hex::FromHex, - ::Error: std::error::Error + Send + Sync + 'static, - { - let Self { hex } = self; - let hex = hex.ok_or_else(|| super::Error::missing_field::("hex"))?; - T::from_hex(&hex).map_err(|err| { - super::Error::invalid_field_value::(field_name, &hex, err) - }) - } - - /// Variant of [`Self::decode`] that returns a `tonic::Status` error - pub fn decode_tonic(self, field_name: &str) -> Result - where - Message: prost::Name, - T: hex::FromHex, - ::Error: std::error::Error + Send + Sync + 'static, - { - self.decode::(field_name).map_err(|err| { - let mut msg = err.to_string(); - if let Some(source) = err.source() { - msg = format!("{msg}: {source:#}") - } - tonic::Status::new(tonic::Code::InvalidArgument, msg) - }) - } - - pub fn encode(value: &T) -> Self - where - T: hex::ToHex, - { - let hex = value.encode_hex(); - Self { hex: Some(hex) } - } - } - - impl ReverseHex { - pub fn decode(self, field_name: &str) -> Result - where - Message: prost::Name, - T: bitcoin::consensus::Decodable, - { - let Self { hex } = self; - let hex = hex.ok_or_else(|| super::Error::missing_field::("hex"))?; - let mut bytes = hex::decode(&hex).map_err(|err| { - super::Error::invalid_field_value::(field_name, &hex, err) - })?; - bytes.reverse(); - bitcoin::consensus::deserialize(&bytes).map_err(|err| { - super::Error::invalid_field_value::(field_name, &hex, err) - }) - } +pub fn wrap_string(value: impl Into) -> MessageField { + MessageField::some(StringValue { + value: value.into(), + ..Default::default() + }) +} - /// Variant of [`Self::decode`] that returns a `tonic::Status` error - pub fn decode_tonic(self, field_name: &str) -> Result - where - Message: prost::Name, - T: bitcoin::consensus::Decodable, - { - self.decode::(field_name).map_err(|err| { - let mut msg = err.to_string(); - if let Some(source) = err.source() { - msg = format!("{msg}: {source:#}") - } - tonic::Status::new(tonic::Code::InvalidArgument, msg) - }) - } +pub fn wrap_u32(value: u32) -> MessageField { + MessageField::some(UInt32Value { + value, + ..Default::default() + }) +} - pub fn encode(value: &T) -> Self - where - T: bitcoin::consensus::Encodable, - { - let mut bytes = bitcoin::consensus::encode::serialize(value); - bytes.reverse(); - Self { - hex: Some(hex::encode(bytes)), - } - } - } +pub fn wrap_u64(value: u64) -> MessageField { + MessageField::some(UInt64Value { + value, + ..Default::default() + }) } -#[expect(clippy::allow_attributes, reason = "generated code uses #[allow]")] -pub mod crypto { - tonic::include_proto!("cusf.crypto.v1"); +pub fn wrap_timestamp(seconds: i64) -> MessageField { + MessageField::some(Timestamp { + seconds, + nanos: 0, + ..Default::default() + }) } -#[expect(clippy::allow_attributes, reason = "generated code uses #[allow]")] -pub mod mainchain { - use crate::{ - messages::{ - CoinbaseMessage, M1ProposeSidechain, M2AckSidechain, M3ProposeBundle, M4AckBundles, - }, - proto::common::{ConsensusHex, Hex, ReverseHex}, - types::SidechainNumber, - }; +pub fn unwrap_string(field: MessageField) -> Option { + field.into_option().map(|sv| sv.value) +} - tonic::include_proto!("cusf.mainchain.v1"); +pub fn unwrap_u32(field: MessageField) -> Option { + field.into_option().map(|uv| uv.value) +} - pub use self::{ - subscribe_events_response::event::{ConnectBlock, DisconnectBlock}, - validator_service_server::{ - self as server, ValidatorService as Service, ValidatorServiceServer as Server, - }, - }; +pub fn unwrap_u64(field: MessageField) -> Option { + field.into_option().map(|uv| uv.value) +} - impl From<&bitcoin::OutPoint> for OutPoint { - fn from(outpoint: &bitcoin::OutPoint) -> Self { - Self { - txid: Some(ReverseHex::encode(&outpoint.txid)), - vout: Some(outpoint.vout), - } - } +impl common::ConsensusHex { + pub fn decode(self, field_name: &str) -> Result + where + T: bitcoin::consensus::Decodable, + { + let hex = unwrap_string(self.hex).ok_or_else(|| Error::missing_field::("hex"))?; + bitcoin::consensus::encode::deserialize_hex(&hex) + .map_err(|err| Error::invalid_field_value::(field_name, &hex, err)) } - impl From for sidechain_declaration::V0 { - fn from(declaration: crate::types::SidechainDeclaration) -> Self { - Self { - title: Some(declaration.title), - description: Some(declaration.description), - hash_id_1: Some(ConsensusHex::encode(&declaration.hash_id_1)), - hash_id_2: Some(Hex::encode(&declaration.hash_id_2)), - } - } + pub fn decode_status( + self, + field_name: &str, + ) -> Result + where + T: bitcoin::consensus::Decodable, + { + self.decode::(field_name) + .map_err(ConnectError::from) } - impl TryFrom for crate::types::SidechainDeclaration { - type Error = super::Error; - - fn try_from(declaration: sidechain_declaration::V0) -> Result { - let sidechain_declaration::V0 { - title, - description, - hash_id_1, - hash_id_2, - } = declaration; - let title = title - .ok_or_else(|| super::Error::missing_field::("title"))?; - let description = description.ok_or_else(|| { - super::Error::missing_field::("description") - })?; - let hash_id_1 = hash_id_1 - .ok_or_else(|| { - super::Error::missing_field::("hash_id_1") - })? - .decode::("hash_id_1")?; - let hash_id_2 = hash_id_2 - .ok_or_else(|| { - super::Error::missing_field::("hash_id_2") - })? - .decode::("hash_id_2")?; - Ok(Self { - title, - description, - hash_id_1, - hash_id_2, - }) + pub fn encode(value: &T) -> Self + where + T: bitcoin::consensus::Encodable, + { + let hex = bitcoin::consensus::encode::serialize_hex(value); + Self { + hex: wrap_string(hex), } } +} - impl From for sidechain_declaration::SidechainDeclaration { - fn from(declaration: sidechain_declaration::V0) -> Self { - sidechain_declaration::SidechainDeclaration::V0(declaration) - } +impl common::Hex { + pub fn decode(self, field_name: &str) -> Result + where + T: hex::FromHex, + ::Error: std::error::Error + Send + Sync + 'static, + { + let hex = unwrap_string(self.hex).ok_or_else(|| Error::missing_field::("hex"))?; + T::from_hex(&hex) + .map_err(|err| Error::invalid_field_value::(field_name, &hex, err)) } - impl From for SidechainDeclaration { - fn from(declaration: sidechain_declaration::V0) -> Self { - Self { - sidechain_declaration: Some(declaration.into()), - } - } + pub fn decode_status( + self, + field_name: &str, + ) -> Result + where + T: hex::FromHex, + ::Error: std::error::Error + Send + Sync + 'static, + { + self.decode::(field_name) + .map_err(ConnectError::from) } - impl From for SidechainDeclaration { - fn from(declaration: crate::types::SidechainDeclaration) -> Self { - sidechain_declaration::V0::from(declaration).into() + pub fn encode(value: &T) -> Self + where + T: hex::ToHex, + { + let hex: String = value.encode_hex(); + Self { + hex: wrap_string(hex), } } +} - impl TryFrom for crate::types::SidechainDeclaration { - type Error = super::Error; - - fn try_from( - declaration: sidechain_declaration::SidechainDeclaration, - ) -> Result { - match declaration { - sidechain_declaration::SidechainDeclaration::V0(v0) => v0.try_into(), - } - } +impl common::ReverseHex { + pub fn decode(self, field_name: &str) -> Result + where + T: bitcoin::consensus::Decodable, + { + let hex = unwrap_string(self.hex).ok_or_else(|| Error::missing_field::("hex"))?; + let mut bytes = hex::decode(&hex) + .map_err(|err| Error::invalid_field_value::(field_name, &hex, err))?; + bytes.reverse(); + bitcoin::consensus::deserialize(&bytes) + .map_err(|err| Error::invalid_field_value::(field_name, &hex, err)) } - impl TryFrom for crate::types::SidechainDeclaration { - type Error = super::Error; - - fn try_from(declaration: SidechainDeclaration) -> Result { - let SidechainDeclaration { - sidechain_declaration, - } = declaration; - sidechain_declaration - .ok_or_else(|| { - super::Error::missing_field::("sidechain_declaration") - })? - .try_into() - } + pub fn decode_status( + self, + field_name: &str, + ) -> Result + where + T: bitcoin::consensus::Decodable, + { + self.decode::(field_name) + .map_err(ConnectError::from) } - impl From for Network { - fn from(network: bitcoin::Network) -> Self { - match network { - bitcoin::Network::Bitcoin => Network::Mainnet, - bitcoin::Network::Regtest => Network::Regtest, - bitcoin::Network::Signet => Network::Signet, - bitcoin::Network::Testnet => Network::Testnet, - _ => Network::Unknown, - } + pub fn encode(value: &T) -> Self + where + T: bitcoin::consensus::Encodable, + { + let mut bytes = bitcoin::consensus::encode::serialize(value); + bytes.reverse(); + Self { + hex: wrap_string(hex::encode(bytes)), } } +} - impl TryFrom for M1ProposeSidechain { - type Error = super::Error; - - fn try_from( - propose_sidechain: get_coinbase_psbt_request::ProposeSidechain, - ) -> Result { - use get_coinbase_psbt_request::ProposeSidechain; - let ProposeSidechain { - sidechain_number, - data, - } = propose_sidechain; - let sidechain_number: SidechainNumber = { - let sidechain_number: u32 = sidechain_number.ok_or_else(|| { - Self::Error::missing_field::("sidechain_number") - })?; - sidechain_number.try_into().map_err(|err| { - Self::Error::invalid_field_value::( - "sidechain_number", - &sidechain_number.to_string(), - err, - ) - })? - }; - let description: Vec = data - .ok_or_else(|| Self::Error::missing_field::("data"))? - .decode::("data")?; - Ok(M1ProposeSidechain { - sidechain_number, - description: description.into(), - }) +impl From<&OutPoint> for mainchain::OutPoint { + fn from(outpoint: &OutPoint) -> Self { + Self { + txid: MessageField::some(ReverseHex::encode(&outpoint.txid)), + vout: wrap_u32(outpoint.vout), } } +} - impl TryFrom for M2AckSidechain { - type Error = super::Error; - - fn try_from( - ack_sidechain: get_coinbase_psbt_request::AckSidechain, - ) -> Result { - use get_coinbase_psbt_request::AckSidechain; - let AckSidechain { - sidechain_number, - data_hash, - } = ack_sidechain; - let sidechain_number: SidechainNumber = { - let sidechain_number: u32 = sidechain_number.ok_or_else(|| { - Self::Error::missing_field::("sidechain_number") - })?; - sidechain_number.try_into().map_err(|err| { - Self::Error::invalid_field_value::( - "sidechain_number", - &sidechain_number.to_string(), - err, - ) - })? - }; - let description_hash = data_hash - .ok_or_else(|| Self::Error::missing_field::("data_hash"))? - .decode::("data_hash")?; - Ok(M2AckSidechain { - sidechain_number, - description_hash, - }) +impl From for sidechain_declaration::V0 { + fn from(decl: crate::types::SidechainDeclaration) -> Self { + Self { + title: wrap_string(decl.title), + description: wrap_string(decl.description), + hash_id_1: MessageField::some(ConsensusHex::encode(&decl.hash_id_1)), + hash_id_2: MessageField::some(Hex::encode(&decl.hash_id_2)), } } +} - impl TryFrom for M3ProposeBundle { - type Error = super::Error; - - fn try_from( - propose_bundle: get_coinbase_psbt_request::ProposeBundle, - ) -> Result { - use get_coinbase_psbt_request::ProposeBundle; - let ProposeBundle { - sidechain_number, - bundle_txid, - } = propose_bundle; - let sidechain_number: SidechainNumber = { - let sidechain_number: u32 = sidechain_number.ok_or_else(|| { - Self::Error::missing_field::("sidechain_number") - })?; - sidechain_number.try_into().map_err(|err| { - Self::Error::invalid_field_value::( - "sidechain_number", - &sidechain_number.to_string(), - err, - ) - })? - }; - let bundle_txid: [u8; 32] = bundle_txid - .ok_or_else(|| Self::Error::missing_field::("bundle_txid"))? - .decode::("bundle_txid")?; - Ok(M3ProposeBundle { - sidechain_number, - bundle_txid, - }) - } +impl TryFrom for crate::types::SidechainDeclaration { + type Error = Error; + + fn try_from(decl: sidechain_declaration::V0) -> Result { + let sidechain_declaration::V0 { + title, + description, + hash_id_1, + hash_id_2, + .. + } = decl; + let title = unwrap_string(title) + .ok_or_else(|| Error::missing_field::("title"))?; + let description = unwrap_string(description) + .ok_or_else(|| Error::missing_field::("description"))?; + let hash_id_1 = hash_id_1 + .into_option() + .ok_or_else(|| Error::missing_field::("hash_id_1"))? + .decode::("hash_id_1")?; + let hash_id_2 = hash_id_2 + .into_option() + .ok_or_else(|| Error::missing_field::("hash_id_2"))? + .decode::("hash_id_2")?; + Ok(Self { + title, + description, + hash_id_1, + hash_id_2, + }) } +} - impl From for M4AckBundles { - fn from(repeat_previous: get_coinbase_psbt_request::ack_bundles::RepeatPrevious) -> Self { - let get_coinbase_psbt_request::ack_bundles::RepeatPrevious {} = repeat_previous; - Self::RepeatPrevious +impl From for SidechainDeclaration { + fn from(v0: sidechain_declaration::V0) -> Self { + Self { + sidechain_declaration: Some(v0.into()), } } +} - impl From for M4AckBundles { - fn from(leading_by_50: get_coinbase_psbt_request::ack_bundles::LeadingBy50) -> Self { - let get_coinbase_psbt_request::ack_bundles::LeadingBy50 {} = leading_by_50; - Self::LeadingBy50 - } +impl From for SidechainDeclaration { + fn from(decl: crate::types::SidechainDeclaration) -> Self { + sidechain_declaration::V0::from(decl).into() } +} - impl TryFrom for M4AckBundles { - type Error = super::Error; +impl TryFrom for crate::types::SidechainDeclaration { + type Error = Error; - fn try_from( - upvotes: get_coinbase_psbt_request::ack_bundles::Upvotes, - ) -> Result { - use get_coinbase_psbt_request::ack_bundles::Upvotes; - let Upvotes { upvotes } = upvotes; - let mut two_bytes = false; - for upvote in &upvotes { - if *upvote > u16::MAX as u32 { - let err = Self::Error::invalid_repeated_value::( - "upvotes", - &upvote.to_string(), - ); - return Err(err); - } else if *upvote > u8::MAX as u32 { - two_bytes = true; - } - } - if two_bytes { - let upvotes = upvotes.into_iter().map(|upvote| upvote as u16).collect(); - Ok(Self::TwoBytes { upvotes }) - } else { - let upvotes = upvotes.into_iter().map(|upvote| upvote as u8).collect(); - Ok(Self::OneByte { upvotes }) - } + fn try_from(decl: sidechain_declaration::SidechainDeclaration) -> Result { + match decl { + sidechain_declaration::SidechainDeclaration::V0(v0) => (*v0).try_into(), } } +} - impl TryFrom for M4AckBundles { - type Error = super::Error; - - fn try_from( - ack_bundles: get_coinbase_psbt_request::ack_bundles::AckBundles, - ) -> Result { - use get_coinbase_psbt_request::ack_bundles::AckBundles; - match ack_bundles { - AckBundles::LeadingBy50(leading_by_50) => Ok(leading_by_50.into()), - AckBundles::RepeatPrevious(repeat_previous) => Ok(repeat_previous.into()), - AckBundles::Upvotes(upvotes) => upvotes.try_into(), - } - } +impl TryFrom for crate::types::SidechainDeclaration { + type Error = Error; + + fn try_from(decl: SidechainDeclaration) -> Result { + let SidechainDeclaration { + sidechain_declaration, + .. + } = decl; + sidechain_declaration + .ok_or_else(|| Error::missing_field::("sidechain_declaration"))? + .try_into() } +} - impl TryFrom for M4AckBundles { - type Error = super::Error; - - fn try_from( - ack_bundles: get_coinbase_psbt_request::AckBundles, - ) -> Result { - use get_coinbase_psbt_request::AckBundles; - let AckBundles { ack_bundles } = ack_bundles; - ack_bundles - .ok_or_else(|| Self::Error::missing_field::("ack_bundles"))? - .try_into() +impl From for Network { + fn from(network: bitcoin::Network) -> Self { + match network { + bitcoin::Network::Bitcoin => Network::NETWORK_MAINNET, + bitcoin::Network::Regtest => Network::NETWORK_REGTEST, + bitcoin::Network::Signet => Network::NETWORK_SIGNET, + bitcoin::Network::Testnet => Network::NETWORK_TESTNET, + bitcoin::Network::Testnet4 => Network::NETWORK_TESTNET, } } +} - impl TryFrom for CoinbaseMessage { - type Error = super::Error; +impl TryFrom for M1ProposeSidechain { + type Error = Error; + + fn try_from(propose: get_coinbase_psbt_request::ProposeSidechain) -> Result { + use get_coinbase_psbt_request::ProposeSidechain; + let ProposeSidechain { + sidechain_number, + data, + .. + } = propose; + let sidechain_number: SidechainNumber = { + let n = unwrap_u32(sidechain_number) + .ok_or_else(|| Error::missing_field::("sidechain_number"))?; + n.try_into().map_err(|err| { + Error::invalid_field_value::( + "sidechain_number", + &n.to_string(), + err, + ) + })? + }; + let description: Vec = data + .into_option() + .ok_or_else(|| Error::missing_field::("data"))? + .decode::("data")?; + Ok(M1ProposeSidechain { + sidechain_number, + description: description.into(), + }) + } +} - fn try_from( - ack_bundles: get_coinbase_psbt_request::AckBundles, - ) -> Result { - ack_bundles.try_into().map(Self::M4AckBundles) - } +impl TryFrom for M2AckSidechain { + type Error = Error; + + fn try_from(ack: get_coinbase_psbt_request::AckSidechain) -> Result { + use get_coinbase_psbt_request::AckSidechain; + let AckSidechain { + sidechain_number, + data_hash, + .. + } = ack; + let sidechain_number: SidechainNumber = { + let n = unwrap_u32(sidechain_number) + .ok_or_else(|| Error::missing_field::("sidechain_number"))?; + n.try_into().map_err(|err| { + Error::invalid_field_value::( + "sidechain_number", + &n.to_string(), + err, + ) + })? + }; + let description_hash = data_hash + .into_option() + .ok_or_else(|| Error::missing_field::("data_hash"))? + .decode::("data_hash")?; + Ok(M2AckSidechain { + sidechain_number, + description_hash, + }) } +} - impl From for BlockHeaderInfo { - fn from(header_info: crate::types::HeaderInfo) -> Self { - Self { - block_hash: Some(ReverseHex::encode(&header_info.block_hash)), - prev_block_hash: Some(ReverseHex::encode(&header_info.prev_block_hash)), - height: header_info.height, - work: Some(ConsensusHex::encode(&header_info.work.to_le_bytes())), - timestamp: header_info.timestamp as u64, - } - } +impl TryFrom for M3ProposeBundle { + type Error = Error; + + fn try_from(propose: get_coinbase_psbt_request::ProposeBundle) -> Result { + use get_coinbase_psbt_request::ProposeBundle; + let ProposeBundle { + sidechain_number, + bundle_txid, + .. + } = propose; + let sidechain_number: SidechainNumber = { + let n = unwrap_u32(sidechain_number) + .ok_or_else(|| Error::missing_field::("sidechain_number"))?; + n.try_into().map_err(|err| { + Error::invalid_field_value::( + "sidechain_number", + &n.to_string(), + err, + ) + })? + }; + let bundle_txid: [u8; 32] = bundle_txid + .into_option() + .ok_or_else(|| Error::missing_field::("bundle_txid"))? + .decode::("bundle_txid")?; + Ok(M3ProposeBundle { + sidechain_number, + bundle_txid, + }) } +} - impl From<&crate::types::Deposit> for (SidechainNumber, Deposit) { - fn from(deposit: &crate::types::Deposit) -> Self { - let crate::types::Deposit { - sidechain_id, - sequence_number, - outpoint, - address, - value, - } = deposit; - let output = deposit::Output { - address: Some(Hex::encode(&address)), - value_sats: Some(value.to_sat()), - }; - let deposit = Deposit { - sequence_number: Some(*sequence_number), - outpoint: Some(outpoint.into()), - output: Some(output), - }; - (*sidechain_id, deposit) - } +impl From for M4AckBundles { + fn from(_: get_coinbase_psbt_request::ack_bundles::RepeatPrevious) -> Self { + Self::RepeatPrevious } +} - impl From for withdrawal_bundle_event::event::Event { - fn from(failed: withdrawal_bundle_event::event::Failed) -> Self { - Self::Failed(failed) - } +impl From for M4AckBundles { + fn from(_: get_coinbase_psbt_request::ack_bundles::LeadingBy50) -> Self { + Self::LeadingBy50 } +} - impl From for withdrawal_bundle_event::event::Event { - fn from(submitted: withdrawal_bundle_event::event::Submitted) -> Self { - Self::Submitted(submitted) +impl TryFrom for M4AckBundles { + type Error = Error; + + fn try_from( + upvotes: get_coinbase_psbt_request::ack_bundles::Upvotes, + ) -> Result { + use get_coinbase_psbt_request::ack_bundles::Upvotes; + let Upvotes { upvotes: vals, .. } = upvotes; + let mut two_bytes = false; + for upvote in &vals { + if *upvote > u16::MAX as u32 { + return Err(Error::invalid_repeated_value::( + "upvotes", + &upvote.to_string(), + )); + } else if *upvote > u8::MAX as u32 { + two_bytes = true; + } + } + if two_bytes { + Ok(Self::TwoBytes { + upvotes: vals.into_iter().map(|u| u as u16).collect(), + }) + } else { + Ok(Self::OneByte { + upvotes: vals.into_iter().map(|u| u as u8).collect(), + }) } } +} - impl From for withdrawal_bundle_event::event::Event { - fn from(succeeded: withdrawal_bundle_event::event::Succeeded) -> Self { - Self::Succeeded(succeeded) +impl TryFrom for M4AckBundles { + type Error = Error; + + fn try_from( + ack: get_coinbase_psbt_request::ack_bundles::AckBundles, + ) -> Result { + use get_coinbase_psbt_request::ack_bundles::AckBundles; + match ack { + AckBundles::LeadingBy50(v) => Ok((*v).into()), + AckBundles::RepeatPrevious(v) => Ok((*v).into()), + AckBundles::Upvotes(v) => (*v).try_into(), } } +} - impl From<&crate::types::WithdrawalBundleEventKind> for withdrawal_bundle_event::event::Event { - fn from(event_kind: &crate::types::WithdrawalBundleEventKind) -> Self { - use withdrawal_bundle_event::event::{Failed, Submitted, Succeeded}; +impl TryFrom for M4AckBundles { + type Error = Error; - use crate::types::WithdrawalBundleEventKind; - match event_kind { - WithdrawalBundleEventKind::Failed => Self::from(Failed {}), - WithdrawalBundleEventKind::Submitted => Self::from(Submitted {}), - WithdrawalBundleEventKind::Succeeded { - sequence_number, - transaction, - } => Self::from(Succeeded { - sequence_number: Some(*sequence_number), - transaction: Some(ConsensusHex::encode(transaction)), - }), - } - } + fn try_from(ack: get_coinbase_psbt_request::AckBundles) -> Result { + use get_coinbase_psbt_request::AckBundles; + let AckBundles { ack_bundles, .. } = ack; + ack_bundles + .ok_or_else(|| Error::missing_field::("ack_bundles"))? + .try_into() } +} - impl From<&crate::types::WithdrawalBundleEventKind> for withdrawal_bundle_event::Event { - fn from(event_kind: &crate::types::WithdrawalBundleEventKind) -> Self { - Self { - event: Some(event_kind.into()), - } - } +impl TryFrom for CoinbaseMessage { + type Error = Error; + + fn try_from(ack: get_coinbase_psbt_request::AckBundles) -> Result { + ack.try_into().map(Self::M4AckBundles) } +} - impl From<&crate::types::WithdrawalBundleEvent> for (SidechainNumber, WithdrawalBundleEvent) { - fn from(event: &crate::types::WithdrawalBundleEvent) -> Self { - let sidechain_number = event.sidechain_id; - let event = WithdrawalBundleEvent { - m6id: Some(ConsensusHex::encode(&event.m6id.0)), - event: Some((&event.kind).into()), - }; - (sidechain_number, event) +impl From for BlockHeaderInfo { + fn from(info: crate::types::HeaderInfo) -> Self { + Self { + block_hash: MessageField::some(ReverseHex::encode(&info.block_hash)), + prev_block_hash: MessageField::some(ReverseHex::encode(&info.prev_block_hash)), + height: info.height, + work: MessageField::some(ConsensusHex::encode(&info.work.to_le_bytes())), + timestamp: info.timestamp as u64, } } +} - impl From<&crate::types::BlockEvent> for Option<(SidechainNumber, block_info::event::Event)> { - fn from( - event: &crate::types::BlockEvent, - ) -> Option<(SidechainNumber, block_info::event::Event)> { - use crate::types::BlockEvent; - match event { - BlockEvent::Deposit(deposit) => { - let (sidechain_number, deposit) = deposit.into(); - Some((sidechain_number, block_info::event::Event::Deposit(deposit))) - } - BlockEvent::SidechainProposal { .. } => None, - BlockEvent::WithdrawalBundle(bundle_event) => { - let (sidechain_number, bundle_event) = bundle_event.into(); - Some(( - sidechain_number, - block_info::event::Event::WithdrawalBundle(bundle_event), - )) - } - } - } +impl From<&crate::types::Deposit> for (SidechainNumber, Deposit) { + fn from(d: &crate::types::Deposit) -> Self { + let crate::types::Deposit { + sidechain_id, + sequence_number, + outpoint, + address, + value, + } = d; + let output = deposit::Output { + address: MessageField::some(Hex::encode(&address)), + value_sats: wrap_u64(value.to_sat()), + }; + let deposit = Deposit { + sequence_number: wrap_u64(*sequence_number), + outpoint: MessageField::some(outpoint.into()), + output: MessageField::some(output), + }; + (*sidechain_id, deposit) } +} - impl From<&crate::types::BlockEvent> for Option<(SidechainNumber, block_info::Event)> { - fn from(event: &crate::types::BlockEvent) -> Self { - let (sidechain_number, event) = Option::<_>::from(event)?; - Some((sidechain_number, block_info::Event { event: Some(event) })) +impl From<&crate::types::WithdrawalBundleEventKind> for withdrawal_bundle_event::event::Event { + fn from(kind: &crate::types::WithdrawalBundleEventKind) -> Self { + use withdrawal_bundle_event::event::Succeeded; + + use crate::types::WithdrawalBundleEventKind as K; + match kind { + K::Failed => Self::Failed(Box::default()), + K::Submitted => Self::Submitted(Box::default()), + K::Succeeded { + sequence_number, + transaction, + } => Self::Succeeded(Box::new(Succeeded { + sequence_number: wrap_u64(*sequence_number), + transaction: MessageField::some(ConsensusHex::encode(transaction)), + })), } } +} - impl From<&crate::types::SidechainBlockInfo> for BlockInfo - where - E: std::borrow::Borrow, - { - fn from(block_info: &crate::types::SidechainBlockInfo) -> Self { - let bmm_commitment = block_info.bmm_commitment.as_ref().map(ConsensusHex::encode); - let events = block_info - .events - .iter() - .filter_map(|event| { - let (_event_sidechain_number, event) = Option::<_>::from(event.borrow())?; - Some(event) - }) - .collect(); - Self { - bmm_commitment, - events, - } +impl From<&crate::types::WithdrawalBundleEventKind> for withdrawal_bundle_event::Event { + fn from(kind: &crate::types::WithdrawalBundleEventKind) -> Self { + Self { + event: Some(kind.into()), } } +} - impl crate::types::BlockInfo { - pub fn as_proto(&self, sidechain_number: SidechainNumber) -> BlockInfo { - (&self.only_sidechain(sidechain_number)).into() - } +impl From<&crate::types::WithdrawalBundleEvent> for (SidechainNumber, WithdrawalBundleEvent) { + fn from(event: &crate::types::WithdrawalBundleEvent) -> Self { + let proto = WithdrawalBundleEvent { + m6id: MessageField::some(ConsensusHex::encode(&event.m6id.0)), + event: MessageField::some((&event.kind).into()), + }; + (event.sidechain_id, proto) } +} - impl crate::types::TwoWayPegData { - pub fn into_proto( - self, - sidechain_number: SidechainNumber, - ) -> Option { - let Self { - header_info, - block_info, - } = self; - let block_info = block_info.as_proto(sidechain_number); - if block_info == BlockInfo::default() { - None - } else { - Some(get_two_way_peg_data_response::ResponseItem { - block_header_info: Some(header_info.into()), - block_info: Some(block_info), - }) +impl From<&crate::types::BlockEvent> for Option<(SidechainNumber, block_info::event::Event)> { + fn from(event: &crate::types::BlockEvent) -> Self { + use crate::types::BlockEvent; + match event { + BlockEvent::Deposit(d) => { + let (n, deposit) = d.into(); + Some((n, block_info::event::Event::Deposit(Box::new(deposit)))) + } + BlockEvent::SidechainProposal { .. } => None, + BlockEvent::WithdrawalBundle(b) => { + let (n, bundle) = b.into(); + Some(( + n, + block_info::event::Event::WithdrawalBundle(Box::new(bundle)), + )) } } } +} - impl crate::types::Event { - pub fn into_proto( - self, - sidechain_number: SidechainNumber, - ) -> subscribe_events_response::event::Event { - match self { - Self::ConnectBlock { - header_info, - block_info, - } => { - let event = ConnectBlock { - header_info: Some(header_info.into()), - block_info: Some(block_info.as_proto(sidechain_number)), - }; - subscribe_events_response::event::Event::ConnectBlock(event) - } - Self::DisconnectBlock { block_hash } => { - let event = DisconnectBlock { - block_hash: Some(ReverseHex::encode(&block_hash)), - }; - subscribe_events_response::event::Event::DisconnectBlock(event) - } - } - } +impl From<&crate::types::BlockEvent> for Option<(SidechainNumber, block_info::Event)> { + fn from(event: &crate::types::BlockEvent) -> Self { + let (n, ev) = Option::<_>::from(event)?; + Some((n, block_info::Event { event: Some(ev) })) } +} - impl From for subscribe_events_response::Event { - fn from(event: subscribe_events_response::event::Event) -> Self { - Self { event: Some(event) } +impl From<&crate::types::SidechainBlockInfo> for BlockInfo +where + E: std::borrow::Borrow, +{ + fn from(info: &crate::types::SidechainBlockInfo) -> Self { + let bmm_commitment = info + .bmm_commitment + .as_ref() + .map(ConsensusHex::encode) + .map(MessageField::some) + .unwrap_or_default(); + let events = info + .events + .iter() + .filter_map(|ev| { + let (_, ev) = Option::<_>::from(ev.borrow())?; + Some(ev) + }) + .collect(); + Self { + bmm_commitment, + events, } } +} - impl From for get_sidechains_response::SidechainInfo { - fn from(sidechain: crate::types::Sidechain) -> Self { - use crate::types::SidechainDeclaration; - let decl = SidechainDeclaration::try_from(&sidechain.proposal.description).ok(); - - Self { - sidechain_number: Some(sidechain.proposal.sidechain_number.0 as u32), - description: Some(ConsensusHex::encode(&sidechain.proposal.description.0)), - vote_count: Some(sidechain.status.vote_count as u32), - proposal_height: Some(sidechain.status.proposal_height), - activation_height: sidechain.status.activation_height, - declaration: decl.map(|decl| decl.into()), - } - } +impl crate::types::BlockInfo { + pub fn as_proto(&self, sidechain_number: SidechainNumber) -> BlockInfo { + (&self.only_sidechain(sidechain_number)).into() } +} - impl From<&bdk_wallet::chain::ChainPosition> - for wallet_transaction::Confirmation - { - fn from( - chain_position: &bdk_wallet::chain::ChainPosition< - bdk_wallet::chain::ConfirmationBlockTime, - >, - ) -> Self { - match chain_position { - bdk_wallet::chain::ChainPosition::Confirmed { - anchor: conf_block_time, - transitively: _, - } => Self { - height: conf_block_time.block_id.height, - block_hash: Some(ReverseHex::encode(&conf_block_time.block_id.hash)), - timestamp: Some(prost_types::Timestamp { - seconds: conf_block_time.confirmation_time as i64, - nanos: 0, - }), - }, - bdk_wallet::chain::ChainPosition::Unconfirmed { - last_seen, - first_seen: _, - } => { - let timestamp = last_seen.map(|last_seen| prost_types::Timestamp { - seconds: last_seen as i64, - nanos: 0, - }); - Self { - height: 0, - block_hash: None, - timestamp, - } - } - } +impl crate::types::TwoWayPegData { + pub fn into_proto( + self, + sidechain_number: SidechainNumber, + ) -> Option { + let Self { + header_info, + block_info, + } = self; + let block_info = block_info.as_proto(sidechain_number); + if block_info == BlockInfo::default() { + None + } else { + Some(get_two_way_peg_data_response::ResponseItem { + block_header_info: MessageField::some(header_info.into()), + block_info: MessageField::some(block_info), + }) } } +} - impl From<&crate::types::BDKWalletTransaction> for WalletTransaction { - fn from(tx: &crate::types::BDKWalletTransaction) -> Self { - Self { - txid: Some(ReverseHex::encode(&tx.txid)), - raw_transaction: Some(ConsensusHex::encode(&tx.tx)), - fee_sats: tx.fee.to_sat(), - received_sats: tx.received.to_sat(), - sent_sats: tx.sent.to_sat(), - confirmation_info: Some((&tx.chain_position).into()), +impl crate::types::Event { + pub fn into_proto( + self, + sidechain_number: SidechainNumber, + ) -> subscribe_events_response::event::Event { + use subscribe_events_response::event::{ConnectBlock, DisconnectBlock}; + match self { + Self::ConnectBlock { + header_info, + block_info, + } => { + let cb = ConnectBlock { + header_info: MessageField::some(header_info.into()), + block_info: MessageField::some(block_info.as_proto(sidechain_number)), + }; + subscribe_events_response::event::Event::ConnectBlock(Box::new(cb)) + } + Self::DisconnectBlock { block_hash } => { + let db = DisconnectBlock { + block_hash: MessageField::some(ReverseHex::encode(&block_hash)), + }; + subscribe_events_response::event::Event::DisconnectBlock(Box::new(db)) } } } +} - #[derive(Debug, thiserror::Error)] - #[error("Invalid sats per vbyte")] - pub struct InvalidSatsPerVbyte { - pub sats_per_vbyte: u64, +impl From for subscribe_events_response::Event { + fn from(ev: subscribe_events_response::event::Event) -> Self { + Self { event: Some(ev) } } +} - impl TryFrom for crate::types::FeePolicy { - type Error = InvalidSatsPerVbyte; +impl From for get_sidechains_response::SidechainInfo { + fn from(sc: crate::types::Sidechain) -> Self { + let decl = crate::types::SidechainDeclaration::try_from(&sc.proposal.description).ok(); - fn try_from(fee: send_transaction_request::fee_rate::Fee) -> Result { - use send_transaction_request::fee_rate::Fee; - match fee { - Fee::SatPerVbyte(sats_per_vbyte) => { - let rate = bitcoin::FeeRate::from_sat_per_vb(sats_per_vbyte) - .ok_or(InvalidSatsPerVbyte { sats_per_vbyte })?; - Ok(rate.into()) - } - Fee::Sats(sats) => { - let amount = bitcoin::Amount::from_sat(sats); - Ok(amount.into()) - } - } + Self { + sidechain_number: wrap_u32(sc.proposal.sidechain_number.0 as u32), + description: MessageField::some(ConsensusHex::encode(&sc.proposal.description.0)), + vote_count: wrap_u32(sc.status.vote_count as u32), + proposal_height: wrap_u32(sc.status.proposal_height), + activation_height: sc + .status + .activation_height + .map(wrap_u32) + .unwrap_or_default(), + declaration: decl + .map(|d| MessageField::some(SidechainDeclaration::from(d))) + .unwrap_or_default(), } } +} - impl TryFrom for crate::types::FeePolicy { - type Error = super::Error; - - fn try_from(fee_rate: send_transaction_request::FeeRate) -> Result { - use send_transaction_request::FeeRate; - let FeeRate { fee } = fee_rate; - fee.ok_or_else(|| Self::Error::missing_field::("fee"))? - .try_into() - .map_err(|err: InvalidSatsPerVbyte| { - Self::Error::invalid_field_value::( - "fee", - &err.sats_per_vbyte.to_string(), - err, - ) - }) +impl From<&bdk_wallet::chain::ChainPosition> + for wallet_transaction::Confirmation +{ + fn from( + chain_position: &bdk_wallet::chain::ChainPosition, + ) -> Self { + match chain_position { + bdk_wallet::chain::ChainPosition::Confirmed { + anchor: conf, + transitively: _, + } => Self { + height: conf.block_id.height, + block_hash: MessageField::some(ReverseHex::encode(&conf.block_id.hash)), + timestamp: wrap_timestamp(conf.confirmation_time as i64), + }, + bdk_wallet::chain::ChainPosition::Unconfirmed { + last_seen, + first_seen: _, + } => Self { + height: 0, + block_hash: MessageField::none(), + timestamp: last_seen + .map(|s| wrap_timestamp(s as i64)) + .unwrap_or_default(), + }, } } +} - #[derive(Copy, Clone, Debug)] - pub struct HeaderSyncProgress { - pub current_height: Option, +impl From<&crate::types::BDKWalletTransaction> for mainchain::WalletTransaction { + fn from(tx: &crate::types::BDKWalletTransaction) -> Self { + Self { + txid: MessageField::some(ReverseHex::encode(&tx.txid)), + raw_transaction: MessageField::some(ConsensusHex::encode(&tx.tx)), + fee_sats: tx.fee.to_sat(), + received_sats: tx.received.to_sat(), + sent_sats: tx.sent.to_sat(), + confirmation_info: MessageField::some((&tx.chain_position).into()), + } } +} - impl From for SubscribeHeaderSyncProgressResponse { - fn from(progress: HeaderSyncProgress) -> Self { - Self { - current_height: progress.current_height, +#[derive(Debug, thiserror::Error)] +#[error("Invalid sats per vbyte")] +pub struct InvalidSatsPerVbyte { + pub sats_per_vbyte: u64, +} + +impl TryFrom for crate::types::FeePolicy { + type Error = InvalidSatsPerVbyte; + + fn try_from(fee: send_transaction_request::fee_rate::Fee) -> Result { + use send_transaction_request::fee_rate::Fee; + match fee { + Fee::SatPerVbyte(sats_per_vbyte) => { + let rate = bitcoin::FeeRate::from_sat_per_vb(sats_per_vbyte) + .ok_or(InvalidSatsPerVbyte { sats_per_vbyte })?; + Ok(rate.into()) + } + Fee::Sats(sats) => { + let amount = bitcoin::Amount::from_sat(sats); + Ok(amount.into()) } } } } -#[expect(clippy::allow_attributes, reason = "generated code uses #[allow]")] -pub mod sidechain { - tonic::include_proto!("cusf.sidechain.v1"); +impl TryFrom for crate::types::FeePolicy { + type Error = Error; + + fn try_from(fee_rate: send_transaction_request::FeeRate) -> Result { + use send_transaction_request::FeeRate; + let FeeRate { fee, .. } = fee_rate; + fee.ok_or_else(|| Error::missing_field::("fee"))? + .try_into() + .map_err(|err: InvalidSatsPerVbyte| { + Error::invalid_field_value::( + "fee", + &err.sats_per_vbyte.to_string(), + err, + ) + }) + } } diff --git a/lib/proto/generated/buffa/cusf.common.v1.rs b/lib/proto/generated/buffa/cusf.common.v1.rs new file mode 100644 index 00000000..5f3e1c71 --- /dev/null +++ b/lib/proto/generated/buffa/cusf.common.v1.rs @@ -0,0 +1,1029 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +/// / Consensus-encoded hex. +/// / Variable length data uses a length prefix. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ConsensusHex { + /// Field 1: `hex` + #[serde( + rename = "hex", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hex: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, +} +impl ::core::fmt::Debug for ConsensusHex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConsensusHex").field("hex", &self.hex).finish() + } +} +impl ConsensusHex { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ConsensusHex"; +} +impl ::buffa::DefaultInstance for ConsensusHex { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ConsensusHex { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "ConsensusHex"; + const FULL_NAME: &'static str = "cusf.common.v1.ConsensusHex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ConsensusHex"; +} +impl ::buffa::Message for ConsensusHex { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hex.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.hex = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ConsensusHex { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CONSENSUS_HEX_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.common.v1.ConsensusHex", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// / Hex encoding of byte arrays/vectors. +/// / Length prefixes are not used. +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Hex { + /// Field 1: `hex` + #[serde( + rename = "hex", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hex: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, +} +impl ::core::fmt::Debug for Hex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Hex").field("hex", &self.hex).finish() + } +} +impl Hex { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.Hex"; +} +impl ::buffa::DefaultInstance for Hex { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Hex { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "Hex"; + const FULL_NAME: &'static str = "cusf.common.v1.Hex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.Hex"; +} +impl ::buffa::Message for Hex { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hex.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.hex = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Hex { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HEX_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.common.v1.Hex", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +/// / Reverse consensus-encoded hex +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ReverseHex { + /// Field 1: `hex` + #[serde( + rename = "hex", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hex: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, +} +impl ::core::fmt::Debug for ReverseHex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ReverseHex").field("hex", &self.hex).finish() + } +} +impl ReverseHex { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ReverseHex"; +} +impl ::buffa::DefaultInstance for ReverseHex { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ReverseHex { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "ReverseHex"; + const FULL_NAME: &'static str = "cusf.common.v1.ReverseHex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ReverseHex"; +} +impl ::buffa::Message for ReverseHex { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hex.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.hex = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ReverseHex { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __REVERSE_HEX_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.common.v1.ReverseHex", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + /// / Consensus-encoded hex. + /// / Variable length data uses a length prefix. + #[derive(Clone, Debug, Default)] + pub struct ConsensusHexView<'a> { + /// Field 1: `hex` + pub hex: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + } + impl<'a> ConsensusHexView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hex.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hex = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ConsensusHexView<'a> { + type Owned = super::super::ConsensusHex; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ConsensusHex { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ConsensusHex { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ConsensusHex { + hex: match self.hex.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ConsensusHexView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ConsensusHexView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.hex.as_option() { + __map.serialize_entry("hex", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ConsensusHexView<'a> { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "ConsensusHex"; + const FULL_NAME: &'static str = "cusf.common.v1.ConsensusHex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ConsensusHex"; + } + impl<'v> ::buffa::DefaultViewInstance for ConsensusHexView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ConsensusHexView<'static> { + type Reborrowed<'b> = ConsensusHexView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + /// / Hex encoding of byte arrays/vectors. + /// / Length prefixes are not used. + #[derive(Clone, Debug, Default)] + pub struct HexView<'a> { + /// Field 1: `hex` + pub hex: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + } + impl<'a> HexView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hex.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hex = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for HexView<'a> { + type Owned = super::super::Hex; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Hex { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Hex { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Hex { + hex: match self.hex.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for HexView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for HexView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.hex.as_option() { + __map.serialize_entry("hex", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for HexView<'a> { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "Hex"; + const FULL_NAME: &'static str = "cusf.common.v1.Hex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.Hex"; + } + impl<'v> ::buffa::DefaultViewInstance for HexView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for HexView<'static> { + type Reborrowed<'b> = HexView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + /// / Reverse consensus-encoded hex + #[derive(Clone, Debug, Default)] + pub struct ReverseHexView<'a> { + /// Field 1: `hex` + pub hex: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + } + impl<'a> ReverseHexView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hex.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hex = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ReverseHexView<'a> { + type Owned = super::super::ReverseHex; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ReverseHex { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ReverseHex { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ReverseHex { + hex: match self.hex.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ReverseHexView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hex.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hex.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hex.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hex.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ReverseHexView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.hex.as_option() { + __map.serialize_entry("hex", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ReverseHexView<'a> { + const PACKAGE: &'static str = "cusf.common.v1"; + const NAME: &'static str = "ReverseHex"; + const FULL_NAME: &'static str = "cusf.common.v1.ReverseHex"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.common.v1.ReverseHex"; + } + impl<'v> ::buffa::DefaultViewInstance for ReverseHexView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ReverseHexView<'static> { + type Reborrowed<'b> = ReverseHexView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__CONSENSUS_HEX_JSON_ANY); + reg.register_json_any(super::__HEX_JSON_ANY); + reg.register_json_any(super::__REVERSE_HEX_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::ConsensusHexView; +#[doc(inline)] +pub use self::__buffa::view::HexView; +#[doc(inline)] +pub use self::__buffa::view::ReverseHexView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/lib/proto/generated/buffa/cusf.crypto.v1.rs b/lib/proto/generated/buffa/cusf.crypto.v1.rs new file mode 100644 index 00000000..2abf961f --- /dev/null +++ b/lib/proto/generated/buffa/cusf.crypto.v1.rs @@ -0,0 +1,3775 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct HmacSha512Request { + /// Field 1: `key` + #[serde( + rename = "key", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub key: ::buffa::MessageField, + /// Field 2: `msg` + #[serde( + rename = "msg", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub msg: ::buffa::MessageField, +} +impl ::core::fmt::Debug for HmacSha512Request { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HmacSha512Request") + .field("key", &self.key) + .field("msg", &self.msg) + .finish() + } +} +impl HmacSha512Request { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Request"; +} +impl ::buffa::DefaultInstance for HmacSha512Request { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for HmacSha512Request { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "HmacSha512Request"; + const FULL_NAME: &'static str = "cusf.crypto.v1.HmacSha512Request"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Request"; +} +impl ::buffa::Message for HmacSha512Request { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.msg.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.msg.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.key.write_to(__cache, buf); + } + if self.msg.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.msg.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.key.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.msg.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.key = ::buffa::MessageField::none(); + self.msg = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for HmacSha512Request { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HMAC_SHA512REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.HmacSha512Request", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct HmacSha512Response { + /// Field 1: `hmac` + #[serde( + rename = "hmac", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hmac: ::buffa::MessageField, +} +impl ::core::fmt::Debug for HmacSha512Response { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HmacSha512Response").field("hmac", &self.hmac).finish() + } +} +impl HmacSha512Response { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Response"; +} +impl ::buffa::DefaultInstance for HmacSha512Response { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for HmacSha512Response { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "HmacSha512Response"; + const FULL_NAME: &'static str = "cusf.crypto.v1.HmacSha512Response"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Response"; +} +impl ::buffa::Message for HmacSha512Response { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hmac.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hmac.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hmac.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hmac.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hmac.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.hmac = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for HmacSha512Response { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __HMAC_SHA512RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.HmacSha512Response", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Ripemd160Request { + /// Field 1: `msg` + #[serde( + rename = "msg", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub msg: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Ripemd160Request { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ripemd160Request").field("msg", &self.msg).finish() + } +} +impl Ripemd160Request { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Request"; +} +impl ::buffa::DefaultInstance for Ripemd160Request { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Ripemd160Request { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Ripemd160Request"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Ripemd160Request"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Request"; +} +impl ::buffa::Message for Ripemd160Request { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.msg.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.msg.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.msg.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.msg.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.msg.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.msg = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Ripemd160Request { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RIPEMD160REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Ripemd160Request", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Ripemd160Response { + /// Field 1: `digest` + #[serde( + rename = "digest", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub digest: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Ripemd160Response { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ripemd160Response").field("digest", &self.digest).finish() + } +} +impl Ripemd160Response { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Response"; +} +impl ::buffa::DefaultInstance for Ripemd160Response { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Ripemd160Response { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Ripemd160Response"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Ripemd160Response"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Response"; +} +impl ::buffa::Message for Ripemd160Response { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.digest.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.digest.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.digest.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.digest = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Ripemd160Response { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __RIPEMD160RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Ripemd160Response", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1SecretKeyToPublicKeyRequest { + /// Field 1: `secret_key` + #[serde( + rename = "secretKey", + alias = "secret_key", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub secret_key: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Secp256k1SecretKeyToPublicKeyRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1SecretKeyToPublicKeyRequest") + .field("secret_key", &self.secret_key) + .finish() + } +} +impl Secp256k1SecretKeyToPublicKeyRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest"; +} +impl ::buffa::DefaultInstance for Secp256k1SecretKeyToPublicKeyRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SecretKeyToPublicKeyRequest, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1SecretKeyToPublicKeyRequest { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SecretKeyToPublicKeyRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest"; +} +impl ::buffa::Message for Secp256k1SecretKeyToPublicKeyRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.secret_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.secret_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.secret_key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.secret_key.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.secret_key.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.secret_key = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1SecretKeyToPublicKeyRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1SECRET_KEY_TO_PUBLIC_KEY_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::< + Secp256k1SecretKeyToPublicKeyRequest, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1SecretKeyToPublicKeyResponse { + /// Field 1: `public_key` + #[serde( + rename = "publicKey", + alias = "public_key", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub public_key: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Secp256k1SecretKeyToPublicKeyResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1SecretKeyToPublicKeyResponse") + .field("public_key", &self.public_key) + .finish() + } +} +impl Secp256k1SecretKeyToPublicKeyResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse"; +} +impl ::buffa::DefaultInstance for Secp256k1SecretKeyToPublicKeyResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SecretKeyToPublicKeyResponse, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1SecretKeyToPublicKeyResponse { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SecretKeyToPublicKeyResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse"; +} +impl ::buffa::Message for Secp256k1SecretKeyToPublicKeyResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.public_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.public_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.public_key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.public_key.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.public_key.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.public_key = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1SecretKeyToPublicKeyResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1SECRET_KEY_TO_PUBLIC_KEY_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse", + to_json: ::buffa::type_registry::any_to_json::< + Secp256k1SecretKeyToPublicKeyResponse, + >, + from_json: ::buffa::type_registry::any_from_json::< + Secp256k1SecretKeyToPublicKeyResponse, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1SignRequest { + /// Field 1: `message` + #[serde( + rename = "message", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub message: ::buffa::MessageField, + /// Field 2: `secret_key` + #[serde( + rename = "secretKey", + alias = "secret_key", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub secret_key: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Secp256k1SignRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1SignRequest") + .field("message", &self.message) + .field("secret_key", &self.secret_key) + .finish() + } +} +impl Secp256k1SignRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignRequest"; +} +impl ::buffa::DefaultInstance for Secp256k1SignRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1SignRequest { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SignRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SignRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignRequest"; +} +impl ::buffa::Message for Secp256k1SignRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.secret_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.secret_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.message.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.message.write_to(__cache, buf); + } + if self.secret_key.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.secret_key.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.message.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.secret_key.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.message = ::buffa::MessageField::none(); + self.secret_key = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1SignRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1SIGN_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1SignRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1SignResponse { + /// Field 1: `signature` + #[serde( + rename = "signature", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub signature: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Secp256k1SignResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1SignResponse") + .field("signature", &self.signature) + .finish() + } +} +impl Secp256k1SignResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignResponse"; +} +impl ::buffa::DefaultInstance for Secp256k1SignResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1SignResponse { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SignResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SignResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignResponse"; +} +impl ::buffa::Message for Secp256k1SignResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.signature.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.signature.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.signature.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.signature.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.signature.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.signature = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1SignResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1SIGN_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1SignResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1VerifyRequest { + /// Field 1: `message` + #[serde( + rename = "message", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub message: ::buffa::MessageField, + /// Field 2: `signature` + #[serde( + rename = "signature", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub signature: ::buffa::MessageField, + /// Field 3: `public_key` + #[serde( + rename = "publicKey", + alias = "public_key", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub public_key: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Secp256k1VerifyRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1VerifyRequest") + .field("message", &self.message) + .field("signature", &self.signature) + .field("public_key", &self.public_key) + .finish() + } +} +impl Secp256k1VerifyRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyRequest"; +} +impl ::buffa::DefaultInstance for Secp256k1VerifyRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1VerifyRequest { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1VerifyRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1VerifyRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyRequest"; +} +impl ::buffa::Message for Secp256k1VerifyRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.signature.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.signature.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.public_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.public_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.message.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.message.write_to(__cache, buf); + } + if self.signature.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.signature.write_to(__cache, buf); + } + if self.public_key.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.public_key.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.message.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.signature.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.public_key.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.message = ::buffa::MessageField::none(); + self.signature = ::buffa::MessageField::none(); + self.public_key = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1VerifyRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1VERIFY_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Secp256k1VerifyResponse { + /// Field 1: `valid` + #[serde( + rename = "valid", + with = "::buffa::json_helpers::proto_bool", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_false" + )] + pub valid: bool, +} +impl ::core::fmt::Debug for Secp256k1VerifyResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Secp256k1VerifyResponse").field("valid", &self.valid).finish() + } +} +impl Secp256k1VerifyResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyResponse"; +} +impl ::buffa::DefaultInstance for Secp256k1VerifyResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Secp256k1VerifyResponse { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1VerifyResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1VerifyResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyResponse"; +} +impl ::buffa::Message for Secp256k1VerifyResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.valid { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.valid { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_bool(self.valid, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.valid = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.valid = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for Secp256k1VerifyResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SECP256K1VERIFY_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct HmacSha512RequestView<'a> { + /// Field 1: `key` + pub key: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + /// Field 2: `msg` + pub msg: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + } + impl<'a> HmacSha512RequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.key.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.key = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.msg.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.msg = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for HmacSha512RequestView<'a> { + type Owned = super::super::HmacSha512Request; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::HmacSha512Request { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::HmacSha512Request { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::HmacSha512Request { + key: match self.key.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + msg: match self.msg.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for HmacSha512RequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.msg.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.msg.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.key.write_to(__cache, buf); + } + if self.msg.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.msg.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for HmacSha512RequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.key.as_option() { + __map.serialize_entry("key", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.msg.as_option() { + __map.serialize_entry("msg", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for HmacSha512RequestView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "HmacSha512Request"; + const FULL_NAME: &'static str = "cusf.crypto.v1.HmacSha512Request"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Request"; + } + impl<'v> ::buffa::DefaultViewInstance for HmacSha512RequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + HmacSha512RequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for HmacSha512RequestView<'static> { + type Reborrowed<'b> = HmacSha512RequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct HmacSha512ResponseView<'a> { + /// Field 1: `hmac` + pub hmac: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + } + impl<'a> HmacSha512ResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hmac.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hmac = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for HmacSha512ResponseView<'a> { + type Owned = super::super::HmacSha512Response; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::HmacSha512Response { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::HmacSha512Response { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::HmacSha512Response { + hmac: match self.hmac.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for HmacSha512ResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.hmac.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hmac.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.hmac.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hmac.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for HmacSha512ResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.hmac.as_option() { + __map.serialize_entry("hmac", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for HmacSha512ResponseView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "HmacSha512Response"; + const FULL_NAME: &'static str = "cusf.crypto.v1.HmacSha512Response"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.HmacSha512Response"; + } + impl<'v> ::buffa::DefaultViewInstance for HmacSha512ResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + HmacSha512ResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for HmacSha512ResponseView<'static> { + type Reborrowed<'b> = HmacSha512ResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Ripemd160RequestView<'a> { + /// Field 1: `msg` + pub msg: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + } + impl<'a> Ripemd160RequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.msg.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.msg = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Ripemd160RequestView<'a> { + type Owned = super::super::Ripemd160Request; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Ripemd160Request { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Ripemd160Request { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Ripemd160Request { + msg: match self.msg.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Ripemd160RequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.msg.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.msg.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.msg.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.msg.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Ripemd160RequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.msg.as_option() { + __map.serialize_entry("msg", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Ripemd160RequestView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Ripemd160Request"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Ripemd160Request"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Request"; + } + impl<'v> ::buffa::DefaultViewInstance for Ripemd160RequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Ripemd160RequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Ripemd160RequestView<'static> { + type Reborrowed<'b> = Ripemd160RequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Ripemd160ResponseView<'a> { + /// Field 1: `digest` + pub digest: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + } + impl<'a> Ripemd160ResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.digest.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.digest = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Ripemd160ResponseView<'a> { + type Owned = super::super::Ripemd160Response; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Ripemd160Response { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Ripemd160Response { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Ripemd160Response { + digest: match self.digest.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Ripemd160ResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.digest.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.digest.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.digest.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.digest.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Ripemd160ResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.digest.as_option() { + __map.serialize_entry("digest", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Ripemd160ResponseView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Ripemd160Response"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Ripemd160Response"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Ripemd160Response"; + } + impl<'v> ::buffa::DefaultViewInstance for Ripemd160ResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Ripemd160ResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Ripemd160ResponseView<'static> { + type Reborrowed<'b> = Ripemd160ResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1SecretKeyToPublicKeyRequestView<'a> { + /// Field 1: `secret_key` + pub secret_key: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> Secp256k1SecretKeyToPublicKeyRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.secret_key.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.secret_key = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for Secp256k1SecretKeyToPublicKeyRequestView<'a> { + type Owned = super::super::Secp256k1SecretKeyToPublicKeyRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::Secp256k1SecretKeyToPublicKeyRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1SecretKeyToPublicKeyRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1SecretKeyToPublicKeyRequest { + secret_key: match self.secret_key.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for Secp256k1SecretKeyToPublicKeyRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.secret_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.secret_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.secret_key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.secret_key.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for Secp256k1SecretKeyToPublicKeyRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .secret_key + .as_option() + { + __map.serialize_entry("secretKey", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1SecretKeyToPublicKeyRequestView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SecretKeyToPublicKeyRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for Secp256k1SecretKeyToPublicKeyRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SecretKeyToPublicKeyRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for Secp256k1SecretKeyToPublicKeyRequestView<'static> { + type Reborrowed<'b> = Secp256k1SecretKeyToPublicKeyRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1SecretKeyToPublicKeyResponseView<'a> { + /// Field 1: `public_key` + pub public_key: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> Secp256k1SecretKeyToPublicKeyResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.public_key.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.public_key = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for Secp256k1SecretKeyToPublicKeyResponseView<'a> { + type Owned = super::super::Secp256k1SecretKeyToPublicKeyResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::Secp256k1SecretKeyToPublicKeyResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1SecretKeyToPublicKeyResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1SecretKeyToPublicKeyResponse { + public_key: match self.public_key.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for Secp256k1SecretKeyToPublicKeyResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.public_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.public_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.public_key.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.public_key.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for Secp256k1SecretKeyToPublicKeyResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .public_key + .as_option() + { + __map.serialize_entry("publicKey", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1SecretKeyToPublicKeyResponseView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SecretKeyToPublicKeyResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SecretKeyToPublicKeyResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for Secp256k1SecretKeyToPublicKeyResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SecretKeyToPublicKeyResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for Secp256k1SecretKeyToPublicKeyResponseView<'static> { + type Reborrowed<'b> = Secp256k1SecretKeyToPublicKeyResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1SignRequestView<'a> { + /// Field 1: `message` + pub message: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + /// Field 2: `secret_key` + pub secret_key: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> Secp256k1SignRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.message.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.message = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.secret_key.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.secret_key = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Secp256k1SignRequestView<'a> { + type Owned = super::super::Secp256k1SignRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Secp256k1SignRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1SignRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1SignRequest { + message: match self.message.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + secret_key: match self.secret_key.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Secp256k1SignRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.secret_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.secret_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.message.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.message.write_to(__cache, buf); + } + if self.secret_key.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.secret_key.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Secp256k1SignRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.message.as_option() { + __map.serialize_entry("message", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .secret_key + .as_option() + { + __map.serialize_entry("secretKey", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1SignRequestView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SignRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SignRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for Secp256k1SignRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SignRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Secp256k1SignRequestView<'static> { + type Reborrowed<'b> = Secp256k1SignRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1SignResponseView<'a> { + /// Field 1: `signature` + pub signature: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + } + impl<'a> Secp256k1SignResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.signature.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.signature = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Secp256k1SignResponseView<'a> { + type Owned = super::super::Secp256k1SignResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Secp256k1SignResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1SignResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1SignResponse { + signature: match self.signature.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Secp256k1SignResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.signature.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.signature.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.signature.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.signature.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Secp256k1SignResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.signature.as_option() + { + __map.serialize_entry("signature", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1SignResponseView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1SignResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1SignResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1SignResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for Secp256k1SignResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1SignResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Secp256k1SignResponseView<'static> { + type Reborrowed<'b> = Secp256k1SignResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1VerifyRequestView<'a> { + /// Field 1: `message` + pub message: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + /// Field 2: `signature` + pub signature: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + /// Field 3: `public_key` + pub public_key: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> Secp256k1VerifyRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.message.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.message = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.signature.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.signature = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.public_key.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.public_key = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Secp256k1VerifyRequestView<'a> { + type Owned = super::super::Secp256k1VerifyRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Secp256k1VerifyRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1VerifyRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1VerifyRequest { + message: match self.message.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + signature: match self.signature.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + public_key: match self.public_key.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Secp256k1VerifyRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.signature.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.signature.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.public_key.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.public_key.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.message.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.message.write_to(__cache, buf); + } + if self.signature.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.signature.write_to(__cache, buf); + } + if self.public_key.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.public_key.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Secp256k1VerifyRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.message.as_option() { + __map.serialize_entry("message", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.signature.as_option() + { + __map.serialize_entry("signature", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .public_key + .as_option() + { + __map.serialize_entry("publicKey", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1VerifyRequestView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1VerifyRequest"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1VerifyRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for Secp256k1VerifyRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1VerifyRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Secp256k1VerifyRequestView<'static> { + type Reborrowed<'b> = Secp256k1VerifyRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct Secp256k1VerifyResponseView<'a> { + /// Field 1: `valid` + pub valid: bool, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> Secp256k1VerifyResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.valid = ::buffa::types::decode_bool(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for Secp256k1VerifyResponseView<'a> { + type Owned = super::super::Secp256k1VerifyResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Secp256k1VerifyResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Secp256k1VerifyResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Secp256k1VerifyResponse { + valid: self.valid, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for Secp256k1VerifyResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.valid { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.valid { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_bool(self.valid, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for Secp256k1VerifyResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if self.valid { + __map.serialize_entry("valid", &self.valid)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for Secp256k1VerifyResponseView<'a> { + const PACKAGE: &'static str = "cusf.crypto.v1"; + const NAME: &'static str = "Secp256k1VerifyResponse"; + const FULL_NAME: &'static str = "cusf.crypto.v1.Secp256k1VerifyResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.crypto.v1.Secp256k1VerifyResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for Secp256k1VerifyResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + Secp256k1VerifyResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for Secp256k1VerifyResponseView<'static> { + type Reborrowed<'b> = Secp256k1VerifyResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__HMAC_SHA512REQUEST_JSON_ANY); + reg.register_json_any(super::__HMAC_SHA512RESPONSE_JSON_ANY); + reg.register_json_any(super::__RIPEMD160REQUEST_JSON_ANY); + reg.register_json_any(super::__RIPEMD160RESPONSE_JSON_ANY); + reg.register_json_any( + super::__SECP256K1SECRET_KEY_TO_PUBLIC_KEY_REQUEST_JSON_ANY, + ); + reg.register_json_any( + super::__SECP256K1SECRET_KEY_TO_PUBLIC_KEY_RESPONSE_JSON_ANY, + ); + reg.register_json_any(super::__SECP256K1SIGN_REQUEST_JSON_ANY); + reg.register_json_any(super::__SECP256K1SIGN_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SECP256K1VERIFY_REQUEST_JSON_ANY); + reg.register_json_any(super::__SECP256K1VERIFY_RESPONSE_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::HmacSha512RequestView; +#[doc(inline)] +pub use self::__buffa::view::HmacSha512ResponseView; +#[doc(inline)] +pub use self::__buffa::view::Ripemd160RequestView; +#[doc(inline)] +pub use self::__buffa::view::Ripemd160ResponseView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1SecretKeyToPublicKeyRequestView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1SignRequestView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1SignResponseView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1VerifyRequestView; +#[doc(inline)] +pub use self::__buffa::view::Secp256k1VerifyResponseView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/lib/proto/generated/buffa/cusf.mainchain.v1.rs b/lib/proto/generated/buffa/cusf.mainchain.v1.rs new file mode 100644 index 00000000..bbc746cb --- /dev/null +++ b/lib/proto/generated/buffa/cusf.mainchain.v1.rs @@ -0,0 +1,42197 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct OutPoint { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, + /// Field 2: `vout` + #[serde( + rename = "vout", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub vout: ::buffa::MessageField<::buffa_types::google::protobuf::UInt32Value>, +} +impl ::core::fmt::Debug for OutPoint { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OutPoint") + .field("txid", &self.txid) + .field("vout", &self.vout) + .finish() + } +} +impl OutPoint { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.OutPoint"; +} +impl ::buffa::DefaultInstance for OutPoint { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for OutPoint { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "OutPoint"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.OutPoint"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.OutPoint"; +} +impl ::buffa::Message for OutPoint { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vout.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.vout.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.vout.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.vout.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + self.vout = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for OutPoint { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __OUT_POINT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.OutPoint", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct SidechainDeclaration { + #[serde(flatten)] + pub sidechain_declaration: ::core::option::Option< + __buffa::oneof::sidechain_declaration::SidechainDeclaration, + >, +} +impl ::core::fmt::Debug for SidechainDeclaration { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SidechainDeclaration") + .field("sidechain_declaration", &self.sidechain_declaration) + .finish() + } +} +impl SidechainDeclaration { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration"; +} +impl ::buffa::DefaultInstance for SidechainDeclaration { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SidechainDeclaration { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SidechainDeclaration"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SidechainDeclaration"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration"; +} +impl ::buffa::Message for SidechainDeclaration { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.sidechain_declaration { + match v { + __buffa::oneof::sidechain_declaration::SidechainDeclaration::V0(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.sidechain_declaration { + match v { + __buffa::oneof::sidechain_declaration::SidechainDeclaration::V0(x) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + __buffa::oneof::sidechain_declaration::SidechainDeclaration::V0( + ref mut existing, + ), + ) = self.sidechain_declaration + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.sidechain_declaration = ::core::option::Option::Some( + __buffa::oneof::sidechain_declaration::SidechainDeclaration::V0( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_declaration = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for SidechainDeclaration { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = SidechainDeclaration; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct SidechainDeclaration") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_sidechain_declaration: ::core::option::Option< + __buffa::oneof::sidechain_declaration::SidechainDeclaration, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "v0" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + sidechain_declaration::V0, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_sidechain_declaration.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'sidechain_declaration'", + ), + ); + } + __oneof_sidechain_declaration = Some( + __buffa::oneof::sidechain_declaration::SidechainDeclaration::V0( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.sidechain_declaration = __oneof_sidechain_declaration; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for SidechainDeclaration { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SIDECHAIN_DECLARATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod sidechain_declaration { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct V0 { + /// Field 1: `title` + #[serde( + rename = "title", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub title: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, + /// Field 2: `description` + #[serde( + rename = "description", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub description: ::buffa::MessageField< + ::buffa_types::google::protobuf::StringValue, + >, + /// Field 3: `hash_id_1` + #[serde( + rename = "hashId1", + alias = "hash_id_1", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hash_id_1: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + /// Field 4: `hash_id_2` + #[serde( + rename = "hashId2", + alias = "hash_id_2", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hash_id_2: ::buffa::MessageField, + } + impl ::core::fmt::Debug for V0 { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("V0") + .field("title", &self.title) + .field("description", &self.description) + .field("hash_id_1", &self.hash_id_1) + .field("hash_id_2", &self.hash_id_2) + .finish() + } + } + impl V0 { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration.V0"; + } + impl ::buffa::DefaultInstance for V0 { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for V0 { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SidechainDeclaration.V0"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SidechainDeclaration.V0"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration.V0"; + } + impl ::buffa::Message for V0 { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.title.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.title.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.hash_id_1.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash_id_1.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.hash_id_2.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash_id_2.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.title.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.title.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.description.write_to(__cache, buf); + } + if self.hash_id_1.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hash_id_1.write_to(__cache, buf); + } + if self.hash_id_2.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hash_id_2.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.title.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.description.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hash_id_1.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hash_id_2.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.title = ::buffa::MessageField::none(); + self.description = ::buffa::MessageField::none(); + self.hash_id_1 = ::buffa::MessageField::none(); + self.hash_id_2 = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for V0 { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __V0_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration.V0", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::oneof::sidechain_declaration::SidechainDeclaration; + #[doc(inline)] + pub use super::__buffa::view::sidechain_declaration::V0View; + #[doc(inline)] + pub use super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration as SidechainDeclarationView; +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[repr(i32)] +pub enum Network { + NETWORK_UNSPECIFIED = 0i32, + NETWORK_UNKNOWN = 1i32, + NETWORK_MAINNET = 2i32, + NETWORK_REGTEST = 3i32, + NETWORK_SIGNET = 4i32, + NETWORK_TESTNET = 5i32, +} +impl ::core::default::Default for Network { + fn default() -> Self { + Self::NETWORK_UNSPECIFIED + } +} +impl ::serde::Serialize for Network { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + s.serialize_str(::buffa::Enumeration::proto_name(self)) + } +} +impl<'de> ::serde::Deserialize<'de> for Network { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl ::serde::de::Visitor<'_> for _V { + type Value = Network; + fn expecting( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { + f.write_str( + concat!("a string, integer, or null for ", stringify!(Network)), + ) + } + fn visit_str( + self, + v: &str, + ) -> ::core::result::Result { + ::from_proto_name(v) + .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) }) + } + fn visit_i64( + self, + v: i64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_u64( + self, + v: u64, + ) -> ::core::result::Result { + let v32 = i32::try_from(v) + .map_err(|_| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("enum value {v} out of i32 range"), + ) + })?; + ::from_i32(v32) + .ok_or_else(|| { + ::serde::de::Error::custom( + ::buffa::alloc::format!("unknown enum value {v32}"), + ) + }) + } + fn visit_unit( + self, + ) -> ::core::result::Result { + ::core::result::Result::Ok(::core::default::Default::default()) + } + } + d.deserialize_any(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for Network { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +impl ::buffa::Enumeration for Network { + fn from_i32(value: i32) -> ::core::option::Option { + match value { + 0i32 => ::core::option::Option::Some(Self::NETWORK_UNSPECIFIED), + 1i32 => ::core::option::Option::Some(Self::NETWORK_UNKNOWN), + 2i32 => ::core::option::Option::Some(Self::NETWORK_MAINNET), + 3i32 => ::core::option::Option::Some(Self::NETWORK_REGTEST), + 4i32 => ::core::option::Option::Some(Self::NETWORK_SIGNET), + 5i32 => ::core::option::Option::Some(Self::NETWORK_TESTNET), + _ => ::core::option::Option::None, + } + } + fn to_i32(&self) -> i32 { + *self as i32 + } + fn proto_name(&self) -> &'static str { + match self { + Self::NETWORK_UNSPECIFIED => "NETWORK_UNSPECIFIED", + Self::NETWORK_UNKNOWN => "NETWORK_UNKNOWN", + Self::NETWORK_MAINNET => "NETWORK_MAINNET", + Self::NETWORK_REGTEST => "NETWORK_REGTEST", + Self::NETWORK_SIGNET => "NETWORK_SIGNET", + Self::NETWORK_TESTNET => "NETWORK_TESTNET", + } + } + fn from_proto_name(name: &str) -> ::core::option::Option { + match name { + "NETWORK_UNSPECIFIED" => { + ::core::option::Option::Some(Self::NETWORK_UNSPECIFIED) + } + "NETWORK_UNKNOWN" => ::core::option::Option::Some(Self::NETWORK_UNKNOWN), + "NETWORK_MAINNET" => ::core::option::Option::Some(Self::NETWORK_MAINNET), + "NETWORK_REGTEST" => ::core::option::Option::Some(Self::NETWORK_REGTEST), + "NETWORK_SIGNET" => ::core::option::Option::Some(Self::NETWORK_SIGNET), + "NETWORK_TESTNET" => ::core::option::Option::Some(Self::NETWORK_TESTNET), + _ => ::core::option::Option::None, + } + } + fn values() -> &'static [Self] { + &[ + Self::NETWORK_UNSPECIFIED, + Self::NETWORK_UNKNOWN, + Self::NETWORK_MAINNET, + Self::NETWORK_REGTEST, + Self::NETWORK_SIGNET, + Self::NETWORK_TESTNET, + ] + } +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BlockHeaderInfo { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField, + /// Field 2: `prev_block_hash` + #[serde( + rename = "prevBlockHash", + alias = "prev_block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub prev_block_hash: ::buffa::MessageField, + /// Field 3: `height` + #[serde( + rename = "height", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub height: u32, + /// Total work as a uint256, little-endian + /// + /// Field 4: `work` + #[serde( + rename = "work", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub work: ::buffa::MessageField, + /// Unix timestamp (seconds since epoch) + /// + /// Field 5: `timestamp` + #[serde( + rename = "timestamp", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub timestamp: u64, +} +impl ::core::fmt::Debug for BlockHeaderInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BlockHeaderInfo") + .field("block_hash", &self.block_hash) + .field("prev_block_hash", &self.prev_block_hash) + .field("height", &self.height) + .field("work", &self.work) + .field("timestamp", &self.timestamp) + .finish() + } +} +impl BlockHeaderInfo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockHeaderInfo"; +} +impl ::buffa::DefaultInstance for BlockHeaderInfo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BlockHeaderInfo { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockHeaderInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockHeaderInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockHeaderInfo"; +} +impl ::buffa::Message for BlockHeaderInfo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.work.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.work.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.timestamp != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.timestamp) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_block_hash.write_to(__cache, buf); + } + if self.height != 0u32 { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.work.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.work.write_to(__cache, buf); + } + if self.timestamp != 0u64 { + ::buffa::encoding::Tag::new(5u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.timestamp, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.prev_block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.height = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.work.get_or_insert_default(), + buf, + depth, + )?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.timestamp = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.prev_block_hash = ::buffa::MessageField::none(); + self.height = 0u32; + self.work = ::buffa::MessageField::none(); + self.timestamp = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for BlockHeaderInfo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BLOCK_HEADER_INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.BlockHeaderInfo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct Deposit { + /// Field 1: `sequence_number` + #[serde( + rename = "sequenceNumber", + alias = "sequence_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sequence_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt64Value, + >, + /// Field 2: `outpoint` + #[serde( + rename = "outpoint", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub outpoint: ::buffa::MessageField, + /// Field 3: `output` + #[serde( + rename = "output", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub output: ::buffa::MessageField, +} +impl ::core::fmt::Debug for Deposit { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Deposit") + .field("sequence_number", &self.sequence_number) + .field("outpoint", &self.outpoint) + .field("output", &self.output) + .finish() + } +} +impl Deposit { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit"; +} +impl ::buffa::DefaultInstance for Deposit { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for Deposit { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "Deposit"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.Deposit"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit"; +} +impl ::buffa::Message for Deposit { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.outpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.outpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.output.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_number.write_to(__cache, buf); + } + if self.outpoint.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.outpoint.write_to(__cache, buf); + } + if self.output.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.output.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sequence_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.outpoint.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.output.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence_number = ::buffa::MessageField::none(); + self.outpoint = ::buffa::MessageField::none(); + self.output = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for Deposit { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __DEPOSIT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.Deposit", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod deposit { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Output { + /// Field 2: `address` + #[serde( + rename = "address", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub address: ::buffa::MessageField, + /// Field 3: `value_sats` + #[serde( + rename = "valueSats", + alias = "value_sats", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub value_sats: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt64Value, + >, + } + impl ::core::fmt::Debug for Output { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Output") + .field("address", &self.address) + .field("value_sats", &self.value_sats) + .finish() + } + } + impl Output { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit.Output"; + } + impl ::buffa::DefaultInstance for Output { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Output { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "Deposit.Output"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.Deposit.Output"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit.Output"; + } + impl ::buffa::Message for Output { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.address.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.value_sats.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.address.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.value_sats.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.address = ::buffa::MessageField::none(); + self.value_sats = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Output { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __OUTPUT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.Deposit.Output", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::deposit::OutputView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct WithdrawalBundleEvent { + /// Field 1: `m6id` + #[serde( + rename = "m6id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub m6id: ::buffa::MessageField, + /// Field 2: `event` + #[serde( + rename = "event", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub event: ::buffa::MessageField, +} +impl ::core::fmt::Debug for WithdrawalBundleEvent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WithdrawalBundleEvent") + .field("m6id", &self.m6id) + .field("event", &self.event) + .finish() + } +} +impl WithdrawalBundleEvent { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent"; +} +impl ::buffa::DefaultInstance for WithdrawalBundleEvent { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for WithdrawalBundleEvent { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent"; +} +impl ::buffa::Message for WithdrawalBundleEvent { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.m6id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.m6id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.m6id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.m6id.write_to(__cache, buf); + } + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.m6id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.event.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.m6id = ::buffa::MessageField::none(); + self.event = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for WithdrawalBundleEvent { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __WITHDRAWAL_BUNDLE_EVENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod withdrawal_bundle_event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct Event { + #[serde(flatten)] + pub event: ::core::option::Option< + super::__buffa::oneof::withdrawal_bundle_event::event::Event, + >, + } + impl ::core::fmt::Debug for Event { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Event").field("event", &self.event).finish() + } + } + impl Event { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event"; + } + impl ::buffa::DefaultInstance for Event { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Event { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event"; + } + impl ::buffa::Message for Event { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for Event { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = Event; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct Event") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_event: ::core::option::Option< + super::__buffa::oneof::withdrawal_bundle_event::event::Event, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "failed" => { + let v: ::core::option::Option< + super::withdrawal_bundle_event::event::Failed, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::withdrawal_bundle_event::event::Failed, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "succeeded" => { + let v: ::core::option::Option< + super::withdrawal_bundle_event::event::Succeeded, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::withdrawal_bundle_event::event::Succeeded, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "submitted" => { + let v: ::core::option::Option< + super::withdrawal_bundle_event::event::Submitted, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::withdrawal_bundle_event::event::Submitted, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.event = __oneof_event; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for Event { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __EVENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Failed {} + impl ::core::fmt::Debug for Failed { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Failed").finish() + } + } + impl Failed { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed"; + } + impl ::buffa::DefaultInstance for Failed { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Failed { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Failed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed"; + } + impl ::buffa::Message for Failed { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} + } + impl ::buffa::json_helpers::ProtoElemJson for Failed { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __FAILED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Succeeded { + /// Field 1: `sequence_number` + #[serde( + rename = "sequenceNumber", + alias = "sequence_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sequence_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt64Value, + >, + /// Field 2: `transaction` + #[serde( + rename = "transaction", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub transaction: ::buffa::MessageField< + super::super::super::super::common::v1::ConsensusHex, + >, + } + impl ::core::fmt::Debug for Succeeded { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Succeeded") + .field("sequence_number", &self.sequence_number) + .field("transaction", &self.transaction) + .finish() + } + } + impl Succeeded { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded"; + } + impl ::buffa::DefaultInstance for Succeeded { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Succeeded { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Succeeded"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded"; + } + impl ::buffa::Message for Succeeded { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_number.write_to(__cache, buf); + } + if self.transaction.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.transaction.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sequence_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.transaction.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence_number = ::buffa::MessageField::none(); + self.transaction = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Succeeded { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __SUCCEEDED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Submitted {} + impl ::core::fmt::Debug for Submitted { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Submitted").finish() + } + } + impl Submitted { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted"; + } + impl ::buffa::DefaultInstance for Submitted { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Submitted { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Submitted"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted"; + } + impl ::buffa::Message for Submitted { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} + } + impl ::buffa::json_helpers::ProtoElemJson for Submitted { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __SUBMITTED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::super::__buffa::oneof::withdrawal_bundle_event::event::Event; + #[doc(inline)] + pub use super::super::__buffa::view::withdrawal_bundle_event::event::FailedView; + #[doc(inline)] + pub use super::super::__buffa::view::withdrawal_bundle_event::event::SucceededView; + #[doc(inline)] + pub use super::super::__buffa::view::withdrawal_bundle_event::event::SubmittedView; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event as EventView; + } + #[doc(inline)] + pub use super::__buffa::view::withdrawal_bundle_event::EventView; +} +/// Specific to an individual sidechain slot +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BlockInfo { + /// repeated Deposit deposits = 1; + /// repeated WithdrawalBundleEvent withdrawal_bundle_events = 2; + /// + /// Field 1: `bmm_commitment` + #[serde( + rename = "bmmCommitment", + alias = "bmm_commitment", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub bmm_commitment: ::buffa::MessageField, + /// Field 2: `events` + #[serde( + rename = "events", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub events: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for BlockInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BlockInfo") + .field("bmm_commitment", &self.bmm_commitment) + .field("events", &self.events) + .finish() + } +} +impl BlockInfo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo"; +} +impl ::buffa::DefaultInstance for BlockInfo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BlockInfo { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo"; +} +impl ::buffa::Message for BlockInfo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.bmm_commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.bmm_commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.events { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.bmm_commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.bmm_commitment.write_to(__cache, buf); + } + for v in &self.events { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.bmm_commitment.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.events.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.bmm_commitment = ::buffa::MessageField::none(); + self.events.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for BlockInfo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BLOCK_INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.BlockInfo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod block_info { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct Event { + #[serde(flatten)] + pub event: ::core::option::Option< + super::__buffa::oneof::block_info::event::Event, + >, + } + impl ::core::fmt::Debug for Event { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Event").field("event", &self.event).finish() + } + } + impl Event { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo.Event"; + } + impl ::buffa::DefaultInstance for Event { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Event { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockInfo.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockInfo.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo.Event"; + } + impl ::buffa::Message for Event { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::block_info::event::Event::Deposit(x) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::block_info::event::Event::Deposit(x) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::block_info::event::Event::Deposit( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::block_info::event::Event::Deposit( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for Event { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = Event; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct Event") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_event: ::core::option::Option< + super::__buffa::oneof::block_info::event::Event, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "deposit" => { + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::Deposit, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::block_info::event::Event::Deposit( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "withdrawalBundle" | "withdrawal_bundle" => { + let v: ::core::option::Option< + super::WithdrawalBundleEvent, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::WithdrawalBundleEvent, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.event = __oneof_event; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for Event { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __EVENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.BlockInfo.Event", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::super::__buffa::oneof::block_info::event::Event; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::block_info::event::Event as EventView; + } + #[doc(inline)] + pub use super::__buffa::view::block_info::EventView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBlockHeaderInfoRequest { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField, + /// Request block header info for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 2: `max_ancestors` + #[serde( + rename = "maxAncestors", + alias = "max_ancestors", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_ancestors: ::core::option::Option, +} +impl ::core::fmt::Debug for GetBlockHeaderInfoRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBlockHeaderInfoRequest") + .field("block_hash", &self.block_hash) + .field("max_ancestors", &self.max_ancestors) + .finish() + } +} +impl GetBlockHeaderInfoRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoRequest"; +} +impl GetBlockHeaderInfoRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_ancestors`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_ancestors(mut self, value: u32) -> Self { + self.max_ancestors = Some(value); + self + } +} +impl ::buffa::DefaultInstance for GetBlockHeaderInfoRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBlockHeaderInfoRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockHeaderInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockHeaderInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoRequest"; +} +impl ::buffa::Message for GetBlockHeaderInfoRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.max_ancestors = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.max_ancestors = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBlockHeaderInfoRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BLOCK_HEADER_INFO_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBlockHeaderInfoResponse { + /// Field 1: `header_infos` + #[serde( + rename = "headerInfos", + alias = "header_infos", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub header_infos: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for GetBlockHeaderInfoResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBlockHeaderInfoResponse") + .field("header_infos", &self.header_infos) + .finish() + } +} +impl GetBlockHeaderInfoResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoResponse"; +} +impl ::buffa::DefaultInstance for GetBlockHeaderInfoResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBlockHeaderInfoResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockHeaderInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockHeaderInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoResponse"; +} +impl ::buffa::Message for GetBlockHeaderInfoResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.header_infos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.header_infos { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.header_infos.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.header_infos.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBlockHeaderInfoResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BLOCK_HEADER_INFO_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBlockInfoRequest { + /// The block to fetch information about. + /// + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField, + /// The sidechain to filter for events relating to. + /// + /// Field 2: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Request block info for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 3: `max_ancestors` + #[serde( + rename = "maxAncestors", + alias = "max_ancestors", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_ancestors: ::core::option::Option, +} +impl ::core::fmt::Debug for GetBlockInfoRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBlockInfoRequest") + .field("block_hash", &self.block_hash) + .field("sidechain_id", &self.sidechain_id) + .field("max_ancestors", &self.max_ancestors) + .finish() + } +} +impl GetBlockInfoRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoRequest"; +} +impl GetBlockInfoRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_ancestors`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_ancestors(mut self, value: u32) -> Self { + self.max_ancestors = Some(value); + self + } +} +impl ::buffa::DefaultInstance for GetBlockInfoRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBlockInfoRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoRequest"; +} +impl ::buffa::Message for GetBlockInfoRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.max_ancestors = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.sidechain_id = ::buffa::MessageField::none(); + self.max_ancestors = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBlockInfoRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BLOCK_INFO_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBlockInfoResponse { + /// Empty if the requested block was not found. + /// Ancestors MUST be sorted newest-first. + /// + /// Field 1: `infos` + #[serde( + rename = "infos", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub infos: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for GetBlockInfoResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBlockInfoResponse").field("infos", &self.infos).finish() + } +} +impl GetBlockInfoResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse"; +} +impl ::buffa::DefaultInstance for GetBlockInfoResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBlockInfoResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse"; +} +impl ::buffa::Message for GetBlockInfoResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.infos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.infos { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.infos.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.infos.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBlockInfoResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BLOCK_INFO_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_block_info_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Info { + /// Information about the block itself. + /// + /// Field 1: `header_info` + #[serde( + rename = "headerInfo", + alias = "header_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub header_info: ::buffa::MessageField, + /// Information about the block, filtered for events relating to a specific + /// sidechain. + /// + /// Field 2: `block_info` + #[serde( + rename = "blockInfo", + alias = "block_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_info: ::buffa::MessageField, + } + impl ::core::fmt::Debug for Info { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Info") + .field("header_info", &self.header_info) + .field("block_info", &self.block_info) + .finish() + } + } + impl Info { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse.Info"; + } + impl ::buffa::DefaultInstance for Info { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Info { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoResponse.Info"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoResponse.Info"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse.Info"; + } + impl ::buffa::Message for Info { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_info.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.header_info.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_info.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.header_info = ::buffa::MessageField::none(); + self.block_info = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Info { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse.Info", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_block_info_response::InfoView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBmmHStarCommitmentRequest { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField, + /// Field 2: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Request commitments for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 3: `max_ancestors` + #[serde( + rename = "maxAncestors", + alias = "max_ancestors", + with = "::buffa::json_helpers::opt_uint32", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub max_ancestors: ::core::option::Option, +} +impl ::core::fmt::Debug for GetBmmHStarCommitmentRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBmmHStarCommitmentRequest") + .field("block_hash", &self.block_hash) + .field("sidechain_id", &self.sidechain_id) + .field("max_ancestors", &self.max_ancestors) + .finish() + } +} +impl GetBmmHStarCommitmentRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentRequest"; +} +impl GetBmmHStarCommitmentRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::max_ancestors`] to `Some(value)`, consuming and returning `self`. + pub fn with_max_ancestors(mut self, value: u32) -> Self { + self.max_ancestors = Some(value); + self + } +} +impl ::buffa::DefaultInstance for GetBmmHStarCommitmentRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBmmHStarCommitmentRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentRequest"; +} +impl ::buffa::Message for GetBmmHStarCommitmentRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.max_ancestors = ::core::option::Option::Some( + ::buffa::types::decode_uint32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.sidechain_id = ::buffa::MessageField::none(); + self.max_ancestors = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBmmHStarCommitmentRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BMM_H_STAR_COMMITMENT_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct GetBmmHStarCommitmentResponse { + #[serde(flatten)] + pub result: ::core::option::Option< + __buffa::oneof::get_bmm_h_star_commitment_response::Result, + >, +} +impl ::core::fmt::Debug for GetBmmHStarCommitmentResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBmmHStarCommitmentResponse") + .field("result", &self.result) + .finish() + } +} +impl GetBmmHStarCommitmentResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse"; +} +impl ::buffa::DefaultInstance for GetBmmHStarCommitmentResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBmmHStarCommitmentResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse"; +} +impl ::buffa::Message for GetBmmHStarCommitmentResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.result { + match v { + __buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + __buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.result { + match v { + __buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + x.write_to(__cache, buf); + } + __buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ref mut existing, + ), + ) = self.result + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.result = ::core::option::Option::Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ref mut existing, + ), + ) = self.result + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.result = ::core::option::Option::Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.result = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for GetBmmHStarCommitmentResponse { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = GetBmmHStarCommitmentResponse; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct GetBmmHStarCommitmentResponse") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_result: ::core::option::Option< + __buffa::oneof::get_bmm_h_star_commitment_response::Result, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "blockNotFound" | "block_not_found" => { + let v: ::core::option::Option< + get_bmm_h_star_commitment_response::BlockNotFoundError, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + get_bmm_h_star_commitment_response::BlockNotFoundError, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_result.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'result'", + ), + ); + } + __oneof_result = Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "commitment" => { + let v: ::core::option::Option< + get_bmm_h_star_commitment_response::Commitment, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + get_bmm_h_star_commitment_response::Commitment, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_result.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'result'", + ), + ); + } + __oneof_result = Some( + __buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.result = __oneof_result; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBmmHStarCommitmentResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BMM_H_STAR_COMMITMENT_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_bmm_h_star_commitment_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct BlockNotFoundError { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + } + impl ::core::fmt::Debug for BlockNotFoundError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BlockNotFoundError") + .field("block_hash", &self.block_hash) + .finish() + } + } + impl BlockNotFoundError { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError"; + } + impl ::buffa::DefaultInstance for BlockNotFoundError { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for BlockNotFoundError { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.BlockNotFoundError"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError"; + } + impl ::buffa::Message for BlockNotFoundError { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for BlockNotFoundError { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __BLOCK_NOT_FOUND_ERROR_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct OptionalCommitment { + /// Field 1: `commitment` + #[serde( + rename = "commitment", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub commitment: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + } + impl ::core::fmt::Debug for OptionalCommitment { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("OptionalCommitment") + .field("commitment", &self.commitment) + .finish() + } + } + impl OptionalCommitment { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment"; + } + impl ::buffa::DefaultInstance for OptionalCommitment { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for OptionalCommitment { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.OptionalCommitment"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment"; + } + impl ::buffa::Message for OptionalCommitment { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.commitment.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.commitment.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.commitment = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for OptionalCommitment { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __OPTIONAL_COMMITMENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Commitment { + /// Field 1: `commitment` + #[serde( + rename = "commitment", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub commitment: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + /// Ancestors MUST be sorted newest-first + /// + /// Field 2: `ancestor_commitments` + #[serde( + rename = "ancestorCommitments", + alias = "ancestor_commitments", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub ancestor_commitments: ::buffa::alloc::vec::Vec< + super::get_bmm_h_star_commitment_response::OptionalCommitment, + >, + } + impl ::core::fmt::Debug for Commitment { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Commitment") + .field("commitment", &self.commitment) + .field("ancestor_commitments", &self.ancestor_commitments) + .finish() + } + } + impl Commitment { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment"; + } + impl ::buffa::DefaultInstance for Commitment { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Commitment { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.Commitment"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment"; + } + impl ::buffa::Message for Commitment { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.ancestor_commitments { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.commitment.write_to(__cache, buf); + } + for v in &self.ancestor_commitments { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.commitment.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.ancestor_commitments.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.commitment = ::buffa::MessageField::none(); + self.ancestor_commitments.clear(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Commitment { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __COMMITMENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::oneof::get_bmm_h_star_commitment_response::Result; + #[doc(inline)] + pub use super::__buffa::view::get_bmm_h_star_commitment_response::BlockNotFoundErrorView; + #[doc(inline)] + pub use super::__buffa::view::get_bmm_h_star_commitment_response::OptionalCommitmentView; + #[doc(inline)] + pub use super::__buffa::view::get_bmm_h_star_commitment_response::CommitmentView; + #[doc(inline)] + pub use super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result as ResultView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChainInfoRequest {} +impl ::core::fmt::Debug for GetChainInfoRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChainInfoRequest").finish() + } +} +impl GetChainInfoRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoRequest"; +} +impl ::buffa::DefaultInstance for GetChainInfoRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetChainInfoRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoRequest"; +} +impl ::buffa::Message for GetChainInfoRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetChainInfoRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHAIN_INFO_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetChainInfoRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChainInfoResponse { + /// Field 1: `network` + #[serde( + rename = "network", + with = "::buffa::json_helpers::proto_enum", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value" + )] + pub network: ::buffa::EnumValue, +} +impl ::core::fmt::Debug for GetChainInfoResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChainInfoResponse").field("network", &self.network).finish() + } +} +impl GetChainInfoResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoResponse"; +} +impl ::buffa::DefaultInstance for GetChainInfoResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetChainInfoResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoResponse"; +} +impl ::buffa::Message for GetChainInfoResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + { + let val = self.network.to_i32(); + if val != 0 { + size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32; + } + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.network.to_i32(); + if val != 0 { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_int32(val, buf); + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.network = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(buf)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.network = ::buffa::EnumValue::from(0); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetChainInfoResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHAIN_INFO_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetChainInfoResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChainTipRequest {} +impl ::core::fmt::Debug for GetChainTipRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChainTipRequest").finish() + } +} +impl GetChainTipRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipRequest"; +} +impl ::buffa::DefaultInstance for GetChainTipRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetChainTipRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainTipRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainTipRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipRequest"; +} +impl ::buffa::Message for GetChainTipRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetChainTipRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHAIN_TIP_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetChainTipRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetChainTipResponse { + /// Field 1: `block_header_info` + #[serde( + rename = "blockHeaderInfo", + alias = "block_header_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_header_info: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetChainTipResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetChainTipResponse") + .field("block_header_info", &self.block_header_info) + .finish() + } +} +impl GetChainTipResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipResponse"; +} +impl ::buffa::DefaultInstance for GetChainTipResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetChainTipResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainTipResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainTipResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipResponse"; +} +impl ::buffa::Message for GetChainTipResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_header_info.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_header_info.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_header_info = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetChainTipResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CHAIN_TIP_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetChainTipResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetCoinbasePSBTRequest { + /// Field 1: `propose_sidechains` + #[serde( + rename = "proposeSidechains", + alias = "propose_sidechains", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub propose_sidechains: ::buffa::alloc::vec::Vec< + get_coinbase_psbt_request::ProposeSidechain, + >, + /// Field 2: `ack_sidechains` + #[serde( + rename = "ackSidechains", + alias = "ack_sidechains", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub ack_sidechains: ::buffa::alloc::vec::Vec< + get_coinbase_psbt_request::AckSidechain, + >, + /// Field 3: `propose_bundles` + #[serde( + rename = "proposeBundles", + alias = "propose_bundles", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub propose_bundles: ::buffa::alloc::vec::Vec< + get_coinbase_psbt_request::ProposeBundle, + >, + /// Field 4: `ack_bundles` + #[serde( + rename = "ackBundles", + alias = "ack_bundles", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub ack_bundles: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetCoinbasePSBTRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetCoinbasePSBTRequest") + .field("propose_sidechains", &self.propose_sidechains) + .field("ack_sidechains", &self.ack_sidechains) + .field("propose_bundles", &self.propose_bundles) + .field("ack_bundles", &self.ack_bundles) + .finish() + } +} +impl GetCoinbasePSBTRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest"; +} +impl ::buffa::DefaultInstance for GetCoinbasePSBTRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetCoinbasePSBTRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest"; +} +impl ::buffa::Message for GetCoinbasePSBTRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.propose_sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.ack_sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.propose_bundles { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.ack_bundles.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ack_bundles.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.propose_sidechains { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + for v in &self.ack_sidechains { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + for v in &self.propose_bundles { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + if self.ack_bundles.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.ack_bundles.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.propose_sidechains.push(elem); + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.ack_sidechains.push(elem); + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.propose_bundles.push(elem); + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.ack_bundles.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.propose_sidechains.clear(); + self.ack_sidechains.clear(); + self.propose_bundles.clear(); + self.ack_bundles = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetCoinbasePSBTRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_COINBASE_PSBT_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_coinbase_psbt_request { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct ProposeSidechain { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `data` + #[serde( + rename = "data", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub data: ::buffa::MessageField, + } + impl ::core::fmt::Debug for ProposeSidechain { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProposeSidechain") + .field("sidechain_number", &self.sidechain_number) + .field("data", &self.data) + .finish() + } + } + impl ProposeSidechain { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain"; + } + impl ::buffa::DefaultInstance for ProposeSidechain { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for ProposeSidechain { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.ProposeSidechain"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain"; + } + impl ::buffa::Message for ProposeSidechain { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.data.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.data.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.data.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.data.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.data.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.data = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for ProposeSidechain { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __PROPOSE_SIDECHAIN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct AckSidechain { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `data_hash` + #[serde( + rename = "dataHash", + alias = "data_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub data_hash: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + } + impl ::core::fmt::Debug for AckSidechain { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AckSidechain") + .field("sidechain_number", &self.sidechain_number) + .field("data_hash", &self.data_hash) + .finish() + } + } + impl AckSidechain { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain"; + } + impl ::buffa::DefaultInstance for AckSidechain { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for AckSidechain { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckSidechain"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain"; + } + impl ::buffa::Message for AckSidechain { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.data_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.data_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.data_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.data_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.data_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.data_hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for AckSidechain { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __ACK_SIDECHAIN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct ProposeBundle { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `bundle_txid` + #[serde( + rename = "bundleTxid", + alias = "bundle_txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub bundle_txid: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + } + impl ::core::fmt::Debug for ProposeBundle { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ProposeBundle") + .field("sidechain_number", &self.sidechain_number) + .field("bundle_txid", &self.bundle_txid) + .finish() + } + } + impl ProposeBundle { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle"; + } + impl ::buffa::DefaultInstance for ProposeBundle { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for ProposeBundle { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.ProposeBundle"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle"; + } + impl ::buffa::Message for ProposeBundle { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.bundle_txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.bundle_txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.bundle_txid.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.bundle_txid.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.bundle_txid.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.bundle_txid = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for ProposeBundle { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __PROPOSE_BUNDLE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct AckBundles { + #[serde(flatten)] + pub ack_bundles: ::core::option::Option< + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles, + >, + } + impl ::core::fmt::Debug for AckBundles { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("AckBundles").field("ack_bundles", &self.ack_bundles).finish() + } + } + impl AckBundles { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles"; + } + impl ::buffa::DefaultInstance for AckBundles { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for AckBundles { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles"; + } + impl ::buffa::Message for AckBundles { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.ack_bundles { + match v { + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.ack_bundles { + match v { + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ref mut existing, + ), + ) = self.ack_bundles + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.ack_bundles = ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ref mut existing, + ), + ) = self.ack_bundles + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.ack_bundles = ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ref mut existing, + ), + ) = self.ack_bundles + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.ack_bundles = ::core::option::Option::Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ack_bundles = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for AckBundles { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = AckBundles; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct AckBundles") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_ack_bundles: ::core::option::Option< + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "repeatPrevious" | "repeat_previous" => { + let v: ::core::option::Option< + super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_ack_bundles.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'ack_bundles'", + ), + ); + } + __oneof_ack_bundles = Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "leadingBy50" | "leading_by_50" => { + let v: ::core::option::Option< + super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_ack_bundles.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'ack_bundles'", + ), + ); + } + __oneof_ack_bundles = Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "upvotes" => { + let v: ::core::option::Option< + super::get_coinbase_psbt_request::ack_bundles::Upvotes, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::get_coinbase_psbt_request::ack_bundles::Upvotes, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_ack_bundles.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'ack_bundles'", + ), + ); + } + __oneof_ack_bundles = Some( + super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.ack_bundles = __oneof_ack_bundles; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for AckBundles { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __ACK_BUNDLES_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod ack_bundles { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct RepeatPrevious {} + impl ::core::fmt::Debug for RepeatPrevious { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RepeatPrevious").finish() + } + } + impl RepeatPrevious { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + } + impl ::buffa::DefaultInstance for RepeatPrevious { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for RepeatPrevious { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + } + impl ::buffa::Message for RepeatPrevious { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} + } + impl ::buffa::json_helpers::ProtoElemJson for RepeatPrevious { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __REPEAT_PREVIOUS_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct LeadingBy50 {} + impl ::core::fmt::Debug for LeadingBy50 { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("LeadingBy50").finish() + } + } + impl LeadingBy50 { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + } + impl ::buffa::DefaultInstance for LeadingBy50 { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for LeadingBy50 { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + } + impl ::buffa::Message for LeadingBy50 { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} + } + impl ::buffa::json_helpers::ProtoElemJson for LeadingBy50 { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __LEADING_BY50_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Upvotes { + /// Field 1: `upvotes` + #[serde( + rename = "upvotes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub upvotes: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for Upvotes { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Upvotes").field("upvotes", &self.upvotes).finish() + } + } + impl Upvotes { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes"; + } + impl ::buffa::DefaultInstance for Upvotes { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Upvotes { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.Upvotes"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes"; + } + impl ::buffa::Message for Upvotes { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.upvotes.is_empty() { + let payload: u32 = self + .upvotes + .iter() + .map(|&v| ::buffa::types::uint32_encoded_len(v) as u32) + .sum::(); + size + += 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32 + + payload; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.upvotes.is_empty() { + let payload: u32 = self + .upvotes + .iter() + .map(|&v| ::buffa::types::uint32_encoded_len(v) as u32) + .sum::(); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(payload as u64, buf); + for &v in &self.upvotes { + ::buffa::types::encode_uint32(v, buf); + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + == ::buffa::encoding::WireType::LengthDelimited + { + let len = ::buffa::encoding::decode_varint(buf)?; + let len = usize::try_from(len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + self.upvotes.reserve(len); + let mut limited = buf.take(len); + while limited.has_remaining() { + self.upvotes + .push(::buffa::types::decode_uint32(&mut limited)?); + } + let leftover = limited.remaining(); + if leftover > 0 { + limited.advance(leftover); + } + } else if tag.wire_type() == ::buffa::encoding::WireType::Varint + { + self.upvotes.push(::buffa::types::decode_uint32(buf)?); + } else { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.upvotes.clear(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Upvotes { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __UPVOTES_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles; + #[doc(inline)] + pub use super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::RepeatPreviousView; + #[doc(inline)] + pub use super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::LeadingBy50View; + #[doc(inline)] + pub use super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::UpvotesView; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles as AckBundlesView; + } + #[doc(inline)] + pub use super::__buffa::view::get_coinbase_psbt_request::ProposeSidechainView; + #[doc(inline)] + pub use super::__buffa::view::get_coinbase_psbt_request::AckSidechainView; + #[doc(inline)] + pub use super::__buffa::view::get_coinbase_psbt_request::ProposeBundleView; + #[doc(inline)] + pub use super::__buffa::view::get_coinbase_psbt_request::AckBundlesView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetCoinbasePSBTResponse { + /// Field 1: `psbt` + #[serde( + rename = "psbt", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub psbt: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetCoinbasePSBTResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetCoinbasePSBTResponse").field("psbt", &self.psbt).finish() + } +} +impl GetCoinbasePSBTResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTResponse"; +} +impl ::buffa::DefaultInstance for GetCoinbasePSBTResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetCoinbasePSBTResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTResponse"; +} +impl ::buffa::Message for GetCoinbasePSBTResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.psbt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.psbt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.psbt.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.psbt.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.psbt.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.psbt = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetCoinbasePSBTResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_COINBASE_PSBT_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetCtipRequest { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, +} +impl ::core::fmt::Debug for GetCtipRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetCtipRequest") + .field("sidechain_number", &self.sidechain_number) + .finish() + } +} +impl GetCtipRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipRequest"; +} +impl ::buffa::DefaultInstance for GetCtipRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetCtipRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipRequest"; +} +impl ::buffa::Message for GetCtipRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetCtipRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CTIP_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCtipRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetCtipResponse { + /// Field 1: `ctip` + #[serde( + rename = "ctip", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub ctip: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetCtipResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetCtipResponse").field("ctip", &self.ctip).finish() + } +} +impl GetCtipResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse"; +} +impl ::buffa::DefaultInstance for GetCtipResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetCtipResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse"; +} +impl ::buffa::Message for GetCtipResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.ctip.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ctip.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.ctip.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.ctip.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.ctip.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.ctip = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetCtipResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_CTIP_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_ctip_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Ctip { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, + /// Field 2: `vout` + #[serde( + rename = "vout", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub vout: u32, + /// Field 3: `value` + #[serde( + rename = "value", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub value: u64, + /// Field 4: `sequence_number` + #[serde( + rename = "sequenceNumber", + alias = "sequence_number", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub sequence_number: u64, + } + impl ::core::fmt::Debug for Ctip { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Ctip") + .field("txid", &self.txid) + .field("vout", &self.vout) + .field("value", &self.value) + .field("sequence_number", &self.sequence_number) + .finish() + } + } + impl Ctip { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse.Ctip"; + } + impl ::buffa::DefaultInstance for Ctip { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Ctip { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipResponse.Ctip"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipResponse.Ctip"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse.Ctip"; + } + impl ::buffa::Message for Ctip { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + if self.value != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.value) as u32; + } + if self.sequence_number != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.sequence_number) + as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + if self.value != 0u64 { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.value, buf); + } + if self.sequence_number != 0u64 { + ::buffa::encoding::Tag::new(4u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.sequence_number, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.vout = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.value = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.sequence_number = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + self.vout = 0u32; + self.value = 0u64; + self.sequence_number = 0u64; + } + } + impl ::buffa::json_helpers::ProtoElemJson for Ctip { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __CTIP_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse.Ctip", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_ctip_response::CtipView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSidechainProposalsRequest {} +impl ::core::fmt::Debug for GetSidechainProposalsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSidechainProposalsRequest").finish() + } +} +impl GetSidechainProposalsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsRequest"; +} +impl ::buffa::DefaultInstance for GetSidechainProposalsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetSidechainProposalsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsRequest"; +} +impl ::buffa::Message for GetSidechainProposalsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetSidechainProposalsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SIDECHAIN_PROPOSALS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSidechainProposalsResponse { + /// Field 1: `sidechain_proposals` + #[serde( + rename = "sidechainProposals", + alias = "sidechain_proposals", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub sidechain_proposals: ::buffa::alloc::vec::Vec< + get_sidechain_proposals_response::SidechainProposal, + >, +} +impl ::core::fmt::Debug for GetSidechainProposalsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSidechainProposalsResponse") + .field("sidechain_proposals", &self.sidechain_proposals) + .finish() + } +} +impl GetSidechainProposalsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse"; +} +impl ::buffa::DefaultInstance for GetSidechainProposalsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetSidechainProposalsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse"; +} +impl ::buffa::Message for GetSidechainProposalsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.sidechain_proposals { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.sidechain_proposals { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.sidechain_proposals.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_proposals.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSidechainProposalsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SIDECHAIN_PROPOSALS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_sidechain_proposals_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct SidechainProposal { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Raw sidechain proposal description + /// + /// Field 2: `description` + #[serde( + rename = "description", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub description: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + /// Sidechain data, as declared in the M1 proposal. + /// Might be nil, if the proposal uses an unknown version. + /// + /// Field 7: `declaration` + #[serde( + rename = "declaration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub declaration: ::buffa::MessageField, + /// Field 3: `description_sha256d_hash` + #[serde( + rename = "descriptionSha256dHash", + alias = "description_sha256d_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub description_sha256d_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + /// Field 4: `vote_count` + #[serde( + rename = "voteCount", + alias = "vote_count", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub vote_count: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 5: `proposal_height` + #[serde( + rename = "proposalHeight", + alias = "proposal_height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub proposal_height: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 6: `proposal_age` + #[serde( + rename = "proposalAge", + alias = "proposal_age", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub proposal_age: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + } + impl ::core::fmt::Debug for SidechainProposal { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SidechainProposal") + .field("sidechain_number", &self.sidechain_number) + .field("description", &self.description) + .field("declaration", &self.declaration) + .field("description_sha256d_hash", &self.description_sha256d_hash) + .field("vote_count", &self.vote_count) + .field("proposal_height", &self.proposal_height) + .field("proposal_age", &self.proposal_age) + .finish() + } + } + impl SidechainProposal { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal"; + } + impl ::buffa::DefaultInstance for SidechainProposal { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for SidechainProposal { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsResponse.SidechainProposal"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal"; + } + impl ::buffa::Message for SidechainProposal { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description_sha256d_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description_sha256d_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vote_count.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vote_count.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.description.write_to(__cache, buf); + } + if self.description_sha256d_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.description_sha256d_hash.write_to(__cache, buf); + } + if self.vote_count.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.vote_count.write_to(__cache, buf); + } + if self.proposal_height.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.proposal_height.write_to(__cache, buf); + } + if self.proposal_age.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.proposal_age.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 7u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.declaration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.description.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.description_sha256d_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.vote_count.get_or_insert_default(), + buf, + depth, + )?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.proposal_height.get_or_insert_default(), + buf, + depth, + )?; + } + 6u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.proposal_age.get_or_insert_default(), + buf, + depth, + )?; + } + 7u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 7u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.declaration.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.description = ::buffa::MessageField::none(); + self.description_sha256d_hash = ::buffa::MessageField::none(); + self.vote_count = ::buffa::MessageField::none(); + self.proposal_height = ::buffa::MessageField::none(); + self.proposal_age = ::buffa::MessageField::none(); + self.declaration = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for SidechainProposal { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __SIDECHAIN_PROPOSAL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_sidechain_proposals_response::SidechainProposalView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSidechainsRequest {} +impl ::core::fmt::Debug for GetSidechainsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSidechainsRequest").finish() + } +} +impl GetSidechainsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsRequest"; +} +impl ::buffa::DefaultInstance for GetSidechainsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetSidechainsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsRequest"; +} +impl ::buffa::Message for GetSidechainsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetSidechainsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SIDECHAINS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetSidechainsResponse { + /// Field 1: `sidechains` + #[serde( + rename = "sidechains", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub sidechains: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for GetSidechainsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetSidechainsResponse") + .field("sidechains", &self.sidechains) + .finish() + } +} +impl GetSidechainsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse"; +} +impl ::buffa::DefaultInstance for GetSidechainsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetSidechainsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse"; +} +impl ::buffa::Message for GetSidechainsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.sidechains { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.sidechains.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechains.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetSidechainsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_SIDECHAINS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_sidechains_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct SidechainInfo { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `description` + #[serde( + rename = "description", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub description: ::buffa::MessageField< + super::super::super::common::v1::ConsensusHex, + >, + /// Field 3: `vote_count` + #[serde( + rename = "voteCount", + alias = "vote_count", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub vote_count: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 4: `proposal_height` + #[serde( + rename = "proposalHeight", + alias = "proposal_height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub proposal_height: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 5: `activation_height` + #[serde( + rename = "activationHeight", + alias = "activation_height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub activation_height: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Sidechain data, as declared in the M1 proposal. + /// Might be nil, if the proposal uses an unknown version. + /// + /// Field 6: `declaration` + #[serde( + rename = "declaration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub declaration: ::buffa::MessageField, + } + impl ::core::fmt::Debug for SidechainInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SidechainInfo") + .field("sidechain_number", &self.sidechain_number) + .field("description", &self.description) + .field("vote_count", &self.vote_count) + .field("proposal_height", &self.proposal_height) + .field("activation_height", &self.activation_height) + .field("declaration", &self.declaration) + .finish() + } + } + impl SidechainInfo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo"; + } + impl ::buffa::DefaultInstance for SidechainInfo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for SidechainInfo { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsResponse.SidechainInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo"; + } + impl ::buffa::Message for SidechainInfo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vote_count.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vote_count.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.activation_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.activation_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.description.write_to(__cache, buf); + } + if self.vote_count.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.vote_count.write_to(__cache, buf); + } + if self.proposal_height.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.proposal_height.write_to(__cache, buf); + } + if self.activation_height.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.activation_height.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.declaration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.description.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.vote_count.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.proposal_height.get_or_insert_default(), + buf, + depth, + )?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.activation_height.get_or_insert_default(), + buf, + depth, + )?; + } + 6u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.declaration.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.description = ::buffa::MessageField::none(); + self.vote_count = ::buffa::MessageField::none(); + self.proposal_height = ::buffa::MessageField::none(); + self.activation_height = ::buffa::MessageField::none(); + self.declaration = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for SidechainInfo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __SIDECHAIN_INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_sidechains_response::SidechainInfoView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetTwoWayPegDataRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `start_block_hash` + #[serde( + rename = "startBlockHash", + alias = "start_block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub start_block_hash: ::buffa::MessageField, + /// Field 3: `end_block_hash` + #[serde( + rename = "endBlockHash", + alias = "end_block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub end_block_hash: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetTwoWayPegDataRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetTwoWayPegDataRequest") + .field("sidechain_id", &self.sidechain_id) + .field("start_block_hash", &self.start_block_hash) + .field("end_block_hash", &self.end_block_hash) + .finish() + } +} +impl GetTwoWayPegDataRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataRequest"; +} +impl ::buffa::DefaultInstance for GetTwoWayPegDataRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetTwoWayPegDataRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataRequest"; +} +impl ::buffa::Message for GetTwoWayPegDataRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.start_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.start_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.end_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.end_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.start_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.start_block_hash.write_to(__cache, buf); + } + if self.end_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.end_block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.start_block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.end_block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + self.start_block_hash = ::buffa::MessageField::none(); + self.end_block_hash = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetTwoWayPegDataRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_TWO_WAY_PEG_DATA_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetTwoWayPegDataResponse { + /// Field 1: `blocks` + #[serde( + rename = "blocks", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub blocks: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for GetTwoWayPegDataResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetTwoWayPegDataResponse").field("blocks", &self.blocks).finish() + } +} +impl GetTwoWayPegDataResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse"; +} +impl ::buffa::DefaultInstance for GetTwoWayPegDataResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetTwoWayPegDataResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse"; +} +impl ::buffa::Message for GetTwoWayPegDataResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.blocks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.blocks { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.blocks.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.blocks.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetTwoWayPegDataResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_TWO_WAY_PEG_DATA_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_two_way_peg_data_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct ResponseItem { + /// Field 1: `block_header_info` + #[serde( + rename = "blockHeaderInfo", + alias = "block_header_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_header_info: ::buffa::MessageField, + /// Field 2: `block_info` + #[serde( + rename = "blockInfo", + alias = "block_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_info: ::buffa::MessageField, + } + impl ::core::fmt::Debug for ResponseItem { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ResponseItem") + .field("block_header_info", &self.block_header_info) + .field("block_info", &self.block_info) + .finish() + } + } + impl ResponseItem { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem"; + } + impl ::buffa::DefaultInstance for ResponseItem { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for ResponseItem { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataResponse.ResponseItem"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem"; + } + impl ::buffa::Message for ResponseItem { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_info.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_header_info.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_info.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_header_info = ::buffa::MessageField::none(); + self.block_info = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for ResponseItem { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __RESPONSE_ITEM_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_two_way_peg_data_response::ResponseItemView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeEventsRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, +} +impl ::core::fmt::Debug for SubscribeEventsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeEventsRequest") + .field("sidechain_id", &self.sidechain_id) + .finish() + } +} +impl SubscribeEventsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsRequest"; +} +impl ::buffa::DefaultInstance for SubscribeEventsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeEventsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsRequest"; +} +impl ::buffa::Message for SubscribeEventsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeEventsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_EVENTS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeEventsResponse { + /// Field 1: `event` + #[serde( + rename = "event", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub event: ::buffa::MessageField, +} +impl ::core::fmt::Debug for SubscribeEventsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeEventsResponse").field("event", &self.event).finish() + } +} +impl SubscribeEventsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse"; +} +impl ::buffa::DefaultInstance for SubscribeEventsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeEventsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse"; +} +impl ::buffa::Message for SubscribeEventsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.event.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeEventsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_EVENTS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct Event { + #[serde(flatten)] + pub event: ::core::option::Option< + super::__buffa::oneof::subscribe_events_response::event::Event, + >, + } + impl ::core::fmt::Debug for Event { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Event").field("event", &self.event).finish() + } + } + impl Event { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event"; + } + impl ::buffa::DefaultInstance for Event { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Event { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event"; + } + impl ::buffa::Message for Event { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for Event { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = Event; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct Event") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_event: ::core::option::Option< + super::__buffa::oneof::subscribe_events_response::event::Event, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "connectBlock" | "connect_block" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::ConnectBlock, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::ConnectBlock, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "disconnectBlock" | "disconnect_block" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::DisconnectBlock, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::DisconnectBlock, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.event = __oneof_event; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for Event { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __EVENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct ConnectBlock { + /// Field 1: `header_info` + #[serde( + rename = "headerInfo", + alias = "header_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub header_info: ::buffa::MessageField, + /// Field 2: `block_info` + #[serde( + rename = "blockInfo", + alias = "block_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_info: ::buffa::MessageField, + } + impl ::core::fmt::Debug for ConnectBlock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConnectBlock") + .field("header_info", &self.header_info) + .field("block_info", &self.block_info) + .finish() + } + } + impl ConnectBlock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl ::buffa::DefaultInstance for ConnectBlock { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for ConnectBlock { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.ConnectBlock"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl ::buffa::Message for ConnectBlock { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_info.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.header_info.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_info.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.header_info = ::buffa::MessageField::none(); + self.block_info = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for ConnectBlock { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __CONNECT_BLOCK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct DisconnectBlock { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField< + super::super::super::super::common::v1::ReverseHex, + >, + } + impl ::core::fmt::Debug for DisconnectBlock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DisconnectBlock") + .field("block_hash", &self.block_hash) + .finish() + } + } + impl DisconnectBlock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl ::buffa::DefaultInstance for DisconnectBlock { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for DisconnectBlock { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.DisconnectBlock"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl ::buffa::Message for DisconnectBlock { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for DisconnectBlock { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __DISCONNECT_BLOCK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::super::__buffa::oneof::subscribe_events_response::event::Event; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::subscribe_events_response::event::Event as EventView; + } + #[doc(inline)] + pub use super::__buffa::view::subscribe_events_response::EventView; +} +/// Empty for now, could add filters later +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeHeaderSyncProgressRequest {} +impl ::core::fmt::Debug for SubscribeHeaderSyncProgressRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeHeaderSyncProgressRequest").finish() + } +} +impl SubscribeHeaderSyncProgressRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest"; +} +impl ::buffa::DefaultInstance for SubscribeHeaderSyncProgressRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeHeaderSyncProgressRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeHeaderSyncProgressRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest"; +} +impl ::buffa::Message for SubscribeHeaderSyncProgressRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeHeaderSyncProgressRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_HEADER_SYNC_PROGRESS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::< + SubscribeHeaderSyncProgressRequest, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeHeaderSyncProgressResponse { + /// Current sync height may be unknown at the start of a sync + /// + /// Field 1: `current_height` + #[serde( + rename = "currentHeight", + alias = "current_height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub current_height: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, +} +impl ::core::fmt::Debug for SubscribeHeaderSyncProgressResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeHeaderSyncProgressResponse") + .field("current_height", &self.current_height) + .finish() + } +} +impl SubscribeHeaderSyncProgressResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse"; +} +impl ::buffa::DefaultInstance for SubscribeHeaderSyncProgressResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeHeaderSyncProgressResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeHeaderSyncProgressResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse"; +} +impl ::buffa::Message for SubscribeHeaderSyncProgressResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.current_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.current_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.current_height.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.current_height.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.current_height.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.current_height = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeHeaderSyncProgressResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_HEADER_SYNC_PROGRESS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::< + SubscribeHeaderSyncProgressResponse, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StopRequest {} +impl ::core::fmt::Debug for StopRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StopRequest").finish() + } +} +impl StopRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopRequest"; +} +impl ::buffa::DefaultInstance for StopRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for StopRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "StopRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.StopRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopRequest"; +} +impl ::buffa::Message for StopRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for StopRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STOP_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.StopRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct StopResponse {} +impl ::core::fmt::Debug for StopResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("StopResponse").finish() + } +} +impl StopResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopResponse"; +} +impl ::buffa::DefaultInstance for StopResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for StopResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "StopResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.StopResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopResponse"; +} +impl ::buffa::Message for StopResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for StopResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __STOP_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.StopResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct WalletTransaction { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, + /// Field 6: `raw_transaction` + #[serde( + rename = "rawTransaction", + alias = "raw_transaction", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub raw_transaction: ::buffa::MessageField, + /// Field 2: `fee_sats` + #[serde( + rename = "feeSats", + alias = "fee_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub fee_sats: u64, + /// Field 3: `received_sats` + #[serde( + rename = "receivedSats", + alias = "received_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub received_sats: u64, + /// Field 4: `sent_sats` + #[serde( + rename = "sentSats", + alias = "sent_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub sent_sats: u64, + /// Field 5: `confirmation_info` + #[serde( + rename = "confirmationInfo", + alias = "confirmation_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub confirmation_info: ::buffa::MessageField, +} +impl ::core::fmt::Debug for WalletTransaction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("WalletTransaction") + .field("txid", &self.txid) + .field("raw_transaction", &self.raw_transaction) + .field("fee_sats", &self.fee_sats) + .field("received_sats", &self.received_sats) + .field("sent_sats", &self.sent_sats) + .field("confirmation_info", &self.confirmation_info) + .finish() + } +} +impl WalletTransaction { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction"; +} +impl ::buffa::DefaultInstance for WalletTransaction { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for WalletTransaction { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WalletTransaction"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WalletTransaction"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction"; +} +impl ::buffa::Message for WalletTransaction { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.fee_sats != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.fee_sats) as u32; + } + if self.received_sats != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.received_sats) as u32; + } + if self.sent_sats != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.sent_sats) as u32; + } + if self.confirmation_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmation_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.raw_transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.fee_sats != 0u64 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.fee_sats, buf); + } + if self.received_sats != 0u64 { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.received_sats, buf); + } + if self.sent_sats != 0u64 { + ::buffa::encoding::Tag::new(4u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.sent_sats, buf); + } + if self.confirmation_info.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.confirmation_info.write_to(__cache, buf); + } + if self.raw_transaction.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.raw_transaction.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.fee_sats = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.received_sats = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.sent_sats = ::buffa::types::decode_uint64(buf)?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.confirmation_info.get_or_insert_default(), + buf, + depth, + )?; + } + 6u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.raw_transaction.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + self.fee_sats = 0u64; + self.received_sats = 0u64; + self.sent_sats = 0u64; + self.confirmation_info = ::buffa::MessageField::none(); + self.raw_transaction = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for WalletTransaction { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __WALLET_TRANSACTION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WalletTransaction", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod wallet_transaction { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Confirmation { + /// Field 1: `height` + #[serde( + rename = "height", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub height: u32, + /// Field 2: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + /// Field 3: `timestamp` + #[serde( + rename = "timestamp", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub timestamp: ::buffa::MessageField<::buffa_types::google::protobuf::Timestamp>, + } + impl ::core::fmt::Debug for Confirmation { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Confirmation") + .field("height", &self.height) + .field("block_hash", &self.block_hash) + .field("timestamp", &self.timestamp) + .finish() + } + } + impl Confirmation { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction.Confirmation"; + } + impl ::buffa::DefaultInstance for Confirmation { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Confirmation { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WalletTransaction.Confirmation"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WalletTransaction.Confirmation"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction.Confirmation"; + } + impl ::buffa::Message for Confirmation { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.height != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.timestamp.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.timestamp.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.height != 0u32 { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.timestamp.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.timestamp.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.height = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.timestamp.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.height = 0u32; + self.block_hash = ::buffa::MessageField::none(); + self.timestamp = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Confirmation { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __CONFIRMATION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.WalletTransaction.Confirmation", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::wallet_transaction::ConfirmationView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BroadcastWithdrawalBundleRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `transaction` + #[serde( + rename = "transaction", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub transaction: ::buffa::MessageField<::buffa_types::google::protobuf::BytesValue>, +} +impl ::core::fmt::Debug for BroadcastWithdrawalBundleRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BroadcastWithdrawalBundleRequest") + .field("sidechain_id", &self.sidechain_id) + .field("transaction", &self.transaction) + .finish() + } +} +impl BroadcastWithdrawalBundleRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleRequest"; +} +impl ::buffa::DefaultInstance for BroadcastWithdrawalBundleRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BroadcastWithdrawalBundleRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BroadcastWithdrawalBundleRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BroadcastWithdrawalBundleRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleRequest"; +} +impl ::buffa::Message for BroadcastWithdrawalBundleRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.transaction.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.transaction.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.transaction.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + self.transaction = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for BroadcastWithdrawalBundleRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BROADCAST_WITHDRAWAL_BUNDLE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BroadcastWithdrawalBundleResponse {} +impl ::core::fmt::Debug for BroadcastWithdrawalBundleResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BroadcastWithdrawalBundleResponse").finish() + } +} +impl BroadcastWithdrawalBundleResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleResponse"; +} +impl ::buffa::DefaultInstance for BroadcastWithdrawalBundleResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BroadcastWithdrawalBundleResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BroadcastWithdrawalBundleResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BroadcastWithdrawalBundleResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleResponse"; +} +impl ::buffa::Message for BroadcastWithdrawalBundleResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for BroadcastWithdrawalBundleResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BROADCAST_WITHDRAWAL_BUNDLE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::< + BroadcastWithdrawalBundleResponse, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateBmmCriticalDataTransactionRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `value_sats` + #[serde( + rename = "valueSats", + alias = "value_sats", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub value_sats: ::buffa::MessageField<::buffa_types::google::protobuf::UInt64Value>, + /// Field 3: `height` + #[serde( + rename = "height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub height: ::buffa::MessageField<::buffa_types::google::protobuf::UInt32Value>, + /// Field 4: `critical_hash` + #[serde( + rename = "criticalHash", + alias = "critical_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub critical_hash: ::buffa::MessageField, + /// Field 5: `prev_bytes` + #[serde( + rename = "prevBytes", + alias = "prev_bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub prev_bytes: ::buffa::MessageField, +} +impl ::core::fmt::Debug for CreateBmmCriticalDataTransactionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateBmmCriticalDataTransactionRequest") + .field("sidechain_id", &self.sidechain_id) + .field("value_sats", &self.value_sats) + .field("height", &self.height) + .field("critical_hash", &self.critical_hash) + .field("prev_bytes", &self.prev_bytes) + .finish() + } +} +impl CreateBmmCriticalDataTransactionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest"; +} +impl ::buffa::DefaultInstance for CreateBmmCriticalDataTransactionRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + CreateBmmCriticalDataTransactionRequest, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateBmmCriticalDataTransactionRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateBmmCriticalDataTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest"; +} +impl ::buffa::Message for CreateBmmCriticalDataTransactionRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.critical_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.critical_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_bytes.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_bytes.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.value_sats.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.height.write_to(__cache, buf); + } + if self.critical_hash.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.critical_hash.write_to(__cache, buf); + } + if self.prev_bytes.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_bytes.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.value_sats.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.height.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.critical_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.prev_bytes.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + self.value_sats = ::buffa::MessageField::none(); + self.height = ::buffa::MessageField::none(); + self.critical_hash = ::buffa::MessageField::none(); + self.prev_bytes = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateBmmCriticalDataTransactionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_BMM_CRITICAL_DATA_TRANSACTION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest", + to_json: ::buffa::type_registry::any_to_json::< + CreateBmmCriticalDataTransactionRequest, + >, + from_json: ::buffa::type_registry::any_from_json::< + CreateBmmCriticalDataTransactionRequest, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateBmmCriticalDataTransactionResponse { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, +} +impl ::core::fmt::Debug for CreateBmmCriticalDataTransactionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateBmmCriticalDataTransactionResponse") + .field("txid", &self.txid) + .finish() + } +} +impl CreateBmmCriticalDataTransactionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse"; +} +impl ::buffa::DefaultInstance for CreateBmmCriticalDataTransactionResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + CreateBmmCriticalDataTransactionResponse, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateBmmCriticalDataTransactionResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateBmmCriticalDataTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse"; +} +impl ::buffa::Message for CreateBmmCriticalDataTransactionResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateBmmCriticalDataTransactionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_BMM_CRITICAL_DATA_TRANSACTION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse", + to_json: ::buffa::type_registry::any_to_json::< + CreateBmmCriticalDataTransactionResponse, + >, + from_json: ::buffa::type_registry::any_from_json::< + CreateBmmCriticalDataTransactionResponse, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateDepositTransactionRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Addresses are encoded in UTF8. + /// *Sidechain deposit addresses* (not sidechain addresses) are typically + /// formatted as `s_
_`, + /// where `CHECKSUM` is a hex encoding of the first 6 bytes of the SHA256 + /// hash of `s_
`. + /// protolint:disable:next MAX_LINE_LENGTH + /// + /// The address used here is a sidechain address, the middle component of a + /// sidechain deposit address. + /// + /// Field 2: `address` + #[serde( + rename = "address", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub address: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, + /// Field 3: `value_sats` + #[serde( + rename = "valueSats", + alias = "value_sats", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub value_sats: ::buffa::MessageField<::buffa_types::google::protobuf::UInt64Value>, + /// Field 4: `fee_sats` + #[serde( + rename = "feeSats", + alias = "fee_sats", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub fee_sats: ::buffa::MessageField<::buffa_types::google::protobuf::UInt64Value>, +} +impl ::core::fmt::Debug for CreateDepositTransactionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateDepositTransactionRequest") + .field("sidechain_id", &self.sidechain_id) + .field("address", &self.address) + .field("value_sats", &self.value_sats) + .field("fee_sats", &self.fee_sats) + .finish() + } +} +impl CreateDepositTransactionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionRequest"; +} +impl ::buffa::DefaultInstance for CreateDepositTransactionRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateDepositTransactionRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateDepositTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateDepositTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionRequest"; +} +impl ::buffa::Message for CreateDepositTransactionRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.fee_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fee_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.address.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.value_sats.write_to(__cache, buf); + } + if self.fee_sats.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.fee_sats.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.address.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.value_sats.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.fee_sats.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + self.address = ::buffa::MessageField::none(); + self.value_sats = ::buffa::MessageField::none(); + self.fee_sats = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateDepositTransactionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_DEPOSIT_TRANSACTION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateDepositTransactionResponse { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, +} +impl ::core::fmt::Debug for CreateDepositTransactionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateDepositTransactionResponse") + .field("txid", &self.txid) + .finish() + } +} +impl CreateDepositTransactionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionResponse"; +} +impl ::buffa::DefaultInstance for CreateDepositTransactionResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateDepositTransactionResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateDepositTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateDepositTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionResponse"; +} +impl ::buffa::Message for CreateDepositTransactionResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateDepositTransactionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_DEPOSIT_TRANSACTION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateNewAddressRequest {} +impl ::core::fmt::Debug for CreateNewAddressRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateNewAddressRequest").finish() + } +} +impl CreateNewAddressRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressRequest"; +} +impl ::buffa::DefaultInstance for CreateNewAddressRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateNewAddressRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateNewAddressRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateNewAddressRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressRequest"; +} +impl ::buffa::Message for CreateNewAddressRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for CreateNewAddressRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_NEW_ADDRESS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateNewAddressResponse { + /// Field 1: `address` + #[serde( + rename = "address", + with = "::buffa::json_helpers::proto_string", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str" + )] + pub address: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for CreateNewAddressResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateNewAddressResponse") + .field("address", &self.address) + .finish() + } +} +impl CreateNewAddressResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressResponse"; +} +impl ::buffa::DefaultInstance for CreateNewAddressResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateNewAddressResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateNewAddressResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateNewAddressResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressResponse"; +} +impl ::buffa::Message for CreateNewAddressResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.address.is_empty() { + size += 1u32 + ::buffa::types::string_encoded_len(&self.address) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.address.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.address, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string(&mut self.address, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.address.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateNewAddressResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_NEW_ADDRESS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateSidechainProposalRequest { + /// Field 1: `sidechain_id` + #[serde( + rename = "sidechainId", + alias = "sidechain_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_id: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `declaration` + #[serde( + rename = "declaration", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub declaration: ::buffa::MessageField, +} +impl ::core::fmt::Debug for CreateSidechainProposalRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateSidechainProposalRequest") + .field("sidechain_id", &self.sidechain_id) + .field("declaration", &self.declaration) + .finish() + } +} +impl CreateSidechainProposalRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalRequest"; +} +impl ::buffa::DefaultInstance for CreateSidechainProposalRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateSidechainProposalRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalRequest"; +} +impl ::buffa::Message for CreateSidechainProposalRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.declaration.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.declaration.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_id = ::buffa::MessageField::none(); + self.declaration = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateSidechainProposalRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_SIDECHAIN_PROPOSAL_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize)] +#[serde(default)] +pub struct CreateSidechainProposalResponse { + #[serde(flatten)] + pub event: ::core::option::Option< + __buffa::oneof::create_sidechain_proposal_response::Event, + >, +} +impl ::core::fmt::Debug for CreateSidechainProposalResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateSidechainProposalResponse") + .field("event", &self.event) + .finish() + } +} +impl CreateSidechainProposalResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse"; +} +impl ::buffa::DefaultInstance for CreateSidechainProposalResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateSidechainProposalResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse"; +} +impl ::buffa::Message for CreateSidechainProposalResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + __buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + __buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + __buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + x.write_to(__cache, buf); + } + __buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + __buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + __buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + __buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + __buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::core::option::Option::None; + } +} +impl<'de> serde::Deserialize<'de> for CreateSidechainProposalResponse { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = CreateSidechainProposalResponse; + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("struct CreateSidechainProposalResponse") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_event: ::core::option::Option< + __buffa::oneof::create_sidechain_proposal_response::Event, + > = None; + while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? { + match key.as_str() { + "confirmed" => { + let v: ::core::option::Option< + create_sidechain_proposal_response::Confirmed, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + create_sidechain_proposal_response::Confirmed, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + __buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "notConfirmed" | "not_confirmed" => { + let v: ::core::option::Option< + create_sidechain_proposal_response::NotConfirmed, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + create_sidechain_proposal_response::NotConfirmed, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + __buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.event = __oneof_event; + Ok(__r) + } + } + d.deserialize_map(_V) + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateSidechainProposalResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_SIDECHAIN_PROPOSAL_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod create_sidechain_proposal_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Confirmed { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + /// Field 2: `confirmations` + #[serde( + rename = "confirmations", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub confirmations: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 3: `height` + #[serde( + rename = "height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub height: ::buffa::MessageField<::buffa_types::google::protobuf::UInt32Value>, + /// Field 4: `outpoint` + #[serde( + rename = "outpoint", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub outpoint: ::buffa::MessageField, + /// Field 5: `prev_block_hash` + #[serde( + rename = "prevBlockHash", + alias = "prev_block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub prev_block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + } + impl ::core::fmt::Debug for Confirmed { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Confirmed") + .field("block_hash", &self.block_hash) + .field("confirmations", &self.confirmations) + .field("height", &self.height) + .field("outpoint", &self.outpoint) + .field("prev_block_hash", &self.prev_block_hash) + .finish() + } + } + impl Confirmed { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed"; + } + impl ::buffa::DefaultInstance for Confirmed { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Confirmed { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse.Confirmed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed"; + } + impl ::buffa::Message for Confirmed { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.confirmations.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmations.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.outpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.outpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.confirmations.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.confirmations.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.height.write_to(__cache, buf); + } + if self.outpoint.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.outpoint.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.confirmations.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.height.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.outpoint.get_or_insert_default(), + buf, + depth, + )?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.prev_block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.confirmations = ::buffa::MessageField::none(); + self.height = ::buffa::MessageField::none(); + self.outpoint = ::buffa::MessageField::none(); + self.prev_block_hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Confirmed { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __CONFIRMED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct NotConfirmed { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + /// Field 2: `height` + #[serde( + rename = "height", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub height: ::buffa::MessageField<::buffa_types::google::protobuf::UInt32Value>, + /// Field 3: `prev_block_hash` + #[serde( + rename = "prevBlockHash", + alias = "prev_block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub prev_block_hash: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + } + impl ::core::fmt::Debug for NotConfirmed { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("NotConfirmed") + .field("block_hash", &self.block_hash) + .field("height", &self.height) + .field("prev_block_hash", &self.prev_block_hash) + .finish() + } + } + impl NotConfirmed { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed"; + } + impl ::buffa::DefaultInstance for NotConfirmed { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for NotConfirmed { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse.NotConfirmed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed"; + } + impl ::buffa::Message for NotConfirmed { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.height.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.height.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.prev_block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + self.height = ::buffa::MessageField::none(); + self.prev_block_hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for NotConfirmed { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __NOT_CONFIRMED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::oneof::create_sidechain_proposal_response::Event; + #[doc(inline)] + pub use super::__buffa::view::create_sidechain_proposal_response::ConfirmedView; + #[doc(inline)] + pub use super::__buffa::view::create_sidechain_proposal_response::NotConfirmedView; + #[doc(inline)] + pub use super::__buffa::view::oneof::create_sidechain_proposal_response::Event as EventView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateWalletRequest { + /// BIP39 mnemonic. 12 or 24 words. + /// + /// Field 1: `mnemonic_words` + #[serde( + rename = "mnemonicWords", + alias = "mnemonic_words", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub mnemonic_words: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>, + /// Path to a file containing the mnemonic. + /// + /// Field 2: `mnemonic_path` + #[serde( + rename = "mnemonicPath", + alias = "mnemonic_path", + with = "::buffa::json_helpers::proto_string", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str" + )] + pub mnemonic_path: ::buffa::alloc::string::String, + /// Password for the wallet. Used to encrypt the mnemonic in storage. + /// NOT a BIP39 passphrase. + /// + /// Field 3: `password` + #[serde( + rename = "password", + with = "::buffa::json_helpers::proto_string", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str" + )] + pub password: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for CreateWalletRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateWalletRequest") + .field("mnemonic_words", &self.mnemonic_words) + .field("mnemonic_path", &self.mnemonic_path) + .field("password", &self.password) + .finish() + } +} +impl CreateWalletRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletRequest"; +} +impl ::buffa::DefaultInstance for CreateWalletRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateWalletRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateWalletRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateWalletRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletRequest"; +} +impl ::buffa::Message for CreateWalletRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.mnemonic_words { + size += 1u32 + ::buffa::types::string_encoded_len(v) as u32; + } + if !self.mnemonic_path.is_empty() { + size + += 1u32 + ::buffa::types::string_encoded_len(&self.mnemonic_path) as u32; + } + if !self.password.is_empty() { + size += 1u32 + ::buffa::types::string_encoded_len(&self.password) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.mnemonic_words { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + if !self.mnemonic_path.is_empty() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.mnemonic_path, buf); + } + if !self.password.is_empty() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.password, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + self.mnemonic_words.push(::buffa::types::decode_string(buf)?); + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string(&mut self.mnemonic_path, buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string(&mut self.password, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.mnemonic_words.clear(); + self.mnemonic_path.clear(); + self.password.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for CreateWalletRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_WALLET_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateWalletRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct CreateWalletResponse {} +impl ::core::fmt::Debug for CreateWalletResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CreateWalletResponse").finish() + } +} +impl CreateWalletResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletResponse"; +} +impl ::buffa::DefaultInstance for CreateWalletResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for CreateWalletResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateWalletResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateWalletResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletResponse"; +} +impl ::buffa::Message for CreateWalletResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for CreateWalletResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __CREATE_WALLET_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.CreateWalletResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBalanceRequest {} +impl ::core::fmt::Debug for GetBalanceRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBalanceRequest").finish() + } +} +impl GetBalanceRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceRequest"; +} +impl ::buffa::DefaultInstance for GetBalanceRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBalanceRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBalanceRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBalanceRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceRequest"; +} +impl ::buffa::Message for GetBalanceRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetBalanceRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BALANCE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBalanceRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetBalanceResponse { + /// Field 1: `confirmed_sats` + #[serde( + rename = "confirmedSats", + alias = "confirmed_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub confirmed_sats: u64, + /// Field 2: `pending_sats` + #[serde( + rename = "pendingSats", + alias = "pending_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub pending_sats: u64, + /// Whether the wallet has completed its initial sync. + /// + /// Field 3: `has_synced` + #[serde( + rename = "hasSynced", + alias = "has_synced", + with = "::buffa::json_helpers::proto_bool", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_false" + )] + pub has_synced: bool, +} +impl ::core::fmt::Debug for GetBalanceResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetBalanceResponse") + .field("confirmed_sats", &self.confirmed_sats) + .field("pending_sats", &self.pending_sats) + .field("has_synced", &self.has_synced) + .finish() + } +} +impl GetBalanceResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceResponse"; +} +impl ::buffa::DefaultInstance for GetBalanceResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetBalanceResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBalanceResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBalanceResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceResponse"; +} +impl ::buffa::Message for GetBalanceResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.confirmed_sats != 0u64 { + size + += 1u32 + ::buffa::types::uint64_encoded_len(self.confirmed_sats) as u32; + } + if self.pending_sats != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.pending_sats) as u32; + } + if self.has_synced { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.confirmed_sats != 0u64 { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.confirmed_sats, buf); + } + if self.pending_sats != 0u64 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.pending_sats, buf); + } + if self.has_synced { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_bool(self.has_synced, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.confirmed_sats = ::buffa::types::decode_uint64(buf)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.pending_sats = ::buffa::types::decode_uint64(buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.has_synced = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.confirmed_sats = 0u64; + self.pending_sats = 0u64; + self.has_synced = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetBalanceResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_BALANCE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetBalanceResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListSidechainDepositTransactionsRequest {} +impl ::core::fmt::Debug for ListSidechainDepositTransactionsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListSidechainDepositTransactionsRequest").finish() + } +} +impl ListSidechainDepositTransactionsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsRequest"; +} +impl ::buffa::DefaultInstance for ListSidechainDepositTransactionsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + ListSidechainDepositTransactionsRequest, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListSidechainDepositTransactionsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsRequest"; +} +impl ::buffa::Message for ListSidechainDepositTransactionsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for ListSidechainDepositTransactionsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsRequest", + to_json: ::buffa::type_registry::any_to_json::< + ListSidechainDepositTransactionsRequest, + >, + from_json: ::buffa::type_registry::any_from_json::< + ListSidechainDepositTransactionsRequest, + >, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListSidechainDepositTransactionsResponse { + /// Field 1: `transactions` + #[serde( + rename = "transactions", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub transactions: ::buffa::alloc::vec::Vec< + list_sidechain_deposit_transactions_response::SidechainDepositTransaction, + >, +} +impl ::core::fmt::Debug for ListSidechainDepositTransactionsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListSidechainDepositTransactionsResponse") + .field("transactions", &self.transactions) + .finish() + } +} +impl ListSidechainDepositTransactionsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse"; +} +impl ::buffa::DefaultInstance for ListSidechainDepositTransactionsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox< + ListSidechainDepositTransactionsResponse, + > = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListSidechainDepositTransactionsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse"; +} +impl ::buffa::Message for ListSidechainDepositTransactionsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.transactions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.transactions { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.transactions.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.transactions.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListSidechainDepositTransactionsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse", + to_json: ::buffa::type_registry::any_to_json::< + ListSidechainDepositTransactionsResponse, + >, + from_json: ::buffa::type_registry::any_from_json::< + ListSidechainDepositTransactionsResponse, + >, + is_wkt: false, +}; +pub mod list_sidechain_deposit_transactions_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct SidechainDepositTransaction { + /// Field 1: `sidechain_number` + #[serde( + rename = "sidechainNumber", + alias = "sidechain_number", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sidechain_number: ::buffa::MessageField< + ::buffa_types::google::protobuf::UInt32Value, + >, + /// Field 2: `tx` + #[serde( + rename = "tx", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub tx: ::buffa::MessageField, + } + impl ::core::fmt::Debug for SidechainDepositTransaction { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SidechainDepositTransaction") + .field("sidechain_number", &self.sidechain_number) + .field("tx", &self.tx) + .finish() + } + } + impl SidechainDepositTransaction { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + } + impl ::buffa::DefaultInstance for SidechainDepositTransaction { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for SidechainDepositTransaction { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + } + impl ::buffa::Message for SidechainDepositTransaction { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.tx.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.tx.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + if self.tx.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.tx.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sidechain_number.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.tx.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sidechain_number = ::buffa::MessageField::none(); + self.tx = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for SidechainDepositTransaction { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __SIDECHAIN_DEPOSIT_TRANSACTION_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::list_sidechain_deposit_transactions_response::SidechainDepositTransactionView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListTransactionsRequest {} +impl ::core::fmt::Debug for ListTransactionsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListTransactionsRequest").finish() + } +} +impl ListTransactionsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsRequest"; +} +impl ::buffa::DefaultInstance for ListTransactionsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListTransactionsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListTransactionsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListTransactionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsRequest"; +} +impl ::buffa::Message for ListTransactionsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for ListTransactionsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_TRANSACTIONS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListTransactionsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListTransactionsResponse { + /// Field 1: `transactions` + #[serde( + rename = "transactions", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub transactions: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ListTransactionsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListTransactionsResponse") + .field("transactions", &self.transactions) + .finish() + } +} +impl ListTransactionsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsResponse"; +} +impl ::buffa::DefaultInstance for ListTransactionsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListTransactionsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListTransactionsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListTransactionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsResponse"; +} +impl ::buffa::Message for ListTransactionsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.transactions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.transactions { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.transactions.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.transactions.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListTransactionsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_TRANSACTIONS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListTransactionsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SendTransactionRequest { + /// Address -\> satoshi amount + /// + /// Field 1: `destinations` + #[serde( + rename = "destinations", + with = "::buffa::json_helpers::proto_map", + skip_serializing_if = "::buffa::__private::HashMap::is_empty" + )] + pub destinations: ::buffa::__private::HashMap<::buffa::alloc::string::String, u64>, + /// If not set, a reasonable rate is used by asking Core for an estimate. + /// + /// Field 2: `fee_rate` + #[serde( + rename = "feeRate", + alias = "fee_rate", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub fee_rate: ::buffa::MessageField, + /// if set, the transaction will add a separate OP_RETURN output with this + /// message. + /// + /// Field 3: `op_return_message` + #[serde( + rename = "opReturnMessage", + alias = "op_return_message", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub op_return_message: ::buffa::MessageField, + /// UTXOs that must be included in the transaction. Incompatible with + /// specifying a draining address. + /// + /// Field 4: `required_utxos` + #[serde( + rename = "requiredUtxos", + alias = "required_utxos", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub required_utxos: ::buffa::alloc::vec::Vec, + /// If set, the transaction will send all UTXOs in the wallet to this address. + /// Incompatible with specifying required UTXOs. + /// + /// Field 5: `drain_wallet_to` + #[serde( + rename = "drainWalletTo", + alias = "drain_wallet_to", + skip_serializing_if = "::core::option::Option::is_none" + )] + pub drain_wallet_to: ::core::option::Option<::buffa::alloc::string::String>, +} +impl ::core::fmt::Debug for SendTransactionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SendTransactionRequest") + .field("destinations", &self.destinations) + .field("fee_rate", &self.fee_rate) + .field("op_return_message", &self.op_return_message) + .field("required_utxos", &self.required_utxos) + .field("drain_wallet_to", &self.drain_wallet_to) + .finish() + } +} +impl SendTransactionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest"; +} +impl SendTransactionRequest { + #[must_use = "with_* setters return `self` by value; assign or chain the result"] + #[inline] + ///Sets [`Self::drain_wallet_to`] to `Some(value)`, consuming and returning `self`. + pub fn with_drain_wallet_to( + mut self, + value: impl Into<::buffa::alloc::string::String>, + ) -> Self { + self.drain_wallet_to = Some(value.into()); + self + } +} +impl ::buffa::DefaultInstance for SendTransactionRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SendTransactionRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest"; +} +impl ::buffa::Message for SendTransactionRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + #[allow(clippy::for_kv_map)] + for (k, v) in &self.destinations { + let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32 + + 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + size + += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32 + + entry_size; + } + if self.fee_rate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fee_rate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.op_return_message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.op_return_message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.required_utxos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(ref v) = self.drain_wallet_to { + size += 1u32 + ::buffa::types::string_encoded_len(v) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for (k, v) in &self.destinations { + let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32 + + 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(entry_size as u64, buf); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(k, buf); + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(*v, buf); + } + if self.fee_rate.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.fee_rate.write_to(__cache, buf); + } + if self.op_return_message.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.op_return_message.write_to(__cache, buf); + } + for v in &self.required_utxos { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.drain_wallet_to { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let entry_len = ::buffa::encoding::decode_varint(buf)?; + let entry_len = usize::try_from(entry_len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < entry_len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + let entry_limit = buf.remaining() - entry_len; + let mut key = ::core::default::Default::default(); + let mut val = ::core::default::Default::default(); + while buf.remaining() > entry_limit { + let entry_tag = ::buffa::encoding::Tag::decode(buf)?; + match entry_tag.field_number() { + 1 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + key = ::buffa::types::decode_string(buf)?; + } + 2 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::Varint + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 0u8, + actual: entry_tag.wire_type() as u8, + }); + } + val = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(entry_tag, buf, depth)?; + } + } + } + if buf.remaining() != entry_limit { + let remaining = buf.remaining(); + if remaining > entry_limit { + buf.advance(remaining - entry_limit); + } else { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + } + self.destinations.insert(key, val); + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.fee_rate.get_or_insert_default(), + buf, + depth, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.op_return_message.get_or_insert_default(), + buf, + depth, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.required_utxos.push(elem); + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string( + self + .drain_wallet_to + .get_or_insert_with(::buffa::alloc::string::String::new), + buf, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.destinations.clear(); + self.fee_rate = ::buffa::MessageField::none(); + self.op_return_message = ::buffa::MessageField::none(); + self.required_utxos.clear(); + self.drain_wallet_to = ::core::option::Option::None; + } +} +impl ::buffa::json_helpers::ProtoElemJson for SendTransactionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SEND_TRANSACTION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod send_transaction_request { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct FeeRate { + #[serde(flatten)] + pub fee: ::core::option::Option< + super::__buffa::oneof::send_transaction_request::fee_rate::Fee, + >, + } + impl ::core::fmt::Debug for FeeRate { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FeeRate").field("fee", &self.fee).finish() + } + } + impl FeeRate { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.FeeRate"; + } + impl ::buffa::DefaultInstance for FeeRate { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for FeeRate { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest.FeeRate"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest.FeeRate"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.FeeRate"; + } + impl ::buffa::Message for FeeRate { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.fee { + match v { + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + v, + ) => { + size += 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + } + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::Sats( + v, + ) => { + size += 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + } + } + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.fee { + match v { + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(*x, buf); + } + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::Sats( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(*x, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.fee = ::core::option::Option::Some( + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + ::buffa::types::decode_uint64(buf)?, + ), + ); + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.fee = ::core::option::Option::Some( + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::Sats( + ::buffa::types::decode_uint64(buf)?, + ), + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.fee = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for FeeRate { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = FeeRate; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct FeeRate") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_fee: ::core::option::Option< + super::__buffa::oneof::send_transaction_request::fee_rate::Fee, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "satPerVbyte" | "sat_per_vbyte" => { + struct _DeserSeed; + impl<'de> serde::de::DeserializeSeed<'de> for _DeserSeed { + type Value = u64; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result { + ::buffa::json_helpers::uint64::deserialize(d) + } + } + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed(_DeserSeed), + )?; + if let Some(v) = v { + if __oneof_fee.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'fee'", + ), + ); + } + __oneof_fee = Some( + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + v, + ), + ); + } + } + "sats" => { + struct _DeserSeed; + impl<'de> serde::de::DeserializeSeed<'de> for _DeserSeed { + type Value = u64; + fn deserialize>( + self, + d: D, + ) -> ::core::result::Result { + ::buffa::json_helpers::uint64::deserialize(d) + } + } + let v: ::core::option::Option = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed(_DeserSeed), + )?; + if let Some(v) = v { + if __oneof_fee.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'fee'", + ), + ); + } + __oneof_fee = Some( + super::__buffa::oneof::send_transaction_request::fee_rate::Fee::Sats( + v, + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.fee = __oneof_fee; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for FeeRate { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __FEE_RATE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.FeeRate", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod fee_rate { + #[allow(unused_imports)] + use super::*; + #[doc(inline)] + pub use super::super::__buffa::oneof::send_transaction_request::fee_rate::Fee; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee as FeeView; + } + /// A previous unspent transaction output that must be included in the + /// transaction. + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct RequiredUtxo { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, + /// Field 2: `vout` + #[serde( + rename = "vout", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub vout: u32, + } + impl ::core::fmt::Debug for RequiredUtxo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("RequiredUtxo") + .field("txid", &self.txid) + .field("vout", &self.vout) + .finish() + } + } + impl RequiredUtxo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo"; + } + impl ::buffa::DefaultInstance for RequiredUtxo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for RequiredUtxo { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest.RequiredUtxo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo"; + } + impl ::buffa::Message for RequiredUtxo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.vout = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + self.vout = 0u32; + } + } + impl ::buffa::json_helpers::ProtoElemJson for RequiredUtxo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __REQUIRED_UTXO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::send_transaction_request::FeeRateView; + #[doc(inline)] + pub use super::__buffa::view::send_transaction_request::RequiredUtxoView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SendTransactionResponse { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, +} +impl ::core::fmt::Debug for SendTransactionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SendTransactionResponse").field("txid", &self.txid).finish() + } +} +impl SendTransactionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionResponse"; +} +impl ::buffa::DefaultInstance for SendTransactionResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SendTransactionResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionResponse"; +} +impl ::buffa::Message for SendTransactionResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SendTransactionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SEND_TRANSACTION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.SendTransactionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UnlockWalletRequest { + /// Field 1: `password` + #[serde( + rename = "password", + with = "::buffa::json_helpers::proto_string", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str" + )] + pub password: ::buffa::alloc::string::String, +} +impl ::core::fmt::Debug for UnlockWalletRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UnlockWalletRequest").field("password", &self.password).finish() + } +} +impl UnlockWalletRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletRequest"; +} +impl ::buffa::DefaultInstance for UnlockWalletRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for UnlockWalletRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "UnlockWalletRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.UnlockWalletRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletRequest"; +} +impl ::buffa::Message for UnlockWalletRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.password.is_empty() { + size += 1u32 + ::buffa::types::string_encoded_len(&self.password) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.password.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.password, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string(&mut self.password, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.password.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for UnlockWalletRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UNLOCK_WALLET_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.UnlockWalletRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct UnlockWalletResponse {} +impl ::core::fmt::Debug for UnlockWalletResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("UnlockWalletResponse").finish() + } +} +impl UnlockWalletResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletResponse"; +} +impl ::buffa::DefaultInstance for UnlockWalletResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for UnlockWalletResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "UnlockWalletResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.UnlockWalletResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletResponse"; +} +impl ::buffa::Message for UnlockWalletResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for UnlockWalletResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __UNLOCK_WALLET_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.UnlockWalletResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GenerateBlocksRequest { + /// Number of blocks to generate. + /// + /// Field 1: `blocks` + #[serde( + rename = "blocks", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub blocks: ::buffa::MessageField<::buffa_types::google::protobuf::UInt32Value>, + /// ACK all sidechain proposals, irregardless of if they are already + /// in the wallet DB. + /// + /// Field 2: `ack_all_proposals` + #[serde( + rename = "ackAllProposals", + alias = "ack_all_proposals", + with = "::buffa::json_helpers::proto_bool", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_false" + )] + pub ack_all_proposals: bool, +} +impl ::core::fmt::Debug for GenerateBlocksRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GenerateBlocksRequest") + .field("blocks", &self.blocks) + .field("ack_all_proposals", &self.ack_all_proposals) + .finish() + } +} +impl GenerateBlocksRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksRequest"; +} +impl ::buffa::DefaultInstance for GenerateBlocksRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GenerateBlocksRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GenerateBlocksRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GenerateBlocksRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksRequest"; +} +impl ::buffa::Message for GenerateBlocksRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.blocks.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.blocks.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.ack_all_proposals { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.blocks.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.blocks.write_to(__cache, buf); + } + if self.ack_all_proposals { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_bool(self.ack_all_proposals, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.blocks.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.ack_all_proposals = ::buffa::types::decode_bool(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.blocks = ::buffa::MessageField::none(); + self.ack_all_proposals = false; + } +} +impl ::buffa::json_helpers::ProtoElemJson for GenerateBlocksRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GENERATE_BLOCKS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GenerateBlocksResponse { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_hash: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GenerateBlocksResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GenerateBlocksResponse") + .field("block_hash", &self.block_hash) + .finish() + } +} +impl GenerateBlocksResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksResponse"; +} +impl ::buffa::DefaultInstance for GenerateBlocksResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GenerateBlocksResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GenerateBlocksResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GenerateBlocksResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksResponse"; +} +impl ::buffa::Message for GenerateBlocksResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GenerateBlocksResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GENERATE_BLOCKS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetInfoRequest {} +impl ::core::fmt::Debug for GetInfoRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetInfoRequest").finish() + } +} +impl GetInfoRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoRequest"; +} +impl ::buffa::DefaultInstance for GetInfoRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetInfoRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoRequest"; +} +impl ::buffa::Message for GetInfoRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetInfoRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_INFO_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetInfoRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetInfoResponse { + /// The network the wallet is on + /// + /// Field 1: `network` + #[serde( + rename = "network", + with = "::buffa::json_helpers::proto_string", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str" + )] + pub network: ::buffa::alloc::string::String, + /// Total number of transactions in the wallet + /// + /// Field 2: `transaction_count` + #[serde( + rename = "transactionCount", + alias = "transaction_count", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub transaction_count: u32, + /// Number of UTXOs in the wallet. + /// + /// Field 3: `unspent_output_count` + #[serde( + rename = "unspentOutputCount", + alias = "unspent_output_count", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub unspent_output_count: u32, + /// Field 4: `descriptors` + #[serde( + rename = "descriptors", + skip_serializing_if = "::buffa::__private::HashMap::is_empty", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub descriptors: ::buffa::__private::HashMap< + ::buffa::alloc::string::String, + ::buffa::alloc::string::String, + >, + /// The chain tip the wallet is synced to. + /// + /// Field 5: `tip` + #[serde( + rename = "tip", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub tip: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetInfoResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetInfoResponse") + .field("network", &self.network) + .field("transaction_count", &self.transaction_count) + .field("unspent_output_count", &self.unspent_output_count) + .field("descriptors", &self.descriptors) + .field("tip", &self.tip) + .finish() + } +} +impl GetInfoResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse"; +} +impl ::buffa::DefaultInstance for GetInfoResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetInfoResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse"; +} +impl ::buffa::Message for GetInfoResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.network.is_empty() { + size += 1u32 + ::buffa::types::string_encoded_len(&self.network) as u32; + } + if self.transaction_count != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.transaction_count) as u32; + } + if self.unspent_output_count != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.unspent_output_count) + as u32; + } + #[allow(clippy::for_kv_map)] + for (k, v) in &self.descriptors { + let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32 + + 1u32 + ::buffa::types::string_encoded_len(v) as u32; + size + += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32 + + entry_size; + } + if self.tip.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.tip.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.network.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.network, buf); + } + if self.transaction_count != 0u32 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.transaction_count, buf); + } + if self.unspent_output_count != 0u32 { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.unspent_output_count, buf); + } + for (k, v) in &self.descriptors { + let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32 + + 1u32 + ::buffa::types::string_encoded_len(v) as u32; + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(entry_size as u64, buf); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(k, buf); + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + if self.tip.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.tip.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_string(&mut self.network, buf)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.transaction_count = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.unspent_output_count = ::buffa::types::decode_uint32(buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let entry_len = ::buffa::encoding::decode_varint(buf)?; + let entry_len = usize::try_from(entry_len) + .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?; + if buf.remaining() < entry_len { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + let entry_limit = buf.remaining() - entry_len; + let mut key = ::core::default::Default::default(); + let mut val = ::core::default::Default::default(); + while buf.remaining() > entry_limit { + let entry_tag = ::buffa::encoding::Tag::decode(buf)?; + match entry_tag.field_number() { + 1 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + key = ::buffa::types::decode_string(buf)?; + } + 2 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + val = ::buffa::types::decode_string(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(entry_tag, buf, depth)?; + } + } + } + if buf.remaining() != entry_limit { + let remaining = buf.remaining(); + if remaining > entry_limit { + buf.advance(remaining - entry_limit); + } else { + return ::core::result::Result::Err( + ::buffa::DecodeError::UnexpectedEof, + ); + } + } + self.descriptors.insert(key, val); + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.tip.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.network.clear(); + self.transaction_count = 0u32; + self.unspent_output_count = 0u32; + self.descriptors.clear(); + self.tip = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetInfoResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_INFO_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod get_info_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Tip { + /// The height of the tip of the wallet. + /// + /// Field 1: `height` + #[serde( + rename = "height", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub height: u32, + /// The hash of the tip of the wallet. + /// + /// Field 2: `hash` + #[serde( + rename = "hash", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub hash: ::buffa::MessageField, + } + impl ::core::fmt::Debug for Tip { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Tip") + .field("height", &self.height) + .field("hash", &self.hash) + .finish() + } + } + impl Tip { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse.Tip"; + } + impl ::buffa::DefaultInstance for Tip { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Tip { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoResponse.Tip"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoResponse.Tip"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse.Tip"; + } + impl ::buffa::Message for Tip { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.height != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.height != 0u32 { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.hash.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.height = ::buffa::types::decode_uint32(buf)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.hash.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.height = 0u32; + self.hash = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Tip { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __TIP_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse.Tip", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::get_info_response::TipView; +} +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListUnspentOutputsRequest {} +impl ::core::fmt::Debug for ListUnspentOutputsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListUnspentOutputsRequest").finish() + } +} +impl ListUnspentOutputsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsRequest"; +} +impl ::buffa::DefaultInstance for ListUnspentOutputsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListUnspentOutputsRequest { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsRequest"; +} +impl ::buffa::Message for ListUnspentOutputsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for ListUnspentOutputsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_UNSPENT_OUTPUTS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct ListUnspentOutputsResponse { + /// Field 1: `outputs` + #[serde( + rename = "outputs", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec", + deserialize_with = "::buffa::json_helpers::null_as_default" + )] + pub outputs: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for ListUnspentOutputsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ListUnspentOutputsResponse") + .field("outputs", &self.outputs) + .finish() + } +} +impl ListUnspentOutputsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse"; +} +impl ::buffa::DefaultInstance for ListUnspentOutputsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for ListUnspentOutputsResponse { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse"; +} +impl ::buffa::Message for ListUnspentOutputsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.outputs { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.outputs { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let mut elem = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?; + self.outputs.push(elem); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.outputs.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for ListUnspentOutputsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __LIST_UNSPENT_OUTPUTS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod list_unspent_outputs_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct Output { + /// Field 1: `txid` + #[serde( + rename = "txid", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub txid: ::buffa::MessageField, + /// Field 2: `vout` + #[serde( + rename = "vout", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub vout: u32, + /// Field 3: `value_sats` + #[serde( + rename = "valueSats", + alias = "value_sats", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub value_sats: u64, + /// An internal output is one that was created by the wallet itself + /// as change output for a transaction. + /// + /// Field 4: `is_internal` + #[serde( + rename = "isInternal", + alias = "is_internal", + with = "::buffa::json_helpers::proto_bool", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_false" + )] + pub is_internal: bool, + /// Field 5: `is_confirmed` + #[serde( + rename = "isConfirmed", + alias = "is_confirmed", + with = "::buffa::json_helpers::proto_bool", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_false" + )] + pub is_confirmed: bool, + /// Field 6: `confirmed_at_block` + #[serde( + rename = "confirmedAtBlock", + alias = "confirmed_at_block", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub confirmed_at_block: u32, + /// Field 7: `confirmed_at_time` + #[serde( + rename = "confirmedAtTime", + alias = "confirmed_at_time", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub confirmed_at_time: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + >, + /// Field 8: `confirmed_transitively` + #[serde( + rename = "confirmedTransitively", + alias = "confirmed_transitively", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub confirmed_transitively: ::buffa::MessageField< + super::super::super::common::v1::ReverseHex, + >, + /// Field 9: `unconfirmed_last_seen` + #[serde( + rename = "unconfirmedLastSeen", + alias = "unconfirmed_last_seen", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub unconfirmed_last_seen: ::buffa::MessageField< + ::buffa_types::google::protobuf::Timestamp, + >, + /// The address corresponding to this output. Empty if we're unable + /// to represent it as an address. + /// + /// Field 10: `address` + #[serde( + rename = "address", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub address: ::buffa::MessageField<::buffa_types::google::protobuf::StringValue>, + } + impl ::core::fmt::Debug for Output { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Output") + .field("txid", &self.txid) + .field("vout", &self.vout) + .field("value_sats", &self.value_sats) + .field("is_internal", &self.is_internal) + .field("is_confirmed", &self.is_confirmed) + .field("confirmed_at_block", &self.confirmed_at_block) + .field("confirmed_at_time", &self.confirmed_at_time) + .field("confirmed_transitively", &self.confirmed_transitively) + .field("unconfirmed_last_seen", &self.unconfirmed_last_seen) + .field("address", &self.address) + .finish() + } + } + impl Output { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse.Output"; + } + impl ::buffa::DefaultInstance for Output { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Output { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsResponse.Output"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsResponse.Output"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse.Output"; + } + impl ::buffa::Message for Output { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + if self.value_sats != 0u64 { + size + += 1u32 + ::buffa::types::uint64_encoded_len(self.value_sats) as u32; + } + if self.is_internal { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + if self.is_confirmed { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + if self.confirmed_at_block != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.confirmed_at_block) + as u32; + } + if self.confirmed_at_time.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmed_at_time.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.confirmed_transitively.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmed_transitively.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.unconfirmed_last_seen.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.unconfirmed_last_seen.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + if self.value_sats != 0u64 { + ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.value_sats, buf); + } + if self.is_internal { + ::buffa::encoding::Tag::new(4u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_bool(self.is_internal, buf); + } + if self.is_confirmed { + ::buffa::encoding::Tag::new(5u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_bool(self.is_confirmed, buf); + } + if self.confirmed_at_block != 0u32 { + ::buffa::encoding::Tag::new(6u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.confirmed_at_block, buf); + } + if self.confirmed_at_time.is_set() { + ::buffa::encoding::Tag::new( + 7u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.confirmed_at_time.write_to(__cache, buf); + } + if self.confirmed_transitively.is_set() { + ::buffa::encoding::Tag::new( + 8u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.confirmed_transitively.write_to(__cache, buf); + } + if self.unconfirmed_last_seen.is_set() { + ::buffa::encoding::Tag::new( + 9u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.unconfirmed_last_seen.write_to(__cache, buf); + } + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 10u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.address.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.txid.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.vout = ::buffa::types::decode_uint32(buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.value_sats = ::buffa::types::decode_uint64(buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.is_internal = ::buffa::types::decode_bool(buf)?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.is_confirmed = ::buffa::types::decode_bool(buf)?; + } + 6u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.confirmed_at_block = ::buffa::types::decode_uint32(buf)?; + } + 7u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 7u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.confirmed_at_time.get_or_insert_default(), + buf, + depth, + )?; + } + 8u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 8u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.confirmed_transitively.get_or_insert_default(), + buf, + depth, + )?; + } + 9u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 9u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.unconfirmed_last_seen.get_or_insert_default(), + buf, + depth, + )?; + } + 10u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 10u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.address.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid = ::buffa::MessageField::none(); + self.vout = 0u32; + self.value_sats = 0u64; + self.is_internal = false; + self.is_confirmed = false; + self.confirmed_at_block = 0u32; + self.confirmed_at_time = ::buffa::MessageField::none(); + self.confirmed_transitively = ::buffa::MessageField::none(); + self.unconfirmed_last_seen = ::buffa::MessageField::none(); + self.address = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for Output { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __OUTPUT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse.Output", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::__buffa::view::list_unspent_outputs_response::OutputView; +} +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct OutPointView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 2: `vout` + pub vout: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + } + impl<'a> OutPointView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.vout.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.vout = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for OutPointView<'a> { + type Owned = super::super::OutPoint; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::OutPoint { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::OutPoint { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::OutPoint { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vout: match self.vout.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for OutPointView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vout.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.vout.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.vout.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for OutPointView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() { + __map.serialize_entry("txid", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.vout.as_option() { + __map.serialize_entry("vout", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for OutPointView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "OutPoint"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.OutPoint"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.OutPoint"; + } + impl<'v> ::buffa::DefaultViewInstance for OutPointView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for OutPointView<'static> { + type Reborrowed<'b> = OutPointView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SidechainDeclarationView<'a> { + pub sidechain_declaration: ::core::option::Option< + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration< + 'a, + >, + >, + } + impl<'a> SidechainDeclarationView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + ref mut existing, + ), + ) = view.sidechain_declaration + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.sidechain_declaration = Some( + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + ::buffa::alloc::boxed::Box::new( + super::super::__buffa::view::sidechain_declaration::V0View::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SidechainDeclarationView<'a> { + type Owned = super::super::SidechainDeclaration; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SidechainDeclaration { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SidechainDeclaration { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SidechainDeclaration { + sidechain_declaration: self + .sidechain_declaration + .as_ref() + .map(|v| match v { + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + v, + ) => { + super::super::__buffa::oneof::sidechain_declaration::SidechainDeclaration::V0( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SidechainDeclarationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.sidechain_declaration { + match v { + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.sidechain_declaration { + match v { + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SidechainDeclarationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self + .sidechain_declaration + { + match __ov { + super::super::__buffa::view::oneof::sidechain_declaration::SidechainDeclaration::V0( + v, + ) => { + __map.serialize_entry("v0", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SidechainDeclarationView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SidechainDeclaration"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SidechainDeclaration"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration"; + } + impl<'v> ::buffa::DefaultViewInstance for SidechainDeclarationView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SidechainDeclarationView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SidechainDeclarationView<'static> { + type Reborrowed<'b> = SidechainDeclarationView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod sidechain_declaration { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct V0View<'a> { + /// Field 1: `title` + pub title: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + /// Field 2: `description` + pub description: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + /// Field 3: `hash_id_1` + pub hash_id_1: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 4: `hash_id_2` + pub hash_id_2: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::HexView< + 'a, + >, + >, + } + impl<'a> V0View<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.title.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.title = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.description.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.description = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hash_id_1.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hash_id_1 = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hash_id_2.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hash_id_2 = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for V0View<'a> { + type Owned = super::super::super::sidechain_declaration::V0; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::sidechain_declaration::V0 { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::sidechain_declaration::V0 { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::sidechain_declaration::V0 { + title: match self.title.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + description: match self.description.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + hash_id_1: match self.hash_id_1.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + hash_id_2: match self.hash_id_2.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for V0View<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.title.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.title.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.hash_id_1.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash_id_1.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.hash_id_2.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash_id_2.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.title.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.title.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.description.write_to(__cache, buf); + } + if self.hash_id_1.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.hash_id_1.write_to(__cache, buf); + } + if self.hash_id_2.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.hash_id_2.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for V0View<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.title.as_option() + { + __map.serialize_entry("title", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .description + .as_option() + { + __map.serialize_entry("description", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .hash_id_1 + .as_option() + { + __map.serialize_entry("hashId1", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .hash_id_2 + .as_option() + { + __map.serialize_entry("hashId2", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for V0View<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SidechainDeclaration.V0"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SidechainDeclaration.V0"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SidechainDeclaration.V0"; + } + impl<'v> ::buffa::DefaultViewInstance for V0View<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for V0View<'static> { + type Reborrowed<'b> = V0View<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct BlockHeaderInfoView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 2: `prev_block_hash` + pub prev_block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 3: `height` + pub height: u32, + /// Total work as a uint256, little-endian + /// + /// Field 4: `work` + pub work: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Unix timestamp (seconds since epoch) + /// + /// Field 5: `timestamp` + pub timestamp: u64, + } + impl<'a> BlockHeaderInfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.prev_block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.prev_block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.height = ::buffa::types::decode_uint32(&mut cur)?; + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.work.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.work = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.timestamp = ::buffa::types::decode_uint64(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BlockHeaderInfoView<'a> { + type Owned = super::super::BlockHeaderInfo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::BlockHeaderInfo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BlockHeaderInfo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BlockHeaderInfo { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + prev_block_hash: match self.prev_block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + height: self.height, + work: match self.work.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + timestamp: self.timestamp, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BlockHeaderInfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height != 0u32 { + size + += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.work.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.work.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.timestamp != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.timestamp) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_block_hash.write_to(__cache, buf); + } + if self.height != 0u32 { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.work.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.work.write_to(__cache, buf); + } + if self.timestamp != 0u64 { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.timestamp, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BlockHeaderInfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .prev_block_hash + .as_option() + { + __map.serialize_entry("prevBlockHash", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.height) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("height", &_W(self.height))?; + } + { + if let ::core::option::Option::Some(__v) = self.work.as_option() { + __map.serialize_entry("work", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.timestamp) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("timestamp", &_W(self.timestamp))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for BlockHeaderInfoView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockHeaderInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockHeaderInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockHeaderInfo"; + } + impl<'v> ::buffa::DefaultViewInstance for BlockHeaderInfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + BlockHeaderInfoView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BlockHeaderInfoView<'static> { + type Reborrowed<'b> = BlockHeaderInfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct DepositView<'a> { + /// Field 1: `sequence_number` + pub sequence_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView<'a>, + >, + /// Field 2: `outpoint` + pub outpoint: ::buffa::MessageFieldView< + super::super::__buffa::view::OutPointView<'a>, + >, + /// Field 3: `output` + pub output: ::buffa::MessageFieldView< + super::super::__buffa::view::deposit::OutputView<'a>, + >, + } + impl<'a> DepositView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sequence_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sequence_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.outpoint.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.outpoint = ::buffa::MessageFieldView::set( + super::super::__buffa::view::OutPointView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.output.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.output = ::buffa::MessageFieldView::set( + super::super::__buffa::view::deposit::OutputView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for DepositView<'a> { + type Owned = super::super::Deposit; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::Deposit { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::Deposit { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::Deposit { + sequence_number: match self.sequence_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + outpoint: match self.outpoint.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::OutPoint, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + output: match self.output.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::deposit::Output, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for DepositView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.outpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.outpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.output.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.output.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_number.write_to(__cache, buf); + } + if self.outpoint.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.outpoint.write_to(__cache, buf); + } + if self.output.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.output.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for DepositView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sequence_number + .as_option() + { + __map.serialize_entry("sequenceNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.outpoint.as_option() + { + __map.serialize_entry("outpoint", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.output.as_option() { + __map.serialize_entry("output", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for DepositView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "Deposit"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.Deposit"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit"; + } + impl<'v> ::buffa::DefaultViewInstance for DepositView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for DepositView<'static> { + type Reborrowed<'b> = DepositView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod deposit { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct OutputView<'a> { + /// Field 2: `address` + pub address: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::HexView< + 'a, + >, + >, + /// Field 3: `value_sats` + pub value_sats: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView<'a>, + >, + } + impl<'a> OutputView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.address.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.address = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.value_sats.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.value_sats = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for OutputView<'a> { + type Owned = super::super::super::deposit::Output; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::super::deposit::Output { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::deposit::Output { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::deposit::Output { + address: match self.address.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + value_sats: match self.value_sats.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for OutputView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.address.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.value_sats.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for OutputView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .address + .as_option() + { + __map.serialize_entry("address", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .value_sats + .as_option() + { + __map.serialize_entry("valueSats", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for OutputView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "Deposit.Output"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.Deposit.Output"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.Deposit.Output"; + } + impl<'v> ::buffa::DefaultViewInstance for OutputView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for OutputView<'static> { + type Reborrowed<'b> = OutputView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct WithdrawalBundleEventView<'a> { + /// Field 1: `m6id` + pub m6id: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 2: `event` + pub event: ::buffa::MessageFieldView< + super::super::__buffa::view::withdrawal_bundle_event::EventView<'a>, + >, + } + impl<'a> WithdrawalBundleEventView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.m6id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.m6id = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.event.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.event = ::buffa::MessageFieldView::set( + super::super::__buffa::view::withdrawal_bundle_event::EventView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for WithdrawalBundleEventView<'a> { + type Owned = super::super::WithdrawalBundleEvent; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::WithdrawalBundleEvent { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::WithdrawalBundleEvent { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::WithdrawalBundleEvent { + m6id: match self.m6id.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + event: match self.event.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::withdrawal_bundle_event::Event, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for WithdrawalBundleEventView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.m6id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.m6id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.m6id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.m6id.write_to(__cache, buf); + } + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for WithdrawalBundleEventView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.m6id.as_option() { + __map.serialize_entry("m6id", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.event.as_option() { + __map.serialize_entry("event", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for WithdrawalBundleEventView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent"; + } + impl<'v> ::buffa::DefaultViewInstance for WithdrawalBundleEventView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + WithdrawalBundleEventView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for WithdrawalBundleEventView<'static> { + type Reborrowed<'b> = WithdrawalBundleEventView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod withdrawal_bundle_event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct EventView<'a> { + pub event: ::core::option::Option< + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event< + 'a, + >, + >, + } + impl<'a> EventView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::withdrawal_bundle_event::event::FailedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::withdrawal_bundle_event::event::SucceededView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::withdrawal_bundle_event::event::SubmittedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for EventView<'a> { + type Owned = super::super::super::withdrawal_bundle_event::Event; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::withdrawal_bundle_event::Event { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::withdrawal_bundle_event::Event { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::withdrawal_bundle_event::Event { + event: self + .event + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + v, + ) => { + super::super::super::__buffa::oneof::withdrawal_bundle_event::event::Event::Failed( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + v, + ) => { + super::super::super::__buffa::oneof::withdrawal_bundle_event::event::Event::Succeeded( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + v, + ) => { + super::super::super::__buffa::oneof::withdrawal_bundle_event::event::Event::Submitted( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for EventView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for EventView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.event { + match __ov { + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Failed( + v, + ) => { + __map.serialize_entry("failed", v)?; + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Succeeded( + v, + ) => { + __map.serialize_entry("succeeded", v)?; + } + super::super::super::__buffa::view::oneof::withdrawal_bundle_event::event::Event::Submitted( + v, + ) => { + __map.serialize_entry("submitted", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for EventView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event"; + } + impl<'v> ::buffa::DefaultViewInstance for EventView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for EventView<'static> { + type Reborrowed<'b> = EventView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct FailedView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> FailedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for FailedView<'a> { + type Owned = super::super::super::super::withdrawal_bundle_event::event::Failed; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::withdrawal_bundle_event::event::Failed { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::withdrawal_bundle_event::event::Failed { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::withdrawal_bundle_event::event::Failed { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for FailedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for FailedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for FailedView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Failed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Failed"; + } + impl<'v> ::buffa::DefaultViewInstance for FailedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for FailedView<'static> { + type Reborrowed<'b> = FailedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SucceededView<'a> { + /// Field 1: `sequence_number` + pub sequence_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView< + 'a, + >, + >, + /// Field 2: `transaction` + pub transaction: ::buffa::MessageFieldView< + super::super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> SucceededView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sequence_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sequence_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.transaction.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.transaction = ::buffa::MessageFieldView::set( + super::super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SucceededView<'a> { + type Owned = super::super::super::super::withdrawal_bundle_event::event::Succeeded; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::withdrawal_bundle_event::event::Succeeded { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::withdrawal_bundle_event::event::Succeeded { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::withdrawal_bundle_event::event::Succeeded { + sequence_number: match self.sequence_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + transaction: match self.transaction.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SucceededView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sequence_number.write_to(__cache, buf); + } + if self.transaction.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.transaction.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SucceededView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sequence_number + .as_option() + { + __map.serialize_entry("sequenceNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .transaction + .as_option() + { + __map.serialize_entry("transaction", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SucceededView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Succeeded"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Succeeded"; + } + impl<'v> ::buffa::DefaultViewInstance for SucceededView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SucceededView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SucceededView<'static> { + type Reborrowed<'b> = SucceededView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubmittedView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> SubmittedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubmittedView<'a> { + type Owned = super::super::super::super::withdrawal_bundle_event::event::Submitted; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::withdrawal_bundle_event::event::Submitted { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::withdrawal_bundle_event::event::Submitted { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::withdrawal_bundle_event::event::Submitted { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubmittedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubmittedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubmittedView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WithdrawalBundleEvent.Event.Submitted"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WithdrawalBundleEvent.Event.Submitted"; + } + impl<'v> ::buffa::DefaultViewInstance for SubmittedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubmittedView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubmittedView<'static> { + type Reborrowed<'b> = SubmittedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + } + /// Specific to an individual sidechain slot + #[derive(Clone, Debug, Default)] + pub struct BlockInfoView<'a> { + /// repeated Deposit deposits = 1; + /// repeated WithdrawalBundleEvent withdrawal_bundle_events = 2; + /// + /// Field 1: `bmm_commitment` + pub bmm_commitment: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 2: `events` + pub events: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::block_info::EventView<'a>, + >, + } + impl<'a> BlockInfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.bmm_commitment.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.bmm_commitment = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.events + .push( + super::super::__buffa::view::block_info::EventView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BlockInfoView<'a> { + type Owned = super::super::BlockInfo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::BlockInfo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BlockInfo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BlockInfo { + bmm_commitment: match self.bmm_commitment.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + events: self + .events + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BlockInfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.bmm_commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.bmm_commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.events { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.bmm_commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.bmm_commitment.write_to(__cache, buf); + } + for v in &self.events { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BlockInfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .bmm_commitment + .as_option() + { + __map.serialize_entry("bmmCommitment", __v)?; + } + } + if !self.events.is_empty() { + __map.serialize_entry("events", &*self.events)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for BlockInfoView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo"; + } + impl<'v> ::buffa::DefaultViewInstance for BlockInfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BlockInfoView<'static> { + type Reborrowed<'b> = BlockInfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod block_info { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct EventView<'a> { + pub event: ::core::option::Option< + super::super::super::__buffa::view::oneof::block_info::event::Event< + 'a, + >, + >, + } + impl<'a> EventView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::DepositView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::WithdrawalBundleEventView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for EventView<'a> { + type Owned = super::super::super::block_info::Event; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::super::block_info::Event { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::block_info::Event { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::block_info::Event { + event: self + .event + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + v, + ) => { + super::super::super::__buffa::oneof::block_info::event::Event::Deposit( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + v, + ) => { + super::super::super::__buffa::oneof::block_info::event::Event::WithdrawalBundle( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for EventView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for EventView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.event { + match __ov { + super::super::super::__buffa::view::oneof::block_info::event::Event::Deposit( + v, + ) => { + __map.serialize_entry("deposit", v)?; + } + super::super::super::__buffa::view::oneof::block_info::event::Event::WithdrawalBundle( + v, + ) => { + __map.serialize_entry("withdrawalBundle", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for EventView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BlockInfo.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BlockInfo.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BlockInfo.Event"; + } + impl<'v> ::buffa::DefaultViewInstance for EventView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for EventView<'static> { + type Reborrowed<'b> = EventView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBlockHeaderInfoRequestView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Request block header info for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 2: `max_ancestors` + pub max_ancestors: ::core::option::Option, + } + impl<'a> GetBlockHeaderInfoRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.max_ancestors = Some( + ::buffa::types::decode_uint32(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBlockHeaderInfoRequestView<'a> { + type Owned = super::super::GetBlockHeaderInfoRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBlockHeaderInfoRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBlockHeaderInfoRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBlockHeaderInfoRequest { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + max_ancestors: self.max_ancestors, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBlockHeaderInfoRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBlockHeaderInfoRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.max_ancestors { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("maxAncestors", &_W(__v))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBlockHeaderInfoRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockHeaderInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockHeaderInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBlockHeaderInfoRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBlockHeaderInfoRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBlockHeaderInfoRequestView<'static> { + type Reborrowed<'b> = GetBlockHeaderInfoRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBlockHeaderInfoResponseView<'a> { + /// Field 1: `header_infos` + pub header_infos: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::BlockHeaderInfoView<'a>, + >, + } + impl<'a> GetBlockHeaderInfoResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.header_infos + .push( + super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBlockHeaderInfoResponseView<'a> { + type Owned = super::super::GetBlockHeaderInfoResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBlockHeaderInfoResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBlockHeaderInfoResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBlockHeaderInfoResponse { + header_infos: self + .header_infos + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBlockHeaderInfoResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.header_infos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.header_infos { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBlockHeaderInfoResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.header_infos.is_empty() { + __map.serialize_entry("headerInfos", &*self.header_infos)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBlockHeaderInfoResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockHeaderInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockHeaderInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockHeaderInfoResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBlockHeaderInfoResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBlockHeaderInfoResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBlockHeaderInfoResponseView<'static> { + type Reborrowed<'b> = GetBlockHeaderInfoResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBlockInfoRequestView<'a> { + /// The block to fetch information about. + /// + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// The sidechain to filter for events relating to. + /// + /// Field 2: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Request block info for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 3: `max_ancestors` + pub max_ancestors: ::core::option::Option, + } + impl<'a> GetBlockInfoRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.max_ancestors = Some( + ::buffa::types::decode_uint32(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBlockInfoRequestView<'a> { + type Owned = super::super::GetBlockInfoRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBlockInfoRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBlockInfoRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBlockInfoRequest { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + max_ancestors: self.max_ancestors, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBlockInfoRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBlockInfoRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.max_ancestors { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("maxAncestors", &_W(__v))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBlockInfoRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBlockInfoRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBlockInfoRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBlockInfoRequestView<'static> { + type Reborrowed<'b> = GetBlockInfoRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBlockInfoResponseView<'a> { + /// Empty if the requested block was not found. + /// Ancestors MUST be sorted newest-first. + /// + /// Field 1: `infos` + pub infos: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_block_info_response::InfoView<'a>, + >, + } + impl<'a> GetBlockInfoResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.infos + .push( + super::super::__buffa::view::get_block_info_response::InfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBlockInfoResponseView<'a> { + type Owned = super::super::GetBlockInfoResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBlockInfoResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBlockInfoResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBlockInfoResponse { + infos: self + .infos + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBlockInfoResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.infos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.infos { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBlockInfoResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.infos.is_empty() { + __map.serialize_entry("infos", &*self.infos)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBlockInfoResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBlockInfoResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBlockInfoResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBlockInfoResponseView<'static> { + type Reborrowed<'b> = GetBlockInfoResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_block_info_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct InfoView<'a> { + /// Information about the block itself. + /// + /// Field 1: `header_info` + pub header_info: ::buffa::MessageFieldView< + super::super::super::__buffa::view::BlockHeaderInfoView<'a>, + >, + /// Information about the block, filtered for events relating to a specific + /// sidechain. + /// + /// Field 2: `block_info` + pub block_info: ::buffa::MessageFieldView< + super::super::super::__buffa::view::BlockInfoView<'a>, + >, + } + impl<'a> InfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.header_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.header_info = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_info = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::BlockInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for InfoView<'a> { + type Owned = super::super::super::get_block_info_response::Info; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_block_info_response::Info { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_block_info_response::Info { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_block_info_response::Info { + header_info: match self.header_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::BlockHeaderInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + block_info: match self.block_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::BlockInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for InfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_info.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for InfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .header_info + .as_option() + { + __map.serialize_entry("headerInfo", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .block_info + .as_option() + { + __map.serialize_entry("blockInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for InfoView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBlockInfoResponse.Info"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBlockInfoResponse.Info"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBlockInfoResponse.Info"; + } + impl<'v> ::buffa::DefaultViewInstance for InfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for InfoView<'static> { + type Reborrowed<'b> = InfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBmmHStarCommitmentRequestView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 2: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Request commitments for up to `max_ancestors` ancestors. + /// Fewer ancestors MAY be returned. + /// + /// Field 3: `max_ancestors` + pub max_ancestors: ::core::option::Option, + } + impl<'a> GetBmmHStarCommitmentRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.max_ancestors = Some( + ::buffa::types::decode_uint32(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBmmHStarCommitmentRequestView<'a> { + type Owned = super::super::GetBmmHStarCommitmentRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBmmHStarCommitmentRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBmmHStarCommitmentRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBmmHStarCommitmentRequest { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + max_ancestors: self.max_ancestors, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBmmHStarCommitmentRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(v) = self.max_ancestors { + size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if let Some(v) = self.max_ancestors { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(v, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBmmHStarCommitmentRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + if let ::core::option::Option::Some(__v) = self.max_ancestors { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("maxAncestors", &_W(__v))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBmmHStarCommitmentRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBmmHStarCommitmentRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBmmHStarCommitmentRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBmmHStarCommitmentRequestView<'static> { + type Reborrowed<'b> = GetBmmHStarCommitmentRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBmmHStarCommitmentResponseView<'a> { + pub result: ::core::option::Option< + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result< + 'a, + >, + >, + } + impl<'a> GetBmmHStarCommitmentResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ref mut existing, + ), + ) = view.result + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.result = Some( + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ::buffa::alloc::boxed::Box::new( + super::super::__buffa::view::get_bmm_h_star_commitment_response::BlockNotFoundErrorView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ref mut existing, + ), + ) = view.result + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.result = Some( + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ::buffa::alloc::boxed::Box::new( + super::super::__buffa::view::get_bmm_h_star_commitment_response::CommitmentView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBmmHStarCommitmentResponseView<'a> { + type Owned = super::super::GetBmmHStarCommitmentResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBmmHStarCommitmentResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBmmHStarCommitmentResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBmmHStarCommitmentResponse { + result: self + .result + .as_ref() + .map(|v| match v { + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + v, + ) => { + super::super::__buffa::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + v, + ) => { + super::super::__buffa::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBmmHStarCommitmentResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.result { + match v { + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.result { + match v { + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBmmHStarCommitmentResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.result { + match __ov { + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::BlockNotFound( + v, + ) => { + __map.serialize_entry("blockNotFound", v)?; + } + super::super::__buffa::view::oneof::get_bmm_h_star_commitment_response::Result::Commitment( + v, + ) => { + __map.serialize_entry("commitment", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBmmHStarCommitmentResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBmmHStarCommitmentResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBmmHStarCommitmentResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBmmHStarCommitmentResponseView<'static> { + type Reborrowed<'b> = GetBmmHStarCommitmentResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_bmm_h_star_commitment_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct BlockNotFoundErrorView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> BlockNotFoundErrorView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BlockNotFoundErrorView<'a> { + type Owned = super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BlockNotFoundErrorView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BlockNotFoundErrorView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for BlockNotFoundErrorView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.BlockNotFoundError"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.BlockNotFoundError"; + } + impl<'v> ::buffa::DefaultViewInstance for BlockNotFoundErrorView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + BlockNotFoundErrorView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BlockNotFoundErrorView<'static> { + type Reborrowed<'b> = BlockNotFoundErrorView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct OptionalCommitmentView<'a> { + /// Field 1: `commitment` + pub commitment: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> OptionalCommitmentView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.commitment.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.commitment = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for OptionalCommitmentView<'a> { + type Owned = super::super::super::get_bmm_h_star_commitment_response::OptionalCommitment; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_bmm_h_star_commitment_response::OptionalCommitment { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_bmm_h_star_commitment_response::OptionalCommitment { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_bmm_h_star_commitment_response::OptionalCommitment { + commitment: match self.commitment.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for OptionalCommitmentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.commitment.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for OptionalCommitmentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .commitment + .as_option() + { + __map.serialize_entry("commitment", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for OptionalCommitmentView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.OptionalCommitment"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.OptionalCommitment"; + } + impl<'v> ::buffa::DefaultViewInstance for OptionalCommitmentView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + OptionalCommitmentView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for OptionalCommitmentView<'static> { + type Reborrowed<'b> = OptionalCommitmentView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CommitmentView<'a> { + /// Field 1: `commitment` + pub commitment: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Ancestors MUST be sorted newest-first + /// + /// Field 2: `ancestor_commitments` + pub ancestor_commitments: ::buffa::RepeatedView< + 'a, + super::super::super::__buffa::view::get_bmm_h_star_commitment_response::OptionalCommitmentView< + 'a, + >, + >, + } + impl<'a> CommitmentView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.commitment.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.commitment = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.ancestor_commitments + .push( + super::super::super::__buffa::view::get_bmm_h_star_commitment_response::OptionalCommitmentView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CommitmentView<'a> { + type Owned = super::super::super::get_bmm_h_star_commitment_response::Commitment; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_bmm_h_star_commitment_response::Commitment { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_bmm_h_star_commitment_response::Commitment { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_bmm_h_star_commitment_response::Commitment { + commitment: match self.commitment.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ancestor_commitments: self + .ancestor_commitments + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CommitmentView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.commitment.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.commitment.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.ancestor_commitments { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.commitment.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.commitment.write_to(__cache, buf); + } + for v in &self.ancestor_commitments { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CommitmentView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .commitment + .as_option() + { + __map.serialize_entry("commitment", __v)?; + } + } + if !self.ancestor_commitments.is_empty() { + __map + .serialize_entry( + "ancestorCommitments", + &*self.ancestor_commitments, + )?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CommitmentView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBmmHStarCommitmentResponse.Commitment"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBmmHStarCommitmentResponse.Commitment"; + } + impl<'v> ::buffa::DefaultViewInstance for CommitmentView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CommitmentView<'static> { + type Reborrowed<'b> = CommitmentView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetChainInfoRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetChainInfoRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetChainInfoRequestView<'a> { + type Owned = super::super::GetChainInfoRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetChainInfoRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetChainInfoRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetChainInfoRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetChainInfoRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetChainInfoRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetChainInfoRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetChainInfoRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetChainInfoRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetChainInfoRequestView<'static> { + type Reborrowed<'b> = GetChainInfoRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetChainInfoResponseView<'a> { + /// Field 1: `network` + pub network: ::buffa::EnumValue, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetChainInfoResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.network = ::buffa::EnumValue::from( + ::buffa::types::decode_int32(&mut cur)?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetChainInfoResponseView<'a> { + type Owned = super::super::GetChainInfoResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetChainInfoResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetChainInfoResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetChainInfoResponse { + network: self.network, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetChainInfoResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + { + let val = self.network.to_i32(); + if val != 0 { + size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32; + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + { + let val = self.network.to_i32(); + if val != 0 { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_int32(val, buf); + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetChainInfoResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_default_enum_value( + &self.network, + ) { + __map.serialize_entry("network", &self.network)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetChainInfoResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainInfoResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetChainInfoResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetChainInfoResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetChainInfoResponseView<'static> { + type Reborrowed<'b> = GetChainInfoResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetChainTipRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetChainTipRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetChainTipRequestView<'a> { + type Owned = super::super::GetChainTipRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetChainTipRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetChainTipRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetChainTipRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetChainTipRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetChainTipRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetChainTipRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainTipRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainTipRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetChainTipRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetChainTipRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetChainTipRequestView<'static> { + type Reborrowed<'b> = GetChainTipRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetChainTipResponseView<'a> { + /// Field 1: `block_header_info` + pub block_header_info: ::buffa::MessageFieldView< + super::super::__buffa::view::BlockHeaderInfoView<'a>, + >, + } + impl<'a> GetChainTipResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_header_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_header_info = ::buffa::MessageFieldView::set( + super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetChainTipResponseView<'a> { + type Owned = super::super::GetChainTipResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetChainTipResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetChainTipResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetChainTipResponse { + block_header_info: match self.block_header_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::BlockHeaderInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetChainTipResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_header_info.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetChainTipResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_header_info + .as_option() + { + __map.serialize_entry("blockHeaderInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetChainTipResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetChainTipResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetChainTipResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetChainTipResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetChainTipResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetChainTipResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetChainTipResponseView<'static> { + type Reborrowed<'b> = GetChainTipResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetCoinbasePSBTRequestView<'a> { + /// Field 1: `propose_sidechains` + pub propose_sidechains: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_coinbase_psbt_request::ProposeSidechainView< + 'a, + >, + >, + /// Field 2: `ack_sidechains` + pub ack_sidechains: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_coinbase_psbt_request::AckSidechainView< + 'a, + >, + >, + /// Field 3: `propose_bundles` + pub propose_bundles: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_coinbase_psbt_request::ProposeBundleView< + 'a, + >, + >, + /// Field 4: `ack_bundles` + pub ack_bundles: ::buffa::MessageFieldView< + super::super::__buffa::view::get_coinbase_psbt_request::AckBundlesView< + 'a, + >, + >, + } + impl<'a> GetCoinbasePSBTRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ack_bundles.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.ack_bundles = ::buffa::MessageFieldView::set( + super::super::__buffa::view::get_coinbase_psbt_request::AckBundlesView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.propose_sidechains + .push( + super::super::__buffa::view::get_coinbase_psbt_request::ProposeSidechainView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.ack_sidechains + .push( + super::super::__buffa::view::get_coinbase_psbt_request::AckSidechainView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.propose_bundles + .push( + super::super::__buffa::view::get_coinbase_psbt_request::ProposeBundleView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetCoinbasePSBTRequestView<'a> { + type Owned = super::super::GetCoinbasePSBTRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetCoinbasePSBTRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetCoinbasePSBTRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetCoinbasePSBTRequest { + propose_sidechains: self + .propose_sidechains + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ack_sidechains: self + .ack_sidechains + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + propose_bundles: self + .propose_bundles + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ack_bundles: match self.ack_bundles.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::get_coinbase_psbt_request::AckBundles, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetCoinbasePSBTRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.propose_sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.ack_sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.propose_bundles { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.ack_bundles.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ack_bundles.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.propose_sidechains { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + for v in &self.ack_sidechains { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + for v in &self.propose_bundles { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + if self.ack_bundles.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.ack_bundles.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetCoinbasePSBTRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.propose_sidechains.is_empty() { + __map + .serialize_entry( + "proposeSidechains", + &*self.propose_sidechains, + )?; + } + if !self.ack_sidechains.is_empty() { + __map.serialize_entry("ackSidechains", &*self.ack_sidechains)?; + } + if !self.propose_bundles.is_empty() { + __map.serialize_entry("proposeBundles", &*self.propose_bundles)?; + } + { + if let ::core::option::Option::Some(__v) = self + .ack_bundles + .as_option() + { + __map.serialize_entry("ackBundles", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetCoinbasePSBTRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetCoinbasePSBTRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetCoinbasePSBTRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetCoinbasePSBTRequestView<'static> { + type Reborrowed<'b> = GetCoinbasePSBTRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_coinbase_psbt_request { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ProposeSidechainView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `data` + pub data: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> ProposeSidechainView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.data.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.data = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ProposeSidechainView<'a> { + type Owned = super::super::super::get_coinbase_psbt_request::ProposeSidechain; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_coinbase_psbt_request::ProposeSidechain { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_coinbase_psbt_request::ProposeSidechain { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_coinbase_psbt_request::ProposeSidechain { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + data: match self.data.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ProposeSidechainView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.data.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.data.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.data.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.data.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ProposeSidechainView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.data.as_option() + { + __map.serialize_entry("data", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ProposeSidechainView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.ProposeSidechain"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeSidechain"; + } + impl<'v> ::buffa::DefaultViewInstance for ProposeSidechainView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ProposeSidechainView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ProposeSidechainView<'static> { + type Reborrowed<'b> = ProposeSidechainView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct AckSidechainView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `data_hash` + pub data_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> AckSidechainView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.data_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.data_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for AckSidechainView<'a> { + type Owned = super::super::super::get_coinbase_psbt_request::AckSidechain; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_coinbase_psbt_request::AckSidechain { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_coinbase_psbt_request::AckSidechain { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_coinbase_psbt_request::AckSidechain { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + data_hash: match self.data_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for AckSidechainView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.data_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.data_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.data_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.data_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for AckSidechainView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .data_hash + .as_option() + { + __map.serialize_entry("dataHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for AckSidechainView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckSidechain"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckSidechain"; + } + impl<'v> ::buffa::DefaultViewInstance for AckSidechainView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + AckSidechainView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for AckSidechainView<'static> { + type Reborrowed<'b> = AckSidechainView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct ProposeBundleView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `bundle_txid` + pub bundle_txid: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> ProposeBundleView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.bundle_txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.bundle_txid = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ProposeBundleView<'a> { + type Owned = super::super::super::get_coinbase_psbt_request::ProposeBundle; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_coinbase_psbt_request::ProposeBundle { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_coinbase_psbt_request::ProposeBundle { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_coinbase_psbt_request::ProposeBundle { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + bundle_txid: match self.bundle_txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ProposeBundleView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.bundle_txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.bundle_txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.bundle_txid.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.bundle_txid.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ProposeBundleView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .bundle_txid + .as_option() + { + __map.serialize_entry("bundleTxid", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ProposeBundleView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.ProposeBundle"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.ProposeBundle"; + } + impl<'v> ::buffa::DefaultViewInstance for ProposeBundleView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ProposeBundleView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ProposeBundleView<'static> { + type Reborrowed<'b> = ProposeBundleView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct AckBundlesView<'a> { + pub ack_bundles: ::core::option::Option< + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles< + 'a, + >, + >, + } + impl<'a> AckBundlesView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ref mut existing, + ), + ) = view.ack_bundles + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.ack_bundles = Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::RepeatPreviousView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ref mut existing, + ), + ) = view.ack_bundles + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.ack_bundles = Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::LeadingBy50View::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ref mut existing, + ), + ) = view.ack_bundles + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.ack_bundles = Some( + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::UpvotesView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for AckBundlesView<'a> { + type Owned = super::super::super::get_coinbase_psbt_request::AckBundles; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_coinbase_psbt_request::AckBundles { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_coinbase_psbt_request::AckBundles { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_coinbase_psbt_request::AckBundles { + ack_bundles: self + .ack_bundles + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + v, + ) => { + super::super::super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + v, + ) => { + super::super::super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + v, + ) => { + super::super::super::__buffa::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for AckBundlesView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.ack_bundles { + match v { + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.ack_bundles { + match v { + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for AckBundlesView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.ack_bundles { + match __ov { + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::RepeatPrevious( + v, + ) => { + __map.serialize_entry("repeatPrevious", v)?; + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::LeadingBy50( + v, + ) => { + __map.serialize_entry("leadingBy50", v)?; + } + super::super::super::__buffa::view::oneof::get_coinbase_psbt_request::ack_bundles::AckBundles::Upvotes( + v, + ) => { + __map.serialize_entry("upvotes", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for AckBundlesView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles"; + } + impl<'v> ::buffa::DefaultViewInstance for AckBundlesView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for AckBundlesView<'static> { + type Reborrowed<'b> = AckBundlesView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod ack_bundles { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct RepeatPreviousView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> RepeatPreviousView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for RepeatPreviousView<'a> { + type Owned = super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for RepeatPreviousView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for RepeatPreviousView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for RepeatPreviousView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.RepeatPrevious"; + } + impl<'v> ::buffa::DefaultViewInstance for RepeatPreviousView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + RepeatPreviousView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for RepeatPreviousView<'static> { + type Reborrowed<'b> = RepeatPreviousView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct LeadingBy50View<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> LeadingBy50View<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for LeadingBy50View<'a> { + type Owned = super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50 { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50 { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50 { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for LeadingBy50View<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for LeadingBy50View<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for LeadingBy50View<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.LeadingBy50"; + } + impl<'v> ::buffa::DefaultViewInstance for LeadingBy50View<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + LeadingBy50View<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for LeadingBy50View<'static> { + type Reborrowed<'b> = LeadingBy50View<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct UpvotesView<'a> { + /// Field 1: `upvotes` + pub upvotes: ::buffa::RepeatedView<'a, u32>, + } + impl<'a> UpvotesView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + == ::buffa::encoding::WireType::LengthDelimited + { + let payload = ::buffa::types::borrow_bytes(&mut cur)?; + let mut pcur: &[u8] = payload; + while !pcur.is_empty() { + view.upvotes + .push(::buffa::types::decode_uint32(&mut pcur)?); + } + } else if tag.wire_type() + == ::buffa::encoding::WireType::Varint + { + view.upvotes.push(::buffa::types::decode_uint32(&mut cur)?); + } else { + return Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for UpvotesView<'a> { + type Owned = super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes { + upvotes: self.upvotes.to_vec(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for UpvotesView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.upvotes.is_empty() { + let payload: u32 = self + .upvotes + .iter() + .map(|&v| ::buffa::types::uint32_encoded_len(v) as u32) + .sum::(); + size + += 1u32 + + ::buffa::encoding::varint_len(payload as u64) as u32 + + payload; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.upvotes.is_empty() { + let payload: u32 = self + .upvotes + .iter() + .map(|&v| ::buffa::types::uint32_encoded_len(v) as u32) + .sum::(); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(payload as u64, buf); + for &v in &self.upvotes { + ::buffa::types::encode_uint32(v, buf); + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for UpvotesView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.upvotes.is_empty() { + struct _WSeq<'__x>(&'__x [u32]); + impl ::serde::Serialize for _WSeq<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::proto_seq::serialize(self.0, __s) + } + } + __map.serialize_entry("upvotes", &_WSeq(&self.upvotes))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for UpvotesView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTRequest.AckBundles.Upvotes"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTRequest.AckBundles.Upvotes"; + } + impl<'v> ::buffa::DefaultViewInstance for UpvotesView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + UpvotesView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for UpvotesView<'static> { + type Reborrowed<'b> = UpvotesView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetCoinbasePSBTResponseView<'a> { + /// Field 1: `psbt` + pub psbt: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + } + impl<'a> GetCoinbasePSBTResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.psbt.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.psbt = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetCoinbasePSBTResponseView<'a> { + type Owned = super::super::GetCoinbasePSBTResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetCoinbasePSBTResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetCoinbasePSBTResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetCoinbasePSBTResponse { + psbt: match self.psbt.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetCoinbasePSBTResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.psbt.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.psbt.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.psbt.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.psbt.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetCoinbasePSBTResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.psbt.as_option() { + __map.serialize_entry("psbt", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetCoinbasePSBTResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCoinbasePSBTResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCoinbasePSBTResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCoinbasePSBTResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetCoinbasePSBTResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetCoinbasePSBTResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetCoinbasePSBTResponseView<'static> { + type Reborrowed<'b> = GetCoinbasePSBTResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetCtipRequestView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + } + impl<'a> GetCtipRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetCtipRequestView<'a> { + type Owned = super::super::GetCtipRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetCtipRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetCtipRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetCtipRequest { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetCtipRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_number.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetCtipRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetCtipRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetCtipRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetCtipRequestView<'static> { + type Reborrowed<'b> = GetCtipRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetCtipResponseView<'a> { + /// Field 1: `ctip` + pub ctip: ::buffa::MessageFieldView< + super::super::__buffa::view::get_ctip_response::CtipView<'a>, + >, + } + impl<'a> GetCtipResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.ctip.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.ctip = ::buffa::MessageFieldView::set( + super::super::__buffa::view::get_ctip_response::CtipView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetCtipResponseView<'a> { + type Owned = super::super::GetCtipResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetCtipResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetCtipResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetCtipResponse { + ctip: match self.ctip.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::get_ctip_response::Ctip, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetCtipResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.ctip.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.ctip.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.ctip.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.ctip.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetCtipResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.ctip.as_option() { + __map.serialize_entry("ctip", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetCtipResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetCtipResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetCtipResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetCtipResponseView<'static> { + type Reborrowed<'b> = GetCtipResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_ctip_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct CtipView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 2: `vout` + pub vout: u32, + /// Field 3: `value` + pub value: u64, + /// Field 4: `sequence_number` + pub sequence_number: u64, + } + impl<'a> CtipView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.vout = ::buffa::types::decode_uint32(&mut cur)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.value = ::buffa::types::decode_uint64(&mut cur)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.sequence_number = ::buffa::types::decode_uint64( + &mut cur, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CtipView<'a> { + type Owned = super::super::super::get_ctip_response::Ctip; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_ctip_response::Ctip { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_ctip_response::Ctip { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_ctip_response::Ctip { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vout: self.vout, + value: self.value, + sequence_number: self.sequence_number, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CtipView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + if self.value != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.value) as u32; + } + if self.sequence_number != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.sequence_number) + as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + if self.value != 0u64 { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.value, buf); + } + if self.sequence_number != 0u64 { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.sequence_number, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CtipView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() + { + __map.serialize_entry("txid", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.vout) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("vout", &_W(self.vout))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.value) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("value", &_W(self.value))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64( + &self.sequence_number, + ) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map + .serialize_entry( + "sequenceNumber", + &_W(self.sequence_number), + )?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CtipView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetCtipResponse.Ctip"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetCtipResponse.Ctip"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetCtipResponse.Ctip"; + } + impl<'v> ::buffa::DefaultViewInstance for CtipView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CtipView<'static> { + type Reborrowed<'b> = CtipView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetSidechainProposalsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetSidechainProposalsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetSidechainProposalsRequestView<'a> { + type Owned = super::super::GetSidechainProposalsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetSidechainProposalsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetSidechainProposalsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetSidechainProposalsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetSidechainProposalsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetSidechainProposalsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetSidechainProposalsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetSidechainProposalsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetSidechainProposalsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetSidechainProposalsRequestView<'static> { + type Reborrowed<'b> = GetSidechainProposalsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetSidechainProposalsResponseView<'a> { + /// Field 1: `sidechain_proposals` + pub sidechain_proposals: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_sidechain_proposals_response::SidechainProposalView< + 'a, + >, + >, + } + impl<'a> GetSidechainProposalsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.sidechain_proposals + .push( + super::super::__buffa::view::get_sidechain_proposals_response::SidechainProposalView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetSidechainProposalsResponseView<'a> { + type Owned = super::super::GetSidechainProposalsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetSidechainProposalsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetSidechainProposalsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetSidechainProposalsResponse { + sidechain_proposals: self + .sidechain_proposals + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetSidechainProposalsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.sidechain_proposals { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.sidechain_proposals { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetSidechainProposalsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.sidechain_proposals.is_empty() { + __map + .serialize_entry( + "sidechainProposals", + &*self.sidechain_proposals, + )?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetSidechainProposalsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetSidechainProposalsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetSidechainProposalsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetSidechainProposalsResponseView<'static> { + type Reborrowed<'b> = GetSidechainProposalsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_sidechain_proposals_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct SidechainProposalView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Raw sidechain proposal description + /// + /// Field 2: `description` + pub description: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Sidechain data, as declared in the M1 proposal. + /// Might be nil, if the proposal uses an unknown version. + /// + /// Field 7: `declaration` + pub declaration: ::buffa::MessageFieldView< + super::super::super::__buffa::view::SidechainDeclarationView<'a>, + >, + /// Field 3: `description_sha256d_hash` + pub description_sha256d_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 4: `vote_count` + pub vote_count: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 5: `proposal_height` + pub proposal_height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 6: `proposal_age` + pub proposal_age: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + } + impl<'a> SidechainProposalView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.description.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.description = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 7u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 7u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.declaration.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.declaration = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::SidechainDeclarationView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.description_sha256d_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.description_sha256d_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.vote_count.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.vote_count = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.proposal_height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.proposal_height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 6u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.proposal_age.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.proposal_age = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SidechainProposalView<'a> { + type Owned = super::super::super::get_sidechain_proposals_response::SidechainProposal; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_sidechain_proposals_response::SidechainProposal { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_sidechain_proposals_response::SidechainProposal { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_sidechain_proposals_response::SidechainProposal { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + description: match self.description.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + declaration: match self.declaration.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::SidechainDeclaration, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + description_sha256d_hash: match self + .description_sha256d_hash + .as_option() + { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vote_count: match self.vote_count.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + proposal_height: match self.proposal_height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + proposal_age: match self.proposal_age.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SidechainProposalView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description_sha256d_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self + .description_sha256d_hash + .compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vote_count.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vote_count.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_age.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_age.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.description.write_to(__cache, buf); + } + if self.description_sha256d_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.description_sha256d_hash.write_to(__cache, buf); + } + if self.vote_count.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.vote_count.write_to(__cache, buf); + } + if self.proposal_height.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.proposal_height.write_to(__cache, buf); + } + if self.proposal_age.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.proposal_age.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 7u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.declaration.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SidechainProposalView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .description + .as_option() + { + __map.serialize_entry("description", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .declaration + .as_option() + { + __map.serialize_entry("declaration", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .description_sha256d_hash + .as_option() + { + __map.serialize_entry("descriptionSha256dHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .vote_count + .as_option() + { + __map.serialize_entry("voteCount", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .proposal_height + .as_option() + { + __map.serialize_entry("proposalHeight", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .proposal_age + .as_option() + { + __map.serialize_entry("proposalAge", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SidechainProposalView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainProposalsResponse.SidechainProposal"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainProposalsResponse.SidechainProposal"; + } + impl<'v> ::buffa::DefaultViewInstance for SidechainProposalView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SidechainProposalView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SidechainProposalView<'static> { + type Reborrowed<'b> = SidechainProposalView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetSidechainsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetSidechainsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetSidechainsRequestView<'a> { + type Owned = super::super::GetSidechainsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetSidechainsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetSidechainsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetSidechainsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetSidechainsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetSidechainsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetSidechainsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetSidechainsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetSidechainsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetSidechainsRequestView<'static> { + type Reborrowed<'b> = GetSidechainsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetSidechainsResponseView<'a> { + /// Field 1: `sidechains` + pub sidechains: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_sidechains_response::SidechainInfoView< + 'a, + >, + >, + } + impl<'a> GetSidechainsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.sidechains + .push( + super::super::__buffa::view::get_sidechains_response::SidechainInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetSidechainsResponseView<'a> { + type Owned = super::super::GetSidechainsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetSidechainsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetSidechainsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetSidechainsResponse { + sidechains: self + .sidechains + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetSidechainsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.sidechains { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.sidechains { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetSidechainsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.sidechains.is_empty() { + __map.serialize_entry("sidechains", &*self.sidechains)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetSidechainsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetSidechainsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetSidechainsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetSidechainsResponseView<'static> { + type Reborrowed<'b> = GetSidechainsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_sidechains_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct SidechainInfoView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `description` + pub description: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 3: `vote_count` + pub vote_count: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 4: `proposal_height` + pub proposal_height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 5: `activation_height` + pub activation_height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Sidechain data, as declared in the M1 proposal. + /// Might be nil, if the proposal uses an unknown version. + /// + /// Field 6: `declaration` + pub declaration: ::buffa::MessageFieldView< + super::super::super::__buffa::view::SidechainDeclarationView<'a>, + >, + } + impl<'a> SidechainInfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.description.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.description = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.vote_count.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.vote_count = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.proposal_height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.proposal_height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.activation_height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.activation_height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 6u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.declaration.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.declaration = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::SidechainDeclarationView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SidechainInfoView<'a> { + type Owned = super::super::super::get_sidechains_response::SidechainInfo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_sidechains_response::SidechainInfo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_sidechains_response::SidechainInfo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_sidechains_response::SidechainInfo { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + description: match self.description.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vote_count: match self.vote_count.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + proposal_height: match self.proposal_height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + activation_height: match self.activation_height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + declaration: match self.declaration.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::SidechainDeclaration, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SidechainInfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.description.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.description.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vote_count.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.vote_count.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.proposal_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.proposal_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.activation_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.activation_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.description.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.description.write_to(__cache, buf); + } + if self.vote_count.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.vote_count.write_to(__cache, buf); + } + if self.proposal_height.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.proposal_height.write_to(__cache, buf); + } + if self.activation_height.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.activation_height.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.declaration.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SidechainInfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .description + .as_option() + { + __map.serialize_entry("description", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .vote_count + .as_option() + { + __map.serialize_entry("voteCount", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .proposal_height + .as_option() + { + __map.serialize_entry("proposalHeight", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .activation_height + .as_option() + { + __map.serialize_entry("activationHeight", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .declaration + .as_option() + { + __map.serialize_entry("declaration", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SidechainInfoView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetSidechainsResponse.SidechainInfo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetSidechainsResponse.SidechainInfo"; + } + impl<'v> ::buffa::DefaultViewInstance for SidechainInfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SidechainInfoView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SidechainInfoView<'static> { + type Reborrowed<'b> = SidechainInfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct GetTwoWayPegDataRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `start_block_hash` + pub start_block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 3: `end_block_hash` + pub end_block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> GetTwoWayPegDataRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.start_block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.start_block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.end_block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.end_block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetTwoWayPegDataRequestView<'a> { + type Owned = super::super::GetTwoWayPegDataRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetTwoWayPegDataRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetTwoWayPegDataRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetTwoWayPegDataRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + start_block_hash: match self.start_block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + end_block_hash: match self.end_block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetTwoWayPegDataRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.start_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.start_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.end_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.end_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.start_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.start_block_hash.write_to(__cache, buf); + } + if self.end_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.end_block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetTwoWayPegDataRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .start_block_hash + .as_option() + { + __map.serialize_entry("startBlockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .end_block_hash + .as_option() + { + __map.serialize_entry("endBlockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetTwoWayPegDataRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetTwoWayPegDataRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetTwoWayPegDataRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetTwoWayPegDataRequestView<'static> { + type Reborrowed<'b> = GetTwoWayPegDataRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetTwoWayPegDataResponseView<'a> { + /// Field 1: `blocks` + pub blocks: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::get_two_way_peg_data_response::ResponseItemView< + 'a, + >, + >, + } + impl<'a> GetTwoWayPegDataResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.blocks + .push( + super::super::__buffa::view::get_two_way_peg_data_response::ResponseItemView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetTwoWayPegDataResponseView<'a> { + type Owned = super::super::GetTwoWayPegDataResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetTwoWayPegDataResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetTwoWayPegDataResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetTwoWayPegDataResponse { + blocks: self + .blocks + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetTwoWayPegDataResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.blocks { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.blocks { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetTwoWayPegDataResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.blocks.is_empty() { + __map.serialize_entry("blocks", &*self.blocks)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetTwoWayPegDataResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetTwoWayPegDataResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetTwoWayPegDataResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetTwoWayPegDataResponseView<'static> { + type Reborrowed<'b> = GetTwoWayPegDataResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_two_way_peg_data_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ResponseItemView<'a> { + /// Field 1: `block_header_info` + pub block_header_info: ::buffa::MessageFieldView< + super::super::super::__buffa::view::BlockHeaderInfoView<'a>, + >, + /// Field 2: `block_info` + pub block_info: ::buffa::MessageFieldView< + super::super::super::__buffa::view::BlockInfoView<'a>, + >, + } + impl<'a> ResponseItemView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_header_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_header_info = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_info = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::BlockInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ResponseItemView<'a> { + type Owned = super::super::super::get_two_way_peg_data_response::ResponseItem; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_two_way_peg_data_response::ResponseItem { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_two_way_peg_data_response::ResponseItem { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_two_way_peg_data_response::ResponseItem { + block_header_info: match self.block_header_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::BlockHeaderInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + block_info: match self.block_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::BlockInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ResponseItemView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_info.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ResponseItemView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_header_info + .as_option() + { + __map.serialize_entry("blockHeaderInfo", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .block_info + .as_option() + { + __map.serialize_entry("blockInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ResponseItemView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetTwoWayPegDataResponse.ResponseItem"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetTwoWayPegDataResponse.ResponseItem"; + } + impl<'v> ::buffa::DefaultViewInstance for ResponseItemView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ResponseItemView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ResponseItemView<'static> { + type Reborrowed<'b> = ResponseItemView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct SubscribeEventsRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + } + impl<'a> SubscribeEventsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubscribeEventsRequestView<'a> { + type Owned = super::super::SubscribeEventsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubscribeEventsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeEventsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeEventsRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubscribeEventsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeEventsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeEventsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for SubscribeEventsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeEventsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeEventsRequestView<'static> { + type Reborrowed<'b> = SubscribeEventsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubscribeEventsResponseView<'a> { + /// Field 1: `event` + pub event: ::buffa::MessageFieldView< + super::super::__buffa::view::subscribe_events_response::EventView<'a>, + >, + } + impl<'a> SubscribeEventsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.event.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.event = ::buffa::MessageFieldView::set( + super::super::__buffa::view::subscribe_events_response::EventView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubscribeEventsResponseView<'a> { + type Owned = super::super::SubscribeEventsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubscribeEventsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeEventsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeEventsResponse { + event: match self.event.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::subscribe_events_response::Event, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubscribeEventsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeEventsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.event.as_option() { + __map.serialize_entry("event", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeEventsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for SubscribeEventsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeEventsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeEventsResponseView<'static> { + type Reborrowed<'b> = SubscribeEventsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct EventView<'a> { + pub event: ::core::option::Option< + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event< + 'a, + >, + >, + } + impl<'a> EventView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for EventView<'a> { + type Owned = super::super::super::subscribe_events_response::Event; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::subscribe_events_response::Event { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::subscribe_events_response::Event { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::subscribe_events_response::Event { + event: self + .event + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for EventView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for EventView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.event { + match __ov { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + v, + ) => { + __map.serialize_entry("connectBlock", v)?; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + v, + ) => { + __map.serialize_entry("disconnectBlock", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for EventView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event"; + } + impl<'v> ::buffa::DefaultViewInstance for EventView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for EventView<'static> { + type Reborrowed<'b> = EventView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ConnectBlockView<'a> { + /// Field 1: `header_info` + pub header_info: ::buffa::MessageFieldView< + super::super::super::super::__buffa::view::BlockHeaderInfoView< + 'a, + >, + >, + /// Field 2: `block_info` + pub block_info: ::buffa::MessageFieldView< + super::super::super::super::__buffa::view::BlockInfoView<'a>, + >, + } + impl<'a> ConnectBlockView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.header_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.header_info = ::buffa::MessageFieldView::set( + super::super::super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_info = ::buffa::MessageFieldView::set( + super::super::super::super::__buffa::view::BlockInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ConnectBlockView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::ConnectBlock; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::ConnectBlock { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::ConnectBlock { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::ConnectBlock { + header_info: match self.header_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::BlockHeaderInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + block_info: match self.block_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::BlockInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ConnectBlockView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_info.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ConnectBlockView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .header_info + .as_option() + { + __map.serialize_entry("headerInfo", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .block_info + .as_option() + { + __map.serialize_entry("blockInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ConnectBlockView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.ConnectBlock"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl<'v> ::buffa::DefaultViewInstance for ConnectBlockView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ConnectBlockView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ConnectBlockView<'static> { + type Reborrowed<'b> = ConnectBlockView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct DisconnectBlockView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> DisconnectBlockView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for DisconnectBlockView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::DisconnectBlock; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::DisconnectBlock { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::DisconnectBlock { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::DisconnectBlock { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for DisconnectBlockView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for DisconnectBlockView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for DisconnectBlockView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.DisconnectBlock"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl<'v> ::buffa::DefaultViewInstance for DisconnectBlockView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + DisconnectBlockView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for DisconnectBlockView<'static> { + type Reborrowed<'b> = DisconnectBlockView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + } + /// Empty for now, could add filters later + #[derive(Clone, Debug, Default)] + pub struct SubscribeHeaderSyncProgressRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> SubscribeHeaderSyncProgressRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for SubscribeHeaderSyncProgressRequestView<'a> { + type Owned = super::super::SubscribeHeaderSyncProgressRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::SubscribeHeaderSyncProgressRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeHeaderSyncProgressRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeHeaderSyncProgressRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubscribeHeaderSyncProgressRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeHeaderSyncProgressRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeHeaderSyncProgressRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeHeaderSyncProgressRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for SubscribeHeaderSyncProgressRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeHeaderSyncProgressRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeHeaderSyncProgressRequestView<'static> { + type Reborrowed<'b> = SubscribeHeaderSyncProgressRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubscribeHeaderSyncProgressResponseView<'a> { + /// Current sync height may be unknown at the start of a sync + /// + /// Field 1: `current_height` + pub current_height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + } + impl<'a> SubscribeHeaderSyncProgressResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.current_height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.current_height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for SubscribeHeaderSyncProgressResponseView<'a> { + type Owned = super::super::SubscribeHeaderSyncProgressResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::SubscribeHeaderSyncProgressResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeHeaderSyncProgressResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeHeaderSyncProgressResponse { + current_height: match self.current_height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for SubscribeHeaderSyncProgressResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.current_height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.current_height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.current_height.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.current_height.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeHeaderSyncProgressResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .current_height + .as_option() + { + __map.serialize_entry("currentHeight", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeHeaderSyncProgressResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SubscribeHeaderSyncProgressResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SubscribeHeaderSyncProgressResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for SubscribeHeaderSyncProgressResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeHeaderSyncProgressResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeHeaderSyncProgressResponseView<'static> { + type Reborrowed<'b> = SubscribeHeaderSyncProgressResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct StopRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> StopRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for StopRequestView<'a> { + type Owned = super::super::StopRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::StopRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::StopRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::StopRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for StopRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for StopRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for StopRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "StopRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.StopRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for StopRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for StopRequestView<'static> { + type Reborrowed<'b> = StopRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct StopResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> StopResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for StopResponseView<'a> { + type Owned = super::super::StopResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::StopResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::StopResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::StopResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for StopResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for StopResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for StopResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "StopResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.StopResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.StopResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for StopResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for StopResponseView<'static> { + type Reborrowed<'b> = StopResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct WalletTransactionView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + /// Field 6: `raw_transaction` + pub raw_transaction: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 2: `fee_sats` + pub fee_sats: u64, + /// Field 3: `received_sats` + pub received_sats: u64, + /// Field 4: `sent_sats` + pub sent_sats: u64, + /// Field 5: `confirmation_info` + pub confirmation_info: ::buffa::MessageFieldView< + super::super::__buffa::view::wallet_transaction::ConfirmationView<'a>, + >, + } + impl<'a> WalletTransactionView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 6u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.raw_transaction.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.raw_transaction = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.fee_sats = ::buffa::types::decode_uint64(&mut cur)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.received_sats = ::buffa::types::decode_uint64( + &mut cur, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.sent_sats = ::buffa::types::decode_uint64(&mut cur)?; + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.confirmation_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.confirmation_info = ::buffa::MessageFieldView::set( + super::super::__buffa::view::wallet_transaction::ConfirmationView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for WalletTransactionView<'a> { + type Owned = super::super::WalletTransaction; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::WalletTransaction { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::WalletTransaction { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::WalletTransaction { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + raw_transaction: match self.raw_transaction.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + fee_sats: self.fee_sats, + received_sats: self.received_sats, + sent_sats: self.sent_sats, + confirmation_info: match self.confirmation_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::wallet_transaction::Confirmation, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for WalletTransactionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.fee_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.fee_sats) as u32; + } + if self.received_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.received_sats) + as u32; + } + if self.sent_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.sent_sats) as u32; + } + if self.confirmation_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmation_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.raw_transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.raw_transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + if self.fee_sats != 0u64 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.fee_sats, buf); + } + if self.received_sats != 0u64 { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.received_sats, buf); + } + if self.sent_sats != 0u64 { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.sent_sats, buf); + } + if self.confirmation_info.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.confirmation_info.write_to(__cache, buf); + } + if self.raw_transaction.is_set() { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.raw_transaction.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for WalletTransactionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() { + __map.serialize_entry("txid", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .raw_transaction + .as_option() + { + __map.serialize_entry("rawTransaction", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.fee_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("feeSats", &_W(self.fee_sats))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.received_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("receivedSats", &_W(self.received_sats))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.sent_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("sentSats", &_W(self.sent_sats))?; + } + { + if let ::core::option::Option::Some(__v) = self + .confirmation_info + .as_option() + { + __map.serialize_entry("confirmationInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for WalletTransactionView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WalletTransaction"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WalletTransaction"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction"; + } + impl<'v> ::buffa::DefaultViewInstance for WalletTransactionView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + WalletTransactionView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for WalletTransactionView<'static> { + type Reborrowed<'b> = WalletTransactionView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod wallet_transaction { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ConfirmationView<'a> { + /// Field 1: `height` + pub height: u32, + /// Field 2: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 3: `timestamp` + pub timestamp: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + } + impl<'a> ConfirmationView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.height = ::buffa::types::decode_uint32(&mut cur)?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.timestamp.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.timestamp = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::TimestampView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ConfirmationView<'a> { + type Owned = super::super::super::wallet_transaction::Confirmation; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::wallet_transaction::Confirmation { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::wallet_transaction::Confirmation { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::wallet_transaction::Confirmation { + height: self.height, + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + timestamp: match self.timestamp.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ConfirmationView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.height != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.timestamp.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.timestamp.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.height != 0u32 { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_hash.write_to(__cache, buf); + } + if self.timestamp.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.timestamp.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ConfirmationView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.height) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("height", &_W(self.height))?; + } + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .timestamp + .as_option() + { + __map.serialize_entry("timestamp", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ConfirmationView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "WalletTransaction.Confirmation"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.WalletTransaction.Confirmation"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.WalletTransaction.Confirmation"; + } + impl<'v> ::buffa::DefaultViewInstance for ConfirmationView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ConfirmationView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ConfirmationView<'static> { + type Reborrowed<'b> = ConfirmationView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct BroadcastWithdrawalBundleRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `transaction` + pub transaction: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::BytesValueView<'a>, + >, + } + impl<'a> BroadcastWithdrawalBundleRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.transaction.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.transaction = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::BytesValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BroadcastWithdrawalBundleRequestView<'a> { + type Owned = super::super::BroadcastWithdrawalBundleRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::BroadcastWithdrawalBundleRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BroadcastWithdrawalBundleRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BroadcastWithdrawalBundleRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + transaction: match self.transaction.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::BytesValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BroadcastWithdrawalBundleRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.transaction.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.transaction.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.transaction.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.transaction.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BroadcastWithdrawalBundleRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .transaction + .as_option() + { + __map.serialize_entry("transaction", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for BroadcastWithdrawalBundleRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BroadcastWithdrawalBundleRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BroadcastWithdrawalBundleRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for BroadcastWithdrawalBundleRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + BroadcastWithdrawalBundleRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BroadcastWithdrawalBundleRequestView<'static> { + type Reborrowed<'b> = BroadcastWithdrawalBundleRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct BroadcastWithdrawalBundleResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> BroadcastWithdrawalBundleResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BroadcastWithdrawalBundleResponseView<'a> { + type Owned = super::super::BroadcastWithdrawalBundleResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::BroadcastWithdrawalBundleResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BroadcastWithdrawalBundleResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BroadcastWithdrawalBundleResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BroadcastWithdrawalBundleResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BroadcastWithdrawalBundleResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for BroadcastWithdrawalBundleResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "BroadcastWithdrawalBundleResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.BroadcastWithdrawalBundleResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.BroadcastWithdrawalBundleResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for BroadcastWithdrawalBundleResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + BroadcastWithdrawalBundleResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BroadcastWithdrawalBundleResponseView<'static> { + type Reborrowed<'b> = BroadcastWithdrawalBundleResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateBmmCriticalDataTransactionRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `value_sats` + pub value_sats: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView<'a>, + >, + /// Field 3: `height` + pub height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 4: `critical_hash` + pub critical_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ConsensusHexView< + 'a, + >, + >, + /// Field 5: `prev_bytes` + pub prev_bytes: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> CreateBmmCriticalDataTransactionRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.value_sats.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.value_sats = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.critical_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.critical_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ConsensusHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.prev_bytes.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.prev_bytes = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for CreateBmmCriticalDataTransactionRequestView<'a> { + type Owned = super::super::CreateBmmCriticalDataTransactionRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::CreateBmmCriticalDataTransactionRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateBmmCriticalDataTransactionRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateBmmCriticalDataTransactionRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + value_sats: match self.value_sats.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + height: match self.height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + critical_hash: match self.critical_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ConsensusHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + prev_bytes: match self.prev_bytes.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for CreateBmmCriticalDataTransactionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.critical_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.critical_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_bytes.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_bytes.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.value_sats.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.height.write_to(__cache, buf); + } + if self.critical_hash.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.critical_hash.write_to(__cache, buf); + } + if self.prev_bytes.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.prev_bytes.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for CreateBmmCriticalDataTransactionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .value_sats + .as_option() + { + __map.serialize_entry("valueSats", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.height.as_option() { + __map.serialize_entry("height", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .critical_hash + .as_option() + { + __map.serialize_entry("criticalHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .prev_bytes + .as_option() + { + __map.serialize_entry("prevBytes", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName + for CreateBmmCriticalDataTransactionRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateBmmCriticalDataTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateBmmCriticalDataTransactionRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateBmmCriticalDataTransactionRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for CreateBmmCriticalDataTransactionRequestView<'static> { + type Reborrowed<'b> = CreateBmmCriticalDataTransactionRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateBmmCriticalDataTransactionResponseView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> CreateBmmCriticalDataTransactionResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for CreateBmmCriticalDataTransactionResponseView<'a> { + type Owned = super::super::CreateBmmCriticalDataTransactionResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::CreateBmmCriticalDataTransactionResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateBmmCriticalDataTransactionResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateBmmCriticalDataTransactionResponse { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for CreateBmmCriticalDataTransactionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for CreateBmmCriticalDataTransactionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() { + __map.serialize_entry("txid", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName + for CreateBmmCriticalDataTransactionResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateBmmCriticalDataTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateBmmCriticalDataTransactionResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateBmmCriticalDataTransactionResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateBmmCriticalDataTransactionResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for CreateBmmCriticalDataTransactionResponseView<'static> { + type Reborrowed<'b> = CreateBmmCriticalDataTransactionResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateDepositTransactionRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Addresses are encoded in UTF8. + /// *Sidechain deposit addresses* (not sidechain addresses) are typically + /// formatted as `s_
_`, + /// where `CHECKSUM` is a hex encoding of the first 6 bytes of the SHA256 + /// hash of `s_
`. + /// protolint:disable:next MAX_LINE_LENGTH + /// + /// The address used here is a sidechain address, the middle component of a + /// sidechain deposit address. + /// + /// Field 2: `address` + pub address: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + /// Field 3: `value_sats` + pub value_sats: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView<'a>, + >, + /// Field 4: `fee_sats` + pub fee_sats: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView<'a>, + >, + } + impl<'a> CreateDepositTransactionRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.address.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.address = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.value_sats.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.value_sats = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.fee_sats.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.fee_sats = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt64ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateDepositTransactionRequestView<'a> { + type Owned = super::super::CreateDepositTransactionRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateDepositTransactionRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateDepositTransactionRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateDepositTransactionRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + address: match self.address.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + value_sats: match self.value_sats.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + fee_sats: match self.fee_sats.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt64Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateDepositTransactionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.value_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.value_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.fee_sats.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fee_sats.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.address.write_to(__cache, buf); + } + if self.value_sats.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.value_sats.write_to(__cache, buf); + } + if self.fee_sats.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.fee_sats.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateDepositTransactionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.address.as_option() { + __map.serialize_entry("address", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .value_sats + .as_option() + { + __map.serialize_entry("valueSats", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.fee_sats.as_option() + { + __map.serialize_entry("feeSats", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateDepositTransactionRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateDepositTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateDepositTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateDepositTransactionRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateDepositTransactionRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateDepositTransactionRequestView<'static> { + type Reborrowed<'b> = CreateDepositTransactionRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateDepositTransactionResponseView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> CreateDepositTransactionResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateDepositTransactionResponseView<'a> { + type Owned = super::super::CreateDepositTransactionResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::CreateDepositTransactionResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateDepositTransactionResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateDepositTransactionResponse { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateDepositTransactionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateDepositTransactionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() { + __map.serialize_entry("txid", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateDepositTransactionResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateDepositTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateDepositTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateDepositTransactionResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateDepositTransactionResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateDepositTransactionResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateDepositTransactionResponseView<'static> { + type Reborrowed<'b> = CreateDepositTransactionResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateNewAddressRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> CreateNewAddressRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateNewAddressRequestView<'a> { + type Owned = super::super::CreateNewAddressRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateNewAddressRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateNewAddressRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateNewAddressRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateNewAddressRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateNewAddressRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateNewAddressRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateNewAddressRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateNewAddressRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for CreateNewAddressRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateNewAddressRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateNewAddressRequestView<'static> { + type Reborrowed<'b> = CreateNewAddressRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateNewAddressResponseView<'a> { + /// Field 1: `address` + pub address: &'a str, + } + impl<'a> CreateNewAddressResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.address = ::buffa::types::borrow_str(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateNewAddressResponseView<'a> { + type Owned = super::super::CreateNewAddressResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateNewAddressResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateNewAddressResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateNewAddressResponse { + address: self.address.to_string(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateNewAddressResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.address.is_empty() { + size + += 1u32 + + ::buffa::types::string_encoded_len(&self.address) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.address.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.address, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateNewAddressResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_str(self.address) { + __map.serialize_entry("address", self.address)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateNewAddressResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateNewAddressResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateNewAddressResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateNewAddressResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for CreateNewAddressResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateNewAddressResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateNewAddressResponseView<'static> { + type Reborrowed<'b> = CreateNewAddressResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateSidechainProposalRequestView<'a> { + /// Field 1: `sidechain_id` + pub sidechain_id: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `declaration` + pub declaration: ::buffa::MessageFieldView< + super::super::__buffa::view::SidechainDeclarationView<'a>, + >, + } + impl<'a> CreateSidechainProposalRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_id = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.declaration.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.declaration = ::buffa::MessageFieldView::set( + super::super::__buffa::view::SidechainDeclarationView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateSidechainProposalRequestView<'a> { + type Owned = super::super::CreateSidechainProposalRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateSidechainProposalRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateSidechainProposalRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateSidechainProposalRequest { + sidechain_id: match self.sidechain_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + declaration: match self.declaration.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SidechainDeclaration, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateSidechainProposalRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.declaration.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.declaration.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sidechain_id.write_to(__cache, buf); + } + if self.declaration.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.declaration.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateSidechainProposalRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_id + .as_option() + { + __map.serialize_entry("sidechainId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .declaration + .as_option() + { + __map.serialize_entry("declaration", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateSidechainProposalRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateSidechainProposalRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateSidechainProposalRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateSidechainProposalRequestView<'static> { + type Reborrowed<'b> = CreateSidechainProposalRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateSidechainProposalResponseView<'a> { + pub event: ::core::option::Option< + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event< + 'a, + >, + >, + } + impl<'a> CreateSidechainProposalResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + ::buffa::alloc::boxed::Box::new( + super::super::__buffa::view::create_sidechain_proposal_response::ConfirmedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ::buffa::alloc::boxed::Box::new( + super::super::__buffa::view::create_sidechain_proposal_response::NotConfirmedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateSidechainProposalResponseView<'a> { + type Owned = super::super::CreateSidechainProposalResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateSidechainProposalResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateSidechainProposalResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateSidechainProposalResponse { + event: self + .event + .as_ref() + .map(|v| match v { + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + v, + ) => { + super::super::__buffa::oneof::create_sidechain_proposal_response::Event::Confirmed( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + v, + ) => { + super::super::__buffa::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateSidechainProposalResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateSidechainProposalResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.event { + match __ov { + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::Confirmed( + v, + ) => { + __map.serialize_entry("confirmed", v)?; + } + super::super::__buffa::view::oneof::create_sidechain_proposal_response::Event::NotConfirmed( + v, + ) => { + __map.serialize_entry("notConfirmed", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateSidechainProposalResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for CreateSidechainProposalResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateSidechainProposalResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateSidechainProposalResponseView<'static> { + type Reborrowed<'b> = CreateSidechainProposalResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod create_sidechain_proposal_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ConfirmedView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 2: `confirmations` + pub confirmations: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 3: `height` + pub height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 4: `outpoint` + pub outpoint: ::buffa::MessageFieldView< + super::super::super::__buffa::view::OutPointView<'a>, + >, + /// Field 5: `prev_block_hash` + pub prev_block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> ConfirmedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.confirmations.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.confirmations = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.outpoint.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.outpoint = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::OutPointView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.prev_block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.prev_block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ConfirmedView<'a> { + type Owned = super::super::super::create_sidechain_proposal_response::Confirmed; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::create_sidechain_proposal_response::Confirmed { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::create_sidechain_proposal_response::Confirmed { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::create_sidechain_proposal_response::Confirmed { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + confirmations: match self.confirmations.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + height: match self.height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + outpoint: match self.outpoint.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::OutPoint, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + prev_block_hash: match self.prev_block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ConfirmedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.confirmations.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmations.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.outpoint.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.outpoint.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_hash.write_to(__cache, buf); + } + if self.confirmations.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.confirmations.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.height.write_to(__cache, buf); + } + if self.outpoint.is_set() { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.outpoint.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.prev_block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ConfirmedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .confirmations + .as_option() + { + __map.serialize_entry("confirmations", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .height + .as_option() + { + __map.serialize_entry("height", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .outpoint + .as_option() + { + __map.serialize_entry("outpoint", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .prev_block_hash + .as_option() + { + __map.serialize_entry("prevBlockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ConfirmedView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse.Confirmed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.Confirmed"; + } + impl<'v> ::buffa::DefaultViewInstance for ConfirmedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ConfirmedView<'static> { + type Reborrowed<'b> = ConfirmedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct NotConfirmedView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 2: `height` + pub height: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 3: `prev_block_hash` + pub prev_block_hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> NotConfirmedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.height.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.height = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.prev_block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.prev_block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for NotConfirmedView<'a> { + type Owned = super::super::super::create_sidechain_proposal_response::NotConfirmed; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::create_sidechain_proposal_response::NotConfirmed { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::create_sidechain_proposal_response::NotConfirmed { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::create_sidechain_proposal_response::NotConfirmed { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + height: match self.height.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + prev_block_hash: match self.prev_block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for NotConfirmedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.height.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.height.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.prev_block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.prev_block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_hash.write_to(__cache, buf); + } + if self.height.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.height.write_to(__cache, buf); + } + if self.prev_block_hash.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.prev_block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for NotConfirmedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .height + .as_option() + { + __map.serialize_entry("height", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .prev_block_hash + .as_option() + { + __map.serialize_entry("prevBlockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for NotConfirmedView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateSidechainProposalResponse.NotConfirmed"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateSidechainProposalResponse.NotConfirmed"; + } + impl<'v> ::buffa::DefaultViewInstance for NotConfirmedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + NotConfirmedView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for NotConfirmedView<'static> { + type Reborrowed<'b> = NotConfirmedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateWalletRequestView<'a> { + /// BIP39 mnemonic. 12 or 24 words. + /// + /// Field 1: `mnemonic_words` + pub mnemonic_words: ::buffa::RepeatedView<'a, &'a str>, + /// Path to a file containing the mnemonic. + /// + /// Field 2: `mnemonic_path` + pub mnemonic_path: &'a str, + /// Password for the wallet. Used to encrypt the mnemonic in storage. + /// NOT a BIP39 passphrase. + /// + /// Field 3: `password` + pub password: &'a str, + } + impl<'a> CreateWalletRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.mnemonic_path = ::buffa::types::borrow_str(&mut cur)?; + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.password = ::buffa::types::borrow_str(&mut cur)?; + } + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.mnemonic_words + .push(::buffa::types::borrow_str(&mut cur)?); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateWalletRequestView<'a> { + type Owned = super::super::CreateWalletRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateWalletRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateWalletRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateWalletRequest { + mnemonic_words: self + .mnemonic_words + .iter() + .map(|s| s.to_string()) + .collect(), + mnemonic_path: self.mnemonic_path.to_string(), + password: self.password.to_string(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateWalletRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.mnemonic_words { + size += 1u32 + ::buffa::types::string_encoded_len(v) as u32; + } + if !self.mnemonic_path.is_empty() { + size + += 1u32 + + ::buffa::types::string_encoded_len(&self.mnemonic_path) + as u32; + } + if !self.password.is_empty() { + size + += 1u32 + + ::buffa::types::string_encoded_len(&self.password) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.mnemonic_words { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + if !self.mnemonic_path.is_empty() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.mnemonic_path, buf); + } + if !self.password.is_empty() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.password, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateWalletRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.mnemonic_words.is_empty() { + __map.serialize_entry("mnemonicWords", &*self.mnemonic_words)?; + } + if !::buffa::json_helpers::skip_if::is_empty_str(self.mnemonic_path) { + __map.serialize_entry("mnemonicPath", self.mnemonic_path)?; + } + if !::buffa::json_helpers::skip_if::is_empty_str(self.password) { + __map.serialize_entry("password", self.password)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateWalletRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateWalletRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateWalletRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for CreateWalletRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateWalletRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateWalletRequestView<'static> { + type Reborrowed<'b> = CreateWalletRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct CreateWalletResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> CreateWalletResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for CreateWalletResponseView<'a> { + type Owned = super::super::CreateWalletResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::CreateWalletResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::CreateWalletResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::CreateWalletResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for CreateWalletResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for CreateWalletResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for CreateWalletResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "CreateWalletResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.CreateWalletResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.CreateWalletResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for CreateWalletResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + CreateWalletResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for CreateWalletResponseView<'static> { + type Reborrowed<'b> = CreateWalletResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBalanceRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetBalanceRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBalanceRequestView<'a> { + type Owned = super::super::GetBalanceRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBalanceRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBalanceRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBalanceRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBalanceRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBalanceRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBalanceRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBalanceRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBalanceRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBalanceRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBalanceRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBalanceRequestView<'static> { + type Reborrowed<'b> = GetBalanceRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetBalanceResponseView<'a> { + /// Field 1: `confirmed_sats` + pub confirmed_sats: u64, + /// Field 2: `pending_sats` + pub pending_sats: u64, + /// Whether the wallet has completed its initial sync. + /// + /// Field 3: `has_synced` + pub has_synced: bool, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetBalanceResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.confirmed_sats = ::buffa::types::decode_uint64( + &mut cur, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.pending_sats = ::buffa::types::decode_uint64(&mut cur)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.has_synced = ::buffa::types::decode_bool(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetBalanceResponseView<'a> { + type Owned = super::super::GetBalanceResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetBalanceResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetBalanceResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetBalanceResponse { + confirmed_sats: self.confirmed_sats, + pending_sats: self.pending_sats, + has_synced: self.has_synced, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetBalanceResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.confirmed_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.confirmed_sats) + as u32; + } + if self.pending_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.pending_sats) + as u32; + } + if self.has_synced { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.confirmed_sats != 0u64 { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.confirmed_sats, buf); + } + if self.pending_sats != 0u64 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.pending_sats, buf); + } + if self.has_synced { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_bool(self.has_synced, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetBalanceResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.confirmed_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("confirmedSats", &_W(self.confirmed_sats))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.pending_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("pendingSats", &_W(self.pending_sats))?; + } + if self.has_synced { + __map.serialize_entry("hasSynced", &self.has_synced)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetBalanceResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetBalanceResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetBalanceResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetBalanceResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetBalanceResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetBalanceResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetBalanceResponseView<'static> { + type Reborrowed<'b> = GetBalanceResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct ListSidechainDepositTransactionsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> ListSidechainDepositTransactionsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for ListSidechainDepositTransactionsRequestView<'a> { + type Owned = super::super::ListSidechainDepositTransactionsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::ListSidechainDepositTransactionsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListSidechainDepositTransactionsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListSidechainDepositTransactionsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for ListSidechainDepositTransactionsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for ListSidechainDepositTransactionsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName + for ListSidechainDepositTransactionsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance + for ListSidechainDepositTransactionsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListSidechainDepositTransactionsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for ListSidechainDepositTransactionsRequestView<'static> { + type Reborrowed<'b> = ListSidechainDepositTransactionsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct ListSidechainDepositTransactionsResponseView<'a> { + /// Field 1: `transactions` + pub transactions: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::list_sidechain_deposit_transactions_response::SidechainDepositTransactionView< + 'a, + >, + >, + } + impl<'a> ListSidechainDepositTransactionsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.transactions + .push( + super::super::__buffa::view::list_sidechain_deposit_transactions_response::SidechainDepositTransactionView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> + for ListSidechainDepositTransactionsResponseView<'a> { + type Owned = super::super::ListSidechainDepositTransactionsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::ListSidechainDepositTransactionsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListSidechainDepositTransactionsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListSidechainDepositTransactionsResponse { + transactions: self + .transactions + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> + for ListSidechainDepositTransactionsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.transactions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.transactions { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize + for ListSidechainDepositTransactionsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.transactions.is_empty() { + __map.serialize_entry("transactions", &*self.transactions)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName + for ListSidechainDepositTransactionsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance + for ListSidechainDepositTransactionsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListSidechainDepositTransactionsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow + for ListSidechainDepositTransactionsResponseView<'static> { + type Reborrowed<'b> = ListSidechainDepositTransactionsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod list_sidechain_deposit_transactions_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct SidechainDepositTransactionView<'a> { + /// Field 1: `sidechain_number` + pub sidechain_number: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// Field 2: `tx` + pub tx: ::buffa::MessageFieldView< + super::super::super::__buffa::view::WalletTransactionView<'a>, + >, + } + impl<'a> SidechainDepositTransactionView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sidechain_number.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sidechain_number = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.tx.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.tx = ::buffa::MessageFieldView::set( + super::super::super::__buffa::view::WalletTransactionView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SidechainDepositTransactionView<'a> { + type Owned = super::super::super::list_sidechain_deposit_transactions_response::SidechainDepositTransaction; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::list_sidechain_deposit_transactions_response::SidechainDepositTransaction { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::list_sidechain_deposit_transactions_response::SidechainDepositTransaction { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::list_sidechain_deposit_transactions_response::SidechainDepositTransaction { + sidechain_number: match self.sidechain_number.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + tx: match self.tx.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::WalletTransaction, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SidechainDepositTransactionView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sidechain_number.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sidechain_number.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.tx.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.tx.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sidechain_number.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.sidechain_number.write_to(__cache, buf); + } + if self.tx.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.tx.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SidechainDepositTransactionView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sidechain_number + .as_option() + { + __map.serialize_entry("sidechainNumber", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.tx.as_option() { + __map.serialize_entry("tx", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SidechainDepositTransactionView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListSidechainDepositTransactionsResponse.SidechainDepositTransaction"; + } + impl<'v> ::buffa::DefaultViewInstance + for SidechainDepositTransactionView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SidechainDepositTransactionView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SidechainDepositTransactionView<'static> { + type Reborrowed<'b> = SidechainDepositTransactionView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct ListTransactionsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> ListTransactionsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ListTransactionsRequestView<'a> { + type Owned = super::super::ListTransactionsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ListTransactionsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListTransactionsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListTransactionsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ListTransactionsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ListTransactionsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for ListTransactionsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListTransactionsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListTransactionsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for ListTransactionsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListTransactionsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ListTransactionsRequestView<'static> { + type Reborrowed<'b> = ListTransactionsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct ListTransactionsResponseView<'a> { + /// Field 1: `transactions` + pub transactions: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::WalletTransactionView<'a>, + >, + } + impl<'a> ListTransactionsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.transactions + .push( + super::super::__buffa::view::WalletTransactionView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ListTransactionsResponseView<'a> { + type Owned = super::super::ListTransactionsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ListTransactionsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListTransactionsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListTransactionsResponse { + transactions: self + .transactions + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ListTransactionsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.transactions { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.transactions { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ListTransactionsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.transactions.is_empty() { + __map.serialize_entry("transactions", &*self.transactions)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ListTransactionsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListTransactionsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListTransactionsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListTransactionsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for ListTransactionsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListTransactionsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ListTransactionsResponseView<'static> { + type Reborrowed<'b> = ListTransactionsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SendTransactionRequestView<'a> { + /// Address -\> satoshi amount + /// + /// Field 1: `destinations` (map) + pub destinations: ::buffa::MapView<'a, &'a str, u64>, + /// If not set, a reasonable rate is used by asking Core for an estimate. + /// + /// Field 2: `fee_rate` + pub fee_rate: ::buffa::MessageFieldView< + super::super::__buffa::view::send_transaction_request::FeeRateView<'a>, + >, + /// if set, the transaction will add a separate OP_RETURN output with this + /// message. + /// + /// Field 3: `op_return_message` + pub op_return_message: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::HexView<'a>, + >, + /// UTXOs that must be included in the transaction. Incompatible with + /// specifying a draining address. + /// + /// Field 4: `required_utxos` + pub required_utxos: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::send_transaction_request::RequiredUtxoView< + 'a, + >, + >, + /// If set, the transaction will send all UTXOs in the wallet to this address. + /// Incompatible with specifying required UTXOs. + /// + /// Field 5: `drain_wallet_to` + pub drain_wallet_to: ::core::option::Option<&'a str>, + } + impl<'a> SendTransactionRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.fee_rate.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.fee_rate = ::buffa::MessageFieldView::set( + super::super::__buffa::view::send_transaction_request::FeeRateView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.op_return_message.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.op_return_message = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::HexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.drain_wallet_to = Some( + ::buffa::types::borrow_str(&mut cur)?, + ); + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.required_utxos + .push( + super::super::__buffa::view::send_transaction_request::RequiredUtxoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?; + let mut entry_cur: &'a [u8] = entry_bytes; + let mut key = ""; + let mut val = ::core::default::Default::default(); + while !entry_cur.is_empty() { + let entry_tag = ::buffa::encoding::Tag::decode( + &mut entry_cur, + )?; + match entry_tag.field_number() { + 1 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + key = ::buffa::types::borrow_str(&mut entry_cur)?; + } + 2 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::Varint + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 0u8, + actual: entry_tag.wire_type() as u8, + }); + } + val = ::buffa::types::decode_uint64(&mut entry_cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth( + entry_tag, + &mut entry_cur, + depth, + )?; + } + } + } + view.destinations.push(key, val); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SendTransactionRequestView<'a> { + type Owned = super::super::SendTransactionRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SendTransactionRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SendTransactionRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SendTransactionRequest { + destinations: self + .destinations + .iter() + .map(|(k, v)| (k.to_string(), *v)) + .collect(), + fee_rate: match self.fee_rate.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::send_transaction_request::FeeRate, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + op_return_message: match self.op_return_message.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::Hex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + required_utxos: self + .required_utxos + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + drain_wallet_to: self.drain_wallet_to.map(|s| s.to_string()), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SendTransactionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + #[allow(clippy::for_kv_map)] + for (k, v) in &self.destinations { + let entry_size: u32 = 1u32 + + ::buffa::types::string_encoded_len(k) as u32 + 1u32 + + ::buffa::types::uint64_encoded_len(*v) as u32; + size + += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32 + + entry_size; + } + if self.fee_rate.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.fee_rate.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.op_return_message.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.op_return_message.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + for v in &self.required_utxos { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if let Some(ref v) = self.drain_wallet_to { + size += 1u32 + ::buffa::types::string_encoded_len(v) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for (k, v) in &self.destinations { + let entry_size: u32 = 1u32 + + ::buffa::types::string_encoded_len(k) as u32 + 1u32 + + ::buffa::types::uint64_encoded_len(*v) as u32; + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(entry_size as u64, buf); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(k, buf); + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(*v, buf); + } + if self.fee_rate.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.fee_rate.write_to(__cache, buf); + } + if self.op_return_message.is_set() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.op_return_message.write_to(__cache, buf); + } + for v in &self.required_utxos { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + if let Some(ref v) = self.drain_wallet_to { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SendTransactionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.destinations.is_empty() { + struct _WM<'__a, '__x>(&'__x ::buffa::MapView<'__x, &'__a str, u64>); + impl<'__a> ::serde::Serialize for _WM<'__a, '_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + struct _WV(u64); + impl ::serde::Serialize for _WV { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + let mut __m = __s + .serialize_map(::core::option::Option::Some(self.0.len()))?; + for (k, v) in self.0.iter_unique() { + __m.serialize_entry(k, &_WV(*v))?; + } + __m.end() + } + } + __map.serialize_entry("destinations", &_WM(&self.destinations))?; + } + { + if let ::core::option::Option::Some(__v) = self.fee_rate.as_option() + { + __map.serialize_entry("feeRate", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .op_return_message + .as_option() + { + __map.serialize_entry("opReturnMessage", __v)?; + } + } + if !self.required_utxos.is_empty() { + __map.serialize_entry("requiredUtxos", &*self.required_utxos)?; + } + if let ::core::option::Option::Some(__v) = self.drain_wallet_to { + __map.serialize_entry("drainWalletTo", __v)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SendTransactionRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for SendTransactionRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SendTransactionRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SendTransactionRequestView<'static> { + type Reborrowed<'b> = SendTransactionRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod send_transaction_request { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct FeeRateView<'a> { + pub fee: ::core::option::Option< + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee, + >, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> FeeRateView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.fee = Some( + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + ::buffa::types::decode_uint64(&mut cur)?, + ), + ); + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.fee = Some( + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::Sats( + ::buffa::types::decode_uint64(&mut cur)?, + ), + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for FeeRateView<'a> { + type Owned = super::super::super::send_transaction_request::FeeRate; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::send_transaction_request::FeeRate { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::send_transaction_request::FeeRate { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::send_transaction_request::FeeRate { + fee: self + .fee + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + v, + ) => { + super::super::super::__buffa::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + *v, + ) + } + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::Sats( + v, + ) => { + super::super::super::__buffa::oneof::send_transaction_request::fee_rate::Fee::Sats( + *v, + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for FeeRateView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.fee { + match v { + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + v, + ) => { + size + += 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + } + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::Sats( + v, + ) => { + size + += 1u32 + ::buffa::types::uint64_encoded_len(*v) as u32; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.fee { + match v { + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(*x, buf); + } + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::Sats( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(*x, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for FeeRateView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.fee { + match __ov { + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::SatPerVbyte( + v, + ) => { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("satPerVbyte", &_W(*v))?; + } + super::super::super::__buffa::view::oneof::send_transaction_request::fee_rate::Fee::Sats( + v, + ) => { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("sats", &_W(*v))?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for FeeRateView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest.FeeRate"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest.FeeRate"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.FeeRate"; + } + impl<'v> ::buffa::DefaultViewInstance for FeeRateView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for FeeRateView<'static> { + type Reborrowed<'b> = FeeRateView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + /// A previous unspent transaction output that must be included in the + /// transaction. + #[derive(Clone, Debug, Default)] + pub struct RequiredUtxoView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 2: `vout` + pub vout: u32, + } + impl<'a> RequiredUtxoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.vout = ::buffa::types::decode_uint32(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for RequiredUtxoView<'a> { + type Owned = super::super::super::send_transaction_request::RequiredUtxo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::send_transaction_request::RequiredUtxo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::send_transaction_request::RequiredUtxo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::send_transaction_request::RequiredUtxo { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vout: self.vout, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for RequiredUtxoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for RequiredUtxoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() + { + __map.serialize_entry("txid", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.vout) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("vout", &_W(self.vout))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for RequiredUtxoView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionRequest.RequiredUtxo"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionRequest.RequiredUtxo"; + } + impl<'v> ::buffa::DefaultViewInstance for RequiredUtxoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + RequiredUtxoView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for RequiredUtxoView<'static> { + type Reborrowed<'b> = RequiredUtxoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct SendTransactionResponseView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> SendTransactionResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SendTransactionResponseView<'a> { + type Owned = super::super::SendTransactionResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SendTransactionResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SendTransactionResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SendTransactionResponse { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SendTransactionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.txid.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SendTransactionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() { + __map.serialize_entry("txid", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SendTransactionResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "SendTransactionResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.SendTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.SendTransactionResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for SendTransactionResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SendTransactionResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SendTransactionResponseView<'static> { + type Reborrowed<'b> = SendTransactionResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct UnlockWalletRequestView<'a> { + /// Field 1: `password` + pub password: &'a str, + } + impl<'a> UnlockWalletRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.password = ::buffa::types::borrow_str(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for UnlockWalletRequestView<'a> { + type Owned = super::super::UnlockWalletRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::UnlockWalletRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::UnlockWalletRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::UnlockWalletRequest { + password: self.password.to_string(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for UnlockWalletRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.password.is_empty() { + size + += 1u32 + + ::buffa::types::string_encoded_len(&self.password) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.password.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.password, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for UnlockWalletRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_str(self.password) { + __map.serialize_entry("password", self.password)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for UnlockWalletRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "UnlockWalletRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.UnlockWalletRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for UnlockWalletRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + UnlockWalletRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for UnlockWalletRequestView<'static> { + type Reborrowed<'b> = UnlockWalletRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct UnlockWalletResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> UnlockWalletResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for UnlockWalletResponseView<'a> { + type Owned = super::super::UnlockWalletResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::UnlockWalletResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::UnlockWalletResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::UnlockWalletResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for UnlockWalletResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for UnlockWalletResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for UnlockWalletResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "UnlockWalletResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.UnlockWalletResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.UnlockWalletResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for UnlockWalletResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + UnlockWalletResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for UnlockWalletResponseView<'static> { + type Reborrowed<'b> = UnlockWalletResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GenerateBlocksRequestView<'a> { + /// Number of blocks to generate. + /// + /// Field 1: `blocks` + pub blocks: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView<'a>, + >, + /// ACK all sidechain proposals, irregardless of if they are already + /// in the wallet DB. + /// + /// Field 2: `ack_all_proposals` + pub ack_all_proposals: bool, + } + impl<'a> GenerateBlocksRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.blocks.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.blocks = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::UInt32ValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.ack_all_proposals = ::buffa::types::decode_bool( + &mut cur, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GenerateBlocksRequestView<'a> { + type Owned = super::super::GenerateBlocksRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GenerateBlocksRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GenerateBlocksRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GenerateBlocksRequest { + blocks: match self.blocks.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::UInt32Value, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ack_all_proposals: self.ack_all_proposals, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GenerateBlocksRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.blocks.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.blocks.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.ack_all_proposals { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.blocks.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.blocks.write_to(__cache, buf); + } + if self.ack_all_proposals { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_bool(self.ack_all_proposals, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GenerateBlocksRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.blocks.as_option() { + __map.serialize_entry("blocks", __v)?; + } + } + if self.ack_all_proposals { + __map.serialize_entry("ackAllProposals", &self.ack_all_proposals)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GenerateBlocksRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GenerateBlocksRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GenerateBlocksRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GenerateBlocksRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GenerateBlocksRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GenerateBlocksRequestView<'static> { + type Reborrowed<'b> = GenerateBlocksRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GenerateBlocksResponseView<'a> { + /// Field 1: `block_hash` + pub block_hash: ::buffa::MessageFieldView< + super::super::super::super::common::v1::__buffa::view::ReverseHexView<'a>, + >, + } + impl<'a> GenerateBlocksResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_hash = ::buffa::MessageFieldView::set( + super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GenerateBlocksResponseView<'a> { + type Owned = super::super::GenerateBlocksResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GenerateBlocksResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GenerateBlocksResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GenerateBlocksResponse { + block_hash: match self.block_hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GenerateBlocksResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.block_hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.block_hash.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GenerateBlocksResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .block_hash + .as_option() + { + __map.serialize_entry("blockHash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GenerateBlocksResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GenerateBlocksResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GenerateBlocksResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GenerateBlocksResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GenerateBlocksResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GenerateBlocksResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GenerateBlocksResponseView<'static> { + type Reborrowed<'b> = GenerateBlocksResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetInfoRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetInfoRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetInfoRequestView<'a> { + type Owned = super::super::GetInfoRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetInfoRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetInfoRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetInfoRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetInfoRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetInfoRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetInfoRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetInfoRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetInfoRequestView<'static> { + type Reborrowed<'b> = GetInfoRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetInfoResponseView<'a> { + /// The network the wallet is on + /// + /// Field 1: `network` + pub network: &'a str, + /// Total number of transactions in the wallet + /// + /// Field 2: `transaction_count` + pub transaction_count: u32, + /// Number of UTXOs in the wallet. + /// + /// Field 3: `unspent_output_count` + pub unspent_output_count: u32, + /// Field 4: `descriptors` (map) + pub descriptors: ::buffa::MapView<'a, &'a str, &'a str>, + /// The chain tip the wallet is synced to. + /// + /// Field 5: `tip` + pub tip: ::buffa::MessageFieldView< + super::super::__buffa::view::get_info_response::TipView<'a>, + >, + } + impl<'a> GetInfoResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.network = ::buffa::types::borrow_str(&mut cur)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.transaction_count = ::buffa::types::decode_uint32( + &mut cur, + )?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.unspent_output_count = ::buffa::types::decode_uint32( + &mut cur, + )?; + } + 5u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.tip.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.tip = ::buffa::MessageFieldView::set( + super::super::__buffa::view::get_info_response::TipView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?; + let mut entry_cur: &'a [u8] = entry_bytes; + let mut key = ""; + let mut val = ""; + while !entry_cur.is_empty() { + let entry_tag = ::buffa::encoding::Tag::decode( + &mut entry_cur, + )?; + match entry_tag.field_number() { + 1 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + key = ::buffa::types::borrow_str(&mut entry_cur)?; + } + 2 => { + if entry_tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: entry_tag.field_number(), + expected: 2u8, + actual: entry_tag.wire_type() as u8, + }); + } + val = ::buffa::types::borrow_str(&mut entry_cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth( + entry_tag, + &mut entry_cur, + depth, + )?; + } + } + } + view.descriptors.push(key, val); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetInfoResponseView<'a> { + type Owned = super::super::GetInfoResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetInfoResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetInfoResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetInfoResponse { + network: self.network.to_string(), + transaction_count: self.transaction_count, + unspent_output_count: self.unspent_output_count, + descriptors: self + .descriptors + .iter() + .map(|(k, v)| (k.to_string(), v.to_string())) + .collect(), + tip: match self.tip.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::get_info_response::Tip, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetInfoResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.network.is_empty() { + size + += 1u32 + + ::buffa::types::string_encoded_len(&self.network) as u32; + } + if self.transaction_count != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.transaction_count) + as u32; + } + if self.unspent_output_count != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len( + self.unspent_output_count, + ) as u32; + } + #[allow(clippy::for_kv_map)] + for (k, v) in &self.descriptors { + let entry_size: u32 = 1u32 + + ::buffa::types::string_encoded_len(k) as u32 + 1u32 + + ::buffa::types::string_encoded_len(v) as u32; + size + += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32 + + entry_size; + } + if self.tip.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.tip.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.network.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(&self.network, buf); + } + if self.transaction_count != 0u32 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.transaction_count, buf); + } + if self.unspent_output_count != 0u32 { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.unspent_output_count, buf); + } + for (k, v) in &self.descriptors { + let entry_size: u32 = 1u32 + + ::buffa::types::string_encoded_len(k) as u32 + 1u32 + + ::buffa::types::string_encoded_len(v) as u32; + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(entry_size as u64, buf); + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(k, buf); + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_string(v, buf); + } + if self.tip.is_set() { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.tip.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetInfoResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_str(self.network) { + __map.serialize_entry("network", self.network)?; + } + if !::buffa::json_helpers::skip_if::is_zero_u32( + &self.transaction_count, + ) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map + .serialize_entry( + "transactionCount", + &_W(self.transaction_count), + )?; + } + if !::buffa::json_helpers::skip_if::is_zero_u32( + &self.unspent_output_count, + ) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map + .serialize_entry( + "unspentOutputCount", + &_W(self.unspent_output_count), + )?; + } + if !self.descriptors.is_empty() { + struct _WM<'__a, '__x>( + &'__x ::buffa::MapView<'__x, &'__a str, &'__a str>, + ); + impl<'__a> ::serde::Serialize for _WM<'__a, '_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __m = __s + .serialize_map(::core::option::Option::Some(self.0.len()))?; + for (k, v) in self.0.iter_unique() { + __m.serialize_entry(k, v)?; + } + __m.end() + } + } + __map.serialize_entry("descriptors", &_WM(&self.descriptors))?; + } + { + if let ::core::option::Option::Some(__v) = self.tip.as_option() { + __map.serialize_entry("tip", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetInfoResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetInfoResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetInfoResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetInfoResponseView<'static> { + type Reborrowed<'b> = GetInfoResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod get_info_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct TipView<'a> { + /// The height of the tip of the wallet. + /// + /// Field 1: `height` + pub height: u32, + /// The hash of the tip of the wallet. + /// + /// Field 2: `hash` + pub hash: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + } + impl<'a> TipView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.height = ::buffa::types::decode_uint32(&mut cur)?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.hash.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.hash = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for TipView<'a> { + type Owned = super::super::super::get_info_response::Tip; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::get_info_response::Tip { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::get_info_response::Tip { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::get_info_response::Tip { + height: self.height, + hash: match self.hash.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for TipView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.height != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + if self.hash.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.hash.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.height != 0u32 { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + if self.hash.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.hash.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for TipView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.height) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("height", &_W(self.height))?; + } + { + if let ::core::option::Option::Some(__v) = self.hash.as_option() + { + __map.serialize_entry("hash", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for TipView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "GetInfoResponse.Tip"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.GetInfoResponse.Tip"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.GetInfoResponse.Tip"; + } + impl<'v> ::buffa::DefaultViewInstance for TipView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for TipView<'static> { + type Reborrowed<'b> = TipView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + #[derive(Clone, Debug, Default)] + pub struct ListUnspentOutputsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> ListUnspentOutputsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ListUnspentOutputsRequestView<'a> { + type Owned = super::super::ListUnspentOutputsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ListUnspentOutputsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListUnspentOutputsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListUnspentOutputsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ListUnspentOutputsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ListUnspentOutputsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for ListUnspentOutputsRequestView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsRequest"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for ListUnspentOutputsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListUnspentOutputsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ListUnspentOutputsRequestView<'static> { + type Reborrowed<'b> = ListUnspentOutputsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct ListUnspentOutputsResponseView<'a> { + /// Field 1: `outputs` + pub outputs: ::buffa::RepeatedView< + 'a, + super::super::__buffa::view::list_unspent_outputs_response::OutputView< + 'a, + >, + >, + } + impl<'a> ListUnspentOutputsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + view.outputs + .push( + super::super::__buffa::view::list_unspent_outputs_response::OutputView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ListUnspentOutputsResponseView<'a> { + type Owned = super::super::ListUnspentOutputsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::ListUnspentOutputsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::ListUnspentOutputsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::ListUnspentOutputsResponse { + outputs: self + .outputs + .iter() + .map(|v| v.to_owned_from_source(__buffa_src)) + .collect(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ListUnspentOutputsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + for v in &self.outputs { + let __slot = __cache.reserve(); + let inner_size = v.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + for v in &self.outputs { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + v.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ListUnspentOutputsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !self.outputs.is_empty() { + __map.serialize_entry("outputs", &*self.outputs)?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ListUnspentOutputsResponseView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsResponse"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for ListUnspentOutputsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ListUnspentOutputsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ListUnspentOutputsResponseView<'static> { + type Reborrowed<'b> = ListUnspentOutputsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod list_unspent_outputs_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct OutputView<'a> { + /// Field 1: `txid` + pub txid: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 2: `vout` + pub vout: u32, + /// Field 3: `value_sats` + pub value_sats: u64, + /// An internal output is one that was created by the wallet itself + /// as change output for a transaction. + /// + /// Field 4: `is_internal` + pub is_internal: bool, + /// Field 5: `is_confirmed` + pub is_confirmed: bool, + /// Field 6: `confirmed_at_block` + pub confirmed_at_block: u32, + /// Field 7: `confirmed_at_time` + pub confirmed_at_time: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// Field 8: `confirmed_transitively` + pub confirmed_transitively: ::buffa::MessageFieldView< + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView< + 'a, + >, + >, + /// Field 9: `unconfirmed_last_seen` + pub unconfirmed_last_seen: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>, + >, + /// The address corresponding to this output. Empty if we're unable + /// to represent it as an address. + /// + /// Field 10: `address` + pub address: ::buffa::MessageFieldView< + ::buffa_types::google::protobuf::__buffa::view::StringValueView<'a>, + >, + } + impl<'a> OutputView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.txid.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.txid = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.vout = ::buffa::types::decode_uint32(&mut cur)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.value_sats = ::buffa::types::decode_uint64(&mut cur)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.is_internal = ::buffa::types::decode_bool(&mut cur)?; + } + 5u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 5u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.is_confirmed = ::buffa::types::decode_bool(&mut cur)?; + } + 6u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 6u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.confirmed_at_block = ::buffa::types::decode_uint32( + &mut cur, + )?; + } + 7u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 7u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.confirmed_at_time.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.confirmed_at_time = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::TimestampView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 8u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 8u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.confirmed_transitively.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.confirmed_transitively = ::buffa::MessageFieldView::set( + super::super::super::super::super::common::v1::__buffa::view::ReverseHexView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 9u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 9u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.unconfirmed_last_seen.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.unconfirmed_last_seen = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::TimestampView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 10u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 10u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.address.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.address = ::buffa::MessageFieldView::set( + ::buffa_types::google::protobuf::__buffa::view::StringValueView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for OutputView<'a> { + type Owned = super::super::super::list_unspent_outputs_response::Output; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::list_unspent_outputs_response::Output { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::list_unspent_outputs_response::Output { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::list_unspent_outputs_response::Output { + txid: match self.txid.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + vout: self.vout, + value_sats: self.value_sats, + is_internal: self.is_internal, + is_confirmed: self.is_confirmed, + confirmed_at_block: self.confirmed_at_block, + confirmed_at_time: match self.confirmed_at_time.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + confirmed_transitively: match self + .confirmed_transitively + .as_option() + { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::super::common::v1::ReverseHex, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + unconfirmed_last_seen: match self + .unconfirmed_last_seen + .as_option() + { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::Timestamp, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + address: match self.address.as_option() { + Some(v) => { + ::buffa::MessageField::< + ::buffa_types::google::protobuf::StringValue, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for OutputView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.txid.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.txid.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.vout != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len(self.vout) as u32; + } + if self.value_sats != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.value_sats) + as u32; + } + if self.is_internal { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + if self.is_confirmed { + size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32; + } + if self.confirmed_at_block != 0u32 { + size + += 1u32 + + ::buffa::types::uint32_encoded_len( + self.confirmed_at_block, + ) as u32; + } + if self.confirmed_at_time.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.confirmed_at_time.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.confirmed_transitively.is_set() { + let __slot = __cache.reserve(); + let inner_size = self + .confirmed_transitively + .compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.unconfirmed_last_seen.is_set() { + let __slot = __cache.reserve(); + let inner_size = self + .unconfirmed_last_seen + .compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.address.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.address.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.txid.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.txid.write_to(__cache, buf); + } + if self.vout != 0u32 { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.vout, buf); + } + if self.value_sats != 0u64 { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.value_sats, buf); + } + if self.is_internal { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_bool(self.is_internal, buf); + } + if self.is_confirmed { + ::buffa::encoding::Tag::new( + 5u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_bool(self.is_confirmed, buf); + } + if self.confirmed_at_block != 0u32 { + ::buffa::encoding::Tag::new( + 6u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.confirmed_at_block, buf); + } + if self.confirmed_at_time.is_set() { + ::buffa::encoding::Tag::new( + 7u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.confirmed_at_time.write_to(__cache, buf); + } + if self.confirmed_transitively.is_set() { + ::buffa::encoding::Tag::new( + 8u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.confirmed_transitively.write_to(__cache, buf); + } + if self.unconfirmed_last_seen.is_set() { + ::buffa::encoding::Tag::new( + 9u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.unconfirmed_last_seen.write_to(__cache, buf); + } + if self.address.is_set() { + ::buffa::encoding::Tag::new( + 10u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.address.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for OutputView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self.txid.as_option() + { + __map.serialize_entry("txid", __v)?; + } + } + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.vout) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("vout", &_W(self.vout))?; + } + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.value_sats) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("valueSats", &_W(self.value_sats))?; + } + if self.is_internal { + __map.serialize_entry("isInternal", &self.is_internal)?; + } + if self.is_confirmed { + __map.serialize_entry("isConfirmed", &self.is_confirmed)?; + } + if !::buffa::json_helpers::skip_if::is_zero_u32( + &self.confirmed_at_block, + ) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map + .serialize_entry( + "confirmedAtBlock", + &_W(self.confirmed_at_block), + )?; + } + { + if let ::core::option::Option::Some(__v) = self + .confirmed_at_time + .as_option() + { + __map.serialize_entry("confirmedAtTime", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .confirmed_transitively + .as_option() + { + __map.serialize_entry("confirmedTransitively", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .unconfirmed_last_seen + .as_option() + { + __map.serialize_entry("unconfirmedLastSeen", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .address + .as_option() + { + __map.serialize_entry("address", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for OutputView<'a> { + const PACKAGE: &'static str = "cusf.mainchain.v1"; + const NAME: &'static str = "ListUnspentOutputsResponse.Output"; + const FULL_NAME: &'static str = "cusf.mainchain.v1.ListUnspentOutputsResponse.Output"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.mainchain.v1.ListUnspentOutputsResponse.Output"; + } + impl<'v> ::buffa::DefaultViewInstance for OutputView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for OutputView<'static> { + type Reborrowed<'b> = OutputView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + pub mod sidechain_declaration { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum SidechainDeclaration<'a> { + V0( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::sidechain_declaration::V0View< + 'a, + >, + >, + ), + } + } + pub mod withdrawal_bundle_event { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Event<'a> { + Failed( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::withdrawal_bundle_event::event::FailedView< + 'a, + >, + >, + ), + Succeeded( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::withdrawal_bundle_event::event::SucceededView< + 'a, + >, + >, + ), + Submitted( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::withdrawal_bundle_event::event::SubmittedView< + 'a, + >, + >, + ), + } + } + } + pub mod block_info { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Event<'a> { + Deposit( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::DepositView< + 'a, + >, + >, + ), + WithdrawalBundle( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::WithdrawalBundleEventView< + 'a, + >, + >, + ), + } + } + } + pub mod get_bmm_h_star_commitment_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Result<'a> { + BlockNotFound( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::get_bmm_h_star_commitment_response::BlockNotFoundErrorView< + 'a, + >, + >, + ), + Commitment( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::get_bmm_h_star_commitment_response::CommitmentView< + 'a, + >, + >, + ), + } + } + pub mod get_coinbase_psbt_request { + #[allow(unused_imports)] + use super::*; + pub mod ack_bundles { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum AckBundles<'a> { + RepeatPrevious( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::RepeatPreviousView< + 'a, + >, + >, + ), + LeadingBy50( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::LeadingBy50View< + 'a, + >, + >, + ), + Upvotes( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::get_coinbase_psbt_request::ack_bundles::UpvotesView< + 'a, + >, + >, + ), + } + } + } + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Event<'a> { + ConnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView< + 'a, + >, + >, + ), + DisconnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView< + 'a, + >, + >, + ), + } + } + } + pub mod create_sidechain_proposal_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Event<'a> { + Confirmed( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::create_sidechain_proposal_response::ConfirmedView< + 'a, + >, + >, + ), + NotConfirmed( + ::buffa::alloc::boxed::Box< + super::super::super::super::__buffa::view::create_sidechain_proposal_response::NotConfirmedView< + 'a, + >, + >, + ), + } + } + pub mod send_transaction_request { + #[allow(unused_imports)] + use super::*; + pub mod fee_rate { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Fee { + SatPerVbyte(u64), + Sats(u64), + } + } + } + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + pub mod sidechain_declaration { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum SidechainDeclaration { + V0( + ::buffa::alloc::boxed::Box< + super::super::super::sidechain_declaration::V0, + >, + ), + } + impl ::buffa::Oneof for SidechainDeclaration {} + impl From + for SidechainDeclaration { + fn from(v: super::super::super::sidechain_declaration::V0) -> Self { + Self::V0(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::sidechain_declaration::V0) -> Self { + Self::Some(SidechainDeclaration::from(v)) + } + } + impl serde::Serialize for SidechainDeclaration { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::V0(v) => { + map.serialize_entry("v0", v)?; + } + } + map.end() + } + } + } + pub mod withdrawal_bundle_event { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Event { + Failed( + ::buffa::alloc::boxed::Box< + super::super::super::super::withdrawal_bundle_event::event::Failed, + >, + ), + Succeeded( + ::buffa::alloc::boxed::Box< + super::super::super::super::withdrawal_bundle_event::event::Succeeded, + >, + ), + Submitted( + ::buffa::alloc::boxed::Box< + super::super::super::super::withdrawal_bundle_event::event::Submitted, + >, + ), + } + impl ::buffa::Oneof for Event {} + impl From< + super::super::super::super::withdrawal_bundle_event::event::Failed, + > for Event { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Failed, + ) -> Self { + Self::Failed(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::withdrawal_bundle_event::event::Failed, + > for ::core::option::Option { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Failed, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::withdrawal_bundle_event::event::Succeeded, + > for Event { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Succeeded, + ) -> Self { + Self::Succeeded(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::withdrawal_bundle_event::event::Succeeded, + > for ::core::option::Option { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Succeeded, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::withdrawal_bundle_event::event::Submitted, + > for Event { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Submitted, + ) -> Self { + Self::Submitted(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::withdrawal_bundle_event::event::Submitted, + > for ::core::option::Option { + fn from( + v: super::super::super::super::withdrawal_bundle_event::event::Submitted, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl serde::Serialize for Event { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::Failed(v) => { + map.serialize_entry("failed", v)?; + } + Self::Succeeded(v) => { + map.serialize_entry("succeeded", v)?; + } + Self::Submitted(v) => { + map.serialize_entry("submitted", v)?; + } + } + map.end() + } + } + } + } + pub mod block_info { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Event { + Deposit( + ::buffa::alloc::boxed::Box, + ), + WithdrawalBundle( + ::buffa::alloc::boxed::Box< + super::super::super::super::WithdrawalBundleEvent, + >, + ), + } + impl ::buffa::Oneof for Event {} + impl From for Event { + fn from(v: super::super::super::super::Deposit) -> Self { + Self::Deposit(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from(v: super::super::super::super::Deposit) -> Self { + Self::Some(Event::from(v)) + } + } + impl From for Event { + fn from( + v: super::super::super::super::WithdrawalBundleEvent, + ) -> Self { + Self::WithdrawalBundle(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from( + v: super::super::super::super::WithdrawalBundleEvent, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl serde::Serialize for Event { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::Deposit(v) => { + map.serialize_entry("deposit", v)?; + } + Self::WithdrawalBundle(v) => { + map.serialize_entry("withdrawalBundle", v)?; + } + } + map.end() + } + } + } + } + pub mod get_bmm_h_star_commitment_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Result { + BlockNotFound( + ::buffa::alloc::boxed::Box< + super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError, + >, + ), + Commitment( + ::buffa::alloc::boxed::Box< + super::super::super::get_bmm_h_star_commitment_response::Commitment, + >, + ), + } + impl ::buffa::Oneof for Result {} + impl From< + super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError, + > for Result { + fn from( + v: super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError, + ) -> Self { + Self::BlockNotFound(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError, + > for ::core::option::Option { + fn from( + v: super::super::super::get_bmm_h_star_commitment_response::BlockNotFoundError, + ) -> Self { + Self::Some(Result::from(v)) + } + } + impl From< + super::super::super::get_bmm_h_star_commitment_response::Commitment, + > for Result { + fn from( + v: super::super::super::get_bmm_h_star_commitment_response::Commitment, + ) -> Self { + Self::Commitment(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::get_bmm_h_star_commitment_response::Commitment, + > for ::core::option::Option { + fn from( + v: super::super::super::get_bmm_h_star_commitment_response::Commitment, + ) -> Self { + Self::Some(Result::from(v)) + } + } + impl serde::Serialize for Result { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::BlockNotFound(v) => { + map.serialize_entry("blockNotFound", v)?; + } + Self::Commitment(v) => { + map.serialize_entry("commitment", v)?; + } + } + map.end() + } + } + } + pub mod get_coinbase_psbt_request { + #[allow(unused_imports)] + use super::*; + pub mod ack_bundles { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum AckBundles { + RepeatPrevious( + ::buffa::alloc::boxed::Box< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + >, + ), + LeadingBy50( + ::buffa::alloc::boxed::Box< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + >, + ), + Upvotes( + ::buffa::alloc::boxed::Box< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes, + >, + ), + } + impl ::buffa::Oneof for AckBundles {} + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + > for AckBundles { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + ) -> Self { + Self::RepeatPrevious(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + > for ::core::option::Option { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::RepeatPrevious, + ) -> Self { + Self::Some(AckBundles::from(v)) + } + } + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + > for AckBundles { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + ) -> Self { + Self::LeadingBy50(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + > for ::core::option::Option { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::LeadingBy50, + ) -> Self { + Self::Some(AckBundles::from(v)) + } + } + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes, + > for AckBundles { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes, + ) -> Self { + Self::Upvotes(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes, + > for ::core::option::Option { + fn from( + v: super::super::super::super::get_coinbase_psbt_request::ack_bundles::Upvotes, + ) -> Self { + Self::Some(AckBundles::from(v)) + } + } + impl serde::Serialize for AckBundles { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::RepeatPrevious(v) => { + map.serialize_entry("repeatPrevious", v)?; + } + Self::LeadingBy50(v) => { + map.serialize_entry("leadingBy50", v)?; + } + Self::Upvotes(v) => { + map.serialize_entry("upvotes", v)?; + } + } + map.end() + } + } + } + } + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Event { + ConnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + >, + ), + DisconnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + >, + ), + } + impl ::buffa::Oneof for Event {} + impl From< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::ConnectBlock, + ) -> Self { + Self::ConnectBlock(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::ConnectBlock, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::DisconnectBlock, + ) -> Self { + Self::DisconnectBlock(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::DisconnectBlock, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl serde::Serialize for Event { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::ConnectBlock(v) => { + map.serialize_entry("connectBlock", v)?; + } + Self::DisconnectBlock(v) => { + map.serialize_entry("disconnectBlock", v)?; + } + } + map.end() + } + } + } + } + pub mod create_sidechain_proposal_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Event { + Confirmed( + ::buffa::alloc::boxed::Box< + super::super::super::create_sidechain_proposal_response::Confirmed, + >, + ), + NotConfirmed( + ::buffa::alloc::boxed::Box< + super::super::super::create_sidechain_proposal_response::NotConfirmed, + >, + ), + } + impl ::buffa::Oneof for Event {} + impl From + for Event { + fn from( + v: super::super::super::create_sidechain_proposal_response::Confirmed, + ) -> Self { + Self::Confirmed(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From + for ::core::option::Option { + fn from( + v: super::super::super::create_sidechain_proposal_response::Confirmed, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::create_sidechain_proposal_response::NotConfirmed, + > for Event { + fn from( + v: super::super::super::create_sidechain_proposal_response::NotConfirmed, + ) -> Self { + Self::NotConfirmed(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::create_sidechain_proposal_response::NotConfirmed, + > for ::core::option::Option { + fn from( + v: super::super::super::create_sidechain_proposal_response::NotConfirmed, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl serde::Serialize for Event { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::Confirmed(v) => { + map.serialize_entry("confirmed", v)?; + } + Self::NotConfirmed(v) => { + map.serialize_entry("notConfirmed", v)?; + } + } + map.end() + } + } + } + pub mod send_transaction_request { + #[allow(unused_imports)] + use super::*; + pub mod fee_rate { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Fee { + SatPerVbyte(u64), + Sats(u64), + } + impl ::buffa::Oneof for Fee {} + impl serde::Serialize for Fee { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::SatPerVbyte(v) => { + struct _W<'a>(&'a u64); + impl serde::Serialize for _W<'_> { + fn serialize( + &self, + s: S2, + ) -> ::core::result::Result { + ::buffa::json_helpers::uint64::serialize(self.0, s) + } + } + map.serialize_entry("satPerVbyte", &_W(v))?; + } + Self::Sats(v) => { + struct _W<'a>(&'a u64); + impl serde::Serialize for _W<'_> { + fn serialize( + &self, + s: S2, + ) -> ::core::result::Result { + ::buffa::json_helpers::uint64::serialize(self.0, s) + } + } + map.serialize_entry("sats", &_W(v))?; + } + } + map.end() + } + } + } + } + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__OUT_POINT_JSON_ANY); + reg.register_json_any(super::__SIDECHAIN_DECLARATION_JSON_ANY); + reg.register_json_any(super::sidechain_declaration::__V0_JSON_ANY); + reg.register_json_any(super::__BLOCK_HEADER_INFO_JSON_ANY); + reg.register_json_any(super::__DEPOSIT_JSON_ANY); + reg.register_json_any(super::deposit::__OUTPUT_JSON_ANY); + reg.register_json_any(super::__WITHDRAWAL_BUNDLE_EVENT_JSON_ANY); + reg.register_json_any(super::withdrawal_bundle_event::__EVENT_JSON_ANY); + reg.register_json_any(super::withdrawal_bundle_event::event::__FAILED_JSON_ANY); + reg.register_json_any( + super::withdrawal_bundle_event::event::__SUCCEEDED_JSON_ANY, + ); + reg.register_json_any( + super::withdrawal_bundle_event::event::__SUBMITTED_JSON_ANY, + ); + reg.register_json_any(super::__BLOCK_INFO_JSON_ANY); + reg.register_json_any(super::block_info::__EVENT_JSON_ANY); + reg.register_json_any(super::__GET_BLOCK_HEADER_INFO_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_BLOCK_HEADER_INFO_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_BLOCK_INFO_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_BLOCK_INFO_RESPONSE_JSON_ANY); + reg.register_json_any(super::get_block_info_response::__INFO_JSON_ANY); + reg.register_json_any(super::__GET_BMM_H_STAR_COMMITMENT_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_BMM_H_STAR_COMMITMENT_RESPONSE_JSON_ANY); + reg.register_json_any( + super::get_bmm_h_star_commitment_response::__BLOCK_NOT_FOUND_ERROR_JSON_ANY, + ); + reg.register_json_any( + super::get_bmm_h_star_commitment_response::__OPTIONAL_COMMITMENT_JSON_ANY, + ); + reg.register_json_any( + super::get_bmm_h_star_commitment_response::__COMMITMENT_JSON_ANY, + ); + reg.register_json_any(super::__GET_CHAIN_INFO_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_CHAIN_INFO_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_CHAIN_TIP_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_CHAIN_TIP_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_COINBASE_PSBT_REQUEST_JSON_ANY); + reg.register_json_any( + super::get_coinbase_psbt_request::__PROPOSE_SIDECHAIN_JSON_ANY, + ); + reg.register_json_any( + super::get_coinbase_psbt_request::__ACK_SIDECHAIN_JSON_ANY, + ); + reg.register_json_any( + super::get_coinbase_psbt_request::__PROPOSE_BUNDLE_JSON_ANY, + ); + reg.register_json_any(super::get_coinbase_psbt_request::__ACK_BUNDLES_JSON_ANY); + reg.register_json_any( + super::get_coinbase_psbt_request::ack_bundles::__REPEAT_PREVIOUS_JSON_ANY, + ); + reg.register_json_any( + super::get_coinbase_psbt_request::ack_bundles::__LEADING_BY50_JSON_ANY, + ); + reg.register_json_any( + super::get_coinbase_psbt_request::ack_bundles::__UPVOTES_JSON_ANY, + ); + reg.register_json_any(super::__GET_COINBASE_PSBT_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_CTIP_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_CTIP_RESPONSE_JSON_ANY); + reg.register_json_any(super::get_ctip_response::__CTIP_JSON_ANY); + reg.register_json_any(super::__GET_SIDECHAIN_PROPOSALS_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_SIDECHAIN_PROPOSALS_RESPONSE_JSON_ANY); + reg.register_json_any( + super::get_sidechain_proposals_response::__SIDECHAIN_PROPOSAL_JSON_ANY, + ); + reg.register_json_any(super::__GET_SIDECHAINS_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_SIDECHAINS_RESPONSE_JSON_ANY); + reg.register_json_any(super::get_sidechains_response::__SIDECHAIN_INFO_JSON_ANY); + reg.register_json_any(super::__GET_TWO_WAY_PEG_DATA_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_TWO_WAY_PEG_DATA_RESPONSE_JSON_ANY); + reg.register_json_any( + super::get_two_way_peg_data_response::__RESPONSE_ITEM_JSON_ANY, + ); + reg.register_json_any(super::__SUBSCRIBE_EVENTS_REQUEST_JSON_ANY); + reg.register_json_any(super::__SUBSCRIBE_EVENTS_RESPONSE_JSON_ANY); + reg.register_json_any(super::subscribe_events_response::__EVENT_JSON_ANY); + reg.register_json_any( + super::subscribe_events_response::event::__CONNECT_BLOCK_JSON_ANY, + ); + reg.register_json_any( + super::subscribe_events_response::event::__DISCONNECT_BLOCK_JSON_ANY, + ); + reg.register_json_any(super::__SUBSCRIBE_HEADER_SYNC_PROGRESS_REQUEST_JSON_ANY); + reg.register_json_any(super::__SUBSCRIBE_HEADER_SYNC_PROGRESS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__STOP_REQUEST_JSON_ANY); + reg.register_json_any(super::__STOP_RESPONSE_JSON_ANY); + reg.register_json_any(super::__WALLET_TRANSACTION_JSON_ANY); + reg.register_json_any(super::wallet_transaction::__CONFIRMATION_JSON_ANY); + reg.register_json_any(super::__BROADCAST_WITHDRAWAL_BUNDLE_REQUEST_JSON_ANY); + reg.register_json_any(super::__BROADCAST_WITHDRAWAL_BUNDLE_RESPONSE_JSON_ANY); + reg.register_json_any( + super::__CREATE_BMM_CRITICAL_DATA_TRANSACTION_REQUEST_JSON_ANY, + ); + reg.register_json_any( + super::__CREATE_BMM_CRITICAL_DATA_TRANSACTION_RESPONSE_JSON_ANY, + ); + reg.register_json_any(super::__CREATE_DEPOSIT_TRANSACTION_REQUEST_JSON_ANY); + reg.register_json_any(super::__CREATE_DEPOSIT_TRANSACTION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__CREATE_NEW_ADDRESS_REQUEST_JSON_ANY); + reg.register_json_any(super::__CREATE_NEW_ADDRESS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__CREATE_SIDECHAIN_PROPOSAL_REQUEST_JSON_ANY); + reg.register_json_any(super::__CREATE_SIDECHAIN_PROPOSAL_RESPONSE_JSON_ANY); + reg.register_json_any( + super::create_sidechain_proposal_response::__CONFIRMED_JSON_ANY, + ); + reg.register_json_any( + super::create_sidechain_proposal_response::__NOT_CONFIRMED_JSON_ANY, + ); + reg.register_json_any(super::__CREATE_WALLET_REQUEST_JSON_ANY); + reg.register_json_any(super::__CREATE_WALLET_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_BALANCE_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_BALANCE_RESPONSE_JSON_ANY); + reg.register_json_any( + super::__LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_REQUEST_JSON_ANY, + ); + reg.register_json_any( + super::__LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_RESPONSE_JSON_ANY, + ); + reg.register_json_any( + super::list_sidechain_deposit_transactions_response::__SIDECHAIN_DEPOSIT_TRANSACTION_JSON_ANY, + ); + reg.register_json_any(super::__LIST_TRANSACTIONS_REQUEST_JSON_ANY); + reg.register_json_any(super::__LIST_TRANSACTIONS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SEND_TRANSACTION_REQUEST_JSON_ANY); + reg.register_json_any(super::send_transaction_request::__FEE_RATE_JSON_ANY); + reg.register_json_any(super::send_transaction_request::__REQUIRED_UTXO_JSON_ANY); + reg.register_json_any(super::__SEND_TRANSACTION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__UNLOCK_WALLET_REQUEST_JSON_ANY); + reg.register_json_any(super::__UNLOCK_WALLET_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GENERATE_BLOCKS_REQUEST_JSON_ANY); + reg.register_json_any(super::__GENERATE_BLOCKS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_INFO_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_INFO_RESPONSE_JSON_ANY); + reg.register_json_any(super::get_info_response::__TIP_JSON_ANY); + reg.register_json_any(super::__LIST_UNSPENT_OUTPUTS_REQUEST_JSON_ANY); + reg.register_json_any(super::__LIST_UNSPENT_OUTPUTS_RESPONSE_JSON_ANY); + reg.register_json_any(super::list_unspent_outputs_response::__OUTPUT_JSON_ANY); + } +} +#[doc(inline)] +pub use self::__buffa::view::OutPointView; +#[doc(inline)] +pub use self::__buffa::view::SidechainDeclarationView; +#[doc(inline)] +pub use self::__buffa::view::BlockHeaderInfoView; +#[doc(inline)] +pub use self::__buffa::view::DepositView; +#[doc(inline)] +pub use self::__buffa::view::WithdrawalBundleEventView; +#[doc(inline)] +pub use self::__buffa::view::BlockInfoView; +#[doc(inline)] +pub use self::__buffa::view::GetBlockHeaderInfoRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetBlockHeaderInfoResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetBlockInfoRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetBlockInfoResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetBmmHStarCommitmentRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetBmmHStarCommitmentResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetChainInfoRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetChainInfoResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetChainTipRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetChainTipResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetCoinbasePSBTRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetCoinbasePSBTResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetCtipRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetCtipResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetSidechainProposalsRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetSidechainProposalsResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetSidechainsRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetSidechainsResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetTwoWayPegDataRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetTwoWayPegDataResponseView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeEventsRequestView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeEventsResponseView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeHeaderSyncProgressRequestView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeHeaderSyncProgressResponseView; +#[doc(inline)] +pub use self::__buffa::view::StopRequestView; +#[doc(inline)] +pub use self::__buffa::view::StopResponseView; +#[doc(inline)] +pub use self::__buffa::view::WalletTransactionView; +#[doc(inline)] +pub use self::__buffa::view::BroadcastWithdrawalBundleRequestView; +#[doc(inline)] +pub use self::__buffa::view::BroadcastWithdrawalBundleResponseView; +#[doc(inline)] +pub use self::__buffa::view::CreateBmmCriticalDataTransactionRequestView; +#[doc(inline)] +pub use self::__buffa::view::CreateBmmCriticalDataTransactionResponseView; +#[doc(inline)] +pub use self::__buffa::view::CreateDepositTransactionRequestView; +#[doc(inline)] +pub use self::__buffa::view::CreateDepositTransactionResponseView; +#[doc(inline)] +pub use self::__buffa::view::CreateNewAddressRequestView; +#[doc(inline)] +pub use self::__buffa::view::CreateNewAddressResponseView; +#[doc(inline)] +pub use self::__buffa::view::CreateSidechainProposalRequestView; +#[doc(inline)] +pub use self::__buffa::view::CreateSidechainProposalResponseView; +#[doc(inline)] +pub use self::__buffa::view::CreateWalletRequestView; +#[doc(inline)] +pub use self::__buffa::view::CreateWalletResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetBalanceRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetBalanceResponseView; +#[doc(inline)] +pub use self::__buffa::view::ListSidechainDepositTransactionsRequestView; +#[doc(inline)] +pub use self::__buffa::view::ListSidechainDepositTransactionsResponseView; +#[doc(inline)] +pub use self::__buffa::view::ListTransactionsRequestView; +#[doc(inline)] +pub use self::__buffa::view::ListTransactionsResponseView; +#[doc(inline)] +pub use self::__buffa::view::SendTransactionRequestView; +#[doc(inline)] +pub use self::__buffa::view::SendTransactionResponseView; +#[doc(inline)] +pub use self::__buffa::view::UnlockWalletRequestView; +#[doc(inline)] +pub use self::__buffa::view::UnlockWalletResponseView; +#[doc(inline)] +pub use self::__buffa::view::GenerateBlocksRequestView; +#[doc(inline)] +pub use self::__buffa::view::GenerateBlocksResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetInfoRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetInfoResponseView; +#[doc(inline)] +pub use self::__buffa::view::ListUnspentOutputsRequestView; +#[doc(inline)] +pub use self::__buffa::view::ListUnspentOutputsResponseView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/lib/proto/generated/buffa/cusf.sidechain.v1.rs b/lib/proto/generated/buffa/cusf.sidechain.v1.rs new file mode 100644 index 00000000..d3434a12 --- /dev/null +++ b/lib/proto/generated/buffa/cusf.sidechain.v1.rs @@ -0,0 +1,5857 @@ +// @generated by buffa-codegen. DO NOT EDIT. + +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SequenceId { + /// Field 1: `sequence_id` + #[serde( + rename = "sequenceId", + alias = "sequence_id", + with = "::buffa::json_helpers::uint64", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64" + )] + pub sequence_id: u64, +} +impl ::core::fmt::Debug for SequenceId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SequenceId").field("sequence_id", &self.sequence_id).finish() + } +} +impl SequenceId { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SequenceId"; +} +impl ::buffa::DefaultInstance for SequenceId { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SequenceId { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SequenceId"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SequenceId"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SequenceId"; +} +impl ::buffa::Message for SequenceId { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id != 0u64 { + size += 1u32 + ::buffa::types::uint64_encoded_len(self.sequence_id) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id != 0u64 { + ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint64(self.sequence_id, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.sequence_id = ::buffa::types::decode_uint64(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence_id = 0u64; + } +} +impl ::buffa::json_helpers::ProtoElemJson for SequenceId { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SEQUENCE_ID_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SequenceId", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BlockHeaderInfo { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub block_hash: ::buffa::alloc::vec::Vec, + /// Field 2: `prev_block_hash` + #[serde( + rename = "prevBlockHash", + alias = "prev_block_hash", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub prev_block_hash: ::buffa::alloc::vec::Vec, + /// Field 3: `prev_main_block_hash` + #[serde( + rename = "prevMainBlockHash", + alias = "prev_main_block_hash", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub prev_main_block_hash: ::buffa::alloc::vec::Vec, + /// Field 4: `height` + #[serde( + rename = "height", + with = "::buffa::json_helpers::uint32", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32" + )] + pub height: u32, +} +impl ::core::fmt::Debug for BlockHeaderInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BlockHeaderInfo") + .field("block_hash", &self.block_hash) + .field("prev_block_hash", &self.prev_block_hash) + .field("prev_main_block_hash", &self.prev_main_block_hash) + .field("height", &self.height) + .finish() + } +} +impl BlockHeaderInfo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockHeaderInfo"; +} +impl ::buffa::DefaultInstance for BlockHeaderInfo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BlockHeaderInfo { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "BlockHeaderInfo"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.BlockHeaderInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockHeaderInfo"; +} +impl ::buffa::Message for BlockHeaderInfo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.block_hash.is_empty() { + size += 1u32 + ::buffa::types::bytes_encoded_len(&self.block_hash) as u32; + } + if !self.prev_block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.prev_block_hash) as u32; + } + if !self.prev_main_block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.prev_main_block_hash) + as u32; + } + if self.height != 0u32 { + size += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.block_hash, buf); + } + if !self.prev_block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.prev_block_hash, buf); + } + if !self.prev_main_block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.prev_main_block_hash, buf); + } + if self.height != 0u32 { + ::buffa::encoding::Tag::new(4u32, ::buffa::encoding::WireType::Varint) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.block_hash, buf)?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.prev_block_hash, buf)?; + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.prev_main_block_hash, buf)?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + self.height = ::buffa::types::decode_uint32(buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash.clear(); + self.prev_block_hash.clear(); + self.prev_main_block_hash.clear(); + self.height = 0u32; + } +} +impl ::buffa::json_helpers::ProtoElemJson for BlockHeaderInfo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BLOCK_HEADER_INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.BlockHeaderInfo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct BlockInfo {} +impl ::core::fmt::Debug for BlockInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("BlockInfo").finish() + } +} +impl BlockInfo { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockInfo"; +} +impl ::buffa::DefaultInstance for BlockInfo { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for BlockInfo { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "BlockInfo"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.BlockInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockInfo"; +} +impl ::buffa::Message for BlockInfo { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for BlockInfo { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __BLOCK_INFO_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.BlockInfo", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetMempoolTxsRequest {} +impl ::core::fmt::Debug for GetMempoolTxsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetMempoolTxsRequest").finish() + } +} +impl GetMempoolTxsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsRequest"; +} +impl ::buffa::DefaultInstance for GetMempoolTxsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetMempoolTxsRequest { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetMempoolTxsRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetMempoolTxsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsRequest"; +} +impl ::buffa::Message for GetMempoolTxsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetMempoolTxsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_MEMPOOL_TXS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetMempoolTxsResponse { + /// Field 1: `sequence_id` + #[serde( + rename = "sequenceId", + alias = "sequence_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sequence_id: ::buffa::MessageField, +} +impl ::core::fmt::Debug for GetMempoolTxsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetMempoolTxsResponse") + .field("sequence_id", &self.sequence_id) + .finish() + } +} +impl GetMempoolTxsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsResponse"; +} +impl ::buffa::DefaultInstance for GetMempoolTxsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetMempoolTxsResponse { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetMempoolTxsResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetMempoolTxsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsResponse"; +} +impl ::buffa::Message for GetMempoolTxsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_id.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sequence_id.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence_id = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for GetMempoolTxsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_MEMPOOL_TXS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetUtxosRequest {} +impl ::core::fmt::Debug for GetUtxosRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetUtxosRequest").finish() + } +} +impl GetUtxosRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosRequest"; +} +impl ::buffa::DefaultInstance for GetUtxosRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetUtxosRequest { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetUtxosRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetUtxosRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosRequest"; +} +impl ::buffa::Message for GetUtxosRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetUtxosRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_UTXOS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.GetUtxosRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct GetUtxosResponse {} +impl ::core::fmt::Debug for GetUtxosResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("GetUtxosResponse").finish() + } +} +impl GetUtxosResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosResponse"; +} +impl ::buffa::DefaultInstance for GetUtxosResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for GetUtxosResponse { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetUtxosResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetUtxosResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosResponse"; +} +impl ::buffa::Message for GetUtxosResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for GetUtxosResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __GET_UTXOS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.GetUtxosResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubmitTransactionRequest { + /// Field 1: `transaction` + #[serde( + rename = "transaction", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub transaction: ::buffa::alloc::vec::Vec, +} +impl ::core::fmt::Debug for SubmitTransactionRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubmitTransactionRequest") + .field("transaction", &self.transaction) + .finish() + } +} +impl SubmitTransactionRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionRequest"; +} +impl ::buffa::DefaultInstance for SubmitTransactionRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubmitTransactionRequest { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubmitTransactionRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubmitTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionRequest"; +} +impl ::buffa::Message for SubmitTransactionRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.transaction.is_empty() { + size += 1u32 + ::buffa::types::bytes_encoded_len(&self.transaction) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.transaction.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.transaction, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.transaction, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.transaction.clear(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubmitTransactionRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBMIT_TRANSACTION_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubmitTransactionResponse {} +impl ::core::fmt::Debug for SubmitTransactionResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubmitTransactionResponse").finish() + } +} +impl SubmitTransactionResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionResponse"; +} +impl ::buffa::DefaultInstance for SubmitTransactionResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubmitTransactionResponse { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubmitTransactionResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubmitTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionResponse"; +} +impl ::buffa::Message for SubmitTransactionResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for SubmitTransactionResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBMIT_TRANSACTION_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeEventsRequest {} +impl ::core::fmt::Debug for SubscribeEventsRequest { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeEventsRequest").finish() + } +} +impl SubscribeEventsRequest { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsRequest"; +} +impl ::buffa::DefaultInstance for SubscribeEventsRequest { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeEventsRequest { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsRequest"; +} +impl ::buffa::Message for SubscribeEventsRequest { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) {} +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeEventsRequest { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_EVENTS_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsRequest", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +#[derive(Clone, PartialEq, Default)] +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(default)] +pub struct SubscribeEventsResponse { + /// Field 1: `sequence_id` + #[serde( + rename = "sequenceId", + alias = "sequence_id", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub sequence_id: ::buffa::MessageField, + /// Field 2: `event` + #[serde( + rename = "event", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub event: ::buffa::MessageField, +} +impl ::core::fmt::Debug for SubscribeEventsResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("SubscribeEventsResponse") + .field("sequence_id", &self.sequence_id) + .field("event", &self.event) + .finish() + } +} +impl SubscribeEventsResponse { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse"; +} +impl ::buffa::DefaultInstance for SubscribeEventsResponse { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } +} +impl ::buffa::MessageName for SubscribeEventsResponse { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse"; +} +impl ::buffa::Message for SubscribeEventsResponse { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_id.write_to(__cache, buf); + } + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.sequence_id.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.event.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.sequence_id = ::buffa::MessageField::none(); + self.event = ::buffa::MessageField::none(); + } +} +impl ::buffa::json_helpers::ProtoElemJson for SubscribeEventsResponse { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } +} +#[doc(hidden)] +pub const __SUBSCRIBE_EVENTS_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, +}; +pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize)] + #[serde(default)] + pub struct Event { + #[serde(flatten)] + pub event: ::core::option::Option< + super::__buffa::oneof::subscribe_events_response::event::Event, + >, + } + impl ::core::fmt::Debug for Event { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Event").field("event", &self.event).finish() + } + } + impl Event { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event"; + } + impl ::buffa::DefaultInstance for Event { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for Event { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event"; + } + impl ::buffa::Message for Event { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + x, + ) => { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 2u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 3u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if let ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ref mut existing, + ), + ) = self.event + { + ::buffa::Message::merge_length_delimited( + &mut **existing, + buf, + depth, + )?; + } else { + let mut val = ::core::default::Default::default(); + ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?; + self.event = ::core::option::Option::Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ::buffa::alloc::boxed::Box::new(val), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.event = ::core::option::Option::None; + } + } + impl<'de> serde::Deserialize<'de> for Event { + fn deserialize>( + d: D, + ) -> ::core::result::Result { + struct _V; + impl<'de> serde::de::Visitor<'de> for _V { + type Value = Event; + fn expecting( + &self, + f: &mut core::fmt::Formatter<'_>, + ) -> core::fmt::Result { + f.write_str("struct Event") + } + #[allow(clippy::field_reassign_with_default)] + fn visit_map>( + self, + mut map: A, + ) -> ::core::result::Result { + let mut __oneof_event: ::core::option::Option< + super::__buffa::oneof::subscribe_events_response::event::Event, + > = None; + while let Some(key) = map + .next_key::<::buffa::alloc::string::String>()? + { + match key.as_str() { + "connectBlock" | "connect_block" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::ConnectBlock, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::ConnectBlock, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "disconnectBlock" | "disconnect_block" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::DisconnectBlock, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::DisconnectBlock, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "mempoolTxAdded" | "mempool_tx_added" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::MempoolTxAdded, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::MempoolTxAdded, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + "mempoolTxRemoved" | "mempool_tx_removed" => { + let v: ::core::option::Option< + super::subscribe_events_response::event::MempoolTxRemoved, + > = map + .next_value_seed( + ::buffa::json_helpers::NullableDeserializeSeed( + ::buffa::json_helpers::DefaultDeserializeSeed::< + super::subscribe_events_response::event::MempoolTxRemoved, + >::new(), + ), + )?; + if let Some(v) = v { + if __oneof_event.is_some() { + return Err( + serde::de::Error::custom( + "multiple oneof fields set for 'event'", + ), + ); + } + __oneof_event = Some( + super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ::buffa::alloc::boxed::Box::new(v), + ), + ); + } + } + _ => { + map.next_value::()?; + } + } + } + let mut __r = ::default(); + __r.event = __oneof_event; + Ok(__r) + } + } + d.deserialize_map(_V) + } + } + impl ::buffa::json_helpers::ProtoElemJson for Event { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __EVENT_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct ConnectBlock { + /// Field 1: `header_info` + #[serde( + rename = "headerInfo", + alias = "header_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub header_info: ::buffa::MessageField, + /// Field 2: `block_info` + #[serde( + rename = "blockInfo", + alias = "block_info", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field" + )] + pub block_info: ::buffa::MessageField, + } + impl ::core::fmt::Debug for ConnectBlock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ConnectBlock") + .field("header_info", &self.header_info) + .field("block_info", &self.block_info) + .finish() + } + } + impl ConnectBlock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl ::buffa::DefaultInstance for ConnectBlock { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for ConnectBlock { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.ConnectBlock"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl ::buffa::Message for ConnectBlock { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.block_info.write_to(__cache, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.header_info.get_or_insert_default(), + buf, + depth, + )?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::Message::merge_length_delimited( + self.block_info.get_or_insert_default(), + buf, + depth, + )?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.header_info = ::buffa::MessageField::none(); + self.block_info = ::buffa::MessageField::none(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for ConnectBlock { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __CONNECT_BLOCK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct DisconnectBlock { + /// Field 1: `block_hash` + #[serde( + rename = "blockHash", + alias = "block_hash", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub block_hash: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for DisconnectBlock { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DisconnectBlock") + .field("block_hash", &self.block_hash) + .finish() + } + } + impl DisconnectBlock { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl ::buffa::DefaultInstance for DisconnectBlock { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for DisconnectBlock { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.DisconnectBlock"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl ::buffa::Message for DisconnectBlock { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.block_hash) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.block_hash, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.block_hash, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.block_hash.clear(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for DisconnectBlock { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __DISCONNECT_BLOCK_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct MempoolTxAdded { + /// Field 1: `txid` + #[serde( + rename = "txid", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub txid: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for MempoolTxAdded { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MempoolTxAdded").field("txid", &self.txid).finish() + } + } + impl MempoolTxAdded { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded"; + } + impl ::buffa::DefaultInstance for MempoolTxAdded { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for MempoolTxAdded { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.MempoolTxAdded"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded"; + } + impl ::buffa::Message for MempoolTxAdded { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.txid.is_empty() { + size += 1u32 + ::buffa::types::bytes_encoded_len(&self.txid) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.txid.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.txid, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.txid, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid.clear(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for MempoolTxAdded { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __MEMPOOL_TX_ADDED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[derive(Clone, PartialEq, Default)] + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(default)] + pub struct MempoolTxRemoved { + /// Field 1: `txid` + #[serde( + rename = "txid", + with = "::buffa::json_helpers::bytes", + skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes" + )] + pub txid: ::buffa::alloc::vec::Vec, + } + impl ::core::fmt::Debug for MempoolTxRemoved { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MempoolTxRemoved").field("txid", &self.txid).finish() + } + } + impl MempoolTxRemoved { + /// Protobuf type URL for this message, for use with `Any::pack` and + /// `Any::unpack_if`. + /// + /// Format: `type.googleapis.com/` + pub const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved"; + } + impl ::buffa::DefaultInstance for MempoolTxRemoved { + fn default_instance() -> &'static Self { + static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) + } + } + impl ::buffa::MessageName for MempoolTxRemoved { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.MempoolTxRemoved"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved"; + } + impl ::buffa::Message for MempoolTxRemoved { + /// Returns the total encoded size in bytes. + /// + /// The result is a `u32`; the protobuf specification requires all + /// messages to fit within 2 GiB (2,147,483,647 bytes), so a + /// compliant message will never overflow this type. + #[allow(clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.txid.is_empty() { + size += 1u32 + ::buffa::types::bytes_encoded_len(&self.txid) as u32; + } + size + } + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.txid.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.txid, buf); + } + } + fn merge_field( + &mut self, + tag: ::buffa::encoding::Tag, + buf: &mut impl ::buffa::bytes::Buf, + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + #[allow(unused_imports)] + use ::buffa::bytes::Buf as _; + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + ::buffa::types::merge_bytes(&mut self.txid, buf)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, buf, depth)?; + } + } + ::core::result::Result::Ok(()) + } + fn clear(&mut self) { + self.txid.clear(); + } + } + impl ::buffa::json_helpers::ProtoElemJson for MempoolTxRemoved { + fn serialize_proto_json( + v: &Self, + s: S, + ) -> ::core::result::Result { + ::serde::Serialize::serialize(v, s) + } + fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>( + d: D, + ) -> ::core::result::Result { + ::deserialize(d) + } + } + #[doc(hidden)] + pub const __MEMPOOL_TX_REMOVED_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry { + type_url: "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved", + to_json: ::buffa::type_registry::any_to_json::, + from_json: ::buffa::type_registry::any_from_json::, + is_wkt: false, + }; + #[doc(inline)] + pub use super::super::__buffa::oneof::subscribe_events_response::event::Event; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::MempoolTxAddedView; + #[doc(inline)] + pub use super::super::__buffa::view::subscribe_events_response::event::MempoolTxRemovedView; + #[doc(inline)] + pub use super::super::__buffa::view::oneof::subscribe_events_response::event::Event as EventView; + } + #[doc(inline)] + pub use super::__buffa::view::subscribe_events_response::EventView; +} +#[allow( + non_camel_case_types, + dead_code, + unused_imports, + unused_qualifications, + clippy::derivable_impls, + clippy::match_single_binding, + clippy::uninlined_format_args, + clippy::doc_lazy_continuation, + clippy::module_inception +)] +pub mod __buffa { + #[allow(unused_imports)] + use super::*; + pub mod view { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct SequenceIdView<'a> { + /// Field 1: `sequence_id` + pub sequence_id: u64, + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> SequenceIdView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.sequence_id = ::buffa::types::decode_uint64(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SequenceIdView<'a> { + type Owned = super::super::SequenceId; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SequenceId { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SequenceId { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SequenceId { + sequence_id: self.sequence_id, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SequenceIdView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id != 0u64 { + size + += 1u32 + + ::buffa::types::uint64_encoded_len(self.sequence_id) + as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id != 0u64 { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint64(self.sequence_id, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SequenceIdView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_zero_u64(&self.sequence_id) { + struct _W(u64); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint64::serialize(&self.0, __s) + } + } + __map.serialize_entry("sequenceId", &_W(self.sequence_id))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SequenceIdView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SequenceId"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SequenceId"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SequenceId"; + } + impl<'v> ::buffa::DefaultViewInstance for SequenceIdView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SequenceIdView<'static> { + type Reborrowed<'b> = SequenceIdView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct BlockHeaderInfoView<'a> { + /// Field 1: `block_hash` + pub block_hash: &'a [u8], + /// Field 2: `prev_block_hash` + pub prev_block_hash: &'a [u8], + /// Field 3: `prev_main_block_hash` + pub prev_main_block_hash: &'a [u8], + /// Field 4: `height` + pub height: u32, + } + impl<'a> BlockHeaderInfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.block_hash = ::buffa::types::borrow_bytes(&mut cur)?; + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.prev_block_hash = ::buffa::types::borrow_bytes( + &mut cur, + )?; + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.prev_main_block_hash = ::buffa::types::borrow_bytes( + &mut cur, + )?; + } + 4u32 => { + if tag.wire_type() != ::buffa::encoding::WireType::Varint { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 0u8, + actual: tag.wire_type() as u8, + }); + } + view.height = ::buffa::types::decode_uint32(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BlockHeaderInfoView<'a> { + type Owned = super::super::BlockHeaderInfo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::BlockHeaderInfo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BlockHeaderInfo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BlockHeaderInfo { + block_hash: (self.block_hash).to_vec(), + prev_block_hash: (self.prev_block_hash).to_vec(), + prev_main_block_hash: (self.prev_main_block_hash).to_vec(), + height: self.height, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BlockHeaderInfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.block_hash) as u32; + } + if !self.prev_block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.prev_block_hash) + as u32; + } + if !self.prev_main_block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len( + &self.prev_main_block_hash, + ) as u32; + } + if self.height != 0u32 { + size + += 1u32 + ::buffa::types::uint32_encoded_len(self.height) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.block_hash, buf); + } + if !self.prev_block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.prev_block_hash, buf); + } + if !self.prev_main_block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.prev_main_block_hash, buf); + } + if self.height != 0u32 { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::Varint, + ) + .encode(buf); + ::buffa::types::encode_uint32(self.height, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BlockHeaderInfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_bytes(self.block_hash) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("blockHash", &_W(self.block_hash))?; + } + if !::buffa::json_helpers::skip_if::is_empty_bytes( + self.prev_block_hash, + ) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("prevBlockHash", &_W(self.prev_block_hash))?; + } + if !::buffa::json_helpers::skip_if::is_empty_bytes( + self.prev_main_block_hash, + ) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map + .serialize_entry( + "prevMainBlockHash", + &_W(self.prev_main_block_hash), + )?; + } + if !::buffa::json_helpers::skip_if::is_zero_u32(&self.height) { + struct _W(u32); + impl ::serde::Serialize for _W { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::uint32::serialize(&self.0, __s) + } + } + __map.serialize_entry("height", &_W(self.height))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for BlockHeaderInfoView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "BlockHeaderInfo"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.BlockHeaderInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockHeaderInfo"; + } + impl<'v> ::buffa::DefaultViewInstance for BlockHeaderInfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + BlockHeaderInfoView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BlockHeaderInfoView<'static> { + type Reborrowed<'b> = BlockHeaderInfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct BlockInfoView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> BlockInfoView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for BlockInfoView<'a> { + type Owned = super::super::BlockInfo; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::BlockInfo { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::BlockInfo { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::BlockInfo { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for BlockInfoView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for BlockInfoView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for BlockInfoView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "BlockInfo"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.BlockInfo"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.BlockInfo"; + } + impl<'v> ::buffa::DefaultViewInstance for BlockInfoView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for BlockInfoView<'static> { + type Reborrowed<'b> = BlockInfoView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetMempoolTxsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetMempoolTxsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetMempoolTxsRequestView<'a> { + type Owned = super::super::GetMempoolTxsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetMempoolTxsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetMempoolTxsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetMempoolTxsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetMempoolTxsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetMempoolTxsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetMempoolTxsRequestView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetMempoolTxsRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetMempoolTxsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetMempoolTxsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetMempoolTxsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetMempoolTxsRequestView<'static> { + type Reborrowed<'b> = GetMempoolTxsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetMempoolTxsResponseView<'a> { + /// Field 1: `sequence_id` + pub sequence_id: ::buffa::MessageFieldView< + super::super::__buffa::view::SequenceIdView<'a>, + >, + } + impl<'a> GetMempoolTxsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sequence_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sequence_id = ::buffa::MessageFieldView::set( + super::super::__buffa::view::SequenceIdView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetMempoolTxsResponseView<'a> { + type Owned = super::super::GetMempoolTxsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetMempoolTxsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetMempoolTxsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetMempoolTxsResponse { + sequence_id: match self.sequence_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SequenceId, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetMempoolTxsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_id.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetMempoolTxsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sequence_id + .as_option() + { + __map.serialize_entry("sequenceId", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetMempoolTxsResponseView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetMempoolTxsResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetMempoolTxsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetMempoolTxsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetMempoolTxsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetMempoolTxsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetMempoolTxsResponseView<'static> { + type Reborrowed<'b> = GetMempoolTxsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetUtxosRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetUtxosRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetUtxosRequestView<'a> { + type Owned = super::super::GetUtxosRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetUtxosRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetUtxosRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetUtxosRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetUtxosRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetUtxosRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetUtxosRequestView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetUtxosRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetUtxosRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for GetUtxosRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetUtxosRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetUtxosRequestView<'static> { + type Reborrowed<'b> = GetUtxosRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct GetUtxosResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> GetUtxosResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for GetUtxosResponseView<'a> { + type Owned = super::super::GetUtxosResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::GetUtxosResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::GetUtxosResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::GetUtxosResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for GetUtxosResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for GetUtxosResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for GetUtxosResponseView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "GetUtxosResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.GetUtxosResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.GetUtxosResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for GetUtxosResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + GetUtxosResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for GetUtxosResponseView<'static> { + type Reborrowed<'b> = GetUtxosResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubmitTransactionRequestView<'a> { + /// Field 1: `transaction` + pub transaction: &'a [u8], + } + impl<'a> SubmitTransactionRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.transaction = ::buffa::types::borrow_bytes(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubmitTransactionRequestView<'a> { + type Owned = super::super::SubmitTransactionRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubmitTransactionRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubmitTransactionRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubmitTransactionRequest { + transaction: (self.transaction).to_vec(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubmitTransactionRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.transaction.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.transaction) + as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.transaction.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.transaction, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubmitTransactionRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_bytes(self.transaction) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("transaction", &_W(self.transaction))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubmitTransactionRequestView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubmitTransactionRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubmitTransactionRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for SubmitTransactionRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubmitTransactionRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubmitTransactionRequestView<'static> { + type Reborrowed<'b> = SubmitTransactionRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubmitTransactionResponseView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> SubmitTransactionResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubmitTransactionResponseView<'a> { + type Owned = super::super::SubmitTransactionResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubmitTransactionResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubmitTransactionResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubmitTransactionResponse { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubmitTransactionResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubmitTransactionResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubmitTransactionResponseView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubmitTransactionResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubmitTransactionResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubmitTransactionResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for SubmitTransactionResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubmitTransactionResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubmitTransactionResponseView<'static> { + type Reborrowed<'b> = SubmitTransactionResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubscribeEventsRequestView<'a> { + #[doc(hidden)] + pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>, + } + impl<'a> SubscribeEventsRequestView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubscribeEventsRequestView<'a> { + type Owned = super::super::SubscribeEventsRequest; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubscribeEventsRequest { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeEventsRequest { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeEventsRequest { + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubscribeEventsRequestView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let size = 0u32; + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + _buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeEventsRequestView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeEventsRequestView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsRequest"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsRequest"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsRequest"; + } + impl<'v> ::buffa::DefaultViewInstance for SubscribeEventsRequestView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeEventsRequestView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeEventsRequestView<'static> { + type Reborrowed<'b> = SubscribeEventsRequestView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct SubscribeEventsResponseView<'a> { + /// Field 1: `sequence_id` + pub sequence_id: ::buffa::MessageFieldView< + super::super::__buffa::view::SequenceIdView<'a>, + >, + /// Field 2: `event` + pub event: ::buffa::MessageFieldView< + super::super::__buffa::view::subscribe_events_response::EventView<'a>, + >, + } + impl<'a> SubscribeEventsResponseView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.sequence_id.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.sequence_id = ::buffa::MessageFieldView::set( + super::super::__buffa::view::SequenceIdView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.event.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.event = ::buffa::MessageFieldView::set( + super::super::__buffa::view::subscribe_events_response::EventView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for SubscribeEventsResponseView<'a> { + type Owned = super::super::SubscribeEventsResponse; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message(&self) -> super::super::SubscribeEventsResponse { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::SubscribeEventsResponse { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::SubscribeEventsResponse { + sequence_id: match self.sequence_id.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::SequenceId, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + event: match self.event.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::subscribe_events_response::Event, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for SubscribeEventsResponseView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.sequence_id.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.sequence_id.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.event.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.event.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.sequence_id.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.sequence_id.write_to(__cache, buf); + } + if self.event.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf); + self.event.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for SubscribeEventsResponseView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .sequence_id + .as_option() + { + __map.serialize_entry("sequenceId", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self.event.as_option() { + __map.serialize_entry("event", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for SubscribeEventsResponseView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse"; + } + impl<'v> ::buffa::DefaultViewInstance for SubscribeEventsResponseView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + SubscribeEventsResponseView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for SubscribeEventsResponseView<'static> { + type Reborrowed<'b> = SubscribeEventsResponseView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct EventView<'a> { + pub event: ::core::option::Option< + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event< + 'a, + >, + >, + } + impl<'a> EventView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 3u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 3u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::MempoolTxAddedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + 4u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 4u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + if let Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ref mut existing, + ), + ) = view.event + { + existing._merge_into_view(sub, depth - 1)?; + } else { + view.event = Some( + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ::buffa::alloc::boxed::Box::new( + super::super::super::__buffa::view::subscribe_events_response::event::MempoolTxRemovedView::_decode_depth( + sub, + depth - 1, + )?, + ), + ), + ); + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for EventView<'a> { + type Owned = super::super::super::subscribe_events_response::Event; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::subscribe_events_response::Event { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::subscribe_events_response::Event { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::subscribe_events_response::Event { + event: self + .event + .as_ref() + .map(|v| match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::ConnectBlock( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::DisconnectBlock( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + v, + ) => { + super::super::super::__buffa::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + ::buffa::alloc::boxed::Box::new( + v.to_owned_from_source(__buffa_src), + ), + ) + } + }), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for EventView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + x, + ) => { + let __slot = __cache.reserve(); + let inner = x.compute_size(__cache); + __cache.set(__slot, inner); + size + += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32 + + inner; + } + } + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if let ::core::option::Option::Some(ref v) = self.event { + match v { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + x, + ) => { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + x, + ) => { + ::buffa::encoding::Tag::new( + 3u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + x, + ) => { + ::buffa::encoding::Tag::new( + 4u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + x.write_to(__cache, buf); + } + } + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for EventView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if let ::core::option::Option::Some(ref __ov) = self.event { + match __ov { + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::ConnectBlock( + v, + ) => { + __map.serialize_entry("connectBlock", v)?; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::DisconnectBlock( + v, + ) => { + __map.serialize_entry("disconnectBlock", v)?; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxAdded( + v, + ) => { + __map.serialize_entry("mempoolTxAdded", v)?; + } + super::super::super::__buffa::view::oneof::subscribe_events_response::event::Event::MempoolTxRemoved( + v, + ) => { + __map.serialize_entry("mempoolTxRemoved", v)?; + } + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for EventView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event"; + } + impl<'v> ::buffa::DefaultViewInstance for EventView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for EventView<'static> { + type Reborrowed<'b> = EventView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug, Default)] + pub struct ConnectBlockView<'a> { + /// Field 1: `header_info` + pub header_info: ::buffa::MessageFieldView< + super::super::super::super::__buffa::view::BlockHeaderInfoView< + 'a, + >, + >, + /// Field 2: `block_info` + pub block_info: ::buffa::MessageFieldView< + super::super::super::super::__buffa::view::BlockInfoView<'a>, + >, + } + impl<'a> ConnectBlockView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.header_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.header_info = ::buffa::MessageFieldView::set( + super::super::super::super::__buffa::view::BlockHeaderInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + 2u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 2u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + if depth == 0 { + return Err(::buffa::DecodeError::RecursionLimitExceeded); + } + let sub = ::buffa::types::borrow_bytes(&mut cur)?; + match view.block_info.as_mut() { + Some(existing) => existing._merge_into_view(sub, depth - 1)?, + None => { + view.block_info = ::buffa::MessageFieldView::set( + super::super::super::super::__buffa::view::BlockInfoView::_decode_depth( + sub, + depth - 1, + )?, + ); + } + } + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for ConnectBlockView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::ConnectBlock; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::ConnectBlock { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::ConnectBlock { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::ConnectBlock { + header_info: match self.header_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::BlockHeaderInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + block_info: match self.block_info.as_option() { + Some(v) => { + ::buffa::MessageField::< + super::super::super::super::BlockInfo, + >::some(v.to_owned_from_source(__buffa_src)) + } + None => ::buffa::MessageField::none(), + }, + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for ConnectBlockView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if self.header_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.header_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + if self.block_info.is_set() { + let __slot = __cache.reserve(); + let inner_size = self.block_info.compute_size(__cache); + __cache.set(__slot, inner_size); + size + += 1u32 + + ::buffa::encoding::varint_len(inner_size as u64) as u32 + + inner_size; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + __cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if self.header_info.is_set() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.header_info.write_to(__cache, buf); + } + if self.block_info.is_set() { + ::buffa::encoding::Tag::new( + 2u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::encoding::encode_varint( + __cache.consume_next() as u64, + buf, + ); + self.block_info.write_to(__cache, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for ConnectBlockView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + { + if let ::core::option::Option::Some(__v) = self + .header_info + .as_option() + { + __map.serialize_entry("headerInfo", __v)?; + } + } + { + if let ::core::option::Option::Some(__v) = self + .block_info + .as_option() + { + __map.serialize_entry("blockInfo", __v)?; + } + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for ConnectBlockView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.ConnectBlock"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.ConnectBlock"; + } + impl<'v> ::buffa::DefaultViewInstance for ConnectBlockView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + ConnectBlockView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for ConnectBlockView<'static> { + type Reborrowed<'b> = ConnectBlockView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct DisconnectBlockView<'a> { + /// Field 1: `block_hash` + pub block_hash: &'a [u8], + } + impl<'a> DisconnectBlockView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.block_hash = ::buffa::types::borrow_bytes(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for DisconnectBlockView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::DisconnectBlock; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::DisconnectBlock { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::DisconnectBlock { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::DisconnectBlock { + block_hash: (self.block_hash).to_vec(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for DisconnectBlockView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.block_hash.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.block_hash) + as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.block_hash.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.block_hash, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for DisconnectBlockView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_bytes( + self.block_hash, + ) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("blockHash", &_W(self.block_hash))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for DisconnectBlockView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.DisconnectBlock"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.DisconnectBlock"; + } + impl<'v> ::buffa::DefaultViewInstance for DisconnectBlockView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + DisconnectBlockView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for DisconnectBlockView<'static> { + type Reborrowed<'b> = DisconnectBlockView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct MempoolTxAddedView<'a> { + /// Field 1: `txid` + pub txid: &'a [u8], + } + impl<'a> MempoolTxAddedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.txid = ::buffa::types::borrow_bytes(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for MempoolTxAddedView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::MempoolTxAdded; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::MempoolTxAdded { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::MempoolTxAdded { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::MempoolTxAdded { + txid: (self.txid).to_vec(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for MempoolTxAddedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.txid.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.txid) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.txid.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.txid, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for MempoolTxAddedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_bytes(self.txid) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("txid", &_W(self.txid))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for MempoolTxAddedView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.MempoolTxAdded"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxAdded"; + } + impl<'v> ::buffa::DefaultViewInstance for MempoolTxAddedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + MempoolTxAddedView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for MempoolTxAddedView<'static> { + type Reborrowed<'b> = MempoolTxAddedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + #[derive(Clone, Debug, Default)] + pub struct MempoolTxRemovedView<'a> { + /// Field 1: `txid` + pub txid: &'a [u8], + } + impl<'a> MempoolTxRemovedView<'a> { + /// Decode from `buf`, enforcing a recursion depth limit for nested messages. + /// + /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`] + /// and by generated sub-message decode arms with `depth - 1`. + /// + /// **Not part of the public API.** Named with a leading underscore to + /// signal that it is for generated-code use only. + #[doc(hidden)] + pub fn _decode_depth( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + let mut view = Self::default(); + view._merge_into_view(buf, depth)?; + ::core::result::Result::Ok(view) + } + /// Merge fields from `buf` into this view (proto merge semantics). + /// + /// Repeated fields append; singular fields last-wins; singular + /// MESSAGE fields merge recursively. Used by sub-message decode + /// arms when the same field appears multiple times on the wire. + /// + /// **Not part of the public API.** + #[doc(hidden)] + pub fn _merge_into_view( + &mut self, + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result<(), ::buffa::DecodeError> { + let _ = depth; + #[allow(unused_variables)] + let view = self; + let mut cur: &'a [u8] = buf; + while !cur.is_empty() { + let tag = ::buffa::encoding::Tag::decode(&mut cur)?; + match tag.field_number() { + 1u32 => { + if tag.wire_type() + != ::buffa::encoding::WireType::LengthDelimited + { + return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch { + field_number: 1u32, + expected: 2u8, + actual: tag.wire_type() as u8, + }); + } + view.txid = ::buffa::types::borrow_bytes(&mut cur)?; + } + _ => { + ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?; + } + } + } + ::core::result::Result::Ok(()) + } + } + impl<'a> ::buffa::MessageView<'a> for MempoolTxRemovedView<'a> { + type Owned = super::super::super::super::subscribe_events_response::event::MempoolTxRemoved; + fn decode_view( + buf: &'a [u8], + ) -> ::core::result::Result { + Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT) + } + fn decode_view_with_limit( + buf: &'a [u8], + depth: u32, + ) -> ::core::result::Result { + Self::_decode_depth(buf, depth) + } + fn to_owned_message( + &self, + ) -> super::super::super::super::subscribe_events_response::event::MempoolTxRemoved { + self.to_owned_from_source(None) + } + #[allow(clippy::useless_conversion, clippy::needless_update)] + fn to_owned_from_source( + &self, + __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>, + ) -> super::super::super::super::subscribe_events_response::event::MempoolTxRemoved { + #[allow(unused_imports)] + use ::buffa::alloc::string::ToString as _; + let _ = __buffa_src; + super::super::super::super::subscribe_events_response::event::MempoolTxRemoved { + txid: (self.txid).to_vec(), + ..::core::default::Default::default() + } + } + } + impl<'a> ::buffa::ViewEncode<'a> for MempoolTxRemovedView<'a> { + #[allow(clippy::needless_borrow, clippy::let_and_return)] + fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + let mut size = 0u32; + if !self.txid.is_empty() { + size + += 1u32 + + ::buffa::types::bytes_encoded_len(&self.txid) as u32; + } + size + } + #[allow(clippy::needless_borrow)] + fn write_to( + &self, + _cache: &mut ::buffa::SizeCache, + buf: &mut impl ::buffa::bytes::BufMut, + ) { + #[allow(unused_imports)] + use ::buffa::Enumeration as _; + if !self.txid.is_empty() { + ::buffa::encoding::Tag::new( + 1u32, + ::buffa::encoding::WireType::LengthDelimited, + ) + .encode(buf); + ::buffa::types::encode_bytes(&self.txid, buf); + } + } + } + /// Serializes this view as protobuf JSON. + /// + /// Implicit-presence fields with default values are omitted, `required` + /// fields are always emitted, explicit-presence (`optional`) fields are + /// emitted only when set, bytes fields are base64-encoded, and enum + /// values are their proto name strings. + /// + /// This impl uses `serialize_map(None)` because the number of emitted + /// fields depends on default-omission rules; serializers that require + /// known map lengths (e.g. `bincode`) will return a runtime error. + /// Use the owned message type for those formats. + impl<'__a> ::serde::Serialize for MempoolTxRemovedView<'__a> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + use ::serde::ser::SerializeMap as _; + let mut __map = __s.serialize_map(::core::option::Option::None)?; + if !::buffa::json_helpers::skip_if::is_empty_bytes(self.txid) { + struct _W<'__x>(&'__x [u8]); + impl ::serde::Serialize for _W<'_> { + fn serialize<__S: ::serde::Serializer>( + &self, + __s: __S, + ) -> ::core::result::Result<__S::Ok, __S::Error> { + ::buffa::json_helpers::bytes::serialize(self.0, __s) + } + } + __map.serialize_entry("txid", &_W(self.txid))?; + } + __map.end() + } + } + impl<'a> ::buffa::MessageName for MempoolTxRemovedView<'a> { + const PACKAGE: &'static str = "cusf.sidechain.v1"; + const NAME: &'static str = "SubscribeEventsResponse.Event.MempoolTxRemoved"; + const FULL_NAME: &'static str = "cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved"; + const TYPE_URL: &'static str = "type.googleapis.com/cusf.sidechain.v1.SubscribeEventsResponse.Event.MempoolTxRemoved"; + } + impl<'v> ::buffa::DefaultViewInstance for MempoolTxRemovedView<'v> { + fn default_view_instance<'a>() -> &'a Self + where + Self: 'a, + { + static VALUE: ::buffa::__private::OnceBox< + MempoolTxRemovedView<'static>, + > = ::buffa::__private::OnceBox::new(); + VALUE + .get_or_init(|| ::buffa::alloc::boxed::Box::new( + >::default(), + )) + } + } + impl ::buffa::ViewReborrow for MempoolTxRemovedView<'static> { + type Reborrowed<'b> = MempoolTxRemovedView<'b>; + fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> { + this + } + } + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, Debug)] + pub enum Event<'a> { + ConnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::ConnectBlockView< + 'a, + >, + >, + ), + DisconnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::DisconnectBlockView< + 'a, + >, + >, + ), + MempoolTxAdded( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::MempoolTxAddedView< + 'a, + >, + >, + ), + MempoolTxRemoved( + ::buffa::alloc::boxed::Box< + super::super::super::super::super::__buffa::view::subscribe_events_response::event::MempoolTxRemovedView< + 'a, + >, + >, + ), + } + } + } + } + } + pub mod oneof { + #[allow(unused_imports)] + use super::*; + pub mod subscribe_events_response { + #[allow(unused_imports)] + use super::*; + pub mod event { + #[allow(unused_imports)] + use super::*; + #[derive(Clone, PartialEq, Debug)] + pub enum Event { + ConnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + >, + ), + DisconnectBlock( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + >, + ), + MempoolTxAdded( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::MempoolTxAdded, + >, + ), + MempoolTxRemoved( + ::buffa::alloc::boxed::Box< + super::super::super::super::subscribe_events_response::event::MempoolTxRemoved, + >, + ), + } + impl ::buffa::Oneof for Event {} + impl From< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::ConnectBlock, + ) -> Self { + Self::ConnectBlock(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::ConnectBlock, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::ConnectBlock, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::DisconnectBlock, + ) -> Self { + Self::DisconnectBlock(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::DisconnectBlock, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::DisconnectBlock, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::MempoolTxAdded, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::MempoolTxAdded, + ) -> Self { + Self::MempoolTxAdded(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::MempoolTxAdded, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::MempoolTxAdded, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::MempoolTxRemoved, + > for Event { + fn from( + v: super::super::super::super::subscribe_events_response::event::MempoolTxRemoved, + ) -> Self { + Self::MempoolTxRemoved(::buffa::alloc::boxed::Box::new(v)) + } + } + impl From< + super::super::super::super::subscribe_events_response::event::MempoolTxRemoved, + > for ::core::option::Option { + fn from( + v: super::super::super::super::subscribe_events_response::event::MempoolTxRemoved, + ) -> Self { + Self::Some(Event::from(v)) + } + } + impl serde::Serialize for Event { + fn serialize( + &self, + s: S, + ) -> ::core::result::Result { + use serde::ser::SerializeMap; + let mut map = s.serialize_map(Some(1))?; + match self { + Self::ConnectBlock(v) => { + map.serialize_entry("connectBlock", v)?; + } + Self::DisconnectBlock(v) => { + map.serialize_entry("disconnectBlock", v)?; + } + Self::MempoolTxAdded(v) => { + map.serialize_entry("mempoolTxAdded", v)?; + } + Self::MempoolTxRemoved(v) => { + map.serialize_entry("mempoolTxRemoved", v)?; + } + } + map.end() + } + } + } + } + } + /// Register this package's `Any` type entries and extension entries. + pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) { + reg.register_json_any(super::__SEQUENCE_ID_JSON_ANY); + reg.register_json_any(super::__BLOCK_HEADER_INFO_JSON_ANY); + reg.register_json_any(super::__BLOCK_INFO_JSON_ANY); + reg.register_json_any(super::__GET_MEMPOOL_TXS_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_MEMPOOL_TXS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__GET_UTXOS_REQUEST_JSON_ANY); + reg.register_json_any(super::__GET_UTXOS_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SUBMIT_TRANSACTION_REQUEST_JSON_ANY); + reg.register_json_any(super::__SUBMIT_TRANSACTION_RESPONSE_JSON_ANY); + reg.register_json_any(super::__SUBSCRIBE_EVENTS_REQUEST_JSON_ANY); + reg.register_json_any(super::__SUBSCRIBE_EVENTS_RESPONSE_JSON_ANY); + reg.register_json_any(super::subscribe_events_response::__EVENT_JSON_ANY); + reg.register_json_any( + super::subscribe_events_response::event::__CONNECT_BLOCK_JSON_ANY, + ); + reg.register_json_any( + super::subscribe_events_response::event::__DISCONNECT_BLOCK_JSON_ANY, + ); + reg.register_json_any( + super::subscribe_events_response::event::__MEMPOOL_TX_ADDED_JSON_ANY, + ); + reg.register_json_any( + super::subscribe_events_response::event::__MEMPOOL_TX_REMOVED_JSON_ANY, + ); + } +} +#[doc(inline)] +pub use self::__buffa::view::SequenceIdView; +#[doc(inline)] +pub use self::__buffa::view::BlockHeaderInfoView; +#[doc(inline)] +pub use self::__buffa::view::BlockInfoView; +#[doc(inline)] +pub use self::__buffa::view::GetMempoolTxsRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetMempoolTxsResponseView; +#[doc(inline)] +pub use self::__buffa::view::GetUtxosRequestView; +#[doc(inline)] +pub use self::__buffa::view::GetUtxosResponseView; +#[doc(inline)] +pub use self::__buffa::view::SubmitTransactionRequestView; +#[doc(inline)] +pub use self::__buffa::view::SubmitTransactionResponseView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeEventsRequestView; +#[doc(inline)] +pub use self::__buffa::view::SubscribeEventsResponseView; +#[doc(inline)] +pub use self::__buffa::register_types; diff --git a/lib/proto/generated/connect/cusf.crypto.v1.rs b/lib/proto/generated/connect/cusf.crypto.v1.rs new file mode 100644 index 00000000..a94f2091 --- /dev/null +++ b/lib/proto/generated/connect/cusf.crypto.v1.rs @@ -0,0 +1,978 @@ +// @generated by connectrpc-codegen. DO NOT EDIT. + +///Shorthand for `OwnedView>`. +pub type OwnedHmacSha512RequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512RequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedHmacSha512ResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512ResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedRipemd160RequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160RequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedRipemd160ResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160ResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1SecretKeyToPublicKeyRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1SecretKeyToPublicKeyResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1SignRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1SignResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1VerifyRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSecp256k1VerifyResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyResponseView< + 'static, + >, +>; +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Response, +> +for crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512ResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Response, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512ResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Response, +> +for crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160ResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Response, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160ResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyResponse, +> +for crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignResponse, +> +for crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyResponse, +> +for crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +/// Full service name for this service. +pub const CRYPTO_SERVICE_SERVICE_NAME: &str = "cusf.crypto.v1.CryptoService"; +/// Static [`Spec`](::connectrpc::Spec) for the server-side `HmacSha512` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const CRYPTO_SERVICE_HMAC_SHA512_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.crypto.v1.CryptoService/HmacSha512", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `Ripemd160` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const CRYPTO_SERVICE_RIPEMD160_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.crypto.v1.CryptoService/Ripemd160", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `Secp256k1SecretKeyToPublicKey` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const CRYPTO_SERVICE_SECP256K1_SECRET_KEY_TO_PUBLIC_KEY_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.crypto.v1.CryptoService/Secp256k1SecretKeyToPublicKey", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `Secp256k1Sign` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const CRYPTO_SERVICE_SECP256K1_SIGN_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.crypto.v1.CryptoService/Secp256k1Sign", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `Secp256k1Verify` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const CRYPTO_SERVICE_SECP256K1_VERIFY_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.crypto.v1.CryptoService/Secp256k1Verify", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Server trait for CryptoService. +/// +/// # Implementing handlers +/// +/// Handlers receive requests as `OwnedFooView` (an alias for +/// `OwnedView>`), which gives zero-copy borrowed access +/// to fields (e.g. `request.name` is a `&str` into the decoded buffer). +/// The view can be held across `.await` points. When two RPC types in +/// the same package would alias to the same `Owned<…>View` name (e.g. +/// a local message plus an imported one with the same short name), the +/// alias is suppressed for both and the request type is spelled as +/// `OwnedView<…View<'static>>` directly in the trait signature. +/// +/// Implement methods with plain `async fn`; the returned future satisfies +/// the `Send` bound automatically. See the +/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations) +/// for zero-copy access patterns and when `to_owned_message()` is needed. +/// +/// The `impl Encodable` return bound accepts the owned `Out`, the +/// generated `OutView<'_>` / `OwnedOutView`, +/// [`MaybeBorrowed`](::connectrpc::MaybeBorrowed), or +/// [`PreEncoded`](::connectrpc::PreEncoded) for handlers that encode a +/// non-`'static` view internally and pass the bytes across the handler +/// boundary. View bodies are not emitted for output types mapped via +/// `extern_path` (the impl would be an orphan); return owned for +/// WKT/extern outputs. +/// +/// Server-streaming and bidi-streaming methods return +/// `ServiceStream + Send + use>`. The +/// `use` precise-capturing clause excludes `&self`'s lifetime +/// (unary methods use `use<'a, Self>` and may borrow), so stream items +/// must be `'static`. To stream view-encoded data, encode each item +/// inside the stream body and yield +/// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming +/// example` doc. +#[allow(clippy::type_complexity)] +pub trait CryptoService: Send + Sync + 'static { + /// Handle the HmacSha512 RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn hmac_sha512<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedHmacSha512RequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Response, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the Ripemd160 RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn ripemd160<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedRipemd160RequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Response, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the Secp256k1SecretKeyToPublicKey RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn secp256k1_secret_key_to_public_key<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedSecp256k1SecretKeyToPublicKeyRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the Secp256k1Sign RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn secp256k1_sign<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedSecp256k1SignRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the Secp256k1Verify RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn secp256k1_verify<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedSecp256k1VerifyRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyResponse, + > + Send + use<'a, Self>, + >, + > + Send; +} +/// Extension trait for registering a service implementation with a Router. +/// +/// This trait is automatically implemented for all types that implement the service trait. +/// +/// # Example +/// +/// ```rust,ignore +/// use std::sync::Arc; +/// +/// let service = Arc::new(MyServiceImpl); +/// let router = service.register(Router::new()); +/// ``` +pub trait CryptoServiceExt: CryptoService { + /// Register this service implementation with a Router. + /// + /// Takes ownership of the `Arc` and returns a new Router with + /// this service's methods registered. + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router; +} +impl CryptoServiceExt for S { + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router { + router + .route_view( + CRYPTO_SERVICE_SERVICE_NAME, + "HmacSha512", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.hmac_sha512(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Response, + >(format) + } + }) + }, + ) + .with_spec(CRYPTO_SERVICE_HMAC_SHA512_SPEC) + .route_view( + CRYPTO_SERVICE_SERVICE_NAME, + "Ripemd160", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.ripemd160(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Response, + >(format) + } + }) + }, + ) + .with_spec(CRYPTO_SERVICE_RIPEMD160_SPEC) + .route_view( + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1SecretKeyToPublicKey", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.secp256k1_secret_key_to_public_key(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyResponse, + >(format) + } + }) + }, + ) + .with_spec(CRYPTO_SERVICE_SECP256K1_SECRET_KEY_TO_PUBLIC_KEY_SPEC) + .route_view( + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1Sign", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.secp256k1_sign(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignResponse, + >(format) + } + }) + }, + ) + .with_spec(CRYPTO_SERVICE_SECP256K1_SIGN_SPEC) + .route_view( + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1Verify", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.secp256k1_verify(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyResponse, + >(format) + } + }) + }, + ) + .with_spec(CRYPTO_SERVICE_SECP256K1_VERIFY_SPEC) + } +} +/// Monomorphic dispatcher for `CryptoService`. +/// +/// Unlike `.register(Router)` which type-erases each method into an `Arc` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup. +/// +/// # Example +/// +/// ```rust,ignore +/// use connectrpc::ConnectRpcService; +/// +/// let server = CryptoServiceServer::new(MyImpl); +/// let service = ConnectRpcService::new(server); +/// // hand `service` to axum/hyper as a fallback_service +/// ``` +pub struct CryptoServiceServer { + inner: ::std::sync::Arc, +} +impl CryptoServiceServer { + /// Wrap a service implementation in a monomorphic dispatcher. + pub fn new(service: T) -> Self { + Self { + inner: ::std::sync::Arc::new(service), + } + } + /// Wrap an already-`Arc`'d service implementation. + pub fn from_arc(inner: ::std::sync::Arc) -> Self { + Self { inner } + } +} +impl Clone for CryptoServiceServer { + fn clone(&self) -> Self { + Self { + inner: ::std::sync::Arc::clone(&self.inner), + } + } +} +impl ::connectrpc::Dispatcher for CryptoServiceServer { + #[inline] + fn lookup( + &self, + path: &str, + ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + let method = path.strip_prefix("cusf.crypto.v1.CryptoService/")?; + match method { + "HmacSha512" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(CRYPTO_SERVICE_HMAC_SHA512_SPEC), + ) + } + "Ripemd160" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(CRYPTO_SERVICE_RIPEMD160_SPEC), + ) + } + "Secp256k1SecretKeyToPublicKey" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec( + CRYPTO_SERVICE_SECP256K1_SECRET_KEY_TO_PUBLIC_KEY_SPEC, + ), + ) + } + "Secp256k1Sign" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(CRYPTO_SERVICE_SECP256K1_SIGN_SPEC), + ) + } + "Secp256k1Verify" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(CRYPTO_SERVICE_SECP256K1_VERIFY_SPEC), + ) + } + _ => None, + } + } + fn call_unary( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::connectrpc::Payload, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.crypto.v1.CryptoService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &request, &format); + match method { + "HmacSha512" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512RequestView, + >(request.encoded()?, format)?; + svc.hmac_sha512(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Response, + >(format) + }) + } + "Ripemd160" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160RequestView, + >(request.encoded()?, format)?; + svc.ripemd160(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Response, + >(format) + }) + } + "Secp256k1SecretKeyToPublicKey" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyRequestView, + >(request.encoded()?, format)?; + svc.secp256k1_secret_key_to_public_key(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyResponse, + >(format) + }) + } + "Secp256k1Sign" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignRequestView, + >(request.encoded()?, format)?; + svc.secp256k1_sign(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignResponse, + >(format) + }) + } + "Secp256k1Verify" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyRequestView, + >(request.encoded()?, format)?; + svc.secp256k1_verify(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyResponse, + >(format) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_server_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::buffa::bytes::Bytes, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.crypto.v1.CryptoService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &request, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } + fn call_client_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.crypto.v1.CryptoService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_bidi_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.crypto.v1.CryptoService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } +} +/// Client for this service. +/// +/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use +/// `Http2Connection` — it has honest `poll_ready` and composes with +/// `tower::balance` for multi-connection load balancing. For **Connect +/// over HTTP/1.1** (or unknown protocol), use `HttpClient`. +/// +/// # Example (gRPC / HTTP/2) +/// +/// ```rust,ignore +/// use connectrpc::client::{Http2Connection, ClientConfig}; +/// use connectrpc::Protocol; +/// +/// let uri: http::Uri = "http://localhost:8080".parse()?; +/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024); +/// let config = ClientConfig::new(uri).with_protocol(Protocol::Grpc); +/// +/// let client = CryptoServiceClient::new(conn, config); +/// let response = client.hmac_sha512(request).await?; +/// ``` +/// +/// # Example (Connect / HTTP/1.1 or ALPN) +/// +/// ```rust,ignore +/// use connectrpc::client::{HttpClient, ClientConfig}; +/// +/// let http = HttpClient::plaintext(); // cleartext http:// only +/// let config = ClientConfig::new("http://localhost:8080".parse()?); +/// +/// let client = CryptoServiceClient::new(http, config); +/// let response = client.hmac_sha512(request).await?; +/// ``` +/// +/// # Working with the response +/// +/// Unary calls return [`UnaryResponse>`](::connectrpc::client::UnaryResponse). +/// The `OwnedView` derefs to the view, so field access is zero-copy: +/// +/// ```rust,ignore +/// let resp = client.hmac_sha512(request).await?.into_view(); +/// let name: &str = resp.name; // borrow into the response buffer +/// ``` +/// +/// If you need the owned struct (e.g. to store or pass by value), use +/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned): +/// +/// ```rust,ignore +/// let owned = client.hmac_sha512(request).await?.into_owned(); +/// ``` +#[derive(Clone)] +pub struct CryptoServiceClient { + transport: T, + config: ::connectrpc::client::ClientConfig, +} +impl CryptoServiceClient +where + T: ::connectrpc::client::ClientTransport, + ::Error: ::std::fmt::Display, +{ + /// Create a new client with the given transport and configuration. + pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self { + Self { transport, config } + } + /// Get the client configuration. + pub fn config(&self) -> &::connectrpc::client::ClientConfig { + &self.config + } + /// Get a mutable reference to the client configuration. + pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig { + &mut self.config + } + /// Call the HmacSha512 RPC. Sends a request to /cusf.crypto.v1.CryptoService/HmacSha512. + pub async fn hmac_sha512( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Request, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512ResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.hmac_sha512_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the HmacSha512 RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn hmac_sha512_with_options( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::HmacSha512Request, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::HmacSha512ResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + CRYPTO_SERVICE_SERVICE_NAME, + "HmacSha512", + request, + options, + ) + .await + } + /// Call the Ripemd160 RPC. Sends a request to /cusf.crypto.v1.CryptoService/Ripemd160. + pub async fn ripemd160( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Request, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160ResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.ripemd160_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the Ripemd160 RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn ripemd160_with_options( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Ripemd160Request, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Ripemd160ResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + CRYPTO_SERVICE_SERVICE_NAME, + "Ripemd160", + request, + options, + ) + .await + } + /// Call the Secp256k1SecretKeyToPublicKey RPC. Sends a request to /cusf.crypto.v1.CryptoService/Secp256k1SecretKeyToPublicKey. + pub async fn secp256k1_secret_key_to_public_key( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.secp256k1_secret_key_to_public_key_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the Secp256k1SecretKeyToPublicKey RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn secp256k1_secret_key_to_public_key_with_options( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SecretKeyToPublicKeyRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SecretKeyToPublicKeyResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1SecretKeyToPublicKey", + request, + options, + ) + .await + } + /// Call the Secp256k1Sign RPC. Sends a request to /cusf.crypto.v1.CryptoService/Secp256k1Sign. + pub async fn secp256k1_sign( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.secp256k1_sign_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the Secp256k1Sign RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn secp256k1_sign_with_options( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1SignRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1SignResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1Sign", + request, + options, + ) + .await + } + /// Call the Secp256k1Verify RPC. Sends a request to /cusf.crypto.v1.CryptoService/Secp256k1Verify. + pub async fn secp256k1_verify( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.secp256k1_verify_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the Secp256k1Verify RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn secp256k1_verify_with_options( + &self, + request: crate::proto::generated::buffa::cusf::crypto::v1::Secp256k1VerifyRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::crypto::v1::__buffa::view::Secp256k1VerifyResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + CRYPTO_SERVICE_SERVICE_NAME, + "Secp256k1Verify", + request, + options, + ) + .await + } +} diff --git a/lib/proto/generated/connect/cusf.mainchain.v1.rs b/lib/proto/generated/connect/cusf.mainchain.v1.rs new file mode 100644 index 00000000..00e7aed3 --- /dev/null +++ b/lib/proto/generated/connect/cusf.mainchain.v1.rs @@ -0,0 +1,4422 @@ +// @generated by connectrpc-codegen. DO NOT EDIT. + +///Shorthand for `OwnedView>`. +pub type OwnedGetBlockHeaderInfoRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBlockHeaderInfoResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBlockInfoRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBlockInfoResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBmmHStarCommitmentRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBmmHStarCommitmentResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetChainInfoRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetChainInfoResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetChainTipRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetChainTipResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetCoinbasePsbtRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetCoinbasePsbtResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetCtipRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetCtipResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetSidechainProposalsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetSidechainProposalsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetSidechainsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetSidechainsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetTwoWayPegDataRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetTwoWayPegDataResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeEventsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeEventsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeHeaderSyncProgressRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeHeaderSyncProgressResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedStopRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedStopResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopResponseView< + 'static, + >, +>; +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::StopResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::StopResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +/// Full service name for this service. +pub const VALIDATOR_SERVICE_SERVICE_NAME: &str = "cusf.mainchain.v1.ValidatorService"; +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetBlockHeaderInfo` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_BLOCK_HEADER_INFO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetBlockHeaderInfo", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetBlockInfo` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_BLOCK_INFO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetBlockInfo", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetBmmHStarCommitment` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_BMM_H_STAR_COMMITMENT_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetBmmHStarCommitment", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetChainInfo` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_CHAIN_INFO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetChainInfo", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetChainTip` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_CHAIN_TIP_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetChainTip", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetCoinbasePSBT` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_COINBASE_PSBT_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetCoinbasePSBT", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetCtip` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_CTIP_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetCtip", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetSidechainProposals` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_SIDECHAIN_PROPOSALS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetSidechainProposals", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetSidechains` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_SIDECHAINS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetSidechains", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetTwoWayPegData` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_GET_TWO_WAY_PEG_DATA_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/GetTwoWayPegData", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `SubscribeEvents` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_SUBSCRIBE_EVENTS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/SubscribeEvents", + ::connectrpc::StreamType::ServerStream, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `SubscribeHeaderSyncProgress` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_SUBSCRIBE_HEADER_SYNC_PROGRESS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/SubscribeHeaderSyncProgress", + ::connectrpc::StreamType::ServerStream, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `Stop` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const VALIDATOR_SERVICE_STOP_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.ValidatorService/Stop", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Idempotent); +/// Server trait for ValidatorService. +/// +/// # Implementing handlers +/// +/// Handlers receive requests as `OwnedFooView` (an alias for +/// `OwnedView>`), which gives zero-copy borrowed access +/// to fields (e.g. `request.name` is a `&str` into the decoded buffer). +/// The view can be held across `.await` points. When two RPC types in +/// the same package would alias to the same `Owned<…>View` name (e.g. +/// a local message plus an imported one with the same short name), the +/// alias is suppressed for both and the request type is spelled as +/// `OwnedView<…View<'static>>` directly in the trait signature. +/// +/// Implement methods with plain `async fn`; the returned future satisfies +/// the `Send` bound automatically. See the +/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations) +/// for zero-copy access patterns and when `to_owned_message()` is needed. +/// +/// The `impl Encodable` return bound accepts the owned `Out`, the +/// generated `OutView<'_>` / `OwnedOutView`, +/// [`MaybeBorrowed`](::connectrpc::MaybeBorrowed), or +/// [`PreEncoded`](::connectrpc::PreEncoded) for handlers that encode a +/// non-`'static` view internally and pass the bytes across the handler +/// boundary. View bodies are not emitted for output types mapped via +/// `extern_path` (the impl would be an orphan); return owned for +/// WKT/extern outputs. +/// +/// Server-streaming and bidi-streaming methods return +/// `ServiceStream + Send + use>`. The +/// `use` precise-capturing clause excludes `&self`'s lifetime +/// (unary methods use `use<'a, Self>` and may borrow), so stream items +/// must be `'static`. To stream view-encoded data, encode each item +/// inside the stream body and yield +/// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming +/// example` doc. +#[allow(clippy::type_complexity)] +pub trait ValidatorService: Send + Sync + 'static { + /// Fetches information about a specific mainchain block header, + /// and optionally, it's ancestors + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_block_header_info<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetBlockHeaderInfoRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Fetches information about a specific mainchain block (and optionally, + /// it's ancestors), regarding how it pertains to events happening on a + /// specific sidechain. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_block_info<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetBlockInfoRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Fetches BMM h* commitment for a specific mainchain block, + /// and optionally, it's ancestors + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_bmm_h_star_commitment<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetBmmHStarCommitmentRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetChainInfo RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_chain_info<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetChainInfoRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetChainTip RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_chain_tip<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetChainTipRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetCoinbasePSBT RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_coinbase_psbt<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetCoinbasePsbtRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetCtip RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_ctip<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetCtipRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetSidechainProposals RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_sidechain_proposals<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetSidechainProposalsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetSidechains RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_sidechains<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetSidechainsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetTwoWayPegData RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_two_way_peg_data<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetTwoWayPegDataRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the SubscribeEvents RPC. + fn subscribe_events( + &self, + ctx: ::connectrpc::RequestContext, + request: OwnedSubscribeEventsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + ::connectrpc::ServiceStream< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsResponse, + > + Send + use, + >, + >, + > + Send; + /// Stream header sync progress updates + fn subscribe_header_sync_progress( + &self, + ctx: ::connectrpc::RequestContext, + request: OwnedSubscribeHeaderSyncProgressRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + ::connectrpc::ServiceStream< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressResponse, + > + Send + use, + >, + >, + > + Send; + /// Safely shutdown the validator. This is equivalent to sending a SIGINT + /// to the validator process, and can be used to trigger a graceful shutdown + /// in cases where you don't have access to the validator process. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn stop<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedStopRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::StopResponse, + > + Send + use<'a, Self>, + >, + > + Send; +} +/// Extension trait for registering a service implementation with a Router. +/// +/// This trait is automatically implemented for all types that implement the service trait. +/// +/// # Example +/// +/// ```rust,ignore +/// use std::sync::Arc; +/// +/// let service = Arc::new(MyServiceImpl); +/// let router = service.register(Router::new()); +/// ``` +pub trait ValidatorServiceExt: ValidatorService { + /// Register this service implementation with a Router. + /// + /// Takes ownership of the `Arc` and returns a new Router with + /// this service's methods registered. + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router; +} +impl ValidatorServiceExt for S { + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router { + router + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBlockHeaderInfo", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_block_header_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_BLOCK_HEADER_INFO_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBlockInfo", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_block_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_BLOCK_INFO_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBmmHStarCommitment", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_bmm_h_star_commitment(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_BMM_H_STAR_COMMITMENT_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetChainInfo", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_chain_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_CHAIN_INFO_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetChainTip", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_chain_tip(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_CHAIN_TIP_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetCoinbasePSBT", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_coinbase_psbt(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_COINBASE_PSBT_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetCtip", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_ctip(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_CTIP_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetSidechainProposals", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_sidechain_proposals(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_SIDECHAIN_PROPOSALS_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetSidechains", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_sidechains(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_SIDECHAINS_SPEC) + .route_view_idempotent( + VALIDATOR_SERVICE_SERVICE_NAME, + "GetTwoWayPegData", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_two_way_peg_data(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_GET_TWO_WAY_PEG_DATA_SPEC) + .route_view_server_stream::< + _, + _, + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsResponse, + >( + VALIDATOR_SERVICE_SERVICE_NAME, + "SubscribeEvents", + ::connectrpc::view_streaming_handler_fn({ + let svc = ::std::sync::Arc::clone(&self); + move |ctx, req| { + let svc = ::std::sync::Arc::clone(&svc); + async move { svc.subscribe_events(ctx, req).await } + } + }), + ) + .with_spec(VALIDATOR_SERVICE_SUBSCRIBE_EVENTS_SPEC) + .route_view_server_stream::< + _, + _, + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressResponse, + >( + VALIDATOR_SERVICE_SERVICE_NAME, + "SubscribeHeaderSyncProgress", + ::connectrpc::view_streaming_handler_fn({ + let svc = ::std::sync::Arc::clone(&self); + move |ctx, req| { + let svc = ::std::sync::Arc::clone(&svc); + async move { svc.subscribe_header_sync_progress(ctx, req).await } + } + }), + ) + .with_spec(VALIDATOR_SERVICE_SUBSCRIBE_HEADER_SYNC_PROGRESS_SPEC) + .route_view( + VALIDATOR_SERVICE_SERVICE_NAME, + "Stop", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.stop(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::StopResponse, + >(format) + } + }) + }, + ) + .with_spec(VALIDATOR_SERVICE_STOP_SPEC) + } +} +/// Monomorphic dispatcher for `ValidatorService`. +/// +/// Unlike `.register(Router)` which type-erases each method into an `Arc` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup. +/// +/// # Example +/// +/// ```rust,ignore +/// use connectrpc::ConnectRpcService; +/// +/// let server = ValidatorServiceServer::new(MyImpl); +/// let service = ConnectRpcService::new(server); +/// // hand `service` to axum/hyper as a fallback_service +/// ``` +pub struct ValidatorServiceServer { + inner: ::std::sync::Arc, +} +impl ValidatorServiceServer { + /// Wrap a service implementation in a monomorphic dispatcher. + pub fn new(service: T) -> Self { + Self { + inner: ::std::sync::Arc::new(service), + } + } + /// Wrap an already-`Arc`'d service implementation. + pub fn from_arc(inner: ::std::sync::Arc) -> Self { + Self { inner } + } +} +impl Clone for ValidatorServiceServer { + fn clone(&self) -> Self { + Self { + inner: ::std::sync::Arc::clone(&self.inner), + } + } +} +impl ::connectrpc::Dispatcher for ValidatorServiceServer { + #[inline] + fn lookup( + &self, + path: &str, + ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + let method = path.strip_prefix("cusf.mainchain.v1.ValidatorService/")?; + match method { + "GetBlockHeaderInfo" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_BLOCK_HEADER_INFO_SPEC), + ) + } + "GetBlockInfo" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_BLOCK_INFO_SPEC), + ) + } + "GetBmmHStarCommitment" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_BMM_H_STAR_COMMITMENT_SPEC), + ) + } + "GetChainInfo" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_CHAIN_INFO_SPEC), + ) + } + "GetChainTip" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_CHAIN_TIP_SPEC), + ) + } + "GetCoinbasePSBT" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_COINBASE_PSBT_SPEC), + ) + } + "GetCtip" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_CTIP_SPEC), + ) + } + "GetSidechainProposals" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_SIDECHAIN_PROPOSALS_SPEC), + ) + } + "GetSidechains" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_SIDECHAINS_SPEC), + ) + } + "GetTwoWayPegData" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(VALIDATOR_SERVICE_GET_TWO_WAY_PEG_DATA_SPEC), + ) + } + "SubscribeEvents" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() + .with_spec(VALIDATOR_SERVICE_SUBSCRIBE_EVENTS_SPEC), + ) + } + "SubscribeHeaderSyncProgress" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() + .with_spec(VALIDATOR_SERVICE_SUBSCRIBE_HEADER_SYNC_PROGRESS_SPEC), + ) + } + "Stop" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(VALIDATOR_SERVICE_STOP_SPEC), + ) + } + _ => None, + } + } + fn call_unary( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::connectrpc::Payload, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.ValidatorService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &request, &format); + match method { + "GetBlockHeaderInfo" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoRequestView, + >(request.encoded()?, format)?; + svc.get_block_header_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoResponse, + >(format) + }) + } + "GetBlockInfo" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoRequestView, + >(request.encoded()?, format)?; + svc.get_block_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoResponse, + >(format) + }) + } + "GetBmmHStarCommitment" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentRequestView, + >(request.encoded()?, format)?; + svc.get_bmm_h_star_commitment(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentResponse, + >(format) + }) + } + "GetChainInfo" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoRequestView, + >(request.encoded()?, format)?; + svc.get_chain_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoResponse, + >(format) + }) + } + "GetChainTip" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipRequestView, + >(request.encoded()?, format)?; + svc.get_chain_tip(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipResponse, + >(format) + }) + } + "GetCoinbasePSBT" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTRequestView, + >(request.encoded()?, format)?; + svc.get_coinbase_psbt(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTResponse, + >(format) + }) + } + "GetCtip" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipRequestView, + >(request.encoded()?, format)?; + svc.get_ctip(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipResponse, + >(format) + }) + } + "GetSidechainProposals" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsRequestView, + >(request.encoded()?, format)?; + svc.get_sidechain_proposals(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsResponse, + >(format) + }) + } + "GetSidechains" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsRequestView, + >(request.encoded()?, format)?; + svc.get_sidechains(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsResponse, + >(format) + }) + } + "GetTwoWayPegData" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataRequestView, + >(request.encoded()?, format)?; + svc.get_two_way_peg_data(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataResponse, + >(format) + }) + } + "Stop" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopRequestView, + >(request.encoded()?, format)?; + svc.stop(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::StopResponse, + >(format) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_server_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::buffa::bytes::Bytes, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.ValidatorService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &request, &format); + match method { + "SubscribeEvents" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsRequestView, + >(request, format)?; + let resp = svc.subscribe_events(ctx, req).await?; + Ok( + resp + .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsResponse, + _, + _, + >(s, format)), + ) + }) + } + "SubscribeHeaderSyncProgress" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressRequestView, + >(request, format)?; + let resp = svc.subscribe_header_sync_progress(ctx, req).await?; + Ok( + resp + .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< + crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressResponse, + _, + _, + >(s, format)), + ) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } + fn call_client_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.ValidatorService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_bidi_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.ValidatorService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } +} +/// Client for this service. +/// +/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use +/// `Http2Connection` — it has honest `poll_ready` and composes with +/// `tower::balance` for multi-connection load balancing. For **Connect +/// over HTTP/1.1** (or unknown protocol), use `HttpClient`. +/// +/// # Example (gRPC / HTTP/2) +/// +/// ```rust,ignore +/// use connectrpc::client::{Http2Connection, ClientConfig}; +/// use connectrpc::Protocol; +/// +/// let uri: http::Uri = "http://localhost:8080".parse()?; +/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024); +/// let config = ClientConfig::new(uri).with_protocol(Protocol::Grpc); +/// +/// let client = ValidatorServiceClient::new(conn, config); +/// let response = client.get_block_header_info(request).await?; +/// ``` +/// +/// # Example (Connect / HTTP/1.1 or ALPN) +/// +/// ```rust,ignore +/// use connectrpc::client::{HttpClient, ClientConfig}; +/// +/// let http = HttpClient::plaintext(); // cleartext http:// only +/// let config = ClientConfig::new("http://localhost:8080".parse()?); +/// +/// let client = ValidatorServiceClient::new(http, config); +/// let response = client.get_block_header_info(request).await?; +/// ``` +/// +/// # Working with the response +/// +/// Unary calls return [`UnaryResponse>`](::connectrpc::client::UnaryResponse). +/// The `OwnedView` derefs to the view, so field access is zero-copy: +/// +/// ```rust,ignore +/// let resp = client.get_block_header_info(request).await?.into_view(); +/// let name: &str = resp.name; // borrow into the response buffer +/// ``` +/// +/// If you need the owned struct (e.g. to store or pass by value), use +/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned): +/// +/// ```rust,ignore +/// let owned = client.get_block_header_info(request).await?.into_owned(); +/// ``` +#[derive(Clone)] +pub struct ValidatorServiceClient { + transport: T, + config: ::connectrpc::client::ClientConfig, +} +impl ValidatorServiceClient +where + T: ::connectrpc::client::ClientTransport, + ::Error: ::std::fmt::Display, +{ + /// Create a new client with the given transport and configuration. + pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self { + Self { transport, config } + } + /// Get the client configuration. + pub fn config(&self) -> &::connectrpc::client::ClientConfig { + &self.config + } + /// Get a mutable reference to the client configuration. + pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig { + &mut self.config + } + /// Call the GetBlockHeaderInfo RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetBlockHeaderInfo. + pub async fn get_block_header_info( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_block_header_info_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetBlockHeaderInfo RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_block_header_info_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockHeaderInfoRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockHeaderInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBlockHeaderInfo", + request, + options, + ) + .await + } + /// Call the GetBlockInfo RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetBlockInfo. + pub async fn get_block_info( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_block_info_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetBlockInfo RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_block_info_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBlockInfoRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBlockInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBlockInfo", + request, + options, + ) + .await + } + /// Call the GetBmmHStarCommitment RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetBmmHStarCommitment. + pub async fn get_bmm_h_star_commitment( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_bmm_h_star_commitment_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetBmmHStarCommitment RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_bmm_h_star_commitment_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBmmHStarCommitmentRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBmmHStarCommitmentResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetBmmHStarCommitment", + request, + options, + ) + .await + } + /// Call the GetChainInfo RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetChainInfo. + pub async fn get_chain_info( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_chain_info_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetChainInfo RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_chain_info_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetChainInfoRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetChainInfo", + request, + options, + ) + .await + } + /// Call the GetChainTip RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetChainTip. + pub async fn get_chain_tip( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_chain_tip_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetChainTip RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_chain_tip_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetChainTipRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetChainTipResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetChainTip", + request, + options, + ) + .await + } + /// Call the GetCoinbasePSBT RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetCoinbasePSBT. + pub async fn get_coinbase_psbt( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_coinbase_psbt_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetCoinbasePSBT RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_coinbase_psbt_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetCoinbasePSBTRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCoinbasePSBTResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetCoinbasePSBT", + request, + options, + ) + .await + } + /// Call the GetCtip RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetCtip. + pub async fn get_ctip( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_ctip_with_options(request, ::connectrpc::client::CallOptions::default()) + .await + } + /// Call the GetCtip RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_ctip_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetCtipRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetCtipResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetCtip", + request, + options, + ) + .await + } + /// Call the GetSidechainProposals RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetSidechainProposals. + pub async fn get_sidechain_proposals( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_sidechain_proposals_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetSidechainProposals RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_sidechain_proposals_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainProposalsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainProposalsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetSidechainProposals", + request, + options, + ) + .await + } + /// Call the GetSidechains RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetSidechains. + pub async fn get_sidechains( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_sidechains_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetSidechains RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_sidechains_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetSidechainsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetSidechainsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetSidechains", + request, + options, + ) + .await + } + /// Call the GetTwoWayPegData RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/GetTwoWayPegData. + pub async fn get_two_way_peg_data( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_two_way_peg_data_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetTwoWayPegData RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_two_way_peg_data_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetTwoWayPegDataRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetTwoWayPegDataResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "GetTwoWayPegData", + request, + options, + ) + .await + } + /// Call the SubscribeEvents RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/SubscribeEvents. + pub async fn subscribe_events( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsRequest, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + self.subscribe_events_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the SubscribeEvents RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn subscribe_events_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeEventsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_server_stream( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "SubscribeEvents", + request, + options, + ) + .await + } + /// Call the SubscribeHeaderSyncProgress RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/SubscribeHeaderSyncProgress. + pub async fn subscribe_header_sync_progress( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressRequest, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + self.subscribe_header_sync_progress_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the SubscribeHeaderSyncProgress RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn subscribe_header_sync_progress_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SubscribeHeaderSyncProgressRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SubscribeHeaderSyncProgressResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_server_stream( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "SubscribeHeaderSyncProgress", + request, + options, + ) + .await + } + /// Call the Stop RPC. Sends a request to /cusf.mainchain.v1.ValidatorService/Stop. + pub async fn stop( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::StopRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.stop_with_options(request, ::connectrpc::client::CallOptions::default()) + .await + } + /// Call the Stop RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn stop_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::StopRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::StopResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + VALIDATOR_SERVICE_SERVICE_NAME, + "Stop", + request, + options, + ) + .await + } +} + +///Shorthand for `OwnedView>`. +pub type OwnedBroadcastWithdrawalBundleRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedBroadcastWithdrawalBundleResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateBmmCriticalDataTransactionRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateBmmCriticalDataTransactionResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateDepositTransactionRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateDepositTransactionResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateNewAddressRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateNewAddressResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateSidechainProposalRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateSidechainProposalResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateWalletRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedCreateWalletResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBalanceRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetBalanceResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListSidechainDepositTransactionsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListSidechainDepositTransactionsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListTransactionsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListTransactionsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListUnspentOutputsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedListUnspentOutputsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetInfoRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetInfoResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSendTransactionRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSendTransactionResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedUnlockWalletRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedUnlockWalletResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGenerateBlocksRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGenerateBlocksResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksResponseView< + 'static, + >, +>; +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksResponse, +> +for crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +/// Full service name for this service. +pub const WALLET_SERVICE_SERVICE_NAME: &str = "cusf.mainchain.v1.WalletService"; +/// Static [`Spec`](::connectrpc::Spec) for the server-side `BroadcastWithdrawalBundle` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_BROADCAST_WITHDRAWAL_BUNDLE_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/BroadcastWithdrawalBundle", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Idempotent); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `CreateBmmCriticalDataTransaction` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_CREATE_BMM_CRITICAL_DATA_TRANSACTION_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/CreateBmmCriticalDataTransaction", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `CreateDepositTransaction` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_CREATE_DEPOSIT_TRANSACTION_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/CreateDepositTransaction", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `CreateNewAddress` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_CREATE_NEW_ADDRESS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/CreateNewAddress", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `CreateSidechainProposal` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_CREATE_SIDECHAIN_PROPOSAL_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/CreateSidechainProposal", + ::connectrpc::StreamType::ServerStream, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `CreateWallet` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_CREATE_WALLET_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/CreateWallet", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetBalance` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_GET_BALANCE_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/GetBalance", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `ListSidechainDepositTransactions` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/ListSidechainDepositTransactions", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `ListTransactions` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_LIST_TRANSACTIONS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/ListTransactions", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `ListUnspentOutputs` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_LIST_UNSPENT_OUTPUTS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/ListUnspentOutputs", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetInfo` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_GET_INFO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/GetInfo", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `SendTransaction` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_SEND_TRANSACTION_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/SendTransaction", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `UnlockWallet` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_UNLOCK_WALLET_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/UnlockWallet", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Idempotent); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GenerateBlocks` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const WALLET_SERVICE_GENERATE_BLOCKS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.mainchain.v1.WalletService/GenerateBlocks", + ::connectrpc::StreamType::ServerStream, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown); +/// Server trait for WalletService. +/// +/// # Implementing handlers +/// +/// Handlers receive requests as `OwnedFooView` (an alias for +/// `OwnedView>`), which gives zero-copy borrowed access +/// to fields (e.g. `request.name` is a `&str` into the decoded buffer). +/// The view can be held across `.await` points. When two RPC types in +/// the same package would alias to the same `Owned<…>View` name (e.g. +/// a local message plus an imported one with the same short name), the +/// alias is suppressed for both and the request type is spelled as +/// `OwnedView<…View<'static>>` directly in the trait signature. +/// +/// Implement methods with plain `async fn`; the returned future satisfies +/// the `Send` bound automatically. See the +/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations) +/// for zero-copy access patterns and when `to_owned_message()` is needed. +/// +/// The `impl Encodable` return bound accepts the owned `Out`, the +/// generated `OutView<'_>` / `OwnedOutView`, +/// [`MaybeBorrowed`](::connectrpc::MaybeBorrowed), or +/// [`PreEncoded`](::connectrpc::PreEncoded) for handlers that encode a +/// non-`'static` view internally and pass the bytes across the handler +/// boundary. View bodies are not emitted for output types mapped via +/// `extern_path` (the impl would be an orphan); return owned for +/// WKT/extern outputs. +/// +/// Server-streaming and bidi-streaming methods return +/// `ServiceStream + Send + use>`. The +/// `use` precise-capturing clause excludes `&self`'s lifetime +/// (unary methods use `use<'a, Self>` and may borrow), so stream items +/// must be `'static`. To stream view-encoded data, encode each item +/// inside the stream body and yield +/// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming +/// example` doc. +#[allow(clippy::type_complexity)] +pub trait WalletService: Send + Sync + 'static { + /// Handle the BroadcastWithdrawalBundle RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn broadcast_withdrawal_bundle<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedBroadcastWithdrawalBundleRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the CreateBmmCriticalDataTransaction RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn create_bmm_critical_data_transaction<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedCreateBmmCriticalDataTransactionRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the CreateDepositTransaction RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn create_deposit_transaction<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedCreateDepositTransactionRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the CreateNewAddress RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn create_new_address<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedCreateNewAddressRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Create a new sidechain proposal (M1 in BIP300) and persist to the local + /// database for further processing. + /// Sidechain proposals must be included in the coinbase transaction of a + /// newly mined block, so this proposal is not active until the wallet has + /// been able to generate a new block. + /// Returns a stream of (non-)confirmation events for the sidechain proposal. + fn create_sidechain_proposal( + &self, + ctx: ::connectrpc::RequestContext, + request: OwnedCreateSidechainProposalRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + ::connectrpc::ServiceStream< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalResponse, + > + Send + use, + >, + >, + > + Send; + /// Handle the CreateWallet RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn create_wallet<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedCreateWalletRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetBalance RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_balance<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetBalanceRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the ListSidechainDepositTransactions RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn list_sidechain_deposit_transactions<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedListSidechainDepositTransactionsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the ListTransactions RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn list_transactions<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedListTransactionsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the ListUnspentOutputs RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn list_unspent_outputs<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedListUnspentOutputsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetInfo RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_info<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetInfoRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the SendTransaction RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn send_transaction<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedSendTransactionRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the UnlockWallet RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn unlock_wallet<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedUnlockWalletRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Available on regtest and signet only. + fn generate_blocks( + &self, + ctx: ::connectrpc::RequestContext, + request: OwnedGenerateBlocksRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + ::connectrpc::ServiceStream< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksResponse, + > + Send + use, + >, + >, + > + Send; +} +/// Extension trait for registering a service implementation with a Router. +/// +/// This trait is automatically implemented for all types that implement the service trait. +/// +/// # Example +/// +/// ```rust,ignore +/// use std::sync::Arc; +/// +/// let service = Arc::new(MyServiceImpl); +/// let router = service.register(Router::new()); +/// ``` +pub trait WalletServiceExt: WalletService { + /// Register this service implementation with a Router. + /// + /// Takes ownership of the `Arc` and returns a new Router with + /// this service's methods registered. + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router; +} +impl WalletServiceExt for S { + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router { + router + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "BroadcastWithdrawalBundle", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.broadcast_withdrawal_bundle(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_BROADCAST_WITHDRAWAL_BUNDLE_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "CreateBmmCriticalDataTransaction", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.create_bmm_critical_data_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_CREATE_BMM_CRITICAL_DATA_TRANSACTION_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "CreateDepositTransaction", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.create_deposit_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_CREATE_DEPOSIT_TRANSACTION_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "CreateNewAddress", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.create_new_address(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_CREATE_NEW_ADDRESS_SPEC) + .route_view_server_stream::< + _, + _, + crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalResponse, + >( + WALLET_SERVICE_SERVICE_NAME, + "CreateSidechainProposal", + ::connectrpc::view_streaming_handler_fn({ + let svc = ::std::sync::Arc::clone(&self); + move |ctx, req| { + let svc = ::std::sync::Arc::clone(&svc); + async move { svc.create_sidechain_proposal(ctx, req).await } + } + }), + ) + .with_spec(WALLET_SERVICE_CREATE_SIDECHAIN_PROPOSAL_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "CreateWallet", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.create_wallet(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_CREATE_WALLET_SPEC) + .route_view_idempotent( + WALLET_SERVICE_SERVICE_NAME, + "GetBalance", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_balance(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_GET_BALANCE_SPEC) + .route_view_idempotent( + WALLET_SERVICE_SERVICE_NAME, + "ListSidechainDepositTransactions", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.list_sidechain_deposit_transactions(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_SPEC) + .route_view_idempotent( + WALLET_SERVICE_SERVICE_NAME, + "ListTransactions", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.list_transactions(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_LIST_TRANSACTIONS_SPEC) + .route_view_idempotent( + WALLET_SERVICE_SERVICE_NAME, + "ListUnspentOutputs", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.list_unspent_outputs(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_LIST_UNSPENT_OUTPUTS_SPEC) + .route_view_idempotent( + WALLET_SERVICE_SERVICE_NAME, + "GetInfo", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_GET_INFO_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "SendTransaction", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.send_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_SEND_TRANSACTION_SPEC) + .route_view( + WALLET_SERVICE_SERVICE_NAME, + "UnlockWallet", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.unlock_wallet(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletResponse, + >(format) + } + }) + }, + ) + .with_spec(WALLET_SERVICE_UNLOCK_WALLET_SPEC) + .route_view_server_stream::< + _, + _, + crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksResponse, + >( + WALLET_SERVICE_SERVICE_NAME, + "GenerateBlocks", + ::connectrpc::view_streaming_handler_fn({ + let svc = ::std::sync::Arc::clone(&self); + move |ctx, req| { + let svc = ::std::sync::Arc::clone(&svc); + async move { svc.generate_blocks(ctx, req).await } + } + }), + ) + .with_spec(WALLET_SERVICE_GENERATE_BLOCKS_SPEC) + } +} +/// Monomorphic dispatcher for `WalletService`. +/// +/// Unlike `.register(Router)` which type-erases each method into an `Arc` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup. +/// +/// # Example +/// +/// ```rust,ignore +/// use connectrpc::ConnectRpcService; +/// +/// let server = WalletServiceServer::new(MyImpl); +/// let service = ConnectRpcService::new(server); +/// // hand `service` to axum/hyper as a fallback_service +/// ``` +pub struct WalletServiceServer { + inner: ::std::sync::Arc, +} +impl WalletServiceServer { + /// Wrap a service implementation in a monomorphic dispatcher. + pub fn new(service: T) -> Self { + Self { + inner: ::std::sync::Arc::new(service), + } + } + /// Wrap an already-`Arc`'d service implementation. + pub fn from_arc(inner: ::std::sync::Arc) -> Self { + Self { inner } + } +} +impl Clone for WalletServiceServer { + fn clone(&self) -> Self { + Self { + inner: ::std::sync::Arc::clone(&self.inner), + } + } +} +impl ::connectrpc::Dispatcher for WalletServiceServer { + #[inline] + fn lookup( + &self, + path: &str, + ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + let method = path.strip_prefix("cusf.mainchain.v1.WalletService/")?; + match method { + "BroadcastWithdrawalBundle" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_BROADCAST_WITHDRAWAL_BUNDLE_SPEC), + ) + } + "CreateBmmCriticalDataTransaction" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec( + WALLET_SERVICE_CREATE_BMM_CRITICAL_DATA_TRANSACTION_SPEC, + ), + ) + } + "CreateDepositTransaction" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_CREATE_DEPOSIT_TRANSACTION_SPEC), + ) + } + "CreateNewAddress" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_CREATE_NEW_ADDRESS_SPEC), + ) + } + "CreateSidechainProposal" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() + .with_spec(WALLET_SERVICE_CREATE_SIDECHAIN_PROPOSAL_SPEC), + ) + } + "CreateWallet" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_CREATE_WALLET_SPEC), + ) + } + "GetBalance" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(WALLET_SERVICE_GET_BALANCE_SPEC), + ) + } + "ListSidechainDepositTransactions" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec( + WALLET_SERVICE_LIST_SIDECHAIN_DEPOSIT_TRANSACTIONS_SPEC, + ), + ) + } + "ListTransactions" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(WALLET_SERVICE_LIST_TRANSACTIONS_SPEC), + ) + } + "ListUnspentOutputs" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(WALLET_SERVICE_LIST_UNSPENT_OUTPUTS_SPEC), + ) + } + "GetInfo" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(WALLET_SERVICE_GET_INFO_SPEC), + ) + } + "SendTransaction" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_SEND_TRANSACTION_SPEC), + ) + } + "UnlockWallet" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(WALLET_SERVICE_UNLOCK_WALLET_SPEC), + ) + } + "GenerateBlocks" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() + .with_spec(WALLET_SERVICE_GENERATE_BLOCKS_SPEC), + ) + } + _ => None, + } + } + fn call_unary( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::connectrpc::Payload, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.WalletService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &request, &format); + match method { + "BroadcastWithdrawalBundle" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleRequestView, + >(request.encoded()?, format)?; + svc.broadcast_withdrawal_bundle(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleResponse, + >(format) + }) + } + "CreateBmmCriticalDataTransaction" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionRequestView, + >(request.encoded()?, format)?; + svc.create_bmm_critical_data_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionResponse, + >(format) + }) + } + "CreateDepositTransaction" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionRequestView, + >(request.encoded()?, format)?; + svc.create_deposit_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionResponse, + >(format) + }) + } + "CreateNewAddress" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressRequestView, + >(request.encoded()?, format)?; + svc.create_new_address(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressResponse, + >(format) + }) + } + "CreateWallet" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletRequestView, + >(request.encoded()?, format)?; + svc.create_wallet(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletResponse, + >(format) + }) + } + "GetBalance" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceRequestView, + >(request.encoded()?, format)?; + svc.get_balance(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceResponse, + >(format) + }) + } + "ListSidechainDepositTransactions" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsRequestView, + >(request.encoded()?, format)?; + svc.list_sidechain_deposit_transactions(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsResponse, + >(format) + }) + } + "ListTransactions" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsRequestView, + >(request.encoded()?, format)?; + svc.list_transactions(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsResponse, + >(format) + }) + } + "ListUnspentOutputs" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsRequestView, + >(request.encoded()?, format)?; + svc.list_unspent_outputs(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsResponse, + >(format) + }) + } + "GetInfo" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoRequestView, + >(request.encoded()?, format)?; + svc.get_info(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoResponse, + >(format) + }) + } + "SendTransaction" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionRequestView, + >(request.encoded()?, format)?; + svc.send_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionResponse, + >(format) + }) + } + "UnlockWallet" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletRequestView, + >(request.encoded()?, format)?; + svc.unlock_wallet(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletResponse, + >(format) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_server_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::buffa::bytes::Bytes, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.WalletService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &request, &format); + match method { + "CreateSidechainProposal" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalRequestView, + >(request, format)?; + let resp = svc.create_sidechain_proposal(ctx, req).await?; + Ok( + resp + .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< + crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalResponse, + _, + _, + >(s, format)), + ) + }) + } + "GenerateBlocks" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksRequestView, + >(request, format)?; + let resp = svc.generate_blocks(ctx, req).await?; + Ok( + resp + .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< + crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksResponse, + _, + _, + >(s, format)), + ) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } + fn call_client_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.WalletService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_bidi_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.mainchain.v1.WalletService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } +} +/// Client for this service. +/// +/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use +/// `Http2Connection` — it has honest `poll_ready` and composes with +/// `tower::balance` for multi-connection load balancing. For **Connect +/// over HTTP/1.1** (or unknown protocol), use `HttpClient`. +/// +/// # Example (gRPC / HTTP/2) +/// +/// ```rust,ignore +/// use connectrpc::client::{Http2Connection, ClientConfig}; +/// use connectrpc::Protocol; +/// +/// let uri: http::Uri = "http://localhost:8080".parse()?; +/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024); +/// let config = ClientConfig::new(uri).with_protocol(Protocol::Grpc); +/// +/// let client = WalletServiceClient::new(conn, config); +/// let response = client.broadcast_withdrawal_bundle(request).await?; +/// ``` +/// +/// # Example (Connect / HTTP/1.1 or ALPN) +/// +/// ```rust,ignore +/// use connectrpc::client::{HttpClient, ClientConfig}; +/// +/// let http = HttpClient::plaintext(); // cleartext http:// only +/// let config = ClientConfig::new("http://localhost:8080".parse()?); +/// +/// let client = WalletServiceClient::new(http, config); +/// let response = client.broadcast_withdrawal_bundle(request).await?; +/// ``` +/// +/// # Working with the response +/// +/// Unary calls return [`UnaryResponse>`](::connectrpc::client::UnaryResponse). +/// The `OwnedView` derefs to the view, so field access is zero-copy: +/// +/// ```rust,ignore +/// let resp = client.broadcast_withdrawal_bundle(request).await?.into_view(); +/// let name: &str = resp.name; // borrow into the response buffer +/// ``` +/// +/// If you need the owned struct (e.g. to store or pass by value), use +/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned): +/// +/// ```rust,ignore +/// let owned = client.broadcast_withdrawal_bundle(request).await?.into_owned(); +/// ``` +#[derive(Clone)] +pub struct WalletServiceClient { + transport: T, + config: ::connectrpc::client::ClientConfig, +} +impl WalletServiceClient +where + T: ::connectrpc::client::ClientTransport, + ::Error: ::std::fmt::Display, +{ + /// Create a new client with the given transport and configuration. + pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self { + Self { transport, config } + } + /// Get the client configuration. + pub fn config(&self) -> &::connectrpc::client::ClientConfig { + &self.config + } + /// Get a mutable reference to the client configuration. + pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig { + &mut self.config + } + /// Call the BroadcastWithdrawalBundle RPC. Sends a request to /cusf.mainchain.v1.WalletService/BroadcastWithdrawalBundle. + pub async fn broadcast_withdrawal_bundle( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.broadcast_withdrawal_bundle_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the BroadcastWithdrawalBundle RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn broadcast_withdrawal_bundle_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::BroadcastWithdrawalBundleRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::BroadcastWithdrawalBundleResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "BroadcastWithdrawalBundle", + request, + options, + ) + .await + } + /// Call the CreateBmmCriticalDataTransaction RPC. Sends a request to /cusf.mainchain.v1.WalletService/CreateBmmCriticalDataTransaction. + pub async fn create_bmm_critical_data_transaction( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.create_bmm_critical_data_transaction_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the CreateBmmCriticalDataTransaction RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn create_bmm_critical_data_transaction_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateBmmCriticalDataTransactionRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateBmmCriticalDataTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "CreateBmmCriticalDataTransaction", + request, + options, + ) + .await + } + /// Call the CreateDepositTransaction RPC. Sends a request to /cusf.mainchain.v1.WalletService/CreateDepositTransaction. + pub async fn create_deposit_transaction( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.create_deposit_transaction_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the CreateDepositTransaction RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn create_deposit_transaction_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateDepositTransactionRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateDepositTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "CreateDepositTransaction", + request, + options, + ) + .await + } + /// Call the CreateNewAddress RPC. Sends a request to /cusf.mainchain.v1.WalletService/CreateNewAddress. + pub async fn create_new_address( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.create_new_address_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the CreateNewAddress RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn create_new_address_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateNewAddressRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateNewAddressResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "CreateNewAddress", + request, + options, + ) + .await + } + /// Call the CreateSidechainProposal RPC. Sends a request to /cusf.mainchain.v1.WalletService/CreateSidechainProposal. + pub async fn create_sidechain_proposal( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalRequest, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + self.create_sidechain_proposal_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the CreateSidechainProposal RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn create_sidechain_proposal_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateSidechainProposalRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateSidechainProposalResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_server_stream( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "CreateSidechainProposal", + request, + options, + ) + .await + } + /// Call the CreateWallet RPC. Sends a request to /cusf.mainchain.v1.WalletService/CreateWallet. + pub async fn create_wallet( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.create_wallet_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the CreateWallet RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn create_wallet_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::CreateWalletRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::CreateWalletResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "CreateWallet", + request, + options, + ) + .await + } + /// Call the GetBalance RPC. Sends a request to /cusf.mainchain.v1.WalletService/GetBalance. + pub async fn get_balance( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_balance_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetBalance RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_balance_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetBalanceRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetBalanceResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "GetBalance", + request, + options, + ) + .await + } + /// Call the ListSidechainDepositTransactions RPC. Sends a request to /cusf.mainchain.v1.WalletService/ListSidechainDepositTransactions. + pub async fn list_sidechain_deposit_transactions( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.list_sidechain_deposit_transactions_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the ListSidechainDepositTransactions RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn list_sidechain_deposit_transactions_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListSidechainDepositTransactionsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListSidechainDepositTransactionsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "ListSidechainDepositTransactions", + request, + options, + ) + .await + } + /// Call the ListTransactions RPC. Sends a request to /cusf.mainchain.v1.WalletService/ListTransactions. + pub async fn list_transactions( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.list_transactions_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the ListTransactions RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn list_transactions_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListTransactionsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListTransactionsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "ListTransactions", + request, + options, + ) + .await + } + /// Call the ListUnspentOutputs RPC. Sends a request to /cusf.mainchain.v1.WalletService/ListUnspentOutputs. + pub async fn list_unspent_outputs( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.list_unspent_outputs_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the ListUnspentOutputs RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn list_unspent_outputs_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::ListUnspentOutputsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::ListUnspentOutputsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "ListUnspentOutputs", + request, + options, + ) + .await + } + /// Call the GetInfo RPC. Sends a request to /cusf.mainchain.v1.WalletService/GetInfo. + pub async fn get_info( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_info_with_options(request, ::connectrpc::client::CallOptions::default()) + .await + } + /// Call the GetInfo RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_info_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GetInfoRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GetInfoResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "GetInfo", + request, + options, + ) + .await + } + /// Call the SendTransaction RPC. Sends a request to /cusf.mainchain.v1.WalletService/SendTransaction. + pub async fn send_transaction( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.send_transaction_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the SendTransaction RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn send_transaction_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::SendTransactionRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::SendTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "SendTransaction", + request, + options, + ) + .await + } + /// Call the UnlockWallet RPC. Sends a request to /cusf.mainchain.v1.WalletService/UnlockWallet. + pub async fn unlock_wallet( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.unlock_wallet_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the UnlockWallet RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn unlock_wallet_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::UnlockWalletRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::UnlockWalletResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "UnlockWallet", + request, + options, + ) + .await + } + /// Call the GenerateBlocks RPC. Sends a request to /cusf.mainchain.v1.WalletService/GenerateBlocks. + pub async fn generate_blocks( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksRequest, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + self.generate_blocks_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GenerateBlocks RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn generate_blocks_with_options( + &self, + request: crate::proto::generated::buffa::cusf::mainchain::v1::GenerateBlocksRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::mainchain::v1::__buffa::view::GenerateBlocksResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_server_stream( + &self.transport, + &self.config, + WALLET_SERVICE_SERVICE_NAME, + "GenerateBlocks", + request, + options, + ) + .await + } +} diff --git a/lib/proto/generated/connect/cusf.sidechain.v1.rs b/lib/proto/generated/connect/cusf.sidechain.v1.rs new file mode 100644 index 00000000..b9e60596 --- /dev/null +++ b/lib/proto/generated/connect/cusf.sidechain.v1.rs @@ -0,0 +1,831 @@ +// @generated by connectrpc-codegen. DO NOT EDIT. + +///Shorthand for `OwnedView>`. +pub type OwnedGetMempoolTxsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetMempoolTxsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetUtxosRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedGetUtxosResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubmitTransactionRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubmitTransactionResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionResponseView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeEventsRequestView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsRequestView< + 'static, + >, +>; +///Shorthand for `OwnedView>`. +pub type OwnedSubscribeEventsResponseView = ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, +>; +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsResponse, +> +for crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosResponse, +> +for crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionResponse, +> +for crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsResponse, +> +for crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsResponseView< + '_, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(self, codec) + } +} +impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsResponse, +> +for ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, +> { + fn encode( + &self, + codec: ::connectrpc::CodecFormat, + ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> { + ::connectrpc::__codegen::encode_view_body(&**self, codec) + } +} +/// Full service name for this service. +pub const SIDECHAIN_SERVICE_SERVICE_NAME: &str = "cusf.sidechain.v1.SidechainService"; +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetMempoolTxs` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const SIDECHAIN_SERVICE_GET_MEMPOOL_TXS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.sidechain.v1.SidechainService/GetMempoolTxs", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetUtxos` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const SIDECHAIN_SERVICE_GET_UTXOS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.sidechain.v1.SidechainService/GetUtxos", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `SubmitTransaction` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const SIDECHAIN_SERVICE_SUBMIT_TRANSACTION_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.sidechain.v1.SidechainService/SubmitTransaction", + ::connectrpc::StreamType::Unary, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::Idempotent); +/// Static [`Spec`](::connectrpc::Spec) for the server-side `SubscribeEvents` RPC. +/// +/// The dispatcher surfaces this on +/// [`RequestContext::spec`](::connectrpc::RequestContext::spec). +pub const SIDECHAIN_SERVICE_SUBSCRIBE_EVENTS_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( + "/cusf.sidechain.v1.SidechainService/SubscribeEvents", + ::connectrpc::StreamType::ServerStream, + ) + .with_idempotency_level(::connectrpc::IdempotencyLevel::NoSideEffects); +/// Server trait for SidechainService. +/// +/// # Implementing handlers +/// +/// Handlers receive requests as `OwnedFooView` (an alias for +/// `OwnedView>`), which gives zero-copy borrowed access +/// to fields (e.g. `request.name` is a `&str` into the decoded buffer). +/// The view can be held across `.await` points. When two RPC types in +/// the same package would alias to the same `Owned<…>View` name (e.g. +/// a local message plus an imported one with the same short name), the +/// alias is suppressed for both and the request type is spelled as +/// `OwnedView<…View<'static>>` directly in the trait signature. +/// +/// Implement methods with plain `async fn`; the returned future satisfies +/// the `Send` bound automatically. See the +/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations) +/// for zero-copy access patterns and when `to_owned_message()` is needed. +/// +/// The `impl Encodable` return bound accepts the owned `Out`, the +/// generated `OutView<'_>` / `OwnedOutView`, +/// [`MaybeBorrowed`](::connectrpc::MaybeBorrowed), or +/// [`PreEncoded`](::connectrpc::PreEncoded) for handlers that encode a +/// non-`'static` view internally and pass the bytes across the handler +/// boundary. View bodies are not emitted for output types mapped via +/// `extern_path` (the impl would be an orphan); return owned for +/// WKT/extern outputs. +/// +/// Server-streaming and bidi-streaming methods return +/// `ServiceStream + Send + use>`. The +/// `use` precise-capturing clause excludes `&self`'s lifetime +/// (unary methods use `use<'a, Self>` and may borrow), so stream items +/// must be `'static`. To stream view-encoded data, encode each item +/// inside the stream body and yield +/// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming +/// example` doc. +#[allow(clippy::type_complexity)] +pub trait SidechainService: Send + Sync + 'static { + /// Handle the GetMempoolTxs RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_mempool_txs<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetMempoolTxsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the GetUtxos RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn get_utxos<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedGetUtxosRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the SubmitTransaction RPC. + /// + /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). + fn submit_transaction<'a>( + &'a self, + ctx: ::connectrpc::RequestContext, + request: OwnedSubmitTransactionRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionResponse, + > + Send + use<'a, Self>, + >, + > + Send; + /// Handle the SubscribeEvents RPC. + fn subscribe_events( + &self, + ctx: ::connectrpc::RequestContext, + request: OwnedSubscribeEventsRequestView, + ) -> impl ::std::future::Future< + Output = ::connectrpc::ServiceResult< + ::connectrpc::ServiceStream< + impl ::connectrpc::Encodable< + crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsResponse, + > + Send + use, + >, + >, + > + Send; +} +/// Extension trait for registering a service implementation with a Router. +/// +/// This trait is automatically implemented for all types that implement the service trait. +/// +/// # Example +/// +/// ```rust,ignore +/// use std::sync::Arc; +/// +/// let service = Arc::new(MyServiceImpl); +/// let router = service.register(Router::new()); +/// ``` +pub trait SidechainServiceExt: SidechainService { + /// Register this service implementation with a Router. + /// + /// Takes ownership of the `Arc` and returns a new Router with + /// this service's methods registered. + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router; +} +impl SidechainServiceExt for S { + fn register( + self: ::std::sync::Arc, + router: ::connectrpc::Router, + ) -> ::connectrpc::Router { + router + .route_view_idempotent( + SIDECHAIN_SERVICE_SERVICE_NAME, + "GetMempoolTxs", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_mempool_txs(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsResponse, + >(format) + } + }) + }, + ) + .with_spec(SIDECHAIN_SERVICE_GET_MEMPOOL_TXS_SPEC) + .route_view_idempotent( + SIDECHAIN_SERVICE_SERVICE_NAME, + "GetUtxos", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.get_utxos(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosResponse, + >(format) + } + }) + }, + ) + .with_spec(SIDECHAIN_SERVICE_GET_UTXOS_SPEC) + .route_view( + SIDECHAIN_SERVICE_SERVICE_NAME, + "SubmitTransaction", + { + let svc = ::std::sync::Arc::clone(&self); + ::connectrpc::view_handler_fn(move |ctx, req, format| { + let svc = ::std::sync::Arc::clone(&svc); + async move { + svc.submit_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionResponse, + >(format) + } + }) + }, + ) + .with_spec(SIDECHAIN_SERVICE_SUBMIT_TRANSACTION_SPEC) + .route_view_server_stream::< + _, + _, + crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsResponse, + >( + SIDECHAIN_SERVICE_SERVICE_NAME, + "SubscribeEvents", + ::connectrpc::view_streaming_handler_fn({ + let svc = ::std::sync::Arc::clone(&self); + move |ctx, req| { + let svc = ::std::sync::Arc::clone(&svc); + async move { svc.subscribe_events(ctx, req).await } + } + }), + ) + .with_spec(SIDECHAIN_SERVICE_SUBSCRIBE_EVENTS_SPEC) + } +} +/// Monomorphic dispatcher for `SidechainService`. +/// +/// Unlike `.register(Router)` which type-erases each method into an `Arc` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup. +/// +/// # Example +/// +/// ```rust,ignore +/// use connectrpc::ConnectRpcService; +/// +/// let server = SidechainServiceServer::new(MyImpl); +/// let service = ConnectRpcService::new(server); +/// // hand `service` to axum/hyper as a fallback_service +/// ``` +pub struct SidechainServiceServer { + inner: ::std::sync::Arc, +} +impl SidechainServiceServer { + /// Wrap a service implementation in a monomorphic dispatcher. + pub fn new(service: T) -> Self { + Self { + inner: ::std::sync::Arc::new(service), + } + } + /// Wrap an already-`Arc`'d service implementation. + pub fn from_arc(inner: ::std::sync::Arc) -> Self { + Self { inner } + } +} +impl Clone for SidechainServiceServer { + fn clone(&self) -> Self { + Self { + inner: ::std::sync::Arc::clone(&self.inner), + } + } +} +impl ::connectrpc::Dispatcher for SidechainServiceServer { + #[inline] + fn lookup( + &self, + path: &str, + ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + let method = path.strip_prefix("cusf.sidechain.v1.SidechainService/")?; + match method { + "GetMempoolTxs" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(SIDECHAIN_SERVICE_GET_MEMPOOL_TXS_SPEC), + ) + } + "GetUtxos" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) + .with_spec(SIDECHAIN_SERVICE_GET_UTXOS_SPEC), + ) + } + "SubmitTransaction" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) + .with_spec(SIDECHAIN_SERVICE_SUBMIT_TRANSACTION_SPEC), + ) + } + "SubscribeEvents" => { + Some( + ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() + .with_spec(SIDECHAIN_SERVICE_SUBSCRIBE_EVENTS_SPEC), + ) + } + _ => None, + } + } + fn call_unary( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::connectrpc::Payload, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.sidechain.v1.SidechainService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &request, &format); + match method { + "GetMempoolTxs" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsRequestView, + >(request.encoded()?, format)?; + svc.get_mempool_txs(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsResponse, + >(format) + }) + } + "GetUtxos" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosRequestView, + >(request.encoded()?, format)?; + svc.get_utxos(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosResponse, + >(format) + }) + } + "SubmitTransaction" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionRequestView, + >(request.encoded()?, format)?; + svc.submit_transaction(ctx, req) + .await? + .encode::< + crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionResponse, + >(format) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_server_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + request: ::buffa::bytes::Bytes, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.sidechain.v1.SidechainService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &request, &format); + match method { + "SubscribeEvents" => { + let svc = ::std::sync::Arc::clone(&self.inner); + Box::pin(async move { + let req = ::connectrpc::dispatcher::codegen::decode_request_view::< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsRequestView, + >(request, format)?; + let resp = svc.subscribe_events(ctx, req).await?; + Ok( + resp + .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< + crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsResponse, + _, + _, + >(s, format)), + ) + }) + } + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } + fn call_client_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::UnaryResult { + let Some(method) = path.strip_prefix("cusf.sidechain.v1.SidechainService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path), + } + } + fn call_bidi_streaming( + &self, + path: &str, + ctx: ::connectrpc::RequestContext, + requests: ::connectrpc::dispatcher::codegen::RequestStream, + format: ::connectrpc::CodecFormat, + ) -> ::connectrpc::dispatcher::codegen::StreamingResult { + let Some(method) = path.strip_prefix("cusf.sidechain.v1.SidechainService/") else { + return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); + }; + let _ = (&ctx, &requests, &format); + match method { + _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path), + } + } +} +/// Client for this service. +/// +/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use +/// `Http2Connection` — it has honest `poll_ready` and composes with +/// `tower::balance` for multi-connection load balancing. For **Connect +/// over HTTP/1.1** (or unknown protocol), use `HttpClient`. +/// +/// # Example (gRPC / HTTP/2) +/// +/// ```rust,ignore +/// use connectrpc::client::{Http2Connection, ClientConfig}; +/// use connectrpc::Protocol; +/// +/// let uri: http::Uri = "http://localhost:8080".parse()?; +/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024); +/// let config = ClientConfig::new(uri).with_protocol(Protocol::Grpc); +/// +/// let client = SidechainServiceClient::new(conn, config); +/// let response = client.get_mempool_txs(request).await?; +/// ``` +/// +/// # Example (Connect / HTTP/1.1 or ALPN) +/// +/// ```rust,ignore +/// use connectrpc::client::{HttpClient, ClientConfig}; +/// +/// let http = HttpClient::plaintext(); // cleartext http:// only +/// let config = ClientConfig::new("http://localhost:8080".parse()?); +/// +/// let client = SidechainServiceClient::new(http, config); +/// let response = client.get_mempool_txs(request).await?; +/// ``` +/// +/// # Working with the response +/// +/// Unary calls return [`UnaryResponse>`](::connectrpc::client::UnaryResponse). +/// The `OwnedView` derefs to the view, so field access is zero-copy: +/// +/// ```rust,ignore +/// let resp = client.get_mempool_txs(request).await?.into_view(); +/// let name: &str = resp.name; // borrow into the response buffer +/// ``` +/// +/// If you need the owned struct (e.g. to store or pass by value), use +/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned): +/// +/// ```rust,ignore +/// let owned = client.get_mempool_txs(request).await?.into_owned(); +/// ``` +#[derive(Clone)] +pub struct SidechainServiceClient { + transport: T, + config: ::connectrpc::client::ClientConfig, +} +impl SidechainServiceClient +where + T: ::connectrpc::client::ClientTransport, + ::Error: ::std::fmt::Display, +{ + /// Create a new client with the given transport and configuration. + pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self { + Self { transport, config } + } + /// Get the client configuration. + pub fn config(&self) -> &::connectrpc::client::ClientConfig { + &self.config + } + /// Get a mutable reference to the client configuration. + pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig { + &mut self.config + } + /// Call the GetMempoolTxs RPC. Sends a request to /cusf.sidechain.v1.SidechainService/GetMempoolTxs. + pub async fn get_mempool_txs( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_mempool_txs_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetMempoolTxs RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_mempool_txs_with_options( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::GetMempoolTxsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetMempoolTxsResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + SIDECHAIN_SERVICE_SERVICE_NAME, + "GetMempoolTxs", + request, + options, + ) + .await + } + /// Call the GetUtxos RPC. Sends a request to /cusf.sidechain.v1.SidechainService/GetUtxos. + pub async fn get_utxos( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.get_utxos_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the GetUtxos RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn get_utxos_with_options( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::GetUtxosRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::GetUtxosResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + SIDECHAIN_SERVICE_SERVICE_NAME, + "GetUtxos", + request, + options, + ) + .await + } + /// Call the SubmitTransaction RPC. Sends a request to /cusf.sidechain.v1.SidechainService/SubmitTransaction. + pub async fn submit_transaction( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionRequest, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + self.submit_transaction_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the SubmitTransaction RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn submit_transaction_with_options( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::SubmitTransactionRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::UnaryResponse< + ::buffa::view::OwnedView< + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubmitTransactionResponseView< + 'static, + >, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_unary( + &self.transport, + &self.config, + SIDECHAIN_SERVICE_SERVICE_NAME, + "SubmitTransaction", + request, + options, + ) + .await + } + /// Call the SubscribeEvents RPC. Sends a request to /cusf.sidechain.v1.SidechainService/SubscribeEvents. + pub async fn subscribe_events( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsRequest, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + self.subscribe_events_with_options( + request, + ::connectrpc::client::CallOptions::default(), + ) + .await + } + /// Call the SubscribeEvents RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults. + pub async fn subscribe_events_with_options( + &self, + request: crate::proto::generated::buffa::cusf::sidechain::v1::SubscribeEventsRequest, + options: ::connectrpc::client::CallOptions, + ) -> Result< + ::connectrpc::client::ServerStream< + T::ResponseBody, + crate::proto::generated::buffa::cusf::sidechain::v1::__buffa::view::SubscribeEventsResponseView< + 'static, + >, + >, + ::connectrpc::ConnectError, + > { + ::connectrpc::client::call_server_stream( + &self.transport, + &self.config, + SIDECHAIN_SERVICE_SERVICE_NAME, + "SubscribeEvents", + request, + options, + ) + .await + } +} diff --git a/lib/server/crypto.rs b/lib/server/crypto.rs index e66b84d7..8c923736 100644 --- a/lib/server/crypto.rs +++ b/lib/server/crypto.rs @@ -2,6 +2,7 @@ use bitcoin::{ hashes::{Hash, HashEngine, hmac, ripemd160, sha256, sha512}, key::Secp256k1, }; +use connectrpc::{RequestContext, ServiceResult}; use crate::{ proto::{ @@ -10,7 +11,12 @@ use crate::{ HmacSha512Request, HmacSha512Response, Ripemd160Request, Ripemd160Response, Secp256k1SecretKeyToPublicKeyRequest, Secp256k1SecretKeyToPublicKeyResponse, Secp256k1SignRequest, Secp256k1SignResponse, Secp256k1VerifyRequest, - Secp256k1VerifyResponse, crypto_service_server::CryptoService, + Secp256k1VerifyResponse, + }, + crypto_service::{ + CryptoService, OwnedHmacSha512RequestView, OwnedRipemd160RequestView, + OwnedSecp256k1SecretKeyToPublicKeyRequestView, OwnedSecp256k1SignRequestView, + OwnedSecp256k1VerifyRequestView, }, }, server::{invalid_field_value, missing_field}, @@ -23,137 +29,144 @@ const SECP256K1_SECRET_KEY_LENGTH: usize = 32; const SECP256K1_PUBLIC_KEY_LENGTH: usize = 33; const SECP256K1_SIGNATURE_COMPACT_SERIALIZATION_LENGTH: usize = 64; -#[tonic::async_trait] +#[allow(refining_impl_trait_reachable)] impl CryptoService for CryptoServiceServer { async fn ripemd160( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { - let Ripemd160Request { msg } = request.into_inner(); - let msg: Vec = msg + _ctx: RequestContext, + request: OwnedRipemd160RequestView, + ) -> ServiceResult { + let request = request.to_owned_message(); + let msg: Vec = request + .msg + .into_option() .ok_or_else(|| missing_field::("msg"))? - .decode_tonic::("msg")?; + .decode_status::("msg")?; let digest = ripemd160::Hash::hash(&msg); - let response = Ripemd160Response { - digest: Some(Hex::encode(&digest.as_byte_array())), - }; - Ok(tonic::Response::new(response)) + Ok(connectrpc::Response::new(Ripemd160Response { + digest: buffa::MessageField::some(Hex::encode(&digest.as_byte_array())), + })) } async fn hmac_sha512( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { - let HmacSha512Request { key, msg } = request.into_inner(); - let key: Vec = key + _ctx: RequestContext, + request: OwnedHmacSha512RequestView, + ) -> ServiceResult { + let request = request.to_owned_message(); + let key: Vec = request + .key + .into_option() .ok_or_else(|| missing_field::("key"))? - .decode_tonic::("key")?; - let msg: Vec = msg + .decode_status::("key")?; + let msg: Vec = request + .msg + .into_option() .ok_or_else(|| missing_field::("msg"))? - .decode_tonic::("msg")?; + .decode_status::("msg")?; let mut engine = hmac::HmacEngine::::new(&key); engine.input(&msg); let hmac = hmac::Hmac::::from_engine(engine); - let response = HmacSha512Response { - hmac: Some(Hex::encode(&hmac.as_byte_array())), - }; - Ok(tonic::Response::new(response)) + Ok(connectrpc::Response::new(HmacSha512Response { + hmac: buffa::MessageField::some(Hex::encode(&hmac.as_byte_array())), + })) } async fn secp256k1_secret_key_to_public_key( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> - { - let Secp256k1SecretKeyToPublicKeyRequest { secret_key } = request.into_inner(); - let secret_key: [u8; SECP256K1_SECRET_KEY_LENGTH] = secret_key + _ctx: RequestContext, + request: OwnedSecp256k1SecretKeyToPublicKeyRequestView, + ) -> ServiceResult { + let request = request.to_owned_message(); + let secret_key: [u8; SECP256K1_SECRET_KEY_LENGTH] = request + .secret_key + .into_option() .ok_or_else(|| missing_field::("secret_key"))? - .decode_tonic::("secret_key")?; + .decode_status::("secret_key")?; let secret_key = bitcoin::secp256k1::SecretKey::from_slice(&secret_key).map_err(|err| { invalid_field_value::("secret_key", "", err) })?; let secp = Secp256k1::new(); let public_key = bitcoin::secp256k1::PublicKey::from_secret_key(&secp, &secret_key); let public_key: [u8; SECP256K1_PUBLIC_KEY_LENGTH] = public_key.serialize(); - let response = Secp256k1SecretKeyToPublicKeyResponse { - public_key: Some(ConsensusHex::encode(&public_key)), - }; - Ok(tonic::Response::new(response)) + Ok(connectrpc::Response::new( + Secp256k1SecretKeyToPublicKeyResponse { + public_key: buffa::MessageField::some(ConsensusHex::encode(&public_key)), + }, + )) } async fn secp256k1_sign( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { - let Secp256k1SignRequest { - message, - secret_key, - } = request.into_inner(); - let message: Vec = message + _ctx: RequestContext, + request: OwnedSecp256k1SignRequestView, + ) -> ServiceResult { + let request = request.to_owned_message(); + let message: Vec = request + .message + .into_option() .ok_or_else(|| missing_field::("message"))? - .decode_tonic::("message")?; + .decode_status::("message")?; let digest = sha256::Hash::hash(&message).to_byte_array(); let message = bitcoin::secp256k1::Message::from_digest(digest); - let secret_key: [u8; SECP256K1_SECRET_KEY_LENGTH] = secret_key + let secret_key: [u8; SECP256K1_SECRET_KEY_LENGTH] = request + .secret_key + .into_option() .ok_or_else(|| missing_field::("secret_key"))? - .decode_tonic::("secret_key")?; + .decode_status::("secret_key")?; let secret_key = bitcoin::secp256k1::SecretKey::from_slice(&secret_key) .map_err(|err| invalid_field_value::("secret_key", "", err))?; let secp = Secp256k1::new(); let signature = secp.sign_ecdsa(&message, &secret_key); let signature = signature.serialize_compact(); - let response = Secp256k1SignResponse { - signature: Some(Hex::encode(&signature)), - }; - Ok(tonic::Response::new(response)) + Ok(connectrpc::Response::new(Secp256k1SignResponse { + signature: buffa::MessageField::some(Hex::encode(&signature)), + })) } async fn secp256k1_verify( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { - let Secp256k1VerifyRequest { - message, - signature, - public_key, - } = request.into_inner(); - let message: Vec = message + _ctx: RequestContext, + request: OwnedSecp256k1VerifyRequestView, + ) -> ServiceResult { + let request = request.to_owned_message(); + let message: Vec = request + .message + .into_option() .ok_or_else(|| missing_field::("message"))? - .decode_tonic::("message")?; + .decode_status::("message")?; let digest = sha256::Hash::hash(&message).to_byte_array(); let message = bitcoin::secp256k1::Message::from_digest(digest); - let signature: Vec = signature + let signature: Vec = request + .signature + .into_option() .ok_or_else(|| missing_field::("signature"))? - .decode_tonic::("signature")?; + .decode_status::("signature")?; let signature_len = signature.len(); let signature: [u8; SECP256K1_SIGNATURE_COMPACT_SERIALIZATION_LENGTH] = - signature.try_into().map_err(|_err| { - tonic::Status::new( - tonic::Code::InvalidArgument, - format!("invalid signature length {signature_len}, must be {SECP256K1_SIGNATURE_COMPACT_SERIALIZATION_LENGTH}"), + signature.try_into().map_err(|_| { + invalid_field_value::( + "signature", + &signature_len.to_string(), + std::io::Error::other(format!( + "invalid signature length, must be {SECP256K1_SIGNATURE_COMPACT_SERIALIZATION_LENGTH}" + )), ) })?; let signature = bitcoin::secp256k1::ecdsa::Signature::from_compact(&signature).map_err(|err| { - invalid_field_value::( - "signature", - &hex::encode(signature), - err, - ) + invalid_field_value::("signature", "", err) })?; - let public_key: [u8; SECP256K1_PUBLIC_KEY_LENGTH] = public_key + let public_key: [u8; SECP256K1_PUBLIC_KEY_LENGTH] = request + .public_key + .into_option() .ok_or_else(|| missing_field::("public_key"))? - .decode_tonic::("public_key")?; + .decode_status::("public_key")?; let public_key = bitcoin::secp256k1::PublicKey::from_slice(&public_key).map_err(|err| { - invalid_field_value::( - "public_key", - &hex::encode(public_key), - err, - ) + invalid_field_value::("public_key", "", err) })?; let secp = Secp256k1::new(); let valid = secp.verify_ecdsa(&message, &signature, &public_key).is_ok(); - let response = Secp256k1VerifyResponse { valid }; - Ok(tonic::Response::new(response)) + Ok(connectrpc::Response::new(Secp256k1VerifyResponse { valid })) } } diff --git a/lib/server/mod.rs b/lib/server/mod.rs index c5c3330b..9f26a817 100644 --- a/lib/server/mod.rs +++ b/lib/server/mod.rs @@ -1,30 +1,40 @@ +use buffa::MessageField; +use buffa_types::google::protobuf::UInt32Value; +use connectrpc::ConnectError; + +use crate::types::SidechainNumber; + pub mod crypto; pub mod validator; pub mod wallet; -fn custom_json_rpc_err(error: Error) -> jsonrpsee::types::ErrorObject<'static> -where - Error: std::error::Error, -{ - let err_msg = format!("{:#}", crate::errors::ErrorChain::new(&error)); - jsonrpsee::types::ErrorObject::owned(-1, err_msg, Option::<()>::None) -} - -pub(crate) fn invalid_field_value( +pub(crate) fn invalid_field_value( field_name: &str, value: &str, source: Error, -) -> tonic::Status +) -> ConnectError where - Message: prost::Name, Error: std::error::Error + Send + Sync + 'static, { crate::proto::Error::invalid_field_value::(field_name, value, source).into() } -pub(crate) fn missing_field(field_name: &str) -> tonic::Status -where - Message: prost::Name, -{ +pub(crate) fn missing_field(field_name: &str) -> ConnectError { crate::proto::Error::missing_field::(field_name).into() } + +pub(crate) fn internal_err(err: E) -> ConnectError { + ConnectError::internal(err.to_string()) +} + +/// Decode a `MessageField` sidechain id from a request, mapping any +/// failure to a `ConnectError` carrying the message's name. +pub(crate) fn parse_sidechain_id( + field: MessageField, + field_name: &str, +) -> Result { + let raw = + crate::proto::unwrap_u32(field).ok_or_else(|| missing_field::(field_name))?; + SidechainNumber::try_from(raw) + .map_err(|err| invalid_field_value::(field_name, &raw.to_string(), err)) +} diff --git a/lib/server/validator/grpc.rs b/lib/server/validator/grpc.rs index 362b7326..dd55c8bd 100644 --- a/lib/server/validator/grpc.rs +++ b/lib/server/validator/grpc.rs @@ -1,7 +1,8 @@ use bitcoin::{Amount, BlockHash, Transaction, TxOut, absolute::Height, hashes::Hash}; +use buffa::MessageField; +use connectrpc::{ConnectError, RequestContext, Response, ServiceResult}; use futures::{StreamExt as _, stream::BoxStream}; use miette::IntoDiagnostic as _; -use tonic::{Request, Response, Status}; use crate::{ convert, @@ -10,313 +11,292 @@ use crate::{ ToStatus as _, common::{ConsensusHex, ReverseHex}, mainchain::{ - GetBlockHeaderInfoRequest, GetBlockHeaderInfoResponse, GetBlockInfoRequest, - GetBlockInfoResponse, GetBmmHStarCommitmentRequest, GetBmmHStarCommitmentResponse, - GetChainInfoRequest, GetChainInfoResponse, GetChainTipRequest, GetChainTipResponse, - GetCoinbasePsbtRequest, GetCoinbasePsbtResponse, GetCtipRequest, GetCtipResponse, - GetSidechainProposalsRequest, GetSidechainProposalsResponse, GetSidechainsRequest, - GetSidechainsResponse, GetTwoWayPegDataRequest, GetTwoWayPegDataResponse, Network, - StopRequest, StopResponse, SubscribeEventsRequest, SubscribeEventsResponse, - SubscribeHeaderSyncProgressRequest, SubscribeHeaderSyncProgressResponse, + GetBlockHeaderInfoResponse, GetBlockInfoResponse, GetBmmHStarCommitmentResponse, + GetChainInfoResponse, GetChainTipResponse, GetCoinbasePSBTResponse, GetCtipResponse, + GetSidechainProposalsResponse, GetSidechainsResponse, GetTwoWayPegDataResponse, + Network, StopResponse, SubscribeEventsResponse, SubscribeHeaderSyncProgressResponse, get_block_info_response, get_bmm_h_star_commitment_response, get_ctip_response::Ctip, get_sidechain_proposals_response::SidechainProposal, - get_sidechains_response::SidechainInfo, server::ValidatorService, + get_sidechains_response::SidechainInfo, }, + mainchain_service::{ + OwnedGetBlockHeaderInfoRequestView, OwnedGetBlockInfoRequestView, + OwnedGetBmmHStarCommitmentRequestView, OwnedGetChainInfoRequestView, + OwnedGetChainTipRequestView, OwnedGetCoinbasePsbtRequestView, OwnedGetCtipRequestView, + OwnedGetSidechainProposalsRequestView, OwnedGetSidechainsRequestView, + OwnedGetTwoWayPegDataRequestView, OwnedStopRequestView, + OwnedSubscribeEventsRequestView, OwnedSubscribeHeaderSyncProgressRequestView, + ValidatorService, + }, + wrap_u32, }, - server::{invalid_field_value, missing_field, validator::Server}, - types::SidechainNumber, + server::{internal_err, missing_field, parse_sidechain_id, validator::Server}, }; -#[tonic::async_trait] +#[allow(refining_impl_trait_reachable)] impl ValidatorService for Server { async fn get_block_header_info( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedGetBlockHeaderInfoRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetBlockHeaderInfoRequest; let GetBlockHeaderInfoRequest { block_hash, max_ancestors, - } = request.into_inner(); + .. + } = request.to_owned_message(); let block_hash = block_hash + .into_option() .ok_or_else(|| missing_field::("block_hash"))? - .decode_tonic::("block_hash")?; + .decode_status::("block_hash")?; + let max_ancestors = max_ancestors.unwrap_or(0) as usize; let resp = match self .validator - .try_get_header_infos(&block_hash, max_ancestors.unwrap_or(0) as usize) - .map_err(|err| tonic::Status::from_error(Box::new(err)))? + .try_get_header_infos(&block_hash, max_ancestors) + .map_err(internal_err)? { - Some(header_infos) => GetBlockHeaderInfoResponse { - header_infos: header_infos - .into_iter() - .map(|header_info| header_info.into()) - .collect(), - }, - None => GetBlockHeaderInfoResponse { - header_infos: Vec::new(), + Some(infos) => GetBlockHeaderInfoResponse { + header_infos: infos.into_iter().map(Into::into).collect(), }, + None => GetBlockHeaderInfoResponse::default(), }; - Ok(tonic::Response::new(resp)) + Ok(Response::new(resp)) } async fn get_block_info( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedGetBlockInfoRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetBlockInfoRequest; let GetBlockInfoRequest { block_hash, sidechain_id, max_ancestors, - } = request.into_inner(); + .. + } = request.to_owned_message(); let block_hash = block_hash + .into_option() .ok_or_else(|| missing_field::("block_hash"))? - .decode_tonic::("block_hash")?; - let sidechain_id = { - let raw_id = - sidechain_id.ok_or_else(|| missing_field::("sidechain_id"))?; - - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; + .decode_status::("block_hash")?; + let sidechain_id = parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let max_ancestors = max_ancestors.unwrap_or(0) as usize; let resp = match self .validator - .try_get_block_infos(&block_hash, max_ancestors.unwrap_or(0) as usize) - .map_err(|err| tonic::Status::from_error(Box::new(err)))? + .try_get_block_infos(&block_hash, max_ancestors) + .map_err(internal_err)? { - None => GetBlockInfoResponse { infos: Vec::new() }, - Some(block_infos) => GetBlockInfoResponse { - infos: block_infos + None => GetBlockInfoResponse::default(), + Some(infos) => GetBlockInfoResponse { + infos: infos .into_iter() .map(|(header_info, block_info)| get_block_info_response::Info { - header_info: Some(header_info.into()), - block_info: Some(block_info.as_proto(sidechain_id)), + header_info: MessageField::some(header_info.into()), + block_info: MessageField::some(block_info.as_proto(sidechain_id)), }) .collect(), }, }; - Ok(tonic::Response::new(resp)) + Ok(Response::new(resp)) } async fn get_bmm_h_star_commitment( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedGetBmmHStarCommitmentRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetBmmHStarCommitmentRequest; let GetBmmHStarCommitmentRequest { block_hash, sidechain_id, max_ancestors, - } = request.into_inner(); + .. + } = request.to_owned_message(); let block_hash = block_hash + .into_option() .ok_or_else(|| missing_field::("block_hash"))? - .decode_tonic::("block_hash")?; - - let sidechain_id = { - let raw_id = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id"))?; - - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; + .decode_status::("block_hash")?; + let sidechain_id = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let max_ancestors = max_ancestors.unwrap_or(0) as usize; let bmm_commitments = self .validator - .try_get_bmm_commitments(&block_hash, max_ancestors.unwrap_or(0) as usize) - .map_err(|err| tonic::Status::from_error(Box::new(err)))?; + .try_get_bmm_commitments(&block_hash, max_ancestors) + .map_err(internal_err)?; let res = match nonempty::NonEmpty::from_vec(bmm_commitments) { - None => { - let err = get_bmm_h_star_commitment_response::BlockNotFoundError { - block_hash: Some(ReverseHex::encode(&block_hash)), - }; - get_bmm_h_star_commitment_response::Result::BlockNotFound(err) - } + None => get_bmm_h_star_commitment_response::Result::BlockNotFound(Box::new( + get_bmm_h_star_commitment_response::BlockNotFoundError { + block_hash: MessageField::some(ReverseHex::encode(&block_hash)), + }, + )), Some(nonempty::NonEmpty { head, tail }) => { - get_bmm_h_star_commitment_response::Result::Commitment( + let commitment = head + .get(&sidechain_id) + .map(|c| MessageField::some(ConsensusHex::encode(c))) + .unwrap_or_default(); + let ancestor_commitments = tail + .into_iter() + .map( + |commitments| get_bmm_h_star_commitment_response::OptionalCommitment { + commitment: commitments + .get(&sidechain_id) + .map(|c| MessageField::some(ConsensusHex::encode(c))) + .unwrap_or_default(), + }, + ) + .collect(); + get_bmm_h_star_commitment_response::Result::Commitment(Box::new( get_bmm_h_star_commitment_response::Commitment { - commitment: head.get(&sidechain_id).map(ConsensusHex::encode), - ancestor_commitments: tail - .into_iter() - .map(|commitments| { - get_bmm_h_star_commitment_response::OptionalCommitment { - commitment: commitments - .get(&sidechain_id) - .map(ConsensusHex::encode), - } - }) - .collect(), + commitment, + ancestor_commitments, }, - ) + )) } }; - let resp = GetBmmHStarCommitmentResponse { result: Some(res) }; - Ok(tonic::Response::new(resp)) + Ok(Response::new(GetBmmHStarCommitmentResponse { + result: Some(res), + })) } async fn get_chain_info( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let GetChainInfoRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedGetChainInfoRequestView, + ) -> ServiceResult { let network: Network = self.validator.network().into(); - let resp = GetChainInfoResponse { - network: network as i32, - }; - Ok(tonic::Response::new(resp)) + Ok(Response::new(GetChainInfoResponse { + network: network.into(), + })) } async fn get_chain_tip( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let GetChainTipRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedGetChainTipRequestView, + ) -> ServiceResult { let Some(tip_hash) = self .validator .try_get_mainchain_tip() - .map_err(|err| err.builder().to_status())? + .map_err(|err| err.builder().to_connect_error())? else { - return Err(tonic::Status::unavailable("Validator is not synced")); + return Err(ConnectError::unavailable("Validator is not synced")); }; let header_info = self .validator .get_header_info(&tip_hash) - .map_err(|err| tonic::Status::from_error(err.into()))?; - let resp = GetChainTipResponse { - block_header_info: Some(header_info.into()), - }; - Ok(tonic::Response::new(resp)) + .map_err(internal_err)?; + Ok(Response::new(GetChainTipResponse { + block_header_info: MessageField::some(header_info.into()), + })) } async fn get_coinbase_psbt( &self, - request: Request, - ) -> Result, Status> { - let request = request.into_inner(); + _ctx: RequestContext, + request: OwnedGetCoinbasePsbtRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetCoinbasePSBTRequest; + let request = request.to_owned_message(); let mut messages = Vec::::new(); - for propose_sidechain in request.propose_sidechains { - let m1: M1ProposeSidechain = propose_sidechain - .try_into() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; + for propose in request.propose_sidechains { + let m1: M1ProposeSidechain = propose.try_into()?; messages.push(m1.into()); } - for ack_sidechain in request.ack_sidechains { - let m2: M2AckSidechain = ack_sidechain - .try_into() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; + for ack in request.ack_sidechains { + let m2: M2AckSidechain = ack.try_into()?; messages.push(m2.into()); } - for propose_bundle in request.propose_bundles { - let m3: M3ProposeBundle = propose_bundle - .try_into() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; + for propose in request.propose_bundles { + let m3: M3ProposeBundle = propose.try_into()?; messages.push(m3.into()); } let ack_bundles = request .ack_bundles - .ok_or_else(|| missing_field::("ack_bundles"))?; - { - let message = ack_bundles - .try_into() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; - messages.push(message); - } + .into_option() + .ok_or_else(|| missing_field::("ack_bundles"))?; + let m4: CoinbaseMessage = ack_bundles.try_into()?; + messages.push(m4); let output = messages .into_iter() - .map(|message| { + .map(|m| { Ok(TxOut { value: Amount::ZERO, - script_pubkey: message.try_into().into_diagnostic()?, + script_pubkey: m.try_into().into_diagnostic()?, }) }) .collect::>>() - .map_err(|err| tonic::Status::internal(err.to_string()))?; + .map_err(internal_err)?; let transaction = Transaction { output, input: vec![], lock_time: bitcoin::absolute::LockTime::Blocks(Height::ZERO), version: bitcoin::transaction::Version::TWO, }; - let response = GetCoinbasePsbtResponse { - psbt: Some(ConsensusHex::encode(&transaction)), - }; - Ok(Response::new(response)) + Ok(Response::new(GetCoinbasePSBTResponse { + psbt: MessageField::some(ConsensusHex::encode(&transaction)), + })) } async fn get_ctip( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let GetCtipRequest { sidechain_number } = request.into_inner(); - let sidechain_number = { - let raw_id = sidechain_number - .ok_or_else(|| missing_field::("sidechain_number"))?; - - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_number", - &raw_id.to_string(), - err, - ) - })? - }; - + _ctx: RequestContext, + request: OwnedGetCtipRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetCtipRequest; + let GetCtipRequest { + sidechain_number, .. + } = request.to_owned_message(); + let sidechain_number = + parse_sidechain_id::(sidechain_number, "sidechain_number")?; let ctip = self .validator .try_get_ctip(sidechain_number) - .map_err(|err| err.builder().to_status())?; - if let Some(ctip) = ctip { + .map_err(|err| err.builder().to_connect_error())?; + let response = if let Some(ctip) = ctip { let sequence_number = self .validator .get_ctip_sequence_number(sidechain_number) - .map_err(|err| err.builder().to_status())?; - // get_ctip returned Some(ctip) above, so we know that the sequence_number will also - // return Some, so we just unwrap it. - let sequence_number = sequence_number.unwrap(); - let ctip = Ctip { - txid: Some(ReverseHex::encode(&ctip.outpoint.txid)), - vout: ctip.outpoint.vout, - value: ctip.value.to_sat(), - sequence_number, - }; - let response = GetCtipResponse { ctip: Some(ctip) }; - Ok(Response::new(response)) + .map_err(|err| err.builder().to_connect_error())? + // get_ctip returned Some(ctip) above, so we know that the sequence_number will also + // return Some, so we just unwrap it. + .unwrap(); + GetCtipResponse { + ctip: MessageField::some(Ctip { + txid: MessageField::some(ReverseHex::encode(&ctip.outpoint.txid)), + vout: ctip.outpoint.vout, + value: ctip.value.to_sat(), + sequence_number, + }), + } } else { - let response = GetCtipResponse { ctip: None }; - Ok(Response::new(response)) - } + GetCtipResponse::default() + }; + Ok(Response::new(response)) } async fn get_sidechain_proposals( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let GetSidechainProposalsRequest {} = request.into_inner(); - let Some(mainchain_tip) = self + _ctx: RequestContext, + _request: OwnedGetSidechainProposalsRequestView, + ) -> ServiceResult { + let Some(tip) = self .validator .try_get_mainchain_tip() - .map_err(|err| err.builder().to_status())? + .map_err(|err| err.builder().to_connect_error())? else { - let response = GetSidechainProposalsResponse { - sidechain_proposals: Vec::new(), - }; - return Ok(Response::new(response)); + return Ok(Response::new(GetSidechainProposalsResponse::default())); }; let mainchain_tip_height = self .validator - .get_header_info(&mainchain_tip) - .map_err(|err| err.builder().to_status())? + .get_header_info(&tip) + .map_err(|err| err.builder().to_connect_error())? .height; - let sidechain_proposals = self + let proposals = self .validator .get_sidechains() - .map_err(|err| err.builder().to_status())?; - let sidechain_proposals = sidechain_proposals + .map_err(|err| err.builder().to_connect_error())?; + let sidechain_proposals = proposals .into_iter() .map(|(proposal_id, sidechain)| { let description = ConsensusHex::encode(&sidechain.proposal.description.0); @@ -325,161 +305,124 @@ impl ValidatorService for Server { .map(crate::proto::mainchain::SidechainDeclaration::from) .ok(); SidechainProposal { - sidechain_number: Some(sidechain.proposal.sidechain_number.0 as u32), - description: Some(description), - declaration, - description_sha256d_hash: Some(ReverseHex::encode( + sidechain_number: wrap_u32(sidechain.proposal.sidechain_number.0 as u32), + description: MessageField::some(description), + declaration: declaration.map(MessageField::some).unwrap_or_default(), + description_sha256d_hash: MessageField::some(ReverseHex::encode( &proposal_id.description_hash, )), - vote_count: Some(sidechain.status.vote_count as u32), - proposal_height: Some(sidechain.status.proposal_height), - proposal_age: Some(mainchain_tip_height - sidechain.status.proposal_height), + vote_count: wrap_u32(sidechain.status.vote_count as u32), + proposal_height: wrap_u32(sidechain.status.proposal_height), + proposal_age: wrap_u32(mainchain_tip_height - sidechain.status.proposal_height), } }) .collect(); - let response = GetSidechainProposalsResponse { + Ok(Response::new(GetSidechainProposalsResponse { sidechain_proposals, - }; - Ok(Response::new(response)) + })) } async fn get_sidechains( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let GetSidechainsRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedGetSidechainsRequestView, + ) -> ServiceResult { let sidechains = self .validator .get_active_sidechains() - .map_err(|err| err.builder().to_status())?; + .map_err(|err| err.builder().to_connect_error())?; let sidechains = sidechains.into_iter().map(SidechainInfo::from).collect(); - let response = GetSidechainsResponse { sidechains }; - Ok(Response::new(response)) + Ok(Response::new(GetSidechainsResponse { sidechains })) } async fn get_two_way_peg_data( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedGetTwoWayPegDataRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::GetTwoWayPegDataRequest; let GetTwoWayPegDataRequest { sidechain_id, start_block_hash, end_block_hash, - } = request.into_inner(); - - let sidechain_id = { - let raw_id = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id"))?; - - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; - + .. + } = request.to_owned_message(); + let sidechain_id = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; let start_block_hash: Option = start_block_hash - .map(|start_block_hash| { - start_block_hash.decode_tonic::("start_block_hash") - }) + .into_option() + .map(|h| h.decode_status::("start_block_hash")) .transpose()? .map(|bytes| { convert::bdk_block_hash_to_bitcoin_block_hash( bdk_wallet::bitcoin::BlockHash::from_byte_array(bytes), ) }); - let end_block_hash: BlockHash = end_block_hash + .into_option() .ok_or_else(|| missing_field::("end_block_hash"))? - .decode_tonic::("end_block_hash") + .decode_status::("end_block_hash") .map(bdk_wallet::bitcoin::BlockHash::from_byte_array) .map(convert::bdk_block_hash_to_bitcoin_block_hash)?; - - match self + let two_way_peg_data = self .validator .get_two_way_peg_data(start_block_hash, end_block_hash) - { - Err(err) => Err(tonic::Status::from_error(Box::new(err))), - Ok(two_way_peg_data) => { - let two_way_peg_data = two_way_peg_data - .into_iter() - .filter_map(|two_way_peg_data| two_way_peg_data.into_proto(sidechain_id)) - .collect(); - let resp = GetTwoWayPegDataResponse { - blocks: two_way_peg_data, - }; - Ok(tonic::Response::new(resp)) - } - } + .map_err(internal_err)?; + let blocks = two_way_peg_data + .into_iter() + .filter_map(|d| d.into_proto(sidechain_id)) + .collect(); + Ok(Response::new(GetTwoWayPegDataResponse { blocks })) } - type SubscribeEventsStream = BoxStream<'static, Result>; - async fn subscribe_events( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let SubscribeEventsRequest { sidechain_id } = request.into_inner(); - - let sidechain_id = { - let raw_id = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id"))?; - - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; - - let stream = self + _ctx: RequestContext, + request: OwnedSubscribeEventsRequestView, + ) -> ServiceResult> { + use crate::proto::mainchain::SubscribeEventsRequest; + let SubscribeEventsRequest { sidechain_id, .. } = request.to_owned_message(); + let sidechain_id = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let stream: BoxStream<'static, _> = self .validator .subscribe_events() .map(move |res| match res { Ok(event) => Ok(SubscribeEventsResponse { - event: Some(event.into_proto(sidechain_id).into()), + event: MessageField::some(event.into_proto(sidechain_id).into()), }), - Err(err) => Err(err.builder().to_status()), + Err(err) => Err(err.builder().to_connect_error()), }) .boxed(); - Ok(tonic::Response::new(stream)) + Ok(Response::new(Box::pin(stream))) } - type SubscribeHeaderSyncProgressStream = - BoxStream<'static, Result>; - async fn subscribe_header_sync_progress( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let SubscribeHeaderSyncProgressRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedSubscribeHeaderSyncProgressRequestView, + ) -> ServiceResult> { let Some(rx) = self.validator.subscribe_header_sync_progress() else { - return Err(tonic::Status::unavailable("No header sync in progress")); + return Err(ConnectError::unavailable("No header sync in progress")); }; - let stream = tokio_stream::wrappers::WatchStream::new(rx) + let stream: BoxStream<'static, _> = tokio_stream::wrappers::WatchStream::new(rx) .map(|progress| Ok(progress.into())) .boxed(); - Ok(tonic::Response::new(stream)) + Ok(Response::new(Box::pin(stream))) } async fn stop( &self, - _: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + _request: OwnedStopRequestView, + ) -> ServiceResult { if self.cancel.is_cancelled() { - return Err(tonic::Status::unavailable( + return Err(ConnectError::unavailable( "Validator is already shutting down", )); } - tracing::info!("received stop request, cancelling token"); - self.cancel.cancel(); - - Ok(tonic::Response::new(StopResponse {})) + Ok(Response::new(StopResponse::default())) } } diff --git a/lib/server/validator/json_rpc.rs b/lib/server/validator/json_rpc.rs deleted file mode 100644 index d53e7787..00000000 --- a/lib/server/validator/json_rpc.rs +++ /dev/null @@ -1,80 +0,0 @@ -use bitcoin::BlockHash; -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use serde::{Serialize, Serializer}; - -use crate::{ - server::custom_json_rpc_err, - types::{Ctip, HeaderInfo, SidechainBlockInfo, SidechainNumber}, -}; - -#[derive(Clone, Copy, Debug)] -pub struct Pong; - -impl Serialize for Pong { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str("Pong") - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct BlockInfoItem { - pub header_info: HeaderInfo, - pub block_info: SidechainBlockInfo, -} - -type BlockInfoResponse = Vec; - -#[rpc(namespace = "validator", namespace_separator = ".", server)] -pub trait Rpc { - #[method(name = "ping")] - fn ping(&self) -> RpcResult; - - #[method(name = "ctip")] - fn get_ctip(&self, sidechain_number: SidechainNumber) -> RpcResult>; - - #[method(name = "get_block_info")] - fn get_block_info( - &self, - block_hash: BlockHash, - sidechain_id: SidechainNumber, - max_ancestors: Option, - ) -> RpcResult; -} - -impl RpcServer for crate::validator::Validator { - fn ping(&self) -> RpcResult { - Ok(Pong) - } - - fn get_ctip(&self, sidechain_number: SidechainNumber) -> RpcResult> { - self.try_get_ctip(sidechain_number) - .map_err(custom_json_rpc_err) - } - - fn get_block_info( - &self, - block_hash: BlockHash, - sidechain_id: SidechainNumber, - max_ancestors: Option, - ) -> RpcResult { - // Get block infos with ancestors - let max_ancestors = max_ancestors.unwrap_or(0); - let block_infos = self - .try_get_block_infos(&block_hash, max_ancestors) - .map_err(custom_json_rpc_err)?; - let res = match block_infos { - None => Vec::new(), - Some(block_infos) => block_infos - .into_iter() - .map(|(header_info, block_info)| BlockInfoItem { - header_info, - block_info: block_info.only_sidechain(sidechain_id).to_owned(), - }) - .collect(), - }; - Ok(res) - } -} diff --git a/lib/server/validator/mod.rs b/lib/server/validator/mod.rs index b7763fce..9dbf0781 100644 --- a/lib/server/validator/mod.rs +++ b/lib/server/validator/mod.rs @@ -3,7 +3,6 @@ use tokio_util::sync::CancellationToken; use crate::validator::Validator; mod grpc; -pub mod json_rpc; #[derive(Clone)] pub struct Server { diff --git a/lib/server/wallet/grpc.rs b/lib/server/wallet/grpc.rs index 477e5044..24d13642 100644 --- a/lib/server/wallet/grpc.rs +++ b/lib/server/wallet/grpc.rs @@ -2,11 +2,12 @@ use std::{borrow::Cow, collections::HashMap, str::FromStr, sync::Arc}; use bdk_wallet::bip39::Mnemonic; use bitcoin::{Address, Amount, BlockHash, Transaction, hashes::Hash as _}; +use buffa::MessageField; +use connectrpc::{ConnectError, RequestContext, Response, ServiceResult, ServiceStream}; use futures::{ StreamExt as _, stream::{BoxStream, FusedStream}, }; -use thiserror::Error; use crate::{ convert, @@ -15,25 +16,30 @@ use crate::{ StatusBuilder, ToStatus, common::ReverseHex, mainchain::{ - BroadcastWithdrawalBundleRequest, BroadcastWithdrawalBundleResponse, - CreateBmmCriticalDataTransactionRequest, CreateBmmCriticalDataTransactionResponse, - CreateDepositTransactionRequest, CreateDepositTransactionResponse, - CreateNewAddressRequest, CreateNewAddressResponse, CreateSidechainProposalRequest, - CreateSidechainProposalResponse, CreateWalletRequest, CreateWalletResponse, - GenerateBlocksRequest, GenerateBlocksResponse, GetBalanceRequest, GetBalanceResponse, - GetInfoRequest, GetInfoResponse, ListSidechainDepositTransactionsRequest, - ListSidechainDepositTransactionsResponse, ListTransactionsRequest, - ListTransactionsResponse, ListUnspentOutputsRequest, ListUnspentOutputsResponse, - SendTransactionRequest, SendTransactionResponse, UnlockWalletRequest, + BroadcastWithdrawalBundleResponse, CreateBmmCriticalDataTransactionResponse, + CreateDepositTransactionResponse, CreateNewAddressResponse, + CreateSidechainProposalResponse, CreateWalletResponse, GenerateBlocksResponse, + GetBalanceResponse, GetInfoResponse, ListSidechainDepositTransactionsResponse, + ListTransactionsResponse, ListUnspentOutputsResponse, SendTransactionResponse, UnlockWalletResponse, WalletTransaction, create_sidechain_proposal_response, get_info_response, list_sidechain_deposit_transactions_response::SidechainDepositTransaction, list_unspent_outputs_response, send_transaction_request::RequiredUtxo, - wallet_service_server::WalletService, }, + mainchain_service::{ + OwnedBroadcastWithdrawalBundleRequestView, + OwnedCreateBmmCriticalDataTransactionRequestView, + OwnedCreateDepositTransactionRequestView, OwnedCreateNewAddressRequestView, + OwnedCreateSidechainProposalRequestView, OwnedCreateWalletRequestView, + OwnedGenerateBlocksRequestView, OwnedGetBalanceRequestView, OwnedGetInfoRequestView, + OwnedListSidechainDepositTransactionsRequestView, OwnedListTransactionsRequestView, + OwnedListUnspentOutputsRequestView, OwnedSendTransactionRequestView, + OwnedUnlockWalletRequestView, WalletService, + }, + unwrap_string, unwrap_u32, unwrap_u64, wrap_timestamp, wrap_u32, }, - server::{invalid_field_value, missing_field}, - types::{BlindedM6, Event, SidechainNumber}, + server::{internal_err, invalid_field_value, missing_field, parse_sidechain_id}, + types::{BlindedM6, Event}, wallet::{CreateTransactionParams, error::WalletInitialization}, }; @@ -41,7 +47,7 @@ use crate::{ fn stream_proposal_confirmations( validator: &crate::validator::Validator, sidechain_proposal: crate::types::SidechainProposal, -) -> impl FusedStream> + use<> { +) -> impl FusedStream> + use<> { fn connect_block_event( sidechain_proposal: &crate::types::SidechainProposal, confirmations: &mut HashMap)>, @@ -70,24 +76,32 @@ fn stream_proposal_confirmations( (prev_confirms, outpoint) } else { let notconfirmed = create_sidechain_proposal_response::NotConfirmed { - block_hash: Some(ReverseHex::encode(&header_info.block_hash)), - height: Some(header_info.height), - prev_block_hash: Some(ReverseHex::encode(&header_info.prev_block_hash)), + block_hash: MessageField::some(ReverseHex::encode(&header_info.block_hash)), + height: wrap_u32(header_info.height), + prev_block_hash: MessageField::some(ReverseHex::encode( + &header_info.prev_block_hash, + )), + }; + return CreateSidechainProposalResponse { + event: Some(create_sidechain_proposal_response::Event::NotConfirmed( + Box::new(notconfirmed), + )), }; - let event = create_sidechain_proposal_response::Event::NotConfirmed(notconfirmed); - return CreateSidechainProposalResponse { event: Some(event) }; } }; let confirmed = create_sidechain_proposal_response::Confirmed { - block_hash: Some(ReverseHex::encode(&header_info.block_hash)), - confirmations: Some(confirms), - height: Some(header_info.height), - outpoint: Some((&*outpoint).into()), - prev_block_hash: Some(ReverseHex::encode(&header_info.prev_block_hash)), + block_hash: MessageField::some(ReverseHex::encode(&header_info.block_hash)), + confirmations: wrap_u32(confirms), + height: wrap_u32(header_info.height), + outpoint: MessageField::some((&*outpoint).into()), + prev_block_hash: MessageField::some(ReverseHex::encode(&header_info.prev_block_hash)), }; confirmations.insert(header_info.block_hash, (confirms, outpoint)); - let event = create_sidechain_proposal_response::Event::Confirmed(confirmed); - CreateSidechainProposalResponse { event: Some(event) } + CreateSidechainProposalResponse { + event: Some(create_sidechain_proposal_response::Event::Confirmed( + Box::new(confirmed), + )), + } } let mut confirmations = HashMap::)>::new(); @@ -108,29 +122,24 @@ fn stream_proposal_confirmations( } Event::DisconnectBlock { .. } => None, }, - Err(err) => Some(Err(err.builder().to_status())), + Err(err) => Some(Err(err.builder().to_connect_error())), }; futures::future::ready(resp) }) } -#[tonic::async_trait] +#[allow(refining_impl_trait_reachable)] impl WalletService for crate::wallet::Wallet { - type CreateSidechainProposalStream = - BoxStream<'static, Result>; - - type GenerateBlocksStream = BoxStream<'static, Result>; - async fn get_info( &self, - _request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + _request: OwnedGetInfoRequestView, + ) -> ServiceResult { let info = self .get_wallet_info() .await - .map_err(|err| err.builder().to_status())?; - - let response = GetInfoResponse { + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(GetInfoResponse { network: info.network.to_string(), transaction_count: info.transaction_count as u32, unspent_output_count: info.unspent_output_count as u32, @@ -147,95 +156,85 @@ impl WalletService for crate::wallet::Wallet { ) }) .collect(), - tip: Some(get_info_response::Tip { + tip: MessageField::some(get_info_response::Tip { height: info.tip.1, - hash: Some(ReverseHex::encode(&info.tip.0)), + hash: MessageField::some(ReverseHex::encode(&info.tip.0)), }), - }; - Ok(tonic::Response::new(response)) + })) } async fn create_sidechain_proposal( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedCreateSidechainProposalRequestView, + ) -> ServiceResult> { + use crate::proto::mainchain::CreateSidechainProposalRequest; let CreateSidechainProposalRequest { sidechain_id, declaration, - } = request.into_inner(); - let sidechain_id = { - let raw_id = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id"))?; - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; - let declaration = declaration + .. + } = request.to_owned_message(); + let sidechain_id = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let declaration: crate::types::SidechainDeclaration = declaration + .into_option() .ok_or_else(|| missing_field::("declaration"))? - .try_into() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; + .try_into()?; let (proposal_txout, description) = crate::messages::create_sidechain_proposal(sidechain_id, &declaration).map_err( - |err: bitcoin::script::PushBytesError| tonic::Status::unknown(format!("{err:#}")), + |err: bitcoin::script::PushBytesError| ConnectError::unknown(format!("{err:#}")), )?; - tracing::info!("Created sidechain proposal TX output: {:?}", proposal_txout); let sidechain_proposal = crate::types::SidechainProposal { sidechain_number: sidechain_id, description, }; - let () = self - .propose_sidechain(&sidechain_proposal) + self.propose_sidechain(&sidechain_proposal) .await .map_err(|err| { if let rusqlite::Error::SqliteFailure(sqlite_err, _) = err { tracing::error!("SQLite error: {:#}", ErrorChain::new(&sqlite_err)); - if sqlite_err.code == rusqlite::ErrorCode::ConstraintViolation { - return tonic::Status::already_exists("Sidechain proposal already exists"); + return ConnectError::already_exists("Sidechain proposal already exists"); } } - - tonic::Status::internal(err.to_string()) + ConnectError::internal(err.to_string()) })?; - - tracing::info!("Persisted sidechain proposal into DB",); - - let stream = stream_proposal_confirmations(self.validator(), sidechain_proposal).boxed(); - - Ok(tonic::Response::new(stream)) + tracing::info!("Persisted sidechain proposal into DB"); + let stream: BoxStream<'static, _> = + stream_proposal_confirmations(self.validator(), sidechain_proposal).boxed(); + Ok(Response::new(Box::pin(stream))) } async fn create_new_address( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _ctx: RequestContext, + _request: OwnedCreateNewAddressRequestView, + ) -> ServiceResult { let address = self .get_new_address() .await - .map_err(|err| err.builder().to_status())?; - - let response = CreateNewAddressResponse { + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(CreateNewAddressResponse { address: address.to_string(), - }; - Ok(tonic::Response::new(response)) + })) } async fn generate_blocks( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedGenerateBlocksRequestView, + ) -> ServiceResult> { + use crate::proto::mainchain::GenerateBlocksRequest; let GenerateBlocksRequest { blocks, ack_all_proposals, - } = request.into_inner(); - let count = std::num::NonZeroU32::new(blocks.unwrap_or(1)).ok_or_else(|| { - tonic::Status::invalid_argument("must provide a positive number of blocks") - })?; + .. + } = request.to_owned_message(); + let count = + std::num::NonZeroU32::new(unwrap_u32(blocks).unwrap_or(1)).ok_or_else(|| { + ConnectError::invalid_argument("must provide a positive number of blocks") + })?; // Only allow one GenerateBlocks call at a time. Concurrent callers // will get a rate-limited error instead of queuing up. @@ -244,58 +243,54 @@ impl WalletService for crate::wallet::Wallet { .clone() .try_acquire_owned() .map_err(|_| { - tonic::Status::resource_exhausted("GenerateBlocks is already in progress") + ConnectError::resource_exhausted("GenerateBlocks is already in progress") })?; self.verify_can_mine(count) .await - .map_err(|err| err.builder().to_status())?; + .map_err(|err| err.builder().to_connect_error())?; tracing::info!("generate blocks: verified ability to mine"); - let stream = crate::wallet::Wallet::generate_blocks(self.clone(), count, ack_all_proposals) - .map(|stream_item| match stream_item { - Ok(block_hash) => Ok(GenerateBlocksResponse { - block_hash: Some(ReverseHex::encode(&block_hash)), - }), - Err(err) => { - tracing::error!("{:#}", ErrorChain::new(&err)); - Err(err.builder().to_status()) - } - }) - // Hold the permit for the lifetime of the stream, so that - // the semaphore is released when the stream completes or is - // dropped. - .map(move |item| { - let _permit = &permit; - item - }) - .boxed(); - Ok(tonic::Response::new(stream)) + let stream: BoxStream<'static, _> = + crate::wallet::Wallet::generate_blocks(self.clone(), count, ack_all_proposals) + .map(|item| match item { + Ok(block_hash) => Ok(GenerateBlocksResponse { + block_hash: MessageField::some(ReverseHex::encode(&block_hash)), + }), + Err(err) => { + tracing::error!("{:#}", ErrorChain::new(&err)); + Err(err.builder().to_connect_error()) + } + }) + // Hold the permit for the lifetime of the stream, so that + // the semaphore is released when the stream completes or is + // dropped. + .map(move |item| { + let _permit = &permit; + item + }) + .boxed(); + Ok(Response::new(Box::pin(stream))) } async fn broadcast_withdrawal_bundle( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> - { + _ctx: RequestContext, + request: OwnedBroadcastWithdrawalBundleRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::BroadcastWithdrawalBundleRequest; let BroadcastWithdrawalBundleRequest { sidechain_id, transaction, - } = request.into_inner(); - let sidechain_id = { - let raw_id = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id"))?; - SidechainNumber::try_from(raw_id).map_err(|err| { - invalid_field_value::( - "sidechain_id", - &raw_id.to_string(), - err, - ) - })? - }; - let transaction_bytes = transaction - .ok_or_else(|| missing_field::("transaction"))?; + .. + } = request.to_owned_message(); + let sidechain_id = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let transaction_bytes: Vec = transaction + .into_option() + .ok_or_else(|| missing_field::("transaction"))? + .value; let transaction: Transaction = bitcoin::consensus::deserialize(&transaction_bytes) .map_err(|err| { invalid_field_value::( @@ -310,100 +305,74 @@ impl WalletService for crate::wallet::Wallet { .map_err(|err| { invalid_field_value::( "transaction", - &hex::encode(transaction_bytes), + &hex::encode(&transaction_bytes), err, ) })?; let _m6id = self .put_withdrawal_bundle(sidechain_id, &transaction) .await - .map_err(|err| StatusBuilder::new(&err).to_status())?; - /* - self.broadcast_transaction(transaction.tx().into_owned()) - .await - .map_err(|err| err.builder().to_status())?; - */ - let response = BroadcastWithdrawalBundleResponse {}; - Ok(tonic::Response::new(response)) + .map_err(|err| StatusBuilder::new(&err).to_connect_error())?; + Ok(Response::new(BroadcastWithdrawalBundleResponse::default())) } // Legacy Bitcoin Core-based implementation // https://github.com/LayerTwo-Labs/mainchain/blob/05e71917042132202248c0c917f8ef120a2a5251/src/wallet/rpcwallet.cpp#L3863-L4008 async fn create_bmm_critical_data_transaction( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> - { - tracing::trace!("create_bmm_critical_data_transaction: starting"); + _ctx: RequestContext, + request: OwnedCreateBmmCriticalDataTransactionRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::CreateBmmCriticalDataTransactionRequest; let CreateBmmCriticalDataTransactionRequest { sidechain_id, value_sats, height, critical_hash, prev_bytes, - } = request.into_inner(); - - let amount = value_sats - .ok_or_else(|| missing_field::("value_sats")) - .map(bdk_wallet::bitcoin::Amount::from_sat) - .map_err(|err| { - invalid_field_value::( - "value_sats", - &value_sats.unwrap_or_default().to_string(), - err, - ) - })?; - - let locktime = height - .ok_or_else(|| missing_field::("height")) - .map(bdk_wallet::bitcoin::absolute::LockTime::from_height)? - .map_err(|err| { + .. + } = request.to_owned_message(); + let value_sats_raw = unwrap_u64(value_sats).ok_or_else(|| { + missing_field::("value_sats") + })?; + let amount = bdk_wallet::bitcoin::Amount::from_sat(value_sats_raw); + let height_raw = unwrap_u32(height) + .ok_or_else(|| missing_field::("height"))?; + let locktime = + bdk_wallet::bitcoin::absolute::LockTime::from_height(height_raw).map_err(|err| { invalid_field_value::( "height", - &height.unwrap_or_default().to_string(), - err, - ) - })?; - - let sidechain_number = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id")) - .map(SidechainNumber::try_from)? - .map_err(|err| { - invalid_field_value::( - "sidechain_id", - &sidechain_id.unwrap_or_default().to_string(), + &height_raw.to_string(), err, ) })?; + let sidechain_number = parse_sidechain_id::( + sidechain_id, + "sidechain_id", + )?; match self.is_sidechain_active(sidechain_number) { - Ok(false) => { - return Err(tonic::Status::failed_precondition( - "sidechain is not active", - )); - } + Ok(false) => return Err(ConnectError::failed_precondition("sidechain is not active")), Ok(true) => (), - Err(err) => return Err(tonic::Status::from_error(err.into())), + Err(err) => return Err(internal_err(err)), } // This is also called H* let critical_hash = critical_hash + .into_option() .ok_or_else(|| { missing_field::("critical_hash") })? - .decode_tonic::("critical_hash")?; - + .decode_status::("critical_hash")?; let prev_bytes = prev_bytes + .into_option() .ok_or_else(|| missing_field::("prev_bytes"))? - .decode_tonic::("prev_bytes") + .decode_status::("prev_bytes") .map(bdk_wallet::bitcoin::BlockHash::from_byte_array)?; tracing::trace!("create_bmm_critical_data_transaction: validated request"); - let mainchain_tip = self - .validator() - .get_mainchain_tip() - .map_err(|err| tonic::Status::from_error(err.into()))?; + let mainchain_tip = self.validator().get_mainchain_tip().map_err(internal_err)?; tracing::debug!( "create_bmm_critical_data_transaction: fetched mainchain tip: {:?}", @@ -413,9 +382,9 @@ impl WalletService for crate::wallet::Wallet { // If the mainchain tip has progressed beyond this, the request is already // expired. if mainchain_tip != convert::bdk_block_hash_to_bitcoin_block_hash(prev_bytes) { - let message = format!("invalid prev_bytes {prev_bytes}: expected {mainchain_tip}",); - - return Err(tonic::Status::invalid_argument(message)); + return Err(ConnectError::invalid_argument(format!( + "invalid prev_bytes {prev_bytes}: expected {mainchain_tip}" + ))); } let tx = self @@ -427,11 +396,10 @@ impl WalletService for crate::wallet::Wallet { locktime, ) .await - .map_err(|err| err.builder().to_status()) + .map_err(|err| err.builder().to_connect_error()) .and_then(|tx| { tx.ok_or_else(|| { - tonic::Status::new( - tonic::Code::AlreadyExists, + ConnectError::already_exists( "BMM request with same `sidechain_number` and `prev_bytes` already exists", ) }) @@ -443,120 +411,94 @@ impl WalletService for crate::wallet::Wallet { ); })?; - let txid = tx.compute_txid(); + let txid = convert::bdk_txid_to_bitcoin_txid(tx.compute_txid()); tracing::info!( "create_bmm_critical_data_transaction: created transaction: {:?}", txid ); - let txid = convert::bdk_txid_to_bitcoin_txid(txid); - - let response = CreateBmmCriticalDataTransactionResponse { - txid: Some(ReverseHex::encode(&txid)), - }; - Ok(tonic::Response::new(response)) + Ok(Response::new(CreateBmmCriticalDataTransactionResponse { + txid: MessageField::some(ReverseHex::encode(&txid)), + })) } async fn create_deposit_transaction( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedCreateDepositTransactionRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::CreateDepositTransactionRequest; let CreateDepositTransactionRequest { sidechain_id, address, value_sats, fee_sats, - } = request.into_inner(); - - let sidechain_number = sidechain_id - .ok_or_else(|| missing_field::("sidechain_id")) - .map(SidechainNumber::try_from)? - .map_err(|err| { - invalid_field_value::( - "sidechain_id", - &sidechain_id.unwrap_or_default().to_string(), - err, - ) - })?; - let address: String = - address.ok_or_else(|| missing_field::("address"))?; + .. + } = request.to_owned_message(); + let sidechain_number = + parse_sidechain_id::(sidechain_id, "sidechain_id")?; + let address: String = unwrap_string(address) + .ok_or_else(|| missing_field::("address"))?; if address.is_empty() { - return Err(invalid_field_value::( - "address", - &address, - Error::AddressMustBeNonEmpty, - )); + return Err(ConnectError::invalid_argument("address must be non-empty")); } - let value = value_sats - .ok_or_else(|| missing_field::("value_sats")) - .map(Amount::from_sat)?; + let value = Amount::from_sat( + unwrap_u64(value_sats) + .ok_or_else(|| missing_field::("value_sats"))?, + ); if value == Amount::ZERO { - return Err(invalid_field_value::( - "value_sats", - &value.to_string(), - Error::ValueMustBeGreaterThanZero, + return Err(ConnectError::invalid_argument( + "value_sats must be greater than zero", )); } - let fee = fee_sats - .ok_or_else(|| missing_field::("fee_sats")) - .map(Amount::from_sat)?; - + let fee = Amount::from_sat( + unwrap_u64(fee_sats) + .ok_or_else(|| missing_field::("fee_sats"))?, + ); if !self .is_sidechain_active(sidechain_number) - .map_err(|err| err.builder().to_status())? + .map_err(|err| err.builder().to_connect_error())? { - return Err(tonic::Status::new( - tonic::Code::FailedPrecondition, - format!("sidechain {sidechain_number} is not active"), - )); + return Err(ConnectError::failed_precondition(format!( + "sidechain {sidechain_number} is not active" + ))); } - let txid = self .create_deposit(sidechain_number, address, value, Some(fee)) .await - .map_err(|err| err.builder().to_status())?; + .map_err(|err| err.builder().to_connect_error())?; - let txid = ReverseHex::encode(&txid); - let response = CreateDepositTransactionResponse { txid: Some(txid) }; - Ok(tonic::Response::new(response)) + Ok(Response::new(CreateDepositTransactionResponse { + txid: MessageField::some(ReverseHex::encode(&txid)), + })) } async fn get_balance( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - tracing::trace!("get_balance: starting"); - let GetBalanceRequest {} = request.into_inner(); - - tracing::trace!("get_balance: fetching from BDK wallet"); - + _ctx: RequestContext, + _request: OwnedGetBalanceRequestView, + ) -> ServiceResult { let (balance, has_synced) = self .get_wallet_balance() .await - .map_err(|err| err.builder().to_status())?; - - tracing::trace!("get_balance: fetched balance: {:?}", balance); - - let response = GetBalanceResponse { + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(GetBalanceResponse { confirmed_sats: balance.confirmed.to_sat(), pending_sats: (balance.total() - balance.confirmed).to_sat(), has_synced, - }; - - Ok(tonic::Response::new(response)) + })) } async fn list_unspent_outputs( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let ListUnspentOutputsRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedListUnspentOutputsRequestView, + ) -> ServiceResult { let bdk_utxos = self .get_utxos() .await - .map_err(|err| err.builder().to_status())?; - + .map_err(|err| err.builder().to_connect_error())?; let outputs = bdk_utxos .into_iter() .map(|utxo| { @@ -572,14 +514,13 @@ impl WalletService for crate::wallet::Wallet { bdk_wallet::chain::ChainPosition::Unconfirmed { last_seen, first_seen: _, - } => last_seen.map(|last_seen| prost_types::Timestamp { - seconds: last_seen as i64, - nanos: 0, - }), - bdk_wallet::chain::ChainPosition::Confirmed { .. } => None, + } => last_seen + .map(|s| wrap_timestamp(s as i64)) + .unwrap_or_default(), + bdk_wallet::chain::ChainPosition::Confirmed { .. } => MessageField::none(), }; list_unspent_outputs_response::Output { - txid: Some(ReverseHex::encode(&utxo.outpoint.txid)), + txid: MessageField::some(ReverseHex::encode(&utxo.outpoint.txid)), vout: utxo.outpoint.vout, value_sats: utxo.txout.value.to_sat(), is_internal: utxo.keychain == bdk_wallet::KeychainKind::Internal, @@ -587,90 +528,90 @@ impl WalletService for crate::wallet::Wallet { confirmed_at_block: chain_position .map(|(anchor, _)| anchor.block_id.height) .unwrap_or_default(), - confirmed_at_time: chain_position.map(|(anchor, _)| prost_types::Timestamp { - seconds: anchor.confirmation_time as i64, - nanos: 0, - }), + confirmed_at_time: chain_position + .map(|(anchor, _)| wrap_timestamp(anchor.confirmation_time as i64)) + .unwrap_or_default(), confirmed_transitively: chain_position - .and_then(|(_, transitively)| transitively) - .map(|transitively| ReverseHex::encode(&transitively)), + .and_then(|(_, t)| t) + .map(|t| MessageField::some(ReverseHex::encode(&t))) + .unwrap_or_default(), unconfirmed_last_seen, address: Address::from_script( utxo.txout.script_pubkey.as_script(), self.validator().network(), ) - .map(|addr| addr.to_string()) - .ok(), + .map(|addr| crate::proto::wrap_string(addr.to_string())) + .unwrap_or_default(), } }) .collect(); - Ok(tonic::Response::new(ListUnspentOutputsResponse { outputs })) + Ok(Response::new(ListUnspentOutputsResponse { outputs })) } async fn list_sidechain_deposit_transactions( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let ListSidechainDepositTransactionsRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedListSidechainDepositTransactionsRequestView, + ) -> ServiceResult { let transactions = self .list_sidechain_deposit_transactions() .await - .map_err(|err| err.builder().to_status())? + .map_err(|err| err.builder().to_connect_error())? .into_iter() - .map(|sidechain_deposit_tx| SidechainDepositTransaction { - sidechain_number: Some(sidechain_deposit_tx.sidechain_number.0.into()), - tx: Some(WalletTransaction::from(&sidechain_deposit_tx.wallet_tx)), + .map(|sdt| SidechainDepositTransaction { + sidechain_number: wrap_u32(sdt.sidechain_number.0 as u32), + tx: MessageField::some(WalletTransaction::from(&sdt.wallet_tx)), }) .collect(); - let response = ListSidechainDepositTransactionsResponse { transactions }; - Ok(tonic::Response::new(response)) + Ok(Response::new(ListSidechainDepositTransactionsResponse { + transactions, + })) } async fn list_transactions( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let ListTransactionsRequest {} = request.into_inner(); + _ctx: RequestContext, + _request: OwnedListTransactionsRequestView, + ) -> ServiceResult { let transactions = self .list_wallet_transactions() .await - .map_err(|err| err.builder().to_status())?; - - let response = ListTransactionsResponse { + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(ListTransactionsResponse { transactions: transactions.iter().map(WalletTransaction::from).collect(), - }; - Ok(tonic::Response::new(response)) + })) } async fn send_transaction( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedSendTransactionRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::SendTransactionRequest; let SendTransactionRequest { destinations, fee_rate, op_return_message, required_utxos, drain_wallet_to, - } = request.into_inner(); + .. + } = request.to_owned_message(); let required_utxos = required_utxos - .iter() + .into_iter() .map(|utxo| { let txid = utxo .txid - .as_ref() - .ok_or_else(|| missing_field::("txid"))?; - - let txid = txid.clone().decode_tonic::("txid")?; - + .into_option() + .ok_or_else(|| missing_field::("txid"))? + .decode_status::("txid")?; Ok(bdk_wallet::bitcoin::OutPoint { txid, vout: utxo.vout, }) }) - .collect::, tonic::Status>>()?; + .collect::, ConnectError>>()?; // Parse and validate all destination addresses, but assume network valid let destinations_validated = destinations @@ -682,43 +623,42 @@ impl WalletService for crate::wallet::Wallet { let amount = Amount::from_sat(*amount); if amount.is_dust(&address.script_pubkey()) { - return Err(tonic::Status::invalid_argument(format!( - "amount is below dust limit: {amount} to {address}", + return Err(ConnectError::invalid_argument(format!( + "amount is below dust limit: {amount} to {address}" ))); } Ok((address, amount)) }) - .collect::, tonic::Status>>()?; + .collect::, ConnectError>>()?; if destinations_validated.is_empty() - && op_return_message.is_none() + && !op_return_message.is_set() && drain_wallet_to.is_none() { - return Err(tonic::Status::invalid_argument( + return Err(ConnectError::invalid_argument( "no destinations or op_return_message provided", )); } let drain_wallet_to = drain_wallet_to - .map(|drain_wallet_to| self.parse_checked_address(&drain_wallet_to)) + .map(|s| self.parse_checked_address(&s)) .transpose()?; if drain_wallet_to.is_some() && !required_utxos.is_empty() { - return Err(tonic::Status::invalid_argument( + return Err(ConnectError::invalid_argument( "cannot provide both drain_wallet_to and required_utxos", )); } let fee_policy = fee_rate + .into_option() .map(|fee_rate| fee_rate.try_into()) - .transpose() - .map_err(|err: crate::proto::Error| err.builder().to_status())?; + .transpose()?; let op_return_message = op_return_message - .map(|op_return_message| { - op_return_message.decode_tonic::("op_return_message") - }) + .into_option() + .map(|m| m.decode_status::("op_return_message")) .transpose()?; let txid = self @@ -732,67 +672,56 @@ impl WalletService for crate::wallet::Wallet { }, ) .await - .map_err(|err| err.builder().to_status())?; - - let txid = ReverseHex::encode(&txid); - let response = SendTransactionResponse { txid: Some(txid) }; - Ok(tonic::Response::new(response)) + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(SendTransactionResponse { + txid: MessageField::some(ReverseHex::encode(&txid)), + })) } async fn unlock_wallet( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - let UnlockWalletRequest { password } = request.into_inner(); + _ctx: RequestContext, + request: OwnedUnlockWalletRequestView, + ) -> ServiceResult { + use crate::proto::mainchain::UnlockWalletRequest; + let UnlockWalletRequest { password, .. } = request.to_owned_message(); self.unlock_existing_wallet(password.as_str()) .await - .map_err(|err| err.builder().to_status())?; - - Ok(tonic::Response::new(UnlockWalletResponse {})) + .map_err(|err| err.builder().to_connect_error())?; + Ok(Response::new(UnlockWalletResponse::default())) } async fn create_wallet( &self, - request: tonic::Request, - ) -> Result, tonic::Status> { + _ctx: RequestContext, + request: OwnedCreateWalletRequestView, + ) -> ServiceResult { // TODO: needs a way of creating /multiple/ wallets. RPC for unloading/erasing a wallet? if self.is_initialized().await { let err = WalletInitialization::AlreadyExists; - return Err(tonic::Status::new( - tonic::Code::AlreadyExists, - format!("{err:#}"), - )); + return Err(ConnectError::already_exists(format!("{err:#}"))); } - + use crate::proto::mainchain::CreateWalletRequest; let CreateWalletRequest { mut mnemonic_words, mnemonic_path, password, - } = request.into_inner(); - + } = request.to_owned_message(); if !mnemonic_words.is_empty() && !mnemonic_path.is_empty() { - return Err(tonic::Status::new( - tonic::Code::InvalidArgument, + return Err(ConnectError::invalid_argument( "cannot provide both mnemonic and mnemonic path", )); } - if !mnemonic_path.is_empty() { let read = std::fs::read_to_string(&mnemonic_path).map_err(|err| { - tonic::Status::new( - tonic::Code::InvalidArgument, - format!("failed to read mnemonic from {mnemonic_path}: {err:#}"), - ) + ConnectError::invalid_argument(format!( + "failed to read mnemonic from {mnemonic_path}: {err:#}" + )) })?; - mnemonic_words = read.split_whitespace().map(|s| s.to_string()).collect(); } - if !mnemonic_words.is_empty() && mnemonic_words.len() != 12 { - return Err(tonic::Status::new( - tonic::Code::InvalidArgument, - "mnemonic must be 12 words", - )); + return Err(ConnectError::invalid_argument("mnemonic must be 12 words")); } let parsed = if mnemonic_words.is_empty() { @@ -800,10 +729,7 @@ impl WalletService for crate::wallet::Wallet { } else { Some( Mnemonic::from_str(&mnemonic_words.join(" ")).map_err(|err| { - tonic::Status::new( - tonic::Code::InvalidArgument, - format!("failed to parse mnemonic: {err:#}"), - ) + ConnectError::invalid_argument(format!("failed to parse mnemonic: {err:#}")) })?, ) }; @@ -816,17 +742,8 @@ impl WalletService for crate::wallet::Wallet { self.create_wallet(parsed, password) .await - .map_err(|err| err.builder().to_status())?; + .map_err(|err| err.builder().to_connect_error())?; - Ok(tonic::Response::new(CreateWalletResponse {})) + Ok(Response::new(CreateWalletResponse::default())) } } - -#[derive(Debug, Error)] -enum Error { - #[error("value must be greater than zero")] - ValueMustBeGreaterThanZero, - - #[error("address must be non-empty")] - AddressMustBeNonEmpty, -} diff --git a/lib/server/wallet/json_rpc.rs b/lib/server/wallet/json_rpc.rs deleted file mode 100644 index 5deef098..00000000 --- a/lib/server/wallet/json_rpc.rs +++ /dev/null @@ -1,69 +0,0 @@ -use bitcoin::{BlockHash, Txid}; -use futures::TryFutureExt as _; -use jsonrpsee::{ - core::{RpcResult, async_trait}, - proc_macros::rpc, -}; -use thiserror::Error; - -use crate::{ - server::custom_json_rpc_err, - types::{BmmCommitment, SidechainNumber}, - wallet::SidechainDepositTransaction, -}; - -#[derive(Debug, Error)] -#[error("BMM request with same sidechain number and previous block hash already exists")] -struct BmmRequestAlreadyExistsError; - -#[rpc(namespace = "wallet", namespace_separator = ".", server)] -pub trait Rpc { - #[method(name = "list_sidechain_deposit_transactions")] - async fn list_sidechain_deposit_transactions( - &self, - ) -> RpcResult>; - - #[method(name = "create_bmm_critical_data_transaction")] - async fn create_bmm_critical_data_transaction( - &self, - sidechain_id: SidechainNumber, - value_sats: u64, - lock_time: bitcoin::absolute::LockTime, - critical_hash: BmmCommitment, - prev_block_hash: BlockHash, - ) -> RpcResult; -} - -#[async_trait] -impl RpcServer for crate::wallet::Wallet { - async fn list_sidechain_deposit_transactions( - &self, - ) -> RpcResult> { - self.list_sidechain_deposit_transactions() - .map_err(custom_json_rpc_err) - .await - } - - async fn create_bmm_critical_data_transaction( - &self, - sidechain_id: SidechainNumber, - value_sats: u64, - lock_time: bitcoin::absolute::LockTime, - critical_hash: BmmCommitment, - prev_block_hash: BlockHash, - ) -> RpcResult { - let amount = bdk_wallet::bitcoin::Amount::from_sat(value_sats); - let tx = self - .create_bmm_request( - sidechain_id, - prev_block_hash, - critical_hash, - amount, - lock_time, - ) - .await - .map_err(custom_json_rpc_err)? - .ok_or_else(|| custom_json_rpc_err(BmmRequestAlreadyExistsError))?; - Ok(tx.compute_txid()) - } -} diff --git a/lib/server/wallet/mod.rs b/lib/server/wallet/mod.rs index 11067849..a1a9ee3d 100644 --- a/lib/server/wallet/mod.rs +++ b/lib/server/wallet/mod.rs @@ -2,4 +2,3 @@ pub use crate::server::validator::Server as Validator; mod grpc; -pub mod json_rpc; diff --git a/lib/wallet/error.rs b/lib/wallet/error.rs index 8ea43d04..f823f413 100644 --- a/lib/wallet/error.rs +++ b/lib/wallet/error.rs @@ -30,8 +30,8 @@ impl ToStatus for Electrum { fn builder(&self) -> StatusBuilder<'_> { StatusBuilder::new(self).code(match self.code { // https://github.com/bitcoin/bitcoin/blob/e8f72aefd20049eac81b150e7f0d33709acd18ed/src/common/messages.cpp - -25 => tonic::Code::InvalidArgument, - _ => tonic::Code::Unknown, + -25 => connectrpc::ErrorCode::InvalidArgument, + _ => connectrpc::ErrorCode::Unknown, }) } } @@ -44,22 +44,6 @@ pub struct Esplora { message: String, } -// Add new TonicStatusError type -#[derive(Clone, Debug, Diagnostic, Error)] -#[error("tonic error: {0}")] -pub struct TonicStatus(#[from] tonic::Status); - -// Add extension trait for tonic::Status -pub trait TonicStatusExt { - fn into_diagnostic(self) -> miette::Result<()>; -} - -impl TonicStatusExt for tonic::Status { - fn into_diagnostic(self) -> miette::Result<()> { - Err(TonicStatus(self).into()) - } -} - /// Wallet not synced #[derive(Debug, Diagnostic, Error)] #[diagnostic(code(wallet_not_synced))] @@ -129,12 +113,12 @@ pub enum WalletInitialization { impl ToStatus for WalletInitialization { fn builder(&self) -> StatusBuilder<'_> { StatusBuilder::new(self).code(match self { - Self::NotSynced(_) => tonic::Code::FailedPrecondition, - Self::InvalidPassword => tonic::Code::InvalidArgument, - Self::DataMismatch(_) => tonic::Code::Internal, - Self::NotFound => tonic::Code::NotFound, - Self::AlreadyExists => tonic::Code::AlreadyExists, - Self::AlreadyUnlocked => tonic::Code::AlreadyExists, + Self::NotSynced(_) => connectrpc::ErrorCode::FailedPrecondition, + Self::InvalidPassword => connectrpc::ErrorCode::InvalidArgument, + Self::DataMismatch(_) => connectrpc::ErrorCode::Internal, + Self::NotFound => connectrpc::ErrorCode::NotFound, + Self::AlreadyExists => connectrpc::ErrorCode::AlreadyExists, + Self::AlreadyUnlocked => connectrpc::ErrorCode::AlreadyExists, }) } } @@ -568,7 +552,7 @@ impl ToStatus for BitcoinCoreRPC { // loaded with the /bitcoin core/ wallet not being loaded. let err_msg = "the underlying Bitcoin Core node has no loaded wallet (fix this: `bitcoin-cli loadwallet WALLET_NAME`)"; StatusBuilder { - code: tonic::Code::FailedPrecondition, + code: connectrpc::ErrorCode::FailedPrecondition, fmt_message: Box::new(|f| err_msg.fmt(f)), source: None, } @@ -1043,9 +1027,9 @@ pub struct MissingBinary { impl ToStatus for MissingBinary { fn builder(&self) -> StatusBuilder<'_> { StatusBuilder::new(self).code(if self.source.is_some() { - tonic::Code::Internal + connectrpc::ErrorCode::Internal } else { - tonic::Code::FailedPrecondition + connectrpc::ErrorCode::FailedPrecondition }) } } @@ -1074,10 +1058,10 @@ impl ToStatus for VerifyCanMine { Self::BitcoinCoreRPC(err) => err.builder(), Self::MissingBinary(err) => err.builder(), Self::MultipleBlocksOnSignet => { - StatusBuilder::new(self).code(tonic::Code::InvalidArgument) + StatusBuilder::new(self).code(connectrpc::ErrorCode::InvalidArgument) } Self::Network(_) | Self::SignetChallengeAddressMissing(_) => { - StatusBuilder::new(self).code(tonic::Code::FailedPrecondition) + StatusBuilder::new(self).code(connectrpc::ErrorCode::FailedPrecondition) } Self::NoSignetChallengeFound | Self::ParseSignetChallenge(_) => { StatusBuilder::new(self) @@ -1251,7 +1235,9 @@ pub enum CreateSendPsbt { impl ToStatus for CreateSendPsbt { fn builder(&self) -> StatusBuilder<'_> { match self { - Self::UnknownUTXO(_) => StatusBuilder::new(self).code(tonic::Code::InvalidArgument), + Self::UnknownUTXO(_) => { + StatusBuilder::new(self).code(connectrpc::ErrorCode::InvalidArgument) + } Self::NotUnlocked(err) => err.builder(), Self::CreateTx(err) => StatusBuilder::new(err), Self::Script(err) => StatusBuilder::new(err), diff --git a/lib/wallet/mod.rs b/lib/wallet/mod.rs index 9e16ae7d..8820440f 100644 --- a/lib/wallet/mod.rs +++ b/lib/wallet/mod.rs @@ -817,14 +817,14 @@ impl Wallet { pub(crate) fn parse_checked_address( &self, address: &str, - ) -> Result { + ) -> Result { let network = self.validator().network(); let address = bdk_wallet::bitcoin::Address::from_str(address).map_err(|err| { - tonic::Status::invalid_argument(format!("invalid bitcoin address: {err:#}")) + connectrpc::ConnectError::invalid_argument(format!("invalid bitcoin address: {err:#}")) })?; let address = address.require_network(network).map_err(|_| { - tonic::Status::invalid_argument(format!( + connectrpc::ConnectError::invalid_argument(format!( "bitcoin address is not valid for network `{network}`", )) })?;