From e938496f002d16ed1b4651c271b0e98edff7b828 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 13 Dec 2020 13:57:50 +0000 Subject: [PATCH] Migrate to Rocket 0.5. Rocket 0.5 is a major uprade, rewriting most of Rocket to be async. Required many changes through the code, especially the database layer. The new Rocket async database calls require Futures with 'static lifetimes. General: - Move to stable rust. - Most of codebase is now async. - Rocket migrations (e.g. Cookies to CookieJar). Database: - Switched to owned data (&str -> String) for inserts because of the 'static lifetime requirement on Rocket's DB future. - All database methods now asynchronous. Pages: - Changed various routes to async. - Needed to add clone calls to some places because we need to use owned data multiple times (registration). --- Cargo.lock | 1348 ++++++++++++++++++++++++---------- Cargo.toml | 10 +- Rocket.toml | 2 +- rust-toolchain | 2 +- src/db.rs | 98 +-- src/errors.rs | 28 +- src/main.rs | 8 +- src/models/characters.rs | 6 +- src/models/users.rs | 41 +- src/routes/auth.rs | 40 +- src/routes/characters.rs | 17 +- src/routes/characters/new.rs | 15 +- src/routes/root.rs | 5 +- 13 files changed, 1086 insertions(+), 534 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 233b9de..aab15a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,73 +1,57 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - [[package]] name = "aead" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array", + "generic-array 0.14.4", ] [[package]] name = "aes" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +checksum = "dd2bc6d3f370b5666245ff421e231cba4353df936e26986d2918e61a8fd6aef6" dependencies = [ "aes-soft", "aesni", - "block-cipher-trait", + "block-cipher", ] [[package]] name = "aes-gcm" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "834a6bda386024dbb7c8fc51322856c10ffe69559f972261c868485f5759c638" +checksum = "0301c9e9c443494d970a07885e8cf3e587bae8356a1d5abd0999068413f7205f" dependencies = [ "aead", "aes", - "block-cipher-trait", + "block-cipher", "ghash", - "subtle 2.3.0", - "zeroize", + "subtle", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +checksum = "63dd91889c49327ad7ef3b500fd1109dbd3c509a03db0d4a9ce413b79f575cb6" dependencies = [ - "block-cipher-trait", + "block-cipher", "byteorder", - "opaque-debug", + "opaque-debug 0.3.0", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +checksum = "0a6fe808308bb07d393e2ea47780043ec47683fcf19cf5efc8ca51c50cc8c68a" dependencies = [ - "block-cipher-trait", - "opaque-debug", + "block-cipher", + "opaque-debug 0.3.0", ] [[package]] @@ -97,6 +81,26 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-trait" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" +dependencies = [ + "autocfg", +] + [[package]] name = "atty" version = "0.2.14" @@ -115,34 +119,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] -name = "backtrace" -version = "0.3.55" +name = "base-x" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" -dependencies = [ - "addr2line", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" [[package]] name = "base64" @@ -150,6 +130,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + [[package]] name = "bitflags" version = "1.2.1" @@ -176,16 +162,25 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array", + "generic-array 0.12.3", ] [[package]] -name = "block-cipher-trait" -version = "0.6.2" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.4", +] + +[[package]] +name = "block-cipher" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f337a3e6da609650eb74e02bc9fac7b735049f7623ab12f2e4c719316fcc7e80" +dependencies = [ + "generic-array 0.14.4", ] [[package]] @@ -197,6 +192,21 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "bstr" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +dependencies = [ + "memchr", +] + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + [[package]] name = "byte-tools" version = "0.3.1" @@ -236,10 +246,20 @@ dependencies = [ "libc", "num-integer", "num-traits", - "time", + "time 0.1.44", "winapi 0.3.9", ] +[[package]] +name = "chrono-tz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" +dependencies = [ + "chrono", + "parse-zoneinfo", +] + [[package]] name = "cloudabi" version = "0.1.0" @@ -249,6 +269,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "const_fn" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -257,20 +283,32 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cookie" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5795cda0897252e34380a27baf884c53aa7ad9990329cdad96d4c5d027015d44" +version = "0.15.0-dev" +source = "git+https://github.com/SergioBenitez/cookie-rs.git?rev=1c3ca83#1c3ca838543b60a4448d279dc4b903cc7a2bc22a" dependencies = [ "aes-gcm", - "base64 0.12.3", + "base64", "hkdf", - "hmac", - "percent-encoding 2.1.0", + "percent-encoding", "rand", "sha2", - "time", + "subtle", + "time 0.2.23", + "version_check", ] +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "cpuid-bool" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" + [[package]] name = "crossbeam-utils" version = "0.8.1" @@ -284,12 +322,12 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array", - "subtle 1.0.0", + "generic-array 0.14.4", + "subtle", ] [[package]] @@ -300,9 +338,8 @@ checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" [[package]] name = "devise" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e04ba2d03c5fa0d954c061fc8c9c288badadffc272ebb87679a89846de3ed3" +version = "0.3.0" +source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047" dependencies = [ "devise_codegen", "devise_core", @@ -310,24 +347,23 @@ dependencies = [ [[package]] name = "devise_codegen" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "066ceb7928ca93a9bedc6d0e612a8a0424048b0ab1f75971b203d01420c055d7" +version = "0.3.0" +source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047" dependencies = [ "devise_core", - "quote 0.6.13", + "quote", ] [[package]] name = "devise_core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf41c59b22b5e3ec0ea55c7847e5f358d340f3a8d6d53a5cf4f1564967f96487" +version = "0.3.0" +source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047" dependencies = [ "bitflags", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", ] [[package]] @@ -349,9 +385,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "703e71c268ea2d8da9c0ab0b40d8b217179ee622209c170875d24443193a0dfb" dependencies = [ "heck", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -360,9 +396,9 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -371,9 +407,24 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array", + "generic-array 0.12.3", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + [[package]] name = "either" version = "1.6.1" @@ -389,22 +440,25 @@ dependencies = [ "serde", ] -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "backtrace", - "version_check 0.9.2", -] - [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "figment" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b13e2d266426f89e45fc544117ade84fad2a58ff676f34cc34e123fe4391b856" +dependencies = [ + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + [[package]] name = "filetime" version = "0.2.13" @@ -423,6 +477,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fsevent" version = "0.4.0" @@ -458,6 +518,101 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" + +[[package]] +name = "futures-executor" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" + +[[package]] +name = "futures-macro" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" + +[[package]] +name = "futures-task" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project 1.0.2", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + [[package]] name = "generic-array" version = "0.12.3" @@ -467,6 +622,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.1.15" @@ -480,31 +645,63 @@ dependencies = [ [[package]] name = "ghash" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f0930ed19a7184089ea46d2fedead2f6dc2b674c5db4276b7da336c7cd83252" +checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531" dependencies = [ "polyval", ] -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - -[[package]] -name = "glob" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" - [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "globset" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "globwalk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "h2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", + "tracing-futures", +] + [[package]] name = "hashbrown" version = "0.9.1" @@ -531,22 +728,43 @@ dependencies = [ [[package]] name = "hkdf" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" +checksum = "fe1149865383e4526a43aee8495f9a325f0b806c63ce6427d06336a590abbbc9" dependencies = [ - "digest", + "digest 0.9.0", "hmac", ] [[package]] name = "hmac" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ "crypto-mac", - "digest", + "digest 0.9.0", +] + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", ] [[package]] @@ -555,6 +773,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + [[package]] name = "humansize" version = "1.1.0" @@ -563,32 +787,44 @@ checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" [[package]] name = "hyper" -version = "0.10.16" +version = "0.13.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" +checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" dependencies = [ - "base64 0.9.3", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", "httparse", - "language-tags", - "log 0.3.9", - "mime", - "num_cpus", - "time", - "traitobject", - "typeable", - "unicase", - "url", + "httpdate", + "itoa", + "pin-project 1.0.2", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", ] [[package]] -name = "idna" -version = "0.1.5" +name = "ignore" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "crossbeam-utils", + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", ] [[package]] @@ -601,6 +837,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inlinable_string" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" + [[package]] name = "inotify" version = "0.7.1" @@ -664,12 +906,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" - [[package]] name = "lazy_static" version = "1.4.0" @@ -707,15 +943,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.11", -] - [[package]] name = "log" version = "0.4.11" @@ -731,12 +958,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - [[package]] name = "memchr" version = "2.3.4" @@ -745,22 +966,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "mime" -version = "0.2.6" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -dependencies = [ - "log 0.3.9", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" -dependencies = [ - "adler", - "autocfg", -] +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mio" @@ -774,7 +982,7 @@ dependencies = [ "iovec", "kernel32-sys", "libc", - "log 0.4.11", + "log", "miow", "net2", "slab", @@ -788,11 +996,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", - "log 0.4.11", + "log", "mio", "slab", ] +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + [[package]] name = "miow" version = "0.2.2" @@ -870,10 +1089,10 @@ dependencies = [ ] [[package]] -name = "object" -version = "0.22.0" +name = "once_cell" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "opaque-debug" @@ -881,6 +1100,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "parking_lot" version = "0.11.1" @@ -908,32 +1133,36 @@ dependencies = [ ] [[package]] -name = "pear" -version = "0.1.4" +name = "parse-zoneinfo" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5320f212db967792b67cfe12bd469d08afd6318a249bd917d5c19bc92200ab8a" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" dependencies = [ - "pear_codegen", + "regex", ] [[package]] -name = "pear_codegen" -version = "0.1.4" +name = "pear" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc1c836fdc3d1ef87c348b237b5b5c4dff922156fb2d968f57734f9669768ca" +checksum = "09f612cbd0f9dd03f5dd28a191c48e4148c3b027e41207b32eee130373c6c941" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", - "version_check 0.9.2", + "inlinable_string", + "pear_codegen", "yansi", ] [[package]] -name = "percent-encoding" -version = "1.0.1" +name = "pear_codegen" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +checksum = "602cf1780ee9bbca663ea75769e05643e16fe87d7c8ac9f4f385a2ed8940a75c" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] [[package]] name = "percent-encoding" @@ -968,9 +1197,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -994,6 +1223,64 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pin-project" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" +dependencies = [ + "pin-project-internal 0.4.27", +] + +[[package]] +name = "pin-project" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" +dependencies = [ + "pin-project-internal 1.0.2", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" + +[[package]] +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.19" @@ -1002,11 +1289,11 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "polyval" -version = "0.3.3" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" +checksum = "b4fd92d8e0c06d08525d2e2643cc2b5c80c69ae8eb12c18272d501cd7079ccc0" dependencies = [ - "cfg-if 0.1.10", + "cpuid-bool 0.2.0", "universal-hash", ] @@ -1017,13 +1304,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "proc-macro2" -version = "0.4.30" +name = "proc-macro-hack" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" @@ -1031,7 +1321,20 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "unicode-xid 0.2.1", + "unicode-xid", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", ] [[package]] @@ -1053,7 +1356,7 @@ dependencies = [ "bytes", "heck", "itertools", - "log 0.4.11", + "log", "multimap", "petgraph", "prost", @@ -1070,9 +1373,9 @@ checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1085,22 +1388,13 @@ dependencies = [ "prost", ] -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2 1.0.24", + "proc-macro2", ] [[package]] @@ -1109,7 +1403,7 @@ version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" dependencies = [ - "log 0.4.11", + "log", "parking_lot", "scheduled-thread-pool", ] @@ -1161,6 +1455,26 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "ref-cast" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17626b2f4bcf35b84bf379072a66e28cfe5c3c6ae58b38e4914bb8891dabece" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c523ccaed8ac4b0288948849a350b37d3035827413c458b6a40ddb614bb4f72" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.4.2" @@ -1190,49 +1504,53 @@ dependencies = [ [[package]] name = "rocket" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc7e5d6aaa32ace6893ae8a1875688ca7b07d6c2428ae88e704c3623c8866e9" +version = "0.5.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket?branch=master#1f1f44f336e5a172361fc1860461bb03667b1ed2" dependencies = [ + "async-trait", + "atomic", "atty", - "base64 0.12.3", - "log 0.4.11", + "binascii", + "either", + "figment", + "futures", + "log", "memchr", "num_cpus", - "pear", + "parking_lot", + "rand", + "ref-cast", "rocket_codegen", "rocket_http", + "serde", "state", - "time", - "toml", - "version_check 0.9.2", + "time 0.2.23", + "tokio", + "ubyte", + "version_check", "yansi", ] [[package]] name = "rocket_codegen" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519154b16df5fe552a8f9cd76a97793a9f5d58e34f186ab79c7b29ce1d009358" +version = "0.5.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket?branch=master#1f1f44f336e5a172361fc1860461bb03667b1ed2" dependencies = [ "devise", - "glob 0.3.0", + "glob", "indexmap", - "quote 0.6.13", + "quote", "rocket_http", - "version_check 0.9.2", - "yansi", ] [[package]] name = "rocket_contrib" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9465babd59cfb360669b60431db510f3dc3268d51ccd69fc9264e626681e596a" +version = "0.5.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket?branch=master#1f1f44f336e5a172361fc1860461bb03667b1ed2" dependencies = [ "diesel", - "glob 0.3.0", - "log 0.4.11", + "glob", + "log", "notify", "r2d2", "rocket", @@ -1240,35 +1558,41 @@ dependencies = [ "serde", "serde_json", "tera", + "tokio", ] [[package]] name = "rocket_contrib_codegen" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd30b50723c98c7ba6eea01cc5416e273397fa09ac45569538758ae24590dd7d" +version = "0.5.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket?branch=master#1f1f44f336e5a172361fc1860461bb03667b1ed2" dependencies = [ "devise", - "quote 0.6.13", - "version_check 0.9.2", - "yansi", + "quote", ] [[package]] name = "rocket_http" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d087de7203c7a60a0ed5cd3a135b552dbfbed9932c52d49d083e8629935257" +version = "0.5.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket?branch=master#1f1f44f336e5a172361fc1860461bb03667b1ed2" dependencies = [ "cookie", + "either", + "http", "hyper", "indexmap", + "log", + "mime", + "parking_lot", "pear", - "percent-encoding 1.0.1", + "percent-encoding", + "ref-cast", "smallvec", "state", - "time", - "unicode-xid 0.1.0", + "time 0.2.23", + "tokio", + "uncased", + "unicode-xid", + "version_check", ] [[package]] @@ -1277,17 +1601,20 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.13.0", + "base64", "blake2b_simd", "constant_time_eq", "crossbeam-utils", ] [[package]] -name = "rustc-demangle" -version = "0.1.18" +name = "rustc_version" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] [[package]] name = "ryu" @@ -1295,12 +1622,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "same-file" version = "1.0.6" @@ -1325,11 +1646,29 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" @@ -1337,9 +1676,9 @@ version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1359,22 +1698,38 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" dependencies = [ - "block-buffer", - "digest", + "block-buffer 0.7.3", + "digest 0.8.1", "fake-simd", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] -name = "sha2" -version = "0.8.2" +name = "sha1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "sha2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpuid-bool 0.1.2", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +dependencies = [ + "libc", ] [[package]] @@ -1398,12 +1753,82 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "socket2" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "standback" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8" +dependencies = [ + "version_check", +] + [[package]] name = "state" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483" +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + [[package]] name = "strum" version = "0.20.0" @@ -1420,43 +1845,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" dependencies = [ "heck", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - [[package]] name = "subtle" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - [[package]] name = "syn" version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "unicode-xid 0.2.1", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -1480,7 +1888,8 @@ dependencies = [ "diesel", "diesel-derive-enum", "erased-serde", - "log 0.4.11", + "futures", + "log", "prost", "prost-build", "rand", @@ -1496,23 +1905,24 @@ dependencies = [ [[package]] name = "tera" -version = "0.11.20" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" +checksum = "1381c83828bedd5ce4e59473110afa5381ffe523406d9ade4b77c9f7be70ff9a" dependencies = [ "chrono", - "error-chain", - "glob 0.2.11", + "chrono-tz", + "globwalk", "humansize", "lazy_static", + "percent-encoding", "pest", "pest_derive", + "rand", "regex", "serde", "serde_json", "slug", "unic-segment", - "url", ] [[package]] @@ -1530,9 +1940,9 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1556,40 +1966,142 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.1.0" +name = "time" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b" dependencies = [ - "tinyvec_macros", + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi 0.3.9", ] [[package]] -name = "tinyvec_macros" -version = "0.1.0" +name = "time-macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + +[[package]] +name = "tokio" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio", + "mio-uds", + "num_cpus", + "pin-project-lite 0.1.11", + "signal-hook-registry", + "slab", + "tokio-macros", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.11", + "tokio", +] [[package]] name = "toml" -version = "0.4.10" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" dependencies = [ "serde", ] [[package]] -name = "traitobject" -version = "0.1.0" +name = "tower-service" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] -name = "typeable" -version = "0.1.2" +name = "tracing" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite 0.2.0", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-futures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +dependencies = [ + "pin-project 0.4.27", + "tracing", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typenum" @@ -1597,6 +2109,15 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +[[package]] +name = "ubyte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42756bb9e708855de2f8a98195643dff31a97f0485d90d8467b39dc24be9e8fe" +dependencies = [ + "serde", +] + [[package]] name = "ucd-trie" version = "0.1.3" @@ -1604,40 +2125,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] -name = "unic-char-property" -version = "0.7.0" +name = "uncased" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e" +checksum = "369fa7fd7969c5373541d3c9a40dc1b76ce676fc87aba30d87c0ad3b97fad179" +dependencies = [ + "version_check", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" dependencies = [ "unic-char-range", ] [[package]] name = "unic-char-range" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" [[package]] name = "unic-common" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8d4a7ade929ef7d971e16ced21a8cd56a63869aa6032dfb8cb083cf7d077bf" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" [[package]] name = "unic-segment" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ca47cbb09fb5fcd066b5867d11dc528302fa465277882797d6a836e1ee6f9e" +checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" dependencies = [ "unic-ucd-segment", ] [[package]] name = "unic-ucd-segment" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f1a08ce0409a9e391b88d1930118eec48af12742fc538bcec55f775865776e" +checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" dependencies = [ "unic-char-property", "unic-char-range", @@ -1646,52 +2176,19 @@ dependencies = [ [[package]] name = "unic-ucd-version" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1f5e6c6c53c2d0ece4a5964bc55fcff8602153063cb4fab20958ff32998ff6" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" dependencies = [ "unic-common", ] -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -dependencies = [ - "version_check 0.1.5", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.1" @@ -1700,23 +2197,12 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "universal-hash" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array", - "subtle 2.3.0", -] - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna", - "matches", - "percent-encoding 1.0.1", + "generic-array 0.14.4", + "subtle", ] [[package]] @@ -1725,12 +2211,6 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.2" @@ -1748,6 +2228,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -1760,6 +2250,60 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasm-bindgen" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" + [[package]] name = "which" version = "3.1.1" @@ -1827,9 +2371,3 @@ name = "yansi" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" - -[[package]] -name = "zeroize" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" diff --git a/Cargo.toml b/Cargo.toml index dc503f6..16babc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,16 @@ thiserror = "1.0" rust-argon2 = "0.8" log = "0.4" rand = "0.7" -rocket = { version= "0.4.6", features = ["private-cookies"] } +futures = "0.3" strum = { version = "0.20", features = ["derive"] } +[dependencies.rocket] +git = "https://github.com/SergioBenitez/Rocket" +branch = "master" +features = ["secrets"] + [dependencies.rocket_contrib] -version = "0.4.6" +git = "https://github.com/SergioBenitez/Rocket" +branch = "master" default-features = false features = [ "tera_templates", "diesel_sqlite_pool", "serve" ] \ No newline at end of file diff --git a/Rocket.toml b/Rocket.toml index 8f06e79..176c621 100644 --- a/Rocket.toml +++ b/Rocket.toml @@ -7,5 +7,5 @@ write_timeout = 5 log = "normal" limits = { forms = 32768 } -[development.databases] +[global.databases] tenebrous_db = { url = "./tenebrous.sqlite" } diff --git a/rust-toolchain b/rust-toolchain index bf867e0..2bf5ad0 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly +stable diff --git a/src/db.rs b/src/db.rs index 004b5b6..34f2e6f 100644 --- a/src/db.rs +++ b/src/db.rs @@ -2,23 +2,27 @@ use crate::models::characters::{Character, NewCharacter, StrippedCharacter}; use crate::models::users::{NewUser, User}; use crate::schema::characters; use diesel::prelude::*; -use diesel::SqliteConnection; +use rocket_contrib::databases::diesel; #[database("tenebrous_db")] pub(crate) struct TenebrousDbConn(SqliteConnection); +#[rocket::async_trait] pub(crate) trait Dao { - fn load_user_by_id(&self, id: i32) -> QueryResult>; + async fn load_user_by_id(&self, id: i32) -> QueryResult>; - fn load_user(&self, for_username: &str) -> QueryResult>; + async fn load_user(&self, for_username: String) -> QueryResult>; - fn insert_user(&self, new_user: &NewUser) -> QueryResult; + //async fn insert_user<'a>(&self, new_user: &'a NewUser<'a>) -> QueryResult; - fn load_character_list(&self, for_user_id: i32) -> QueryResult>; + async fn insert_user(&self, new_user: NewUser) -> QueryResult; - fn load_character(&self, character_id: i32) -> QueryResult>; + async fn load_character_list(&self, for_user_id: i32) -> QueryResult>; - fn insert_character(&self, new_character: NewCharacter) -> QueryResult<()>; + async fn load_character(&self, character_id: i32) -> QueryResult>; + + //async fn insert_character<'a>(&self, new_character: NewCharacter<'a>) -> QueryResult<()>; + async fn insert_character(&self, new_character: NewCharacter) -> QueryResult<()>; } type StrippedCharacterColumns = ( @@ -39,55 +43,67 @@ const STRIPPED_CHARACTER_COLUMNS: StrippedCharacterColumns = ( characters::data_version, ); +#[rocket::async_trait] impl Dao for TenebrousDbConn { - fn load_user_by_id(&self, user_id: i32) -> QueryResult> { + async fn load_user_by_id(&self, user_id: i32) -> QueryResult> { use crate::schema::users::dsl::*; - users.filter(id.eq(user_id)).first(&self.0).optional() + self.run(move |conn| users.filter(id.eq(user_id)).first(conn).optional()) + .await } - fn load_user(&self, for_username: &str) -> QueryResult> { + async fn load_user(&self, for_username: String) -> QueryResult> { use crate::schema::users::dsl::*; - users - .filter(username.eq(for_username)) - .first(&self.0) - .optional() + self.run(move |conn| { + users + .filter(username.eq(for_username)) + .first(conn) + .optional() + }) + .await } - fn insert_user(&self, new_user: &NewUser) -> QueryResult { - use crate::schema::users; + async fn insert_user(&self, new_user: NewUser) -> QueryResult { + self.run(move |conn| { + diesel::insert_into(users).values(&new_user).execute(conn)?; - diesel::insert_into(users::table) - .values(new_user) - .execute(&self.0)?; - - use crate::schema::users::dsl::*; - Ok(users - .filter(username.eq(new_user.username)) - .first(&self.0)?) + use crate::schema::users::dsl::*; + users.filter(username.eq(new_user.username)).first(conn) + }) + .await } - fn load_character_list(&self, for_user_id: i32) -> QueryResult> { - use crate::schema::characters::dsl::*; - characters - .filter(user_id.eq(for_user_id)) - .select(STRIPPED_CHARACTER_COLUMNS) - .load(&self.0) - } - - fn load_character(&self, character_id: i32) -> QueryResult> { + async fn load_character_list(&self, for_user_id: i32) -> QueryResult> { use crate::schema::characters::dsl::*; - characters - .filter(id.eq(character_id)) - .first(&self.0) - .optional() + self.run(move |conn| { + characters + .filter(user_id.eq(for_user_id)) + .select(STRIPPED_CHARACTER_COLUMNS) + .load(conn) + }) + .await } - fn insert_character(&self, new_character: NewCharacter) -> QueryResult<()> { - diesel::insert_into(characters::table) - .values(new_character) - .execute(&self.0)?; + async fn load_character(&self, character_id: i32) -> QueryResult> { + use crate::schema::characters::dsl::*; + + self.run(move |conn| { + characters + .filter(id.eq(character_id)) + .first(conn) + .optional() + }) + .await + } + + async fn insert_character(&self, new_character: NewCharacter) -> QueryResult<()> { + self.run(|conn| { + diesel::insert_into(characters::table) + .values(new_character) + .execute(conn) + }) + .await?; Ok(()) } diff --git a/src/errors.rs b/src/errors.rs index 2d740f6..de9eba4 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -27,10 +27,6 @@ pub enum Error { DeserializationError(#[from] prost::DecodeError), } -#[derive(Error, Debug)] -#[error("internal eror")] -pub struct SensitiveError(Error); - impl Error { fn is_sensitive(&self) -> bool { use Error::*; @@ -41,8 +37,9 @@ impl Error { } } -impl<'r> Responder<'r> for Error { - fn respond_to(self, req: &Request) -> response::Result<'r> { +#[rocket::async_trait] +impl<'r> Responder<'r, 'static> for Error { + fn respond_to(self, req: &Request) -> response::Result<'static> { log::error!("error: {0}", self.to_string()); //Hide sensitive error information let message: String = if self.is_sensitive() { @@ -64,22 +61,3 @@ impl<'r> Responder<'r> for Error { } } } - -impl<'r> Responder<'r> for SensitiveError { - fn respond_to(self, req: &Request) -> response::Result<'r> { - log::error!("sensitive error: {0}", self.0.to_string()); - let message: String = self.to_string(); - - let mut context = HashMap::new(); - context.insert("message", message); - let resp = Template::render("error", context).respond_to(req)?; - - use Error::*; - match self.0 { - NotFound => status::NotFound(resp).respond_to(req), - NotLoggedIn => status::Forbidden(Some(resp)).respond_to(req), - NoPermission => status::Forbidden(Some(resp)).respond_to(req), - _ => status::Custom(Status::InternalServerError, resp).respond_to(req), - } - } -} diff --git a/src/main.rs b/src/main.rs index 7a5456b..8cae5a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#![feature(proc_macro_hygiene, decl_macro, never_type)] - #[macro_use] extern crate rocket; @@ -24,7 +22,8 @@ pub mod models; pub mod routes; pub mod schema; -fn main() { +#[rocket::main] +async fn main() -> Result<(), rocket::error::Error> { let root_routes: Vec = { routes::root::routes() .into_iter() @@ -45,5 +44,6 @@ fn main() { StaticFiles::from(concat!(env!("CARGO_MANIFEST_DIR"), "/proto")), ) .register(catchers) - .launch(); + .launch() + .await } diff --git a/src/models/characters.rs b/src/models/characters.rs index a8f17d9..7ae9050 100644 --- a/src/models/characters.rs +++ b/src/models/characters.rs @@ -155,11 +155,11 @@ impl Visibility for StrippedCharacter { /// names correspond to columns. #[derive(Insertable)] #[table_name = "characters"] -pub struct NewCharacter<'a> { +pub struct NewCharacter { pub user_id: i32, pub viewable: bool, - pub character_name: &'a str, + pub character_name: String, pub data_type: CharacterDataType, pub data_version: i32, - pub data: &'a [u8], + pub data: Vec, } diff --git a/src/models/users.rs b/src/models/users.rs index b968932..ab0bb57 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -25,24 +25,29 @@ impl User { } } +async fn attempt_load_user<'a>(db: &'a TenebrousDbConn, id: i32) -> Option { + db.load_user_by_id(id).await.ok().flatten() +} + +#[rocket::async_trait] impl<'a, 'r> FromRequest<'a, 'r> for &'a User { - type Error = !; + type Error = (); - fn from_request(request: &'a Request<'r>) -> request::Outcome { - let user: &Option = request.local_cache(|| { - let attempt_load_user = |id| -> Option { - TenebrousDbConn::from_request(request) - .map(|conn| conn.load_user_by_id(id).ok().flatten()) - .succeeded() - .flatten() - }; + async fn from_request(request: &'a Request<'r>) -> request::Outcome { + let db = try_outcome!(request.guard::().await); + let user_id: Option = request + .cookies() + .get_private("user_id") + .and_then(|cookie| cookie.value().parse().ok()); - request - .cookies() - .get_private("user_id") - .and_then(|cookie| cookie.value().parse().ok()) - .and_then(attempt_load_user) - }); + let user: &Option = request + .local_cache_async(async { + match user_id { + Some(id) => attempt_load_user(&db, id).await, + _ => None, + } + }) + .await; user.as_ref().or_forward(()) } @@ -50,7 +55,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for &'a User { #[derive(Insertable)] #[table_name = "users"] -pub struct NewUser<'a> { - pub username: &'a str, - pub password: &'a str, +pub struct NewUser { + pub username: String, + pub password: String, } diff --git a/src/routes/auth.rs b/src/routes/auth.rs index 9277209..a1c9b21 100644 --- a/src/routes/auth.rs +++ b/src/routes/auth.rs @@ -1,7 +1,7 @@ use crate::db::{Dao, TenebrousDbConn}; use crate::models::users::{self, NewUser, User}; use log::error; -use rocket::http::{Cookie, Cookies}; +use rocket::http::{Cookie, CookieJar}; use rocket::request::{FlashMessage, Form}; use rocket::response::{Flash, Redirect}; use rocket_contrib::templates::Template; @@ -30,11 +30,11 @@ struct Registration { password: String, } -fn add_login_cookie(cookies: &mut Cookies, user: &User) { +fn add_login_cookie(cookies: &CookieJar<'_>, user: &User) { cookies.add_private(Cookie::new("user_id", user.id.to_string())); } -fn remove_login_cookie(cookies: &mut Cookies) { +fn remove_login_cookie(cookies: &CookieJar<'_>) { cookies.remove_private(Cookie::named("user_id")); } @@ -47,13 +47,14 @@ fn registration_error_redirect>(message: S) -> Flash { } #[post("/login", data = "")] -fn login( - mut cookies: Cookies, +async fn login( + cookies: &CookieJar<'_>, login: Form, conn: TenebrousDbConn, ) -> Result> { let user = conn - .load_user(&login.username) + .load_user(login.username.clone()) + .await .map_err(|e| { error!("login - error loading user user: {}", e); login_error_redirect("Internal error.") @@ -61,7 +62,7 @@ fn login( .ok_or_else(|| login_error_redirect("Invalid username or password."))?; if user.verify_password(&login.password) { - add_login_cookie(&mut cookies, &user); + add_login_cookie(cookies, &user); Ok(Redirect::to(uri!(super::root::index))) } else { Err(login_error_redirect("Invalid username or password.")) @@ -69,8 +70,8 @@ fn login( } #[post("/logout")] -fn logout(mut cookies: Cookies) -> Flash { - remove_login_cookie(&mut cookies); +fn logout(cookies: &CookieJar<'_>) -> Flash { + remove_login_cookie(cookies); Flash::success(Redirect::to(uri!(login_page)), "Successfully logged out.") } @@ -100,15 +101,18 @@ fn register_page(flash: Option) -> Template { } #[post("/register", data = "")] -fn register( - mut cookies: Cookies, +async fn register( + mut cookies: &CookieJar<'_>, registration: Form, conn: TenebrousDbConn, ) -> Result> { - let existing_user = conn.load_user(®istration.username).map_err(|e| { - error!("registration - error loading existing user: {}", e); - registration_error_redirect("There was an error attempting to register.") - })?; + let existing_user = conn + .load_user(registration.username.clone()) + .await + .map_err(|e| { + error!("registration - error loading existing user: {}", e); + registration_error_redirect("There was an error attempting to register.") + })?; if existing_user.is_some() { return Err(registration_error_redirect(format!( @@ -123,11 +127,11 @@ fn register( })?; let user = NewUser { - username: ®istration.username, - password: &hashed_pw, + username: registration.username.clone(), + password: hashed_pw, }; - let user = conn.insert_user(&user).map_err(|e| { + let user = conn.insert_user(user).await.map_err(|e| { error!("registration - could not insert user: {}", e); registration_error_redirect("There was an error completing registration.") })?; diff --git a/src/routes/characters.rs b/src/routes/characters.rs index 425f1b6..dfa7fb2 100644 --- a/src/routes/characters.rs +++ b/src/routes/characters.rs @@ -45,16 +45,17 @@ fn view_character_template(user: &User, character: Character) -> Result