1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

feat(rust): move trezor-client build script to separate crate (#3154)

This commit is contained in:
DaniPopes 2023-09-29 20:13:00 +02:00 committed by GitHub
parent bd1d0822b3
commit 6e93532b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 91318 additions and 240 deletions

View File

@ -118,11 +118,13 @@ icons: ## generate FIDO service icons
icons_check: ## generate FIDO service icons
python3 core/tools/build_icons.py --check
protobuf: ## generate python protobuf headers
protobuf: ## generate python and rust protobuf headers
./tools/build_protobuf
./rust/trezor-client/scripts/build_protos
protobuf_check: ## check that generated protobuf headers are up to date
./tools/build_protobuf --check
./rust/trezor-client/scripts/build_protos --check
ci_docs: ## generate CI documentation
./tools/generate_ci_docs.py

View File

@ -4,18 +4,18 @@ version = 3
[[package]]
name = "aho-corasick"
version = "1.0.2"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.71"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "autocfg"
@ -31,9 +31,9 @@ checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445"
[[package]]
name = "bitcoin"
version = "0.30.0"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b36f4c848f6bd9ff208128f08751135846cc23ae57d66ab10a22efff1c675f3c"
checksum = "4e99ff7289b20a7385f66a0feda78af2fc119d28fb56aea8886a9cd0a4abdd75"
dependencies = [
"bech32",
"bitcoin-private",
@ -63,6 +63,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "byteorder"
version = "1.4.3"
@ -71,9 +77,12 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cc"
version = "1.0.79"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cfg-if"
@ -89,12 +98,12 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "dashmap"
version = "5.4.0"
version = "5.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [
"cfg-if",
"hashbrown",
"hashbrown 0.14.1",
"lock_api",
"once_cell",
"parking_lot_core",
@ -102,15 +111,15 @@ dependencies = [
[[package]]
name = "either"
version = "1.8.1"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "errno"
version = "0.3.1"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
@ -129,12 +138,9 @@ dependencies = [
[[package]]
name = "fastrand"
version = "1.9.0"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
dependencies = [
"instant",
]
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "fixed-hash"
@ -229,10 +235,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.3.1"
name = "hashbrown"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12"
[[package]]
name = "hex"
@ -246,6 +252,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
[[package]]
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys",
]
[[package]]
name = "indexmap"
version = "1.9.3"
@ -253,27 +268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "io-lifetimes"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi",
"libc",
"windows-sys",
"hashbrown 0.12.3",
]
[[package]]
@ -284,9 +279,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.146"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "libusb1-sys"
@ -302,9 +297,9 @@ dependencies = [
[[package]]
name = "linux-raw-sys"
version = "0.3.8"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
[[package]]
name = "lock_api"
@ -318,15 +313,15 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.19"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "nu-ansi-term"
@ -375,9 +370,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
version = "0.2.9"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
@ -403,9 +398,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.60"
version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
dependencies = [
"unicode-ident",
]
@ -463,9 +458,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.28"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -476,14 +471,26 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
dependencies = [
"bitflags",
"bitflags 1.3.2",
]
[[package]]
name = "regex"
version = "1.8.4"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
dependencies = [
"aho-corasick",
"memchr",
@ -492,15 +499,15 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.7.2"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "rusb"
version = "0.9.2"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44a8c36914f9b1a3be712c1dfa48c9b397131f9a75707e570a391735f785c5d1"
checksum = "45fff149b6033f25e825cbb7b2c625a11ee8e6dac09264d49beb125e39aa97bf"
dependencies = [
"libc",
"libusb1-sys",
@ -508,13 +515,12 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.37.20"
version = "0.38.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0"
checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f"
dependencies = [
"bitflags",
"bitflags 2.4.0",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
@ -522,9 +528,9 @@ dependencies = [
[[package]]
name = "scopeguard"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "secp256k1"
@ -572,27 +578,27 @@ dependencies = [
[[package]]
name = "sharded-slab"
version = "0.1.4"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b"
dependencies = [
"lazy_static",
]
[[package]]
name = "slab"
version = "0.4.8"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
[[package]]
name = "smallvec"
version = "1.10.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "static_assertions"
@ -602,9 +608,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "2.0.18"
version = "2.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
dependencies = [
"proc-macro2",
"quote",
@ -613,11 +619,10 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.6.0"
version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6"
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
dependencies = [
"autocfg",
"cfg-if",
"fastrand",
"redox_syscall",
@ -627,18 +632,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.40"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.40"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
dependencies = [
"proc-macro2",
"quote",
@ -737,7 +742,6 @@ dependencies = [
"hex",
"primitive-types",
"protobuf",
"protobuf-codegen",
"rusb",
"serial_test",
"thiserror",
@ -746,6 +750,13 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "trezor-client-build"
version = "0.0.0"
dependencies = [
"protobuf-codegen",
]
[[package]]
name = "uint"
version = "0.9.5"
@ -760,9 +771,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.9"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
@ -787,13 +798,14 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "which"
version = "4.4.0"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"libc",
"home",
"once_cell",
"rustix",
]
[[package]]
@ -829,9 +841,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@ -844,42 +856,42 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View File

@ -15,12 +15,24 @@ description = "Client library for interfacing with Trezor hardware wallet device
keywords = ["ethereum", "bitcoin", "trezor", "wallet"]
categories = ["api-bindings", "cryptography::cryptocurrencies"]
readme = "README.md"
exclude = [".github/", ".vscode/", "examples/", "scripts/", "trezor-common/", "rustfmt.toml"]
exclude = [".github/", "examples/", "scripts/", ".clippy.toml", ".gitignore", "rustfmt.toml"]
edition = "2021"
rust-version = "1.60"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[workspace]
members = ["build", "."]
[workspace.dependencies]
# important: keep in sync
protobuf = "=3.2.0"
protobuf-codegen = "=3.2.0"
[dependencies]
protobuf = "3.2"
protobuf.workspace = true
byteorder = "1.4"
rusb = "0.9"
@ -35,9 +47,6 @@ unicode-normalization = { version = "0.1.22", optional = true }
# ethereum
primitive-types = { version = "0.12", default-features = false, optional = true }
[build-dependencies]
protobuf-codegen = "3.2.0"
[dev-dependencies]
tracing-subscriber = "0.3"
serial_test = "2.0.0"

View File

@ -1,26 +0,0 @@
use std::{fs, path::PathBuf};
fn main() {
let proto_path = "protob";
let protos: Vec<PathBuf> = fs::read_dir(proto_path)
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() && path.extension().map_or(false, |ext| ext == "proto") {
Some(path)
} else {
None
}
})
.collect();
let out_path = std::env::var("OUT_DIR").unwrap();
let out_dir = PathBuf::from(out_path).join("protos");
fs::create_dir_all(&out_dir).expect("Failed to create output directory");
protobuf_codegen::Codegen::new()
.protoc()
.includes(&[proto_path])
.inputs(protos)
.out_dir(out_dir)
.run_from_script();
}

View File

@ -0,0 +1,8 @@
[package]
name = "trezor-client-build"
version = "0.0.0"
description = "Builds Trezor protobuf bindings for trezor-client"
publish = false
[dependencies]
protobuf-codegen.workspace = true

View File

@ -0,0 +1,7 @@
# trezor-client-build
Simple build script for [`trezor-client`](../).
Builds the Rust bindings for the [Trezor protobufs](../../../common/protob/).
This crate is separate from the main crate to avoid dependencies on the
protobuf compiler (`protoc`) and the `protobuf-codegen` crate in `trezor-client`.

View File

@ -0,0 +1,34 @@
use std::{
fs,
path::{Path, PathBuf},
};
fn main() {
let proto_path = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../common/protob");
let proto_dir = Path::new(proto_path).canonicalize().unwrap();
let protos: Vec<PathBuf> = fs::read_dir(&proto_dir)
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() && path.extension().map_or(false, |ext| ext == "proto") {
Some(path)
} else {
None
}
})
.collect();
let out_path = std::env::args().skip(1).next().expect("No output directory given");
let out_dir = PathBuf::from(out_path);
fs::create_dir_all(&out_dir).expect("Failed to create output directory");
protobuf_codegen::Codegen::new()
.protoc()
.includes(&[proto_dir])
.inputs(protos)
.out_dir(&out_dir)
.run_from_script();
// Remove mod.rs because we want to feature-gate some modules manually
fs::remove_file(out_dir.join("mod.rs")).expect("Failed to remove mod.rs");
}

View File

@ -1 +0,0 @@
../../common/protob

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# Generates the `trezor_message_impl!` macro calls for the `src/messages.rs` file.
# Generates the `trezor_message_impl!` macro calls for the `src/messages/mod.rs` file.
from os import path
@ -30,7 +30,7 @@ FEATURES = {
"WebAuthn": "webauthn",
}
MACRO = "trezor_message_impl"
INDENT = "\t"
INDENT = " "
def main():

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Generates src/protos/generated and src/messages/generated.rs
crate_root="$(dirname "$(dirname "$(realpath "$0")")")"
protos="$crate_root/src/protos/generated"
messages="$crate_root/src/messages/generated.rs"
if [ "$1" = "--check" ]; then
protos_out=$(mktemp -d)
messages_out=$(mktemp)
else
protos_out=$protos
messages_out=$messages
fi
cargo run --manifest-path "$crate_root/build/Cargo.toml" -- "$protos_out"
"$crate_root/scripts/build_messages" > "$messages_out"
rustfmt "$messages_out"
if [ "$1" = "--check" ]; then
set -e
diff -ur "$protos_out" "$protos"
diff -ur "$messages_out" "$messages"
fi

View File

@ -1,16 +0,0 @@
#!/bin/sh
# Generates src/protos/
# Requires the `protoc-gen-rust` binary (`cargo install protoc-gen-rust`).
# Overwrites src/protos/mod.rs, but the change should not be committed, and
# instead should be handled manually.
crate_root="$(dirname "$(dirname "$(realpath "$0")")")"
main_root="$(dirname $(dirname "$crate_root"))"
out_dir="$crate_root/src/protos"
proto_dir="$main_root/common/protob"
protoc \
--proto_path "$proto_dir" \
--rust_out "$out_dir" \
"$proto_dir"/*.proto

View File

@ -12,6 +12,7 @@
//! Please be aware that `trace` logging can contain sensitive data.
#![warn(rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod messages;
mod transport;

View File

@ -1,28 +1,3 @@
//! This module implements the `message_type` getter for all protobuf message types.
use crate::protos::{MessageType::*, *};
/// Extends the protobuf Message trait to also have a static getter for the message
/// type code.
pub trait TrezorMessage: protobuf::Message + std::fmt::Debug {
const MESSAGE_TYPE: MessageType;
#[inline]
#[deprecated(note = "Use `MESSAGE_TYPE` instead")]
fn message_type() -> MessageType {
Self::MESSAGE_TYPE
}
}
/// This macro provides the TrezorMessage trait for a protobuf message.
macro_rules! trezor_message_impl {
($($struct:ident => $mtype:expr),+ $(,)?) => {$(
impl TrezorMessage for $struct {
const MESSAGE_TYPE: MessageType = $mtype;
}
)+};
}
trezor_message_impl! {
Initialize => MessageType_Initialize,
Ping => MessageType_Ping,
@ -66,6 +41,10 @@ trezor_message_impl! {
FirmwareHash => MessageType_FirmwareHash,
UnlockPath => MessageType_UnlockPath,
UnlockedPathRequest => MessageType_UnlockedPathRequest,
ShowDeviceTutorial => MessageType_ShowDeviceTutorial,
UnlockBootloader => MessageType_UnlockBootloader,
AuthenticateDevice => MessageType_AuthenticateDevice,
AuthenticityProof => MessageType_AuthenticityProof,
SetU2FCounter => MessageType_SetU2FCounter,
GetNextU2FCounter => MessageType_GetNextU2FCounter,
NextU2FCounter => MessageType_NextU2FCounter,

View File

@ -0,0 +1,26 @@
//! This module implements the `message_type` getter for all protobuf message types.
use crate::protos::{MessageType::*, *};
/// Extends the protobuf Message trait to also have a static getter for the message
/// type code.
pub trait TrezorMessage: protobuf::Message + std::fmt::Debug {
const MESSAGE_TYPE: MessageType;
#[inline]
#[deprecated(note = "Use `MESSAGE_TYPE` instead")]
fn message_type() -> MessageType {
Self::MESSAGE_TYPE
}
}
/// This macro provides the TrezorMessage trait for a protobuf message.
macro_rules! trezor_message_impl {
($($struct:ident => $mtype:expr),+ $(,)?) => {$(
impl TrezorMessage for $struct {
const MESSAGE_TYPE: MessageType = $mtype;
}
)+};
}
include!("./generated.rs");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,768 @@
// This file is generated by rust-protobuf 3.2.0. Do not edit
// .proto file is parsed by protoc 3.19.6
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_results)]
#![allow(unused_mut)]
//! Generated file from `messages-bootloader.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0;
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.bootloader.FirmwareErase)
pub struct FirmwareErase {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.FirmwareErase.length)
pub length: ::std::option::Option<u32>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.bootloader.FirmwareErase.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a FirmwareErase {
fn default() -> &'a FirmwareErase {
<FirmwareErase as ::protobuf::Message>::default_instance()
}
}
impl FirmwareErase {
pub fn new() -> FirmwareErase {
::std::default::Default::default()
}
// optional uint32 length = 1;
pub fn length(&self) -> u32 {
self.length.unwrap_or(0)
}
pub fn clear_length(&mut self) {
self.length = ::std::option::Option::None;
}
pub fn has_length(&self) -> bool {
self.length.is_some()
}
// Param is passed by value, moved
pub fn set_length(&mut self, v: u32) {
self.length = ::std::option::Option::Some(v);
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(1);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"length",
|m: &FirmwareErase| { &m.length },
|m: &mut FirmwareErase| { &mut m.length },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<FirmwareErase>(
"FirmwareErase",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for FirmwareErase {
const NAME: &'static str = "FirmwareErase";
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
8 => {
self.length = ::std::option::Option::Some(is.read_uint32()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.length {
my_size += ::protobuf::rt::uint32_size(1, v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.length {
os.write_uint32(1, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> FirmwareErase {
FirmwareErase::new()
}
fn clear(&mut self) {
self.length = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static FirmwareErase {
static instance: FirmwareErase = FirmwareErase {
length: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for FirmwareErase {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("FirmwareErase").unwrap()).clone()
}
}
impl ::std::fmt::Display for FirmwareErase {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for FirmwareErase {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.bootloader.FirmwareRequest)
pub struct FirmwareRequest {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.FirmwareRequest.offset)
pub offset: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.FirmwareRequest.length)
pub length: ::std::option::Option<u32>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.bootloader.FirmwareRequest.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a FirmwareRequest {
fn default() -> &'a FirmwareRequest {
<FirmwareRequest as ::protobuf::Message>::default_instance()
}
}
impl FirmwareRequest {
pub fn new() -> FirmwareRequest {
::std::default::Default::default()
}
// required uint32 offset = 1;
pub fn offset(&self) -> u32 {
self.offset.unwrap_or(0)
}
pub fn clear_offset(&mut self) {
self.offset = ::std::option::Option::None;
}
pub fn has_offset(&self) -> bool {
self.offset.is_some()
}
// Param is passed by value, moved
pub fn set_offset(&mut self, v: u32) {
self.offset = ::std::option::Option::Some(v);
}
// required uint32 length = 2;
pub fn length(&self) -> u32 {
self.length.unwrap_or(0)
}
pub fn clear_length(&mut self) {
self.length = ::std::option::Option::None;
}
pub fn has_length(&self) -> bool {
self.length.is_some()
}
// Param is passed by value, moved
pub fn set_length(&mut self, v: u32) {
self.length = ::std::option::Option::Some(v);
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(2);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"offset",
|m: &FirmwareRequest| { &m.offset },
|m: &mut FirmwareRequest| { &mut m.offset },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"length",
|m: &FirmwareRequest| { &m.length },
|m: &mut FirmwareRequest| { &mut m.length },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<FirmwareRequest>(
"FirmwareRequest",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for FirmwareRequest {
const NAME: &'static str = "FirmwareRequest";
fn is_initialized(&self) -> bool {
if self.offset.is_none() {
return false;
}
if self.length.is_none() {
return false;
}
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
8 => {
self.offset = ::std::option::Option::Some(is.read_uint32()?);
},
16 => {
self.length = ::std::option::Option::Some(is.read_uint32()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.offset {
my_size += ::protobuf::rt::uint32_size(1, v);
}
if let Some(v) = self.length {
my_size += ::protobuf::rt::uint32_size(2, v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.offset {
os.write_uint32(1, v)?;
}
if let Some(v) = self.length {
os.write_uint32(2, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> FirmwareRequest {
FirmwareRequest::new()
}
fn clear(&mut self) {
self.offset = ::std::option::Option::None;
self.length = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static FirmwareRequest {
static instance: FirmwareRequest = FirmwareRequest {
offset: ::std::option::Option::None,
length: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for FirmwareRequest {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("FirmwareRequest").unwrap()).clone()
}
}
impl ::std::fmt::Display for FirmwareRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for FirmwareRequest {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.bootloader.FirmwareUpload)
pub struct FirmwareUpload {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.FirmwareUpload.payload)
pub payload: ::std::option::Option<::std::vec::Vec<u8>>,
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.FirmwareUpload.hash)
pub hash: ::std::option::Option<::std::vec::Vec<u8>>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.bootloader.FirmwareUpload.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a FirmwareUpload {
fn default() -> &'a FirmwareUpload {
<FirmwareUpload as ::protobuf::Message>::default_instance()
}
}
impl FirmwareUpload {
pub fn new() -> FirmwareUpload {
::std::default::Default::default()
}
// required bytes payload = 1;
pub fn payload(&self) -> &[u8] {
match self.payload.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_payload(&mut self) {
self.payload = ::std::option::Option::None;
}
pub fn has_payload(&self) -> bool {
self.payload.is_some()
}
// Param is passed by value, moved
pub fn set_payload(&mut self, v: ::std::vec::Vec<u8>) {
self.payload = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_payload(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.payload.is_none() {
self.payload = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.payload.as_mut().unwrap()
}
// Take field
pub fn take_payload(&mut self) -> ::std::vec::Vec<u8> {
self.payload.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
// optional bytes hash = 2;
pub fn hash(&self) -> &[u8] {
match self.hash.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_hash(&mut self) {
self.hash = ::std::option::Option::None;
}
pub fn has_hash(&self) -> bool {
self.hash.is_some()
}
// Param is passed by value, moved
pub fn set_hash(&mut self, v: ::std::vec::Vec<u8>) {
self.hash = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_hash(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.hash.is_none() {
self.hash = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.hash.as_mut().unwrap()
}
// Take field
pub fn take_hash(&mut self) -> ::std::vec::Vec<u8> {
self.hash.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(2);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"payload",
|m: &FirmwareUpload| { &m.payload },
|m: &mut FirmwareUpload| { &mut m.payload },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"hash",
|m: &FirmwareUpload| { &m.hash },
|m: &mut FirmwareUpload| { &mut m.hash },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<FirmwareUpload>(
"FirmwareUpload",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for FirmwareUpload {
const NAME: &'static str = "FirmwareUpload";
fn is_initialized(&self) -> bool {
if self.payload.is_none() {
return false;
}
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
10 => {
self.payload = ::std::option::Option::Some(is.read_bytes()?);
},
18 => {
self.hash = ::std::option::Option::Some(is.read_bytes()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.payload.as_ref() {
my_size += ::protobuf::rt::bytes_size(1, &v);
}
if let Some(v) = self.hash.as_ref() {
my_size += ::protobuf::rt::bytes_size(2, &v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.payload.as_ref() {
os.write_bytes(1, v)?;
}
if let Some(v) = self.hash.as_ref() {
os.write_bytes(2, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> FirmwareUpload {
FirmwareUpload::new()
}
fn clear(&mut self) {
self.payload = ::std::option::Option::None;
self.hash = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static FirmwareUpload {
static instance: FirmwareUpload = FirmwareUpload {
payload: ::std::option::Option::None,
hash: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for FirmwareUpload {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("FirmwareUpload").unwrap()).clone()
}
}
impl ::std::fmt::Display for FirmwareUpload {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for FirmwareUpload {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.bootloader.SelfTest)
pub struct SelfTest {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.bootloader.SelfTest.payload)
pub payload: ::std::option::Option<::std::vec::Vec<u8>>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.bootloader.SelfTest.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a SelfTest {
fn default() -> &'a SelfTest {
<SelfTest as ::protobuf::Message>::default_instance()
}
}
impl SelfTest {
pub fn new() -> SelfTest {
::std::default::Default::default()
}
// optional bytes payload = 1;
pub fn payload(&self) -> &[u8] {
match self.payload.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_payload(&mut self) {
self.payload = ::std::option::Option::None;
}
pub fn has_payload(&self) -> bool {
self.payload.is_some()
}
// Param is passed by value, moved
pub fn set_payload(&mut self, v: ::std::vec::Vec<u8>) {
self.payload = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_payload(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.payload.is_none() {
self.payload = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.payload.as_mut().unwrap()
}
// Take field
pub fn take_payload(&mut self) -> ::std::vec::Vec<u8> {
self.payload.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(1);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"payload",
|m: &SelfTest| { &m.payload },
|m: &mut SelfTest| { &mut m.payload },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<SelfTest>(
"SelfTest",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for SelfTest {
const NAME: &'static str = "SelfTest";
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
10 => {
self.payload = ::std::option::Option::Some(is.read_bytes()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.payload.as_ref() {
my_size += ::protobuf::rt::bytes_size(1, &v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.payload.as_ref() {
os.write_bytes(1, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> SelfTest {
SelfTest::new()
}
fn clear(&mut self) {
self.payload = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static SelfTest {
static instance: SelfTest = SelfTest {
payload: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for SelfTest {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("SelfTest").unwrap()).clone()
}
}
impl ::std::fmt::Display for SelfTest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for SelfTest {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x19messages-bootloader.proto\x12\x1dhw.trezor.messages.bootloader\x1a\
\x0emessages.proto\"'\n\rFirmwareErase\x12\x16\n\x06length\x18\x01\x20\
\x01(\rR\x06length\"A\n\x0fFirmwareRequest\x12\x16\n\x06offset\x18\x01\
\x20\x02(\rR\x06offset\x12\x16\n\x06length\x18\x02\x20\x02(\rR\x06length\
\">\n\x0eFirmwareUpload\x12\x18\n\x07payload\x18\x01\x20\x02(\x0cR\x07pa\
yload\x12\x12\n\x04hash\x18\x02\x20\x01(\x0cR\x04hash\"$\n\x08SelfTest\
\x12\x18\n\x07payload\x18\x01\x20\x01(\x0cR\x07payloadB>\n#com.satoshila\
bs.trezor.lib.protobufB\x17TrezorMessageBootloader\
";
/// `FileDescriptorProto` object which was a source for this generated file
fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new();
file_descriptor_proto_lazy.get(|| {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
})
}
/// `FileDescriptor` object which allows dynamic access to files
pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new();
static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new();
file_descriptor.get(|| {
let generated_file_descriptor = generated_file_descriptor_lazy.get(|| {
let mut deps = ::std::vec::Vec::with_capacity(1);
deps.push(super::messages::file_descriptor().clone());
let mut messages = ::std::vec::Vec::with_capacity(4);
messages.push(FirmwareErase::generated_message_descriptor_data());
messages.push(FirmwareRequest::generated_message_descriptor_data());
messages.push(FirmwareUpload::generated_message_descriptor_data());
messages.push(SelfTest::generated_message_descriptor_data());
let mut enums = ::std::vec::Vec::with_capacity(0);
::protobuf::reflect::GeneratedFileDescriptor::new_generated(
file_descriptor_proto(),
deps,
messages,
enums,
)
});
::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor)
})
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,993 @@
// This file is generated by rust-protobuf 3.2.0. Do not edit
// .proto file is parsed by protoc 3.19.6
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_results)]
#![allow(unused_mut)]
//! Generated file from `messages-ethereum-definitions.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0;
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo)
pub struct EthereumNetworkInfo {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo.chain_id)
pub chain_id: ::std::option::Option<u64>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo.symbol)
pub symbol: ::std::option::Option<::std::string::String>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo.slip44)
pub slip44: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo.name)
pub name: ::std::option::Option<::std::string::String>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.ethereum_definitions.EthereumNetworkInfo.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a EthereumNetworkInfo {
fn default() -> &'a EthereumNetworkInfo {
<EthereumNetworkInfo as ::protobuf::Message>::default_instance()
}
}
impl EthereumNetworkInfo {
pub fn new() -> EthereumNetworkInfo {
::std::default::Default::default()
}
// required uint64 chain_id = 1;
pub fn chain_id(&self) -> u64 {
self.chain_id.unwrap_or(0)
}
pub fn clear_chain_id(&mut self) {
self.chain_id = ::std::option::Option::None;
}
pub fn has_chain_id(&self) -> bool {
self.chain_id.is_some()
}
// Param is passed by value, moved
pub fn set_chain_id(&mut self, v: u64) {
self.chain_id = ::std::option::Option::Some(v);
}
// required string symbol = 2;
pub fn symbol(&self) -> &str {
match self.symbol.as_ref() {
Some(v) => v,
None => "",
}
}
pub fn clear_symbol(&mut self) {
self.symbol = ::std::option::Option::None;
}
pub fn has_symbol(&self) -> bool {
self.symbol.is_some()
}
// Param is passed by value, moved
pub fn set_symbol(&mut self, v: ::std::string::String) {
self.symbol = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_symbol(&mut self) -> &mut ::std::string::String {
if self.symbol.is_none() {
self.symbol = ::std::option::Option::Some(::std::string::String::new());
}
self.symbol.as_mut().unwrap()
}
// Take field
pub fn take_symbol(&mut self) -> ::std::string::String {
self.symbol.take().unwrap_or_else(|| ::std::string::String::new())
}
// required uint32 slip44 = 3;
pub fn slip44(&self) -> u32 {
self.slip44.unwrap_or(0)
}
pub fn clear_slip44(&mut self) {
self.slip44 = ::std::option::Option::None;
}
pub fn has_slip44(&self) -> bool {
self.slip44.is_some()
}
// Param is passed by value, moved
pub fn set_slip44(&mut self, v: u32) {
self.slip44 = ::std::option::Option::Some(v);
}
// required string name = 4;
pub fn name(&self) -> &str {
match self.name.as_ref() {
Some(v) => v,
None => "",
}
}
pub fn clear_name(&mut self) {
self.name = ::std::option::Option::None;
}
pub fn has_name(&self) -> bool {
self.name.is_some()
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
if self.name.is_none() {
self.name = ::std::option::Option::Some(::std::string::String::new());
}
self.name.as_mut().unwrap()
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
self.name.take().unwrap_or_else(|| ::std::string::String::new())
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(4);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"chain_id",
|m: &EthereumNetworkInfo| { &m.chain_id },
|m: &mut EthereumNetworkInfo| { &mut m.chain_id },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"symbol",
|m: &EthereumNetworkInfo| { &m.symbol },
|m: &mut EthereumNetworkInfo| { &mut m.symbol },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"slip44",
|m: &EthereumNetworkInfo| { &m.slip44 },
|m: &mut EthereumNetworkInfo| { &mut m.slip44 },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"name",
|m: &EthereumNetworkInfo| { &m.name },
|m: &mut EthereumNetworkInfo| { &mut m.name },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<EthereumNetworkInfo>(
"EthereumNetworkInfo",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for EthereumNetworkInfo {
const NAME: &'static str = "EthereumNetworkInfo";
fn is_initialized(&self) -> bool {
if self.chain_id.is_none() {
return false;
}
if self.symbol.is_none() {
return false;
}
if self.slip44.is_none() {
return false;
}
if self.name.is_none() {
return false;
}
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
8 => {
self.chain_id = ::std::option::Option::Some(is.read_uint64()?);
},
18 => {
self.symbol = ::std::option::Option::Some(is.read_string()?);
},
24 => {
self.slip44 = ::std::option::Option::Some(is.read_uint32()?);
},
34 => {
self.name = ::std::option::Option::Some(is.read_string()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.chain_id {
my_size += ::protobuf::rt::uint64_size(1, v);
}
if let Some(v) = self.symbol.as_ref() {
my_size += ::protobuf::rt::string_size(2, &v);
}
if let Some(v) = self.slip44 {
my_size += ::protobuf::rt::uint32_size(3, v);
}
if let Some(v) = self.name.as_ref() {
my_size += ::protobuf::rt::string_size(4, &v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.chain_id {
os.write_uint64(1, v)?;
}
if let Some(v) = self.symbol.as_ref() {
os.write_string(2, v)?;
}
if let Some(v) = self.slip44 {
os.write_uint32(3, v)?;
}
if let Some(v) = self.name.as_ref() {
os.write_string(4, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> EthereumNetworkInfo {
EthereumNetworkInfo::new()
}
fn clear(&mut self) {
self.chain_id = ::std::option::Option::None;
self.symbol = ::std::option::Option::None;
self.slip44 = ::std::option::Option::None;
self.name = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static EthereumNetworkInfo {
static instance: EthereumNetworkInfo = EthereumNetworkInfo {
chain_id: ::std::option::Option::None,
symbol: ::std::option::Option::None,
slip44: ::std::option::Option::None,
name: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for EthereumNetworkInfo {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("EthereumNetworkInfo").unwrap()).clone()
}
}
impl ::std::fmt::Display for EthereumNetworkInfo {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for EthereumNetworkInfo {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo)
pub struct EthereumTokenInfo {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.address)
pub address: ::std::option::Option<::std::vec::Vec<u8>>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.chain_id)
pub chain_id: ::std::option::Option<u64>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.symbol)
pub symbol: ::std::option::Option<::std::string::String>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.decimals)
pub decimals: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.name)
pub name: ::std::option::Option<::std::string::String>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.ethereum_definitions.EthereumTokenInfo.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a EthereumTokenInfo {
fn default() -> &'a EthereumTokenInfo {
<EthereumTokenInfo as ::protobuf::Message>::default_instance()
}
}
impl EthereumTokenInfo {
pub fn new() -> EthereumTokenInfo {
::std::default::Default::default()
}
// required bytes address = 1;
pub fn address(&self) -> &[u8] {
match self.address.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_address(&mut self) {
self.address = ::std::option::Option::None;
}
pub fn has_address(&self) -> bool {
self.address.is_some()
}
// Param is passed by value, moved
pub fn set_address(&mut self, v: ::std::vec::Vec<u8>) {
self.address = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_address(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.address.is_none() {
self.address = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.address.as_mut().unwrap()
}
// Take field
pub fn take_address(&mut self) -> ::std::vec::Vec<u8> {
self.address.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
// required uint64 chain_id = 2;
pub fn chain_id(&self) -> u64 {
self.chain_id.unwrap_or(0)
}
pub fn clear_chain_id(&mut self) {
self.chain_id = ::std::option::Option::None;
}
pub fn has_chain_id(&self) -> bool {
self.chain_id.is_some()
}
// Param is passed by value, moved
pub fn set_chain_id(&mut self, v: u64) {
self.chain_id = ::std::option::Option::Some(v);
}
// required string symbol = 3;
pub fn symbol(&self) -> &str {
match self.symbol.as_ref() {
Some(v) => v,
None => "",
}
}
pub fn clear_symbol(&mut self) {
self.symbol = ::std::option::Option::None;
}
pub fn has_symbol(&self) -> bool {
self.symbol.is_some()
}
// Param is passed by value, moved
pub fn set_symbol(&mut self, v: ::std::string::String) {
self.symbol = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_symbol(&mut self) -> &mut ::std::string::String {
if self.symbol.is_none() {
self.symbol = ::std::option::Option::Some(::std::string::String::new());
}
self.symbol.as_mut().unwrap()
}
// Take field
pub fn take_symbol(&mut self) -> ::std::string::String {
self.symbol.take().unwrap_or_else(|| ::std::string::String::new())
}
// required uint32 decimals = 4;
pub fn decimals(&self) -> u32 {
self.decimals.unwrap_or(0)
}
pub fn clear_decimals(&mut self) {
self.decimals = ::std::option::Option::None;
}
pub fn has_decimals(&self) -> bool {
self.decimals.is_some()
}
// Param is passed by value, moved
pub fn set_decimals(&mut self, v: u32) {
self.decimals = ::std::option::Option::Some(v);
}
// required string name = 5;
pub fn name(&self) -> &str {
match self.name.as_ref() {
Some(v) => v,
None => "",
}
}
pub fn clear_name(&mut self) {
self.name = ::std::option::Option::None;
}
pub fn has_name(&self) -> bool {
self.name.is_some()
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
if self.name.is_none() {
self.name = ::std::option::Option::Some(::std::string::String::new());
}
self.name.as_mut().unwrap()
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
self.name.take().unwrap_or_else(|| ::std::string::String::new())
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(5);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"address",
|m: &EthereumTokenInfo| { &m.address },
|m: &mut EthereumTokenInfo| { &mut m.address },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"chain_id",
|m: &EthereumTokenInfo| { &m.chain_id },
|m: &mut EthereumTokenInfo| { &mut m.chain_id },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"symbol",
|m: &EthereumTokenInfo| { &m.symbol },
|m: &mut EthereumTokenInfo| { &mut m.symbol },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"decimals",
|m: &EthereumTokenInfo| { &m.decimals },
|m: &mut EthereumTokenInfo| { &mut m.decimals },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"name",
|m: &EthereumTokenInfo| { &m.name },
|m: &mut EthereumTokenInfo| { &mut m.name },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<EthereumTokenInfo>(
"EthereumTokenInfo",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for EthereumTokenInfo {
const NAME: &'static str = "EthereumTokenInfo";
fn is_initialized(&self) -> bool {
if self.address.is_none() {
return false;
}
if self.chain_id.is_none() {
return false;
}
if self.symbol.is_none() {
return false;
}
if self.decimals.is_none() {
return false;
}
if self.name.is_none() {
return false;
}
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
10 => {
self.address = ::std::option::Option::Some(is.read_bytes()?);
},
16 => {
self.chain_id = ::std::option::Option::Some(is.read_uint64()?);
},
26 => {
self.symbol = ::std::option::Option::Some(is.read_string()?);
},
32 => {
self.decimals = ::std::option::Option::Some(is.read_uint32()?);
},
42 => {
self.name = ::std::option::Option::Some(is.read_string()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.address.as_ref() {
my_size += ::protobuf::rt::bytes_size(1, &v);
}
if let Some(v) = self.chain_id {
my_size += ::protobuf::rt::uint64_size(2, v);
}
if let Some(v) = self.symbol.as_ref() {
my_size += ::protobuf::rt::string_size(3, &v);
}
if let Some(v) = self.decimals {
my_size += ::protobuf::rt::uint32_size(4, v);
}
if let Some(v) = self.name.as_ref() {
my_size += ::protobuf::rt::string_size(5, &v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.address.as_ref() {
os.write_bytes(1, v)?;
}
if let Some(v) = self.chain_id {
os.write_uint64(2, v)?;
}
if let Some(v) = self.symbol.as_ref() {
os.write_string(3, v)?;
}
if let Some(v) = self.decimals {
os.write_uint32(4, v)?;
}
if let Some(v) = self.name.as_ref() {
os.write_string(5, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> EthereumTokenInfo {
EthereumTokenInfo::new()
}
fn clear(&mut self) {
self.address = ::std::option::Option::None;
self.chain_id = ::std::option::Option::None;
self.symbol = ::std::option::Option::None;
self.decimals = ::std::option::Option::None;
self.name = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static EthereumTokenInfo {
static instance: EthereumTokenInfo = EthereumTokenInfo {
address: ::std::option::Option::None,
chain_id: ::std::option::Option::None,
symbol: ::std::option::Option::None,
decimals: ::std::option::Option::None,
name: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for EthereumTokenInfo {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("EthereumTokenInfo").unwrap()).clone()
}
}
impl ::std::fmt::Display for EthereumTokenInfo {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for EthereumTokenInfo {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(PartialEq,Clone,Default,Debug)]
// @@protoc_insertion_point(message:hw.trezor.messages.ethereum_definitions.EthereumDefinitions)
pub struct EthereumDefinitions {
// message fields
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumDefinitions.encoded_network)
pub encoded_network: ::std::option::Option<::std::vec::Vec<u8>>,
// @@protoc_insertion_point(field:hw.trezor.messages.ethereum_definitions.EthereumDefinitions.encoded_token)
pub encoded_token: ::std::option::Option<::std::vec::Vec<u8>>,
// special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.ethereum_definitions.EthereumDefinitions.special_fields)
pub special_fields: ::protobuf::SpecialFields,
}
impl<'a> ::std::default::Default for &'a EthereumDefinitions {
fn default() -> &'a EthereumDefinitions {
<EthereumDefinitions as ::protobuf::Message>::default_instance()
}
}
impl EthereumDefinitions {
pub fn new() -> EthereumDefinitions {
::std::default::Default::default()
}
// optional bytes encoded_network = 1;
pub fn encoded_network(&self) -> &[u8] {
match self.encoded_network.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_encoded_network(&mut self) {
self.encoded_network = ::std::option::Option::None;
}
pub fn has_encoded_network(&self) -> bool {
self.encoded_network.is_some()
}
// Param is passed by value, moved
pub fn set_encoded_network(&mut self, v: ::std::vec::Vec<u8>) {
self.encoded_network = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_encoded_network(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.encoded_network.is_none() {
self.encoded_network = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.encoded_network.as_mut().unwrap()
}
// Take field
pub fn take_encoded_network(&mut self) -> ::std::vec::Vec<u8> {
self.encoded_network.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
// optional bytes encoded_token = 2;
pub fn encoded_token(&self) -> &[u8] {
match self.encoded_token.as_ref() {
Some(v) => v,
None => &[],
}
}
pub fn clear_encoded_token(&mut self) {
self.encoded_token = ::std::option::Option::None;
}
pub fn has_encoded_token(&self) -> bool {
self.encoded_token.is_some()
}
// Param is passed by value, moved
pub fn set_encoded_token(&mut self, v: ::std::vec::Vec<u8>) {
self.encoded_token = ::std::option::Option::Some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_encoded_token(&mut self) -> &mut ::std::vec::Vec<u8> {
if self.encoded_token.is_none() {
self.encoded_token = ::std::option::Option::Some(::std::vec::Vec::new());
}
self.encoded_token.as_mut().unwrap()
}
// Take field
pub fn take_encoded_token(&mut self) -> ::std::vec::Vec<u8> {
self.encoded_token.take().unwrap_or_else(|| ::std::vec::Vec::new())
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(2);
let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"encoded_network",
|m: &EthereumDefinitions| { &m.encoded_network },
|m: &mut EthereumDefinitions| { &mut m.encoded_network },
));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"encoded_token",
|m: &EthereumDefinitions| { &m.encoded_token },
|m: &mut EthereumDefinitions| { &mut m.encoded_token },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<EthereumDefinitions>(
"EthereumDefinitions",
fields,
oneofs,
)
}
}
impl ::protobuf::Message for EthereumDefinitions {
const NAME: &'static str = "EthereumDefinitions";
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
while let Some(tag) = is.read_raw_tag_or_eof()? {
match tag {
10 => {
self.encoded_network = ::std::option::Option::Some(is.read_bytes()?);
},
18 => {
self.encoded_token = ::std::option::Option::Some(is.read_bytes()?);
},
tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u64 {
let mut my_size = 0;
if let Some(v) = self.encoded_network.as_ref() {
my_size += ::protobuf::rt::bytes_size(1, &v);
}
if let Some(v) = self.encoded_token.as_ref() {
my_size += ::protobuf::rt::bytes_size(2, &v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
if let Some(v) = self.encoded_network.as_ref() {
os.write_bytes(1, v)?;
}
if let Some(v) = self.encoded_token.as_ref() {
os.write_bytes(2, v)?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(())
}
fn special_fields(&self) -> &::protobuf::SpecialFields {
&self.special_fields
}
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
&mut self.special_fields
}
fn new() -> EthereumDefinitions {
EthereumDefinitions::new()
}
fn clear(&mut self) {
self.encoded_network = ::std::option::Option::None;
self.encoded_token = ::std::option::Option::None;
self.special_fields.clear();
}
fn default_instance() -> &'static EthereumDefinitions {
static instance: EthereumDefinitions = EthereumDefinitions {
encoded_network: ::std::option::Option::None,
encoded_token: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(),
};
&instance
}
}
impl ::protobuf::MessageFull for EthereumDefinitions {
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().message_by_package_relative_name("EthereumDefinitions").unwrap()).clone()
}
}
impl ::std::fmt::Display for EthereumDefinitions {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for EthereumDefinitions {
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
}
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.ethereum_definitions.EthereumDefinitionType)
pub enum EthereumDefinitionType {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.ethereum_definitions.EthereumDefinitionType.NETWORK)
NETWORK = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.ethereum_definitions.EthereumDefinitionType.TOKEN)
TOKEN = 1,
}
impl ::protobuf::Enum for EthereumDefinitionType {
const NAME: &'static str = "EthereumDefinitionType";
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<EthereumDefinitionType> {
match value {
0 => ::std::option::Option::Some(EthereumDefinitionType::NETWORK),
1 => ::std::option::Option::Some(EthereumDefinitionType::TOKEN),
_ => ::std::option::Option::None
}
}
const VALUES: &'static [EthereumDefinitionType] = &[
EthereumDefinitionType::NETWORK,
EthereumDefinitionType::TOKEN,
];
}
impl ::protobuf::EnumFull for EthereumDefinitionType {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().enum_by_package_relative_name("EthereumDefinitionType").unwrap()).clone()
}
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
let index = *self as usize;
Self::enum_descriptor().value_by_index(index)
}
}
impl ::std::default::Default for EthereumDefinitionType {
fn default() -> Self {
EthereumDefinitionType::NETWORK
}
}
impl EthereumDefinitionType {
fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<EthereumDefinitionType>("EthereumDefinitionType")
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n#messages-ethereum-definitions.proto\x12'hw.trezor.messages.ethereum_d\
efinitions\"t\n\x13EthereumNetworkInfo\x12\x19\n\x08chain_id\x18\x01\x20\
\x02(\x04R\x07chainId\x12\x16\n\x06symbol\x18\x02\x20\x02(\tR\x06symbol\
\x12\x16\n\x06slip44\x18\x03\x20\x02(\rR\x06slip44\x12\x12\n\x04name\x18\
\x04\x20\x02(\tR\x04name\"\x90\x01\n\x11EthereumTokenInfo\x12\x18\n\x07a\
ddress\x18\x01\x20\x02(\x0cR\x07address\x12\x19\n\x08chain_id\x18\x02\
\x20\x02(\x04R\x07chainId\x12\x16\n\x06symbol\x18\x03\x20\x02(\tR\x06sym\
bol\x12\x1a\n\x08decimals\x18\x04\x20\x02(\rR\x08decimals\x12\x12\n\x04n\
ame\x18\x05\x20\x02(\tR\x04name\"c\n\x13EthereumDefinitions\x12'\n\x0fen\
coded_network\x18\x01\x20\x01(\x0cR\x0eencodedNetwork\x12#\n\rencoded_to\
ken\x18\x02\x20\x01(\x0cR\x0cencodedToken*0\n\x16EthereumDefinitionType\
\x12\x0b\n\x07NETWORK\x10\0\x12\t\n\x05TOKEN\x10\x01BG\n#com.satoshilabs\
.trezor.lib.protobufB\x20TrezorMessageEthereumDefinitions\
";
/// `FileDescriptorProto` object which was a source for this generated file
fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new();
file_descriptor_proto_lazy.get(|| {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
})
}
/// `FileDescriptor` object which allows dynamic access to files
pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new();
static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new();
file_descriptor.get(|| {
let generated_file_descriptor = generated_file_descriptor_lazy.get(|| {
let mut deps = ::std::vec::Vec::with_capacity(0);
let mut messages = ::std::vec::Vec::with_capacity(3);
messages.push(EthereumNetworkInfo::generated_message_descriptor_data());
messages.push(EthereumTokenInfo::generated_message_descriptor_data());
messages.push(EthereumDefinitions::generated_message_descriptor_data());
let mut enums = ::std::vec::Vec::with_capacity(1);
enums.push(EthereumDefinitionType::generated_enum_descriptor_data());
::protobuf::reflect::GeneratedFileDescriptor::new_generated(
file_descriptor_proto(),
deps,
messages,
enums,
)
});
::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor)
})
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,27 @@
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));
//! Bindings for Trezor protobufs.
// Note: we do not use the generated `mod.rs` because we want to feature-gate some modules manually.
// This significantly improves compile times.
// See https://github.com/joshieDo/rust-trezor-api/pull/9 for more details.
#[allow(ambiguous_glob_reexports)]
pub use messages::*;
pub use messages_bootloader::*;
pub use messages_common::*;
pub use messages_crypto::*;
pub use messages_debug::*;
pub use messages_management::*;
macro_rules! features {
($($feature:literal => $item:ident)+) => {$(
#[cfg(feature = $feature)]
#[allow(ambiguous_glob_reexports)]
pub use $item::*;
mod generated {
macro_rules! modules {
($($($feature:literal =>)? $module:ident)+) => {$(
$(#[cfg(feature = $feature)])?
mod $module;
$(#[cfg(feature = $feature)])?
pub use self::$module::*;
)+};
}
features! {
modules! {
messages
messages_bootloader
messages_common
messages_crypto
messages_debug
messages_management
"bitcoin" => messages_bitcoin
"ethereum" => messages_ethereum
"ethereum" => messages_ethereum_eip712
@ -31,3 +36,6 @@ features! {
"tezos" => messages_tezos
"webauthn" => messages_webauthn
}
}
pub use generated::*;