diff --git a/Cargo.lock b/Cargo.lock index 5203879..1ddc5c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,21 +10,20 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aes" -version = "0.7.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "opaque-debug", ] [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -37,15 +36,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bitflags" @@ -53,11 +52,17 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -72,16 +77,20 @@ dependencies = [ ] [[package]] -name = "bumpalo" -version = "3.12.0" +name = "bstr" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +dependencies = [ + "memchr", + "serde", +] [[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 = "bzip2" @@ -106,11 +115,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -121,11 +131,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] @@ -136,9 +147,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -154,9 +165,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" dependencies = [ "cfg-if", ] @@ -171,11 +182,20 @@ dependencies = [ "typenum", ] +[[package]] +name = "deranged" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +dependencies = [ + "powerfmt", +] + [[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", @@ -184,33 +204,40 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "erased-serde" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ca605381c017ec7a5fef5e548f1cfaa419ed0f6df6367339300db74c92aa7d" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" dependencies = [ "serde", ] [[package]] -name = "fastrand" -version = "1.8.0" +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "instant", + "libc", + "windows-sys 0.52.0", ] +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -218,44 +245,32 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" - -[[package]] -name = "futures-macro" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", - "futures-macro", "futures-task", "pin-project-lite", "pin-utils", @@ -264,14 +279,25 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "hmac" version = "0.12.1" @@ -281,23 +307,32 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "idna" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] [[package]] -name = "instant" -version = "0.1.12" +name = "inout" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "cfg-if", + "generic-array", ] [[package]] @@ -309,145 +344,172 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] -name = "js-sys" -version = "0.3.60" +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "libloading" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ - "wasm-bindgen", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] -name = "libc" -version = "0.2.139" +name = "linux-raw-sys" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lua-src" -version = "544.0.1" +version = "546.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "708ba3c844d5e9d38def4a09dd871c17c370f519b3c4b7261fbabe4a613a814c" +checksum = "2da0daa7eee611a4c30c8f5ee31af55266e26e573971ba9336d2993e2da129b2" dependencies = [ "cc", ] [[package]] name = "luajit-src" -version = "210.4.5+resty2cf5186" +version = "210.5.3+29b0b28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b7992a40e602786272d84c6f2beca44a588ededcfd57b48ec6f82008a7cb97" +checksum = "0c2bb89013916ce5c949f01a1fbd6d435a58e1d980767a791d755911211d792d" dependencies = [ "cc", + "which", ] [[package]] name = "luau0-src" -version = "0.5.1+luau558" +version = "0.7.11+luau606" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0869ba31f9b152c28bb604ecee6deaa2103a97365bb219781ac137bd487626" +checksum = "07ffc4945ee953a33cb2b331e00b19e11275fc105c8ac8a977c810597d790f08" dependencies = [ "cc", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "mlua" -version = "0.8.7" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee2ad7a9aa69056b148d9d590344bc155d3ce0d2200e3b2838f7034f6ba33c1" +checksum = "7c81f8ac20188feb5461a73eabb22a34dd09d6d58513535eb587e46bff6ba250" dependencies = [ - "bstr", - "cc", + "bstr 1.8.0", "erased-serde", - "futures-core", - "futures-task", "futures-util", - "lua-src", - "luajit-src", - "luau0-src", + "libloading", + "mlua-sys", "mlua_derive", "num-traits", "once_cell", - "pkg-config", "rustc-hash", "serde", + "serde-value", +] + +[[package]] +name = "mlua-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc29228347d6bdc9e613dc95c69df2817f755434ee0f7f3b27b57755fe238b7f" +dependencies = [ + "cc", + "cfg-if", + "lua-src", + "luajit-src", + "luau0-src", + "pkg-config", ] [[package]] name = "mlua_derive" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9214e60d3cf1643013b107330fcd374ccec1e4ba1eef76e7e5da5e8202e71c0" +checksum = "0f359220f24e6452dd82a3f50d7242d4aab822b5594798048e953d7a9e0314c6" dependencies = [ - "itertools", + "itertools 0.11.0", "once_cell", "proc-macro-error", "proc-macro2", "quote", "regex", - "syn", + "syn 2.0.41", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.17.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "ordered-float" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] [[package]] name = "password-hash" @@ -474,15 +536,15 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -492,9 +554,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro-error" @@ -505,7 +573,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -522,18 +590,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -546,62 +614,64 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", + "regex-automata", "regex-syntax", ] [[package]] -name = "regex-syntax" -version = "0.6.28" +name = "regex-automata" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "rlua" -version = "0.19.4" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b38117a836316ef62c02f6751e6d28e2eb53a1c35f0329427a9fb9c1c7b6a0" +checksum = "5d33e5ba15c3d43178f283ed5863d4531e292fc0e56fb773f3bea45f18e3a42a" dependencies = [ - "bitflags", - "bstr", + "bitflags 1.3.2", + "bstr 0.2.17", "libc", "num-traits", "rlua-lua51-sys", @@ -611,9 +681,9 @@ dependencies = [ [[package]] name = "rlua-lua51-sys" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5b07f844489670cc84ac3a0140141251c83eae1885186b72be23826bdbe8e3" +checksum = "5c8f4636b03fa54b5c154415f1d9333cec7a7e3bd6bc64c092a2196e488cfd52" dependencies = [ "cc", "libc", @@ -622,9 +692,9 @@ dependencies = [ [[package]] name = "rlua-lua53-sys" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ac18111861b20e6df46af6bf56fbe81f2d01d8a48f533b0e632ff3e6c1f74de" +checksum = "c930c9de241450277dec8617cfa540eaed711db7b0fd894316d7d7c0b6b8f4a4" dependencies = [ "cc", "libc", @@ -633,9 +703,9 @@ dependencies = [ [[package]] name = "rlua-lua54-sys" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ae48797c3e76fb2c205fda8f30e28416a15b9fc1d649cc7cea9ff1fb9cf028" +checksum = "7aafabafe1895cb4a2be81a56d7ff3d46bf4b5d2f9cfdbea2ed404cdabe96474" dependencies = [ "cc", "libc", @@ -648,29 +718,52 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", + "rustls-webpki", "sct", - "webpki", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", ] [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -678,29 +771,39 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.152" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.41", ] [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -709,9 +812,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -720,9 +823,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -731,30 +834,41 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] [[package]] name = "syn" -version = "1.0.107" +version = "2.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" dependencies = [ "proc-macro2", "quote", @@ -765,8 +879,8 @@ dependencies = [ name = "tealr" version = "0.9.0-alpha4" dependencies = [ - "bstr", - "itertools", + "bstr 0.2.17", + "itertools 0.10.5", "mlua", "rlua", "serde", @@ -780,7 +894,7 @@ version = "0.9.0-alpha4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "tempfile", "ureq", "venial", @@ -789,44 +903,34 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.48.0", ] [[package]] name = "time" -version = "0.3.17" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ - "itoa", + "deranged", + "powerfmt", "serde", "time-core", - "time-macros", ] [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" -dependencies = [ - "time-core", -] +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "tinyvec" @@ -839,27 +943,27 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -872,31 +976,31 @@ dependencies = [ [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.6.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d" +checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" dependencies = [ "base64", "flate2", "log", "once_cell", "rustls", + "rustls-webpki", "url", - "webpki", "webpki-roots", ] [[package]] name = "url" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -920,115 +1024,167 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "wasm-bindgen" -version = "0.2.83" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" +name = "which" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" dependencies = [ - "bumpalo", - "log", + "either", + "home", "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", + "rustix", + "windows-sys 0.48.0", ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" +name = "windows-sys" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "quote", - "wasm-bindgen-macro-support", + "windows-targets 0.48.5", ] [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", + "windows-targets 0.52.0", ] [[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" +name = "windows-targets" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] [[package]] -name = "web-sys" -version = "0.3.60" +name = "windows-targets" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ - "js-sys", - "wasm-bindgen", + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] -name = "webpki" -version = "0.22.0" +name = "windows_aarch64_gnullvm" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] -name = "webpki-roots" -version = "0.22.6" +name = "windows_aarch64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows_aarch64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_i686_gnu" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "zip" -version = "0.6.3" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ "aes", "byteorder", @@ -1065,11 +1221,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.5+zstd.1.5.2" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc50ffce891ad571e9f9afe5039c4837bede781ac4bb13052ed7ae695518596" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index d414b58..757bd84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,7 @@ repository = "https://github.com/lenscas/tealr/" version = "0.9.0-alpha4" [workspace] -members = [ - "tealr_derive", -] +members = ["tealr_derive"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -48,13 +46,13 @@ rlua_system-lua53 = ["rlua/system-lua53"] rlua_system-lua54 = ["rlua/system-lua54"] [dependencies] -bstr = {version = "0.2", default_features = false, features = ["std"]} +bstr = { version = "0.2", default_features = false, features = ["std"] } itertools = "0.10.3" -mlua = {version = "0.8.1", optional = true, default_features = false} -rlua = {version = "0.19.2", optional = true, default_features = false} -serde = {version = "1.0.136", features = ["derive"]} +mlua = { version = "0.9.2", optional = true, default_features = false } +rlua = { version = "0.19.7", optional = true, default_features = false } +serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.91" -tealr_derive = {version = "0.9.0-alpha4", optional = true, path = "./tealr_derive"} +tealr_derive = { version = "0.9.0-alpha4", optional = true, path = "./tealr_derive" } # Rlua tests [[test]] @@ -207,5 +205,13 @@ path = "examples/mlua/named_parameters.rs" required-features = ["mlua"] [package.metadata.docs.rs] -features = ["mlua", "rlua", "rlua_builtin-lua54", "mlua_lua54", "mlua_vendored", "mlua_async", "mlua_serialize"] +features = [ + "mlua", + "rlua", + "rlua_builtin-lua54", + "mlua_lua54", + "mlua_vendored", + "mlua_async", + "mlua_serialize", +] rustdoc-args = ["--cfg", "docsrs"] diff --git a/README.md b/README.md index 2db72ca..19ec23d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,19 @@ Mlua: use tealr::ToTypename; #[derive(Clone, tealr::mlu::UserData, ToTypename)] struct ExampleMlua {} +impl<'lua> FromLua<'lua> for ExampleMlua { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} + impl tealr::mlu::TealData for ExampleMlua { //implement your methods/functions fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { @@ -136,7 +149,7 @@ To go along with typed functions, tealr also comes with a way to mimic generics. In the following example we take a generic function and call it, returning whatever it returned back to lua. Thanks to the use of generics, it i clear that the return type of the method is equal to the return type of the lambda. If `lua::Value` was used instead this was not clear. ```rust ignore -use mlua::ToLua; +use mlua::IntoLua; use tealr::{ create_generic_mlua, mlu::{mlua::FromLua, TealData, TealDataMethods, TypedFunction,UserData}, @@ -147,6 +160,7 @@ create_generic_mlua!(X); #[derive(Clone, UserData, ToTypename)] struct Example {} + impl TealData for Example { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { methods.add_method( @@ -157,6 +171,21 @@ impl TealData for Example { ); } } + +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} + + ``` For rlua, all you have to do is replace `mlua` for `rlua` @@ -201,7 +230,7 @@ let compiler = embed_compiler!("v0.13.1"); { let code = compiler("example/basic_teal_file"); let lua = tealr::mlu::mlua::Lua::new(); - let res: u8 = lua.load(&code).set_name("embedded_compiler")?.eval()?; + let res: u8 = lua.load(&code).set_name("embedded_compiler").eval()?; }; Ok::<(), Box>(()) ``` diff --git a/examples/mlua/compile_inline_teal.rs b/examples/mlua/compile_inline_teal.rs index b26b847..36ccca2 100644 --- a/examples/mlua/compile_inline_teal.rs +++ b/examples/mlua/compile_inline_teal.rs @@ -24,7 +24,7 @@ return add(1,2) let result: String = lua .load(code) - .set_name("compile inline teal example")? + .set_name("compile inline teal example") .eval()?; println!("output:{}", result); diff --git a/examples/mlua/derive.rs b/examples/mlua/derive.rs index dc5bb6c..0c150eb 100644 --- a/examples/mlua/derive.rs +++ b/examples/mlua/derive.rs @@ -1,6 +1,6 @@ use tealr::{ mlu::{ - mlua::{Lua, Result}, + mlua::{FromLua, Lua, Result}, TealData, TealDataMethods, UserData, }, ToTypename, TypeWalker, @@ -17,6 +17,18 @@ use tealr::{ //The clone is only needed because one of the example functions has it as a parameter #[derive(Clone, UserData, ToTypename)] struct Example {} +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { @@ -55,6 +67,6 @@ print(test:example_method_mut(2,\"test\")) print(test.example_function({})) print(test.example_function_mut(true)) "; - lua.load(code).set_name("test?")?.eval()?; + lua.load(code).set_name("test?").eval()?; Ok(()) } diff --git a/examples/mlua/embed_teal.rs b/examples/mlua/embed_teal.rs index d3ebe08..dcef9d8 100644 --- a/examples/mlua/embed_teal.rs +++ b/examples/mlua/embed_teal.rs @@ -6,7 +6,7 @@ fn main() -> mlua::Result<()> { let compiler = embed_compiler!("v0.9.0"); let lua = mlua::Lua::new(); let code = compiler("examples/mlua/basic_teal_file"); - let res: u8 = lua.load(&code).set_name("embedded_compiler")?.eval()?; + let res: u8 = lua.load(&code).set_name("embedded_compiler").eval()?; println!("got:{}", res); Ok(()) } diff --git a/examples/mlua/manual.rs b/examples/mlua/manual.rs index a15c658..4fc1b64 100644 --- a/examples/mlua/manual.rs +++ b/examples/mlua/manual.rs @@ -1,6 +1,6 @@ use tealr::{ mlu::{ - mlua::{Lua, Result, UserData, UserDataMethods}, + mlua::{FromLua, Lua, Result, UserData, UserDataMethods}, TealData, TealDataMethods, UserDataWrapper, }, ToTypename, TypeBody, TypeWalker, @@ -13,6 +13,18 @@ use tealr::{ //First, create the struct you want to export to lua. #[derive(Clone, Copy)] struct Example(u32); +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { @@ -90,6 +102,6 @@ print(\"Example field\", test.example_field) test.example_field = 2 print(\"After modifying\",test.example_field) "; - lua.load(code).set_name("test?")?.eval()?; + lua.load(code).set_name("test?").eval()?; Ok(()) } diff --git a/examples/mlua/manual_documentation.rs b/examples/mlua/manual_documentation.rs index 7641769..7574004 100644 --- a/examples/mlua/manual_documentation.rs +++ b/examples/mlua/manual_documentation.rs @@ -1,6 +1,6 @@ use tealr::{ mlu::{ - mlua::{Lua, Result, UserData, UserDataMethods}, + mlua::{FromLua, Lua, Result, UserData, UserDataMethods}, TealData, TealDataMethods, UserDataWrapper, }, ToTypename, TypeBody, TypeWalker, @@ -13,6 +13,18 @@ use tealr::{ //First, create the struct you want to export to lua. #[derive(Clone, Copy)] struct Example(u32); +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { @@ -104,6 +116,6 @@ print(test.example_function({})) print(test.example_function_mut(true)) "; - lua.load(code).set_name("test?")?.eval()?; + lua.load(code).set_name("test?").eval()?; Ok(()) } diff --git a/examples/mlua/named_parameters.rs b/examples/mlua/named_parameters.rs index 7e9345a..d4a36f1 100644 --- a/examples/mlua/named_parameters.rs +++ b/examples/mlua/named_parameters.rs @@ -43,6 +43,6 @@ fn main() -> Result<()> { let globals = lua.globals(); globals.set("test", Example {})?; let code = "test:example_method(\"field_1 is a string\", 3)"; - lua.load(code).set_name("test?")?.eval()?; + lua.load(code).set_name("test?").eval()?; Ok(()) } diff --git a/examples/mlua/userdata_proxy.rs b/examples/mlua/userdata_proxy.rs index 09e1b98..d0513f4 100644 --- a/examples/mlua/userdata_proxy.rs +++ b/examples/mlua/userdata_proxy.rs @@ -1,3 +1,4 @@ +use mlua::FromLua; use tealr::{ mlu::{ mlua::{Lua, Result}, @@ -17,6 +18,19 @@ struct Example { float: f32, } +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} + //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { //implement your methods/functions @@ -88,6 +102,6 @@ print(\" Calling from global `Example` :\") print(Example.example_static_field) print(Example.example_function({})) "; - lua.load(code).set_name("test?")?.eval()?; + lua.load(code).set_name("test?").eval()?; Ok(()) } diff --git a/src/exported_function.rs b/src/exported_function.rs index 101850a..fc4fdec 100644 --- a/src/exported_function.rs +++ b/src/exported_function.rs @@ -43,10 +43,10 @@ impl ExportedFunction { ///Creates an ExportedFunction with the given name, Parameters and return value ///```no_run ///# use tealr::ExportedFunction; - ///ExportedFunction::new::<(String,String),String,_>(b"concat",false,None); + ///ExportedFunction::new::<(String,String),String,_>("concat",false,None); ///``` #[cfg(any(feature = "rlua", feature = "mlua"))] - pub fn new>( + pub fn new>( name: S, is_meta_method: bool, extra_self: Option, @@ -72,7 +72,7 @@ impl ExportedFunction { let signature = crate::new_type_to_old(type_to_generate, false); #[allow(deprecated)] Self { - name: name.as_ref().to_vec().into(), + name: name.as_ref().as_bytes().to_vec().into(), signature, is_meta_method, params, diff --git a/src/mlu.rs b/src/mlu.rs index 265d348..3b091e3 100644 --- a/src/mlu.rs +++ b/src/mlu.rs @@ -72,7 +72,7 @@ pub(crate) fn get_meta_name(name: mlua::MetaMethod) -> Cow<'static, str> { MetaMethod::Close => Cow::Borrowed("__close"), #[cfg(feature = "mlua_luau")] MetaMethod::Iter => Cow::Borrowed("__iter"), - MetaMethod::Custom(x) => Cow::Owned(x), + _ => Cow::Borrowed("unknown"), } } diff --git a/src/mlu/generics.rs b/src/mlu/generics.rs index 479da89..b83c2d6 100644 --- a/src/mlu/generics.rs +++ b/src/mlu/generics.rs @@ -32,8 +32,8 @@ macro_rules! create_generic_mlua { Ok(value.into()) } } - impl<'lua> $crate::mlu::mlua::ToLua<'lua> for $type_name<'lua> { - fn to_lua(self, _: &'lua $crate::mlu::mlua::Lua) -> ::std::result::Result<$crate::mlu::mlua::Value<'lua>, $crate::mlu::mlua::Error> { + impl<'lua> $crate::mlu::mlua::IntoLua<'lua> for $type_name<'lua> { + fn into_lua(self, _: &'lua $crate::mlu::mlua::Lua) -> ::std::result::Result<$crate::mlu::mlua::Value<'lua>, $crate::mlu::mlua::Error> { Ok(self.into()) } } @@ -53,7 +53,7 @@ macro_rules! create_generic_mlua { UserData(x) => $type_name::UserData(x), Error(x) => $type_name::Error(x), #[cfg(feature = "mlua_luau")] - Vector(x,y,z) => $type_name::Vector(x,y,z) + Vector(vec) => $type_name::Vector(vec.x(),vec.y(),vec.z()) } } } @@ -73,7 +73,7 @@ macro_rules! create_generic_mlua { UserData(x) => $crate::mlu::mlua::Value::UserData(x), Error(x) => $crate::mlu::mlua::Value::Error(x), #[cfg(feature = "mlua_luau")] - Vector(x,y,z) => $crate::mlu::mlua::Value::Vector(x,y,z) + Vector(x,y,z) => $crate::mlu::mlua::Value::Vector($crate::mlu::mlua::Vector::new(x,y,z)) } } } @@ -98,7 +98,7 @@ macro_rules! create_generic_mlua { ($type_name::Thread(a), $crate::mlu::mlua::Value::Thread(b)) => a == b, ($type_name::UserData(a), $crate::mlu::mlua::Value::UserData(b)) => a == b, #[cfg(feature = "mlua_luau")] - ($type_name::Vector(x,y,z), $crate::mlu::mlua::Value::Vector(x2,y2,z2)) => x == x2 && y == y2 && z == z2, + ($type_name::Vector(x,y,z), $crate::mlu::mlua::Value::Vector(vec)) => *x == vec.x() && *y == vec.y() && *z == vec.z(), _ => false, } } diff --git a/src/mlu/picker_macro.rs b/src/mlu/picker_macro.rs index 6722bd5..ba9ad61 100644 --- a/src/mlu/picker_macro.rs +++ b/src/mlu/picker_macro.rs @@ -42,10 +42,10 @@ macro_rules! create_union_mlua { $visibility enum $type_name { $($sub_types($sub_types) ,)* } - impl<'lua> $crate::mlu::mlua::ToLua<'lua> for $type_name { - fn to_lua(self, lua: &'lua $crate::mlu::mlua::Lua) -> ::std::result::Result<$crate::mlu::mlua::Value<'lua>, $crate::mlu::mlua::Error> { + impl<'lua> $crate::mlu::mlua::IntoLua<'lua> for $type_name { + fn into_lua(self, lua: &'lua $crate::mlu::mlua::Lua) -> ::std::result::Result<$crate::mlu::mlua::Value<'lua>, $crate::mlu::mlua::Error> { match self { - $($type_name::$sub_types(x) => x.to_lua(lua),)* + $($type_name::$sub_types(x) => x.into_lua(lua),)* } } } diff --git a/src/mlu/teal_data_fields.rs b/src/mlu/teal_data_fields.rs index 8e6a3ed..0dd19ae 100644 --- a/src/mlu/teal_data_fields.rs +++ b/src/mlu/teal_data_fields.rs @@ -1,4 +1,4 @@ -use mlua::{AnyUserData, FromLua, Lua, MetaMethod, ToLua}; +use mlua::{AnyUserData, FromLua, IntoLua, Lua, MetaMethod}; use crate::ToTypename; @@ -17,30 +17,30 @@ pub trait TealDataFields<'lua, T: TealData> { /// the teal version of [UserDataFields](mlua::UserDataFields::add_field_method_get) fn add_field_method_get(&mut self, name: &S, method: M) where - S: AsRef<[u8]> + ?Sized, - R: ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: IntoLua<'lua> + ToTypename, M: 'static + MaybeSend + Fn(&'lua Lua, &T) -> mlua::Result; /// the teal version of [UserDataFields](mlua::UserDataFields::add_field_method_set) fn add_field_method_set(&mut self, name: &S, method: M) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: FromLua<'lua> + ToTypename, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> mlua::Result<()>; /// the teal version of [UserDataFields](mlua::UserDataFields::add_field_function_get) fn add_field_function_get(&mut self, name: &S, function: F) where - S: AsRef<[u8]> + ?Sized, - R: ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: IntoLua<'lua> + ToTypename, F: 'static + MaybeSend + Fn(&'lua Lua, AnyUserData<'lua>) -> mlua::Result; /// the teal version of [UserDataFields](mlua::UserDataFields::add_field_function_set) fn add_field_function_set(&mut self, name: &S, function: F) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: FromLua<'lua> + ToTypename, F: 'static + MaybeSend + FnMut(&'lua Lua, AnyUserData<'lua>, A) -> mlua::Result<()>; /// the teal version of [UserDataFields](mlua::UserDataFields::add_meta_field_with) fn add_meta_field_with(&mut self, meta: MetaMethod, f: F) where F: 'static + MaybeSend + Fn(&'lua Lua) -> mlua::Result, - R: ToLua<'lua> + ToTypename; + R: IntoLua<'lua> + ToTypename; } diff --git a/src/mlu/teal_data_methods.rs b/src/mlu/teal_data_methods.rs index a5f73bd..b5abb57 100644 --- a/src/mlu/teal_data_methods.rs +++ b/src/mlu/teal_data_methods.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use mlua::{FromLuaMulti, Lua, MetaMethod, Result, ToLua, ToLuaMulti}; +use mlua::{FromLuaMulti, IntoLua as ToLua, IntoLuaMulti as ToLuaMulti, Lua, MetaMethod, Result}; use crate::{TealMultiValue, ToTypename}; @@ -18,33 +18,33 @@ pub trait TealDataMethods<'lua, T: ToTypename> { ///Exposes a method to lua fn add_method(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> Result; ///Exposes a method to lua that has a mutable reference to Self fn add_method_mut(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> Result; #[cfg(feature = "mlua_async")] ///exposes an async method to lua - fn add_async_method(&mut self, name: &S, method: M) + fn add_async_method<'s, S: ?Sized + AsRef, A, R, M, MR>(&mut self, name: &S, method: M) where - T: Clone, - S: AsRef<[u8]>, + 'lua: 's, + T: 'static, + M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua> + TealMultiValue, - R: ToLuaMulti<'lua> + TealMultiValue, - M: 'static + MaybeSend + Fn(&'lua Lua, T, A) -> MR, - MR: 'lua + std::future::Future>; + MR: std::future::Future> + 's, + R: ToLuaMulti<'lua> + TealMultiValue; ///Exposes a function to lua (its a method that does not take Self) fn add_function(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> Result; @@ -52,7 +52,7 @@ pub trait TealDataMethods<'lua, T: ToTypename> { ///Exposes a mutable function to lua fn add_function_mut(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> Result; @@ -61,7 +61,7 @@ pub trait TealDataMethods<'lua, T: ToTypename> { ///exposes an async function to lua fn add_async_function(&mut self, name: &S, function: F) where - S: AsRef<[u8]>, + S: AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> FR, diff --git a/src/mlu/to_from_macro_doc.md b/src/mlu/to_from_macro_doc.md index eb4fd35..0dd1a57 100644 --- a/src/mlu/to_from_macro_doc.md +++ b/src/mlu/to_from_macro_doc.md @@ -5,7 +5,7 @@ The macro will also add documentation to the [TypeBody](crate::TypeBody) impleme # Structs -Structs implement the [FromLua](mlua::FromLua) and [ToLua](mlua::ToLua) directly. +Structs implement the [FromLua](mlua::FromLua) and [ToLua](mlua::IntoLua) directly. These trait implementations convert the struct directly to and from a table. This table contains every filed INCLUDING private fields. ## Attributes @@ -67,7 +67,7 @@ let code = " instance.field1.test_field = \"new_value\" return instance "; -let res: Example2 = lua.load(code).set_name("MluaToFromLuaStruct").unwrap().eval().unwrap(); +let res: Example2 = lua.load(code).set_name("MluaToFromLuaStruct").eval().unwrap(); assert_eq!(res.field1,"new_value"); ``` @@ -186,6 +186,6 @@ let code = " return ExampleCreator.NewDoubleInnerValueFrom(\"some_new_value\",2) "; -let res: Example = lua.load(code).set_name("MluaToFromLuaEnum").unwrap().eval().unwrap(); +let res: Example = lua.load(code).set_name("MluaToFromLuaEnum").eval().unwrap(); assert!(matches!{Example::DoubleInnerValue("some_new_value".to_string(),5),res}); ``` diff --git a/src/mlu/typed_function.rs b/src/mlu/typed_function.rs index 5e00606..8c3ea6d 100644 --- a/src/mlu/typed_function.rs +++ b/src/mlu/typed_function.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use mlua::{FromLua, FromLuaMulti, Function, Lua, ToLua, ToLuaMulti, Value}; +use mlua::{FromLua, FromLuaMulti, Function, IntoLua, IntoLuaMulti, Lua, Value}; use crate::{TealMultiValue, ToTypename}; @@ -30,13 +30,13 @@ where } } -impl<'lua, Params, Response> ToLua<'lua> for TypedFunction<'lua, Params, Response> +impl<'lua, Params, Response> IntoLua<'lua> for TypedFunction<'lua, Params, Response> where Params: TealMultiValue, Response: TealMultiValue, { #[allow(clippy::wrong_self_convention)] - fn to_lua(self, _: &'lua Lua) -> mlua::Result> { + fn into_lua(self, _: &'lua Lua) -> mlua::Result> { Ok(Value::Function(self.inner_function)) } } @@ -54,7 +54,7 @@ where } impl<'lua, Params, Response> TypedFunction<'lua, Params, Response> where - Params: ToLuaMulti<'lua> + TealMultiValue, + Params: IntoLuaMulti<'lua> + TealMultiValue, Response: FromLuaMulti<'lua> + TealMultiValue, { ///Same as [mlua::Function::call](mlua::Function#method.call). Calls the function with the given parameters. @@ -91,7 +91,7 @@ where impl<'lua, Params, Response> TypedFunction<'lua, Params, Response> where Params: FromLuaMulti<'lua> + TealMultiValue, - Response: ToLuaMulti<'lua> + TealMultiValue, + Response: IntoLuaMulti<'lua> + TealMultiValue, { ///make a typed function directly from a Rust one. pub fn from_rust< @@ -122,7 +122,7 @@ where } impl<'lua, Params, Response> TypedFunction<'lua, Params, Response> where - Params: ToLuaMulti<'lua> + TealMultiValue, + Params: IntoLuaMulti<'lua> + TealMultiValue, Response: TealMultiValue, { ///call a function without trying to convert it to a rust type. diff --git a/src/mlu/user_data_proxy.rs b/src/mlu/user_data_proxy.rs index 1ee12b9..441fc37 100644 --- a/src/mlu/user_data_proxy.rs +++ b/src/mlu/user_data_proxy.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use mlua::{AnyUserData, Error, Lua, ToLua, UserData}; +use mlua::{AnyUserData, Error, IntoLua, Lua, UserData}; use crate::{EnumGenerator, RecordGenerator, ToTypename, Type, TypeBody, TypeName}; @@ -83,8 +83,8 @@ impl TypeBody for UserDataProxy<'_, T } } -impl<'lua, T: StaticUserdata> ToLua<'lua> for UserDataProxy<'lua, T> { - fn to_lua(self, lua: &'lua Lua) -> mlua::Result> { - self.user_data.to_lua(lua) +impl<'lua, T: StaticUserdata> IntoLua<'lua> for UserDataProxy<'lua, T> { + fn into_lua(self, lua: &'lua Lua) -> mlua::Result> { + self.user_data.into_lua(lua) } } diff --git a/src/mlu/user_data_wrapper.rs b/src/mlu/user_data_wrapper.rs index 383de2a..050e50b 100644 --- a/src/mlu/user_data_wrapper.rs +++ b/src/mlu/user_data_wrapper.rs @@ -1,6 +1,7 @@ use bstr::ByteVec; use mlua::{ - FromLuaMulti, Lua, MetaMethod, Result, ToLuaMulti, UserData, UserDataFields, UserDataMethods, + FromLuaMulti, IntoLuaMulti as ToLuaMulti, Lua, MetaMethod, Result, UserData, UserDataFields, + UserDataMethods, }; use std::{collections::HashMap, marker::PhantomData}; @@ -100,7 +101,7 @@ where T: UserData, //Container: UserDataMethods<'lua, T>, { - fn copy_method_docs(&mut self, to: &[u8], self_type: bool) + fn copy_method_docs(&mut self, to: &str, self_type: bool) where A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, @@ -112,10 +113,10 @@ where .unwrap_or_default(); let docs = generated + "\n\ndocs:\n" + &self.next_docs.take().unwrap_or_default(); let documentation = &mut self.documentation; - documentation.insert(to.to_owned(), docs); + documentation.insert(to.as_bytes().to_owned(), docs); } - fn copy_field_docs(&mut self, name: &[u8]) { - let name = name.to_vec(); + fn copy_field_docs(&mut self, name: &str) { + let name = name.as_bytes().to_vec(); let documentation = &mut self.documentation; let mut current_doc = match documentation.remove(&name) { Some(x) => x, @@ -148,7 +149,7 @@ where #[inline(always)] fn add_method(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> Result, @@ -159,7 +160,7 @@ where #[inline(always)] fn add_method_mut(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> Result, @@ -170,7 +171,7 @@ where #[inline(always)] fn add_function(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> Result, @@ -181,7 +182,7 @@ where #[inline(always)] fn add_function_mut(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> Result, @@ -196,7 +197,7 @@ where R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> Result, { - self.copy_method_docs::(meta.name().as_bytes(), true); + self.copy_method_docs::(meta.name(), true); self.cont.add_meta_method(meta, method) } #[inline(always)] @@ -206,7 +207,7 @@ where R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> Result, { - self.copy_method_docs::(meta.name().as_bytes(), true); + self.copy_method_docs::(meta.name(), true); self.cont.add_meta_method_mut(meta, method) } #[inline(always)] @@ -216,7 +217,7 @@ where R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> Result, { - self.copy_method_docs::(meta.name().as_bytes(), false); + self.copy_method_docs::(meta.name(), false); self.cont.add_meta_function(meta, function) } #[inline(always)] @@ -226,20 +227,20 @@ where R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> Result, { - self.copy_method_docs::(meta.name().as_bytes(), false); + self.copy_method_docs::(meta.name(), false); self.cont.add_meta_function_mut(meta, function) } #[cfg(feature = "mlua_async")] #[inline(always)] - fn add_async_method(&mut self, name: &S, method: M) + fn add_async_method<'s, S: ?Sized + AsRef, A, R, M, MR>(&mut self, name: &S, method: M) where - T: Clone, - S: AsRef<[u8]>, + 'lua: 's, + T: 'static, + M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua> + TealMultiValue, + MR: std::future::Future> + 's, R: ToLuaMulti<'lua> + TealMultiValue, - M: 'static + MaybeSend + Fn(&'lua Lua, T, A) -> MR, - MR: 'lua + std::future::Future>, { self.copy_method_docs::(name.as_ref(), true); self.cont.add_async_method(name, method) @@ -249,7 +250,7 @@ where #[inline(always)] fn add_async_function(&mut self, name: &S, function: F) where - S: AsRef<[u8]>, + S: AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> FR, @@ -291,7 +292,7 @@ where } }; - lua.create_string(&doc) + lua.create_string(doc) }) } @@ -310,8 +311,8 @@ where { fn add_field_method_get(&mut self, name: &S, method: M) where - S: AsRef<[u8]> + ?Sized, - R: mlua::ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: mlua::IntoLua<'lua> + ToTypename, M: 'static + MaybeSend + Fn(&'lua Lua, &T) -> mlua::Result, { self.copy_field_docs::(name.as_ref()); @@ -320,7 +321,7 @@ where fn add_field_method_set(&mut self, name: &S, method: M) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: mlua::FromLua<'lua> + ToTypename, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> mlua::Result<()>, { @@ -330,8 +331,8 @@ where fn add_field_function_get(&mut self, name: &S, function: F) where - S: AsRef<[u8]> + ?Sized, - R: mlua::ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: mlua::IntoLua<'lua> + ToTypename, F: 'static + MaybeSend + Fn(&'lua Lua, mlua::AnyUserData<'lua>) -> mlua::Result, { self.copy_field_docs::(name.as_ref()); @@ -340,7 +341,7 @@ where fn add_field_function_set(&mut self, name: &S, function: F) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: mlua::FromLua<'lua> + ToTypename, F: 'static + MaybeSend + FnMut(&'lua Lua, mlua::AnyUserData<'lua>, A) -> mlua::Result<()>, { @@ -351,9 +352,9 @@ where fn add_meta_field_with(&mut self, meta: MetaMethod, f: F) where F: 'static + MaybeSend + Fn(&'lua Lua) -> mlua::Result, - R: mlua::ToLua<'lua> + ToTypename, + R: mlua::IntoLua<'lua> + ToTypename, { - self.copy_field_docs::(meta.name().as_bytes()); + self.copy_field_docs::(meta.name()); self.cont.add_meta_field_with(meta, f) } diff --git a/src/rlu/teal_data_methods.rs b/src/rlu/teal_data_methods.rs index 8d2dfa2..8b81009 100644 --- a/src/rlu/teal_data_methods.rs +++ b/src/rlu/teal_data_methods.rs @@ -15,14 +15,14 @@ pub trait TealDataMethods<'lua, T> { ///Exposes a method to lua fn add_method(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + Send + Fn(Context<'lua>, &T, A) -> Result; ///Exposes a method to lua that has a mutable reference to Self fn add_method_mut(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + Send + FnMut(Context<'lua>, &mut T, A) -> Result; @@ -30,7 +30,7 @@ pub trait TealDataMethods<'lua, T> { ///Exposes a function to lua (its a method that does not take Self) fn add_function(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + Send + Fn(Context<'lua>, A) -> Result; @@ -38,7 +38,7 @@ pub trait TealDataMethods<'lua, T> { ///Exposes a mutable function to lua fn add_function_mut(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, F: 'static + Send + FnMut(Context<'lua>, A) -> Result; diff --git a/src/rlu/user_data_wrapper.rs b/src/rlu/user_data_wrapper.rs index a26aa34..ed6ddf5 100644 --- a/src/rlu/user_data_wrapper.rs +++ b/src/rlu/user_data_wrapper.rs @@ -73,46 +73,47 @@ where #[inline(always)] fn add_method(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua> + TealMultiValue, R: ToLuaMulti<'lua> + TealMultiValue, M: 'static + Send + Fn(Context<'lua>, &T, A) -> Result, { - self.copy_docs(name.as_ref()); - self.cont.add_method(name, method) + self.copy_docs(name.as_ref().as_bytes()); + self.cont.add_method(name.as_ref().as_bytes(), method) } #[inline(always)] fn add_method_mut(&mut self, name: &S, method: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua>, R: ToLuaMulti<'lua>, M: 'static + Send + FnMut(Context<'lua>, &mut T, A) -> Result, { - self.copy_docs(name.as_ref()); - self.cont.add_method_mut(name, method) + self.copy_docs(name.as_ref().as_bytes()); + self.cont.add_method_mut(name.as_ref().as_bytes(), method) } #[inline(always)] fn add_function(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua>, R: ToLuaMulti<'lua>, F: 'static + Send + Fn(Context<'lua>, A) -> Result, { - self.copy_docs(name.as_ref()); - self.cont.add_function(name, function) + self.copy_docs(name.as_ref().as_bytes()); + self.cont.add_function(name.as_ref().as_bytes(), function) } #[inline(always)] fn add_function_mut(&mut self, name: &S, function: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMulti<'lua>, R: ToLuaMulti<'lua>, F: 'static + Send + FnMut(Context<'lua>, A) -> Result, { - self.copy_docs(name.as_ref()); - self.cont.add_function_mut(name, function) + self.copy_docs(name.as_ref().as_bytes()); + self.cont + .add_function_mut(name.as_ref().as_bytes(), function) } #[inline(always)] fn add_meta_method(&mut self, meta: MetaMethod, method: M) diff --git a/src/type_generator.rs b/src/type_generator.rs index 0817d5d..e9d2470 100644 --- a/src/type_generator.rs +++ b/src/type_generator.rs @@ -23,8 +23,9 @@ use crate::mlu::{ }; #[cfg(feature = "mlua")] use mlua::{ - FromLua as FromLuaM, FromLuaMulti as FromLuaMultiM, Lua, MetaMethod as MetaMethodM, - Result as ResultM, ToLua as ToLuaM, ToLuaMulti as ToLuaMultiM, UserData as UserDataM, + FromLua as FromLuaM, FromLuaMulti as FromLuaMultiM, IntoLua as ToLuaM, + IntoLuaMulti as ToLuaMultiM, Lua, MetaMethod as MetaMethodM, Result as ResultM, + UserData as UserDataM, }; use crate::{ @@ -72,8 +73,8 @@ impl<'lua> FromLuaM<'lua> for NameContainer { } #[cfg(feature = "mlua")] impl<'lua> ToLuaM<'lua> for NameContainer { - fn to_lua(self, lua: &'lua Lua) -> ResultM> { - lua.create_string(&self.0).and_then(|x| x.to_lua(lua)) + fn into_lua(self, lua: &'lua Lua) -> ResultM> { + lua.create_string(&self.0).and_then(|x| x.into_lua(lua)) } } @@ -108,7 +109,7 @@ impl From> for NameContainer { } #[cfg(any(feature = "rlua", feature = "mlua"))] -pub(crate) fn get_method_data>( +pub(crate) fn get_method_data>( name: &S, is_meta_method: bool, extra_self: Option, @@ -560,12 +561,12 @@ where { fn add_method(&mut self, name: &S, _: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + Fn(Context<'lua>, &T, A) -> ResultR, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.methods.push(get_method_data::( name, false, @@ -575,12 +576,12 @@ where fn add_method_mut(&mut self, name: &S, _: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + FnMut(Context<'lua>, &mut T, A) -> ResultR, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.mut_methods.push(get_method_data::( name, false, @@ -590,24 +591,24 @@ where fn add_function(&mut self, name: &S, _: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + Fn(Context<'lua>, A) -> ResultR, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.functions .push(get_method_data::(name, false, None)) } fn add_function_mut(&mut self, name: &S, _: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + FnMut(Context<'lua>, A) -> ResultR, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.mut_functions .push(get_method_data::(name, false, None)) } @@ -690,12 +691,12 @@ where { fn add_method(&mut self, name: &S, _: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> ResultM, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.methods.push(get_method_data::( name, false, @@ -705,12 +706,12 @@ where fn add_method_mut(&mut self, name: &S, _: M) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> ResultM, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.mut_methods.push(get_method_data::( name, false, @@ -720,24 +721,24 @@ where fn add_function(&mut self, name: &S, _: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> ResultM, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.functions .push(get_method_data::(name, false, None)) } fn add_function_mut(&mut self, name: &S, _: F) where - S: ?Sized + AsRef<[u8]>, + S: ?Sized + AsRef, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> ResultM, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.mut_functions .push(get_method_data::(name, false, None)) } @@ -750,7 +751,7 @@ where { self.copy_docs(name.name().as_bytes()); self.meta_method.push(get_method_data::( - &get_meta_name_mlua(name).as_bytes(), + &get_meta_name_mlua(name), true, Some(T::to_typename()), )) @@ -764,7 +765,7 @@ where { self.copy_docs(name.name().as_bytes()); self.meta_method_mut.push(get_method_data::( - &get_meta_name_mlua(name).as_bytes(), + &get_meta_name_mlua(name), true, Some(T::to_typename()), )) @@ -778,7 +779,7 @@ where { self.copy_docs(name.name().as_bytes()); self.meta_function.push(get_method_data::( - get_meta_name_mlua(name).as_bytes(), + get_meta_name_mlua(name).as_ref(), true, None, )) @@ -792,22 +793,22 @@ where { self.copy_docs(name.name().as_bytes()); self.meta_function_mut.push(get_method_data::( - &get_meta_name_mlua(name).as_bytes(), + &get_meta_name_mlua(name), true, None, )) } #[cfg(feature = "mlua_async")] - fn add_async_method(&mut self, name: &S, _: M) + fn add_async_method<'s, S: ?Sized + AsRef, A, R, M, MR>(&mut self, name: &S, _: M) where - T: Clone, - S: AsRef<[u8]>, + 'lua: 's, + T: 'static, + M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMultiM<'lua> + TealMultiValue, + MR: std::future::Future> + 's, R: ToLuaMultiM<'lua> + TealMultiValue, - M: 'static + MaybeSend + Fn(&'lua Lua, T, A) -> MR, - MR: 'lua + std::future::Future>, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.methods.push(get_method_data::( name, false, @@ -818,13 +819,13 @@ where #[cfg(feature = "mlua_async")] fn add_async_function(&mut self, name: &S, _: F) where - S: AsRef<[u8]>, + S: AsRef, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> FR, FR: 'lua + std::future::Future>, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.functions .push(get_method_data::(name, false, None)) } @@ -850,52 +851,52 @@ where { fn add_field_method_get(&mut self, name: &S, _: M) where - S: AsRef<[u8]> + ?Sized, - R: mlua::ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: mlua::IntoLua<'lua> + ToTypename, M: 'static + MaybeSend + Fn(&'lua Lua, &T) -> mlua::Result, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.fields - .push((name.as_ref().to_vec().into(), R::to_typename()).into()); + .push((name.as_ref().as_bytes().to_vec().into(), R::to_typename()).into()); } fn add_field_method_set(&mut self, name: &S, _: M) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: mlua::FromLua<'lua> + ToTypename, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> mlua::Result<()>, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.fields - .push((name.as_ref().to_vec().into(), A::to_typename()).into()); + .push((name.as_ref().as_bytes().to_vec().into(), A::to_typename()).into()); } fn add_field_function_get(&mut self, name: &S, _: F) where - S: AsRef<[u8]> + ?Sized, - R: mlua::ToLua<'lua> + ToTypename, + S: AsRef + ?Sized, + R: mlua::IntoLua<'lua> + ToTypename, F: 'static + MaybeSend + Fn(&'lua Lua, mlua::AnyUserData<'lua>) -> mlua::Result, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.static_fields - .push((name.as_ref().to_vec().into(), R::to_typename()).into()); + .push((name.as_ref().as_bytes().to_vec().into(), R::to_typename()).into()); } fn add_field_function_set(&mut self, name: &S, _: F) where - S: AsRef<[u8]> + ?Sized, + S: AsRef + ?Sized, A: mlua::FromLua<'lua> + ToTypename, F: 'static + MaybeSend + FnMut(&'lua Lua, mlua::AnyUserData<'lua>, A) -> mlua::Result<()>, { - self.copy_docs(name.as_ref()); + self.copy_docs(name.as_ref().as_bytes()); self.static_fields - .push((name.as_ref().to_vec().into(), A::to_typename()).into()); + .push((name.as_ref().as_bytes().to_vec().into(), A::to_typename()).into()); } fn add_meta_field_with(&mut self, meta: MetaMethodM, _: F) where F: 'static + MaybeSend + Fn(&'lua Lua) -> mlua::Result, - R: mlua::ToLua<'lua> + ToTypename, + R: mlua::IntoLua<'lua> + ToTypename, { let x = Into::::into(meta); let name: Cow<'_, str> = Cow::Owned(x.name().to_string()); diff --git a/tealr_derive/src/from_to_lua.rs b/tealr_derive/src/from_to_lua.rs index b6f3dbf..5a316fc 100644 --- a/tealr_derive/src/from_to_lua.rs +++ b/tealr_derive/src/from_to_lua.rs @@ -37,7 +37,7 @@ fn find_tag_with_value(to_find: &str, tags: &[venial::Attribute]) -> Option None, venial::AttributeValue::Group(_, y) => { - if y.get(0).map(|v| v.to_string() == to_find).unwrap_or(false) { + if y.first().map(|v| v.to_string() == to_find).unwrap_or(false) { y.get(2).map(|v| v.clone().into_token_stream()) } else { None @@ -84,6 +84,7 @@ struct BasicConfig { result_location_from: TokenStream, lua_type: TokenStream, lua_value: TokenStream, + to_lua_name: TokenStream, error_message: TokenStream, type_name_path: TokenStream, type_body_loc: TokenStream, @@ -117,6 +118,7 @@ fn implement_for_struct(structure: Struct, config: BasicConfig) -> TokenStream { let type_generator_loc = config.type_generator_loc; let record_generator_loc = config.record_generator_loc; let name = &structure.name; + let to_lua_name = config.to_lua_name; let (to_add, (to_remove, type_body)): (TokenStream, (TokenStream, TokenStream)) = match structure.fields { @@ -212,7 +214,7 @@ fn implement_for_struct(structure: Struct, config: BasicConfig) -> TokenStream { .collect::(); quote! { impl<'lua> #to_loc for #name { - fn to_lua(self, #lua_location) -> #result_location_to { + fn #to_lua_name(self, #lua_location) -> #result_location_to { let mut table = #create_table()?; #to_add lua.pack(table) @@ -326,7 +328,7 @@ fn implement_for_enum(enumeration: venial::Enum, config: BasicConfig) -> TokenSt ( proc_macro2::Ident::new( &z, - x.ty.tokens.get(0).map(|v|v.span()) + x.ty.tokens.first().map(|v|v.span()) .unwrap_or_else(Span::call_site)), x, ) @@ -495,11 +497,33 @@ fn implement_for_enum(enumeration: venial::Enum, config: BasicConfig) -> TokenSt } } }; + trait_impls.extend(Some(creator_struct_stream)); trait_impls.extend(Some(with_userdata)); trait_impls.extend(Some(with_clone)); trait_impls.extend(Some(with_teal_data)); trait_impls.extend(Some(with_new_method)); + if config.is_mlua { + let from_loc = config.from_location; + let lua_value = config.lua_value; + let lua_location = config.lua_type; + let error_message = config.error_message; + let result_location_from = config.result_location_from; + let with_from_lua = quote! { + impl<'lua> #from_loc for #name { + fn from_lua(lua_value:#lua_value<'lua>, #lua_location) -> #result_location_from { + match lua_value.as_userdata() { + Some(x) => x.take(), + None => { + let x = lua_value; + Err(#error_message) + } + } + } + } + }; + trait_impls.extend(with_from_lua); + } trait_impls } @@ -515,7 +539,7 @@ fn implement_for_c_enum(enumeration: venial::Enum, config: BasicConfig) -> Token let lua_value = config.lua_value; let enum_generator_loc = config.enum_generator_loc; let invalid_enum_variant_error = config.invalid_enum_variant_error; - + let to_lua_name = config.to_lua_name; let document_type = find_doc_tags(&enumeration.attributes) .map(|v| quote! {gen.document_type(#v);}) .collect::(); @@ -544,7 +568,7 @@ fn implement_for_c_enum(enumeration: venial::Enum, config: BasicConfig) -> Token quote! { impl<'lua> #to_loc for #name { - fn to_lua(self, #lua_location) -> #result_location_to { + fn #to_lua_name(self, #lua_location) -> #result_location_to { let res = match self { #to_branches }; @@ -575,7 +599,8 @@ pub(crate) fn mlua_from_to_lua(input: TokenStream) -> TokenStream { let parsed = parse_declaration(input).unwrap(); let tealr_name = get_tealr_name(parsed.attributes()); let config = BasicConfig { - to_location: quote! {#tealr_name::mlu::mlua::ToLua<'lua>}, + to_location: quote! {#tealr_name::mlu::mlua::IntoLua<'lua>}, + to_lua_name: quote!(into_lua), from_location: quote! {#tealr_name::mlu::mlua::FromLua<'lua>}, create_table: quote! {lua.create_table}, result_location_to: quote! {#tealr_name::mlu::mlua::Result<#tealr_name::mlu::mlua::Value<'lua>>}, @@ -623,6 +648,7 @@ pub(crate) fn rlua_from_to_lua(input: TokenStream) -> TokenStream { let tealr_name = get_tealr_name(parsed.attributes()); let config = BasicConfig { to_location: quote! {#tealr_name::rlu::rlua::ToLua<'lua>}, + to_lua_name: quote!(to_lua), from_location: quote! {#tealr_name::rlu::rlua::FromLua<'lua>}, create_table: quote! {lua.create_table}, result_location_to: quote! {#tealr_name::rlu::rlua::Result<#tealr_name::rlu::rlua::Value<'lua>>}, diff --git a/tests/mlua/async.rs b/tests/mlua/async.rs index ef73cd0..30e4245 100644 --- a/tests/mlua/async.rs +++ b/tests/mlua/async.rs @@ -1,6 +1,8 @@ -use mlua::{Lua, Result}; use tealr::{ - mlu::{TealData, TealDataMethods, UserData}, + mlu::{ + mlua::{FromLua, Lua, Result}, + TealData, TealDataMethods, UserData, + }, ToTypename, TypeWalker, }; //this example shows how the new traits allow you to generate the .d.tl file @@ -16,6 +18,19 @@ use tealr::{ #[derive(Clone, UserData, ToTypename)] struct Example {} +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} + //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { //implement your methods/functions @@ -62,7 +77,7 @@ fn async_fn() -> Result<()> { let code = " test:example_method(2) "; - let x: i8 = lua.load(code).set_name("test?")?.eval()?; + let x: i8 = lua.load(code).set_name("test?").eval()?; assert_eq!(x, 2); Ok(()) diff --git a/tests/mlua/embed_teal.rs b/tests/mlua/embed_teal.rs index 5dd5b86..3e6c89c 100644 --- a/tests/mlua/embed_teal.rs +++ b/tests/mlua/embed_teal.rs @@ -6,7 +6,7 @@ fn legacy_syntax() -> mlua::Result<()> { let code = compiler("tests/mlua/test_embedded_compiler"); let res: u8 = mlua::Lua::new() .load(&code) - .set_name("embedded_compiler_legacy")? + .set_name("embedded_compiler_legacy") .eval()?; assert_eq!(res, 5); Ok(()) @@ -17,7 +17,7 @@ fn new_syntax_github() -> mlua::Result<()> { let code = compiler("tests/mlua/test_embedded_compiler"); let res: u8 = mlua::Lua::new() .load(&code) - .set_name("embedded_compiler_legacy")? + .set_name("embedded_compiler_legacy") .eval()?; assert_eq!(res, 5); Ok(()) @@ -29,7 +29,7 @@ fn new_version_luarocks() -> mlua::Result<()> { let code = compiler("tests/mlua/test_embedded_compiler"); let res: u8 = mlua::Lua::new() .load(&code) - .set_name("embedded_compiler_legacy")? + .set_name("embedded_compiler_legacy") .eval()?; assert_eq!(res, 5); Ok(()) @@ -41,7 +41,7 @@ fn new_syntax_from_local_discover() -> mlua::Result<()> { let code = compiler("tests/mlua/test_embedded_compiler"); let res: u8 = mlua::Lua::new() .load(&code) - .set_name("embedded_compiler_legacy")? + .set_name("embedded_compiler_legacy") .eval()?; assert_eq!(res, 5); Ok(()) diff --git a/tests/mlua/export_instances.rs b/tests/mlua/export_instances.rs index 899165d..2e48a7b 100644 --- a/tests/mlua/export_instances.rs +++ b/tests/mlua/export_instances.rs @@ -1,4 +1,4 @@ -use mlua::ToLua; +use mlua::IntoLua; use tealr::{ create_union_mlua, mlu::{mlua::FromLua, TealData, TealDataMethods, TypedFunction, UserData}, @@ -15,7 +15,7 @@ impl TealData for Example { //implement your methods/functions fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { methods.add_method("limited_callback", |lua, _, fun: TypedFunction| { - let param = X::from_lua("nice!".to_lua(lua)?, lua)?; + let param = X::from_lua("nice!".into_lua(lua)?, lua)?; let res = fun.call(param)?; Ok(res) }); diff --git a/tests/mlua/generics.rs b/tests/mlua/generics.rs index 0d7ded4..2b18733 100644 --- a/tests/mlua/generics.rs +++ b/tests/mlua/generics.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use mlua::ToLua; use tealr::{ create_generic_mlua, mlu::{mlua::FromLua, TealData, TealDataMethods, TypedFunction, UserData}, @@ -18,7 +17,8 @@ impl TealData for Example { methods.add_method( "generic_function_callback", |lua, _, fun: TypedFunction| { - let param = X::from_lua("nice!".to_lua(lua)?, lua)?; + use mlua::IntoLua; + let param = X::from_lua("nice!".into_lua(lua)?, lua)?; let res = fun.call(param)?; Ok(res) }, diff --git a/tests/mlua/inlined_type.rs b/tests/mlua/inlined_type.rs index 40014c8..5711f04 100644 --- a/tests/mlua/inlined_type.rs +++ b/tests/mlua/inlined_type.rs @@ -1,5 +1,8 @@ use tealr::{ - mlu::{TealData, TealDataMethods, UserData}, + mlu::{ + mlua::{FromLua, Lua}, + TealData, TealDataMethods, UserData, + }, ToTypename, TypeWalker, }; //this example shows how the new traits allow you to generate the .d.tl file @@ -14,6 +17,21 @@ use tealr::{ //The clone is only needed because one of the example functions has it as a parameter #[derive(Clone, UserData, ToTypename)] struct Example {} +impl<'lua> FromLua<'lua> for Example { + fn from_lua( + value: mlua::prelude::LuaValue<'lua>, + _: &'lua Lua, + ) -> tealr::mlu::mlua::Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} //now, implement TealData. This tells rlua what methods are available and tealr what the types are impl TealData for Example { diff --git a/tests/mlua/named_parameters.rs b/tests/mlua/named_parameters.rs index b68a2ed..b8b0438 100644 --- a/tests/mlua/named_parameters.rs +++ b/tests/mlua/named_parameters.rs @@ -1,12 +1,24 @@ use tealr::{ mlu::{ - mlua::{Lua, Result}, + mlua::{FromLua, Lua, Result}, TealData, TealDataMethods, UserData, }, ToTypename, TypeWalker, }; #[derive(Clone, UserData, ToTypename)] struct Example {} +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} impl TealData for Example { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { @@ -45,7 +57,7 @@ fn main() -> Result<()> { let globals = lua.globals(); globals.set("test", Example {})?; let code = "return test:example_method(\"field_1 is a string\", 3)"; - let (field1, field2): (String, i64) = lua.load(code).set_name("test?")?.eval()?; + let (field1, field2): (String, i64) = lua.load(code).set_name("test?").eval()?; assert_eq!(field1, "field_1 is a string"); assert_eq!(field2, 3); Ok(()) diff --git a/tests/mlua/readme_pieces.rs b/tests/mlua/readme_pieces.rs index 8a3845d..cd672c2 100644 --- a/tests/mlua/readme_pieces.rs +++ b/tests/mlua/readme_pieces.rs @@ -1,6 +1,9 @@ use tealr::{ compile_inline_teal, create_generic_mlua, create_union_mlua, embed_compiler, - mlu::{TealData, TealDataMethods, TypedFunction, UserData}, + mlu::{ + mlua::{FromLua, Lua, Result}, + TealData, TealDataMethods, TypedFunction, UserData, + }, ToTypename, TypeWalker, }; @@ -10,6 +13,19 @@ fn test() { } #[derive(Clone, UserData, ToTypename)] struct ExampleMlua {} +impl<'lua> FromLua<'lua> for ExampleMlua { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} + impl tealr::mlu::TealData for ExampleMlua { //implement your methods/functions fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { @@ -36,7 +52,18 @@ create_generic_mlua!(X); struct Example { example: u32, } - +impl<'lua> FromLua<'lua> for Example { + fn from_lua(value: mlua::prelude::LuaValue<'lua>, _: &'lua Lua) -> Result { + value + .as_userdata() + .map(|x| x.take()) + .unwrap_or(Err(mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: "Example", + message: None, + })) + } +} impl TealData for Example { fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { methods.add_method( @@ -53,7 +80,7 @@ impl TealData for Example { } } -fn pieces() -> Result<(), mlua::Error> { +fn pieces() -> Result<()> { //the functionality of these pieces of code are already being tested at other places //This is just to make sure the examples in the readme keep working if false { @@ -70,7 +97,7 @@ fn pieces() -> Result<(), mlua::Error> { let code = compiler("example/basic_teal_file"); let lua = tealr::mlu::mlua::Lua::new(); - let _res: u8 = lua.load(&code).set_name("embedded_compiler")?.eval()?; + let _res: u8 = lua.load(&code).set_name("embedded_compiler").eval()?; let add_1 = TypedFunction::::from_rust(|_lua, x| Ok(x + 1), &lua)?; assert_eq!(add_1.call(2)?, 3); } diff --git a/tests/mlua/to_from_derived.rs b/tests/mlua/to_from_derived.rs index f9076f5..6d1e998 100644 --- a/tests/mlua/to_from_derived.rs +++ b/tests/mlua/to_from_derived.rs @@ -99,7 +99,7 @@ fn main() -> Result<(), Box> { test.field1 = creator.NewLessSo() return test "; - let res: Example = lua.load(code).set_name("test?")?.eval()?; + let res: Example = lua.load(code).set_name("test?").eval()?; to_pass.field1 = String::from(Test2::LessSo); assert_eq!(res, to_pass); diff --git a/tests/mlua/type_picker.rs b/tests/mlua/type_picker.rs index 87dfcb3..5a13d47 100644 --- a/tests/mlua/type_picker.rs +++ b/tests/mlua/type_picker.rs @@ -1,4 +1,4 @@ -use mlua::{Lua, ToLua}; +use mlua::{IntoLua, Lua}; use tealr::{ create_union_mlua, mlu::{mlua::FromLua, TealData, TealDataMethods, TypedFunction, UserData}, @@ -15,7 +15,7 @@ impl TealData for Example { //implement your methods/functions fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { methods.add_method("limited_callback", |lua, _, fun: TypedFunction| { - let param = X::from_lua("nice!".to_lua(lua)?, lua)?; + let param = X::from_lua("nice!".into_lua(lua)?, lua)?; let res = fun.call(param)?; Ok(res) }); @@ -49,11 +49,6 @@ fn test_limited() { let code = " return test:limited_simple(true) "; - let x: bool = lua - .load(code) - .set_name("test_limited_lua") - .unwrap() - .eval() - .unwrap(); + let x: bool = lua.load(code).set_name("test_limited_lua").eval().unwrap(); assert!(x); }