diff --git a/Cargo.lock b/Cargo.lock index e0053c0..5dfe9ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,136 +4,41 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1da3ae8dabd9c00f453a329dfe1fb28da3c0a72e2478cdcd93171740c20499" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand 2.0.1", - "futures-lite", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-lock", - "blocking", - "futures-lite", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener", -] +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "async-recursion" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "async-std" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" -dependencies = [ - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -142,64 +47,52 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "async-task" -version = "4.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9441c6b2fe128a7c2bf680a44c34d0df31ce09e5b7e401fcca3faa483dbc921" - [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] name = "bitflags" -version = "1.3.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "block-buffer" @@ -210,48 +103,17 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "fastrand 2.0.1", - "futures-io", - "futures-lite", - "piper", - "tracing", -] - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - [[package]] name = "bytes" -version = "1.5.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "camino" -version = "1.0.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3132262930b0522068049f5870a856ab8affc80c70d08b6ecb785771a6fc23" - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" [[package]] name = "cfg-if" @@ -259,30 +121,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "concurrent-queue" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" - [[package]] name = "crypto-common" version = "0.1.6" @@ -303,54 +150,23 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.52.0", + "libredox", + "windows-sys", ] [[package]] name = "futures" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -363,9 +179,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -373,15 +189,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -390,30 +206,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -422,21 +223,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -452,9 +253,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -473,128 +274,56 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] -name = "log" -version = "0.4.20" +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "value-bag", + "bitflags", + "libc", + "redox_syscall", ] [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ - "adler", + "adler2", ] [[package]] name = "object" -version = "0.32.1" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "parking" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" - [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -603,52 +332,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "piper" -version = "0.2.1" +name = "ppv-lite86" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "atomic-waker", - "fastrand 2.0.1", - "futures-io", + "zerocopy", ] -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -696,18 +401,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ "bitflags", ] [[package]] name = "rust-embed" -version = "8.3.0" +version = "8.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +checksum = "60e425e204264b144d4c929d126d0de524b40a961686414bab5040f7465c71be" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -716,9 +421,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.3.0" +version = "8.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +checksum = "6bf418c9a2e3f6663ca38b8a7134cc2c2167c9d69688860e8961e3faa731702e" dependencies = [ "proc-macro2", "quote", @@ -729,9 +434,9 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "8.3.0" +version = "8.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +checksum = "08d55b95147fe01265d06b3955db798bdaed52e60e2211c41137701b3aba8e21" dependencies = [ "sha2", "walkdir", @@ -739,23 +444,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustix" -version = "0.37.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "same-file" @@ -768,9 +459,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -786,21 +477,11 @@ dependencies = [ "autocfg", ] -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "syn" -version = "2.0.38" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -809,21 +490,21 @@ dependencies = [ [[package]] name = "tokio" -version = "1.29.0" +version = "1.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374442f06ee49c3a28a8fc9f01a2596fed7559c6b99b31279c3261778e77d84f" +checksum = "68722da18b0fc4a05fdc1120b302b82051265792a1e1b399086e9b204b10ad3d" dependencies = [ - "autocfg", "backtrace", + "bytes", "pin-project-lite", "tokio-macros", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", @@ -832,9 +513,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" dependencies = [ "futures-core", "pin-project-lite", @@ -843,9 +524,9 @@ dependencies = [ [[package]] name = "tokio-test" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b3cbabd3ae862100094ae433e1def582cf86451b4e9bf83aa7ac1d8a7d719" +checksum = "2468baabc3311435b55dd935f702f42cd1b8abb7e754fb7dfb16bd36aa88f9f7" dependencies = [ "async-stream", "bytes", @@ -854,33 +535,17 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "tracing" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" - [[package]] name = "typenum" -version = "1.15.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "uuid" @@ -891,17 +556,11 @@ dependencies = [ "rand", ] -[[package]] -name = "value-bag" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3" - [[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 = "vfs" @@ -909,23 +568,17 @@ version = "0.12.1" dependencies = [ "anyhow", "async-recursion", - "async-std", "async-trait", "camino", "filetime", "futures", "rust-embed", "tokio", + "tokio-stream", "tokio-test", "uuid", ] -[[package]] -name = "waker-fn" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" - [[package]] name = "walkdir" version = "2.5.0" @@ -942,241 +595,104 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 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.4", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 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", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" -dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", -] - -[[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.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +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.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] -name = "windows_i686_msvc" -version = "0.48.5" +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.4" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "zerocopy" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +dependencies = [ + "zerocopy-derive", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.4" +name = "zerocopy-derive" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 830db4f..48599c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,24 +14,39 @@ travis-ci = { repository = "manuel-woelker/rust-vfs", branch = "master" } [dependencies] rust-embed = { version = "8.0.0", optional = true } -async-std = { version = "1.12.0", optional = true } -async-trait = { version = "0.1.73", optional = true} -tokio = { version = "1.29.0", features = ["macros", "rt"], optional = true} -futures = {version = "0.3.28", optional = true} -async-recursion = {version = "1.0.5", optional = true} -filetime = "0.2.23" -camino = { version = "1.0.5", optional = true } +async-trait = { version = "0.1.73", optional = true } +tokio = { version = "1.38", features = [ + "macros", + "rt", + "sync", + "fs", + "io-util", +], optional = true } # MSRV 1.65 +tokio-stream = { version = "0.1.2", features = ["fs"], optional = true } + +futures = { version = "0.3.28", optional = true } +async-recursion = { version = "1.1", optional = true } +filetime = "0.2.25" +camino = { version = "1.1.9", optional = true } [dev-dependencies] uuid = { version = "=0.8.1", features = ["v4"] } camino = "1.0.5" -anyhow = "1.0.58" -tokio-test = "0.4.3" +anyhow = "1.0" +tokio-test = "0.4" [features] +default = [] + embedded-fs = ["rust-embed"] -async-vfs = ["tokio", "async-std", "async-trait", "futures", "async-recursion"] -export-test-macros = [ "camino" ] +async-vfs = [ + "dep:tokio", + "dep:tokio-stream", + "dep:async-trait", + "dep:futures", + "dep:async-recursion", +] +export-test-macros = ["camino"] [package.metadata.docs.rs] features = ["embedded-fs", "async-vfs"] diff --git a/src/async_vfs/filesystem.rs b/src/async_vfs/filesystem.rs index 9a1063d..c3da59d 100644 --- a/src/async_vfs/filesystem.rs +++ b/src/async_vfs/filesystem.rs @@ -4,11 +4,11 @@ use crate::async_vfs::{AsyncVfsPath, SeekAndRead}; use crate::error::VfsErrorKind; use crate::{VfsError, VfsMetadata, VfsResult}; -use async_std::io::Write; -use async_std::stream::Stream; use async_trait::async_trait; +use futures::stream::Stream; use std::fmt::Debug; use std::time::SystemTime; +use tokio::io::AsyncWrite; /// File system implementations must implement this trait /// All path parameters are absolute, starting with '/', except for the root directory @@ -32,9 +32,9 @@ pub trait AsyncFileSystem: Debug + Sync + Send + 'static { /// Opens the file at this path for reading async fn open_file(&self, path: &str) -> VfsResult>; /// Creates a file at this path for writing - async fn create_file(&self, path: &str) -> VfsResult>; + async fn create_file(&self, path: &str) -> VfsResult>; /// Opens the file at this path for appending - async fn append_file(&self, path: &str) -> VfsResult>; + async fn append_file(&self, path: &str) -> VfsResult>; /// Returns the file metadata for the file at this path async fn metadata(&self, path: &str) -> VfsResult; /// Sets the files creation timestamp, if the implementation supports it diff --git a/src/async_vfs/impls/altroot.rs b/src/async_vfs/impls/altroot.rs index 9fa9092..ae60ccb 100644 --- a/src/async_vfs/impls/altroot.rs +++ b/src/async_vfs/impls/altroot.rs @@ -4,9 +4,9 @@ use crate::async_vfs::{AsyncFileSystem, AsyncVfsPath, SeekAndRead}; use crate::{error::VfsErrorKind, VfsMetadata, VfsResult}; use std::time::SystemTime; -use async_std::io::Write; use async_trait::async_trait; use futures::stream::{Stream, StreamExt}; +use tokio::io::AsyncWrite; /// Similar to a chroot but done purely by path manipulation /// @@ -60,11 +60,11 @@ impl AsyncFileSystem for AsyncAltrootFS { self.path(path)?.open_file().await } - async fn create_file(&self, path: &str) -> VfsResult> { + async fn create_file(&self, path: &str) -> VfsResult> { self.path(path)?.create_file().await } - async fn append_file(&self, path: &str) -> VfsResult> { + async fn append_file(&self, path: &str) -> VfsResult> { self.path(path)?.append_file().await } @@ -135,7 +135,7 @@ mod tests_physical { use super::*; use crate::async_vfs::AsyncPhysicalFS; - use async_std::io::ReadExt; + use tokio::io::AsyncReadExt; test_async_vfs!(futures::executor::block_on(async { let temp_dir = std::env::temp_dir(); diff --git a/src/async_vfs/impls/memory.rs b/src/async_vfs/impls/memory.rs index e738474..a110fcb 100644 --- a/src/async_vfs/impls/memory.rs +++ b/src/async_vfs/impls/memory.rs @@ -4,8 +4,6 @@ use crate::error::VfsErrorKind; use crate::path::VfsFileType; use crate::{VfsMetadata, VfsResult}; -use async_std::io::{prelude::SeekExt, Cursor, Read, Seek, SeekFrom, Write}; -use async_std::sync::{Arc, RwLock}; use async_trait::async_trait; use futures::task::{Context, Poll}; use futures::{Stream, StreamExt}; @@ -13,8 +11,16 @@ use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fmt; use std::fmt::{Debug, Formatter}; +use std::io::Cursor; use std::mem::swap; use std::pin::Pin; +use std::sync::Arc; + +use tokio::io::AsyncSeek; +use tokio::io::AsyncSeekExt; +use tokio::io::ReadBuf; +use tokio::io::{AsyncRead, AsyncWrite, SeekFrom}; +use tokio::sync::RwLock; type AsyncMemoryFsHandle = Arc>; @@ -60,12 +66,12 @@ struct AsyncWritableFile { fs: AsyncMemoryFsHandle, } -impl Write for AsyncWritableFile { +impl AsyncWrite for AsyncWritableFile { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], - ) -> Poll> { + ) -> Poll> { let this = self.get_mut(); let file = Pin::new(&mut this.content); file.poll_write(cx, buf) @@ -74,18 +80,18 @@ impl Write for AsyncWritableFile { fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { let this = self.get_mut(); let file = Pin::new(&mut this.content); file.poll_flush(cx) } - fn poll_close( + fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { let this = self.get_mut(); let file = Pin::new(&mut this.content); - file.poll_close(cx) + file.poll_shutdown(cx) } } @@ -106,7 +112,7 @@ impl Drop for AsyncWritableFile { struct AsyncReadableFile { #[allow(clippy::rc_buffer)] // to allow accessing the same object as writable content: Arc>, - // Position of the read cursor in the "file" + /// Position of the read cursor in the "file" cursor_pos: u64, } @@ -116,32 +122,31 @@ impl AsyncReadableFile { } } -impl Read for AsyncReadableFile { +impl AsyncRead for AsyncReadableFile { fn poll_read( self: Pin<&mut Self>, _cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { let this = self.get_mut(); let bytes_left = this.len() - this.cursor_pos; - let bytes_read = std::cmp::min(buf.len() as u64, bytes_left); + if bytes_left == 0 { - return Poll::Ready(Ok(0)); + return Poll::Ready(Ok(())); } - buf[..bytes_read as usize].copy_from_slice( + + let bytes_read = std::cmp::min(buf.capacity() as u64, bytes_left); + buf.put_slice( &this.content[this.cursor_pos as usize..(this.cursor_pos + bytes_read) as usize], ); this.cursor_pos += bytes_read; - Poll::Ready(Ok(bytes_read as usize)) + + Poll::Ready(Ok(())) } } -impl Seek for AsyncReadableFile { - fn poll_seek( - self: Pin<&mut Self>, - _cx: &mut Context<'_>, - pos: SeekFrom, - ) -> Poll> { +impl AsyncSeek for AsyncReadableFile { + fn start_seek(self: Pin<&mut Self>, pos: SeekFrom) -> Result<(), tokio::io::Error> { let this = self.get_mut(); let new_pos = match pos { SeekFrom::Start(offset) => offset as i64, @@ -149,15 +154,20 @@ impl Seek for AsyncReadableFile { SeekFrom::Current(offset) => this.cursor_pos as i64 + offset, }; if new_pos < 0 || new_pos >= this.len() as i64 { - Poll::Ready(Err(async_std::io::Error::new( - async_std::io::ErrorKind::InvalidData, + Err(tokio::io::Error::new( + tokio::io::ErrorKind::InvalidData, "Requested offset is outside the file!", - ))) + )) } else { this.cursor_pos = new_pos as u64; - Poll::Ready(Ok(new_pos as u64)) + Ok(()) } } + + fn poll_complete(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { + let this = self.get_mut(); + Poll::Ready(Ok(this.cursor_pos)) + } } #[async_trait] @@ -226,7 +236,7 @@ impl AsyncFileSystem for AsyncMemoryFS { })) } - async fn create_file(&self, path: &str) -> VfsResult> { + async fn create_file(&self, path: &str) -> VfsResult> { self.ensure_has_parent(path).await?; let content = Arc::new(Vec::::new()); self.handle.write().await.files.insert( @@ -244,7 +254,7 @@ impl AsyncFileSystem for AsyncMemoryFS { Ok(Box::new(writer)) } - async fn append_file(&self, path: &str) -> VfsResult> { + async fn append_file(&self, path: &str) -> VfsResult> { let handle = self.handle.write().await; let file = handle.files.get(path).ok_or(VfsErrorKind::FileNotFound)?; let mut content = Cursor::new(file.content.as_ref().clone()); @@ -327,28 +337,29 @@ struct AsyncMemoryFile { mod tests { use super::*; use crate::async_vfs::AsyncVfsPath; - use async_std::io::{ReadExt, WriteExt}; + + use tokio::io::{AsyncReadExt, AsyncWriteExt}; test_async_vfs!(AsyncMemoryFS::new()); #[tokio::test] async fn write_and_read_file() -> VfsResult<()> { let root = AsyncVfsPath::new(AsyncMemoryFS::new()); - let path = root.join("foobar.txt").unwrap(); + let path = root.join("foobar.txt")?; let _send = &path as &dyn Send; { - let mut file = path.create_file().await.unwrap(); - write!(file, "Hello world").await.unwrap(); - write!(file, "!").await.unwrap(); + let mut file = path.create_file().await?; + file.write_all(b"Hello world").await?; + file.write_all(b"!").await?; } { - let mut file = path.open_file().await.unwrap(); + let mut file = path.open_file().await?; let mut string: String = String::new(); - file.read_to_string(&mut string).await.unwrap(); + file.read_to_string(&mut string).await?; assert_eq!(string, "Hello world!"); } assert!(path.exists().await?); - assert!(!root.join("foo").unwrap().exists().await?); - let metadata = path.metadata().await.unwrap(); + assert!(!root.join("foo")?.exists().await?); + let metadata = path.metadata().await?; assert_eq!(metadata.len, 12); assert_eq!(metadata.file_type, VfsFileType::File); Ok(()) diff --git a/src/async_vfs/impls/overlay.rs b/src/async_vfs/impls/overlay.rs index 1ace095..39acdd6 100644 --- a/src/async_vfs/impls/overlay.rs +++ b/src/async_vfs/impls/overlay.rs @@ -4,11 +4,11 @@ use crate::async_vfs::{AsyncFileSystem, AsyncVfsPath, SeekAndRead}; use crate::error::VfsErrorKind; use crate::{VfsMetadata, VfsResult}; -use async_std::io::Write; use async_trait::async_trait; use futures::stream::{Stream, StreamExt}; use std::collections::HashSet; use std::time::SystemTime; +use tokio::io::AsyncWrite; /// An overlay file system combining several filesystems into one, an upper layer with read/write access and lower layers with only read access /// @@ -132,7 +132,7 @@ impl AsyncFileSystem for AsyncOverlayFS { self.read_path(path).await?.open_file().await } - async fn create_file(&self, path: &str) -> VfsResult> { + async fn create_file(&self, path: &str) -> VfsResult> { self.ensure_has_parent(path).await?; let result = self.write_path(path)?.create_file().await?; let whiteout_path = self.whiteout_path(path)?; @@ -142,7 +142,7 @@ impl AsyncFileSystem for AsyncOverlayFS { Ok(result) } - async fn append_file(&self, path: &str) -> VfsResult> { + async fn append_file(&self, path: &str) -> VfsResult> { let write_path = self.write_path(path)?; if !write_path.exists().await? { self.ensure_has_parent(path).await?; @@ -214,8 +214,8 @@ mod tests { use super::*; use crate::async_vfs::AsyncMemoryFS; - use async_std::io::WriteExt; use futures::stream::StreamExt; + use tokio::io::AsyncWriteExt; test_async_vfs!({ let upper_root: AsyncVfsPath = AsyncMemoryFS::new().into(); @@ -436,9 +436,9 @@ mod tests_physical { let temp_dir = std::env::temp_dir(); let dir = temp_dir.join(uuid::Uuid::new_v4().to_string()); let lower_path = dir.join("lower"); - async_std::fs::create_dir_all(&lower_path).await.unwrap(); + tokio::fs::create_dir_all(&lower_path).await.unwrap(); let upper_path = dir.join("upper"); - async_std::fs::create_dir_all(&upper_path).await.unwrap(); + tokio::fs::create_dir_all(&upper_path).await.unwrap(); let upper_root: AsyncVfsPath = AsyncPhysicalFS::new(upper_path).into(); let lower_root: AsyncVfsPath = AsyncPhysicalFS::new(lower_path).into(); diff --git a/src/async_vfs/impls/physical.rs b/src/async_vfs/impls/physical.rs index f2c4306..14f6a21 100644 --- a/src/async_vfs/impls/physical.rs +++ b/src/async_vfs/impls/physical.rs @@ -4,14 +4,18 @@ use crate::error::VfsErrorKind; use crate::path::VfsFileType; use crate::{VfsError, VfsMetadata, VfsResult}; -use async_std::fs::{File, OpenOptions}; -use async_std::io::{ErrorKind, Write}; -use async_std::path::{Path, PathBuf}; use async_trait::async_trait; use filetime::FileTime; -use futures::stream::{Stream, StreamExt}; +use futures::stream::Stream; +use tokio_stream::wrappers::ReadDirStream; +use tokio_stream::StreamExt; + +use std::path::{Path, PathBuf}; use std::pin::Pin; use std::time::SystemTime; + +use tokio::fs::{File, OpenOptions}; +use tokio::io::{AsyncWrite, ErrorKind}; use tokio::runtime::Handle; /// A physical filesystem implementation using the underlying OS file system @@ -66,23 +70,25 @@ impl AsyncFileSystem for AsyncPhysicalFS { async fn read_dir( &self, path: &str, - ) -> VfsResult + Send>> { - let entries = Box::new( - self.get_path(path) - .read_dir() - .await? - .map(|entry| entry.unwrap().file_name().into_string().unwrap()), - ); - Ok(entries) + ) -> VfsResult + Send + Unpin>> { + let p = self.get_path(path); + let read_dir = ReadDirStream::new(tokio::fs::read_dir(p).await?); + + let entries = read_dir.filter_map(|entry| match entry { + Ok(entry) => entry.file_name().into_string().ok(), + Err(_) => None, + }); + + Ok(Box::new(entries)) } async fn create_dir(&self, path: &str) -> VfsResult<()> { let fs_path = self.get_path(path); - match async_std::fs::create_dir(&fs_path).await { + match tokio::fs::create_dir(&fs_path).await { Ok(()) => Ok(()), Err(e) => match e.kind() { ErrorKind::AlreadyExists => { - let metadata = async_std::fs::metadata(&fs_path).await.unwrap(); + let metadata = tokio::fs::metadata(&fs_path).await.unwrap(); if metadata.is_dir() { return Err(VfsError::from(VfsErrorKind::DirectoryExists)); } @@ -97,11 +103,11 @@ impl AsyncFileSystem for AsyncPhysicalFS { Ok(Box::new(File::open(self.get_path(path)).await?)) } - async fn create_file(&self, path: &str) -> VfsResult> { + async fn create_file(&self, path: &str) -> VfsResult> { Ok(Box::new(File::create(self.get_path(path)).await?)) } - async fn append_file(&self, path: &str) -> VfsResult> { + async fn append_file(&self, path: &str) -> VfsResult> { Ok(Box::new( OpenOptions::new() .write(true) @@ -112,7 +118,7 @@ impl AsyncFileSystem for AsyncPhysicalFS { } async fn metadata(&self, path: &str) -> VfsResult { - let metadata = self.get_path(path).metadata().await?; + let metadata = tokio::fs::metadata(self.get_path(path)).await?; Ok(if metadata.is_dir() { VfsMetadata { file_type: VfsFileType::Directory, @@ -149,32 +155,32 @@ impl AsyncFileSystem for AsyncPhysicalFS { } async fn exists(&self, path: &str) -> VfsResult { - Ok(self.get_path(path).exists().await) + Ok(self.get_path(path).exists()) } async fn remove_file(&self, path: &str) -> VfsResult<()> { - async_std::fs::remove_file(self.get_path(path)).await?; + tokio::fs::remove_file(self.get_path(path)).await?; Ok(()) } async fn remove_dir(&self, path: &str) -> VfsResult<()> { - async_std::fs::remove_dir(self.get_path(path)).await?; + tokio::fs::remove_dir(self.get_path(path)).await?; Ok(()) } async fn copy_file(&self, src: &str, dest: &str) -> VfsResult<()> { - async_std::fs::copy(self.get_path(src), self.get_path(dest)).await?; + tokio::fs::copy(self.get_path(src), self.get_path(dest)).await?; Ok(()) } async fn move_file(&self, src: &str, dest: &str) -> VfsResult<()> { - async_std::fs::rename(self.get_path(src), self.get_path(dest)).await?; + tokio::fs::rename(self.get_path(src), self.get_path(dest)).await?; Ok(()) } async fn move_dir(&self, src: &str, dest: &str) -> VfsResult<()> { - let result = async_std::fs::rename(self.get_path(src), self.get_path(dest)).await; + let result = tokio::fs::rename(self.get_path(src), self.get_path(dest)).await; if result.is_err() { // Error possibly due to different filesystems, return not supported and let the fallback handle it return Err(VfsErrorKind::NotSupported.into()); @@ -188,15 +194,16 @@ mod tests { use super::*; use crate::async_vfs::AsyncVfsPath; - use async_std::io::ReadExt; - use async_std::io::WriteExt; - use async_std::path::Path; use futures::stream::StreamExt; + use std::path::Path; + + use tokio::io::AsyncReadExt; + use tokio::io::AsyncWriteExt; test_async_vfs!(futures::executor::block_on(async { let temp_dir = std::env::temp_dir(); let dir = temp_dir.join(uuid::Uuid::new_v4().to_string()); - async_std::fs::create_dir_all(&dir).await.unwrap(); + tokio::fs::create_dir_all(&dir).await.unwrap(); AsyncPhysicalFS::new(dir) })); test_async_vfs_readonly!({ AsyncPhysicalFS::new("test/test_directory") }); @@ -207,7 +214,7 @@ mod tests { #[tokio::test] async fn open_file() { - let expected = async_std::fs::read_to_string("Cargo.toml").await.unwrap(); + let expected = tokio::fs::read_to_string("Cargo.toml").await.unwrap(); let root = create_root(); let mut string = String::new(); root.join("Cargo.toml") @@ -225,8 +232,9 @@ mod tests { async fn create_file() { let root = create_root(); let _string = String::new(); - let _ = async_std::fs::remove_file("target/test.txt").await; - root.join("target/test.txt") + let p = "target/test_async_create_file.txt"; + let _ = tokio::fs::remove_file(p).await; + root.join(p) .unwrap() .create_file() .await @@ -234,7 +242,7 @@ mod tests { .write_all(b"Testing only") .await .unwrap(); - let read = std::fs::read_to_string("target/test.txt").unwrap(); + let read = std::fs::read_to_string(p).unwrap(); assert_eq!(read, "Testing only"); } @@ -242,7 +250,7 @@ mod tests { async fn append_file() { let root = create_root(); let _string = String::new(); - let _ = async_std::fs::remove_file("target/test_append.txt").await; + let _ = tokio::fs::remove_file("target/test_append.txt").await; let path = Box::pin(root.join("target/test_append.txt").unwrap()); path.create_file() .await @@ -256,7 +264,7 @@ mod tests { .write_all(b"Testing 2") .await .unwrap(); - let read = async_std::fs::read_to_string("target/test_append.txt") + let read = tokio::fs::read_to_string("target/test_append.txt") .await .unwrap(); assert_eq!(read, "Testing 1Testing 2"); @@ -264,7 +272,7 @@ mod tests { #[tokio::test] async fn read_dir() { - let _expected = async_std::fs::read_to_string("Cargo.toml").await.unwrap(); + let _expected = tokio::fs::read_to_string("Cargo.toml").await.unwrap(); let root = create_root(); let entries: Vec<_> = root.read_dir().await.unwrap().collect().await; let map: Vec<_> = entries @@ -277,7 +285,7 @@ mod tests { #[tokio::test] async fn create_dir() { - let _ = async_std::fs::remove_dir("target/fs_test").await; + let _ = tokio::fs::remove_dir("target/fs_test").await; let root = create_root(); root.join("target/fs_test") .unwrap() @@ -285,14 +293,14 @@ mod tests { .await .unwrap(); let path = Path::new("target/fs_test"); - assert!(path.exists().await, "Path was not created"); - assert!(path.is_dir().await, "Path is not a directory"); - async_std::fs::remove_dir("target/fs_test").await.unwrap(); + assert!(path.exists(), "Path was not created"); + assert!(path.is_dir(), "Path is not a directory"); + tokio::fs::remove_dir("target/fs_test").await.unwrap(); } #[tokio::test] async fn file_metadata() { - let expected = async_std::fs::read_to_string("Cargo.toml").await.unwrap(); + let expected = tokio::fs::read_to_string("Cargo.toml").await.unwrap(); let root = create_root(); let metadata = root.join("Cargo.toml").unwrap().metadata().await.unwrap(); assert_eq!(metadata.len, expected.len() as u64); diff --git a/src/async_vfs/mod.rs b/src/async_vfs/mod.rs index 5944879..d363383 100644 --- a/src/async_vfs/mod.rs +++ b/src/async_vfs/mod.rs @@ -13,7 +13,7 @@ //! # Usage Examples //! //! ``` -//! use async_std::io::{ReadExt, WriteExt}; +//! use tokio::io::{AsyncReadExt, AsyncWriteExt}; //! use vfs::async_vfs::{AsyncVfsPath, AsyncPhysicalFS}; //! use vfs::VfsError; //! @@ -29,7 +29,7 @@ //! ``` //! //! ``` -//! use async_std::io::{ReadExt, WriteExt}; +//! use tokio::io::{AsyncReadExt, AsyncWriteExt}; //! use vfs::async_vfs::{AsyncVfsPath, AsyncMemoryFS}; //! use vfs::VfsError; //! diff --git a/src/async_vfs/path.rs b/src/async_vfs/path.rs index 20b6358..b42ea4b 100644 --- a/src/async_vfs/path.rs +++ b/src/async_vfs/path.rs @@ -10,17 +10,18 @@ use crate::path::VfsFileType; use crate::{VfsMetadata, VfsResult}; use async_recursion::async_recursion; -use async_std::io::{Read, ReadExt, Seek, Write}; -use async_std::sync::Arc; -use async_std::task::{Context, Poll}; +use futures::task::{Context, Poll}; use futures::{future::BoxFuture, FutureExt, Stream, StreamExt}; use std::pin::Pin; +use std::sync::Arc; use std::time::SystemTime; +use tokio::io::{AsyncRead, AsyncReadExt, AsyncSeek, AsyncWrite}; + /// Trait combining Seek and Read, return value for opening files -pub trait SeekAndRead: Seek + Read {} +pub trait SeekAndRead: AsyncSeek + AsyncRead {} -impl SeekAndRead for T where T: Seek + Read {} +impl SeekAndRead for T where T: AsyncSeek + AsyncRead {} #[derive(Debug)] struct AsyncVFS { @@ -262,20 +263,22 @@ impl AsyncVfsPath { /// ``` /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; - /// use async_std::io:: {ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # tokio_test::block_on(async { - /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); - /// let file = path.join("foo.txt")?; - /// - /// write!(file.create_file().await?, "Hello, world!").await?; + /// let root = AsyncVfsPath::new(AsyncMemoryFS::new()); + /// let path = root.join("foo.txt")?; + /// { + /// let mut f = path.create_file().await?; + /// f.write_all(b"Hello, world!").await?; + /// } /// /// let mut result = String::new(); - /// file.open_file().await?.read_to_string(&mut result).await?; + /// path.open_file().await?.read_to_string(&mut result).await?; /// assert_eq!(&result, "Hello, world!"); /// # Ok::<(), VfsError>(()) /// # }); /// ``` - pub async fn create_file(&self) -> VfsResult> { + pub async fn create_file(&self) -> VfsResult> { self.get_parent("create file").await?; self.fs.fs.create_file(&self.path).await.map_err(|err| { err.with_path(&self.path) @@ -288,11 +291,14 @@ impl AsyncVfsPath { /// ``` /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; - /// use async_std::io:: {ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; - /// write!(file.create_file().await?, "Hello, world!").await?; + /// { + /// let mut f = file.create_file().await?; + /// f.write_all(b"Hello, world!").await?; + /// } /// let mut result = String::new(); /// /// file.open_file().await?.read_to_string(&mut result).await?; @@ -334,19 +340,25 @@ impl AsyncVfsPath { /// ``` /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; - /// use async_std::io:: {ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; - /// write!(file.create_file().await?, "Hello, ").await?; - /// write!(file.append_file().await?, "world!").await?; + /// { + /// let mut f = file.create_file().await?; + /// f.write(b"Hello, ").await?; + /// } + /// { + /// let mut f = file.append_file().await?; + /// f.write(b"world!").await?; + /// } /// let mut result = String::new(); /// file.open_file().await?.read_to_string(&mut result).await?; /// assert_eq!(&result, "Hello, world!"); /// # Ok::<(), VfsError>(()) /// # }); /// ``` - pub async fn append_file(&self) -> VfsResult> { + pub async fn append_file(&self) -> VfsResult> { self.fs.fs.append_file(&self.path).await.map_err(|err| { err.with_path(&self.path) .with_context(|| "Could not open file for appending") @@ -356,13 +368,14 @@ impl AsyncVfsPath { /// Removes the file at this path /// /// ``` - /// use async_std::io:: {ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # use vfs::async_vfs::{AsyncMemoryFS , AsyncVfsPath}; /// # use vfs::VfsError; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; - /// write!(file.create_file().await?, "Hello, ").await?; + /// let mut f = file.create_file().await?; + /// f.write_all(b"Hello, ").await?; /// assert!(file.exists().await?); /// /// file.remove_file().await?; @@ -445,7 +458,7 @@ impl AsyncVfsPath { /// ``` /// use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// use vfs::{VfsError, VfsFileType, VfsMetadata}; - /// use async_std::io::WriteExt; + /// use tokio::io::AsyncWriteExt; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let directory = path.join("foo")?; @@ -455,7 +468,10 @@ impl AsyncVfsPath { /// assert_eq!(directory.metadata().await?.file_type, VfsFileType::Directory); /// /// let file = path.join("bar.txt")?; - /// write!(file.create_file().await?, "Hello, world!").await?; + /// { + /// let mut f = file.create_file().await?; + /// f.write(b"Hello, world!").await?; + /// } /// /// assert_eq!(file.metadata().await?.len, 13); /// assert_eq!(file.metadata().await?.file_type, VfsFileType::File); @@ -473,7 +489,7 @@ impl AsyncVfsPath { /// ``` /// use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// use vfs::{VfsError, VfsFileType, VfsMetadata, VfsPath}; - /// use async_std::io::WriteExt; + /// use tokio::io::AsyncWriteExt; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; @@ -503,7 +519,7 @@ impl AsyncVfsPath { /// ``` /// use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// use vfs::{VfsError, VfsFileType, VfsMetadata, VfsPath}; - /// use async_std::io::WriteExt; + /// use tokio::io::AsyncWriteExt; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; @@ -533,7 +549,7 @@ impl AsyncVfsPath { /// ``` /// use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// use vfs::{VfsError, VfsFileType, VfsMetadata, VfsPath}; - /// use async_std::io::WriteExt; + /// use tokio::io::AsyncWriteExt; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; @@ -727,15 +743,27 @@ impl AsyncVfsPath { /// ``` /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; - /// use async_std::io::{ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let file = path.join("foo.txt")?; - /// write!(file.create_file().await?, "Hello, world!").await?; + /// { + /// let mut f = file.create_file().await?; + /// f.write_all(b"Hello, world!").await?; + /// } /// /// let result = file.read_to_string().await?; - /// /// assert_eq!(&result, "Hello, world!"); + /// + /// { + /// let mut f = file.append_file().await?; + /// for i in 0..5000 { + /// f.write_all(b"Hello, world!").await?; + /// } + /// } + /// + /// let result = file.read_to_string().await?; + /// assert_eq!(result.len(), 13 * 5001); /// # Ok::<(), VfsError>(()) /// # }); /// ``` @@ -766,13 +794,16 @@ impl AsyncVfsPath { /// The destination must not exist, but its parent directory must /// /// ``` - /// use async_std::io::{ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let src = path.join("foo.txt")?; - /// write!(src.create_file().await?, "Hello, world!").await?; + /// { + /// let mut f = src.create_file().await?; + /// f.write_all(b"Hello, world!").await?; + /// } /// let dest = path.join("bar.txt")?; /// /// src.copy_file(&dest).await?; @@ -803,7 +834,7 @@ impl AsyncVfsPath { } let mut src = self.open_file().await?; let mut dest = destination.create_file().await?; - async_std::io::copy(&mut src, &mut dest) + tokio::io::copy(&mut src, &mut dest) .await .map_err(|source| { VfsError::from(source) @@ -832,11 +863,14 @@ impl AsyncVfsPath { /// ``` /// # use vfs::async_vfs::{AsyncMemoryFS, AsyncVfsPath}; /// # use vfs::VfsError; - /// use async_std::io::{ReadExt, WriteExt}; + /// use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// # tokio_test::block_on(async { /// let path = AsyncVfsPath::new(AsyncMemoryFS::new()); /// let src = path.join("foo.txt")?; - /// write!(src.create_file().await?, "Hello, world!").await?; + /// { + /// let mut file = src.create_file().await?; + /// file.write(b"Hello, world!").await?; + /// } /// let dest = path.join("bar.txt")?; /// /// src.move_file(&dest).await?; @@ -868,7 +902,7 @@ impl AsyncVfsPath { } let mut src = self.open_file().await?; let mut dest = destination.create_file().await?; - async_std::io::copy(&mut src, &mut dest) + tokio::io::copy(&mut src, &mut dest) .await .map_err(|source| { VfsError::from(source) diff --git a/src/async_vfs/test_macros.rs b/src/async_vfs/test_macros.rs index a4e347c..8bfe1fc 100644 --- a/src/async_vfs/test_macros.rs +++ b/src/async_vfs/test_macros.rs @@ -11,7 +11,7 @@ macro_rules! test_async_vfs { use $crate::VfsResult; use $crate::error::VfsErrorKind; use futures::stream::StreamExt; - use async_std::io::{WriteExt, ReadExt}; + use tokio::io::{AsyncWriteExt, AsyncReadExt}; use std::time::SystemTime; fn create_root() -> AsyncVfsPath { @@ -102,8 +102,8 @@ macro_rules! test_async_vfs { let _send = &path as &dyn Send; { let mut file = path.create_file().await.unwrap(); - write!(file, "Hello world").await.unwrap(); - write!(file, "!").await.unwrap(); + file.write_all(b"Hello world").await.unwrap(); + file.write_all(b"!").await.unwrap(); } { let mut file = path.open_file().await.unwrap(); @@ -317,8 +317,8 @@ macro_rules! test_async_vfs { Ok(()) } - #[test] - fn filename() { + #[tokio::test] + async fn filename() { let root = create_root(); assert_eq!(root.filename(), ""); assert_eq!( @@ -336,8 +336,8 @@ macro_rules! test_async_vfs { assert_eq!(root.join("fizz.buzz/foo.").unwrap().filename(), "foo."); } - #[test] - fn extension() { + #[tokio::test] + async fn extension() { let root = create_root(); assert_eq!(root.extension(), None, "root"); assert_eq!(root.join("name").unwrap().extension(), None, "name"); @@ -380,8 +380,8 @@ macro_rules! test_async_vfs { ); } - #[test] - fn parent() { + #[tokio::test] + async fn parent() { let root = create_root(); assert_eq!(root.parent(), root.clone(), "root"); assert_eq!( @@ -401,8 +401,8 @@ macro_rules! test_async_vfs { ); } - #[test] - fn eq() { + #[tokio::test] + async fn eq() { let root = create_root(); assert_eq!(root, root); @@ -421,8 +421,8 @@ macro_rules! test_async_vfs { assert_ne!(root.join("foo").unwrap(), root2.join("foo").unwrap()); } - #[test] - fn join() { + #[tokio::test] + async fn join() { let root = create_root(); assert_eq!(root.join("").unwrap().as_str(), ""); assert_eq!(root.join("foo").unwrap().join("").unwrap().as_str(), "/foo"); diff --git a/src/impls/physical.rs b/src/impls/physical.rs index 1034cb9..9aa9beb 100644 --- a/src/impls/physical.rs +++ b/src/impls/physical.rs @@ -174,14 +174,15 @@ mod tests { fn create_file() { let root = create_root(); let _string = String::new(); - let _ = std::fs::remove_file("target/test.txt"); - root.join("target/test.txt") + let p = "target/test_create_file.txt"; + let _ = std::fs::remove_file(p); + root.join(p) .unwrap() .create_file() .unwrap() .write_all(b"Testing only") .unwrap(); - let read = std::fs::read_to_string("target/test.txt").unwrap(); + let read = std::fs::read_to_string(p).unwrap(); assert_eq!(read, "Testing only"); }