diff --git a/Cargo.lock b/Cargo.lock index 96f35354..04ec2966 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,24 +4,24 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "atomic-polyfill" -version = "0.1.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" dependencies = [ "critical-section", ] @@ -32,16 +32,16 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" @@ -49,6 +49,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + [[package]] name = "blake2" version = "0.10.6" @@ -69,21 +75,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cast" @@ -93,9 +99,13 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.79" +version = "1.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "b7a4d3ec6524d28a329fc53654bbadc9bdd7b0431f5d65f1a56ffb28a1ee5283" +dependencies = [ + "find-msvc-tools", + "shlex", +] [[package]] name = "cesu8" @@ -105,9 +115,9 @@ checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" @@ -115,7 +125,7 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "textwrap", "unicode-width", ] @@ -137,9 +147,9 @@ dependencies = [ [[package]] name = "combine" -version = "4.6.6" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", "memchr", @@ -183,58 +193,40 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -242,21 +234,21 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" dependencies = [ "csv-core", "itoa", "ryu", - "serde", + "serde_core", ] [[package]] name = "csv-core" -version = "0.1.10" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" dependencies = [ "memchr", ] @@ -272,9 +264,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -283,18 +275,15 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] -name = "embedded-time" -version = "0.12.1" +name = "find-msvc-tools" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4b4d10ac48d08bfe3db7688c402baadb244721f30a77ce360bd24c3dffe58" -dependencies = [ - "num", -] +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "foreign-types" @@ -323,15 +312,15 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "half" -version = "1.8.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "hash32" @@ -344,9 +333,9 @@ dependencies = [ [[package]] name = "heapless" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", @@ -364,15 +353,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - [[package]] name = "itertools" version = "0.10.5" @@ -384,18 +364,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "java-locator" -version = "0.1.3" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72cb7c9d00a642469deceff95ca37d0da9ce72d7f8b863edbebdf0aac75093da" +checksum = "09c46c1fe465c59b1474e665e85e1256c3893dd00927b8d55f63b09044c1e64f" dependencies = [ "glob", - "lazy_static", ] [[package]] @@ -408,7 +387,7 @@ dependencies = [ "cfg-if", "combine", "java-locator", - "jni-sys", + "jni-sys 0.3.1", "libloading", "log", "thiserror", @@ -418,30 +397,53 @@ dependencies = [ [[package]] name = "jni-sys" -version = "0.3.0" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.184" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af" [[package]] name = "libloading" @@ -455,11 +457,10 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -471,18 +472,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "memchr" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "naan" @@ -502,113 +494,49 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" -[[package]] -name = "num" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "openssl" -version = "0.10.51" +version = "0.10.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ea2d98598bf9ada7ea6ee8a30fb74f9156b63bbe495d64ec2b87c269d2dda3" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cfg-if", "foreign-types", "libc", @@ -630,9 +558,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.86" +version = "0.9.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992bac49bdbab4423199c654a5515bd2a6c6a23bf03f2dd3bdb7e5ae6259bc69" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" dependencies = [ "cc", "libc", @@ -642,21 +570,21 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plotters" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -667,15 +595,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.3" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -688,9 +616,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" @@ -710,32 +641,13 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "rand_core 0.9.5", -] - -[[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 0.6.4", + "rand_core", ] [[package]] @@ -745,15 +657,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.5", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "rand_core" version = "0.9.5" @@ -762,9 +668,9 @@ checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" [[package]] name = "rayon" -version = "1.7.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" dependencies = [ "either", "rayon-core", @@ -772,21 +678,31 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "regex" -version = "1.8.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -795,24 +711,30 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "same-file" @@ -825,15 +747,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.17" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" @@ -847,9 +769,9 @@ dependencies = [ [[package]] name = "serde-json-core" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ec3c8fe427f45ee3aaa0ebb9f0d9ab8ae9ad05d12047fe7249ae5ea9374ff0" +checksum = "3c9e1ab533c0bc414c34920ec7e5f097101d126ed5eac1a1aac711222e0bbb33" dependencies = [ "heapless", "ryu", @@ -888,15 +810,23 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", - "ryu", + "memchr", "serde", + "serde_core", + "zmij", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simple_logger" version = "5.2.0" @@ -920,15 +850,15 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -963,18 +893,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -1026,9 +956,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" dependencies = [ "tinyvec_macros", ] @@ -1043,15 +973,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" name = "toad" version = "0.19.1" dependencies = [ - "embedded-time", "log", "naan", "nb", "no-std-net", "openssl", "paste", - "rand 0.9.2", - "rand_chacha 0.9.0", + "rand", + "rand_chacha", "serde", "serde-json-core", "serde_json", @@ -1068,35 +997,6 @@ dependencies = [ "toad-writable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "toad" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d2a40ef725839735e253c13664aef9eb9989c1c1f79ea42f51f9b0e3076e6e6" -dependencies = [ - "embedded-time", - "log", - "naan", - "nb", - "no-std-net", - "openssl", - "paste", - "rand 0.8.5", - "rand_chacha 0.3.1", - "serde", - "serde_json", - "tinyvec", - "toad-array 0.2.3", - "toad-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toad-len 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "toad-macros 0.2.0", - "toad-map 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "toad-msg 0.18.1", - "toad-stem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toad-string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toad-writable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "toad-array" version = "0.2.3" @@ -1173,13 +1073,12 @@ dependencies = [ name = "toad-jni" version = "0.16.1" dependencies = [ - "embedded-time", "jni", "log", "nb", "no-std-net", "tinyvec", - "toad 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toad", "toad-array 0.5.0", "toad-len 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "toad-msg 0.18.1", @@ -1325,21 +1224,21 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "vcpkg" @@ -1349,15 +1248,15 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -1365,34 +1264,22 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0" dependencies = [ "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", "once_cell", - "proc-macro2", - "quote", - "syn 1.0.109", + "rustversion", + "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1400,28 +1287,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 1.0.109", - "wasm-bindgen-backend", + "syn 2.0.117", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "cd70027e39b12f0849461e08ffc50b9cd7688d942c1c8e3c7b22273236b4dd0a" dependencies = [ "js-sys", "wasm-bindgen", @@ -1445,11 +1335,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "winapi", + "windows-sys 0.61.2", ] [[package]] @@ -1538,3 +1428,29 @@ name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/toad-jni/Cargo.toml b/toad-jni/Cargo.toml index a92ce441..eb0511db 100644 --- a/toad-jni/Cargo.toml +++ b/toad-jni/Cargo.toml @@ -25,11 +25,9 @@ nb = "1" no-std-net = "0.6" tinyvec = {version = "1.5", default_features = false, features = ["alloc", "rustc_1_55"]} toad-msg = "0.18.1" -toad = "0.19.1" +toad = { path = "../toad" } jni = {version = "0.21.1", features = ["invocation"]} toad-stem = {version = "0.1.0", default_features = false} toad-len = {version = "0.1.3", default_features = false} toad-array = {version = "0.5.0", default_features = false} log = "0.4" - -embedded-time = "0.12" diff --git a/toad-jni/src/java/io/io_exception.rs b/toad-jni/src/java/io/io_exception.rs index e013a0f4..4a0e77f1 100644 --- a/toad-jni/src/java/io/io_exception.rs +++ b/toad-jni/src/java/io/io_exception.rs @@ -49,7 +49,7 @@ impl toad::platform::PlatformError for IOExcept Self::new_caused_by(&mut java::env(), "", e) } - fn clock(e: embedded_time::clock::Error) -> Self { + fn clock(e: toad::time::ClockError) -> Self { Self::new(&mut java::env(), format!("{:?}", e)) } } diff --git a/toad/Cargo.toml b/toad/Cargo.toml index a0ad3bf3..e52fad87 100644 --- a/toad/Cargo.toml +++ b/toad/Cargo.toml @@ -51,7 +51,6 @@ toad-macros = "0.2.0" log = "0.4" tinyvec = { version = "1.5", default_features = false, features = ["alloc", "rustc_1_55"] } no-std-net = "0.6" -embedded-time = "0.12" nb = "1" rand = { version = "0.9", default_features = false } rand_chacha = { version = "0.9", default_features = false } diff --git a/toad/src/config.rs b/toad/src/config.rs index 71b095f7..5abc35f7 100644 --- a/toad/src/config.rs +++ b/toad/src/config.rs @@ -1,9 +1,7 @@ #![allow(dead_code)] -use embedded_time::duration::Milliseconds; - use crate::retry::{Attempts, Strategy}; -use crate::time::Millis; +use crate::time::{Millis, Milliseconds}; /// Bytes / Second #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -17,9 +15,9 @@ pub struct Con { /// /// Defaults to an exponential retry strategy: /// ``` - /// use embedded_time::duration::Milliseconds; /// use toad::config::Con; /// use toad::retry::Strategy; + /// use toad::time::Milliseconds; /// /// assert_eq!(Con::default().unacked_retry_strategy, /// Strategy::Exponential { init_min: Milliseconds(500), @@ -35,9 +33,9 @@ pub struct Con { /// /// Defaults to a lazy exponential retry strategy: /// ``` - /// use embedded_time::duration::Milliseconds; /// use toad::config::Con; /// use toad::retry::Strategy; + /// use toad::time::Milliseconds; /// /// assert_eq!(Con::default().acked_retry_strategy, /// Strategy::Exponential { init_min: Milliseconds(1_000), @@ -68,9 +66,9 @@ pub struct Non { /// /// Defaults to a pessimistic exponential retry strategy: /// ``` - /// use embedded_time::duration::Milliseconds; /// use toad::config::Non; /// use toad::retry::Strategy; + /// use toad::time::Milliseconds; /// /// assert_eq!(Non::default().retry_strategy, /// Strategy::Exponential { init_min: Milliseconds(250), @@ -146,8 +144,8 @@ pub struct Msg { /// Defaults to 5000 milliseconds. /// /// ``` - /// use embedded_time::duration::Milliseconds; /// use toad::config::Msg; + /// use toad::time::Milliseconds; /// /// assert_eq!(Msg::default().multicast_response_leisure, /// Milliseconds(5000u64)); diff --git a/toad/src/platform.rs b/toad/src/platform.rs index e6bf6b9d..b899afd8 100644 --- a/toad/src/platform.rs +++ b/toad/src/platform.rs @@ -1,7 +1,6 @@ use core::fmt::Debug; use ::toad_msg::{Id, OptNumber, OptValue, OptionMap, Token, TryIntoBytes}; -use embedded_time::Instant; use naan::prelude::MonadOnce; use no_std_net::SocketAddr; #[cfg(feature = "alloc")] @@ -13,7 +12,7 @@ use crate::net::{Addrd, Socket}; use crate::req::Req; use crate::resp::Resp; use crate::step::Step; -use crate::time::Clock; +use crate::time::{Clock, Instant}; use crate::todo::String; /// Default [`PlatformError`] implementation @@ -23,7 +22,7 @@ pub enum Error { MessageToBytes(::toad_msg::to_bytes::MessageToBytesError), Step(Step), Socket(Socket), - Clock(embedded_time::clock::Error), + Clock(crate::time::ClockError), } impl PlatformError for Error @@ -42,7 +41,7 @@ impl PlatformError for Error Self::Socket(e) } - fn clock(e: embedded_time::clock::Error) -> Self { + fn clock(e: crate::time::ClockError) -> Self { Self::Clock(e) } } @@ -59,7 +58,7 @@ pub trait PlatformError: Sized + core::fmt::Debug { fn socket(e: SocketError) -> Self; /// Convert a clock error to PlatformError - fn clock(e: embedded_time::clock::Error) -> Self; + fn clock(e: crate::time::ClockError) -> Self; } /// The runtime component of the `Platform` abstraction @@ -89,8 +88,6 @@ pub trait Platform /// including the system time and datagrams currently /// in the network socket fn snapshot(&self) -> Result, Self::Error> { - use embedded_time::Clock; - self.socket() .poll() .map_err(Self::Error::socket) @@ -321,7 +318,7 @@ pub trait PlatformTypes: Sized + 'static + core::fmt::Debug { #[non_exhaustive] pub struct Snapshot { /// The current system time at the start of the step pipe - pub time: Instant, + pub time: Instant, /// A UDP datagram received from somewhere pub recvd_dgram: Option::Dgram>>, @@ -405,9 +402,9 @@ impl PartialEq for Effect

{ /// we've attempted to send this request and whether we /// should consider it poisoned. #[derive(Debug, Clone, Copy)] -pub struct Retryable(pub T, pub crate::retry::RetryTimer); +pub struct Retryable(pub T, pub crate::retry::RetryTimer); -impl Retryable { +impl Retryable { /// Gets the data, discarding the retry timer pub fn unwrap(self) -> T { self.0 diff --git a/toad/src/retry.rs b/toad/src/retry.rs index 2b04d48a..4276fe67 100644 --- a/toad/src/retry.rs +++ b/toad/src/retry.rs @@ -1,11 +1,8 @@ use core::ops::{Add, Mul, RangeInclusive, Sub}; -use embedded_time::duration::Milliseconds; -use embedded_time::Instant; -use naan::prelude::Monad; use rand::{Rng, SeedableRng}; -use crate::time::{Clock, Millis}; +use crate::time::{Instant, Millis, Milliseconds}; /// A non-blocking timer that allows a fixed-delay or exponential-backoff retry, /// that lives alongside some operation to retry. @@ -14,9 +11,8 @@ use crate::time::{Clock, Millis}; /// we don't have the luxury of a memory allocator :) /// /// ``` -/// use embedded_time::clock::Clock; -/// use embedded_time::duration::Milliseconds; /// use toad::retry; +/// use toad::time::{Clock, Milliseconds}; /// /// # main(); /// fn main() { @@ -46,31 +42,25 @@ use crate::time::{Clock, Millis}; /// } /// } /// ``` -#[derive(Debug)] -pub struct RetryTimer { - start: Instant, - last_attempted_at: Option>, +#[derive(Debug, Clone, Copy)] +pub struct RetryTimer { + start: Instant, + last_attempted_at: Option, init: Millis, strategy: Strategy, attempts: Attempts, max_attempts: Attempts, } -impl RetryTimer where C: Clock -{ +impl RetryTimer { /// Create a new retrier - pub fn new(start: Instant, strategy: Strategy, max_attempts: Attempts) -> Self { + pub fn new(start: Instant, strategy: Strategy, max_attempts: Attempts) -> Self { Self { start, strategy, last_attempted_at: None, init: if strategy.has_jitter() { - let mut rand = - Ok(start.duration_since_epoch()).bind(Millis::try_from) - .map(|Milliseconds(ms)| { - rand_chacha::ChaCha8Rng::seed_from_u64(ms) - }) - .unwrap(); - + let Milliseconds(ms) = start.duration_since_epoch(); + let mut rand = rand_chacha::ChaCha8Rng::seed_from_u64(ms); Milliseconds(rand.random_range(strategy.range())) } else { Milliseconds(*strategy.range().start()) @@ -85,7 +75,7 @@ impl RetryTimer where C: Clock /// Returns `nb::Error::WouldBlock` when we have not yet /// waited the appropriate amount of time to retry. pub fn what_should_i_do(&mut self, - now: Instant) + now: Instant) -> nb::Result { if self.attempts >= self.max_attempts { Ok(YouShould::Cry) @@ -101,18 +91,18 @@ impl RetryTimer where C: Clock } /// Get the instant this retry timer was first attempted - pub fn first_attempted_at(&self) -> Instant { + pub fn first_attempted_at(&self) -> Instant { self.start } /// Get the instant this retry timer was last attempted (if at all) - pub fn last_attempted_at(&self) -> Instant { + pub fn last_attempted_at(&self) -> Instant { self.last_attempted_at .unwrap_or_else(|| self.first_attempted_at()) } /// Get the next time at which this should be retried - pub fn next_attempt_at(&self) -> Instant { + pub fn next_attempt_at(&self) -> Instant { let after_start = match self.strategy { | Strategy::Delay { .. } => Milliseconds(self.init.0 * (self.attempts.0 as u64)), | Strategy::Exponential { .. } => { @@ -124,21 +114,7 @@ impl RetryTimer where C: Clock } } -impl Copy for RetryTimer where C: Clock {} -impl Clone for RetryTimer where C: Clock -{ - fn clone(&self) -> Self { - Self { start: self.start, - init: self.init, - last_attempted_at: self.last_attempted_at, - strategy: self.strategy, - attempts: self.attempts, - max_attempts: self.max_attempts } - } -} - -impl PartialEq for RetryTimer where C: Clock -{ +impl PartialEq for RetryTimer { fn eq(&self, other: &Self) -> bool { self.start == other.start && self.init == other.init @@ -149,7 +125,7 @@ impl PartialEq for RetryTimer where C: Clock } } -impl Eq for RetryTimer where C: Clock {} +impl Eq for RetryTimer {} /// A number of attempts #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -258,10 +234,8 @@ impl Strategy { #[cfg(test)] mod test { - use embedded_time::rate::Fraction; - use embedded_time::Clock; - use super::*; + use crate::time::{Clock, ClockError, Instant}; #[derive(Debug)] pub struct FakeClock(pub *const u64); @@ -271,12 +245,9 @@ mod test { } } - impl embedded_time::Clock for FakeClock { - type T = u64; - - const SCALING_FACTOR: Fraction = Fraction::new(1, 1000); - - fn try_now(&self) -> Result, embedded_time::clock::Error> { + impl Clock for FakeClock { + fn try_now(&self) -> Result { + // FakeClock stores raw millisecond values unsafe { Ok(Instant::new(*self.0)) } } } diff --git a/toad/src/std/mod.rs b/toad/src/std/mod.rs index c6eff1fb..b9786238 100644 --- a/toad/src/std/mod.rs +++ b/toad/src/std/mod.rs @@ -1,7 +1,5 @@ #![allow(clippy::many_single_char_names)] -use embedded_time::rate::Fraction; - /// Networking! woohoo! pub mod net; use core::marker::PhantomData; @@ -88,7 +86,7 @@ impl PlatformError for io::Error io::Error::new(io::ErrorKind::Other, format!("{:?}", e)) } - fn clock(e: embedded_time::clock::Error) -> Self { + fn clock(e: crate::time::ClockError) -> Self { io::Error::new(io::ErrorKind::Other, format!("{:?}", e)) } } @@ -172,7 +170,7 @@ impl crate::platform::Platform for Platform } } -/// Implement [`embedded_time::Clock`] using [`std::time`] primitives +/// Implement [`crate::time::Clock`] using [`std::time`] primitives #[derive(Debug, Clone, Copy)] pub struct Clock(std::time::Instant); @@ -189,15 +187,10 @@ impl Clock { } } -impl embedded_time::Clock for Clock { - type T = u64; - - // microseconds - const SCALING_FACTOR: Fraction = Fraction::new(1, 1_000_000); - - fn try_now(&self) -> Result, embedded_time::clock::Error> { +impl crate::time::Clock for Clock { + fn try_now(&self) -> Result { let now = std::time::Instant::now(); let elapsed = now.duration_since(self.0); - Ok(embedded_time::Instant::new(elapsed.as_micros() as u64)) + Ok(crate::time::Instant::new(elapsed.as_millis() as u64)) } } diff --git a/toad/src/step/mod.rs b/toad/src/step/mod.rs index fa767437..5c0562f0 100644 --- a/toad/src/step/mod.rs +++ b/toad/src/step/mod.rs @@ -32,7 +32,7 @@ pub mod runtime { #[allow(missing_docs)] pub type HandleAcks = handle_acks::HandleAcks, ()>>; #[allow(missing_docs)] - pub type Retry = retry::Retry>, Addrd>)>>; + pub type Retry = retry::Retry>)>>; #[allow(missing_docs)] pub type BufferResponses = buffer_responses::BufferResponses = provision_ids::ProvisionIds, IdWithDefault>>>>; + Map>>>; #[allow(missing_docs)] pub type Observe = observe::Observe>, @@ -457,14 +455,13 @@ impl Step

for () { #[cfg(test)] #[allow(missing_docs)] pub mod test { - use embedded_time::Clock; use super::*; use crate::test; use crate::test::ClockMock; pub fn default_snapshot() -> platform::Snapshot { - platform::Snapshot { time: ClockMock::new().try_now().unwrap(), + platform::Snapshot { time: ClockMock::instant(0), recvd_dgram: Some(crate::net::Addrd(Default::default(), crate::test::dummy_addr())), config: crate::config::Config::default() } diff --git a/toad/src/step/observe.rs b/toad/src/step/observe.rs index 7672d9de..9f85828a 100644 --- a/toad/src/step/observe.rs +++ b/toad/src/step/observe.rs @@ -562,7 +562,6 @@ mod tests { use std::sync::Mutex; use ::toad_msg::{Code, ContentFormat, Id, Token, Type}; - use embedded_time::Clock; use platform::toad_msg; use tinyvec::array_vec; @@ -645,7 +644,7 @@ mod tests { ({|step: &Observe| { // Inner will yield a Register request, // this should add it to subscribtions list - step.poll_req(&Snapshot { time: ClockMock::new().try_now().unwrap(), + step.poll_req(&Snapshot { time: ClockMock::instant(0), recvd_dgram: None, config: Default::default() }, &mut Default::default()).unwrap().unwrap() }}), @@ -667,11 +666,11 @@ mod tests { WHEN response_to_subscriber_is_sent [ // Store 2 subscriptions (inner.poll_req = { poll_req_emitting_single_register_request(21) }), - ({|step: &Observe| step.poll_req(&Snapshot { time: ClockMock::new().try_now().unwrap(), + ({|step: &Observe| step.poll_req(&Snapshot { time: ClockMock::instant(0), recvd_dgram: None, config: Default::default() }, &mut Default::default()).unwrap().unwrap()}), (inner.poll_req = { poll_req_emitting_single_register_request(22) }), - ({|step: &Observe| step.poll_req(&Snapshot { time: ClockMock::new().try_now().unwrap(), + ({|step: &Observe| step.poll_req(&Snapshot { time: ClockMock::instant(0), recvd_dgram: None, config: Default::default() }, &mut Default::default()).unwrap().unwrap()}) ] @@ -696,7 +695,7 @@ mod tests { WHEN client_subscribes_and_unrelated_event_fires [ (inner.poll_req = { poll_req_emitting_single_register_request(3) }), ({|step: &Observe| { - step.poll_req(&Snapshot { time: test::ClockMock::new().try_now().unwrap(), + step.poll_req(&Snapshot { time: test::ClockMock::instant(0), recvd_dgram: None, config: crate::config::Config::default() }, &mut Default::default()).unwrap().unwrap() }}), @@ -712,13 +711,13 @@ mod tests { WHEN client_subscribes_and_multiple_events_fire [ (inner.poll_req = { poll_req_emitting_single_register_request(41) }), ({|step: &Observe| { - step.poll_req(&Snapshot { time: test::ClockMock::new().try_now().unwrap(), + step.poll_req(&Snapshot { time: test::ClockMock::instant(0), recvd_dgram: None, config: crate::config::Config::default() }, &mut Default::default()).unwrap().unwrap() }}), ({|step: &Observe| step.notify("foo/bar", &mut vec![]).unwrap()}), ({|step: &Observe| { - step.poll_req(&Snapshot { time: test::ClockMock::new().try_now().unwrap(), + step.poll_req(&Snapshot { time: test::ClockMock::instant(0), recvd_dgram: None, config: crate::config::Config::default() }, &mut Default::default()).unwrap().unwrap() }}), diff --git a/toad/src/step/parse.rs b/toad/src/step/parse.rs index 765111c7..d90147d0 100644 --- a/toad/src/step/parse.rs +++ b/toad/src/step/parse.rs @@ -105,7 +105,6 @@ impl, P: PlatformTypes> Step

for Parse { #[cfg(test)] mod test { - use embedded_time::Clock; use toad_msg::{Code, Type}; use super::super::test; @@ -170,7 +169,7 @@ mod test { (inner.poll_req => {None}), (snapshot = { platform::Snapshot { - time: crate::test::ClockMock::new().try_now().unwrap(), + time: crate::test::ClockMock::instant(0), recvd_dgram: Some(test_msg(Type::Con, Code::new(1, 01)).0), config: Default::default(), } @@ -187,7 +186,7 @@ mod test { (inner.poll_req => {None}), (snapshot = { platform::Snapshot { - time: crate::test::ClockMock::new().try_now().unwrap(), + time: crate::test::ClockMock::instant(0), recvd_dgram: Some(test_msg(Type::Ack, Code::new(0, 0)).0), config: Default::default(), } @@ -204,7 +203,7 @@ mod test { (inner.poll_req => {None}), (snapshot = { platform::Snapshot { - time: crate::test::ClockMock::new().try_now().unwrap(), + time: crate::test::ClockMock::instant(0), recvd_dgram: Some(test_msg(Type::Ack, Code::new(2, 04)).0), config: Default::default(), } @@ -221,7 +220,7 @@ mod test { (inner.poll_resp => {None}), (snapshot = { platform::Snapshot { - time: crate::test::ClockMock::new().try_now().unwrap(), + time: crate::test::ClockMock::instant(0), recvd_dgram: Some(test_msg(Type::Ack, Code::new(2, 04)).0), config: Default::default(), } @@ -238,7 +237,7 @@ mod test { (inner.poll_resp => {None}), (snapshot = { platform::Snapshot { - time: crate::test::ClockMock::new().try_now().unwrap(), + time: crate::test::ClockMock::instant(0), recvd_dgram: Some(test_msg(Type::Con, Code::new(1, 1)).0), config: Default::default(), } diff --git a/toad/src/step/provision_ids.rs b/toad/src/step/provision_ids.rs index d09aec5d..222ff6fb 100644 --- a/toad/src/step/provision_ids.rs +++ b/toad/src/step/provision_ids.rs @@ -1,8 +1,6 @@ use core::any::type_name; use core::marker::PhantomData; -use embedded_time::duration::Milliseconds; -use embedded_time::Instant; use no_std_net::SocketAddr; use tinyvec::ArrayVec; use toad_array::Array; @@ -18,7 +16,7 @@ use crate::platform; use crate::platform::PlatformTypes; use crate::req::Req; use crate::resp::Resp; -use crate::time::Stamped; +use crate::time::{Instant, Milliseconds, Stamped}; /// Supertrait type shenanigans /// @@ -31,19 +29,18 @@ use crate::time::Stamped; /// you would have to wrap your collection in a newtype. pub trait IdsBySocketAddr: Map { /// the "given `A` which is an..." type above - type Ids: Array>; + type Ids: Array>; } #[cfg(feature = "alloc")] -impl>> - IdsBySocketAddr

for std_alloc::collections::BTreeMap +impl>> IdsBySocketAddr

+ for std_alloc::collections::BTreeMap { type Ids = A; } -impl>, - const N: usize> IdsBySocketAddr

for ArrayVec<[(SocketAddrWithDefault, A); N]> +impl>, const N: usize> + IdsBySocketAddr

for ArrayVec<[(SocketAddrWithDefault, A); N]> { type Ids = A; } @@ -110,16 +107,14 @@ impl ProvisionIds where Ids: IdsBySocketAddr

, P: PlatformTypes { - fn prune(effs: &mut P::Effects, seen: &mut Ids, now: Instant, config: Config) { + fn prune(effs: &mut P::Effects, seen: &mut Ids, now: Instant, config: Config) { for (_, ids) in seen.iter_mut() { ids.sort_by_key(|t| t.time()); - let ix_of_first_id_to_keep = ids.iter() - .enumerate() - .find(|(_, id)| { - now.checked_duration_since(&id.time()) - < Some(Milliseconds(config.exchange_lifetime_millis()).into()) - }) - .map(|(ix, _)| ix); + let ix_of_first_id_to_keep = + ids.iter() + .enumerate() + .find(|(_, id)| (now - id.time()) < Milliseconds(config.exchange_lifetime_millis())) + .map(|(ix, _)| ix); match ix_of_first_id_to_keep { | Some(keep_at) if keep_at == 0 => (), @@ -150,7 +145,7 @@ impl ProvisionIds match seen.insert(SocketAddrWithDefault(addr), Default::default()) { | Ok(_) => (), | Err(InsertError::CapacityExhausted) => { - let mut to_remove: Option> = None; + let mut to_remove: Option> = None; for (addr, ids) in seen.iter_mut() { if ids.is_empty() { @@ -180,7 +175,7 @@ impl ProvisionIds fn next(effs: &mut P::Effects, seen: &mut Ids, config: Config, - time: Instant, + time: Instant, addr: SocketAddr) -> Id { match seen.get_mut(&SocketAddrWithDefault(addr)) { @@ -249,7 +244,7 @@ impl ProvisionIds fn seen(effs: &mut P::Effects, seen: &mut Ids, config: Config, - now: Instant, + now: Instant, addr: SocketAddr, id: Id) { Self::prune(effs, seen, now, config); @@ -367,18 +362,14 @@ impl Step

for ProvisionIds mod test { use std::collections::BTreeMap; - use embedded_time::duration::Microseconds; - use super::*; use crate::step::test::test_step; use crate::test::{self, ClockMock, Platform as P}; type InnerPollReq = Addrd>; type InnerPollResp = Addrd>; - type ProvisionIds = super::ProvisionIds>>>; + type ProvisionIds = + super::ProvisionIds>>>; fn test_msg(id: Id) -> Addrd { use toad_msg::*; @@ -439,7 +430,7 @@ mod test { #[test] fn seen_should_remove_oldest_addr_when_new_addr_would_exceed_capacity() { - type Ids = ArrayVec<[Stamped; 16]>; + type Ids = ArrayVec<[Stamped; 16]>; type IdsByAddr = ArrayVec<[(SocketAddrWithDefault, Ids); 2]>; type Step = super::ProvisionIds; @@ -457,19 +448,19 @@ mod test { Step::seen(&mut effs, s, cfg, - ClockMock::instant(1), + ClockMock::instant(1_000), test::dummy_addr_2(), Id(1)); Step::seen(&mut effs, s, cfg, - ClockMock::instant(2), + ClockMock::instant(2_000), test::dummy_addr(), Id(2)); Step::seen(&mut effs, s, cfg, - ClockMock::instant(3), + ClockMock::instant(3_000), test::dummy_addr_3(), Id(1)); }); @@ -482,7 +473,7 @@ mod test { #[test] fn seen_should_remove_empty_addr_when_new_addr_would_exceed_capacity() { - type Ids = ArrayVec<[Stamped; 16]>; + type Ids = ArrayVec<[Stamped; 16]>; type IdsByAddr = ArrayVec<[(SocketAddrWithDefault, Ids); 2]>; type Step = super::ProvisionIds; @@ -516,7 +507,7 @@ mod test { #[test] fn seen_should_remove_oldest_id_when_about_to_exceed_capacity() { - type Ids = ArrayVec<[Stamped; 2]>; + type Ids = ArrayVec<[Stamped; 2]>; type IdsByAddr = ArrayVec<[(SocketAddrWithDefault, Ids); 1]>; type Step = super::ProvisionIds; @@ -564,10 +555,6 @@ mod test { let cfg = Config::default(); let exchange_lifetime_micros = cfg.exchange_lifetime_millis() * 1_000; - // This test assumes that the clock considers 1 "tick" to be 1 microsecond. - assert_eq!(Microseconds::try_from(ClockMock::instant(1).duration_since_epoch()), - Ok(Microseconds(1u64))); - step.seen.map_mut(|s| { Step::seen(&mut effs, s, diff --git a/toad/src/step/provision_tokens.rs b/toad/src/step/provision_tokens.rs index 93efef28..a73f3926 100644 --- a/toad/src/step/provision_tokens.rs +++ b/toad/src/step/provision_tokens.rs @@ -1,4 +1,3 @@ -use embedded_time::Instant; use no_std_net::SocketAddr; use toad_msg::{CodeKind, Token}; @@ -9,7 +8,7 @@ use crate::platform; use crate::platform::PlatformTypes; use crate::req::Req; use crate::resp::Resp; -use crate::time::Millis; +use crate::time::{Instant, Millis}; /// Errors that can be encountered when provisioning tokens #[derive(PartialEq, Eq, PartialOrd, Clone, Copy)] @@ -69,17 +68,13 @@ impl Default for ProvisionTokens where Inner: Default impl ProvisionTokens { fn next

(&self, effs: &mut P::Effects, - now: Instant, + now: Instant, cfg: Config) -> Result> where P: PlatformTypes, Inner: Step

{ - // TODO(orion): we may want to handle this - let now_since_epoch = - Millis::try_from(now.duration_since_epoch()).map_err(|_| { - Error::MillisSinceEpochWouldOverflow - })?; + let now_since_epoch = now.duration_since_epoch(); #[allow(clippy::many_single_char_names)] let bytes = { diff --git a/toad/src/step/retry.rs b/toad/src/step/retry.rs index 87debe5a..c1e1ea33 100644 --- a/toad/src/step/retry.rs +++ b/toad/src/step/retry.rs @@ -1,5 +1,3 @@ -use embedded_time::duration::Milliseconds; -use embedded_time::Instant; use toad_array::Array; use toad_msg::{CodeKind, Token, Type}; use toad_stem::Stem; @@ -12,7 +10,7 @@ use crate::platform::{self, Effect, PlatformTypes, Snapshot}; use crate::req::Req; use crate::resp::Resp; use crate::retry::{Attempts, RetryTimer, Strategy, YouShould}; -use crate::time::{Clock, Millis}; +use crate::time::{Instant, Millis, Milliseconds}; #[allow(missing_docs)] #[allow(missing_debug_implementations)] @@ -28,29 +26,19 @@ pub struct Debug { /// Buffer used to store messages queued for retry pub trait Buf

where P: PlatformTypes, - Self: Array, Addrd>)> + Self: Array>)> { /// Data points used by log messaging - fn debug(now: Instant, - state: &State, - msg: &Addrd>) - -> Debug { + fn debug(now: Instant, state: &State, msg: &Addrd>) -> Debug { let msg_short = format!(100, "{:?} {:?} {:?}", msg.data().ty, msg.data().code, msg.data().token); - let since_first_attempt = Millis::try_from(now - state.retry_timer().first_attempted_at()) - .expect("duration since first attempt should be less than u64::MAX milliseconds"); - let since_last_attempt = Millis::try_from(now - state.retry_timer().last_attempted_at()) - .expect("duration since last attempt should be less than u64::MAX milliseconds"); - let until_next_attempt = state.retry_timer() - .next_attempt_at() - .checked_duration_since(&now) - .map(|until| { - Millis::try_from(until) - .expect("duration until next attempt should be less than u64::MAX milliseconds") - }); + let since_first_attempt = now - state.retry_timer().first_attempted_at(); + let since_last_attempt = now - state.retry_timer().last_attempted_at(); + let next = state.retry_timer().next_attempt_at(); + let until_next_attempt = if next > now { Some(next - now) } else { None }; let msg_should_be = if msg.data().ty == Type::Con { "acknowledged" } else { @@ -64,10 +52,7 @@ pub trait Buf

} /// Send all messages that need to be sent - fn attempt_all(&mut self, - now: Instant, - effects: &mut P::Effects) - -> Result<(), Error> { + fn attempt_all(&mut self, now: Instant, effects: &mut P::Effects) -> Result<(), Error> { self.iter_mut().for_each(|(state, msg)| { let dbg = Self::debug(now, state, msg); match state.timer().what_should_i_do(now) { @@ -95,7 +80,7 @@ pub trait Buf

} /// We saw a response and should remove all tracking of a token (if we have any) - fn forget(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { + fn forget(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { match self.iter() .enumerate() .find(|(_, (_, msg))| msg.data().token == token) @@ -118,7 +103,7 @@ pub trait Buf

/// We saw an ACK and should transition the retry state for matching outbound /// CONs to the "acked" state - fn mark_acked(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { + fn mark_acked(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { let found = self.iter_mut().find(|(_, msg)| msg.data().token == token); match found { @@ -157,7 +142,7 @@ pub trait Buf

} /// We saw a RESET regarding token `token` - fn mark_reset(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { + fn mark_reset(&mut self, now: Instant, effects: &mut P::Effects, token: Token) { let found = self.iter().find(|(_, msg)| msg.data().token == token); match found { @@ -185,7 +170,7 @@ pub trait Buf

/// /// May invoke `mark_acked` & `forget` fn maybe_seen_response(&mut self, - now: Instant, + now: Instant, effects: &mut P::Effects, msg: Addrd<&platform::Message

>) -> Result<(), Error> { @@ -219,7 +204,7 @@ pub trait Buf

/// Called when a message of any kind is sent, /// and may store it to be retried in the future fn store_retryables(&mut self, - now: Instant, + now: Instant, effects: &mut P::Effects, msg: &Addrd>, config: Config) @@ -270,20 +255,18 @@ pub trait Buf

} impl Buf

for T - where T: Array, Addrd>)>, + where T: Array>)>, P: PlatformTypes { } /// The state of a message stored in the retry [buffer](Buf) -#[derive(PartialEq, Eq, Debug)] -pub enum State - where C: Clock -{ +#[derive(PartialEq, Eq, Debug, Clone, Copy)] +pub enum State { /// A message that is not an un-acked CON /// /// (meaning the retry strategy will never change) - Just(RetryTimer), + Just(RetryTimer), /// A message that is an un-acked CON /// /// This means that when it is acked, @@ -292,7 +275,7 @@ pub enum State /// [acked CON retry strategy](crate::config::Con.acked_retry_strategy). ConPreAck { /// The current (unacked) retry state - timer: RetryTimer, + timer: RetryTimer, /// The strategy to use once the message is acked post_ack_strategy: Strategy, /// The max number of retry attempts for the post-ack state @@ -300,36 +283,28 @@ pub enum State }, } -impl State where C: Clock -{ +impl State { /// Gets the current in-use retry timer - pub fn retry_timer(&self) -> &RetryTimer { + pub fn retry_timer(&self) -> &RetryTimer { match self { | Self::Just(r) => r, | Self::ConPreAck { timer, .. } => timer, } } -} -impl Copy for State where C: Clock {} -impl Clone for State where C: Clock -{ - fn clone(&self) -> Self { + fn new(time: Instant, strat: Strategy, max_attempts: Attempts) -> Self { + Self::Just(RetryTimer::new(time, strat, max_attempts)) + } + + fn timer(&mut self) -> &mut RetryTimer { match self { - | Self::Just(t) => Self::Just(*t), - | Self::ConPreAck { timer, - post_ack_strategy, - post_ack_max_attempts, } => { - Self::ConPreAck { timer: *timer, - post_ack_strategy: *post_ack_strategy, - post_ack_max_attempts: *post_ack_max_attempts } - }, + | Self::Just(t) => t, + | Self::ConPreAck { timer, .. } => timer, } } } -impl Default for State where C: Clock -{ +impl Default for State { fn default() -> Self { Self::new(Instant::new(0), Strategy::Delay { min: Milliseconds(0), @@ -338,20 +313,6 @@ impl Default for State where C: Clock } } -impl State where C: Clock -{ - fn new(time: Instant, strat: Strategy, max_attempts: Attempts) -> Self { - Self::Just(RetryTimer::new(time, strat, max_attempts)) - } - - fn timer(&mut self) -> &mut RetryTimer { - match self { - | Self::Just(t) => t, - | Self::ConPreAck { timer, .. } => timer, - } - } -} - /// Step that manages retrying outbound messages. /// /// See the [module documentation](crate::step::retry) for more. @@ -472,7 +433,6 @@ impl Step

for Retry #[cfg(test)] mod tests { - use embedded_time::duration::Milliseconds; use tinyvec::array_vec; use toad_msg::{Code, Type}; @@ -483,7 +443,7 @@ mod tests { use crate::step::test::test_step; use crate::test::{self, ClockMock, Platform as P}; - type Retry = super::Retry, Addrd>)>>; + type Retry = super::Retry>)>>; fn snap_time(config: Config, time: u64) -> test::Snapshot { test::Snapshot { config, @@ -554,8 +514,7 @@ mod tests { let token: &'static Token = unsafe { core::mem::transmute::<_, _>(&token) }; s.inner() .set_poll_resp(|_, Snapshot { time, .. }, _, _, _| { - let time: u64 = Milliseconds::try_from(time.duration_since_epoch()).unwrap() - .0; + let time: u64 = time.duration_since_epoch().0; let mut rep = test::msg!(ACK EMPTY x.x.x.x:0000); rep.as_mut().token = *token; @@ -676,8 +635,7 @@ mod tests { s.inner() .set_poll_resp(|_, Snapshot { time, .. }, _, token, _| { - let time: u64 = Milliseconds::try_from(time.duration_since_epoch()).unwrap() - .0; + let time: u64 = time.duration_since_epoch().0; let mut rst = test::msg!(RESET x.x.x.x:0000); rst.as_mut().token = token; @@ -688,8 +646,7 @@ mod tests { } }) .set_poll_req(|_, Snapshot { time, .. }, _| { - let time: u64 = Milliseconds::try_from(time.duration_since_epoch()).unwrap() - .0; + let time: u64 = time.duration_since_epoch().0; let mut rst = test::msg!(RESET x.x.x.x:0000); rst.as_mut().token = *token_c; @@ -780,8 +737,7 @@ mod tests { let token = Token(array_vec![1, 2, 3]); let token: &'static Token = unsafe { core::mem::transmute::<_, _>(&token) }; s.inner().set_poll_req(|_, Snapshot { time, .. }, _| { - let time: u64 = Milliseconds::try_from(time.duration_since_epoch()).unwrap() - .0; + let time: u64 = time.duration_since_epoch().0; let mut ack = test::msg!(ACK EMPTY x.x.x.x:0000); ack.as_mut().token = *token; @@ -853,8 +809,7 @@ mod tests { let token: &'static Token = unsafe { core::mem::transmute::<_, _>(&token) }; s.inner() .set_poll_resp(|_, Snapshot { time, .. }, _, _, _| { - let time: u64 = Milliseconds::try_from(time.duration_since_epoch()).unwrap() - .0; + let time: u64 = time.duration_since_epoch().0; let mut rep = test::msg!(NON {2 . 04} x.x.x.x:0000); rep.as_mut().token = *token; diff --git a/toad/src/test.rs b/toad/src/test.rs index e6e9e243..816a6d6f 100644 --- a/toad/src/test.rs +++ b/toad/src/test.rs @@ -7,8 +7,6 @@ use ::core::time::Duration; use ::std::sync::{Mutex, RwLock}; use ::std::thread; use ::toad_msg::{TryFromBytes, TryIntoBytes}; -use embedded_time::rate::Fraction; -use embedded_time::Instant; use net::*; use no_std_net::{Ipv4Addr, SocketAddr, SocketAddrV4}; use std_alloc::sync::Arc; @@ -17,6 +15,7 @@ use toad_msg::Token; use toad_stem::Stem; use super::*; +use crate::time::Instant; // lol `crate::test::x.x.x.x(80)` pub struct X1 { @@ -370,18 +369,16 @@ impl ClockMock { self.0.set(to); } - pub fn instant(n: u64) -> Instant { - Instant::new(n) + /// Create an Instant from a raw microsecond value (converted to milliseconds) + pub fn instant(micros: u64) -> Instant { + Instant::new(micros / 1000) } } -impl embedded_time::Clock for ClockMock { - type T = u64; - - const SCALING_FACTOR: Fraction = Fraction::new(1, 1_000_000); - - fn try_now(&self) -> Result, embedded_time::clock::Error> { - Ok(Instant::new(self.0.get())) +impl crate::time::Clock for ClockMock { + fn try_now(&self) -> Result { + // stored value is microseconds; return milliseconds + Ok(Instant::new(self.0.get() / 1000)) } } diff --git a/toad/src/time.rs b/toad/src/time.rs index b6750bd6..6e3fb9b9 100644 --- a/toad/src/time.rs +++ b/toad/src/time.rs @@ -1,15 +1,83 @@ -use embedded_time::clock::Error; -use embedded_time::Instant; - use crate::todo::String; -/// A duration, in milliseconds -pub type Millis = embedded_time::duration::Milliseconds; +/// A duration in milliseconds +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)] +pub struct Milliseconds(pub T); + +/// [`Milliseconds`] with a `u64` inner +pub type Millis = Milliseconds; + +impl core::ops::Add for Millis { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + Milliseconds(self.0 + rhs.0) + } +} + +impl core::ops::Sub for Millis { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + Milliseconds(self.0.saturating_sub(rhs.0)) + } +} + +impl core::ops::Mul for Millis { + type Output = Self; + + fn mul(self, rhs: u64) -> Self { + Milliseconds(self.0 * rhs) + } +} + +impl core::fmt::Display for Milliseconds { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{}", self.0) + } +} -/// Supertrait of [`embedded_time::Clock`] pinning the -/// type of "ticks" to u64 -pub trait Clock: core::fmt::Debug + embedded_time::Clock {} -impl + core::fmt::Debug> Clock for C {} +/// An error returned when the system clock cannot be read +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ClockError; + +/// A point in time, represented as milliseconds since an arbitrary epoch +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)] +pub struct Instant(pub u64); + +impl Instant { + /// Create a new Instant from a millisecond timestamp + pub fn new(millis: u64) -> Self { + Self(millis) + } + + /// Duration elapsed since the epoch, in milliseconds + pub fn duration_since_epoch(self) -> Millis { + Milliseconds(self.0) + } +} + +impl core::ops::Add for Instant { + type Output = Self; + + fn add(self, rhs: Millis) -> Self { + Instant(self.0 + rhs.0) + } +} + +impl core::ops::Sub for Instant { + type Output = Millis; + + fn sub(self, rhs: Self) -> Millis { + Milliseconds(self.0.saturating_sub(rhs.0)) + } +} + +/// A clock that can return the current time as milliseconds since an arbitrary epoch +pub trait Clock: core::fmt::Debug { + /// Get the current time + fn try_now(&self) -> Result; +} /// Timeout configuration allowing for "never time out" as an option #[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)] @@ -21,16 +89,16 @@ pub enum Timeout { } /// Data associated with a timestamp -pub struct Stamped(pub T, pub Instant); +pub struct Stamped(pub T, pub Instant); -impl core::fmt::Debug for Stamped { +impl core::fmt::Debug for Stamped { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { use core::fmt::Write; let mut instant = String::<100>::default(); write!(instant, "<{}ms since epoch>", - Millis::try_from(self.1.duration_since_epoch()).unwrap())?; + self.1.duration_since_epoch().0)?; f.debug_tuple("Stamped") .field(&self.0) @@ -39,15 +107,15 @@ impl core::fmt::Debug for Stamped { } } -impl PartialEq for Stamped { +impl PartialEq for Stamped { fn eq(&self, other: &Self) -> bool { self.0 == other.0 && self.1 == other.1 } } -impl Eq for Stamped {} +impl Eq for Stamped {} -impl PartialOrd for Stamped { +impl PartialOrd for Stamped { fn partial_cmp(&self, other: &Self) -> Option { use core::cmp::Ordering; @@ -58,7 +126,7 @@ impl PartialOrd for Stamped { } } -impl Ord for Stamped { +impl Ord for Stamped { fn cmp(&self, other: &Self) -> core::cmp::Ordering { use core::cmp::Ordering; @@ -69,33 +137,33 @@ impl Ord for Stamped { } } -impl Default for Stamped { +impl Default for Stamped { fn default() -> Self { Self(T::default(), Instant::new(0)) } } -impl Clone for Stamped { +impl Clone for Stamped { fn clone(&self) -> Self { Self(self.0.clone(), self.1) } } -impl Copy for Stamped {} +impl Copy for Stamped {} -impl Stamped { - /// TODO - pub fn new(clock: &C, t: T) -> Result { +impl Stamped { + /// Create a new stamped value using the current time from `clock` + pub fn new(clock: &C, t: T) -> Result { clock.try_now().map(|now| Self(t, now)) } /// TODO - pub fn as_ref(&self) -> Stamped { + pub fn as_ref(&self) -> Stamped<&T> { Stamped(&self.0, self.1) } /// TODO - pub fn as_mut(&mut self) -> Stamped { + pub fn as_mut(&mut self) -> Stamped<&mut T> { Stamped(&mut self.0, self.1) } @@ -105,7 +173,7 @@ impl Stamped { } /// TODO - pub fn time(&self) -> Instant { + pub fn time(&self) -> Instant { self.1 } @@ -115,12 +183,12 @@ impl Stamped { } /// TODO - pub fn map(self, f: impl FnOnce(T) -> R) -> Stamped { + pub fn map(self, f: impl FnOnce(T) -> R) -> Stamped { Stamped(f(self.0), self.1) } /// TODO - pub fn find_latest(winner: Option>, cur: Stamped) -> Option> { + pub fn find_latest(winner: Option>, cur: Stamped) -> Option> { Some(winner.filter(|winner| winner.time() > cur.time()) .unwrap_or(cur)) }