symsrv-0.5.3/.cargo_vcs_info.json0000644000000001360000000000100124040ustar { "git": { "sha1": "15e71af25c77c46bd1cb02bd21cc22092b49e4ca" }, "path_in_vcs": "" }symsrv-0.5.3/.gitignore000064400000000000000000000000341046102023000131610ustar 00000000000000target Cargo.lock .DS_Store symsrv-0.5.3/Cargo.lock0000644000001327440000000000100103720ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anstream" version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", ] [[package]] name = "assert-json-diff" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" dependencies = [ "serde", "serde_json", ] [[package]] name = "async-compression" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" dependencies = [ "flate2", "futures-core", "futures-io", "memchr", "pin-project-lite", "tokio", ] [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cab" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "171228650e6721d5acc0868a462cd864f49ac5f64e4a42cde270406e64e404d2" dependencies = [ "byteorder", "flate2", "lzxd", "time", ] [[package]] name = "cc" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", "clap_derive", ] [[package]] name = "clap_builder" version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", ] [[package]] name = "clap_derive" version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck", "proc-macro2", "quote", "syn", ] [[package]] name = "clap_lex" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "colored" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" dependencies = [ "lazy_static", "windows-sys 0.48.0", ] [[package]] name = "console" version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", "windows-sys 0.52.0", ] [[package]] name = "crc32fast" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "deranged" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] [[package]] name = "dirs" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", "option-ext", "redox_users", "windows-sys 0.48.0", ] [[package]] name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "fastrand" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "flate2" version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", ] [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "fs4" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de" dependencies = [ "rustix", "windows-sys 0.52.0", ] [[package]] name = "futures-channel" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-io" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "futures-sink" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", "futures-macro", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gimli" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", "http 0.2.12", "indexmap", "slab", "tokio", "tokio-util", "tracing", ] [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "http" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "http-body" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http 0.2.12", "pin-project-lite", ] [[package]] name = "http-body" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", ] [[package]] name = "http-body-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", "http 1.1.0", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", "h2", "http 0.2.12", "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", "tokio", "tower-service", "tracing", "want", ] [[package]] name = "hyper" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.1", "httparse", "itoa", "pin-project-lite", "smallvec", "tokio", "want", ] [[package]] name = "hyper-rustls" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.4.1", "hyper-util", "rustls", "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", "webpki-roots", ] [[package]] name = "hyper-util" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.1", "hyper 1.4.1", "pin-project-lite", "socket2", "tokio", "tower", "tower-service", "tracing", ] [[package]] name = "idna" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] [[package]] name = "indexmap" version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "indicatif" version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" dependencies = [ "console", "instant", "number_prefix", "portable-atomic", "unicode-width", ] [[package]] name = "instant" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] [[package]] name = "ipnet" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is_terminal_polyfill" version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libredox" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags", "libc", ] [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", ] [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lzxd" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de7336a183103429ad66d11d56d8bdc9c4a2916f6b85a8f11e5b127bde12001" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", ] [[package]] name = "mockito" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2f6e023aa5bdf392aa06c78e4a4e6d498baab5138d0c993503350ebbc37bf1e" dependencies = [ "assert-json-diff", "colored", "futures-core", "hyper 0.14.30", "log", "rand", "regex", "serde_json", "serde_urlencoded", "similar", "tokio", ] [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "number_prefix" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "parking_lot" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets 0.52.6", ] [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2288c0e17cc8d342c712bb43a257a80ebffce59cdb33d5000d8348f3ec02528b" dependencies = [ "zerocopy", "zerocopy-derive", ] [[package]] name = "proc-macro2" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quinn" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", "rustls", "thiserror", "tokio", "tracing", ] [[package]] name = "quinn-proto" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" dependencies = [ "bytes", "rand", "ring", "rustc-hash", "rustls", "slab", "thiserror", "tinyvec", "tracing", ] [[package]] name = "quinn-udp" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", "socket2", "windows-sys 0.52.0", ] [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] [[package]] name = "redox_syscall" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags", ] [[package]] name = "redox_users" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", "thiserror", ] [[package]] name = "regex" version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64", "bytes", "futures-core", "futures-util", "http 1.1.0", "http-body 1.0.1", "http-body-util", "hyper 1.4.1", "hyper-rustls", "hyper-util", "ipnet", "js-sys", "log", "mime", "once_cell", "percent-encoding", "pin-project-lite", "quinn", "rustls", "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", "tokio-rustls", "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "web-sys", "webpki-roots", "winreg", ] [[package]] name = "ring" version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", "getrandom", "libc", "spin", "untrusted", "windows-sys 0.52.0", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] [[package]] name = "rustls" version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring", "rustls-pki-types", "rustls-webpki", "subtle", "zeroize", ] [[package]] name = "rustls-pemfile" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ "base64", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", "untrusted", ] [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", "memchr", "ryu", "serde", ] [[package]] name = "serde_urlencoded" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", "itoa", "ryu", "serde", ] [[package]] name = "similar" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "symsrv" version = "0.5.3" dependencies = [ "async-compression", "cab", "clap", "dirs", "fs4", "futures-util", "http 1.1.0", "indicatif", "mockito", "reqwest", "scopeguard", "tempfile", "thiserror", "tokio", ] [[package]] name = "syn" version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "tempfile" version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", "rustix", "windows-sys 0.52.0", ] [[package]] name = "thiserror" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "time" version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "num-conv", "powerfmt", "serde", "time-core", ] [[package]] name = "time-core" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "tinyvec" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", "parking_lot", "pin-project-lite", "socket2", "tokio-macros", "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tokio-rustls" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-util" version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", ] [[package]] name = "tower" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", "pin-project", "pin-project-lite", "tokio", "tower-layer", "tower-service", ] [[package]] name = "tower-layer" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-bidi" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "untrusted" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "want" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ "try-lock", ] [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-streams" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", ] [[package]] name = "web-sys" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "webpki-roots" version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.5", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winreg" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", ] [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" symsrv-0.5.3/Cargo.toml0000644000000037150000000000100104100ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "symsrv" version = "0.5.3" authors = ["Markus Stange "] build = false exclude = [ "/.github", "/tests", ] autobins = false autoexamples = false autotests = false autobenches = false description = "A Microsoft symsrv symbol server consumer (downloader + cache)" readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/mstange/symsrv/" [lib] name = "symsrv" path = "src/lib.rs" [[example]] name = "symfetch" path = "examples/symfetch.rs" [dependencies.async-compression] version = "0.4.6" features = [ "tokio", "futures-io", "gzip", ] default-features = false [dependencies.cab] version = "0.6" [dependencies.dirs] version = "5" [dependencies.fs4] version = "0.9" [dependencies.futures-util] version = "0.3.30" features = ["io"] default-features = false [dependencies.http] version = "1" [dependencies.reqwest] version = "0.12" features = [ "rustls-tls", "stream", ] default-features = false [dependencies.scopeguard] version = "1.2.0" default-features = false [dependencies.thiserror] version = "1" [dependencies.tokio] version = "1.39" features = ["fs"] default-features = false [dev-dependencies.clap] version = "4.5" features = ["derive"] [dev-dependencies.indicatif] version = "0.17" [dev-dependencies.mockito] version = "1.4" [dev-dependencies.tempfile] version = "3.10" [dev-dependencies.tokio] version = "1.39" features = [ "macros", "rt", "rt-multi-thread", ] default-features = false symsrv-0.5.3/Cargo.toml.orig000064400000000000000000000023201046102023000140600ustar 00000000000000[package] name = "symsrv" version = "0.5.3" edition = "2021" authors = ["Markus Stange "] license = "MIT/Apache-2.0" description = "A Microsoft symsrv symbol server consumer (downloader + cache)" repository = "https://github.com/mstange/symsrv/" readme = "README.md" exclude = ["/.github", "/tests"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] reqwest = { version = "0.12", default-features = false, features = [ "rustls-tls", "stream" ] } dirs = "5" tokio = { version = "1.39", default-features = false, features = ["fs"] } thiserror = "1" # cab = { path = "../rust-cab" } cab = "0.6" futures-util = { version = "0.3.30", default-features = false, features = ["io"] } fs4 = { version = "0.9" } async-compression = { version = "0.4.6", default-features = false, features = [ "tokio", "futures-io", "gzip" ] } http = "1" scopeguard = { version = "1.2.0", default-features = false } [dev-dependencies] tempfile = "3.10" mockito = "1.4" tokio = { version = "1.39", default-features = false, features = [ "macros", "rt", "rt-multi-thread" ] } indicatif = "0.17" clap = { version = "4.5", features = ["derive"] } symsrv-0.5.3/LICENSE-APACHE000064400000000000000000000251371046102023000131300ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. symsrv-0.5.3/LICENSE-MIT000064400000000000000000000020531046102023000126300ustar 00000000000000Copyright (c) 2012-2020 Mozilla Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. symsrv-0.5.3/README.md000064400000000000000000000044451046102023000124620ustar 00000000000000[![crates.io page](https://img.shields.io/crates/v/symsrv.svg)](https://crates.io/crates/symsrv) [![docs.rs page](https://docs.rs/symsrv/badge.svg)](https://docs.rs/symsrv/) # symsrv This crate lets you download and cache symbol files from symbol servers, according to the rules from the `_NT_SYMBOL_PATH` environment variable. It exposes an async API. Internally it uses `reqwest` and `tokio`. The downloaded symbols are stored on the file system. No automatic expiration or eviction is performed. If you want to enforce a cache size limit or expire old files, you can observe cache file creations and accesses with the [`SymsrvObserver`] trait, and then write your own implementation for automatic file cleanup. ## Microsoft Documentation - [Advanced SymSrv Use](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/advanced-symsrv-use) ## Example ```rust use symsrv::SymsrvDownloader; // Parse the _NT_SYMBOL_PATH environment variable. let symbol_path_env = symsrv::get_symbol_path_from_environment(); let symbol_path = symbol_path_env.as_deref().unwrap_or("srv**https://msdl.microsoft.com/download/symbols"); let parsed_symbol_path = symsrv::parse_nt_symbol_path(symbol_path); // Create a downloader which follows the _NT_SYMBOL_PATH recipe. let mut downloader = SymsrvDownloader::new(parsed_symbol_path); downloader.set_default_downstream_store(symsrv::get_home_sym_dir()); // Download and cache a PDB file. let local_path = downloader.get_file("dcomp.pdb", "648B8DD0780A4E22FA7FA89B84633C231").await?; // Use the PDB file. open_pdb_at_path(&local_path); ``` ## Command line tool `symfetch` This repository also contains a small example program called `symfetch`. You can install it as follows: ``` cargo install --examples symsrv ``` Run it with `symfetch ` - see `symfetch --help` for details. ## License Licensed under either of * Apache License, Version 2.0 ([`LICENSE-APACHE`](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([`LICENSE-MIT`](./LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. symsrv-0.5.3/examples/symfetch.rs000064400000000000000000000346501046102023000152120ustar 00000000000000use clap::Parser; use indicatif::{DecimalBytes, MultiProgress, ProgressBar}; use symsrv::{ get_home_sym_dir, parse_nt_symbol_path, CabExtractionError, CachePath, DownloadError, NtSymbolPathEntry, SymsrvDownloader, SymsrvObserver, }; use std::collections::HashMap; use std::error::Error; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, MutexGuard}; #[derive(Parser)] #[clap( version, about = "Fetch a symbol file.", long_about = " Fetch a single symbol file from a symbol server, or find it in a local cache directory. Prints the local path to the file to stdout. Supports symbol servers which serve files with cab compression; the local file will be decompressed if necessary, and the printed path always refers to a decompressed file.", override_usage = r#"symfetch [OPTIONS] Examples: symfetch --server "https://msdl.microsoft.com/download/symbols/" --cache ~/sym winmine.exe 3B7D847520000 symfetch --server "https://msdl.microsoft.com/download/symbols/" --cache ~/sym combase.pdb 071849A7C75FD246A3367704EE1CA85B1 symfetch --server "https://renderdoc.org/symbols" --cache ~/sym renderdoc.pdb 6D1DFFC4DC524537962CCABC000820641 symfetch --symbol-path "srv**https://renderdoc.org/symbols" renderdoc.pdb 6D1DFFC4DC524537962CCABC000820641 _NT_SYMBOL_PATH="srv**https://msdl.microsoft.com/download/symbols/*https://chromium-browser-symsrv.commondatastorage.googleapis.com/" symfetch --use-env-symbol-path chrome.dll.pdb 93B17FC546DE07D14C4C44205044422E1"# )] struct Args { /// The server URL to use for downloading symbol files. Can be specified multiple times. #[clap(long)] server: Vec, /// The local cache directory to use for storing files that are downloaded from servers specified via --server. #[clap(long)] cache: Option, /// If set, nothing is printed to stderr (no progress bars and no status messages). #[clap(long)] quiet: bool, /// Respect the _NT_SYMBOL_PATH environment variable. #[clap(long, short = 'e')] use_env_symbol_path: bool, /// The "symbol path" in the format used by the _NT_SYMBOL_PATH environment variable. /// See https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/advanced-symsrv-use #[clap(long)] symbol_path: Option, /// The local cache directory which should be used if no other cache directories are specified in the symbol path. #[clap(long)] default_downstream_store: Option, /// The file name of the symbol file to fetch. name: String, /// The hash / "ID" of the symbol file, e.g. B2A2B092E45739B84C4C44205044422E1 or 61015E74442b000. /// /// For PDBs this is ``, with `` in uppercase and `` in lowercase hex. /// For binaries this is ``, with `` printed as eight uppercase /// hex digits (with leading zeros added as needed) and `` in lowercase hex // digits with as many digits as needed. hash: String, } #[tokio::main] async fn main() -> Result<(), Box> { let args: Args = Args::parse(); let mut parsed_nt_symbol_path = Vec::new(); let nt_symbol_path = if args.use_env_symbol_path { std::env::var("_NT_SYMBOL_PATH").ok() } else { args.symbol_path }; if let Some(nt_symbol_path) = nt_symbol_path { parsed_nt_symbol_path.extend(parse_nt_symbol_path(&nt_symbol_path)); } if !args.server.is_empty() { let mut cache_paths = Vec::new(); if let Some(cache) = args.cache { cache_paths.push(CachePath::Path(cache)); } let urls = args.server; parsed_nt_symbol_path.push(NtSymbolPathEntry::Chain { dll: "symsrv.dll".into(), cache_paths, urls, }); } let observer = Arc::new(SymFetchObserver::new()); let mut downloader = SymsrvDownloader::new(parsed_nt_symbol_path); downloader.set_default_downstream_store(get_home_sym_dir()); downloader.set_observer(Some(observer)); let path = downloader.get_file(&args.name, &args.hash).await?; println!("{}", path.to_string_lossy()); Ok(()) } struct SymFetchObserver { inner: Mutex, } impl SymFetchObserver { pub fn new() -> Self { Self { inner: Mutex::new(SymFetchObserverInner::new()), } } fn get_inner(&self) -> MutexGuard { self.inner.lock().unwrap() } } impl SymsrvObserver for SymFetchObserver { fn on_new_download_before_connect(&self, download_id: u64, url: &str) { self.get_inner() .on_new_download_before_connect(download_id, url); } fn on_download_failed(&self, download_id: u64, error: DownloadError) { self.get_inner().on_download_failed(download_id, error); } fn on_download_canceled(&self, download_id: u64) { self.get_inner().on_download_canceled(download_id); } fn on_download_started(&self, download_id: u64) { self.get_inner().on_download_started(download_id); } fn on_download_progress(&self, download_id: u64, bytes_so_far: u64, total_bytes: Option) { self.get_inner() .on_download_progress(download_id, bytes_so_far, total_bytes); } fn on_download_completed( &self, download_id: u64, uncompressed_size_in_bytes: u64, _time_until_headers: std::time::Duration, _time_until_completed: std::time::Duration, ) { self.get_inner() .on_download_completed(download_id, uncompressed_size_in_bytes); } fn on_new_cab_extraction(&self, extraction_id: u64, dest_path: &Path) { self.get_inner() .on_new_cab_extraction(extraction_id, dest_path); } fn on_cab_extraction_progress(&self, extraction_id: u64, bytes_so_far: u64, total_bytes: u64) { self.get_inner() .on_cab_extraction_progress(extraction_id, bytes_so_far, total_bytes); } fn on_cab_extraction_completed( &self, extraction_id: u64, uncompressed_size_in_bytes: u64, _time_until_completed: std::time::Duration, ) { self.get_inner() .on_cab_extraction_completed(extraction_id, uncompressed_size_in_bytes); } fn on_cab_extraction_failed(&self, extraction_id: u64, reason: CabExtractionError) { self.get_inner() .on_cab_extraction_failed(extraction_id, reason); } fn on_cab_extraction_canceled(&self, extraction_id: u64) { self.get_inner().on_cab_extraction_canceled(extraction_id); } fn on_file_missed(&self, _path: &Path) {} fn on_file_created(&self, _path: &Path, _size_in_bytes: u64) {} fn on_file_accessed(&self, _path: &Path) {} } struct SymFetchObserverInner { multi_progress: MultiProgress, requests: HashMap, extractions: HashMap, } impl SymFetchObserverInner { pub fn new() -> Self { Self { multi_progress: MultiProgress::new(), requests: HashMap::new(), extractions: HashMap::new(), } } fn on_new_download_before_connect(&mut self, download_id: u64, url: &str) { let progress_bar = self.multi_progress.add(ProgressBar::new_spinner()); progress_bar.set_style(style::spinner()); progress_bar.set_message(format!("Connecting to {url}...")); self.requests.insert( download_id, RequestData { progress_bar, url: url.to_owned(), is_determinate: false, }, ); } fn on_download_failed(&mut self, download_id: u64, error: DownloadError) { let request = self.requests.remove(&download_id).unwrap(); request.progress_bar.finish_and_clear(); self.multi_progress.remove(&request.progress_bar); let url = request.url; self.multi_progress .println(format!("Request to {url} failed: {error}")) .unwrap(); } fn on_download_canceled(&mut self, download_id: u64) { let request = self.requests.remove(&download_id).unwrap(); request.progress_bar.finish_and_clear(); self.multi_progress.remove(&request.progress_bar); let url = request.url; self.multi_progress .println(format!("Canceled request to {url}.")) .unwrap(); } fn message_for_url(url: &str) -> String { format!("Downloading from {url}...") } fn on_download_started(&mut self, download_id: u64) { let request = self.requests.get_mut(&download_id).unwrap(); let message = Self::message_for_url(&request.url); request.progress_bar.set_message(message); } fn on_download_progress( &mut self, download_id: u64, bytes_so_far: u64, total_bytes: Option, ) { let request = self.requests.get_mut(&download_id).unwrap(); match (request.is_determinate, total_bytes) { (false, Some(total_bytes)) => { let progress_bar = self.multi_progress.insert_after( &request.progress_bar, ProgressBar::new(total_bytes).with_elapsed(request.progress_bar.elapsed()), ); self.multi_progress.remove(&request.progress_bar); progress_bar.set_style(style::bar()); progress_bar.set_message(Self::message_for_url(&request.url)); request.progress_bar = progress_bar; request.is_determinate = true; } (true, None) => { let progress_bar = self.multi_progress.insert_after( &request.progress_bar, ProgressBar::new_spinner().with_elapsed(request.progress_bar.elapsed()), ); self.multi_progress.remove(&request.progress_bar); progress_bar.set_style(style::spinner()); progress_bar.set_message(Self::message_for_url(&request.url)); request.progress_bar = progress_bar; request.is_determinate = false; } _ => {} } request.progress_bar.set_position(bytes_so_far); } fn on_download_completed(&mut self, download_id: u64, uncompressed_size_in_bytes: u64) { let request = self.requests.remove(&download_id).unwrap(); request.progress_bar.finish(); self.multi_progress.remove(&request.progress_bar); let url = request.url; self.multi_progress .println(format!( "Successfully downloaded {} from {url}.", DecimalBytes(uncompressed_size_in_bytes) )) .unwrap(); } fn on_new_cab_extraction(&mut self, extraction_id: u64, dest_path: &Path) { let progress_bar = self.multi_progress.add(ProgressBar::new_spinner()); progress_bar.set_style(style::spinner()); progress_bar.set_message(format!( "Extracting to {dest_path}...", dest_path = dest_path.to_string_lossy() )); self.extractions.insert( extraction_id, ExtractionData { progress_bar, extracted_path: dest_path.to_owned(), is_determinate: false, }, ); } fn on_cab_extraction_progress( &mut self, extraction_id: u64, bytes_so_far: u64, total_bytes: u64, ) { let extraction = self.extractions.get_mut(&extraction_id).unwrap(); if !extraction.is_determinate { let progress_bar = self.multi_progress.insert_after( &extraction.progress_bar, ProgressBar::new(total_bytes).with_elapsed(extraction.progress_bar.elapsed()), ); self.multi_progress.remove(&extraction.progress_bar); progress_bar.set_style(style::bar()); progress_bar.set_message(format!( "Extracting {path}...", path = extraction.extracted_path.to_string_lossy() )); extraction.progress_bar = progress_bar; extraction.is_determinate = true; } extraction.progress_bar.set_position(bytes_so_far); } fn on_cab_extraction_completed(&mut self, extraction_id: u64, uncompressed_size_in_bytes: u64) { let extraction = self.extractions.remove(&extraction_id).unwrap(); extraction.progress_bar.finish(); self.multi_progress.remove(&extraction.progress_bar); self.multi_progress .println(format!( "Successfully extracted {} to {path}.", DecimalBytes(uncompressed_size_in_bytes), path = extraction.extracted_path.to_string_lossy() )) .unwrap(); } fn on_cab_extraction_failed(&mut self, extraction_id: u64, reason: CabExtractionError) { let extraction = self.extractions.remove(&extraction_id).unwrap(); extraction.progress_bar.finish_and_clear(); self.multi_progress.remove(&extraction.progress_bar); self.multi_progress .println(format!( "Failed to extract {path}: {reason}.", path = extraction.extracted_path.to_string_lossy(), reason = reason )) .unwrap(); } fn on_cab_extraction_canceled(&mut self, extraction_id: u64) { let extraction = self.extractions.remove(&extraction_id).unwrap(); extraction.progress_bar.finish_and_clear(); self.multi_progress.remove(&extraction.progress_bar); self.multi_progress .println(format!( "Canceled extraction of {path}.", path = extraction.extracted_path.to_string_lossy() )) .unwrap(); } } struct RequestData { progress_bar: ProgressBar, url: String, is_determinate: bool, } struct ExtractionData { progress_bar: ProgressBar, extracted_path: PathBuf, is_determinate: bool, } mod style { use indicatif::ProgressStyle; pub fn bar() -> ProgressStyle { ProgressStyle::default_bar() .template( "[{elapsed_precise}] {bar:.cyan/blue} {decimal_bytes:>12}/{decimal_total_bytes:12} {wide_msg}", ) .unwrap() .progress_chars("█▉▊▋▌▍▎▏ ") } pub fn spinner() -> ProgressStyle { ProgressStyle::default_bar() .template("[{elapsed_precise}] {spinner} {bytes_per_sec:>10} {wide_msg}") .unwrap() } } symsrv-0.5.3/src/computation_coalescing.rs000064400000000000000000000076241046102023000170730ustar 00000000000000use std::collections::HashMap; use std::future::Future; use std::hash::Hash; use std::sync::Mutex; use futures_util::{future, FutureExt}; /// Keeps track of inflight computations and reuses them if another computation with /// the same arguments is requested while the first one is still running. pub struct ComputationCoalescer { weak_map: Mutex>, } impl ComputationCoalescer where Args: Eq + PartialEq + Hash + Clone, Fut: Future, Fut::Output: Clone, { pub fn new() -> Self { Self { weak_map: Mutex::new(WeakSharedFutureMap::new()), } } /// Start a new computation or wait for a currently-running computation with /// the same arguments to finish. /// /// If no computation with the same arguments is currently running, /// `compute_callback` is called to start a new computation. /// If a computation with the same arguments is currently running, /// `compute_callback` is *not* called and this function waits for the /// existing computation to finish and returns its result. /// /// `compute_callback` must not do any slow work synchronously; we call it while a /// mutex is locked. The actual work should be asynchronous, so that it /// starts only once this function awaits the returned future. pub fn subscribe_or_compute<'a>( &'a self, args: &'a Args, compute_callback: impl FnOnce() -> Fut, ) -> impl Future + 'a { let future = { // Find an existing future or create a new one. let mut weak_map = self.weak_map.lock().unwrap(); if let Some(shared_future) = weak_map.get(args) { shared_future } else { // No existing future, call the callback. let future = compute_callback(); // Turn it into a shared future and store a weak reference to it. let shared_future = future.shared(); weak_map.insert(args.clone(), &shared_future); shared_future } }; let remover = scopeguard::guard((), |_| { // Make sure that our map doesn't accumulate too many old entries // for futures which have already completed or which have been canceled. // With a scopeguard we can handle both completion and cancellation. let mut weak_map = self.weak_map.lock().unwrap(); weak_map.remove_if_done(args); }); async move { // Make sure the `remover` scopeguard is moved into this future. let _remover = remover; future.await } } } struct WeakSharedFutureMap { map: HashMap>, } impl WeakSharedFutureMap { fn new() -> Self { Self { map: HashMap::new(), } } fn insert(&mut self, args: Args, future: &future::Shared) { if let Some(weak) = future.downgrade() { self.map.insert(args, weak); } } fn get(&mut self, args: &Args) -> Option> { let strong = self.map.get(args)?.upgrade(); if strong.is_none() { self.map.remove(args); } strong } fn remove_if_done(&mut self, args: &Args) { self.get(args); } } #[cfg(test)] mod tests { use super::*; use futures_util::future::ready; #[tokio::test] async fn test_coalescer() { let coalescer = ComputationCoalescer::new(); let future1 = coalescer.subscribe_or_compute(&"key", || ready(1)); let future2 = coalescer.subscribe_or_compute(&"key", || ready(2)); let result1 = future1.await; let result2 = future2.await; assert_eq!(result1, 1); assert_eq!(result2, 1); } } symsrv-0.5.3/src/download.rs000064400000000000000000000151551046102023000141470ustar 00000000000000use async_compression::futures::bufread::GzipDecoder; use futures_util::{io::BufReader, AsyncRead, TryStreamExt}; use reqwest::header::{AsHeaderName, HeaderMap, CONTENT_ENCODING, CONTENT_LENGTH}; use std::{pin::Pin, sync::Mutex, task::Poll}; fn get_header(headers: &HeaderMap, name: K) -> Option { Some(headers.get(name)?.to_str().ok()?.to_ascii_lowercase()) } enum TotalSize { Compressed(u64), Uncompressed(u64), } fn get_total_size(headers: &HeaderMap) -> Option { let response_encoding = get_header(headers, CONTENT_ENCODING); let content_length = get_header(headers, CONTENT_LENGTH).and_then(|value| value.parse::().ok()); // If the server sends a Content-Length header, use the size from that header. match content_length { Some(len) if len > 0 => { let total_size = match response_encoding.as_deref() { None => TotalSize::Uncompressed(len), Some(_) => TotalSize::Compressed(len), }; return Some(total_size); } _ => {} } // Add a fallback for Google Cloud servers which use Transfer-Encoding: chunked with // HTTP/1.1 and thus do not include a Content-Length header. // This is the case for https://chromium-browser-symsrv.commondatastorage.googleapis.com/ // (the Chrome symbol server) as of February 2023. if response_encoding.as_deref() == Some("gzip") { if let (Some("gzip"), Some(len)) = ( get_header(headers, "x-goog-stored-content-encoding").as_deref(), get_header(headers, "x-goog-stored-content-length") .and_then(|value| value.parse::().ok()), ) { return Some(TotalSize::Compressed(len)); } } // Add another fallback for AWS servers. I have not seen a case where this is necessary, // but it doesn't hurt either. if let Some(len) = get_header(headers, "x-amz-meta-original_size").and_then(|value| value.parse::().ok()) { return Some(TotalSize::Uncompressed(len)); } None } #[derive(Debug, thiserror::Error)] pub enum Error { #[error("Unexpected Content-Encoding header: {0}")] UnexpectedContentEncoding(String), } pub fn response_to_uncompressed_stream_with_progress( response: reqwest::Response, progress: F, ) -> Result>, Error> where F: FnMut(u64, Option) + Send + Sync + 'static, { let headers = response.headers(); let response_encoding = get_header(headers, CONTENT_ENCODING); let total_size = get_total_size(headers); let stream = response.bytes_stream(); let async_read = stream .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)) .into_async_read(); match (response_encoding.as_deref(), total_size) { (Some("gzip"), Some(TotalSize::Uncompressed(len))) => { let async_buf_read = BufReader::new(async_read); let decoder = GzipDecoder::new(async_buf_read); let decoder_with_progress = decoder.with_progress(progress, Some(len)); Ok(Box::pin(decoder_with_progress)) } (Some("gzip"), Some(TotalSize::Compressed(len))) => { let async_read_with_progress = async_read.with_progress(progress, Some(len)); let async_buf_read = BufReader::new(async_read_with_progress); let decoder = GzipDecoder::new(async_buf_read); Ok(Box::pin(decoder)) } (Some("gzip"), None) => { let async_read_with_progress = async_read.with_progress(progress, None); let async_buf_read = BufReader::new(async_read_with_progress); let decoder = GzipDecoder::new(async_buf_read); Ok(Box::pin(decoder)) } (Some(other_encoding), _) => { // TODO: Add support for brotli and deflate Err(Error::UnexpectedContentEncoding(other_encoding.to_string())) } (None, Some(TotalSize::Uncompressed(len))) => { Ok(Box::pin(async_read.with_progress(progress, Some(len)))) } (None, _) => Ok(Box::pin(async_read.with_progress(progress, None))), } } trait AsyncReadObserver { fn did_read(&self, len: u64); } struct ProgressNotifierData)> { progress_fun: F, total_size: Option, accumulated_size: u64, } struct ProgressNotifier)>(Mutex>); impl)> AsyncReadObserver for ProgressNotifier { fn did_read(&self, len: u64) { let mut data = self.0.lock().unwrap(); data.accumulated_size += len; let accum = data.accumulated_size; let total_size = data.total_size; match total_size { Some(total_size) if accum <= total_size => (data.progress_fun)(accum, Some(total_size)), _ => (data.progress_fun)(accum, None), } } } impl)> ProgressNotifier { pub fn new(progress_fun: F, total_size: Option) -> Self { Self(Mutex::new(ProgressNotifierData { progress_fun, total_size, accumulated_size: 0, })) } } struct AsyncReadWrapper { inner: Pin>, observer: Pin>, } impl AsyncReadWrapper { pub fn new(inner: I, observer: O) -> Self { Self { inner: Box::pin(inner), observer: Box::pin(observer), } } } impl AsyncRead for AsyncReadWrapper { fn poll_read( mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, buf: &mut [u8], ) -> Poll> { let res = Pin::new(&mut self.inner).poll_read(cx, buf); match res { Poll::Ready(Ok(len)) => { self.observer.did_read(len as u64); Poll::Ready(Ok(len)) } Poll::Ready(Err(e)) => Poll::Ready(Err(e)), Poll::Pending => Poll::Pending, } } } trait WithProgress: AsyncRead + Sized { fn with_progress) + Send + Sync + 'static>( self, progress_fun: F, total_size: Option, ) -> AsyncReadWrapper; } impl WithProgress for AR { fn with_progress) + Send + Sync + 'static>( self, progress_fun: F, total_size: Option, ) -> AsyncReadWrapper { AsyncReadWrapper::new(self, ProgressNotifier::new(progress_fun, total_size)) } } symsrv-0.5.3/src/file_creation.rs000064400000000000000000000257731046102023000151520ustar 00000000000000use std::io; use std::path::Path; use fs4::{lock_contended_error, fs_std::FileExt}; /// The error type for the `create_file_cleanly` function. #[derive(thiserror::Error, Debug)] pub enum CleanFileCreationError { #[error("The destination path is invalid (no filename)")] InvalidPath, #[error("The lockfile could not be created: {0}")] LockFileCreation(io::Error), #[error("The temporary file could not be created: {0}")] TempFileCreation(io::Error), #[error("The temporary file could not be locked: {0}")] LockFileLocking(io::Error), #[error("The callback function indicated an error: {0}")] CallbackIndicatedError(E), #[error("The temporary file could not be renamed to the destination file: {0}")] RenameError(io::Error), } impl From> for io::Error { fn from(e: CleanFileCreationError) -> io::Error { io::Error::new(io::ErrorKind::Other, e) } } /// Creates a file at `dest_path` with the contents written by `write_fn`. /// If the file already exists, we call `handle_existing_fn`. /// If multiple calls to `create_file_cleanly` (in this process or even in different processes) /// try to create the same destination file at the same time, the first call will create the /// file and the other calls will block on the file lock until the destination file is present, /// and then call `handle_existing_fn`. /// /// `write_fn` must drop the file before it returns. /// /// This function tries to minimize the chance of leaving a partially-written file at the dest_path; /// the final file is only created once the write function has returned successfully. /// This is achieved by writing to a temporary file and then renaming it to the final file. /// /// We use file locks to coordinate multiple attempted writes of the same file from different /// processes running `create_file_cleanly`. This is done with a separate lock file. /// The lock file is locked for the full duration of "create temp file, write into temp file, rename /// to dest file". Once it's unlocked, the presence or absence of the destination file clearly /// indicates whether we've succeeded or failed to create the destination file. /// /// The steps are: /// /// 1. Create a lock file in the same directory as the final file. /// 2. Lock the lock file for exclusive write access. /// 3. Create a temporary file in the same directory as the final file, truncating it if it already exists. /// 4. Call `write_fn` with the temporary file, and wait for `write_fn` to complete successfully. /// 5. Close the temporary file. /// 6. Rename the temporary file to the final file. /// 7. Close (and automatically unlock) the lock file. /// 8. Remove the lock file. /// /// In regular failure cases (full disk, other IO errors, etc), we try to clean up the temporary /// file. If this process is terminated before we can do so, the temporary file will be left /// behind. /// We also clean up the lock file in the case where the destination file has been successfully /// created. In failure cases, we do not clean up the lock file because it's hard to do so without /// interfering with other processes which might have started using the lock file in the meantime. pub async fn create_file_cleanly( dest_path: &Path, write_fn: F, handle_existing_fn: FE, ) -> Result> where E: std::error::Error + Send + Sync + 'static, G: std::future::Future>, GE: std::future::Future>, F: FnOnce(std::fs::File) -> G, FE: FnOnce() -> GE, { let Some(file_name) = dest_path.file_name() else { return Err(CleanFileCreationError::InvalidPath); }; // Create a lock file in the same directory as the final file, or open it if it already exists. let lock_file_path = dest_path.with_file_name(format!("{}.lock", file_name.to_string_lossy())); let lock_file = std::fs::OpenOptions::new() .write(true) .create(true) .truncate(false) .open(&lock_file_path) .map_err(CleanFileCreationError::LockFileCreation)?; let locked_file = lock_file_exclusive(lock_file) .await .map_err(CleanFileCreationError::LockFileLocking)?; // Now the lock file is locked by us. We may be in any one of the following scenarios: // - No collision, destination file doesn't exist yet: We made a new lock file, we locked // it immediately. This is the most common case. // - No collision, but destination file was already there all along: Someone else had // already finished creating this file and cleaned up the lock file before we got here. // We made a new lock file without much purpose. // - The lock call above blocked and we waited for someone else to finish: The destination // file did not exist when we locked, but the temp file and lock file existed, and we // blocked on the lock file being released. It was released once the temp file had been // successfully renamed to the destination file. // - The lock call above blocked but the lock got released before the destination file // existed: This means someone else was trying to create the destination file but failed // to do so. // - The lock call above didn't block but a leftover lock file or temp file might exist // because someone else had failed in the middle of downloading and left some remnants. // Check if the destination file is already there. let destination_file_exists = matches!(std::fs::metadata(dest_path), Ok(meta) if meta.is_file()); if destination_file_exists { // Someone else has already fully created the destination file. // This happened either before or after we attempted to lock the lock file. // Clean up the lock file we created. There probably is no temp file because // the original temp file was renamed into the destination file. drop(locked_file); let _ = std::fs::remove_file(&lock_file_path); let v = handle_existing_fn() .await .map_err(CleanFileCreationError::CallbackIndicatedError)?; return Ok(v); } // Create the temporary file, or open it if it already exists, and truncate it. let temp_file_path = dest_path.with_file_name(format!("{}.part", file_name.to_string_lossy())); let temp_file = std::fs::OpenOptions::new() .write(true) .create(true) .truncate(true) .open(&temp_file_path) .map_err(CleanFileCreationError::TempFileCreation)?; // Call the write function with the temporary file. We pass ownership of the // file to the write function. The write function is responsible for dropping // the file before it returns - this will close the file. let write_result = write_fn(temp_file).await; // The temp file is now closed. // If the write callback failed, propagate the error. let v = match write_result { Ok(v) => v, Err(write_error) => { // Remove the temporary file and close + unlock the lock file. let _ = std::fs::remove_file(&temp_file_path); drop(locked_file); return Err(CleanFileCreationError::CallbackIndicatedError(write_error)); } }; // Everything seems to have worked out. The file has been written to successfully. // Rename it to its final path. match std::fs::rename(&temp_file_path, dest_path) { Ok(_) => {} Err(rename_error) => { // Renaming failed; remove the temporary file and close + unlock the lock file. let _ = std::fs::remove_file(&temp_file_path); drop(locked_file); return Err(CleanFileCreationError::RenameError(rename_error)); } } // The destination file is in place. Remove the lock file and indicate success. // We remove the lock file in this case because, unlike in the failure cases, // in the success case there's no reason to ever need this lock file again - // if anybody else is currently blocking on the file lock, or if anyone else // locks the lock file between the time that we close + unlock the file and the // time that we remove it, they'll just notice that the destination file is // already there and clean up after themselves. drop(locked_file); let _ = std::fs::remove_file(&lock_file_path); Ok(v) } async fn lock_file_exclusive(file: std::fs::File) -> Result { // Use try_lock_exclusive first. If it returns WouldBlock, do the actual blocking locking, // but do it on a different thread so that this thread is available for other tokio tasks. // We do try_lock_exclusive first so that we can avoid launching a new thread in the common case. // We have a retry loop here because file locking can be interrupted by signals. for _ in 0..5 { match file.try_lock_exclusive() { Ok(()) => return Ok(file), Err(e) if e.kind() == io::ErrorKind::Interrupted => continue, Err(e) if e.raw_os_error() == lock_contended_error().raw_os_error() => { return lock_file_exclusive_with_blocking_thread(file).await } Err(e) => return Err(e), } } Err(io::Error::new( io::ErrorKind::Interrupted, "File locking was interrupted too many times", )) } async fn lock_file_exclusive_with_blocking_thread( file: std::fs::File, ) -> Result { // Launch a new thread and call `lock_file_exclusive_blocking_this_thread` in it. // // We don't use tokio::spawn_blocking because you can only use it with tasks that // will make progress even if all other tasks / threads are paused. Grabbing an // exclusive file lock cannot make that guarantee; the lock might be held by // someone in this process who needs to make progress before unlocking, and they // might need tokio's blocking thread pool to do so. let (tx, rx) = tokio::sync::oneshot::channel(); let thread = std::thread::Builder::new() .name("flock".to_string()) .spawn(move || { let locked_file_result = lock_file_exclusive_blocking_this_thread(file); let _ = tx.send(locked_file_result); }) .expect("couldn't create flock thread"); let locked_file = rx.await.expect("flock thread disappeared unexpectedly")?; thread.join().expect("flock thread panicked"); Ok(locked_file) } fn lock_file_exclusive_blocking_this_thread( file: std::fs::File, ) -> Result { // We have a retry loop here because file locking can be interrupted by signals. for _ in 0..5 { match file.lock_exclusive() { // can block Ok(()) => return Ok(file), Err(e) if e.kind() == io::ErrorKind::Interrupted => continue, Err(e) => return Err(e), } } Err(io::Error::new( io::ErrorKind::Interrupted, "File locking was interrupted too many times", )) } symsrv-0.5.3/src/lib.rs000064400000000000000000001531061046102023000131050ustar 00000000000000//! # symsrv //! //! This crate lets you download and cache symbol files from symbol servers, //! according to the rules from the `_NT_SYMBOL_PATH` environment variable. //! //! It exposes an async API. Internally it uses `reqwest` and `tokio`. //! //! The downloaded symbols are stored on the file system. No automatic expiration //! or eviction is performed. If you want to enforce a cache size limit or expire //! old files, you can observe cache file creations and accesses with the //! [`SymsrvObserver`] trait, and then write your own implementation for automatic //! file cleanup. //! //! ## Microsoft Documentation //! //! - [Advanced SymSrv Use](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/advanced-symsrv-use) //! //! ## Example //! //! ``` //! use symsrv::SymsrvDownloader; //! //! # fn open_pdb_at_path(p: &std::path::Path) {} //! # //! # async fn wrapper() -> Result<(), symsrv::Error> { //! // Parse the _NT_SYMBOL_PATH environment variable. //! let symbol_path_env = symsrv::get_symbol_path_from_environment(); //! let symbol_path = symbol_path_env.as_deref().unwrap_or("srv**https://msdl.microsoft.com/download/symbols"); //! let parsed_symbol_path = symsrv::parse_nt_symbol_path(symbol_path); //! //! // Create a downloader which follows the _NT_SYMBOL_PATH recipe. //! let mut downloader = SymsrvDownloader::new(parsed_symbol_path); //! downloader.set_default_downstream_store(symsrv::get_home_sym_dir()); //! //! // Download and cache a PDB file. //! let local_path = downloader.get_file("dcomp.pdb", "648B8DD0780A4E22FA7FA89B84633C231").await?; //! //! // Use the PDB file. //! open_pdb_at_path(&local_path); //! # Ok(()) //! # } //! ``` mod computation_coalescing; mod download; mod file_creation; mod poll_all; mod remotely_fed_cursor; use std::future::Future; use std::io::{BufReader, Read, Seek, Write}; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::pin::Pin; use std::sync::atomic::AtomicU64; use std::sync::Arc; use std::time::Duration; use futures_util::{future, AsyncReadExt}; use tokio::io::AsyncWriteExt; use tokio::time::Instant; use computation_coalescing::ComputationCoalescer; use download::response_to_uncompressed_stream_with_progress; use file_creation::{create_file_cleanly, CleanFileCreationError}; use poll_all::PollAllPreservingOrder; use remotely_fed_cursor::{RemotelyFedCursor, RemotelyFedCursorFeeder}; /// The parsed representation of one entry in the (semicolon-separated list of entries in the) `_NT_SYMBOL_PATH` environment variable. /// The syntax of this string is documented at . #[derive(Clone, Debug, PartialEq, Eq)] pub enum NtSymbolPathEntry { /// Sets a cache path that will be used for subsequent entries, and for any symbol paths that get added at runtime. /// Created for `cache*` entries. Cache(PathBuf), /// A fallback-and-cache chain with optional http / https symbol servers at the end. /// Created for `srv*` and `symsrv*` entries. Chain { /// Usually `symsrv.dll`. (`srv*...` is shorthand for `symsrv*symsrv.dll*...`.) dll: String, /// Any cache directories. The first directory is the "bottom-most" cache. The bottom cache /// is always checked first, and always stores uncompressed files. /// /// Any remaining directories are mid-level cache directories. These can store compressed files. cache_paths: Vec, /// Symbol server URLs. Can serve compressed or uncompressed files. Not used as a cache target. /// These are checked last. urls: Vec, }, /// A path where symbols can be found but which is not used as a cache target. /// Created for entries which are just a path. LocalOrShare(PathBuf), } /// A regular cache directory or a marker for the "default downstream store". #[derive(Clone, Debug, PartialEq, Eq)] pub enum CachePath { /// A placeholder for the directory of the "default downstream store". This is used /// for empty cache items in the `_NT_SYMBOL_PATH`, e.g. if you have a `srv**URL` with /// two asterisks right after each other. DefaultDownstreamStore, /// The path to a directory where this cache is located. Path(PathBuf), } impl CachePath { pub fn to_path<'a>(&'a self, default_downstream_store: &'a Path) -> &'a Path { match self { CachePath::DefaultDownstreamStore => default_downstream_store, CachePath::Path(path) => path, } } } /// Returns the absolute path to the `~/sym` directory. This is a reasonable default for the "default downstream store". /// The return value can be directly passed to [`SymsrvDownloader::set_default_downstream_store`]. /// /// This function returns `None` if the home directory cannot be determined. pub fn get_home_sym_dir() -> Option { let home_dir = dirs::home_dir()?; Some(home_dir.join("sym")) } /// Reads the `_NT_SYMBOL_PATH` environment variable into a string. pub fn get_symbol_path_from_environment() -> Option { std::env::var("_NT_SYMBOL_PATH").ok() } /// Parse the value of the `_NT_SYMBOL_PATH` variable. The format of this variable /// is a semicolon-separated list of entries, where each entry is an asterisk-separated /// hierarchy of symbol locations which can be either directories or server URLs. pub fn parse_nt_symbol_path(symbol_path: &str) -> Vec { fn chain<'a>(dll_name: &str, parts: impl Iterator) -> NtSymbolPathEntry { let mut cache_paths = Vec::new(); let mut urls = Vec::new(); for part in parts { if part.is_empty() { cache_paths.push(CachePath::DefaultDownstreamStore); } else if part.starts_with("http://") || part.starts_with("https://") { urls.push(part.into()); } else { cache_paths.push(CachePath::Path(part.into())); } } NtSymbolPathEntry::Chain { dll: dll_name.to_string(), cache_paths, urls, } } symbol_path .split(';') .filter_map(|segment| { let mut parts = segment.split('*'); let first = parts.next().unwrap(); match first.to_ascii_lowercase().as_str() { "cache" => parts .next() .map(|path| NtSymbolPathEntry::Cache(path.into())), "srv" => Some(chain("symsrv.dll", parts)), "symsrv" => parts.next().map(|dll_name| chain(dll_name, parts)), _ => Some(NtSymbolPathEntry::LocalOrShare(first.into())), } }) .collect() } /// The error type used for results returned from [`SymsrvDownloader::get_file`]. #[derive(thiserror::Error, Debug, Clone)] #[non_exhaustive] pub enum Error { /// There was an error when interacting with the file system. #[error("IO error: {0}")] IoError(String), /// The requested file was not found. #[error("The file was not found in the SymsrvDownloader.")] NotFound, /// No default downstream store was specified, but it was needed. #[error("No default downstream store was specified, but it was needed.")] NoDefaultDownstreamStore, /// The requested path does not have a file extension. #[error("The requested path does not have a file extension.")] NoExtension, /// The requested path does not have a recognized file extension. #[error("The requested path does not have a recognized file extension (exe/dll/pdb/dbg).")] UnrecognizedExtension, /// An internal error occurred: Couldn't join task #[error("An internal error occurred: Couldn't join task")] JoinError(String), /// Generic error from `reqwest`. #[error("ReqwestError: {0}")] ReqwestError(String), /// Unexpected Content-Encoding header. #[error("Unexpected Content-Encoding header: {0}")] UnexpectedContentEncoding(String), /// An error occurred while extracting a CAB archive. #[error("Error while extracting a CAB archive: {0}")] CabExtraction(String), } impl From for Error { fn from(err: std::io::Error) -> Error { Error::IoError(err.to_string()) } } impl From> for Error { fn from(e: CleanFileCreationError) -> Error { match e { CleanFileCreationError::CallbackIndicatedError(e) => e, e => Error::IoError(e.to_string()), } } } /// The error type used in the observer notification [`SymsrvObserver::on_download_failed`]. #[derive(thiserror::Error, Debug)] pub enum DownloadError { /// Creating the reqwest Client failed. #[error("Creating the client failed: {0}")] ClientCreationFailed(String), /// Opening the request failed. #[error("Opening the request failed: {0}")] OpenFailed(Box), /// The download timed out. #[error("The download timed out")] Timeout, /// The server returned a non-success status code. #[error("The server returned status code {0}")] StatusError(http::StatusCode), /// The destination directory could not be created. #[error("The destination directory could not be created")] CouldNotCreateDestinationDirectory, /// The response used an unexpected Content-Encoding. #[error("The response used an unexpected Content-Encoding: {0}")] UnexpectedContentEncoding(String), /// An I/O error occurred in the middle of downloading. #[error("Error during downloading: {0}")] ErrorDuringDownloading(std::io::Error), /// Error while writing the downloaded file. #[error("Error while writing the downloaded file: {0}")] ErrorWhileWritingDownloadedFile(std::io::Error), /// Redirect-related error. #[error("Redirect-related error")] Redirect(Box), /// Other error. #[error("Other error: {0}")] Other(Box), } /// The error type used in the observer notification [`SymsrvObserver::on_cab_extraction_failed`]. #[derive(thiserror::Error, Debug)] pub enum CabExtractionError { /// The CAB archive did not contain any files. #[error("Empty CAB archive")] EmptyCab, /// The CAB archive could not be opened. #[error("Could not open CAB file: {0}")] CouldNotOpenCabFile(std::io::Error), /// The CAB archive could not be parsed. #[error("Error while parsing the CAB file: {0}")] CabParsing(std::io::Error), /// There was an error while reading the CAB archive. #[error("Error while reading the CAB file: {0}")] CabReading(std::io::Error), /// There was an error while writing the extracted file. #[error("Error while writing the file: {0}")] FileWriting(std::io::Error), /// Redirect-related error. #[error("Redirect-related error")] Redirect(Box), /// Other error. #[error("Other error: {0}")] Other(Box), } #[cfg(test)] #[test] fn test_download_error_is_sync() { fn assert_sync() {} assert_sync::(); } impl From for DownloadError { fn from(e: reqwest::Error) -> Self { if e.is_status() { DownloadError::StatusError(e.status().unwrap()) } else if e.is_request() { DownloadError::OpenFailed(e.into()) } else if e.is_redirect() { DownloadError::Redirect(e.into()) } else if e.is_timeout() { DownloadError::Timeout } else { DownloadError::Other(e.into()) } } } /// A trait for observing the behavior of a `SymsrvDownloader`. /// This can be used for logging, displaying progress bars, expiring cached files, etc. pub trait SymsrvObserver: Send + Sync + 'static { /// Called when a new download is about to start, before the connection is established. /// /// The download ID is unique for each download. /// /// For each download ID, we guarantee that exactly one of the following methods /// will be called at the end of the download: `on_download_completed`, /// `on_download_failed`, or `on_download_canceled`. fn on_new_download_before_connect(&self, download_id: u64, url: &str); /// Called once the connection has been established and HTTP headers /// with a success status have arrived. fn on_download_started(&self, download_id: u64); /// Called frequently during the download, whenever a new chunk has been read. /// /// If the HTTP response is gzip-compressed, the number of bytes can refer to /// either the compressed or the uncompressed bytes - but it'll be consistent: /// Either both `bytes_so_far` and `total_bytes` refer to the compressed sizes, /// or both refer to the uncompressed sizes. /// /// If `total_bytes` is `None`, the total size is unknown. fn on_download_progress(&self, download_id: u64, bytes_so_far: u64, total_bytes: Option); /// Called when the download has completed successfully. /// /// Mutually exclusive with `on_download_failed` and `on_download_canceled` for a /// given download ID. fn on_download_completed( &self, download_id: u64, uncompressed_size_in_bytes: u64, time_until_headers: Duration, time_until_completed: Duration, ); /// Called when the download has failed. /// /// This is quite common; the most common reason is [`DownloadError::StatusError`] /// with [`StatusCode::NOT_FOUND`](http::StatusCode::NOT_FOUND), for files which /// are not available on the server. /// /// Mutually exclusive with `on_download_completed` and `on_download_canceled` for a /// given download ID. fn on_download_failed(&self, download_id: u64, reason: DownloadError); /// Called when the download has been canceled. /// /// This does not indicate an error. We commonly attempt to download a file from /// multiple sources simultaneously, and cancel other downloads once one has succeeded. /// /// This function is also called if the user cancels the download by dropping the future /// returned from [`SymsrvDownloader::get_file`]. /// /// Mutually exclusive with `on_download_completed` and `on_download_failed` for a /// given download ID. fn on_download_canceled(&self, download_id: u64); /// Called when a new CAB extraction is about to start. fn on_new_cab_extraction(&self, extraction_id: u64, dest_path: &Path); /// Called periodically during a CAB extraction. The byte counts refer to the uncompressed size. fn on_cab_extraction_progress(&self, extraction_id: u64, bytes_so_far: u64, total_bytes: u64); /// Called when a CAB extraction has completed successfully. fn on_cab_extraction_completed( &self, extraction_id: u64, uncompressed_size_in_bytes: u64, time_until_completed: Duration, ); /// Called when a CAB extraction has failed. fn on_cab_extraction_failed(&self, extraction_id: u64, reason: CabExtractionError); /// Called when a CAB extraction has been canceled. fn on_cab_extraction_canceled(&self, extraction_id: u64); /// Called when a file has been created, for example because it was downloaded from /// a server, copied from a different cache directory, or extracted from a compressed /// file. fn on_file_created(&self, path: &Path, size_in_bytes: u64); /// Called when a file from the cache has been used to service a [`SymsrvDownloader::get_file`] call. /// /// This is only called for pre-existing files and not for newly-created files - newly-created /// files only trigger a call to `on_file_created`. /// /// Useful to guide expiration decisions. fn on_file_accessed(&self, path: &Path); /// Called when we were looking for a file in the cache, and it wasn't there. Used for /// debug logging. /// /// Also called if checking for file existence fails for any other reason. fn on_file_missed(&self, path: &Path); } static NEXT_DOWNLOAD_OR_EXTRACTION_ID: AtomicU64 = AtomicU64::new(0); /// Obtains symbol files (PDBs + binary files) according to the instructions in the symbol path. /// /// Create a new instance with [`SymsrvDownloader::new`], and then use the /// [`get_file`](SymsrvDownloader::get_file) method to obtain files. pub struct SymsrvDownloader { inner: Arc, inflight_request_cache: ComputationCoalescer<(String, String, bool), PinBoxDynFuture>>, } type PinBoxDynFuture = Pin + Send + Sync>>; struct SymsrvDownloaderInner { symbol_path: Vec, default_downstream_store: Option, observer: Option>, reqwest_client: Result, } #[cfg(test)] #[test] fn test_symsrv_downloader_error_is_send_and_sync() { fn assert_send() {} fn assert_sync() {} assert_send::(); assert_sync::(); } impl SymsrvDownloader { /// Create a new `SymsrvDownloader`. /// /// `symbol_path` describes the behavior of the downloader, including which servers to /// download from and which cache directories to use. The symbol path is commonly created /// by parsing the `_NT_SYMBOL_PATH` environment variable with [`parse_nt_symbol_path`]. /// /// # Example /// /// ``` /// use std::path::Path; /// use symsrv::SymsrvDownloader; /// /// let symbol_path_env = symsrv::get_symbol_path_from_environment(); /// let symbol_path = symbol_path_env.as_deref().unwrap_or("srv**https://msdl.microsoft.com/download/symbols"); /// let parsed_symbol_path = symsrv::parse_nt_symbol_path(symbol_path); /// /// let mut downloader = SymsrvDownloader::new(parsed_symbol_path); /// downloader.set_default_downstream_store(symsrv::get_home_sym_dir()); /// ``` pub fn new(symbol_path: Vec) -> Self { Self { inner: Arc::new(SymsrvDownloaderInner::new(symbol_path)), inflight_request_cache: ComputationCoalescer::new(), } } /// Set the observer for this downloader. /// /// The observer can be used for logging, displaying progress bars, informing /// automatic expiration of cached files, and so on. /// /// See the [`SymsrvObserver`] trait for more information. pub fn set_observer(&mut self, observer: Option>) { Arc::get_mut(&mut self.inner).unwrap().observer = observer; } /// Set the default downstream store. In the `srv*DOWNSTREAM_STORE*URL` syntax for `_NT_SYMBOL_PATH`, /// leaving the `DOWNSTREAM_STORE` part empty (i.e. having to asterisks in a row, as in `srv**URL`) /// causes this default directory to be used. /// /// You can set this to `symsrv::get_home_sym_dir()` to use the `~/sym` directory. /// /// You can also leave this at the default `None` to disable the default downstream store; /// this means that `srv**URL` entries will not work because the downloads have nowhere to go. /// /// The Windows Debugger [chooses the default downstream store as follows](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/advanced-symsrv-use): /// > If you include two asterisks in a row where a downstream store would normally be specified, /// > then the default downstream store is used. This store will be located in the sym subdirectory /// > of the home directory. The home directory defaults to the debugger installation directory; /// > this can be changed by using the [!homedir](https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/-homedir) /// > extension or by setting the `DBGHELP_HOMEDIR` environment variable. pub fn set_default_downstream_store>( &mut self, default_downstream_store: Option

, ) { Arc::get_mut(&mut self.inner) .unwrap() .default_downstream_store = default_downstream_store.map(Into::into); } /// This is the primary entry point to fetch files. It looks up the /// file according to the recipe in the symbol path, by searching /// cache directories, downloading files from servers, and uncompressing files /// as needed. /// /// If a matching file is found, a [`PathBuf`] with the path to the uncompressed /// file on the local file system is returned. /// /// The file name can be the name of a PDB file or of a binary file (i.e. .exe or .dll). /// /// The syntax of the hash depends on the file type: /// /// - For PDBs: The hash is ``, with `` in uppercase hex (no dashes) /// and `` in lowercase hex. /// - For binaries: The hash is ``, with `` /// printed as eight uppercase hex digits (with leading zeros added as needed) /// and `` in lowercase hex digits (no leading zeros). /// /// Examples: /// /// - `xul.pdb`, `B2A2B092E45739B84C4C44205044422E1` /// - `renderdoc.dll`, `61015E74442b000` /// /// The PDB hash is commonly created with the help of the `debugid` crate, /// using [`DebugId::breakpad()`](https://docs.rs/debugid/latest/debugid/struct.DebugId.html#method.breakpad). /// /// The binary hash (the "code ID") can be created using /// [`wholesym::PeCodeId`](https://docs.rs/wholesym/latest/wholesym/struct.PeCodeId.html). pub async fn get_file(&self, filename: &str, hash: &str) -> Result { self.get_file_impl(filename, hash, true).await } /// Same as [`get_file`](Self::get_file), but only checks cache directories. /// No downloads are attempted. pub async fn get_file_no_download(&self, filename: &str, hash: &str) -> Result { self.get_file_impl(filename, hash, false).await } async fn get_file_impl( &self, filename: &str, hash: &str, allow_downloads: bool, ) -> Result { let inner = self.inner.clone(); let filename = filename.to_owned(); let hash = hash.to_owned(); self.inflight_request_cache .subscribe_or_compute( &(filename.clone(), hash.clone(), allow_downloads), move || { let f = async move { inner.get_file_impl(&filename, &hash, allow_downloads).await }; Box::pin(f) }, ) .await } } impl SymsrvDownloaderInner { pub fn new(symbol_path: Vec) -> Self { let builder = reqwest::Client::builder(); // Turn off HTTP 2, in order to work around https://github.com/seanmonstar/reqwest/issues/1761 . let builder = builder.http1_only(); // Turn off automatic decompression because it doesn't allow us to compute // download progress percentages: we'd only know the decompressed current // size and the compressed total size. // Instead, we do the streaming decompression manually, see download.rs. let builder = builder.no_gzip().no_brotli().no_deflate(); // Create the client. // TODO: Add timeouts, user agent, maybe other settings let client = builder.build(); Self { symbol_path, default_downstream_store: None, observer: None, reqwest_client: client, } } pub async fn get_file_impl( &self, filename: &str, hash: &str, allow_downloads: bool, ) -> Result { let path: PathBuf = [filename, hash, filename].iter().collect(); let rel_path_uncompressed = &path; let rel_path_compressed = create_compressed_path(rel_path_uncompressed)?; // This array will contain cache paths from `cache*` entries. These get added // once they are encountered. Once encountered, they apply to all subsequent // entries. let mut persisted_cache_paths: Vec = Vec::new(); // Iterate all entries in the symbol path, checking them for matches one by one. for entry in &self.symbol_path { match entry { NtSymbolPathEntry::Cache(cache_dir) => { let cache_path = CachePath::Path(cache_dir.into()); if persisted_cache_paths.contains(&cache_path) { continue; } // Check if the symbol file is present in this cache. If found, also persist // it to the previous cache paths. if let Some(found_path) = self .check_directory( cache_dir, &persisted_cache_paths, rel_path_uncompressed, &rel_path_compressed, ) .await? { return Ok(found_path); } // Add this path to `persisted_cache_paths` so that any matches in the // upcoming entries can be persisted to this cache. persisted_cache_paths.push(cache_path); } NtSymbolPathEntry::Chain { cache_paths, urls, .. } => { // If the symbol file is found, it should also be persisted (copied) to all // of these paths. let mut parent_cache_paths = persisted_cache_paths.clone(); for cache_path in cache_paths { if parent_cache_paths.contains(cache_path) { continue; } parent_cache_paths.push(cache_path.clone()); // Check if the symbol file is present at this path. If found, also persist // it to the previous cache paths. let (_, parent_cache_paths) = parent_cache_paths.split_last().unwrap(); if let Some(cache_dir) = self.resolve_cache_path(cache_path) { if let Some(found_path) = self .check_directory( cache_dir, parent_cache_paths, rel_path_uncompressed, &rel_path_compressed, ) .await? { return Ok(found_path); } } } // The symbol file was not found in any of the cache paths. Try to download it // from the server URLs in this entry. if !allow_downloads { // We're not allowed to download anything. Go to the next entry. continue; } // First, make sure we have a place to download to. let (download_dest_cache, remaining_caches) = parent_cache_paths .split_last() .unwrap_or((&CachePath::DefaultDownstreamStore, &[])); let download_dest_cache_dir = self .resolve_cache_path(download_dest_cache) .ok_or(Error::NoDefaultDownstreamStore)?; let bottom_cache = parent_cache_paths .first() .unwrap_or(&CachePath::DefaultDownstreamStore); // Make a list of URLs to try. For each URL, we try both the uncompressed and // compressed file, in that order. let mut file_urls = Vec::with_capacity(urls.len() * 2); for server_url in urls { file_urls.push(( url_join(server_url, rel_path_uncompressed.components()), false, )); file_urls .push((url_join(server_url, rel_path_compressed.components()), true)); } // Prepare requests to all candidate URLs. let response_futures: Vec<_> = file_urls .into_iter() .map(|(file_url, is_compressed)| async move { ( self.prepare_download_of_file(&file_url).await, is_compressed, ) }) .map(Box::pin) .collect(); // Start all requests and wait for the first successful response, then cancel // all other requests by dropping the array of futures. let Some((notifier, response, is_compressed)) = async { let mut response_futures = PollAllPreservingOrder::new(response_futures); while let Some(next_response) = response_futures.next().await { let (prepared_response, is_compressed) = next_response; if let Some((notifier, response)) = prepared_response { // This request returned a success status from the server. return Some((notifier, response, is_compressed)); }; } None } .await else { // All requests failed. // We are done with this `NtSymbolPathEntry::Chain`. Go to the next entry. continue; }; // If we get here, we have a response with a success HTTP status. // Download the file. If successful, also persist the file to the previous cache paths. let uncompressed_dest_path = if is_compressed { let (rx, tx) = remotely_fed_cursor::create_cursor_channel(); let download_dest_path_future = self.download_file_to_cache( notifier, response, &rel_path_compressed, download_dest_cache_dir, Some(tx), ); let extraction_result_future = self.extract_to_file_in_cache( CabDataSource::Cursor(rx), rel_path_uncompressed, bottom_cache, ); let (download_dest_path, extraction_result) = future::join(download_dest_path_future, extraction_result_future).await; let Some(dest_path) = download_dest_path else { continue; }; // We have a file! if let Some((_remaining_bottom_cache, remaining_mid_level_caches)) = remaining_caches.split_first() { // Copy the compressed file to the mid-level caches. self.copy_file_to_caches( &rel_path_compressed, &dest_path, remaining_mid_level_caches, ) .await; } // Return the path to the uncompressed file in the bottom cache. extraction_result? } else { let dest_path = self .download_file_to_cache( notifier, response, rel_path_uncompressed, download_dest_cache_dir, None, ) .await; let Some(dest_path) = dest_path else { continue }; // The file is not compressed. Just copy to the other caches. self.copy_file_to_caches( rel_path_uncompressed, &dest_path, remaining_caches, ) .await; dest_path }; return Ok(uncompressed_dest_path); } NtSymbolPathEntry::LocalOrShare(dir_path) => { if persisted_cache_paths.contains(&CachePath::Path(dir_path.into())) { continue; } // Check if the symbol file is present at this path. If found, also persist // it to the previous cache paths. if let Some(found_path) = self .check_directory( dir_path, &persisted_cache_paths, rel_path_uncompressed, &rel_path_compressed, ) .await? { return Ok(found_path); }; } } } Err(Error::NotFound) } /// Return whether a file is found at `path`, and notify the observer if not. async fn check_file_exists(&self, path: &Path) -> bool { let file_exists = matches!(tokio::fs::metadata(path).await, Ok(meta) if meta.is_file()); if !file_exists { if let Some(observer) = self.observer.as_deref() { observer.on_file_missed(path); } } file_exists } fn resolve_cache_path<'a>(&'a self, cache_path: &'a CachePath) -> Option<&'a Path> { match cache_path { CachePath::Path(path) => Some(path), CachePath::DefaultDownstreamStore => self.default_downstream_store.as_deref(), } } /// Attempt to find the file on the local file system. This is done first, before any downloading /// is attempted. If a file is found, it is copied into the caches given by `parent_cache_paths` /// and uncompressed if needed. On success, the bottom-most cache in `parent_cache_paths` (i.e. /// the first entry) will always have the uncompressed file, and the other caches with have /// whichever file was found in `dir`. async fn check_directory( &self, dir: &Path, parent_cache_paths: &[CachePath], rel_path_uncompressed: &Path, rel_path_compressed: &Path, ) -> Result, Error> { let full_candidate_path = dir.join(rel_path_uncompressed); let full_candidate_path_compr = dir.join(rel_path_compressed); let (abs_path, is_compressed) = if self.check_file_exists(&full_candidate_path).await { (full_candidate_path, false) } else if self.check_file_exists(&full_candidate_path_compr).await { (full_candidate_path_compr, true) } else { return Ok(None); }; // We found a file. Yay! if let Some(observer) = self.observer.as_deref() { observer.on_file_accessed(&abs_path); } let uncompressed_path = if is_compressed { if let Some((bottom_most_cache, mid_level_caches)) = parent_cache_paths.split_first() { // We have at least one cache, and the file is compressed. // Copy the compressed file to the mid-level caches, and uncompress the file // into the bottom-most cache. self.copy_file_to_caches(rel_path_compressed, &abs_path, mid_level_caches) .await; self.extract_to_file_in_cache( CabDataSource::Filename(abs_path.clone()), rel_path_uncompressed, bottom_most_cache, ) .await? } else { // We have no cache. Extract it into the default downstream cache. self.extract_to_file_in_cache( CabDataSource::Filename(abs_path.clone()), rel_path_uncompressed, &CachePath::DefaultDownstreamStore, ) .await? } } else { abs_path }; Ok(Some(uncompressed_path)) } /// Copy the file at `abs_path` to the cache directories given by `caches`, using /// `rel_path` to create the correct destination path for each cache. async fn copy_file_to_caches(&self, rel_path: &Path, abs_path: &Path, caches: &[CachePath]) { for cache_path in caches { if let Some(cache_dir) = self.resolve_cache_path(cache_path) { if let Ok(dest_path) = self .make_dest_path_and_ensure_parent_dirs(rel_path, cache_dir) .await { // TODO: Check what happens if this process dies in the middle of copying // - do we leave a half-copied file behind? Should we use `create_file_cleanly`? if let Ok(copied_bytes) = tokio::fs::copy(&abs_path, &dest_path).await { if let Some(observer) = self.observer.as_deref() { observer.on_file_created(&dest_path, copied_bytes); } } } } } } /// Given a relative file path and a cache directory path, concatenate the two to make /// a destination path, and create the necessary directories so that a file can be stored /// at the destination path. async fn make_dest_path_and_ensure_parent_dirs( &self, rel_path: &Path, cache_path: &Path, ) -> Result { let dest_path = cache_path.join(rel_path); if let Some(dir) = dest_path.parent() { tokio::fs::create_dir_all(dir).await?; } Ok(dest_path) } /// Uncompress the cab-compressed `bytes` and store the result in a cache /// directory. async fn extract_to_file_in_cache( &self, cab_data_source: CabDataSource, rel_path: &Path, cache_path: &CachePath, ) -> Result { let cache_path = self .resolve_cache_path(cache_path) .ok_or(Error::NoDefaultDownstreamStore)?; let dest_path = self .make_dest_path_and_ensure_parent_dirs(rel_path, cache_path) .await?; let notifier = { let observer = self.observer.clone(); let extraction_id = NEXT_DOWNLOAD_OR_EXTRACTION_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed); if let Some(observer) = observer.as_deref() { observer.on_new_cab_extraction(extraction_id, &dest_path); } ExtractionStatusReporter::new(extraction_id, observer) }; let extraction_id = notifier.extraction_id(); let observer = self.observer.clone(); let extracted_size_result = create_file_cleanly( &dest_path, |mut dest_file: std::fs::File| async { tokio::task::spawn_blocking(move || match cab_data_source { CabDataSource::Filename(compressed_input_path) => { let file = std::fs::File::open(compressed_input_path) .map_err(CabExtractionError::CouldNotOpenCabFile)?; let buf_read = BufReader::new(file); extract_cab_to_file(extraction_id, buf_read, &mut dest_file, observer) } CabDataSource::Cursor(cursor) => { extract_cab_to_file(extraction_id, cursor, &mut dest_file, observer) } }) .await .expect("task panicked") }, || async { let size = std::fs::metadata(&dest_path) .map_err(|_| { CabExtractionError::Other( "Could not get size of existing extracted file".into(), ) })? .len(); Ok(size) }, ) .await; let extracted_size = match extracted_size_result { Ok(size) => size, Err(e) => { let error = Error::CabExtraction(format!("{}", e)); match e { CleanFileCreationError::CallbackIndicatedError(e) => { notifier.extraction_failed(e); } _ => { notifier.extraction_failed(CabExtractionError::FileWriting(e.into())); } } return Err(error); } }; notifier.extraction_completed(extracted_size, Instant::now()); if let Some(observer) = self.observer.as_deref() { observer.on_file_created(&dest_path, extracted_size); } Ok(dest_path) } async fn prepare_download_of_file( &self, url: &str, ) -> Option<(DownloadStatusReporter, reqwest::Response)> { let download_id = NEXT_DOWNLOAD_OR_EXTRACTION_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed); if let Some(observer) = self.observer.as_deref() { observer.on_new_download_before_connect(download_id, url); } let reporter = DownloadStatusReporter::new(download_id, self.observer.clone()); let reqwest_client = match self.reqwest_client.as_ref() { Ok(client) => client, Err(e) => { reporter.download_failed(DownloadError::ClientCreationFailed(e.to_string())); return None; } }; let request_builder = reqwest_client.get(url); // Manually specify the Accept-Encoding header. // This would happen automatically if we hadn't turned off automatic // decompression for this reqwest client. let request_builder = request_builder.header("Accept-Encoding", "gzip"); // Send the request and wait for the headers. let response_result = request_builder.send().await; // Check the HTTP status code. let response_result = response_result.and_then(|response| response.error_for_status()); let response = match response_result { Ok(response) => response, Err(e) => { // The request failed, most commonly due to a 404 status code. reporter.download_failed(DownloadError::from(e)); return None; } }; Some((reporter, response)) } /// Download the file at `url` to a file in `cache_dir``. async fn download_file_to_cache( &self, reporter: DownloadStatusReporter, response: reqwest::Response, rel_path: &Path, cache_dir: &Path, mut chunk_consumer: Option, ) -> Option { // We have a response with a success status code. let ts_after_status = Instant::now(); let download_id = reporter.download_id(); if let Some(observer) = self.observer.as_deref() { observer.on_download_started(download_id); } let dest_path = match self .make_dest_path_and_ensure_parent_dirs(rel_path, cache_dir) .await { Ok(dest_path) => dest_path, Err(_e) => { reporter.download_failed(DownloadError::CouldNotCreateDestinationDirectory); return None; } }; let observer = self.observer.clone(); let mut stream = match response_to_uncompressed_stream_with_progress( response, move |bytes_so_far, total_bytes| { if let Some(observer) = observer.as_deref() { observer.on_download_progress(download_id, bytes_so_far, total_bytes) } }, ) { Ok(stream) => stream, Err(download::Error::UnexpectedContentEncoding(encoding)) => { reporter.download_failed(DownloadError::UnexpectedContentEncoding(encoding)); return None; } }; let download_result: Result> = create_file_cleanly( &dest_path, |dest_file: std::fs::File| async move { let mut dest_file = tokio::fs::File::from_std(dest_file); let mut buf = vec![0u8; 4096]; let mut uncompressed_size_in_bytes = 0; loop { let count = stream.read(&mut buf).await?; if count == 0 { break; } uncompressed_size_in_bytes += count as u64; dest_file.write_all(&buf[..count]).await?; if let Some(chunk_consumer) = &mut chunk_consumer { chunk_consumer.feed(&buf[..count]); } } if let Some(chunk_consumer) = &mut chunk_consumer { chunk_consumer.mark_complete(); } dest_file.flush().await?; Ok(uncompressed_size_in_bytes) }, || async { let size = std::fs::metadata(&dest_path)?.len(); Ok(size) }, ) .await; let uncompressed_size_in_bytes = match download_result { Ok(size) => size, Err(CleanFileCreationError::CallbackIndicatedError(e)) => { reporter.download_failed(DownloadError::ErrorDuringDownloading(e)); return None; } Err(e) => { reporter.download_failed(DownloadError::ErrorWhileWritingDownloadedFile(e.into())); return None; } }; let ts_after_download = Instant::now(); reporter.download_completed( uncompressed_size_in_bytes, ts_after_status, ts_after_download, ); if let Some(observer) = self.observer.as_deref() { observer.on_file_created(&dest_path, uncompressed_size_in_bytes); } Some(dest_path) } } enum CabDataSource { Filename(PathBuf), Cursor(RemotelyFedCursor), } fn get_first_file_entry(cabinet: &mut cab::Cabinet) -> Option<(String, u64)> { for folder in cabinet.folder_entries() { if let Some(file) = folder.file_entries().next() { return Some((file.name().to_owned(), file.uncompressed_size().into())); } } None } fn extract_cab_to_file( extraction_id: u64, source_data: R, dest_file: &mut std::fs::File, observer: Option>, ) -> Result { use CabExtractionError::*; let mut cabinet = cab::Cabinet::new(source_data).map_err(CabParsing)?; let (file_entry_name, file_extracted_size) = get_first_file_entry(&mut cabinet).ok_or(EmptyCab)?; let mut reader = cabinet.read_file(&file_entry_name).map_err(CabParsing)?; let mut bytes_written = 0; loop { let mut buf = [0; 4096]; let bytes_read = reader.read(&mut buf).map_err(CabReading)?; if bytes_read == 0 { break; } dest_file .write_all(&buf[..bytes_read]) .map_err(FileWriting)?; bytes_written += bytes_read as u64; if let Some(observer) = observer.as_deref() { observer.on_cab_extraction_progress(extraction_id, bytes_written, file_extracted_size); } } Ok(bytes_written) } /// Convert a relative `Path` into a URL by appending the components to the /// given base URL. fn url_join(base_url: &str, components: std::path::Components) -> String { format!( "{}/{}", base_url.trim_end_matches('/'), components .map(|c| c.as_os_str().to_string_lossy()) .collect::>() .join("/") ) } /// From a path to the uncompressed exe/dll/pdb file, create the path to the /// compressed file, by replacing the last char of the file extension with /// an underscore. These files are cab-compressed. fn create_compressed_path(uncompressed_path: &Path) -> Result { let uncompressed_ext = match uncompressed_path.extension() { Some(ext) => match ext.to_string_lossy().deref() { "exe" => "ex_", "dll" => "dl_", "pdb" => "pd_", "dbg" => "db_", _ => return Err(Error::UnrecognizedExtension), }, None => return Err(Error::NoExtension), }; let mut compressed_path = uncompressed_path.to_owned(); compressed_path.set_extension(uncompressed_ext); Ok(compressed_path) } /// A helper struct with a drop handler. This lets us detect when a download /// is cancelled by dropping the future. struct DownloadStatusReporter { /// Set to `None` when `download_failed()` or `download_completed()` is called. download_id: Option, observer: Option>, ts_before_connect: Instant, } impl DownloadStatusReporter { pub fn new(download_id: u64, observer: Option>) -> Self { Self { download_id: Some(download_id), observer, ts_before_connect: Instant::now(), } } pub fn download_id(&self) -> u64 { self.download_id.unwrap() } pub fn download_failed(mut self, e: DownloadError) { if let (Some(download_id), Some(observer)) = (self.download_id, self.observer.as_deref()) { observer.on_download_failed(download_id, e); } self.download_id = None; // Drop self. Now the Drop handler won't do anything. } pub fn download_completed( mut self, uncompressed_size_in_bytes: u64, ts_after_headers: Instant, ts_after_completed: Instant, ) { if let (Some(download_id), Some(observer)) = (self.download_id, self.observer.as_deref()) { let time_until_headers = ts_after_headers.duration_since(self.ts_before_connect); let time_until_completed = ts_after_completed.duration_since(self.ts_before_connect); observer.on_download_completed( download_id, uncompressed_size_in_bytes, time_until_headers, time_until_completed, ); } self.download_id = None; // Drop self. Now the Drop handler won't do anything. } } impl Drop for DownloadStatusReporter { fn drop(&mut self) { if let (Some(download_id), Some(observer)) = (self.download_id, self.observer.as_deref()) { // We were dropped before a call to `download_failed` or `download_completed`. // This was most likely because the future we were stored in was dropped. // Tell the observer. observer.on_download_canceled(download_id); } } } /// A helper struct with a drop handler. This lets us detect when a extraction /// is cancelled by dropping the future. struct ExtractionStatusReporter { /// Set to `None` when `extraction_failed()` or `extraction_completed()` is called. extraction_id: Option, observer: Option>, ts_before_start: Instant, } impl ExtractionStatusReporter { pub fn new(extraction_id: u64, observer: Option>) -> Self { Self { extraction_id: Some(extraction_id), observer, ts_before_start: Instant::now(), } } pub fn extraction_id(&self) -> u64 { self.extraction_id.unwrap() } pub fn extraction_failed(mut self, e: CabExtractionError) { if let (Some(extraction_id), Some(observer)) = (self.extraction_id, self.observer.as_deref()) { observer.on_cab_extraction_failed(extraction_id, e); } self.extraction_id = None; // Drop self. Now the Drop handler won't do anything. } pub fn extraction_completed( mut self, uncompressed_size_in_bytes: u64, ts_after_completed: Instant, ) { if let (Some(extraction_id), Some(observer)) = (self.extraction_id, self.observer.as_deref()) { let time_until_completed = ts_after_completed.duration_since(self.ts_before_start); observer.on_cab_extraction_completed( extraction_id, uncompressed_size_in_bytes, time_until_completed, ); } self.extraction_id = None; // Drop self. Now the Drop handler won't do anything. } } impl Drop for ExtractionStatusReporter { fn drop(&mut self) { if let (Some(extraction_id), Some(observer)) = (self.extraction_id, self.observer.as_deref()) { // We were dropped before a call to `extraction_failed` or `extraction_completed`. // This was most likely because the future we were stored in was dropped. // Tell the observer. observer.on_cab_extraction_canceled(extraction_id); } } } symsrv-0.5.3/src/poll_all.rs000064400000000000000000000104551046102023000141340ustar 00000000000000use std::future::{poll_fn, Future}; use std::task::Poll; use futures_util::FutureExt; /// Provides a way to iterate over a collection of futures, but polling all /// of them from the start. This can be used to start e.g. network requests /// in parallel and to consume the results in the original order. pub struct PollAllPreservingOrder + Unpin> { values: Vec>, // None if pending or already consumed, Some if ready pending_futures: Vec<(usize, F)>, current_index: usize, } impl + Unpin> PollAllPreservingOrder { pub fn new(futures: Vec) -> Self { Self { values: futures.iter().map(|_| None).collect(), pending_futures: futures.into_iter().enumerate().collect(), current_index: 0, } } pub async fn next(&mut self) -> Option { poll_fn(move |cx| { if self.current_index == self.values.len() { return Poll::Ready(None); } // Poll all pending futures and remove the ones that are ready, // storing their values in the values array. self.pending_futures .retain_mut(|(i, f)| match f.poll_unpin(cx) { Poll::Pending => true, Poll::Ready(e) => { self.values[*i] = Some(e); false } }); if let Some(next_value) = self.values[self.current_index].take() { self.current_index += 1; Poll::Ready(Some(next_value)) } else { Poll::Pending } }) .await } } #[cfg(test)] mod tests { use super::*; use futures_util::future::ready; #[tokio::test] async fn test_poll_all_ready() { let futures = vec![ready(1), ready(2), ready(3), ready(4), ready(5), ready(6)]; let mut poll_all = PollAllPreservingOrder::new(futures); assert_eq!(poll_all.next().await, Some(1)); assert_eq!(poll_all.next().await, Some(2)); assert_eq!(poll_all.next().await, Some(3)); assert_eq!(poll_all.next().await, Some(4)); assert_eq!(poll_all.next().await, Some(5)); assert_eq!(poll_all.next().await, Some(6)); assert_eq!(poll_all.next().await, None); } #[tokio::test] async fn test_poll_some_pending() { // We create a tokio channel to send numbers. The channel broadcasts the messages // to all receivers. Then we create six receivers. Each receiver has an associated // threshold and a value. The receiver will read from the channel until it receives // a number which is at least as big as its threshold. Then it will return the value. async fn yield_until_threshold_exceeded( mut rx: tokio::sync::broadcast::Receiver, threshold: i32, value: i32, ) -> i32 { loop { let msg = rx.recv().await.unwrap(); if msg >= threshold { return value; } tokio::task::yield_now().await; } } let (tx, _) = tokio::sync::broadcast::channel(100); let receivers = vec![ yield_until_threshold_exceeded(tx.subscribe(), 6, 1), yield_until_threshold_exceeded(tx.subscribe(), 3, 2), yield_until_threshold_exceeded(tx.subscribe(), 5, 3), yield_until_threshold_exceeded(tx.subscribe(), 1, 4), yield_until_threshold_exceeded(tx.subscribe(), 2, 5), yield_until_threshold_exceeded(tx.subscribe(), 4, 6), ]; // Feed messages into the channel. for x in 0..10 { tx.send(x).unwrap(); } // Create the poller and check that it returns the values in the correct order. let mut poll_all = PollAllPreservingOrder::new(receivers.into_iter().map(Box::pin).collect()); assert_eq!(poll_all.next().await, Some(1)); assert_eq!(poll_all.next().await, Some(2)); assert_eq!(poll_all.next().await, Some(3)); assert_eq!(poll_all.next().await, Some(4)); assert_eq!(poll_all.next().await, Some(5)); assert_eq!(poll_all.next().await, Some(6)); assert_eq!(poll_all.next().await, None); } } symsrv-0.5.3/src/remotely_fed_cursor.rs000064400000000000000000000133051046102023000164060ustar 00000000000000use std::io::{Read, Seek, SeekFrom}; use std::sync::{Arc, Condvar, Mutex}; /// Create something like a channel, where the sending side feeds chunks of `&[u8]` data /// into the channel, and the receiving side collects it into a big `Vec` and can be /// used as a `Read` and `Seek` object, synchonously blocking until the data is available. /// /// We use this for streaming CAB extraction: The CAB API expects us to provide a `Read` object /// that it can synchronously read from. But our data arrives in chunks from an `AsyncRead` /// source. Se we make a blocking task for the CAB extraction, and feed the chunks into the /// `RemotelyFedCursor` as they arrive. Then the blocking task can synchronously wait during /// `Read::read` calls until the data is available. pub fn create_cursor_channel() -> (RemotelyFedCursor, RemotelyFedCursorFeeder) { let shared = Arc::new(( Mutex::new(RemotelyFedCursorMutexData::new()), Condvar::new(), )); let feeder = RemotelyFedCursorFeeder { shared: shared.clone(), }; let cursor = RemotelyFedCursor { shared, current_pos: 0, current_known_length: 0, have_complete_length: false, }; (cursor, feeder) } pub struct RemotelyFedCursor { shared: Arc<(Mutex, Condvar)>, current_pos: u64, current_known_length: u64, have_complete_length: bool, } pub struct RemotelyFedCursorFeeder { shared: Arc<(Mutex, Condvar)>, } struct RemotelyFedCursorMutexData { buffer: Vec, is_complete: bool, } impl RemotelyFedCursor { fn get_complete_len(&mut self) -> u64 { if self.have_complete_length { return self.current_known_length; } let (lock, cvar) = &*self.shared; let mut shared = lock.lock().unwrap(); self.current_known_length = shared.buffer.len() as u64; self.have_complete_length = shared.is_complete; while !self.have_complete_length { shared = cvar.wait(shared).expect("condition variable wait failed"); self.current_known_length = shared.buffer.len() as u64; self.have_complete_length = shared.is_complete; } self.current_known_length } fn wait_until_len_known_or_at_least(&mut self, min_len: u64) -> u64 { if self.have_complete_length || self.current_known_length >= min_len { return self.current_known_length; } let (lock, cvar) = &*self.shared; let mut shared = lock.lock().unwrap(); self.current_known_length = shared.buffer.len() as u64; self.have_complete_length = shared.is_complete; while !self.have_complete_length && self.current_known_length < min_len { // eprintln!("Looking for length {min_len}, have {}", self.current_known_length); // Wait until the condition variable is signaled, indicating // that the length has updated. shared = cvar.wait(shared).expect("condition variable wait failed"); self.current_known_length = shared.buffer.len() as u64; self.have_complete_length = shared.is_complete; } self.current_known_length } } impl RemotelyFedCursorFeeder { pub fn feed(&self, bytes: &[u8]) { let (lock, cvar) = &*self.shared; let mut shared = lock.lock().unwrap(); shared.buffer.extend_from_slice(bytes); cvar.notify_one(); } pub fn mark_complete(&self) { let (lock, cvar) = &*self.shared; let mut shared = lock.lock().unwrap(); shared.is_complete = true; cvar.notify_one(); } } impl RemotelyFedCursorMutexData { pub fn new() -> Self { Self { buffer: Vec::new(), is_complete: false, } } } impl Seek for RemotelyFedCursor { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(new_pos) => new_pos, SeekFrom::End(offset) => { let new_pos = self.get_complete_len() as i64 + offset; if new_pos < 0 { return Err(std::io::Error::new( std::io::ErrorKind::InvalidInput, "invalid seek to a negative position", )); } new_pos as u64 } SeekFrom::Current(offset) => { let new_pos = self.current_pos as i64 + offset; if new_pos < 0 { return Err(std::io::Error::new( std::io::ErrorKind::InvalidInput, "invalid seek to a negative position", )); } new_pos as u64 } }; self.current_pos = new_pos; Ok(new_pos) } } impl Read for RemotelyFedCursor { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let buf_end_pos = self.current_pos + buf.len() as u64; let available_end_pos = self.wait_until_len_known_or_at_least(buf_end_pos); if self.current_pos >= available_end_pos { return Ok(0); } let bytes_to_copy = std::cmp::min(buf.len() as u64, available_end_pos - self.current_pos); { let (lock, _cvar) = &*self.shared; let shared = lock.lock().unwrap(); self.current_known_length = shared.buffer.len() as u64; self.have_complete_length = shared.is_complete; buf[..bytes_to_copy as usize].copy_from_slice( &shared.buffer[self.current_pos as usize..][..bytes_to_copy as usize], ); } self.current_pos += bytes_to_copy; Ok(bytes_to_copy as usize) } }