diff --git a/Cargo.lock b/Cargo.lock index 7ab26111af..be812c00fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,14 +7,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" dependencies = [ "lazy_static 1.4.0", - "regex 1.3.9", + "regex 1.4.2", ] [[package]] name = "addr2line" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ "gimli", ] @@ -31,6 +31,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "ahash" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6789e291be47ace86a60303502173d84af8327e3627ecf334356ee0f87a164c" + [[package]] name = "aho-corasick" version = "0.6.10" @@ -42,9 +48,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -82,12 +88,6 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" -[[package]] -name = "arc-swap" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" - [[package]] name = "arrayref" version = "0.3.6" @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "async-attributes" @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.4.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43de69555a39d52918e2bc33a408d3c0a86c829b212d898f4ca25d21a6387478" +checksum = "59740d83946db6a5af71ae25ddf9562c2b176b2ca42cf99a455f09f4a220d6b9" dependencies = [ "concurrent-queue", "event-listener", @@ -132,42 +132,54 @@ dependencies = [ [[package]] name = "async-executor" -version = "0.1.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f47c78ea98277cb1f5e6f60ba4fc762f5eafe9f6511bc2f7dfd8b75c225650" +checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" dependencies = [ + "async-task 4.0.3", + "concurrent-queue", + "fastrand", + "futures-lite 1.11.2", + "once_cell", + "vec-arena", +] + +[[package]] +name = "async-global-executor" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73079b49cd26b8fd5a15f68fc7707fc78698dc2a3d61430f2a7a9430230dfa04" +dependencies = [ + "async-executor", "async-io", - "futures-lite", - "multitask", - "parking 1.0.6", - "scoped-tls 1.0.0", - "waker-fn", + "futures-lite 1.11.2", + "num_cpus", + "once_cell", ] [[package]] name = "async-io" -version = "0.1.11" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae22a338d28c75b53702b66f77979062cb29675db376d99e451af4fa79dedb3" +checksum = "b5bfd63f6fc8fd2925473a147d3f4d252c712291efdde0d7057b25146563402c" dependencies = [ - "cfg-if", "concurrent-queue", - "futures-lite", - "libc", + "fastrand", + "futures-lite 1.11.2", + "log 0.4.11", + "nb-connect", "once_cell", "parking 2.0.0", "polling", - "socket2", "vec-arena", - "wepoll-sys-stjepang", - "winapi 0.3.9", + "waker-fn", ] [[package]] name = "async-mutex" -version = "1.1.5" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20e85981fc34e84cdff3fc2c9219189752633fdc538a06df8b5ac45b68a4f3a9" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" dependencies = [ "event-listener", ] @@ -185,30 +197,30 @@ dependencies = [ [[package]] name = "async-std" -version = "1.6.3" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c8da367da62b8ff2313c406c9ac091c1b31d67a165becdd2de380d846260f7" +checksum = "a7e82538bc65a25dbdff70e4c5439d52f068048ab97cdea0acd73f131594caa1" dependencies = [ "async-attributes", - "async-executor", + "async-global-executor", "async-io", "async-mutex", - "async-task", - "blocking 0.5.2", - "crossbeam-utils 0.7.2", + "blocking 1.0.2", + "crossbeam-utils 0.8.0", "futures-channel", "futures-core", "futures-io", - "futures-lite", + "futures-lite 1.11.2", + "gloo-timers", "kv-log-macro", "log 0.4.11", "memchr", "num_cpus", "once_cell", - "pin-project-lite", + "pin-project-lite 0.1.11", "pin-utils", "slab 0.4.2", - "wasm-bindgen-futures 0.4.17", + "wasm-bindgen-futures 0.4.18", ] [[package]] @@ -218,10 +230,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" [[package]] -name = "async-trait" -version = "0.1.40" +name = "async-task" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687c230d85c0a52504709705fc8a53e4a692b83a2184f03dae73e38e1e93a783" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" + +[[package]] +name = "async-trait" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ "proc-macro2", "quote", @@ -245,12 +263,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.1" @@ -259,14 +271,14 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.50" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" dependencies = [ "addr2line", - "cfg-if", + "cfg-if 1.0.0", "libc", - "miniz_oxide 0.4.1", + "miniz_oxide 0.4.3", "object", "rustc-demangle", ] @@ -291,27 +303,18 @@ dependencies = [ "safemem 0.3.3", ] -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - [[package]] name = "base64" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + [[package]] name = "bat" version = "0.15.4" @@ -333,7 +336,7 @@ dependencies = [ "liquid", "path_abs", "semver 0.9.0", - "serde 1.0.115", + "serde 1.0.117", "serde_yaml", "shell-words", "syntect", @@ -343,17 +346,18 @@ dependencies = [ [[package]] name = "battery" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8775be4956c98c9ac7c11cc383d632636935d3a688dabddb71ac83ba00a3a72f" +checksum = "b4b624268937c0e0a3edb7c27843f9e547c320d730c610d3b8e6e8e95b2026e4" dependencies = [ - "cfg-if", - "core-foundation", + "cfg-if 1.0.0", + "core-foundation 0.7.0", "lazycell", "libc", "mach", - "num-traits 0.2.12", - "uom 0.29.0", + "nix 0.19.0", + "num-traits 0.2.14", + "uom 0.30.0", "winapi 0.3.9", ] @@ -363,10 +367,10 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc403c26e6b03005522e6e8053384c4e881dfe5b2bf041c0c2c49be33d64a539" dependencies = [ - "num-bigint 0.3.0", + "num-bigint 0.3.1", "num-integer", - "num-traits 0.2.12", - "serde 1.0.115", + "num-traits 0.2.14", + "serde 1.0.117", ] [[package]] @@ -376,7 +380,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" dependencies = [ "byteorder", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -402,12 +406,12 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2b_simd" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec 0.5.1", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -465,7 +469,7 @@ checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" dependencies = [ "async-channel", "atomic-waker", - "futures-lite", + "futures-lite 0.1.11", "once_cell", "parking 1.0.6", "waker-fn", @@ -473,15 +477,16 @@ dependencies = [ [[package]] name = "blocking" -version = "0.5.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5800d29218fea137b0880387e5948694a23c93fcdde157006966693a865c7c" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" dependencies = [ "async-channel", + "async-task 4.0.3", "atomic-waker", - "futures-lite", + "fastrand", + "futures-lite 1.11.2", "once_cell", - "waker-fn", ] [[package]] @@ -498,21 +503,21 @@ dependencies = [ "linked-hash-map 0.5.3", "md5 0.6.1", "rand 0.7.3", - "serde 1.0.115", + "serde 1.0.117", "serde_json", "time", ] [[package]] name = "bstr" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" +checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" dependencies = [ "lazy_static 1.4.0", "memchr", "regex-automata", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -555,7 +560,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ "byteorder", - "either", "iovec", ] @@ -594,16 +598,16 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] name = "calamine" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc39da027ec520445e6e526f105170b424ca68ea9e53553d3e6a29df41713ba" +checksum = "36b93ee9afe52156da81c32d39cb4c0c1a947b5ea9bc9719e805af9c8e05d40e" dependencies = [ "byteorder", "codepage", "encoding_rs", "log 0.4.11", - "quick-xml 0.17.2", - "serde 1.0.115", + "quick-xml 0.19.0", + "serde 1.0.117", "zip", ] @@ -615,9 +619,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.59" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" +checksum = "95752358c8f7552394baf48cd82695b345628ad3f170d607de3ca03b8dacca15" dependencies = [ "jobserver", ] @@ -629,22 +633,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "chrono" -version = "0.4.15" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ + "libc", "num-integer", - "num-traits 0.2.12", - "serde 1.0.115", + "num-traits 0.2.14", + "serde 1.0.117", "time", + "winapi 0.3.9", ] [[package]] name = "chrono-tz" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d96be7c3e993c9ee4356442db24ba364c924b6b8331866be6b6952bfe74b9d" +checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" dependencies = [ "chrono", "parse-zoneinfo", @@ -721,7 +733,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0762455306b1ed42bc651ef6a2197aabda5e1d4a43c34d5eab5c1a3634e81d" dependencies = [ - "serde 1.0.115", + "serde 1.0.117", "termcolor", "unicode-width", ] @@ -755,7 +767,7 @@ dependencies = [ "lazy_static 1.4.0", "nom 5.1.2", "rust-ini", - "serde 1.0.115", + "serde 1.0.117", "serde-hjson", "serde_json", "toml", @@ -771,7 +783,7 @@ dependencies = [ "encode_unicode", "lazy_static 1.4.0", "libc", - "regex 1.3.9", + "regex 1.4.2", "terminal_size", "termios", "unicode-width", @@ -779,6 +791,22 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" +dependencies = [ + "cfg-if 0.1.10", + "wasm-bindgen", +] + +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -794,41 +822,23 @@ dependencies = [ "memchr", ] -[[package]] -name = "cookie" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" -dependencies = [ - "time", - "url 1.7.2", -] - -[[package]] -name = "cookie_store" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" -dependencies = [ - "cookie", - "failure", - "idna 0.1.5", - "log 0.4.11", - "publicsuffix", - "serde 1.0.115", - "serde_json", - "time", - "try_from", - "url 1.7.2", -] - [[package]] name = "core-foundation" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.7.0", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys 0.8.2", "libc", ] @@ -838,6 +848,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + [[package]] name = "cpuid-bool" version = "0.1.2" @@ -846,11 +862,11 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crc32fast" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -864,12 +880,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "cfg-if", - "crossbeam-utils 0.7.2", + "cfg-if 1.0.0", + "crossbeam-utils 0.8.0", ] [[package]] @@ -878,19 +894,30 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ - "crossbeam-epoch", + "crossbeam-epoch 0.8.2", "crossbeam-utils 0.7.2", "maybe-uninit", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch 0.9.0", + "crossbeam-utils 0.8.0", +] + [[package]] name = "crossbeam-epoch" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.0.1", - "cfg-if", + "autocfg", + "cfg-if 0.1.10", "crossbeam-utils 0.7.2", "lazy_static 1.4.0", "maybe-uninit", @@ -898,13 +925,27 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +dependencies = [ + "cfg-if 1.0.0", + "const_fn", + "crossbeam-utils 0.8.0", + "lazy_static 1.4.0", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-queue" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "crossbeam-utils 0.7.2", "maybe-uninit", ] @@ -915,7 +956,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "lazy_static 1.4.0", ] @@ -925,22 +966,34 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.1", - "cfg-if", + "autocfg", + "cfg-if 0.1.10", + "lazy_static 1.4.0", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "const_fn", "lazy_static 1.4.0", ] [[package]] name = "crossterm" -version = "0.17.8" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "858085e389f71d31a6909f2b55a56b87d1cb8b168c0f513dcbed5e66a3e1039c" +checksum = "6f4919d60f26ae233e14233cc39746c8c8bb8cd7b05840ace83604917b51b6c7" dependencies = [ "bitflags", "crossterm_winapi", "lazy_static 1.4.0", "libc", - "mio 0.7.0", + "mio 0.7.6", "parking_lot 0.10.2", "signal-hook", "winapi 0.3.9", @@ -948,25 +1001,25 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.18.0" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2fcdc3c9cf8ee446222e8ee8691a6d21b563b8fe1a64b1873080db7b5b23cf0" +checksum = "4e86d73f2a0b407b5768d10a8c720cf5d2df49a9efc10ca09176d201ead4b7fb" dependencies = [ "bitflags", "crossterm_winapi", "lazy_static 1.4.0", "libc", - "mio 0.7.0", - "parking_lot 0.11.0", + "mio 0.7.6", + "parking_lot 0.11.1", "signal-hook", "winapi 0.3.9", ] [[package]] name = "crossterm_winapi" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c" +checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db" dependencies = [ "winapi 0.3.9", ] @@ -994,7 +1047,7 @@ dependencies = [ "phf", "proc-macro2", "quote", - "smallvec 1.4.2", + "smallvec 1.5.0", "syn", ] @@ -1010,15 +1063,15 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +checksum = "fc4666154fd004af3fd6f1da2e81a96fd5a81927fe8ddb6ecc79e2aa6e138b54" dependencies = [ "bstr", "csv-core", "itoa", "ryu", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -1032,19 +1085,19 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.1.6" +version = "3.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b676fa23f995faf587496dcd1c80fead847ed58d2da52ac1caca9a72790dd2" +checksum = "b57a92e9749e10f25a171adcebfafe72991d45e7ec2dcb853e8f83d9dafaeb08" dependencies = [ - "nix 0.17.0", + "nix 0.18.0", "winapi 0.3.9", ] [[package]] name = "curl" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78baca05127a115136a9898e266988fc49ca7ea2c839f60fc6e1fc9df1599168" +checksum = "e268162af1a5fe89917ae25ba3b0a77c8da752bdc58e7dbb4f15b91fbd33756e" dependencies = [ "curl-sys", "libc", @@ -1057,9 +1110,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.36+curl-7.71.1" +version = "0.4.38+curl-7.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68cad94adeb0c16558429c3c34a607acc9ea58e09a7b66310aabc9788fc5d721" +checksum = "498ecfb4f59997fd40023d62a9f1e506e768b2baeb59a1d311eb9751cdcd7e3f" dependencies = [ "cc", "libc", @@ -1167,7 +1220,7 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "dirs-sys", ] @@ -1186,7 +1239,7 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "dirs-sys", ] @@ -1201,11 +1254,11 @@ dependencies = [ [[package]] name = "dirs-next" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cbcf9241d9e8d106295bd496bbe2e9cffd5fa098f2a8c9e2bbcbf09773c11a8" +checksum = "cf36e65a80337bea855cd4ef9b8401ffce06a7baedf2e85ec467b1ac3f6e82b6" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -1222,9 +1275,9 @@ dependencies = [ [[package]] name = "dirs-sys-next" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c60f7b8a8953926148223260454befb50c751d3c50e1c178c4fd1ace4083c9a" +checksum = "99de365f605554ae33f115102a02057d4fc18b01f3284d6870be0938743cfe7d" dependencies = [ "libc", "redox_users", @@ -1261,7 +1314,7 @@ dependencies = [ "chrono", "chrono-tz", "lazy_static 1.4.0", - "num-traits 0.2.12", + "num-traits 0.2.14", "rust_decimal", ] @@ -1273,9 +1326,9 @@ checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" [[package]] name = "either" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "eml-parser" @@ -1283,7 +1336,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9e30d14e24cd200f2351837a02feacf8f043410f2a56441868c93ef33f90239" dependencies = [ - "regex 1.3.9", + "regex 1.4.2", ] [[package]] @@ -1358,11 +1411,11 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[package]] name = "encoding_rs" -version = "0.8.24" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" +checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1374,7 +1427,7 @@ dependencies = [ "atty", "humantime", "log 0.4.11", - "regex 1.3.9", + "regex 1.4.2", "termcolor", ] @@ -1389,9 +1442,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.4.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cd41440ae7e4734bbd42302f63eaba892afc93a3912dad84006247f0dedb0e" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "failure" @@ -1440,14 +1493,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae91abf6555234338687bb47913978d275539235fcb77ba9863b779090b42b14" dependencies = [ "bit-set", - "regex 1.3.9", + "regex 1.4.2", ] [[package]] name = "fastrand" -version = "1.3.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd3bdaaf0a72155260a1c098989b60db1cbb22d6a628e64f16237aa4da93cc7" +checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" +dependencies = [ + "instant", +] [[package]] name = "filesize" @@ -1470,7 +1526,7 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "crc32fast", "libc", "miniz_oxide 0.3.7", @@ -1547,15 +1603,15 @@ dependencies = [ [[package]] name = "futures" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" [[package]] name = "futures" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" +checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" dependencies = [ "futures-channel", "futures-core", @@ -1568,9 +1624,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" dependencies = [ "futures-core", "futures-sink", @@ -1588,9 +1644,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" [[package]] name = "futures-core-preview" @@ -1604,15 +1660,15 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "num_cpus", ] [[package]] name = "futures-executor" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" dependencies = [ "futures-core", "futures-task", @@ -1632,9 +1688,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" [[package]] name = "futures-io-preview" @@ -1653,15 +1709,30 @@ dependencies = [ "futures-io", "memchr", "parking 2.0.0", - "pin-project-lite", + "pin-project-lite 0.1.11", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6c079abfac3ab269e2927ec048dabc89d009ebfdda6b8ee86624f30c689658" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking 2.0.0", + "pin-project-lite 0.1.11", "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -1685,9 +1756,9 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" [[package]] name = "futures-sink-preview" @@ -1697,9 +1768,9 @@ checksum = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" dependencies = [ "once_cell", ] @@ -1712,11 +1783,11 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "futures-channel", "futures-core", "futures-io", @@ -1724,7 +1795,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project", + "pin-project 1.0.2", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1738,7 +1809,7 @@ version = "0.3.0-alpha.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "futures-channel-preview", "futures-core-preview", "futures-io-preview", @@ -1756,9 +1827,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce54d63f8b0c75023ed920d46fd71d0cbbb830b0ee012726b5b4f506fb6dea5b" dependencies = [ "bytes 0.5.6", - "futures 0.3.5", + "futures 0.3.8", "memchr", - "pin-project", + "pin-project 0.4.27", ] [[package]] @@ -1807,11 +1878,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -1830,15 +1901,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "git2" -version = "0.13.11" +version = "0.13.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165" +checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224" dependencies = [ "bitflags", "libc", @@ -1846,7 +1917,7 @@ dependencies = [ "log 0.4.11", "openssl-probe", "openssl-sys", - "url 2.1.1", + "url", ] [[package]] @@ -1857,40 +1928,67 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" dependencies = [ - "aho-corasick 0.7.13", + "aho-corasick 0.7.15", "bstr", "fnv", "log 0.4.11", - "regex 1.3.9", + "regex 1.4.2", +] + +[[package]] +name = "gloo-timers" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] name = "h2" -version = "0.1.26" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "byteorder", - "bytes 0.4.12", + "bytes 0.5.6", "fnv", - "futures 0.1.29", - "http", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.1", "indexmap", - "log 0.4.11", "slab 0.4.2", - "string", - "tokio-io", + "tokio 0.2.23", + "tokio-util", + "tracing", + "tracing-futures", ] [[package]] name = "hashbrown" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8" +dependencies = [ + "hashbrown", +] [[package]] name = "heim" @@ -1915,8 +2013,8 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58d46c2c79530368c7a76e4808ff7263970029f38bcd544a9d43722ed0828527" dependencies = [ - "cfg-if", - "core-foundation", + "cfg-if 0.1.10", + "core-foundation 0.7.0", "futures-core", "futures-util", "lazy_static 1.4.0", @@ -1934,8 +2032,8 @@ version = "0.1.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b1442359831aa671aa931f0a084aab210e77b1330ded78f1e60cc305abc4bb" dependencies = [ - "cfg-if", - "futures 0.3.5", + "cfg-if 0.1.10", + "futures 0.3.8", "glob", "heim-common", "heim-runtime", @@ -1954,8 +2052,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c650cc53da13cb4027eba907bfeff7c764d801e83fd833e48b513c38ed78368" dependencies = [ "bitflags", - "cfg-if", - "core-foundation", + "cfg-if 0.1.10", + "core-foundation 0.7.0", "heim-common", "heim-runtime", "libc", @@ -1970,7 +2068,7 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79cce3ce658bd45e510ff0a2fb5c668cbe1a7368929fd1db123741c99fd6902e" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "heim-common", "heim-runtime", "lazy_static 1.4.0", @@ -1988,7 +2086,7 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edf21693fc5ebcae37997230b90876687bcf6e53d243af988a5a89215a3c2578" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "heim-common", "heim-runtime", "lazy_static 1.4.0", @@ -2004,7 +2102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59da1108e732afcda77e1429b5d0ce648b9a31d1f8cf385108b83bea4cf91342" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 0.1.10", "heim-common", "heim-runtime", "libc", @@ -2019,9 +2117,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd969deb2a89a488b6a9bf18a65923ae4cdef6b128fa2dedb74ef5c694deb5ae" dependencies = [ "async-trait", - "cfg-if", + "cfg-if 0.1.10", "darwin-libproc", - "futures 0.3.5", + "futures 0.3.8", "heim-common", "heim-cpu", "heim-host", @@ -2043,7 +2141,7 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "906dd26ed2eb6b9f5f0dc3dfc04caeb82785ccc05a3b3326e4c841613451acc7" dependencies = [ - "futures 0.3.5", + "futures 0.3.8", "futures-timer", "smol", "version-sync", @@ -2055,16 +2153,16 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdae0cfeffcc728b469424c937abaa286a0d89e2a0c347c51eaddc60c029144" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "heim-common", "heim-runtime", ] [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" dependencies = [ "libc", ] @@ -2133,15 +2231,24 @@ dependencies = [ ] [[package]] -name = "http-body" -version = "0.1.0" +name = "http" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "http", - "tokio-buf", + "bytes 0.5.6", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.6", + "http 0.2.1", ] [[package]] @@ -2150,6 +2257,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 = "humantime" version = "1.3.0" @@ -2167,7 +2280,7 @@ checksum = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" dependencies = [ "base64 0.9.3", "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "futures-cpupool", "httparse", "iovec", @@ -2188,45 +2301,39 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.35" +version = "0.13.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "futures-cpupool", + "bytes 0.5.6", + "futures-channel", + "futures-core", + "futures-util", "h2", - "http", + "http 0.2.1", "http-body", "httparse", - "iovec", + "httpdate", "itoa", - "log 0.4.11", - "net2", - "rustc_version", - "time", - "tokio", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want 0.2.0", + "pin-project 1.0.2", + "socket2", + "tokio 0.2.23", + "tower-service", + "tracing", + "want 0.3.0", ] [[package]] name = "hyper-tls" -version = "0.3.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" +checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "hyper 0.12.35", + "bytes 0.5.6", + "hyper 0.13.9", "native-tls", - "tokio-io", + "tokio 0.2.23", + "tokio-tls", ] [[package]] @@ -2245,22 +2352,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea685d38f1becb4f0a04e6cbff9256c6c2cd5e5905563b251401d1c13d12c654" dependencies = [ "async-std", - "cfg-if", - "futures 0.3.5", + "cfg-if 0.1.10", + "futures 0.3.8", "thiserror", ] -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.2.0" @@ -2282,7 +2378,7 @@ dependencies = [ "jpeg-decoder", "num-iter", "num-rational", - "num-traits 0.2.12", + "num-traits 0.2.14", "png", ] @@ -2292,9 +2388,9 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ - "autocfg 1.0.1", + "autocfg", "hashbrown", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -2308,11 +2404,11 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -2324,6 +2420,12 @@ dependencies = [ "libc", ] +[[package]] +name = "ipnet" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" + [[package]] name = "isahc" version = "0.7.6" @@ -2337,7 +2439,7 @@ dependencies = [ "curl-sys", "futures-io-preview", "futures-util-preview", - "http", + "http 0.1.21", "lazy_static 1.4.0", "log 0.4.11", "slab 0.4.2", @@ -2379,9 +2481,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a7e2c92a4804dd459b86c339278d0fe87cf93757fae222c3fa3ae75458bc73" +checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" dependencies = [ "wasm-bindgen", ] @@ -2402,7 +2504,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1eac31d8e24111621ee7d60b4bc8c3da32925f7606dd8c26a3f789db82a23405" dependencies = [ - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -2444,24 +2546,24 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616" dependencies = [ - "arrayvec 0.5.1", + "arrayvec 0.5.2", "bitflags", - "cfg-if", + "cfg-if 0.1.10", "ryu", "static_assertions", ] [[package]] name = "libc" -version = "0.2.76" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] name = "libgit2-sys" -version = "0.12.13+1.0.1" +version = "0.12.14+1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069eea34f76ec15f2822ccf78fe0cdb8c9016764d0a12865278585a74dbdeae5" +checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549" dependencies = [ "cc", "libc", @@ -2483,9 +2585,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a245984b1b06c291f46e27ebda9f369a94a1ab8461d0e845e23f9ced01f5db" +checksum = "64d31059f22935e6c31830db5249ba2b7ecd54fd73a9909286f0a67aa55c2fbd" dependencies = [ "cc", "pkg-config", @@ -2508,9 +2610,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af67924b8dd885cccea261866c8ce5b74d239d272e154053ff927dae839f5ae9" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" dependencies = [ "cc", "libc", @@ -2554,7 +2656,7 @@ dependencies = [ "liquid-core", "liquid-derive", "liquid-lib", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -2568,10 +2670,10 @@ dependencies = [ "itertools", "kstring", "liquid-derive", - "num-traits 0.2.12", + "num-traits 0.2.14", "pest", "pest_derive", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -2597,7 +2699,7 @@ dependencies = [ "liquid-core", "once_cell", "percent-encoding 2.1.0", - "regex 1.3.9", + "regex 1.4.2", "unicode-segmentation", ] @@ -2612,9 +2714,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] @@ -2634,16 +2736,7 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ - "cfg-if", -] - -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map 0.5.3", + "cfg-if 0.1.10", ] [[package]] @@ -2691,7 +2784,7 @@ dependencies = [ "log 0.4.11", "phf", "phf_codegen", - "serde 1.0.115", + "serde 1.0.117", "serde_derive", "serde_json", "string_cache", @@ -2725,17 +2818,17 @@ checksum = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" [[package]] name = "memchr" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memoffset" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -2775,11 +2868,12 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", + "autocfg", ] [[package]] @@ -2788,7 +2882,7 @@ version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "fuchsia-zircon", "fuchsia-zircon-sys", "iovec", @@ -2803,14 +2897,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.0" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9971bc8349a361217a8f2a41f5d011274686bd4436465ba51730921039d7fb" +checksum = "f33bc887064ef1fd66020c9adfc45bb9f33d75a42096c81e7c56c65b75dd1a8b" dependencies = [ - "lazy_static 1.4.0", "libc", "log 0.4.11", - "miow 0.3.5", + "miow 0.3.6", "ntapi", "winapi 0.3.9", ] @@ -2840,30 +2933,19 @@ dependencies = [ [[package]] name = "miow" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", "winapi 0.3.9", ] -[[package]] -name = "multitask" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c09c35271e7dcdb5f709779111f2c8e8ab8e06c1b587c1c6a9e179d865aaa5b4" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", -] - [[package]] name = "native-tls" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" dependencies = [ "lazy_static 1.4.0", "libc", @@ -2877,6 +2959,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nb-connect" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8123a81538e457d44b933a02faf885d3fe8408806b23fa700e8f01c6c3a98998" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "neso" version = "0.5.0" @@ -2884,20 +2976,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b3c31defbcb081163db18437fd88c2a267cb3e26f7bd5e4b186e4b1b38fe8c8" dependencies = [ "bincode", - "cfg-if", + "cfg-if 0.1.10", "log 0.4.11", - "serde 1.0.115", + "serde 1.0.117", "serde_derive", "wasm-bindgen", ] [[package]] name = "net2" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "winapi 0.3.9", ] @@ -2929,7 +3021,7 @@ checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 0.1.10", "libc", "void", ] @@ -2942,7 +3034,19 @@ checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 0.1.10", + "libc", +] + +[[package]] +name = "nix" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85db2feff6bf70ebc3a4793191517d5f0331100a2f10f9bf93b5e5214f32b7b7" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", "libc", ] @@ -2971,9 +3075,9 @@ dependencies = [ [[package]] name = "ntapi" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ "winapi 0.3.9", ] @@ -2985,7 +3089,7 @@ dependencies = [ "clap", "ctrlc", "dunce", - "futures 0.3.5", + "futures 0.3.8", "itertools", "log 0.4.11", "nu-cli", @@ -3046,7 +3150,7 @@ dependencies = [ "encoding_rs", "filesize", "fs_extra", - "futures 0.3.5", + "futures 0.3.8", "futures-util", "futures_codec", "getset", @@ -3063,6 +3167,7 @@ dependencies = [ "meval", "nu-data", "nu-errors", + "nu-json", "nu-parser", "nu-plugin", "nu-protocol", @@ -3070,10 +3175,10 @@ dependencies = [ "nu-table", "nu-test-support", "nu-value-ext", - "num-bigint 0.3.0", + "num-bigint 0.3.1", "num-format", - "num-traits 0.2.12", - "parking_lot 0.11.0", + "num-traits 0.2.14", + "parking_lot 0.11.1", "pin-utils", "pretty-hex", "ptree", @@ -3083,19 +3188,18 @@ dependencies = [ "quickcheck_macros", "rand 0.7.3", "rayon", - "regex 1.3.9", + "regex 1.4.2", "roxmltree", "rusqlite", "rust-embed", "rustyline", - "serde 1.0.115", - "serde-hjson", + "serde 1.0.117", "serde_bytes", "serde_ini", "serde_json", "serde_urlencoded 0.7.0", "serde_yaml", - "sha2 0.9.1", + "sha2 0.9.2", "shellexpand", "strip-ansi-escapes", "sxd-document", @@ -3109,9 +3213,9 @@ dependencies = [ "umask", "unicode-segmentation", "uom 0.28.0", - "url 2.1.1", + "url", "users", - "uuid 0.8.1", + "uuid", "which", "zip", ] @@ -3136,12 +3240,12 @@ dependencies = [ "nu-table", "nu-test-support", "nu-value-ext", - "num-bigint 0.3.0", + "num-bigint 0.3.1", "num-format", - "num-traits 0.2.12", - "parking_lot 0.11.0", + "num-traits 0.2.14", + "parking_lot 0.11.1", "query_interface", - "serde 1.0.115", + "serde 1.0.117", "toml", "users", ] @@ -3157,14 +3261,24 @@ dependencies = [ "getset", "glob", "nu-source", - "num-bigint 0.3.0", - "num-traits 0.2.12", - "serde 1.0.115", + "num-bigint 0.3.1", + "num-traits 0.2.14", + "serde 1.0.117", "serde_json", "serde_yaml", "toml", ] +[[package]] +name = "nu-json" +version = "0.22.0" +dependencies = [ + "lazy_static 1.4.0", + "num-traits 0.1.43", + "regex 1.4.2", + "serde 0.8.23", +] + [[package]] name = "nu-parser" version = "0.22.0" @@ -3177,9 +3291,9 @@ dependencies = [ "nu-errors", "nu-protocol", "nu-source", - "num-bigint 0.3.0", - "num-traits 0.2.12", - "serde 1.0.115", + "num-bigint 0.3.1", + "num-traits 0.2.14", + "serde 1.0.117", "shellexpand", ] @@ -3194,8 +3308,8 @@ dependencies = [ "nu-source", "nu-test-support", "nu-value-ext", - "num-bigint 0.3.0", - "serde 1.0.115", + "num-bigint 0.3.1", + "serde 1.0.117", "serde_json", ] @@ -3212,10 +3326,10 @@ dependencies = [ "log 0.4.11", "nu-errors", "nu-source", - "num-bigint 0.3.0", + "num-bigint 0.3.1", "num-integer", - "num-traits 0.2.12", - "serde 1.0.115", + "num-traits 0.2.14", + "serde 1.0.117", "serde_bytes", "serde_json", "serde_yaml", @@ -3229,7 +3343,7 @@ dependencies = [ "derive-new", "getset", "pretty", - "serde 1.0.115", + "serde 1.0.117", "termcolor", ] @@ -3255,7 +3369,7 @@ dependencies = [ "nu-protocol", "nu-source", "nu-value-ext", - "num-bigint 0.3.0", + "num-bigint 0.3.1", "tempfile", ] @@ -3268,7 +3382,7 @@ dependencies = [ "nu-errors", "nu-protocol", "nu-source", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3276,7 +3390,7 @@ name = "nu_plugin_binaryview" version = "0.22.0" dependencies = [ "ansi_term 0.12.1", - "crossterm 0.18.0", + "crossterm 0.18.2", "image", "neso", "nu-errors", @@ -3291,7 +3405,7 @@ dependencies = [ name = "nu_plugin_chart" version = "0.22.0" dependencies = [ - "crossterm 0.18.0", + "crossterm 0.18.2", "nu-cli", "nu-data", "nu-errors", @@ -3307,13 +3421,13 @@ name = "nu_plugin_fetch" version = "0.22.0" dependencies = [ "base64 0.12.3", - "futures 0.3.5", + "futures 0.3.8", "nu-errors", "nu-plugin", "nu-protocol", "nu-source", "surf", - "url 2.1.1", + "url", ] [[package]] @@ -3327,7 +3441,7 @@ dependencies = [ "nu-protocol", "nu-source", "nu-value-ext", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3340,7 +3454,7 @@ dependencies = [ "nu-protocol", "nu-source", "nu-value-ext", - "num-traits 0.2.12", + "num-traits 0.2.14", "rusqlite", "tempfile", ] @@ -3366,7 +3480,7 @@ dependencies = [ "nu-plugin", "nu-protocol", "nu-source", - "regex 1.3.9", + "regex 1.4.2", ] [[package]] @@ -3374,36 +3488,36 @@ name = "nu_plugin_post" version = "0.22.0" dependencies = [ "base64 0.12.3", - "futures 0.3.5", + "futures 0.3.8", "nu-errors", "nu-plugin", "nu-protocol", "nu-source", - "num-traits 0.2.12", + "num-traits 0.2.14", "serde_json", "surf", - "url 2.1.1", + "url", ] [[package]] name = "nu_plugin_ps" version = "0.22.0" dependencies = [ - "futures 0.3.5", + "futures 0.3.8", "futures-timer", "heim", "nu-errors", "nu-plugin", "nu-protocol", "nu-source", - "num-bigint 0.3.0", + "num-bigint 0.3.1", ] [[package]] name = "nu_plugin_s3" version = "0.22.0" dependencies = [ - "futures 0.3.5", + "futures 0.3.8", "nu-errors", "nu-plugin", "nu-protocol", @@ -3433,7 +3547,7 @@ dependencies = [ "nu-protocol", "nu-source", "open", - "url 2.1.1", + "url", ] [[package]] @@ -3441,14 +3555,14 @@ name = "nu_plugin_sys" version = "0.22.0" dependencies = [ "battery", - "futures 0.3.5", + "futures 0.3.8", "futures-util", "heim", "nu-errors", "nu-plugin", "nu-protocol", "nu-source", - "num-bigint 0.3.0", + "num-bigint 0.3.1", ] [[package]] @@ -3463,7 +3577,7 @@ dependencies = [ "nu-protocol", "nu-source", "term_size", - "url 2.1.1", + "url", ] [[package]] @@ -3476,7 +3590,7 @@ dependencies = [ "nu-protocol", "nu-source", "nu-value-ext", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3489,7 +3603,7 @@ dependencies = [ "nu-protocol", "nu-source", "nu-value-ext", - "num-traits 0.2.12", + "num-traits 0.2.14", "rusqlite", "tempfile", ] @@ -3532,7 +3646,7 @@ dependencies = [ "num-integer", "num-iter", "num-rational", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3541,21 +3655,21 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-integer", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] name = "num-bigint" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f3fc75e3697059fb1bc465e3d8cca6cf92f56854f201158b3f9c77d5a3cfa0" +checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-integer", - "num-traits 0.2.12", - "serde 1.0.115", + "num-traits 0.2.14", + "serde 1.0.117", ] [[package]] @@ -3564,8 +3678,8 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ - "autocfg 1.0.1", - "num-traits 0.2.12", + "autocfg", + "num-traits 0.2.14", ] [[package]] @@ -3581,23 +3695,23 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", - "num-traits 0.2.12", + "autocfg", + "num-traits 0.2.14", ] [[package]] name = "num-iter" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-integer", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3606,10 +3720,10 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-bigint 0.2.6", "num-integer", - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3618,16 +3732,16 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] name = "num-traits" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -3671,21 +3785,21 @@ dependencies = [ [[package]] name = "object" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[package]] name = "once_cell" -version = "1.4.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "onig" -version = "6.0.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd91ccd8a02fce2f7e8a86655aec67bc6c171e6f8e704118a0e8c4b866a05a8a" +checksum = "8a155d13862da85473665694f4c05d77fb96598bdceeaf696433c84ea9567e20" dependencies = [ "bitflags", "lazy_static 1.4.0", @@ -3695,9 +3809,9 @@ dependencies = [ [[package]] name = "onig_sys" -version = "69.5.0" +version = "69.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3814583fad89f3c60ae0701d80e87e1fd3028741723deda72d0d4a0ecf0cb0db" +checksum = "9bff06597a6b17855040955cae613af000fc0bfc8ad49ea68b9479a74e59292d" dependencies = [ "cc", "pkg-config", @@ -3731,7 +3845,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 0.1.10", "foreign-types", "lazy_static 1.4.0", "libc", @@ -3750,7 +3864,7 @@ version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cc", "libc", "pkg-config", @@ -3763,7 +3877,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" dependencies = [ - "num-traits 0.2.12", + "num-traits 0.2.14", ] [[package]] @@ -3801,12 +3915,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", - "lock_api 0.4.1", + "lock_api 0.4.2", "parking_lot_core 0.8.0", ] @@ -3816,7 +3930,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "cloudabi 0.0.3", "libc", "redox_syscall", @@ -3831,11 +3945,11 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "cloudabi 0.0.3", "libc", "redox_syscall", - "smallvec 1.4.2", + "smallvec 1.5.0", "winapi 0.3.9", ] @@ -3845,12 +3959,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "cloudabi 0.1.0", "instant", "libc", "redox_syscall", - "smallvec 1.4.2", + "smallvec 1.5.0", "winapi 0.3.9", ] @@ -3860,7 +3974,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" dependencies = [ - "regex 1.3.9", + "regex 1.4.2", ] [[package]] @@ -3999,18 +4113,38 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.23" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" dependencies = [ - "pin-project-internal", + "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.23" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" +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", @@ -4019,9 +4153,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.7" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +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" @@ -4031,9 +4171,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "platforms" @@ -4051,7 +4191,7 @@ dependencies = [ "chrono", "indexmap", "line-wrap", - "serde 1.0.115", + "serde 1.0.117", "xml-rs", ] @@ -4069,21 +4209,22 @@ dependencies = [ [[package]] name = "polling" -version = "0.1.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e09dffb745feffca5be3dea51c02b7b368c4597ab0219a82acaf9799ab3e0d1" +checksum = "e0720e0b9ea9d52451cf29d3413ba8a9303f8815d9d9653ef70e03ff73e65566" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", + "log 0.4.11", "wepoll-sys-stjepang", "winapi 0.3.9", ] [[package]] name = "ppv-lite86" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "precomputed-hash" @@ -4102,9 +4243,9 @@ dependencies = [ [[package]] name = "pretty-hex" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8a6a27f79f3ec19193cd2ecfe9b73276b79026529466aef45d70d0f9eca651b" +checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" [[package]] name = "pretty_env_logger" @@ -4142,9 +4283,9 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.18" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" @@ -4154,9 +4295,9 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -4196,24 +4337,11 @@ dependencies = [ "config", "directories 2.0.2", "petgraph", - "serde 1.0.115", + "serde 1.0.117", "serde-value", "tint", ] -[[package]] -name = "publicsuffix" -version = "1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" -dependencies = [ - "error-chain", - "idna 0.2.0", - "lazy_static 1.4.0", - "regex 1.3.9", - "url 2.1.1", -] - [[package]] name = "pulldown-cmark" version = "0.7.2" @@ -4251,20 +4379,20 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.17.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe1e430bdcf30c9fdc25053b9c459bb1a4672af4617b6c783d7d91dc17c6bbb0" +checksum = "3cc440ee4802a86e357165021e3e255a9143724da31db1e2ea540214c96a0f82" dependencies = [ - "encoding_rs", "memchr", ] [[package]] name = "quick-xml" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc440ee4802a86e357165021e3e255a9143724da31db1e2ea540214c96a0f82" +checksum = "b3d72d5477478f85bd00b6521780dfba1ec6cdaadcf90b8b181c36d7de561f9b" dependencies = [ + "encoding_rs", "memchr", ] @@ -4323,25 +4451,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg 0.1.2", - "rand_xorshift", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -4350,20 +4459,10 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", - "rand_pcg 0.2.1", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_hc", + "rand_pcg", ] [[package]] @@ -4400,15 +4499,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -4418,50 +4508,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi 0.0.3", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - [[package]] name = "rand_pcg" version = "0.2.1" @@ -4471,15 +4517,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rawkey" version = "0.1.3" @@ -4494,25 +4531,25 @@ dependencies = [ [[package]] name = "rayon" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd016f0c045ad38b5251be2c9c0ab806917f82da4d36b2a327e5166adad9270" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ - "autocfg 1.0.1", - "crossbeam-deque", + "autocfg", + "crossbeam-deque 0.8.0", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91739a34c4355b5434ce54c9086c5895604a9c278586d1f1aa95e04f66b525a0" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ - "crossbeam-channel 0.4.3", - "crossbeam-deque", - "crossbeam-utils 0.7.2", + "crossbeam-channel 0.5.0", + "crossbeam-deque 0.8.0", + "crossbeam-utils 0.8.0", "lazy_static 1.4.0", "num_cpus", ] @@ -4540,9 +4577,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_users" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom", "redox_syscall", @@ -4564,13 +4601,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.3.9" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" dependencies = [ - "aho-corasick 0.7.13", + "aho-corasick 0.7.15", "memchr", - "regex-syntax 0.6.18", + "regex-syntax 0.6.21", "thread_local 1.0.1", ] @@ -4594,9 +4631,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.18" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" [[package]] name = "relay" @@ -4604,7 +4641,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", ] [[package]] @@ -4618,35 +4655,37 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.9.24" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" +checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce" dependencies = [ - "base64 0.10.1", - "bytes 0.4.12", - "cookie", - "cookie_store", + "base64 0.13.0", + "bytes 0.5.6", "encoding_rs", - "flate2", - "futures 0.1.29", - "http", - "hyper 0.12.35", + "futures-core", + "futures-util", + "http 0.2.1", + "http-body", + "hyper 0.13.9", "hyper-tls", + "ipnet", + "js-sys", + "lazy_static 1.4.0", "log 0.4.11", "mime", "mime_guess", "native-tls", - "serde 1.0.115", - "serde_json", - "serde_urlencoded 0.5.5", - "time", - "tokio", - "tokio-executor", - "tokio-io", - "tokio-threadpool", - "tokio-timer", - "url 1.7.2", - "uuid 0.7.4", + "percent-encoding 2.1.0", + "pin-project-lite 0.2.0", + "serde 1.0.117", + "serde_urlencoded 0.7.0", + "tokio 0.2.23", + "tokio-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures 0.4.18", + "wasm-bindgen-test", + "web-sys", "winreg", ] @@ -4667,26 +4706,26 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c78c3275d9d6eb684d2db4b2388546b32fdae0586c20a82f3905d21ea78b9ef" +checksum = "7e3d4791ab5517217f51216a84a688b53c1ebf7988736469c538d02f46ddba68" dependencies = [ "bitflags", "fallible-iterator", "fallible-streaming-iterator", + "hashlink", "libsqlite3-sys", - "lru-cache", "memchr", - "smallvec 1.4.2", + "smallvec 1.5.0", ] [[package]] name = "rust-argon2" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ - "base64 0.11.0", + "base64 0.12.3", "blake2b_simd", "constant_time_eq", "crossbeam-utils 0.7.2", @@ -4752,14 +4791,14 @@ dependencies = [ "byteorder", "lazy_static 1.4.0", "num", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" [[package]] name = "rustc-serialize" @@ -4782,7 +4821,7 @@ version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0d5e7b0219a3eadd5439498525d4765c59b7c993ef0c12244865cd2d988413" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "dirs-next", "libc", "log 0.4.11", @@ -4803,9 +4842,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "s3handler" -version = "0.5.0" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4c00aaf216bd124a14126ecf2211f34563a1c309daf822172d10c453b63f6" +checksum = "8dd02f08af903cac8f3900ed75c04aca7404a8ba990889fe032fd96c943fcca2" dependencies = [ "base64 0.6.0", "chrono", @@ -4814,20 +4853,21 @@ dependencies = [ "failure_derive", "hmac", "hmac-sha1", - "http", + "http 0.1.21", "hyper 0.11.27", "log 0.4.11", "md5 0.3.8", + "mime_guess", "quick-xml 0.12.4", "regex 0.2.11", "reqwest", "rust-crypto", "rustc-serialize", - "serde 1.0.115", + "serde 1.0.117", "serde_derive", "serde_json", "sha2 0.6.0", - "url 2.1.1", + "url", ] [[package]] @@ -4881,24 +4921,24 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "security-framework" -version = "0.4.4" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69" dependencies = [ "bitflags", - "core-foundation", - "core-foundation-sys", + "core-foundation 0.9.1", + "core-foundation-sys 0.8.2", "libc", "security-framework-sys", ] [[package]] name = "security-framework-sys" -version = "0.4.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.8.2", "libc", ] @@ -4918,7 +4958,7 @@ dependencies = [ "phf_codegen", "precomputed-hash", "servo_arc", - "smallvec 1.4.2", + "smallvec 1.5.0", "thin-slice", ] @@ -4960,9 +5000,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" dependencies = [ "serde_derive", ] @@ -4976,7 +5016,7 @@ dependencies = [ "lazy_static 1.4.0", "linked-hash-map 0.3.0", "num-traits 0.1.43", - "regex 1.3.9", + "regex 1.4.2", "serde 0.8.23", ] @@ -4987,7 +5027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a65a7291a8a568adcae4c10a677ebcedbc6c9cec91c054dee2ce40b0e3290eb" dependencies = [ "ordered-float", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -4996,14 +5036,14 @@ version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" dependencies = [ - "serde 1.0.115", + "serde 1.0.117", ] [[package]] name = "serde_derive" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ "proc-macro2", "quote", @@ -5017,20 +5057,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139" dependencies = [ "result", - "serde 1.0.115", + "serde 1.0.117", "void", ] [[package]] name = "serde_json" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" dependencies = [ "indexmap", "itoa", "ryu", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -5042,18 +5082,6 @@ dependencies = [ "serde 0.8.23", ] -[[package]] -name = "serde_urlencoded" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -dependencies = [ - "dtoa", - "itoa", - "serde 1.0.115", - "url 1.7.2", -] - [[package]] name = "serde_urlencoded" version = "0.6.1" @@ -5062,8 +5090,8 @@ checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" dependencies = [ "dtoa", "itoa", - "serde 1.0.115", - "url 2.1.1", + "serde 1.0.117", + "url", ] [[package]] @@ -5075,18 +5103,18 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] name = "serde_yaml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5" +checksum = "f7baae0a99f1a324984bcdc5f0718384c1f69775f1c7eec8b859b71b443e3fd7" dependencies = [ "dtoa", "linked-hash-map 0.5.3", - "serde 1.0.115", + "serde 1.0.117", "yaml-rust", ] @@ -5133,12 +5161,12 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ "block-buffer 0.9.0", - "cfg-if", + "cfg-if 1.0.0", "cpuid-bool", "digest 0.9.0", "opaque-debug 0.3.0", @@ -5166,17 +5194,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" dependencies = [ "libc", - "mio 0.7.0", + "mio 0.7.6", "signal-hook-registry", ] [[package]] name = "signal-hook-registry" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" +checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" dependencies = [ - "arc-swap", "libc", ] @@ -5226,9 +5253,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" [[package]] name = "smol" @@ -5236,7 +5263,7 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" dependencies = [ - "async-task", + "async-task 3.0.0", "blocking 0.4.7", "concurrent-queue", "fastrand", @@ -5253,11 +5280,11 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.12" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "winapi 0.3.9", @@ -5281,26 +5308,17 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes 0.4.12", -] - [[package]] name = "string_cache" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a" +checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" dependencies = [ "lazy_static 1.4.0", "new_debug_unreachable", "phf_shared", "precomputed-hash", - "serde 1.0.115", + "serde 1.0.117", ] [[package]] @@ -5337,16 +5355,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "741a8008f8a833ef16f47df94a30754478fb2c2bf822b9c2e6f7f09203b97ace" dependencies = [ "futures-preview", - "http", + "http 0.1.21", "isahc", "js-sys", "log 0.4.11", "mime", "mime_guess", - "serde 1.0.115", + "serde 1.0.117", "serde_json", "serde_urlencoded 0.6.1", - "url 2.1.1", + "url", "wasm-bindgen", "wasm-bindgen-futures 0.3.27", "web-sys", @@ -5375,9 +5393,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.39" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" dependencies = [ "proc-macro2", "quote", @@ -5411,8 +5429,8 @@ dependencies = [ "lazycell", "onig", "plist", - "regex-syntax 0.6.18", - "serde 1.0.115", + "regex-syntax 0.6.21", + "serde 1.0.117", "serde_derive", "serde_json", "walkdir", @@ -5431,7 +5449,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "rand 0.7.3", "redox_syscall", @@ -5472,18 +5490,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13" +checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" dependencies = [ "libc", "winapi 0.3.9", @@ -5491,9 +5509,9 @@ dependencies = [ [[package]] name = "termios" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" dependencies = [ "libc", ] @@ -5516,18 +5534,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ "proc-macro2", "quote", @@ -5574,9 +5592,18 @@ dependencies = [ [[package]] name = "tinyvec" -version = "0.3.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" @@ -5585,7 +5612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "mio 0.6.22", "num_cpus", "tokio-codec", @@ -5603,14 +5630,21 @@ dependencies = [ ] [[package]] -name = "tokio-buf" -version = "0.1.1" +name = "tokio" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff" dependencies = [ - "bytes 0.4.12", - "either", - "futures 0.1.29", + "bytes 0.5.6", + "fnv", + "futures-core", + "iovec", + "lazy_static 1.4.0", + "memchr", + "mio 0.6.22", + "num_cpus", + "pin-project-lite 0.1.11", + "slab 0.4.2", ] [[package]] @@ -5620,7 +5654,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "tokio-io", ] @@ -5631,12 +5665,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "iovec", "log 0.4.11", "mio 0.6.22", "scoped-tls 0.1.2", - "tokio", + "tokio 0.1.22", "tokio-executor", "tokio-io", "tokio-reactor", @@ -5649,7 +5683,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "tokio-executor", ] @@ -5660,7 +5694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.30", ] [[package]] @@ -5669,7 +5703,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "tokio-io", "tokio-threadpool", ] @@ -5681,7 +5715,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "log 0.4.11", ] @@ -5691,7 +5725,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "log 0.3.9", "net2", "rand 0.3.23", @@ -5710,7 +5744,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.30", "lazy_static 1.4.0", "log 0.4.11", "mio 0.6.22", @@ -5728,7 +5762,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", ] [[package]] @@ -5738,7 +5772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ "fnv", - "futures 0.1.29", + "futures 0.1.30", ] [[package]] @@ -5748,7 +5782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "iovec", "mio 0.6.22", "tokio-io", @@ -5761,10 +5795,10 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" dependencies = [ - "crossbeam-deque", + "crossbeam-deque 0.7.3", "crossbeam-queue", "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.30", "lazy_static 1.4.0", "log 0.4.11", "num_cpus", @@ -5779,11 +5813,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.30", "slab 0.4.2", "tokio-executor", ] +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +dependencies = [ + "native-tls", + "tokio 0.2.23", +] + [[package]] name = "tokio-udp" version = "0.1.6" @@ -5791,7 +5835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "log 0.4.11", "mio 0.6.22", "tokio-codec", @@ -5806,7 +5850,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.30", "iovec", "libc", "log 0.4.11", @@ -5818,12 +5862,63 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.6" +name = "tokio-util" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "serde 1.0.115", + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log 0.4.11", + "pin-project-lite 0.1.11", + "tokio 0.2.23", +] + +[[package]] +name = "toml" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +dependencies = [ + "serde 1.0.117", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +dependencies = [ + "cfg-if 0.1.10", + "log 0.4.11", + "pin-project-lite 0.1.11", + "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 1.4.0", +] + +[[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]] @@ -5847,15 +5942,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" -[[package]] -name = "try_from" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -dependencies = [ - "cfg-if", -] - [[package]] name = "tui" version = "0.12.0" @@ -5864,7 +5950,7 @@ checksum = "c2eaeee894a1e9b90f80aa466fe59154fdb471980b5e104d8836fcea309ae17e" dependencies = [ "bitflags", "cassowary", - "crossterm 0.17.8", + "crossterm 0.17.7", "unicode-segmentation", "unicode-width", ] @@ -5919,18 +6005,18 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.13" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "db8716a166f290ff49dabc18b44aa407cb7c6dbe1aa0971b44b8a24b0ca35aae" [[package]] name = "unicode-width" @@ -5951,38 +6037,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "627142a1043c2d460613232ce4f7e322e756636e000c0f1d1f2e779cb431358a" dependencies = [ "num-rational", - "num-traits 0.2.12", + "num-traits 0.2.14", "typenum", ] [[package]] name = "uom" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb593f5252356bfb829112f8fca2d0982d48588d2d6bb5a92553b0dfc4c9aba" +checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed" dependencies = [ - "num-traits 0.2.12", + "num-traits 0.2.14", "typenum", ] [[package]] name = "url" -version = "1.7.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - -[[package]] -name = "url" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -dependencies = [ - "idna 0.2.0", + "form_urlencoded", + "idna", "matches", "percent-encoding 2.1.0", ] @@ -6037,15 +6113,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", -] - [[package]] name = "uuid" version = "0.8.1" @@ -6063,9 +6130,9 @@ checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" [[package]] name = "vec-arena" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb18268690309760d59ee1a9b21132c126ba384f374c59a94db4bc03adeb561" +checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" [[package]] name = "vec_map" @@ -6081,11 +6148,11 @@ checksum = "c7b77d2a6f56988f7bb54102fe73ab963df4e7374b58298a7efa1361f681e0e2" dependencies = [ "proc-macro2", "pulldown-cmark", - "regex 1.3.9", + "regex 1.4.2", "semver-parser 0.9.0", "syn", "toml", - "url 2.1.1", + "url", ] [[package]] @@ -6111,9 +6178,9 @@ dependencies = [ [[package]] name = "waker-fn" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9571542c2ce85ce642e6b58b3364da2fb53526360dfb7c211add4f5c23105ff7" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" @@ -6132,18 +6199,17 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" dependencies = [ - "futures 0.1.29", + "futures 0.1.30", "log 0.4.11", "try-lock 0.1.0", ] [[package]] name = "want" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ - "futures 0.1.29", "log 0.4.11", "try-lock 0.2.3", ] @@ -6162,19 +6228,21 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasm-bindgen" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0563a9a4b071746dd5aedbc3a28c6fe9be4586fb3fbadb67c400d4f53c6b16c" +checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", + "serde 1.0.117", + "serde_json", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc71e4c5efa60fb9e74160e89b93353bc24059999c0ae0fb03affc39770310b0" +checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" dependencies = [ "bumpalo", "lazy_static 1.4.0", @@ -6191,8 +6259,8 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" dependencies = [ - "cfg-if", - "futures 0.1.29", + "cfg-if 0.1.10", + "futures 0.1.30", "futures-channel-preview", "futures-util-preview", "js-sys", @@ -6203,11 +6271,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f8d235a77f880bcef268d379810ea6c0af2eacfa90b1ad5af731776e0c4699" +checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "js-sys", "wasm-bindgen", "web-sys", @@ -6215,9 +6283,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c57cefa5fa80e2ba15641578b44d36e7a64279bc5ed43c6dbaf329457a2ed2" +checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6225,9 +6293,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841a6d1c35c6f596ccea1f82504a192a60378f64b3bb0261904ad8f2f5657556" +checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" dependencies = [ "proc-macro2", "quote", @@ -6238,15 +6306,39 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93b162580e34310e5931c4b792560108b10fd14d64915d7fff8ff00180e70092" +checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls 1.0.0", + "wasm-bindgen", + "wasm-bindgen-futures 0.4.18", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585" +dependencies = [ + "proc-macro2", + "quote", +] [[package]] name = "web-sys" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda38f4e5ca63eda02c059d243aa25b5f35ab98451e518c51612cd0f1bd19a47" +checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" dependencies = [ "js-sys", "wasm-bindgen", @@ -6254,9 +6346,9 @@ dependencies = [ [[package]] name = "wepoll-sys-stjepang" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694" +checksum = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d" dependencies = [ "cc", ] @@ -6273,9 +6365,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a763e303c0e0f23b0da40888724762e802a8ffefbc22de4127ef42493c2ea68c" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" [[package]] name = "wild" @@ -6331,9 +6423,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winreg" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ "winapi 0.3.9", ] @@ -6385,9 +6477,9 @@ checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" [[package]] name = "xmlparser" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52613e655f6f11f63c0fe7d1c3b5ef69e44d96df9b65dab296b441ed0e1125f5" +checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8" [[package]] name = "yaml-rust" @@ -6400,9 +6492,9 @@ dependencies = [ [[package]] name = "zip" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30de6e58104bb7b9a94f34b52a2bdabb8a40b678a64201cd0069e3d7119b5ff" +checksum = "543adf038106b64cfca4711c82c917d785e3540e04f7996554488f988ec43124" dependencies = [ "byteorder", "bzip2", diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index c4977f09c6..e4798c36e3 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -12,6 +12,7 @@ doctest = false [dependencies] nu-data = {version = "0.22.0", path = "../nu-data"} nu-errors = {version = "0.22.0", path = "../nu-errors"} +nu-json = {version = "0.22.0", path = "../nu-json"} nu-parser = {version = "0.22.0", path = "../nu-parser"} nu-plugin = {version = "0.22.0", path = "../nu-plugin"} nu-protocol = {version = "0.22.0", path = "../nu-protocol"} @@ -70,7 +71,6 @@ roxmltree = "0.13.0" rust-embed = "5.6.0" rustyline = {version = "6.3.0", optional = true} serde = {version = "1.0.115", features = ["derive"]} -serde-hjson = "0.9.1" serde_bytes = "0.11.5" serde_ini = "0.2.0" serde_json = "1.0.57" diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 47fbba2934..e8ffa41bd6 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -845,8 +845,8 @@ fn rustyline_hinter(config: &dyn nu_data::config::Conf) -> Option &str { - if s.ends_with('\n') { - &s[..s.len() - 1] + if let Some(s) = s.strip_suffix('\n') { + s } else { s } @@ -863,8 +863,8 @@ pub enum LineResult { } pub async fn parse_and_eval(line: &str, ctx: &mut EvaluationContext) -> Result { - let line = if line.ends_with('\n') { - &line[..line.len() - 1] + let line = if let Some(s) = line.strip_suffix('\n') { + s } else { line }; diff --git a/crates/nu-cli/src/commands/clip.rs b/crates/nu-cli/src/commands/clip.rs index 72a62ada8e..d354c4a546 100644 --- a/crates/nu-cli/src/commands/clip.rs +++ b/crates/nu-cli/src/commands/clip.rs @@ -63,7 +63,7 @@ pub async fn clip( let mut first = true; for i in values.iter() { if !first { - new_copy_data.push_str("\n"); + new_copy_data.push('\n'); } else { first = false; } diff --git a/crates/nu-cli/src/commands/from_json.rs b/crates/nu-cli/src/commands/from_json.rs index 30da4ba06d..90ed0c92f6 100644 --- a/crates/nu-cli/src/commands/from_json.rs +++ b/crates/nu-cli/src/commands/from_json.rs @@ -37,26 +37,26 @@ impl WholeStreamCommand for FromJSON { } } -fn convert_json_value_to_nu_value(v: &serde_hjson::Value, tag: impl Into) -> Value { +fn convert_json_value_to_nu_value(v: &nu_json::Value, tag: impl Into) -> Value { let tag = tag.into(); let span = tag.span; match v { - serde_hjson::Value::Null => UntaggedValue::Primitive(Primitive::Nothing).into_value(&tag), - serde_hjson::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(&tag), - serde_hjson::Value::F64(n) => UntaggedValue::decimal_from_float(*n, span).into_value(&tag), - serde_hjson::Value::U64(n) => UntaggedValue::int(*n).into_value(&tag), - serde_hjson::Value::I64(n) => UntaggedValue::int(*n).into_value(&tag), - serde_hjson::Value::String(s) => { + nu_json::Value::Null => UntaggedValue::Primitive(Primitive::Nothing).into_value(&tag), + nu_json::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(&tag), + nu_json::Value::F64(n) => UntaggedValue::decimal_from_float(*n, span).into_value(&tag), + nu_json::Value::U64(n) => UntaggedValue::int(*n).into_value(&tag), + nu_json::Value::I64(n) => UntaggedValue::int(*n).into_value(&tag), + nu_json::Value::String(s) => { UntaggedValue::Primitive(Primitive::String(String::from(s))).into_value(&tag) } - serde_hjson::Value::Array(a) => UntaggedValue::Table( + nu_json::Value::Array(a) => UntaggedValue::Table( a.iter() .map(|x| convert_json_value_to_nu_value(x, &tag)) .collect(), ) .into_value(tag), - serde_hjson::Value::Object(o) => { + nu_json::Value::Object(o) => { let mut collected = TaggedDictBuilder::new(&tag); for (k, v) in o.iter() { collected.insert_value(k.clone(), convert_json_value_to_nu_value(v, &tag)); @@ -67,8 +67,8 @@ fn convert_json_value_to_nu_value(v: &serde_hjson::Value, tag: impl Into) - } } -pub fn from_json_string_to_value(s: String, tag: impl Into) -> serde_hjson::Result { - let v: serde_hjson::Value = serde_hjson::from_str(&s)?; +pub fn from_json_string_to_value(s: String, tag: impl Into) -> nu_json::Result { + let v: nu_json::Value = nu_json::from_str(&s)?; Ok(convert_json_value_to_nu_value(&v, tag)) } @@ -96,7 +96,7 @@ async fn from_json( Err(e) => { let mut message = "Could not parse as JSON (".to_string(); message.push_str(&e.to_string()); - message.push_str(")"); + message.push(')'); Some(Err(ShellError::labeled_error_with_secondary( message, @@ -125,7 +125,7 @@ async fn from_json( Err(e) => { let mut message = "Could not parse as JSON (".to_string(); message.push_str(&e.to_string()); - message.push_str(")"); + message.push(')'); Ok(OutputStream::one(Err( ShellError::labeled_error_with_secondary( diff --git a/crates/nu-cli/src/commands/from_yaml.rs b/crates/nu-cli/src/commands/from_yaml.rs index f7eaf0efac..865d236edf 100644 --- a/crates/nu-cli/src/commands/from_yaml.rs +++ b/crates/nu-cli/src/commands/from_yaml.rs @@ -68,13 +68,12 @@ fn convert_yaml_value_to_nu_value( Ok(match v { serde_yaml::Value::Bool(b) => UntaggedValue::boolean(*b).into_value(tag), serde_yaml::Value::Number(n) if n.is_i64() => { - UntaggedValue::int(n.as_i64().ok_or_else(|| err_not_compatible_number)?).into_value(tag) + UntaggedValue::int(n.as_i64().ok_or(err_not_compatible_number)?).into_value(tag) + } + serde_yaml::Value::Number(n) if n.is_f64() => { + UntaggedValue::decimal_from_float(n.as_f64().ok_or(err_not_compatible_number)?, span) + .into_value(tag) } - serde_yaml::Value::Number(n) if n.is_f64() => UntaggedValue::decimal_from_float( - n.as_f64().ok_or_else(|| err_not_compatible_number)?, - span, - ) - .into_value(tag), serde_yaml::Value::String(s) => UntaggedValue::string(s).into_value(tag), serde_yaml::Value::Sequence(a) => { let result: Result, ShellError> = a diff --git a/crates/nu-cli/src/commands/save.rs b/crates/nu-cli/src/commands/save.rs index e27c1ecfe8..ddab4526fe 100644 --- a/crates/nu-cli/src/commands/save.rs +++ b/crates/nu-cli/src/commands/save.rs @@ -264,7 +264,7 @@ fn string_from(input: &[Value]) -> String { let mut first = true; for i in input.iter() { if !first { - save_data.push_str("\n"); + save_data.push('\n'); } else { first = false; } diff --git a/crates/nu-cli/src/commands/seq.rs b/crates/nu-cli/src/commands/seq.rs index 810eaafefc..8d109882df 100644 --- a/crates/nu-cli/src/commands/seq.rs +++ b/crates/nu-cli/src/commands/seq.rs @@ -304,7 +304,7 @@ fn print_seq( let before_dec = istr.find('.').unwrap_or(ilen); if pad && before_dec < padding { for _ in 0..(padding - before_dec) { - ret_str.push_str("0"); + ret_str.push('0'); } } ret_str.push_str(&istr); diff --git a/crates/nu-cli/src/commands/to_md.rs b/crates/nu-cli/src/commands/to_md.rs index 3b810c73b3..b16e5e7745 100644 --- a/crates/nu-cli/src/commands/to_md.rs +++ b/crates/nu-cli/src/commands/to_md.rs @@ -127,22 +127,22 @@ fn get_output_string( let mut output_string = String::new(); if !headers.is_empty() { - output_string.push_str("|"); + output_string.push('|'); for i in 0..headers.len() { if pretty { - output_string.push_str(" "); + output_string.push(' '); output_string.push_str(&get_padded_string( headers[i].clone(), column_widths[i], ' ', )); - output_string.push_str(" "); + output_string.push(' '); } else { output_string.push_str(headers[i].as_str()); } - output_string.push_str("|"); + output_string.push('|'); } output_string.push_str("\n|"); @@ -150,43 +150,43 @@ fn get_output_string( #[allow(clippy::needless_range_loop)] for i in 0..headers.len() { if pretty { - output_string.push_str(" "); + output_string.push(' '); output_string.push_str(&get_padded_string( String::from("-"), column_widths[i], '-', )); - output_string.push_str(" "); + output_string.push(' '); } else { - output_string.push_str("-"); + output_string.push('-'); } - output_string.push_str("|"); + output_string.push('|'); } - output_string.push_str("\n"); + output_string.push('\n'); } for row in rows { if !headers.is_empty() { - output_string.push_str("|"); + output_string.push('|'); } for i in 0..row.len() { if pretty { - output_string.push_str(" "); + output_string.push(' '); output_string.push_str(&get_padded_string(row[i].clone(), column_widths[i], ' ')); - output_string.push_str(" "); + output_string.push(' '); } else { output_string.push_str(row[i].as_str()); } if !headers.is_empty() { - output_string.push_str("|"); + output_string.push('|'); } } - output_string.push_str("\n"); + output_string.push('\n'); } output_string diff --git a/crates/nu-cli/src/commands/update.rs b/crates/nu-cli/src/commands/update.rs index 08bd9a8d81..b749791e97 100644 --- a/crates/nu-cli/src/commands/update.rs +++ b/crates/nu-cli/src/commands/update.rs @@ -157,7 +157,7 @@ async fn process_row( None => OutputStream::one(Err(ShellError::labeled_error( "update could not find place to insert column", "column name", - field.maybe_span().unwrap_or_else(|| tag.span), + field.maybe_span().unwrap_or(tag.span), ))), }, Value { value: _, ref tag } => { @@ -166,7 +166,7 @@ async fn process_row( None => OutputStream::one(Err(ShellError::labeled_error( "update could not find place to insert column", "column name", - field.maybe_span().unwrap_or_else(|| tag.span), + field.maybe_span().unwrap_or(tag.span), ))), } } diff --git a/crates/nu-cli/src/documentation.rs b/crates/nu-cli/src/documentation.rs index e2b915b028..ca0a27653f 100644 --- a/crates/nu-cli/src/documentation.rs +++ b/crates/nu-cli/src/documentation.rs @@ -129,7 +129,7 @@ pub fn get_documentation( let mut long_desc = String::new(); long_desc.push_str(&cmd.usage()); - long_desc.push_str("\n"); + long_desc.push('\n'); let mut subcommands = vec![]; if !config.no_subcommands { @@ -144,7 +144,7 @@ pub fn get_documentation( let mut one_liner = String::new(); one_liner.push_str(&signature.name); - one_liner.push_str(" "); + one_liner.push(' '); for positional in &signature.positional { match &positional.0 { @@ -175,7 +175,7 @@ pub fn get_documentation( long_desc.push_str("\nSubcommands:\n"); subcommands.sort(); long_desc.push_str(&subcommands.join("\n")); - long_desc.push_str("\n"); + long_desc.push('\n'); } if !signature.positional.is_empty() || signature.rest_positional.is_some() { @@ -205,7 +205,7 @@ pub fn get_documentation( long_desc.push_str("\nExamples:"); } for example in examples { - long_desc.push_str("\n"); + long_desc.push('\n'); long_desc.push_str(" "); long_desc.push_str(example.description); @@ -218,7 +218,7 @@ pub fn get_documentation( } } - long_desc.push_str("\n"); + long_desc.push('\n'); long_desc } diff --git a/crates/nu-cli/src/env/environment_syncer.rs b/crates/nu-cli/src/env/environment_syncer.rs index 88509fca6f..6b3efc391e 100644 --- a/crates/nu-cli/src/env/environment_syncer.rs +++ b/crates/nu-cli/src/env/environment_syncer.rs @@ -50,7 +50,7 @@ impl EnvironmentSyncer { pub fn did_config_change(&mut self) -> bool { let config = self.config.lock(); - config.is_modified().unwrap_or_else(|_| false) + config.is_modified().unwrap_or(false) } pub fn reload(&mut self) { diff --git a/crates/nu-cli/src/env/host.rs b/crates/nu-cli/src/env/host.rs index cddcb276ce..11ba0ea0f8 100644 --- a/crates/nu-cli/src/env/host.rs +++ b/crates/nu-cli/src/env/host.rs @@ -126,7 +126,7 @@ impl Host for BasicHost { } fn width(&self) -> usize { - let (mut term_width, _) = term_size::dimensions().unwrap_or_else(|| (80, 20)); + let (mut term_width, _) = term_size::dimensions().unwrap_or((80, 20)); term_width -= 1; term_width } diff --git a/crates/nu-cli/src/examples.rs b/crates/nu-cli/src/examples.rs index c52cac460e..230fe1e76c 100644 --- a/crates/nu-cli/src/examples.rs +++ b/crates/nu-cli/src/examples.rs @@ -191,8 +191,8 @@ pub fn test_anchors(cmd: Command) -> Result<(), ShellError> { /// Parse and run a nushell pipeline fn parse_line(line: &str, ctx: &mut EvaluationContext) -> Result { - let line = if line.ends_with('\n') { - &line[..line.len() - 1] + let line = if let Some(line) = line.strip_suffix('\n') { + line } else { line }; diff --git a/crates/nu-cli/src/plugin.rs b/crates/nu-cli/src/plugin.rs index 0427959f38..c8dd67bf0a 100644 --- a/crates/nu-cli/src/plugin.rs +++ b/crates/nu-cli/src/plugin.rs @@ -156,7 +156,7 @@ pub fn scan(paths: Vec) -> Result Trying {:?}", path.display()); - build_plugin_command(&path).unwrap_or_else(|_| None) + build_plugin_command(&path).unwrap_or(None) } else { None } diff --git a/crates/nu-cli/tests/commands/alias.rs b/crates/nu-cli/tests/commands/alias.rs index 6d7127aa0c..84334008d7 100644 --- a/crates/nu-cli/tests/commands/alias.rs +++ b/crates/nu-cli/tests/commands/alias.rs @@ -61,7 +61,7 @@ mod tests { ); //If this fails for you, check for any special unicode characters in your ~ path - assert!(actual.out.chars().filter(|c| c.clone() == '/').count() == 2); + assert!(actual.out.chars().filter(|c| *c == '/').count() == 2); #[cfg(target_os = "linux")] assert!(actual.out.contains("home")); #[cfg(target_os = "macos")] diff --git a/crates/nu-cli/tests/commands/save.rs b/crates/nu-cli/tests/commands/save.rs index f19f3620e9..70eb3937bf 100644 --- a/crates/nu-cli/tests/commands/save.rs +++ b/crates/nu-cli/tests/commands/save.rs @@ -33,29 +33,17 @@ fn figures_out_intelligently_where_to_write_out_with_metadata() { #[test] fn writes_out_csv() { Playground::setup("save_test_2", |dirs, sandbox| { - sandbox.with_files(vec![FileWithContent( - "cargo_sample.json", - r#" - { - "package": { - "name": "nu", - "version": "0.14", - "description": "A new type of shell", - "license": "MIT", - "edition": "2018" - } - } - "#, - )]); + sandbox.with_files(vec![]); let expected_file = dirs.test().join("cargo_sample.csv"); nu!( cwd: dirs.root(), - "open save_test_2/cargo_sample.json | get package | save save_test_2/cargo_sample.csv", + r#"echo [[name, version, description, license, edition]; [nu, "0.14", "A new type of shell", "MIT", "2018"]] | save save_test_2/cargo_sample.csv"#, ); let actual = file_contents(expected_file); + println!("{}", actual); assert!(actual.contains("nu,0.14,A new type of shell,MIT,2018")); }) } diff --git a/crates/nu-cli/tests/commands/uniq.rs b/crates/nu-cli/tests/commands/uniq.rs index 65a84e6f21..7433817613 100644 --- a/crates/nu-cli/tests/commands/uniq.rs +++ b/crates/nu-cli/tests/commands/uniq.rs @@ -150,18 +150,24 @@ fn uniq_counting() { | from json | wrap item | uniq --count + | where item == A + | get count "# )); - let expected = nu!( + assert_eq!(actual.out, "2"); + + let actual = nu!( cwd: "tests/fixtures/formats", pipeline( r#" - echo '[{"item": "A", "count": 2}, {"item": "B", "count": 1}]' - | from json + echo '["A", "B", "A"]' + | from json + | wrap item + | uniq --count + | where item == B + | get count "# )); - print!("{}", actual.out); - print!("{}", expected.out); - assert_eq!(actual.out, expected.out); + assert_eq!(actual.out, "1"); } #[test] diff --git a/crates/nu-json/Cargo.toml b/crates/nu-json/Cargo.toml new file mode 100644 index 0000000000..2a7ecef64f --- /dev/null +++ b/crates/nu-json/Cargo.toml @@ -0,0 +1,15 @@ +[package] +authors = ["The Nu Project Contributors", "Christian Zangl "] +description = "Fork of serde-hjson" +edition = "2018" +license = "MIT" +name = "nu-json" +version = "0.22.0" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = "^0.8.0" +num-traits = "~0.1.32" +regex = "^1.0" +lazy_static = "1" diff --git a/crates/nu-json/LICENSE b/crates/nu-json/LICENSE new file mode 100644 index 0000000000..e6fee54fa8 --- /dev/null +++ b/crates/nu-json/LICENSE @@ -0,0 +1,29 @@ +The MIT License (MIT) + +Copyright (c) 2014 The Rust Project Developers +Copyright (c) 2016 Christian Zangl +Copyright (c) 2020 The Nu Project Contributors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/crates/nu-json/src/builder.rs b/crates/nu-json/src/builder.rs new file mode 100644 index 0000000000..5452a1211d --- /dev/null +++ b/crates/nu-json/src/builder.rs @@ -0,0 +1,121 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use serde::ser; + +use crate::value::{self, Map, Value}; + +/// This structure provides a simple interface for constructing a JSON array. +pub struct ArrayBuilder { + array: Vec, +} + +impl Default for ArrayBuilder { + fn default() -> Self { + Self::new() + } +} + +impl ArrayBuilder { + /// Construct an `ObjectBuilder`. + pub fn new() -> ArrayBuilder { + ArrayBuilder { array: Vec::new() } + } + + /// Return the constructed `Value`. + pub fn unwrap(self) -> Value { + Value::Array(self.array) + } + + /// Insert a value into the array. + pub fn push(mut self, v: T) -> ArrayBuilder { + self.array.push(value::to_value(&v)); + self + } + + /// Creates and passes an `ArrayBuilder` into a closure, then inserts the resulting array into + /// this array. + pub fn push_array(mut self, f: F) -> ArrayBuilder + where + F: FnOnce(ArrayBuilder) -> ArrayBuilder, + { + let builder = ArrayBuilder::new(); + self.array.push(f(builder).unwrap()); + self + } + + /// Creates and passes an `ArrayBuilder` into a closure, then inserts the resulting object into + /// this array. + pub fn push_object(mut self, f: F) -> ArrayBuilder + where + F: FnOnce(ObjectBuilder) -> ObjectBuilder, + { + let builder = ObjectBuilder::new(); + self.array.push(f(builder).unwrap()); + self + } +} + +/// This structure provides a simple interface for constructing a JSON object. +pub struct ObjectBuilder { + object: Map, +} + +impl Default for ObjectBuilder { + fn default() -> Self { + Self::new() + } +} + +impl ObjectBuilder { + /// Construct an `ObjectBuilder`. + pub fn new() -> ObjectBuilder { + ObjectBuilder { object: Map::new() } + } + + /// Return the constructed `Value`. + pub fn unwrap(self) -> Value { + Value::Object(self.object) + } + + /// Insert a key-value pair into the object. + pub fn insert(mut self, key: S, value: V) -> ObjectBuilder + where + S: Into, + V: ser::Serialize, + { + self.object.insert(key.into(), value::to_value(&value)); + self + } + + /// Creates and passes an `ObjectBuilder` into a closure, then inserts the resulting array into + /// this object. + pub fn insert_array(mut self, key: S, f: F) -> ObjectBuilder + where + S: Into, + F: FnOnce(ArrayBuilder) -> ArrayBuilder, + { + let builder = ArrayBuilder::new(); + self.object.insert(key.into(), f(builder).unwrap()); + self + } + + /// Creates and passes an `ObjectBuilder` into a closure, then inserts the resulting object into + /// this object. + pub fn insert_object(mut self, key: S, f: F) -> ObjectBuilder + where + S: Into, + F: FnOnce(ObjectBuilder) -> ObjectBuilder, + { + let builder = ObjectBuilder::new(); + self.object.insert(key.into(), f(builder).unwrap()); + self + } +} diff --git a/crates/nu-json/src/de.rs b/crates/nu-json/src/de.rs new file mode 100644 index 0000000000..b11906ff97 --- /dev/null +++ b/crates/nu-json/src/de.rs @@ -0,0 +1,951 @@ +//! Hjson Deserialization +//! +//! This module provides for Hjson deserialization with the type `Deserializer`. + +use std::char; +use std::io; +use std::marker::PhantomData; +use std::str; + +use serde::de; + +use super::error::{Error, ErrorCode, Result}; +use super::util::StringReader; +use super::util::{Number, ParseNumber}; + +enum State { + Normal, + Root, + Keyname, +} + +/// A structure that deserializes Hjson into Rust values. +pub struct Deserializer> { + rdr: StringReader, + str_buf: Vec, + state: State, +} + +// macro_rules! try_or_invalid { +// ($self_:expr, $e:expr) => { +// match $e { +// Some(v) => v, +// None => { return Err($self_.error(ErrorCode::InvalidNumber)); } +// } +// } +// } + +impl Deserializer +where + Iter: Iterator, +{ + /// Creates the Hjson parser from an `std::iter::Iterator`. + #[inline] + pub fn new(rdr: Iter) -> Deserializer { + Deserializer { + rdr: StringReader::new(rdr), + str_buf: Vec::with_capacity(128), + state: State::Normal, + } + } + + /// Creates the Hjson parser from an `std::iter::Iterator`. + #[inline] + pub fn new_for_root(rdr: Iter) -> Deserializer { + let mut res = Deserializer::new(rdr); + res.state = State::Root; + res + } + + /// The `Deserializer::end` method should be called after a value has been fully deserialized. + /// This allows the `Deserializer` to validate that the input stream is at the end or that it + /// only has trailing whitespace. + #[inline] + pub fn end(&mut self) -> Result<()> { + self.rdr.parse_whitespace()?; + if self.rdr.eof()? { + Ok(()) + } else { + Err(self.rdr.error(ErrorCode::TrailingCharacters)) + } + } + + fn is_punctuator_char(&mut self, ch: u8) -> bool { + matches!(ch, b'{' | b'}' | b'[' | b']' | b',' | b':') + } + + fn parse_keyname(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + // quotes for keys are optional in Hjson + // unless they include {}[],: or whitespace. + // assume whitespace was already eaten + + self.str_buf.clear(); + + let mut space: Option = None; + loop { + let ch = self.rdr.next_char_or_null()?; + + if ch == b':' { + if self.str_buf.is_empty() { + return Err(self.rdr.error(ErrorCode::Custom( + "Found ':' but no key name (for an empty key name use quotes)".to_string(), + ))); + } else if space.is_some() + && space.expect("Internal error: json parsing") != self.str_buf.len() + { + return Err(self.rdr.error(ErrorCode::Custom( + "Found whitespace in your key name (use quotes to include)".to_string(), + ))); + } + self.rdr.uneat_char(ch); + let s = str::from_utf8(&self.str_buf).expect("Internal error: json parsing"); + return visitor.visit_str(s); + } else if ch <= b' ' { + if ch == 0 { + return Err(self.rdr.error(ErrorCode::EOFWhileParsingObject)); + } else if space.is_none() { + space = Some(self.str_buf.len()); + } + } else if self.is_punctuator_char(ch) { + return Err(self.rdr.error(ErrorCode::Custom("Found a punctuator where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace)".to_string()))); + } else { + self.str_buf.push(ch); + } + } + } + + fn parse_value(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + self.rdr.parse_whitespace()?; + + if self.rdr.eof()? { + return Err(self.rdr.error(ErrorCode::EOFWhileParsingValue)); + } + + match self.state { + State::Keyname => { + self.state = State::Normal; + return self.parse_keyname(visitor); + } + State::Root => { + self.state = State::Normal; + return visitor.visit_map(MapVisitor::new(self, true)); + } + _ => {} + } + + let value = match self.rdr.peek_or_null()? { + /* + b'-' => { + self.rdr.eat_char(); + self.parse_integer(false, visitor) + } + b'0' ..= b'9' => { + self.parse_integer(true, visitor) + } + */ + b'"' => { + self.rdr.eat_char(); + self.parse_string()?; + let s = str::from_utf8(&self.str_buf).expect("Internal error: json parsing"); + visitor.visit_str(s) + } + b'[' => { + self.rdr.eat_char(); + visitor.visit_seq(SeqVisitor::new(self)) + } + b'{' => { + self.rdr.eat_char(); + visitor.visit_map(MapVisitor::new(self, false)) + } + b'\x00' => Err(self.rdr.error(ErrorCode::ExpectedSomeValue)), + _ => self.parse_tfnns(visitor), + }; + + match value { + Ok(value) => Ok(value), + Err(Error::Syntax(code, _, _)) => Err(self.rdr.error(code)), + Err(err) => Err(err), + } + } + + fn parse_ident(&mut self, ident: &[u8]) -> Result<()> { + for c in ident { + if Some(*c) != self.rdr.next_char()? { + return Err(self.rdr.error(ErrorCode::ExpectedSomeIdent)); + } + } + + Ok(()) + } + + fn parse_tfnns(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + // Hjson strings can be quoteless + // returns string, true, false, or null. + self.str_buf.clear(); + + let first = self.rdr.peek()?.expect("Internal error: json parsing"); + + if self.is_punctuator_char(first) { + return Err(self.rdr.error(ErrorCode::PunctuatorInQlString)); + } + + loop { + let ch = self.rdr.next_char_or_null()?; + + let is_eol = ch == b'\r' || ch == b'\n' || ch == b'\x00'; + let is_comment = ch == b'#' + || if ch == b'/' { + let next = self.rdr.peek_or_null()?; + next == b'/' || next == b'*' + } else { + false + }; + if is_eol || is_comment || ch == b',' || ch == b'}' || ch == b']' { + let chf = self.str_buf[0]; + match chf { + b'f' => { + if str::from_utf8(&self.str_buf) + .expect("Internal error: json parsing") + .trim() + == "false" + { + self.rdr.uneat_char(ch); + return visitor.visit_bool(false); + } + } + b'n' => { + if str::from_utf8(&self.str_buf) + .expect("Internal error: json parsing") + .trim() + == "null" + { + self.rdr.uneat_char(ch); + return visitor.visit_unit(); + } + } + b't' => { + if str::from_utf8(&self.str_buf) + .expect("Internal error: json parsing") + .trim() + == "true" + { + self.rdr.uneat_char(ch); + return visitor.visit_bool(true); + } + } + _ => { + if chf == b'-' || chf >= b'0' && chf <= b'9' { + let mut pn = ParseNumber::new(self.str_buf.iter().cloned()); + match pn.parse(false) { + Ok(Number::F64(v)) => { + self.rdr.uneat_char(ch); + return visitor.visit_f64(v); + } + Ok(Number::U64(v)) => { + self.rdr.uneat_char(ch); + return visitor.visit_u64(v); + } + Ok(Number::I64(v)) => { + self.rdr.uneat_char(ch); + return visitor.visit_i64(v); + } + Err(_) => {} // not a number, continue + } + } + } + } + if is_eol { + // remove any whitespace at the end (ignored in quoteless strings) + return visitor.visit_str( + str::from_utf8(&self.str_buf) + .expect("Internal error: json parsing") + .trim(), + ); + } + } + self.str_buf.push(ch); + + if self.str_buf == vec![b'\''; 3] { + return self.parse_ml_string(visitor); + } + } + } + + fn decode_hex_escape(&mut self) -> Result { + let mut i = 0; + let mut n = 0u16; + while i < 4 && !(self.rdr.eof()?) { + n = match self.rdr.next_char_or_null()? { + c @ b'0'..=b'9' => n * 16_u16 + ((c as u16) - (b'0' as u16)), + b'a' | b'A' => n * 16_u16 + 10_u16, + b'b' | b'B' => n * 16_u16 + 11_u16, + b'c' | b'C' => n * 16_u16 + 12_u16, + b'd' | b'D' => n * 16_u16 + 13_u16, + b'e' | b'E' => n * 16_u16 + 14_u16, + b'f' | b'F' => n * 16_u16 + 15_u16, + _ => { + return Err(self.rdr.error(ErrorCode::InvalidEscape)); + } + }; + + i += 1; + } + + // Error out if we didn't parse 4 digits. + if i != 4 { + return Err(self.rdr.error(ErrorCode::InvalidEscape)); + } + + Ok(n) + } + + fn ml_skip_white(&mut self) -> Result { + match self.rdr.peek_or_null()? { + b' ' | b'\t' | b'\r' => { + self.rdr.eat_char(); + Ok(true) + } + _ => Ok(false), + } + } + + fn ml_skip_indent(&mut self, indent: usize) -> Result<()> { + let mut skip = indent; + while self.ml_skip_white()? && skip > 0 { + skip -= 1; + } + Ok(()) + } + + fn parse_ml_string(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + self.str_buf.clear(); + + // Parse a multiline string value. + let mut triple = 0; + + // we are at ''' +1 - get indent + let (_, col) = self.rdr.pos(); + let indent = col - 4; + + // skip white/to (newline) + while self.ml_skip_white()? {} + if self.rdr.peek_or_null()? == b'\n' { + self.rdr.eat_char(); + self.ml_skip_indent(indent)?; + } + + // When parsing multiline string values, we must look for ' characters. + loop { + if self.rdr.eof()? { + return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + } // todo error("Bad multiline string"); + let ch = self.rdr.next_char_or_null()?; + + if ch == b'\'' { + triple += 1; + if triple == 3 { + if self.str_buf.last() == Some(&b'\n') { + self.str_buf.pop(); + } + let res = str::from_utf8(&self.str_buf).expect("Internal error: json parsing"); + //todo if (self.str_buf.slice(-1) === '\n') self.str_buf=self.str_buf.slice(0, -1); // remove last EOL + return visitor.visit_str(res); + } else { + continue; + } + } + + while triple > 0 { + self.str_buf.push(b'\''); + triple -= 1; + } + + if ch != b'\r' { + self.str_buf.push(ch); + } + if ch == b'\n' { + self.ml_skip_indent(indent)?; + } + } + } + + fn parse_string(&mut self) -> Result<()> { + self.str_buf.clear(); + + loop { + let ch = match self.rdr.next_char()? { + Some(ch) => ch, + None => { + return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + } + }; + + match ch { + b'"' => { + return Ok(()); + } + b'\\' => { + let ch = match self.rdr.next_char()? { + Some(ch) => ch, + None => { + return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + } + }; + + match ch { + b'"' => self.str_buf.push(b'"'), + b'\\' => self.str_buf.push(b'\\'), + b'/' => self.str_buf.push(b'/'), + b'b' => self.str_buf.push(b'\x08'), + b'f' => self.str_buf.push(b'\x0c'), + b'n' => self.str_buf.push(b'\n'), + b'r' => self.str_buf.push(b'\r'), + b't' => self.str_buf.push(b'\t'), + b'u' => { + let c = match self.decode_hex_escape()? { + 0xDC00..=0xDFFF => { + return Err(self + .rdr + .error(ErrorCode::LoneLeadingSurrogateInHexEscape)); + } + + // Non-BMP characters are encoded as a sequence of + // two hex escapes, representing UTF-16 surrogates. + n1 @ 0xD800..=0xDBFF => { + match (self.rdr.next_char()?, self.rdr.next_char()?) { + (Some(b'\\'), Some(b'u')) => (), + _ => { + return Err(self + .rdr + .error(ErrorCode::UnexpectedEndOfHexEscape)); + } + } + + let n2 = self.decode_hex_escape()?; + + if n2 < 0xDC00 || n2 > 0xDFFF { + return Err(self + .rdr + .error(ErrorCode::LoneLeadingSurrogateInHexEscape)); + } + + let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + + 0x1_0000; + + match char::from_u32(n as u32) { + Some(c) => c, + None => { + return Err(self + .rdr + .error(ErrorCode::InvalidUnicodeCodePoint)); + } + } + } + + n => match char::from_u32(n as u32) { + Some(c) => c, + None => { + return Err(self + .rdr + .error(ErrorCode::InvalidUnicodeCodePoint)); + } + }, + }; + + // FIXME: this allocation is required in order to be compatible with stable + // rust, which doesn't support encoding a `char` into a stack buffer. + let mut buf = String::new(); + buf.push(c); + self.str_buf.extend(buf.bytes()); + } + _ => { + return Err(self.rdr.error(ErrorCode::InvalidEscape)); + } + } + } + ch => { + self.str_buf.push(ch); + } + } + } + } + + fn parse_object_colon(&mut self) -> Result<()> { + self.rdr.parse_whitespace()?; + + match self.rdr.next_char()? { + Some(b':') => Ok(()), + Some(_) => Err(self.rdr.error(ErrorCode::ExpectedColon)), + None => Err(self.rdr.error(ErrorCode::EOFWhileParsingObject)), + } + } +} + +impl de::Deserializer for Deserializer +where + Iter: Iterator, +{ + type Error = Error; + + #[inline] + fn deserialize(&mut self, visitor: V) -> Result + where + V: de::Visitor, + { + self.parse_value(visitor) + } + + /// Parses a `null` as a None, and any other values as a `Some(...)`. + #[inline] + fn deserialize_option(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + self.rdr.parse_whitespace()?; + + match self.rdr.peek_or_null()? { + b'n' => { + self.rdr.eat_char(); + self.parse_ident(b"ull")?; + visitor.visit_none() + } + _ => visitor.visit_some(self), + } + } + + /// Parses a newtype struct as the underlying value. + #[inline] + fn deserialize_newtype_struct(&mut self, _name: &str, mut visitor: V) -> Result + where + V: de::Visitor, + { + visitor.visit_newtype_struct(self) + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_enum(name: &'static str, variants: &'static [&'static str]); + deserialize_ignored_any(); + } +} + +struct SeqVisitor<'a, Iter: 'a + Iterator> { + de: &'a mut Deserializer, +} + +impl<'a, Iter: Iterator> SeqVisitor<'a, Iter> { + fn new(de: &'a mut Deserializer) -> Self { + SeqVisitor { de } + } +} + +impl<'a, Iter> de::SeqVisitor for SeqVisitor<'a, Iter> +where + Iter: Iterator, +{ + type Error = Error; + + fn visit(&mut self) -> Result> + where + T: de::Deserialize, + { + self.de.rdr.parse_whitespace()?; + + match self.de.rdr.peek()? { + Some(b']') => { + return Ok(None); + } + Some(_) => {} + None => { + return Err(self.de.rdr.error(ErrorCode::EOFWhileParsingList)); + } + } + + let value = de::Deserialize::deserialize(self.de)?; + + // in Hjson the comma is optional and trailing commas are allowed + self.de.rdr.parse_whitespace()?; + if self.de.rdr.peek()? == Some(b',') { + self.de.rdr.eat_char(); + self.de.rdr.parse_whitespace()?; + } + + Ok(Some(value)) + } + + fn end(&mut self) -> Result<()> { + self.de.rdr.parse_whitespace()?; + + match self.de.rdr.next_char()? { + Some(b']') => Ok(()), + Some(_) => Err(self.de.rdr.error(ErrorCode::TrailingCharacters)), + None => Err(self.de.rdr.error(ErrorCode::EOFWhileParsingList)), + } + } +} + +struct MapVisitor<'a, Iter: 'a + Iterator> { + de: &'a mut Deserializer, + first: bool, + root: bool, +} + +impl<'a, Iter: Iterator> MapVisitor<'a, Iter> { + fn new(de: &'a mut Deserializer, root: bool) -> Self { + MapVisitor { + de, + first: true, + root, + } + } +} + +impl<'a, Iter> de::MapVisitor for MapVisitor<'a, Iter> +where + Iter: Iterator, +{ + type Error = Error; + + fn visit_key(&mut self) -> Result> + where + K: de::Deserialize, + { + self.de.rdr.parse_whitespace()?; + + if self.first { + self.first = false; + } else if self.de.rdr.peek()? == Some(b',') { + // in Hjson the comma is optional and trailing commas are allowed + self.de.rdr.eat_char(); + self.de.rdr.parse_whitespace()?; + } + + match self.de.rdr.peek()? { + Some(b'}') => return Ok(None), // handled later for root + Some(_) => {} + None => { + if self.root { + return Ok(None); + } else { + return Err(self.de.rdr.error(ErrorCode::EOFWhileParsingObject)); + } + } + } + + match self.de.rdr.peek()? { + Some(ch) => { + self.de.state = if ch == b'"' { + State::Normal + } else { + State::Keyname + }; + Ok(Some(de::Deserialize::deserialize(self.de)?)) + } + None => Err(self.de.rdr.error(ErrorCode::EOFWhileParsingValue)), + } + } + + fn visit_value(&mut self) -> Result + where + V: de::Deserialize, + { + self.de.parse_object_colon()?; + + Ok(de::Deserialize::deserialize(self.de)?) + } + + fn end(&mut self) -> Result<()> { + self.de.rdr.parse_whitespace()?; + + match self.de.rdr.next_char()? { + Some(b'}') => { + if !self.root { + Ok(()) + } else { + Err(self.de.rdr.error(ErrorCode::TrailingCharacters)) + } // todo + } + Some(_) => Err(self.de.rdr.error(ErrorCode::TrailingCharacters)), + None => { + if self.root { + Ok(()) + } else { + Err(self.de.rdr.error(ErrorCode::EOFWhileParsingObject)) + } + } + } + } + + fn missing_field(&mut self, field: &'static str) -> Result + where + V: de::Deserialize, + { + struct MissingFieldDeserializer(&'static str); + + impl de::Deserializer for MissingFieldDeserializer { + type Error = de::value::Error; + + fn deserialize(&mut self, _visitor: V) -> std::result::Result + where + V: de::Visitor, + { + let &mut MissingFieldDeserializer(field) = self; + Err(de::value::Error::MissingField(field)) + } + + fn deserialize_option( + &mut self, + mut visitor: V, + ) -> std::result::Result + where + V: de::Visitor, + { + visitor.visit_none() + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_newtype_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_enum(name: &'static str, variants: &'static [&'static str]); + deserialize_ignored_any(); + } + } + + let mut de = MissingFieldDeserializer(field); + Ok(de::Deserialize::deserialize(&mut de)?) + } +} + +impl de::VariantVisitor for Deserializer +where + Iter: Iterator, +{ + type Error = Error; + + fn visit_variant(&mut self) -> Result + where + V: de::Deserialize, + { + let val = de::Deserialize::deserialize(self)?; + self.parse_object_colon()?; + Ok(val) + } + + fn visit_unit(&mut self) -> Result<()> { + de::Deserialize::deserialize(self) + } + + fn visit_newtype(&mut self) -> Result + where + T: de::Deserialize, + { + de::Deserialize::deserialize(self) + } + + fn visit_tuple(&mut self, _len: usize, visitor: V) -> Result + where + V: de::Visitor, + { + de::Deserializer::deserialize(self, visitor) + } + + fn visit_struct(&mut self, _fields: &'static [&'static str], visitor: V) -> Result + where + V: de::Visitor, + { + de::Deserializer::deserialize(self, visitor) + } +} + +////////////////////////////////////////////////////////////////////////////// + +/// Iterator that deserializes a stream into multiple Hjson values. +pub struct StreamDeserializer +where + Iter: Iterator, + T: de::Deserialize, +{ + deser: Deserializer, + _marker: PhantomData, +} + +impl StreamDeserializer +where + Iter: Iterator, + T: de::Deserialize, +{ + /// Returns an `Iterator` of decoded Hjson values from an iterator over + /// `Iterator`. + pub fn new(iter: Iter) -> StreamDeserializer { + StreamDeserializer { + deser: Deserializer::new(iter), + _marker: PhantomData, + } + } +} + +impl Iterator for StreamDeserializer +where + Iter: Iterator, + T: de::Deserialize, +{ + type Item = Result; + + fn next(&mut self) -> Option> { + // skip whitespaces, if any + // this helps with trailing whitespaces, since whitespaces between + // values are handled for us. + if let Err(e) = self.deser.rdr.parse_whitespace() { + return Some(Err(e)); + }; + + match self.deser.rdr.eof() { + Ok(true) => None, + Ok(false) => match de::Deserialize::deserialize(&mut self.deser) { + Ok(v) => Some(Ok(v)), + Err(e) => Some(Err(e)), + }, + Err(e) => Some(Err(e)), + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +/// Decodes a Hjson value from an iterator over an iterator +/// `Iterator`. +pub fn from_iter(iter: I) -> Result +where + I: Iterator>, + T: de::Deserialize, +{ + let fold: io::Result> = iter.collect(); + if let Err(e) = fold { + return Err(Error::Io(e)); + } + + let bytes = fold.expect("Internal error: json parsing"); + + // deserialize tries first to decode with legacy support (new_for_root) + // and then with the standard method if this fails. + // todo: add compile switch + + // deserialize and make sure the whole stream has been consumed + let mut de = Deserializer::new_for_root(bytes.iter().cloned()); + let value = match de::Deserialize::deserialize(&mut de).and_then(|x| { + de.end()?; + Ok(x) + }) { + Ok(v) => Ok(v), + Err(_) => { + let mut de2 = Deserializer::new(bytes.iter().cloned()); + match de::Deserialize::deserialize(&mut de2).and_then(|x| { + de2.end()?; + Ok(x) + }) { + Ok(v) => Ok(v), + Err(e) => Err(e), + } + } + }; + + /* without legacy support: + // deserialize and make sure the whole stream has been consumed + let mut de = Deserializer::new(bytes.iter().map(|b| *b)); + let value = match de::Deserialize::deserialize(&mut de) + .and_then(|x| { de.end()); Ok(x) }) + { + Ok(v) => Ok(v), + Err(e) => Err(e), + }; + */ + + value +} + +/// Decodes a Hjson value from a `std::io::Read`. +pub fn from_reader(rdr: R) -> Result +where + R: io::Read, + T: de::Deserialize, +{ + from_iter(rdr.bytes()) +} + +/// Decodes a Hjson value from a byte slice `&[u8]`. +pub fn from_slice(v: &[u8]) -> Result +where + T: de::Deserialize, +{ + from_iter(v.iter().map(|byte| Ok(*byte))) +} + +/// Decodes a Hjson value from a `&str`. +pub fn from_str(s: &str) -> Result +where + T: de::Deserialize, +{ + from_slice(s.as_bytes()) +} diff --git a/crates/nu-json/src/error.rs b/crates/nu-json/src/error.rs new file mode 100644 index 0000000000..a20bf5f6fa --- /dev/null +++ b/crates/nu-json/src/error.rs @@ -0,0 +1,243 @@ +//! JSON Errors +//! +//! This module is centered around the `Error` and `ErrorCode` types, which represents all possible +//! `serde_hjson` errors. + +use std::error; +use std::fmt; +use std::io; +use std::result; +use std::string::FromUtf8Error; + +use serde::de; +use serde::ser; + +/// The errors that can arise while parsing a JSON stream. +#[derive(Clone, PartialEq)] +pub enum ErrorCode { + /// Catchall for syntax error messages + Custom(String), + + /// Incorrect type from value + InvalidType(de::Type), + + /// Incorrect value + InvalidValue(String), + + /// Invalid length + InvalidLength(usize), + + /// Unknown variant in an enum. + UnknownVariant(String), + + /// Unknown field in struct. + UnknownField(String), + + /// Struct is missing a field. + MissingField(&'static str), + + /// EOF while parsing a list. + EOFWhileParsingList, + + /// EOF while parsing an object. + EOFWhileParsingObject, + + /// EOF while parsing a string. + EOFWhileParsingString, + + /// EOF while parsing a JSON value. + EOFWhileParsingValue, + + /// Expected this character to be a `':'`. + ExpectedColon, + + /// Expected this character to be either a `','` or a `]`. + ExpectedListCommaOrEnd, + + /// Expected this character to be either a `','` or a `}`. + ExpectedObjectCommaOrEnd, + + /// Expected to parse either a `true`, `false`, or a `null`. + ExpectedSomeIdent, + + /// Expected this character to start a JSON value. + ExpectedSomeValue, + + /// Invalid hex escape code. + InvalidEscape, + + /// Invalid number. + InvalidNumber, + + /// Invalid unicode code point. + InvalidUnicodeCodePoint, + + /// Object key is not a string. + KeyMustBeAString, + + /// Lone leading surrogate in hex escape. + LoneLeadingSurrogateInHexEscape, + + /// JSON has non-whitespace trailing characters after the value. + TrailingCharacters, + + /// Unexpected end of hex excape. + UnexpectedEndOfHexEscape, + + /// Found a punctuator character when expecting a quoteless string. + PunctuatorInQlString, +} + +impl fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + //use std::fmt::Debug; + + match *self { + ErrorCode::Custom(ref msg) => write!(f, "{}", msg), + ErrorCode::InvalidType(ref ty) => write!(f, "invalid type: {:?}", ty), + ErrorCode::InvalidValue(ref msg) => write!(f, "invalid value: {}", msg), + ErrorCode::InvalidLength(ref len) => write!(f, "invalid value length {}", len), + ErrorCode::UnknownVariant(ref variant) => write!(f, "unknown variant \"{}\"", variant), + ErrorCode::UnknownField(ref field) => write!(f, "unknown field \"{}\"", field), + ErrorCode::MissingField(ref field) => write!(f, "missing field \"{}\"", field), + ErrorCode::EOFWhileParsingList => "EOF while parsing a list".fmt(f), + ErrorCode::EOFWhileParsingObject => "EOF while parsing an object".fmt(f), + ErrorCode::EOFWhileParsingString => "EOF while parsing a string".fmt(f), + ErrorCode::EOFWhileParsingValue => "EOF while parsing a value".fmt(f), + ErrorCode::ExpectedColon => "expected `:`".fmt(f), + ErrorCode::ExpectedListCommaOrEnd => "expected `,` or `]`".fmt(f), + ErrorCode::ExpectedObjectCommaOrEnd => "expected `,` or `}`".fmt(f), + ErrorCode::ExpectedSomeIdent => "expected ident".fmt(f), + ErrorCode::ExpectedSomeValue => "expected value".fmt(f), + ErrorCode::InvalidEscape => "invalid escape".fmt(f), + ErrorCode::InvalidNumber => "invalid number".fmt(f), + ErrorCode::InvalidUnicodeCodePoint => "invalid unicode code point".fmt(f), + ErrorCode::KeyMustBeAString => "key must be a string".fmt(f), + ErrorCode::LoneLeadingSurrogateInHexEscape => { + "lone leading surrogate in hex escape".fmt(f) + } + ErrorCode::TrailingCharacters => "trailing characters".fmt(f), + ErrorCode::UnexpectedEndOfHexEscape => "unexpected end of hex escape".fmt(f), + ErrorCode::PunctuatorInQlString => { + "found a punctuator character when expecting a quoteless string".fmt(f) + } + } + } +} + +/// This type represents all possible errors that can occur when serializing or deserializing a +/// value into JSON. +#[derive(Debug)] +pub enum Error { + /// The JSON value had some syntatic error. + Syntax(ErrorCode, usize, usize), + + /// Some IO error occurred when serializing or deserializing a value. + Io(io::Error), + + /// Some UTF8 error occurred while serializing or deserializing a value. + FromUtf8(FromUtf8Error), +} + +impl error::Error for Error { + fn cause(&self) -> Option<&dyn error::Error> { + match *self { + Error::Io(ref error) => Some(error), + Error::FromUtf8(ref error) => Some(error), + _ => None, + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Syntax(ref code, line, col) => { + write!(fmt, "{:?} at line {} column {}", code, line, col) + } + Error::Io(ref error) => fmt::Display::fmt(error, fmt), + Error::FromUtf8(ref error) => fmt::Display::fmt(error, fmt), + } + } +} + +impl From for Error { + fn from(error: io::Error) -> Error { + Error::Io(error) + } +} + +impl From for Error { + fn from(error: FromUtf8Error) -> Error { + Error::FromUtf8(error) + } +} + +impl From for Error { + fn from(error: de::value::Error) -> Error { + match error { + de::value::Error::Custom(e) => Error::Syntax(ErrorCode::Custom(e), 0, 0), + de::value::Error::EndOfStream => de::Error::end_of_stream(), + de::value::Error::InvalidType(ty) => Error::Syntax(ErrorCode::InvalidType(ty), 0, 0), + de::value::Error::InvalidValue(msg) => { + Error::Syntax(ErrorCode::InvalidValue(msg), 0, 0) + } + de::value::Error::InvalidLength(len) => { + Error::Syntax(ErrorCode::InvalidLength(len), 0, 0) + } + de::value::Error::UnknownVariant(variant) => { + Error::Syntax(ErrorCode::UnknownVariant(variant), 0, 0) + } + de::value::Error::UnknownField(field) => { + Error::Syntax(ErrorCode::UnknownField(field), 0, 0) + } + de::value::Error::MissingField(field) => { + Error::Syntax(ErrorCode::MissingField(field), 0, 0) + } + } + } +} + +impl de::Error for Error { + fn custom>(msg: T) -> Error { + Error::Syntax(ErrorCode::Custom(msg.into()), 0, 0) + } + + fn end_of_stream() -> Error { + Error::Syntax(ErrorCode::EOFWhileParsingValue, 0, 0) + } + + fn invalid_type(ty: de::Type) -> Error { + Error::Syntax(ErrorCode::InvalidType(ty), 0, 0) + } + + fn invalid_value(msg: &str) -> Error { + Error::Syntax(ErrorCode::InvalidValue(msg.to_owned()), 0, 0) + } + + fn invalid_length(len: usize) -> Error { + Error::Syntax(ErrorCode::InvalidLength(len), 0, 0) + } + + fn unknown_variant(variant: &str) -> Error { + Error::Syntax(ErrorCode::UnknownVariant(String::from(variant)), 0, 0) + } + + fn unknown_field(field: &str) -> Error { + Error::Syntax(ErrorCode::UnknownField(String::from(field)), 0, 0) + } + + fn missing_field(field: &'static str) -> Error { + Error::Syntax(ErrorCode::MissingField(field), 0, 0) + } +} + +impl ser::Error for Error { + /// Raised when there is general error when deserializing a type. + fn custom>(msg: T) -> Error { + Error::Syntax(ErrorCode::Custom(msg.into()), 0, 0) + } +} + +/// Helper alias for `Result` objects that return a JSON `Error`. +pub type Result = result::Result; diff --git a/crates/nu-json/src/forward.rs b/crates/nu-json/src/forward.rs new file mode 100644 index 0000000000..ba36c547ea --- /dev/null +++ b/crates/nu-json/src/forward.rs @@ -0,0 +1,38 @@ +#[macro_export] +/// Create a function to forward a specific serialize call to the generic deserialize +macro_rules! forward_to_deserialize { + ($( + $name:ident ( $( $arg:ident : $ty:ty ),* ); + )*) => { + $( + forward_to_deserialize!{ + func: $name ( $( $arg: $ty ),* ); + } + )* + }; + + (func: deserialize_enum ( $( $arg:ident : $ty:ty ),* );) => { + fn deserialize_enum( + &mut self, + $(_: $ty,)* + _visitor: V, + ) -> ::std::result::Result + where V: ::serde::de::EnumVisitor + { + Err(::serde::de::Error::invalid_type(::serde::de::Type::Enum)) + } + }; + + (func: $name:ident ( $( $arg:ident : $ty:ty ),* );) => { + #[inline] + fn $name( + &mut self, + $(_: $ty,)* + visitor: V, + ) -> ::std::result::Result + where V: ::serde::de::Visitor + { + self.deserialize(visitor) + } + }; +} diff --git a/crates/nu-json/src/lib.rs b/crates/nu-json/src/lib.rs new file mode 100644 index 0000000000..e069bb3f1a --- /dev/null +++ b/crates/nu-json/src/lib.rs @@ -0,0 +1,16 @@ +pub use self::de::{ + from_iter, from_reader, from_slice, from_str, Deserializer, StreamDeserializer, +}; +pub use self::error::{Error, ErrorCode, Result}; +pub use self::ser::{to_string, to_vec, to_writer, Serializer}; +pub use self::value::{from_value, to_value, Map, Value}; + +#[macro_use] +mod forward; + +pub mod builder; +pub mod de; +pub mod error; +pub mod ser; +mod util; +pub mod value; diff --git a/crates/nu-json/src/ser.rs b/crates/nu-json/src/ser.rs new file mode 100644 index 0000000000..56cbdccec7 --- /dev/null +++ b/crates/nu-json/src/ser.rs @@ -0,0 +1,1058 @@ +//! Hjson Serialization +//! +//! This module provides for Hjson serialization with the type `Serializer`. + +use std::fmt::{Display, LowerExp}; +use std::io; +use std::num::FpCategory; + +use super::error::{Error, ErrorCode, Result}; +use serde::ser; + +use super::util::ParseNumber; + +use regex::Regex; + +use lazy_static::lazy_static; + +/// A structure for serializing Rust values into Hjson. +pub struct Serializer { + writer: W, + formatter: F, +} + +impl<'a, W> Serializer> +where + W: io::Write, +{ + /// Creates a new Hjson serializer. + #[inline] + pub fn new(writer: W) -> Self { + Serializer::with_formatter(writer, HjsonFormatter::new()) + } +} + +impl Serializer +where + W: io::Write, + F: Formatter, +{ + /// Creates a new Hjson visitor whose output will be written to the writer + /// specified. + #[inline] + pub fn with_formatter(writer: W, formatter: F) -> Self { + Serializer { writer, formatter } + } + + /// Unwrap the `Writer` from the `Serializer`. + #[inline] + pub fn into_inner(self) -> W { + self.writer + } +} + +#[doc(hidden)] +#[derive(Eq, PartialEq)] +pub enum State { + Empty, + First, + Rest, +} + +impl ser::Serializer for Serializer +where + W: io::Write, + F: Formatter, +{ + type Error = Error; + + type SeqState = State; + type TupleState = State; + type TupleStructState = State; + type TupleVariantState = State; + type MapState = State; + type StructState = State; + type StructVariantState = State; + + #[inline] + fn serialize_bool(&mut self, value: bool) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + if value { + self.writer.write_all(b"true").map_err(From::from) + } else { + self.writer.write_all(b"false").map_err(From::from) + } + } + + #[inline] + fn serialize_isize(&mut self, value: isize) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_i8(&mut self, value: i8) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_i16(&mut self, value: i16) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_i32(&mut self, value: i32) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_i64(&mut self, value: i64) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_usize(&mut self, value: usize) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_u8(&mut self, value: u8) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_u16(&mut self, value: u16) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_u32(&mut self, value: u32) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_u64(&mut self, value: u64) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + write!(&mut self.writer, "{}", value).map_err(From::from) + } + + #[inline] + fn serialize_f32(&mut self, value: f32) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + fmt_f32_or_null(&mut self.writer, if value == -0f32 { 0f32 } else { value }) + .map_err(From::from) + } + + #[inline] + fn serialize_f64(&mut self, value: f64) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + fmt_f64_or_null(&mut self.writer, if value == -0f64 { 0f64 } else { value }) + .map_err(From::from) + } + + #[inline] + fn serialize_char(&mut self, value: char) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + escape_char(&mut self.writer, value).map_err(From::from) + } + + #[inline] + fn serialize_str(&mut self, value: &str) -> Result<()> { + quote_str(&mut self.writer, &mut self.formatter, value).map_err(From::from) + } + + #[inline] + fn serialize_bytes(&mut self, value: &[u8]) -> Result<()> { + let mut state = self.serialize_seq(Some(value.len()))?; + for byte in value { + self.serialize_seq_elt(&mut state, byte)?; + } + self.serialize_seq_end(state) + } + + #[inline] + fn serialize_unit(&mut self) -> Result<()> { + self.formatter.start_value(&mut self.writer)?; + self.writer.write_all(b"null").map_err(From::from) + } + + #[inline] + fn serialize_unit_struct(&mut self, _name: &'static str) -> Result<()> { + self.serialize_unit() + } + + #[inline] + fn serialize_unit_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + ) -> Result<()> { + self.serialize_str(variant) + } + + /// Serialize newtypes without an object wrapper. + #[inline] + fn serialize_newtype_struct(&mut self, _name: &'static str, value: T) -> Result<()> + where + T: ser::Serialize, + { + value.serialize(self) + } + + #[inline] + fn serialize_newtype_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + value: T, + ) -> Result<()> + where + T: ser::Serialize, + { + self.formatter.open(&mut self.writer, b'{')?; + self.formatter.comma(&mut self.writer, true)?; + escape_key(&mut self.writer, variant)?; + self.formatter.colon(&mut self.writer)?; + value.serialize(self)?; + self.formatter.close(&mut self.writer, b'}') + } + + #[inline] + fn serialize_none(&mut self) -> Result<()> { + self.serialize_unit() + } + + #[inline] + fn serialize_some(&mut self, value: V) -> Result<()> + where + V: ser::Serialize, + { + value.serialize(self) + } + + #[inline] + fn serialize_seq(&mut self, len: Option) -> Result { + if len == Some(0) { + self.formatter.start_value(&mut self.writer)?; + self.writer.write_all(b"[]")?; + Ok(State::Empty) + } else { + self.formatter.open(&mut self.writer, b'[')?; + Ok(State::First) + } + } + + #[inline] + fn serialize_seq_elt(&mut self, state: &mut State, value: T) -> Result<()> + where + T: ser::Serialize, + { + self.formatter + .comma(&mut self.writer, *state == State::First)?; + *state = State::Rest; + value.serialize(self) + } + + #[inline] + fn serialize_seq_end(&mut self, state: State) -> Result<()> { + match state { + State::Empty => Ok(()), + _ => self.formatter.close(&mut self.writer, b']'), + } + } + + #[inline] + fn serialize_seq_fixed_size(&mut self, size: usize) -> Result { + self.serialize_seq(Some(size)) + } + + #[inline] + fn serialize_tuple(&mut self, len: usize) -> Result { + self.serialize_seq(Some(len)) + } + + #[inline] + fn serialize_tuple_elt( + &mut self, + state: &mut State, + value: T, + ) -> Result<()> { + self.serialize_seq_elt(state, value) + } + + #[inline] + fn serialize_tuple_end(&mut self, state: State) -> Result<()> { + self.serialize_seq_end(state) + } + + #[inline] + fn serialize_tuple_struct(&mut self, _name: &'static str, len: usize) -> Result { + self.serialize_seq(Some(len)) + } + + #[inline] + fn serialize_tuple_struct_elt( + &mut self, + state: &mut State, + value: T, + ) -> Result<()> { + self.serialize_seq_elt(state, value) + } + + #[inline] + fn serialize_tuple_struct_end(&mut self, state: State) -> Result<()> { + self.serialize_seq_end(state) + } + + #[inline] + fn serialize_tuple_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + len: usize, + ) -> Result { + self.formatter.open(&mut self.writer, b'{')?; + self.formatter.comma(&mut self.writer, true)?; + escape_key(&mut self.writer, variant)?; + self.formatter.colon(&mut self.writer)?; + self.serialize_seq(Some(len)) + } + + #[inline] + fn serialize_tuple_variant_elt( + &mut self, + state: &mut State, + value: T, + ) -> Result<()> { + self.serialize_seq_elt(state, value) + } + + #[inline] + fn serialize_tuple_variant_end(&mut self, state: State) -> Result<()> { + self.serialize_seq_end(state)?; + self.formatter.close(&mut self.writer, b'}') + } + + #[inline] + fn serialize_map(&mut self, len: Option) -> Result { + if len == Some(0) { + self.formatter.start_value(&mut self.writer)?; + self.writer.write_all(b"{}")?; + Ok(State::Empty) + } else { + self.formatter.open(&mut self.writer, b'{')?; + Ok(State::First) + } + } + + #[inline] + fn serialize_map_key(&mut self, state: &mut State, key: T) -> Result<()> { + self.formatter + .comma(&mut self.writer, *state == State::First)?; + *state = State::Rest; + + key.serialize(&mut MapKeySerializer { ser: self })?; + + self.formatter.colon(&mut self.writer) + } + + #[inline] + fn serialize_map_value(&mut self, _: &mut State, value: T) -> Result<()> { + value.serialize(self) + } + + #[inline] + fn serialize_map_end(&mut self, state: State) -> Result<()> { + match state { + State::Empty => Ok(()), + _ => self.formatter.close(&mut self.writer, b'}'), + } + } + + #[inline] + fn serialize_struct(&mut self, _name: &'static str, len: usize) -> Result { + self.serialize_map(Some(len)) + } + + #[inline] + fn serialize_struct_elt( + &mut self, + state: &mut State, + key: &'static str, + value: V, + ) -> Result<()> { + self.serialize_map_key(state, key)?; + self.serialize_map_value(state, value) + } + + #[inline] + fn serialize_struct_end(&mut self, state: State) -> Result<()> { + self.serialize_map_end(state) + } + + #[inline] + fn serialize_struct_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + len: usize, + ) -> Result { + self.formatter.open(&mut self.writer, b'{')?; + self.formatter.comma(&mut self.writer, true)?; + escape_key(&mut self.writer, variant)?; + self.formatter.colon(&mut self.writer)?; + self.serialize_map(Some(len)) + } + + #[inline] + fn serialize_struct_variant_elt( + &mut self, + state: &mut State, + key: &'static str, + value: V, + ) -> Result<()> { + self.serialize_struct_elt(state, key, value) + } + + #[inline] + fn serialize_struct_variant_end(&mut self, state: State) -> Result<()> { + self.serialize_struct_end(state)?; + self.formatter.close(&mut self.writer, b'}') + } +} + +struct MapKeySerializer<'a, W: 'a, F: 'a> { + ser: &'a mut Serializer, +} + +impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> +where + W: io::Write, + F: Formatter, +{ + type Error = Error; + + #[inline] + fn serialize_str(&mut self, value: &str) -> Result<()> { + escape_key(&mut self.ser.writer, value).map_err(From::from) + } + + type SeqState = (); + type TupleState = (); + type TupleStructState = (); + type TupleVariantState = (); + type MapState = (); + type StructState = (); + type StructVariantState = (); + + fn serialize_bool(&mut self, _value: bool) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_isize(&mut self, _value: isize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_i8(&mut self, _value: i8) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_i16(&mut self, _value: i16) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_i32(&mut self, _value: i32) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_i64(&mut self, _value: i64) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_usize(&mut self, _value: usize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_u8(&mut self, _value: u8) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_u16(&mut self, _value: u16) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_u32(&mut self, _value: u32) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_u64(&mut self, _value: u64) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_f32(&mut self, _value: f32) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_f64(&mut self, _value: f64) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_char(&mut self, _value: char) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_bytes(&mut self, _value: &[u8]) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_unit(&mut self) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_unit_struct(&mut self, _name: &'static str) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_unit_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_newtype_struct(&mut self, _name: &'static str, _value: T) -> Result<()> + where + T: ser::Serialize, + { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_newtype_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _value: T, + ) -> Result<()> + where + T: ser::Serialize, + { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_none(&mut self) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_some(&mut self, _value: T) -> Result<()> + where + T: ser::Serialize, + { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_seq(&mut self, _len: Option) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_seq_elt(&mut self, _state: &mut (), _value: T) -> Result<()> + where + T: ser::Serialize, + { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_seq_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_seq_fixed_size(&mut self, _size: usize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple(&mut self, _len: usize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_elt(&mut self, _state: &mut (), _value: T) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_struct(&mut self, _name: &'static str, _len: usize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_struct_elt( + &mut self, + _state: &mut (), + _value: T, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_struct_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _len: usize, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_variant_elt( + &mut self, + _state: &mut (), + _value: T, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_tuple_variant_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_map(&mut self, _len: Option) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_map_key(&mut self, _state: &mut (), _key: T) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_map_value(&mut self, _state: &mut (), _value: T) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_map_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct(&mut self, _name: &'static str, _len: usize) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct_elt( + &mut self, + _state: &mut (), + _key: &'static str, + _value: V, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _len: usize, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct_variant_elt( + &mut self, + _state: &mut (), + _key: &'static str, + _value: V, + ) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } + + fn serialize_struct_variant_end(&mut self, _state: ()) -> Result<()> { + Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)) + } +} + +/// This trait abstracts away serializing the JSON control characters +pub trait Formatter { + /// Called when serializing a '{' or '['. + fn open(&mut self, writer: &mut W, ch: u8) -> Result<()> + where + W: io::Write; + + /// Called when serializing a ','. + fn comma(&mut self, writer: &mut W, first: bool) -> Result<()> + where + W: io::Write; + + /// Called when serializing a ':'. + fn colon(&mut self, writer: &mut W) -> Result<()> + where + W: io::Write; + + /// Called when serializing a '}' or ']'. + fn close(&mut self, writer: &mut W, ch: u8) -> Result<()> + where + W: io::Write; + + /// Newline with indent. + fn newline(&mut self, writer: &mut W, add_indent: i32) -> Result<()> + where + W: io::Write; + + /// Start a value. + fn start_value(&mut self, writer: &mut W) -> Result<()> + where + W: io::Write; +} + +struct HjsonFormatter<'a> { + current_indent: usize, + current_is_array: bool, + stack: Vec, + at_colon: bool, + indent: &'a [u8], + braces_same_line: bool, +} + +impl<'a> HjsonFormatter<'a> { + /// Construct a formatter that defaults to using two spaces for indentation. + pub fn new() -> Self { + HjsonFormatter::with_indent(b" ") + } + + /// Construct a formatter that uses the `indent` string for indentation. + pub fn with_indent(indent: &'a [u8]) -> Self { + HjsonFormatter { + current_indent: 0, + current_is_array: false, + stack: Vec::new(), + at_colon: false, + indent, + braces_same_line: false, + } + } +} + +impl<'a> Formatter for HjsonFormatter<'a> { + fn open(&mut self, writer: &mut W, ch: u8) -> Result<()> + where + W: io::Write, + { + if self.current_indent > 0 && !self.current_is_array && !self.braces_same_line { + self.newline(writer, 0)?; + } else { + self.start_value(writer)?; + } + self.current_indent += 1; + self.stack.push(self.current_is_array); + self.current_is_array = ch == b'['; + writer.write_all(&[ch]).map_err(From::from) + } + + fn comma(&mut self, writer: &mut W, _: bool) -> Result<()> + where + W: io::Write, + { + writer.write_all(b"\n")?; + indent(writer, self.current_indent, self.indent) + } + + fn colon(&mut self, writer: &mut W) -> Result<()> + where + W: io::Write, + { + self.at_colon = !self.braces_same_line; + writer + .write_all(if self.braces_same_line { b": " } else { b":" }) + .map_err(From::from) + } + + fn close(&mut self, writer: &mut W, ch: u8) -> Result<()> + where + W: io::Write, + { + self.current_indent -= 1; + self.current_is_array = self.stack.pop().expect("Internal error: json parsing"); + writer.write_all(b"\n")?; + indent(writer, self.current_indent, self.indent)?; + writer.write_all(&[ch]).map_err(From::from) + } + + fn newline(&mut self, writer: &mut W, add_indent: i32) -> Result<()> + where + W: io::Write, + { + self.at_colon = false; + writer.write_all(b"\n")?; + let ii = self.current_indent as i32 + add_indent; + indent(writer, if ii < 0 { 0 } else { ii as usize }, self.indent) + } + + fn start_value(&mut self, writer: &mut W) -> Result<()> + where + W: io::Write, + { + if self.at_colon { + self.at_colon = false; + writer.write_all(b" ")? + } + Ok(()) + } +} + +/// Serializes and escapes a `&[u8]` into a Hjson string. +#[inline] +pub fn escape_bytes(wr: &mut W, bytes: &[u8]) -> Result<()> +where + W: io::Write, +{ + wr.write_all(b"\"")?; + + let mut start = 0; + + for (i, byte) in bytes.iter().enumerate() { + let escaped = match *byte { + b'"' => b"\\\"", + b'\\' => b"\\\\", + b'\x08' => b"\\b", + b'\x0c' => b"\\f", + b'\n' => b"\\n", + b'\r' => b"\\r", + b'\t' => b"\\t", + _ => { + continue; + } + }; + + if start < i { + wr.write_all(&bytes[start..i])?; + } + + wr.write_all(escaped)?; + + start = i + 1; + } + + if start != bytes.len() { + wr.write_all(&bytes[start..])?; + } + + wr.write_all(b"\"")?; + Ok(()) +} + +/// Serializes and escapes a `&str` into a Hjson string. +#[inline] +pub fn quote_str(wr: &mut W, formatter: &mut F, value: &str) -> Result<()> +where + W: io::Write, + F: Formatter, +{ + lazy_static! { + // NEEDS_ESCAPE tests if the string can be written without escapes + static ref NEEDS_ESCAPE: Regex = Regex::new("[\\\\\"\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]").expect("Internal error: json parsing"); + // NEEDS_QUOTES tests if the string can be written as a quoteless string (includes needsEscape but without \\ and \") + static ref NEEDS_QUOTES: Regex = Regex::new("^\\s|^\"|^'''|^#|^/\\*|^//|^\\{|^\\}|^\\[|^\\]|^:|^,|\\s$|[\x00-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]").expect("Internal error: json parsing"); + // NEEDS_ESCAPEML tests if the string can be written as a multiline string (includes needsEscape but without \n, \r, \\ and \") + static ref NEEDS_ESCAPEML: Regex = Regex::new("'''|[\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\u{9f}\u{00ad}\u{0600}-\u{0604}\u{070f}\u{17b4}\u{17b5}\u{200c}-\u{200f}\u{2028}-\u{202f}\u{2060}-\u{206f}\u{feff}\u{fff0}-\u{ffff}]").expect("Internal error: json parsing"); + // starts with a keyword and optionally is followed by a comment + static ref STARTS_WITH_KEYWORD: Regex = Regex::new(r#"^(true|false|null)\s*((,|\]|\}|#|//|/\*).*)?$"#).expect("Internal error: json parsing"); + } + + if value.is_empty() { + formatter.start_value(wr)?; + return escape_bytes(wr, value.as_bytes()); + } + + // Check if we can insert this string without quotes + // see hjson syntax (must not parse as true, false, null or number) + + let mut pn = ParseNumber::new(value.bytes()); + let is_number = pn.parse(true).is_ok(); + + if is_number || NEEDS_QUOTES.is_match(value) || STARTS_WITH_KEYWORD.is_match(value) { + // First check if the string can be expressed in multiline format or + // we must replace the offending characters with safe escape sequences. + + if NEEDS_ESCAPE.is_match(value) && !NEEDS_ESCAPEML.is_match(value) + /* && !isRootObject */ + { + ml_str(wr, formatter, value) + } else { + formatter.start_value(wr)?; + escape_bytes(wr, value.as_bytes()) + } + } else { + // without quotes + formatter.start_value(wr)?; + wr.write_all(value.as_bytes()).map_err(From::from) + } +} + +/// Serializes and escapes a `&str` into a multiline Hjson string. +pub fn ml_str(wr: &mut W, formatter: &mut F, value: &str) -> Result<()> +where + W: io::Write, + F: Formatter, +{ + // wrap the string into the ''' (multiline) format + + let a: Vec<&str> = value.split('\n').collect(); + + if a.len() == 1 { + // The string contains only a single line. We still use the multiline + // format as it avoids escaping the \ character (e.g. when used in a + // regex). + formatter.start_value(wr)?; + wr.write_all(b"'''")?; + wr.write_all(a[0].as_bytes())?; + wr.write_all(b"'''")? + } else { + formatter.newline(wr, 1)?; + wr.write_all(b"'''")?; + for line in a { + formatter.newline(wr, if !line.is_empty() { 1 } else { -999 })?; + wr.write_all(line.as_bytes())?; + } + formatter.newline(wr, 1)?; + wr.write_all(b"'''")?; + } + Ok(()) +} + +/// Serializes and escapes a `&str` into a Hjson key. +#[inline] +pub fn escape_key(wr: &mut W, value: &str) -> Result<()> +where + W: io::Write, +{ + lazy_static! { + static ref NEEDS_ESCAPE_NAME: Regex = + Regex::new(r#"[,\{\[\}\]\s:#"]|//|/\*|'''|^$"#).expect("Internal error: json parsing"); + } + + // Check if we can insert this name without quotes + if NEEDS_ESCAPE_NAME.is_match(value) { + escape_bytes(wr, value.as_bytes()).map_err(From::from) + } else { + wr.write_all(value.as_bytes()).map_err(From::from) + } +} + +#[inline] +fn escape_char(wr: &mut W, value: char) -> Result<()> +where + W: io::Write, +{ + // FIXME: this allocation is required in order to be compatible with stable + // rust, which doesn't support encoding a `char` into a stack buffer. + let mut s = String::new(); + s.push(value); + escape_bytes(wr, s.as_bytes()) +} + +fn fmt_f32_or_null(wr: &mut W, value: f32) -> Result<()> +where + W: io::Write, +{ + match value.classify() { + FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null")?, + _ => wr.write_all(fmt_small(value).as_bytes())?, + } + + Ok(()) +} + +fn fmt_f64_or_null(wr: &mut W, value: f64) -> Result<()> +where + W: io::Write, +{ + match value.classify() { + FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null")?, + _ => wr.write_all(fmt_small(value).as_bytes())?, + } + + Ok(()) +} + +fn indent(wr: &mut W, n: usize, s: &[u8]) -> Result<()> +where + W: io::Write, +{ + for _ in 0..n { + wr.write_all(s)?; + } + + Ok(()) +} + +// format similar to es6 +fn fmt_small(value: N) -> String +where + N: Display + LowerExp, +{ + let f1 = format!("{}", value); + let f2 = format!("{:e}", value); + if f1.len() <= f2.len() + 1 { + f1 + } else if !f2.contains("e-") { + f2.replace("e", "e+") + } else { + f2 + } +} + +/// Encode the specified struct into a Hjson `[u8]` writer. +#[inline] +pub fn to_writer(writer: &mut W, value: &T) -> Result<()> +where + W: io::Write, + T: ser::Serialize, +{ + let mut ser = Serializer::new(writer); + value.serialize(&mut ser)?; + Ok(()) +} + +/// Encode the specified struct into a Hjson `[u8]` buffer. +#[inline] +pub fn to_vec(value: &T) -> Result> +where + T: ser::Serialize, +{ + // We are writing to a Vec, which doesn't fail. So we can ignore + // the error. + let mut writer = Vec::with_capacity(128); + to_writer(&mut writer, value)?; + Ok(writer) +} + +/// Encode the specified struct into a Hjson `String` buffer. +#[inline] +pub fn to_string(value: &T) -> Result +where + T: ser::Serialize, +{ + let vec = to_vec(value)?; + let string = String::from_utf8(vec)?; + Ok(string) +} diff --git a/crates/nu-json/src/util.rs b/crates/nu-json/src/util.rs new file mode 100644 index 0000000000..3e1b2ddc23 --- /dev/null +++ b/crates/nu-json/src/util.rs @@ -0,0 +1,328 @@ +use std::io; +use std::str; + +use super::error::{Error, ErrorCode, Result}; + +pub struct StringReader> { + iter: Iter, + line: usize, + col: usize, + ch: Vec, +} + +impl StringReader +where + Iter: Iterator, +{ + #[inline] + pub fn new(iter: Iter) -> Self { + StringReader { + iter, + line: 1, + col: 0, + ch: Vec::new(), + } + } + + fn next(&mut self) -> Option> { + match self.iter.next() { + None => None, + Some(b'\n') => { + self.line += 1; + self.col = 0; + Some(Ok(b'\n')) + } + Some(c) => { + self.col += 1; + Some(Ok(c)) + } + } + } + + pub fn pos(&mut self) -> (usize, usize) { + (self.line, self.col) + } + + pub fn eof(&mut self) -> Result { + Ok(self.peek()?.is_none()) + } + + pub fn peek_next(&mut self, idx: usize) -> Result> { + while self.ch.len() <= idx { + match self.next() { + Some(Err(err)) => return Err(Error::Io(err)), + Some(Ok(ch)) => self.ch.push(ch), + None => return Ok(None), + } + } + Ok(Some(self.ch[idx])) + } + + pub fn peek(&mut self) -> Result> { + self.peek_next(0) + } + + pub fn peek_or_null(&mut self) -> Result { + Ok(self.peek()?.unwrap_or(b'\x00')) + } + + pub fn eat_char(&mut self) -> u8 { + self.ch.remove(0) + } + + pub fn uneat_char(&mut self, ch: u8) { + self.ch.insert(0, ch); + } + + pub fn next_char(&mut self) -> Result> { + match self.ch.first() { + Some(&ch) => { + self.eat_char(); + Ok(Some(ch)) + } + None => match self.next() { + Some(Err(err)) => Err(Error::Io(err)), + Some(Ok(ch)) => Ok(Some(ch)), + None => Ok(None), + }, + } + } + + pub fn next_char_or_null(&mut self) -> Result { + Ok(self.next_char()?.unwrap_or(b'\x00')) + } + + fn eat_line(&mut self) -> Result<()> { + loop { + match self.peek()? { + Some(b'\n') | None => return Ok(()), + _ => {} + } + self.eat_char(); + } + } + + pub fn parse_whitespace(&mut self) -> Result<()> { + loop { + match self.peek_or_null()? { + b' ' | b'\n' | b'\t' | b'\r' => { + self.eat_char(); + } + b'#' => self.eat_line()?, + b'/' => { + match self.peek_next(1)? { + Some(b'/') => self.eat_line()?, + Some(b'*') => { + self.eat_char(); + self.eat_char(); + while !(self.peek()?.unwrap_or(b'*') == b'*' + && self.peek_next(1)?.unwrap_or(b'/') == b'/') + { + self.eat_char(); + } + self.eat_char(); + self.eat_char(); + } + Some(_) => { + self.eat_char(); + } + None => return Err(self.error(ErrorCode::TrailingCharacters)), //todo + } + } + _ => { + return Ok(()); + } + } + } + } + + pub fn error(&mut self, reason: ErrorCode) -> Error { + Error::Syntax(reason, self.line, self.col) + } +} + +pub enum Number { + I64(i64), + U64(u64), + F64(f64), +} + +pub struct ParseNumber> { + rdr: StringReader, + result: Vec, +} + +// macro_rules! try_or_invalid { +// ($e:expr) => { +// match $e { +// Some(v) => v, +// None => { return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); } +// } +// } +// } + +impl> ParseNumber { + #[inline] + pub fn new(iter: Iter) -> Self { + ParseNumber { + rdr: StringReader::new(iter), + result: Vec::new(), + } + } + + pub fn parse(&mut self, stop_at_next: bool) -> Result { + match self.try_parse() { + Ok(()) => { + self.rdr.parse_whitespace()?; + + let mut ch = self.rdr.next_char_or_null()?; + + if stop_at_next { + let ch2 = self.rdr.peek_or_null()?; + // end scan if we find a punctuator character like ,}] or a comment + if ch == b',' + || ch == b'}' + || ch == b']' + || ch == b'#' + || ch == b'/' && (ch2 == b'/' || ch2 == b'*') + { + ch = b'\x00'; + } + } + + match ch { + b'\x00' => { + let res = + str::from_utf8(&self.result).expect("Internal error: json parsing"); + + let mut is_float = false; + for ch in res.chars() { + if ch == '.' || ch == 'e' || ch == 'E' { + is_float = true; + break; + } + } + + if is_float { + Ok(Number::F64( + res.parse::().expect("Internal error: json parsing"), + )) + } else if res.starts_with('-') { + Ok(Number::I64( + res.parse::().expect("Internal error: json parsing"), + )) + } else { + Ok(Number::U64( + res.parse::().expect("Internal error: json parsing"), + )) + } + } + _ => Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)), + } + } + Err(e) => Err(e), + } + } + + fn try_parse(&mut self) -> Result<()> { + if self.rdr.peek_or_null()? == b'-' { + self.result.push(self.rdr.eat_char()); + } + + let mut has_value = false; + + if self.rdr.peek_or_null()? == b'0' { + self.result.push(self.rdr.eat_char()); + has_value = true; + // There can be only one leading '0'. + if let b'0'..=b'9' = self.rdr.peek_or_null()? { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + } + + loop { + match self.rdr.peek_or_null()? { + b'0'..=b'9' => { + self.result.push(self.rdr.eat_char()); + has_value = true; + } + b'.' => { + if !has_value { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + self.rdr.eat_char(); + return self.try_decimal(); + } + b'e' | b'E' => { + if !has_value { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + self.rdr.eat_char(); + return self.try_exponent(); + } + _ => { + if !has_value { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + return Ok(()); + } + } + } + } + + fn try_decimal(&mut self) -> Result<()> { + self.result.push(b'.'); + + // Make sure a digit follows the decimal place. + match self.rdr.next_char_or_null()? { + c @ b'0'..=b'9' => { + self.result.push(c); + } + _ => { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + }; + + while let b'0'..=b'9' = self.rdr.peek_or_null()? { + self.result.push(self.rdr.eat_char()); + } + + match self.rdr.peek_or_null()? { + b'e' | b'E' => { + self.rdr.eat_char(); + self.try_exponent() + } + _ => Ok(()), + } + } + + fn try_exponent(&mut self) -> Result<()> { + self.result.push(b'e'); + + match self.rdr.peek_or_null()? { + b'+' => { + self.result.push(self.rdr.eat_char()); + } + b'-' => { + self.result.push(self.rdr.eat_char()); + } + _ => {} + }; + + // Make sure a digit follows the exponent place. + match self.rdr.next_char_or_null()? { + c @ b'0'..=b'9' => { + self.result.push(c); + } + _ => { + return Err(Error::Syntax(ErrorCode::InvalidNumber, 0, 0)); + } + }; + + while let b'0'..=b'9' = self.rdr.peek_or_null()? { + self.result.push(self.rdr.eat_char()); + } + + Ok(()) + } +} diff --git a/crates/nu-json/src/value.rs b/crates/nu-json/src/value.rs new file mode 100644 index 0000000000..a97d0c8cec --- /dev/null +++ b/crates/nu-json/src/value.rs @@ -0,0 +1,1349 @@ +#[cfg(not(feature = "preserve_order"))] +use std::collections::{btree_map, BTreeMap}; + +#[cfg(feature = "preserve_order")] +use linked_hash_map::{self, LinkedHashMap}; + +use std::fmt; +use std::io; +use std::str; +use std::vec; + +use num_traits::NumCast; + +use serde::de; +use serde::ser; + +use crate::error::{Error, ErrorCode}; + +/// Represents a key/value type. +#[cfg(not(feature = "preserve_order"))] +pub type Map = BTreeMap; +/// Represents a key/value type. +#[cfg(feature = "preserve_order")] +pub type Map = LinkedHashMap; + +/// Represents the `IntoIter` type. +#[cfg(not(feature = "preserve_order"))] +pub type MapIntoIter = btree_map::IntoIter; +/// Represents the IntoIter type. +#[cfg(feature = "preserve_order")] +pub type MapIntoIter = linked_hash_map::IntoIter; + +#[cfg(not(feature = "preserve_order"))] +type MapVisitor = de::impls::BTreeMapVisitor; +#[cfg(feature = "preserve_order")] +type MapVisitor = linked_hash_map::serde::LinkedHashMapVisitor; + +/// Represents a Hjson/JSON value +#[derive(Clone, PartialEq)] +pub enum Value { + /// Represents a JSON null value + Null, + + /// Represents a JSON Boolean + Bool(bool), + + /// Represents a JSON signed integer + I64(i64), + + /// Represents a JSON unsigned integer + U64(u64), + + /// Represents a JSON floating point number + F64(f64), + + /// Represents a JSON string + String(String), + + /// Represents a JSON array + Array(Vec), + + /// Represents a JSON object + Object(Map), +} + +impl Value { + /// If the `Value` is an Object, returns the value associated with the provided key. + /// Otherwise, returns None. + pub fn find<'a>(&'a self, key: &str) -> Option<&'a Value> { + match *self { + Value::Object(ref map) => map.get(key), + _ => None, + } + } + + /// Attempts to get a nested Value Object for each key in `keys`. + /// If any key is found not to exist, find_path will return None. + /// Otherwise, it will return the `Value` associated with the final key. + pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Value> { + let mut target = self; + for key in keys { + match target.find(key) { + Some(t) => { + target = t; + } + None => return None, + } + } + Some(target) + } + + /// Looks up a value by a JSON Pointer. + /// + /// JSON Pointer defines a string syntax for identifying a specific value + /// within a JavaScript Object Notation (JSON) document. + /// + /// A Pointer is a Unicode string with the reference tokens separated by `/`. + /// Inside tokens `/` is replaced by `~1` and `~` is replaced by `~0`. The + /// addressed value is returned and if there is no such value `None` is + /// returned. + /// + /// For more information read [RFC6901](https://tools.ietf.org/html/rfc6901). + pub fn pointer<'a>(&'a self, pointer: &str) -> Option<&'a Value> { + fn parse_index(s: &str) -> Option { + if s.starts_with('+') || (s.starts_with('0') && s.len() != 1) { + return None; + } + s.parse().ok() + } + if pointer == "" { + return Some(self); + } + if !pointer.starts_with('/') { + return None; + } + let mut target = self; + for escaped_token in pointer.split('/').skip(1) { + let token = escaped_token.replace("~1", "/").replace("~0", "~"); + let target_opt = match *target { + Value::Object(ref map) => map.get(&token[..]), + Value::Array(ref list) => parse_index(&token[..]).and_then(|x| list.get(x)), + _ => return None, + }; + if let Some(t) = target_opt { + target = t; + } else { + return None; + } + } + Some(target) + } + + /// If the `Value` is an Object, performs a depth-first search until + /// a value associated with the provided key is found. If no value is found + /// or the `Value` is not an Object, returns None. + pub fn search<'a>(&'a self, key: &str) -> Option<&'a Value> { + match *self { + Value::Object(ref map) => match map.get(key) { + Some(json_value) => Some(json_value), + None => { + for (_, v) in map.iter() { + match v.search(key) { + x if x.is_some() => return x, + _ => (), + } + } + None + } + }, + _ => None, + } + } + + /// Returns true if the `Value` is an Object. Returns false otherwise. + pub fn is_object(&self) -> bool { + self.as_object().is_some() + } + + /// If the `Value` is an Object, returns the associated Map. + /// Returns None otherwise. + pub fn as_object(&self) -> Option<&Map> { + match *self { + Value::Object(ref map) => Some(map), + _ => None, + } + } + + /// If the `Value` is an Object, returns the associated mutable Map. + /// Returns None otherwise. + pub fn as_object_mut(&mut self) -> Option<&mut Map> { + match *self { + Value::Object(ref mut map) => Some(map), + _ => None, + } + } + + /// Returns true if the `Value` is an Array. Returns false otherwise. + pub fn is_array(&self) -> bool { + self.as_array().is_some() + } + + /// If the `Value` is an Array, returns the associated vector. + /// Returns None otherwise. + pub fn as_array(&self) -> Option<&Vec> { + match *self { + Value::Array(ref array) => Some(&*array), + _ => None, + } + } + + /// If the `Value` is an Array, returns the associated mutable vector. + /// Returns None otherwise. + pub fn as_array_mut(&mut self) -> Option<&mut Vec> { + match *self { + Value::Array(ref mut list) => Some(list), + _ => None, + } + } + + /// Returns true if the `Value` is a String. Returns false otherwise. + pub fn is_string(&self) -> bool { + self.as_str().is_some() + } + + /// If the `Value` is a String, returns the associated str. + /// Returns None otherwise. + pub fn as_str(&self) -> Option<&str> { + match *self { + Value::String(ref s) => Some(s), + _ => None, + } + } + + /// Returns true if the `Value` is a Number. Returns false otherwise. + pub fn is_number(&self) -> bool { + matches!(*self, Value::I64(_) | Value::U64(_) | Value::F64(_)) + } + + /// Returns true if the `Value` is a i64. Returns false otherwise. + pub fn is_i64(&self) -> bool { + matches!(*self, Value::I64(_)) + } + + /// Returns true if the `Value` is a u64. Returns false otherwise. + pub fn is_u64(&self) -> bool { + matches!(*self, Value::U64(_)) + } + + /// Returns true if the `Value` is a f64. Returns false otherwise. + pub fn is_f64(&self) -> bool { + matches!(*self, Value::F64(_)) + } + + /// If the `Value` is a number, return or cast it to a i64. + /// Returns None otherwise. + pub fn as_i64(&self) -> Option { + match *self { + Value::I64(n) => Some(n), + Value::U64(n) => NumCast::from(n), + _ => None, + } + } + + /// If the `Value` is a number, return or cast it to a u64. + /// Returns None otherwise. + pub fn as_u64(&self) -> Option { + match *self { + Value::I64(n) => NumCast::from(n), + Value::U64(n) => Some(n), + _ => None, + } + } + + /// If the `Value` is a number, return or cast it to a f64. + /// Returns None otherwise. + pub fn as_f64(&self) -> Option { + match *self { + Value::I64(n) => NumCast::from(n), + Value::U64(n) => NumCast::from(n), + Value::F64(n) => Some(n), + _ => None, + } + } + + /// Returns true if the `Value` is a Boolean. Returns false otherwise. + pub fn is_boolean(&self) -> bool { + self.as_bool().is_some() + } + + /// If the `Value` is a Boolean, returns the associated bool. + /// Returns None otherwise. + pub fn as_bool(&self) -> Option { + match *self { + Value::Bool(b) => Some(b), + _ => None, + } + } + + /// Returns true if the `Value` is a Null. Returns false otherwise. + pub fn is_null(&self) -> bool { + self.as_null().is_some() + } + + /// If the `Value` is a Null, returns (). + /// Returns None otherwise. + pub fn as_null(&self) -> Option<()> { + match *self { + Value::Null => Some(()), + _ => None, + } + } +} + +impl ser::Serialize for Value { + #[inline] + fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> + where + S: ser::Serializer, + { + match *self { + Value::Null => serializer.serialize_unit(), + Value::Bool(v) => serializer.serialize_bool(v), + Value::I64(v) => serializer.serialize_i64(v), + Value::U64(v) => serializer.serialize_u64(v), + Value::F64(v) => serializer.serialize_f64(v), + Value::String(ref v) => serializer.serialize_str(v), + Value::Array(ref v) => v.serialize(serializer), + Value::Object(ref v) => v.serialize(serializer), + } + } +} + +impl de::Deserialize for Value { + #[inline] + fn deserialize(deserializer: &mut D) -> Result + where + D: de::Deserializer, + { + struct ValueVisitor; + + impl de::Visitor for ValueVisitor { + type Value = Value; + + #[inline] + fn visit_bool(&mut self, value: bool) -> Result { + Ok(Value::Bool(value)) + } + + #[inline] + fn visit_i64(&mut self, value: i64) -> Result { + if value < 0 { + Ok(Value::I64(value)) + } else { + Ok(Value::U64(value as u64)) + } + } + + #[inline] + fn visit_u64(&mut self, value: u64) -> Result { + Ok(Value::U64(value)) + } + + #[inline] + fn visit_f64(&mut self, value: f64) -> Result { + Ok(Value::F64(value)) + } + + #[inline] + fn visit_str(&mut self, value: &str) -> Result + where + E: de::Error, + { + self.visit_string(String::from(value)) + } + + #[inline] + fn visit_string(&mut self, value: String) -> Result { + Ok(Value::String(value)) + } + + #[inline] + fn visit_none(&mut self) -> Result { + Ok(Value::Null) + } + + #[inline] + fn visit_some(&mut self, deserializer: &mut D) -> Result + where + D: de::Deserializer, + { + de::Deserialize::deserialize(deserializer) + } + + #[inline] + fn visit_unit(&mut self) -> Result { + Ok(Value::Null) + } + + #[inline] + fn visit_seq(&mut self, visitor: V) -> Result + where + V: de::SeqVisitor, + { + let values = de::impls::VecVisitor::new().visit_seq(visitor)?; + Ok(Value::Array(values)) + } + + #[inline] + fn visit_map(&mut self, visitor: V) -> Result + where + V: de::MapVisitor, + { + let values = MapVisitor::new().visit_map(visitor)?; + Ok(Value::Object(values)) + } + } + + deserializer.deserialize(ValueVisitor) + } +} + +struct WriterFormatter<'a, 'b: 'a> { + inner: &'a mut fmt::Formatter<'b>, +} + +impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> { + fn write(&mut self, buf: &[u8]) -> io::Result { + fn io_error(_: E) -> io::Error { + // Value does not matter because fmt::Debug and fmt::Display impls + // below just map it to fmt::Error + io::Error::new(io::ErrorKind::Other, "fmt error") + } + let s = str::from_utf8(buf).map_err(io_error)?; + self.inner.write_str(s).map_err(io_error)?; + Ok(buf.len()) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +impl fmt::Debug for Value { + /// Serializes a Hjson value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut wr = WriterFormatter { inner: f }; + super::ser::to_writer(&mut wr, self).map_err(|_| fmt::Error) + } +} + +impl fmt::Display for Value { + /// Serializes a Hjson value into a string + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut wr = WriterFormatter { inner: f }; + super::ser::to_writer(&mut wr, self).map_err(|_| fmt::Error) + } +} + +impl str::FromStr for Value { + type Err = Error; + fn from_str(s: &str) -> Result { + super::de::from_str(s) + } +} + +/// Create a `serde::Serializer` that serializes a `Serialize`e into a `Value`. +pub struct Serializer { + value: Value, +} + +impl Serializer { + /// Construct a new `Serializer`. + pub fn new() -> Serializer { + Serializer { value: Value::Null } + } + + /// Unwrap the `Serializer` and return the `Value`. + pub fn unwrap(self) -> Value { + self.value + } +} + +impl Default for Serializer { + fn default() -> Self { + Serializer::new() + } +} + +#[doc(hidden)] +pub struct TupleVariantState { + name: String, + vec: Vec, +} + +#[doc(hidden)] +pub struct StructVariantState { + name: String, + map: Map, +} + +#[doc(hidden)] +pub struct MapState { + map: Map, + next_key: Option, +} + +impl ser::Serializer for Serializer { + type Error = Error; + + type SeqState = Vec; + type TupleState = Vec; + type TupleStructState = Vec; + type TupleVariantState = TupleVariantState; + type MapState = MapState; + type StructState = MapState; + type StructVariantState = StructVariantState; + + #[inline] + fn serialize_bool(&mut self, value: bool) -> Result<(), Error> { + self.value = Value::Bool(value); + Ok(()) + } + + #[inline] + fn serialize_isize(&mut self, value: isize) -> Result<(), Error> { + self.serialize_i64(value as i64) + } + + #[inline] + fn serialize_i8(&mut self, value: i8) -> Result<(), Error> { + self.serialize_i64(value as i64) + } + + #[inline] + fn serialize_i16(&mut self, value: i16) -> Result<(), Error> { + self.serialize_i64(value as i64) + } + + #[inline] + fn serialize_i32(&mut self, value: i32) -> Result<(), Error> { + self.serialize_i64(value as i64) + } + + fn serialize_i64(&mut self, value: i64) -> Result<(), Error> { + if value < 0 { + self.value = Value::I64(value); + } else { + self.value = Value::U64(value as u64); + } + Ok(()) + } + + #[inline] + fn serialize_usize(&mut self, value: usize) -> Result<(), Error> { + self.serialize_u64(value as u64) + } + + #[inline] + fn serialize_u8(&mut self, value: u8) -> Result<(), Error> { + self.serialize_u64(value as u64) + } + + #[inline] + fn serialize_u16(&mut self, value: u16) -> Result<(), Error> { + self.serialize_u64(value as u64) + } + + #[inline] + fn serialize_u32(&mut self, value: u32) -> Result<(), Error> { + self.serialize_u64(value as u64) + } + + #[inline] + fn serialize_u64(&mut self, value: u64) -> Result<(), Error> { + self.value = Value::U64(value); + Ok(()) + } + + #[inline] + fn serialize_f32(&mut self, value: f32) -> Result<(), Error> { + self.serialize_f64(value as f64) + } + + #[inline] + fn serialize_f64(&mut self, value: f64) -> Result<(), Error> { + self.value = Value::F64(value); + Ok(()) + } + + #[inline] + fn serialize_char(&mut self, value: char) -> Result<(), Error> { + let mut s = String::new(); + s.push(value); + self.serialize_str(&s) + } + + #[inline] + fn serialize_str(&mut self, value: &str) -> Result<(), Error> { + self.value = Value::String(String::from(value)); + Ok(()) + } + + fn serialize_bytes(&mut self, value: &[u8]) -> Result<(), Error> { + let mut state = self.serialize_seq(Some(value.len()))?; + for byte in value { + self.serialize_seq_elt(&mut state, byte)?; + } + self.serialize_seq_end(state) + } + + #[inline] + fn serialize_unit(&mut self) -> Result<(), Error> { + Ok(()) + } + + #[inline] + fn serialize_unit_struct(&mut self, _name: &'static str) -> Result<(), Error> { + self.serialize_unit() + } + + #[inline] + fn serialize_unit_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + ) -> Result<(), Error> { + self.serialize_str(variant) + } + + #[inline] + fn serialize_newtype_struct(&mut self, _name: &'static str, value: T) -> Result<(), Error> + where + T: ser::Serialize, + { + value.serialize(self) + } + + fn serialize_newtype_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + value: T, + ) -> Result<(), Error> + where + T: ser::Serialize, + { + let mut values = Map::new(); + values.insert(String::from(variant), to_value(&value)); + self.value = Value::Object(values); + Ok(()) + } + + #[inline] + fn serialize_none(&mut self) -> Result<(), Error> { + self.serialize_unit() + } + + #[inline] + fn serialize_some(&mut self, value: V) -> Result<(), Error> + where + V: ser::Serialize, + { + value.serialize(self) + } + + fn serialize_seq(&mut self, len: Option) -> Result, Error> { + Ok(Vec::with_capacity(len.unwrap_or(0))) + } + + fn serialize_seq_elt( + &mut self, + state: &mut Vec, + value: T, + ) -> Result<(), Error> + where + T: ser::Serialize, + { + state.push(to_value(&value)); + Ok(()) + } + + fn serialize_seq_end(&mut self, state: Vec) -> Result<(), Error> { + self.value = Value::Array(state); + Ok(()) + } + + fn serialize_seq_fixed_size(&mut self, size: usize) -> Result, Error> { + self.serialize_seq(Some(size)) + } + + fn serialize_tuple(&mut self, len: usize) -> Result, Error> { + self.serialize_seq(Some(len)) + } + + fn serialize_tuple_elt( + &mut self, + state: &mut Vec, + value: T, + ) -> Result<(), Error> { + self.serialize_seq_elt(state, value) + } + + fn serialize_tuple_end(&mut self, state: Vec) -> Result<(), Error> { + self.serialize_seq_end(state) + } + + fn serialize_tuple_struct( + &mut self, + _name: &'static str, + len: usize, + ) -> Result, Error> { + self.serialize_seq(Some(len)) + } + + fn serialize_tuple_struct_elt( + &mut self, + state: &mut Vec, + value: T, + ) -> Result<(), Error> { + self.serialize_seq_elt(state, value) + } + + fn serialize_tuple_struct_end(&mut self, state: Vec) -> Result<(), Error> { + self.serialize_seq_end(state) + } + + fn serialize_tuple_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + len: usize, + ) -> Result { + Ok(TupleVariantState { + name: String::from(variant), + vec: Vec::with_capacity(len), + }) + } + + fn serialize_tuple_variant_elt( + &mut self, + state: &mut TupleVariantState, + value: T, + ) -> Result<(), Error> { + state.vec.push(to_value(&value)); + Ok(()) + } + + fn serialize_tuple_variant_end(&mut self, state: TupleVariantState) -> Result<(), Error> { + let mut object = Map::new(); + + object.insert(state.name, Value::Array(state.vec)); + + self.value = Value::Object(object); + Ok(()) + } + + fn serialize_map(&mut self, _len: Option) -> Result { + Ok(MapState { + map: Map::new(), + next_key: None, + }) + } + + fn serialize_map_key( + &mut self, + state: &mut MapState, + key: T, + ) -> Result<(), Error> { + match to_value(&key) { + Value::String(s) => state.next_key = Some(s), + _ => return Err(Error::Syntax(ErrorCode::KeyMustBeAString, 0, 0)), + }; + Ok(()) + } + + fn serialize_map_value( + &mut self, + state: &mut MapState, + value: T, + ) -> Result<(), Error> { + match state.next_key.take() { + Some(key) => state.map.insert(key, to_value(&value)), + None => { + return Err(Error::Syntax( + ErrorCode::Custom( + "serialize_map_value without \ + matching serialize_map_key" + .to_owned(), + ), + 0, + 0, + )); + } + }; + Ok(()) + } + + fn serialize_map_end(&mut self, state: MapState) -> Result<(), Error> { + self.value = Value::Object(state.map); + Ok(()) + } + + fn serialize_struct(&mut self, _name: &'static str, len: usize) -> Result { + self.serialize_map(Some(len)) + } + + fn serialize_struct_elt( + &mut self, + state: &mut MapState, + key: &'static str, + value: V, + ) -> Result<(), Error> { + self.serialize_map_key(state, key)?; + self.serialize_map_value(state, value) + } + + fn serialize_struct_end(&mut self, state: MapState) -> Result<(), Error> { + self.serialize_map_end(state) + } + + fn serialize_struct_variant( + &mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str, + _len: usize, + ) -> Result { + Ok(StructVariantState { + name: String::from(variant), + map: Map::new(), + }) + } + + fn serialize_struct_variant_elt( + &mut self, + state: &mut StructVariantState, + key: &'static str, + value: V, + ) -> Result<(), Error> { + state.map.insert(String::from(key), to_value(&value)); + Ok(()) + } + + fn serialize_struct_variant_end(&mut self, state: StructVariantState) -> Result<(), Error> { + let mut object = Map::new(); + + object.insert(state.name, Value::Object(state.map)); + + self.value = Value::Object(object); + Ok(()) + } +} + +/// Creates a `serde::Deserializer` from a `Value` object. +pub struct Deserializer { + value: Option, +} + +impl Deserializer { + /// Creates a new deserializer instance for deserializing the specified Hjson value. + pub fn new(value: Value) -> Deserializer { + Deserializer { value: Some(value) } + } +} + +impl de::Deserializer for Deserializer { + type Error = Error; + + #[inline] + fn deserialize(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + let value = match self.value.take() { + Some(value) => value, + None => { + return Err(de::Error::end_of_stream()); + } + }; + + match value { + Value::Null => visitor.visit_unit(), + Value::Bool(v) => visitor.visit_bool(v), + Value::I64(v) => visitor.visit_i64(v), + Value::U64(v) => visitor.visit_u64(v), + Value::F64(v) => visitor.visit_f64(v), + Value::String(v) => visitor.visit_string(v), + Value::Array(v) => { + let len = v.len(); + visitor.visit_seq(SeqDeserializer { + de: self, + iter: v.into_iter(), + len, + }) + } + Value::Object(v) => { + let len = v.len(); + visitor.visit_map(MapDeserializer { + de: self, + iter: v.into_iter(), + value: None, + len, + }) + } + } + } + + #[inline] + fn deserialize_option(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + match self.value { + Some(Value::Null) => visitor.visit_none(), + Some(_) => visitor.visit_some(self), + None => Err(de::Error::end_of_stream()), + } + } + + #[inline] + fn deserialize_enum( + &mut self, + _name: &str, + _variants: &'static [&'static str], + mut visitor: V, + ) -> Result + where + V: de::EnumVisitor, + { + let (variant, value) = match self.value.take() { + Some(Value::Object(value)) => { + let mut iter = value.into_iter(); + let (variant, value) = match iter.next() { + Some(v) => v, + None => { + return Err(de::Error::invalid_type(de::Type::VariantName)); + } + }; + // enums are encoded in json as maps with a single key:value pair + if iter.next().is_some() { + return Err(de::Error::invalid_type(de::Type::Map)); + } + (variant, Some(value)) + } + Some(Value::String(variant)) => (variant, None), + Some(_) => { + return Err(de::Error::invalid_type(de::Type::Enum)); + } + None => { + return Err(de::Error::end_of_stream()); + } + }; + + visitor.visit(VariantDeserializer { + de: self, + val: value, + variant: Some(Value::String(variant)), + }) + } + + #[inline] + fn deserialize_newtype_struct( + &mut self, + _name: &'static str, + mut visitor: V, + ) -> Result + where + V: de::Visitor, + { + visitor.visit_newtype_struct(self) + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_ignored_any(); + } +} + +struct VariantDeserializer<'a> { + de: &'a mut Deserializer, + val: Option, + variant: Option, +} + +impl<'a> de::VariantVisitor for VariantDeserializer<'a> { + type Error = Error; + + fn visit_variant(&mut self) -> Result + where + V: de::Deserialize, + { + let variant = self.variant.take().expect("variant is missing"); + de::Deserialize::deserialize(&mut Deserializer::new(variant)) + } + + fn visit_unit(&mut self) -> Result<(), Error> { + match self.val.take() { + Some(val) => de::Deserialize::deserialize(&mut Deserializer::new(val)), + None => Ok(()), + } + } + + fn visit_newtype(&mut self) -> Result + where + T: de::Deserialize, + { + let val = self.val.take().expect("val is missing"); + de::Deserialize::deserialize(&mut Deserializer::new(val)) + } + + fn visit_tuple(&mut self, _len: usize, visitor: V) -> Result + where + V: de::Visitor, + { + let val = self.val.take().expect("val is missing"); + if let Value::Array(fields) = val { + de::Deserializer::deserialize( + &mut SeqDeserializer { + de: self.de, + len: fields.len(), + iter: fields.into_iter(), + }, + visitor, + ) + } else { + Err(de::Error::invalid_type(de::Type::Tuple)) + } + } + + fn visit_struct( + &mut self, + _fields: &'static [&'static str], + visitor: V, + ) -> Result + where + V: de::Visitor, + { + let val = self.val.take().expect("val is missing"); + if let Value::Object(fields) = val { + de::Deserializer::deserialize( + &mut MapDeserializer { + de: self.de, + len: fields.len(), + iter: fields.into_iter(), + value: None, + }, + visitor, + ) + } else { + Err(de::Error::invalid_type(de::Type::Struct)) + } + } +} + +struct SeqDeserializer<'a> { + de: &'a mut Deserializer, + iter: vec::IntoIter, + len: usize, +} + +impl<'a> de::Deserializer for SeqDeserializer<'a> { + type Error = Error; + + #[inline] + fn deserialize(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + if self.len == 0 { + visitor.visit_unit() + } else { + visitor.visit_seq(self) + } + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_option(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_newtype_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_enum(name: &'static str, variants: &'static [&'static str]); + deserialize_ignored_any(); + } +} + +impl<'a> de::SeqVisitor for SeqDeserializer<'a> { + type Error = Error; + + fn visit(&mut self) -> Result, Error> + where + T: de::Deserialize, + { + match self.iter.next() { + Some(value) => { + self.len -= 1; + self.de.value = Some(value); + Ok(Some(de::Deserialize::deserialize(self.de)?)) + } + None => Ok(None), + } + } + + fn end(&mut self) -> Result<(), Error> { + if self.len == 0 { + Ok(()) + } else { + Err(de::Error::invalid_length(self.len)) + } + } + + fn size_hint(&self) -> (usize, Option) { + (self.len, Some(self.len)) + } +} + +struct MapDeserializer<'a> { + de: &'a mut Deserializer, + iter: MapIntoIter, + value: Option, + len: usize, +} + +impl<'a> de::MapVisitor for MapDeserializer<'a> { + type Error = Error; + + fn visit_key(&mut self) -> Result, Error> + where + T: de::Deserialize, + { + match self.iter.next() { + Some((key, value)) => { + self.len -= 1; + self.value = Some(value); + self.de.value = Some(Value::String(key)); + Ok(Some(de::Deserialize::deserialize(self.de)?)) + } + None => Ok(None), + } + } + + fn visit_value(&mut self) -> Result + where + T: de::Deserialize, + { + let value = self.value.take().expect("value is missing"); + self.de.value = Some(value); + Ok(de::Deserialize::deserialize(self.de)?) + } + + fn end(&mut self) -> Result<(), Error> { + if self.len == 0 { + Ok(()) + } else { + Err(de::Error::invalid_length(self.len)) + } + } + + fn missing_field(&mut self, field: &'static str) -> Result + where + V: de::Deserialize, + { + struct MissingFieldDeserializer(&'static str); + + impl de::Deserializer for MissingFieldDeserializer { + type Error = de::value::Error; + + fn deserialize(&mut self, _visitor: V) -> Result + where + V: de::Visitor, + { + let &mut MissingFieldDeserializer(field) = self; + Err(de::value::Error::MissingField(field)) + } + + fn deserialize_option(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + visitor.visit_none() + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_newtype_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_enum(name: &'static str, variants: &'static [&'static str]); + deserialize_ignored_any(); + } + } + + let mut de = MissingFieldDeserializer(field); + Ok(de::Deserialize::deserialize(&mut de)?) + } + + fn size_hint(&self) -> (usize, Option) { + (self.len, Some(self.len)) + } +} + +impl<'a> de::Deserializer for MapDeserializer<'a> { + type Error = Error; + + #[inline] + fn deserialize(&mut self, mut visitor: V) -> Result + where + V: de::Visitor, + { + visitor.visit_map(self) + } + + forward_to_deserialize! { + deserialize_bool(); + deserialize_usize(); + deserialize_u8(); + deserialize_u16(); + deserialize_u32(); + deserialize_u64(); + deserialize_isize(); + deserialize_i8(); + deserialize_i16(); + deserialize_i32(); + deserialize_i64(); + deserialize_f32(); + deserialize_f64(); + deserialize_char(); + deserialize_str(); + deserialize_string(); + deserialize_unit(); + deserialize_option(); + deserialize_seq(); + deserialize_seq_fixed_size(len: usize); + deserialize_bytes(); + deserialize_map(); + deserialize_unit_struct(name: &'static str); + deserialize_newtype_struct(name: &'static str); + deserialize_tuple_struct(name: &'static str, len: usize); + deserialize_struct(name: &'static str, fields: &'static [&'static str]); + deserialize_struct_field(); + deserialize_tuple(len: usize); + deserialize_enum(name: &'static str, variants: &'static [&'static str]); + deserialize_ignored_any(); + } +} + +pub fn to_value(value: &T) -> Value +where + T: ser::Serialize, +{ + let mut ser = Serializer::new(); + value.serialize(&mut ser).expect("failed to serialize"); + ser.unwrap() +} + +/// Shortcut function to decode a Hjson `Value` into a `T` +pub fn from_value(value: Value) -> Result +where + T: de::Deserialize, +{ + let mut de = Deserializer::new(value); + de::Deserialize::deserialize(&mut de) +} + +/// A trait for converting values to Hjson +pub trait ToJson { + /// Converts the value of `self` to an instance of Hjson + fn to_json(&self) -> Value; +} + +impl ToJson for T +where + T: ser::Serialize, +{ + fn to_json(&self) -> Value { + to_value(&self) + } +} + +#[cfg(test)] +mod test { + use super::Value; + use crate::de::from_str; + + #[test] + fn number_deserialize() { + let v: Value = from_str("{\"a\":1}").expect("Internal error: json parsing"); + let vo = v.as_object().expect("Internal error: json parsing"); + assert_eq!(vo["a"].as_u64().expect("Internal error: json parsing"), 1); + + let v: Value = from_str("{\"a\":-1}").expect("Internal error: json parsing"); + let vo = v.as_object().expect("Internal error: json parsing"); + assert_eq!(vo["a"].as_i64().expect("Internal error: json parsing"), -1); + } +} diff --git a/crates/nu-protocol/src/value/primitive.rs b/crates/nu-protocol/src/value/primitive.rs index 02ce1a6d4d..3d06eac10c 100644 --- a/crates/nu-protocol/src/value/primitive.rs +++ b/crates/nu-protocol/src/value/primitive.rs @@ -307,7 +307,7 @@ pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> S ); for member in members { - f.push_str("."); + f.push('.'); f.push_str(&member.display()) } diff --git a/crates/nu-source/src/text.rs b/crates/nu-source/src/text.rs index 3448ac07a2..7346e67988 100644 --- a/crates/nu-source/src/text.rs +++ b/crates/nu-source/src/text.rs @@ -3,7 +3,6 @@ use std::cmp::Ordering; use std::hash::Hash; use std::hash::Hasher; use std::ops::Range; -use std::sync::Arc; /// A "Text" is like a string except that it can be cheaply cloned. /// You can also "extract" subtexts quite cheaply. You can also deref @@ -12,7 +11,7 @@ use std::sync::Arc; /// Used to represent the value of an input file. #[derive(Clone)] pub struct Text { - text: Arc, + text: String, start: usize, end: usize, } @@ -39,11 +38,11 @@ impl Text { } } -impl From> for Text { - fn from(text: Arc) -> Self { +impl From<&str> for Text { + fn from(text: &str) -> Self { let end = text.len(); Self { - text, + text: text.to_string(), start: 0, end, } @@ -58,19 +57,12 @@ impl AsRef for Text { impl From for Text { fn from(text: String) -> Self { - Text::from(Arc::new(text)) - } -} - -impl From<&String> for Text { - fn from(text: &String) -> Self { - Text::from(text.to_string()) - } -} - -impl From<&str> for Text { - fn from(text: &str) -> Self { - Text::from(text.to_string()) + let end = text.len(); + Self { + text, + start: 0, + end, + } } } diff --git a/crates/nu-value-ext/src/lib.rs b/crates/nu-value-ext/src/lib.rs index 7cec7aea31..d085018698 100644 --- a/crates/nu-value-ext/src/lib.rs +++ b/crates/nu-value-ext/src/lib.rs @@ -508,7 +508,7 @@ pub fn forgiving_insert_data_at_column_path( } UnspannedPathMember::Int(int) => { let mut rows = vec![]; - let size = int.to_usize().unwrap_or_else(|| 0); + let size = int.to_usize().unwrap_or(0); for _ in 0..=size { rows.push( diff --git a/crates/nu_plugin_binaryview/src/binaryview.rs b/crates/nu_plugin_binaryview/src/binaryview.rs index 4e84f0716c..ba3d9a250b 100644 --- a/crates/nu_plugin_binaryview/src/binaryview.rs +++ b/crates/nu_plugin_binaryview/src/binaryview.rs @@ -149,7 +149,7 @@ impl RenderContext { } } pub fn update(&mut self) -> Result<(), Box> { - let terminal_size = crossterm::terminal::size().unwrap_or_else(|_| (80, 24)); + let terminal_size = crossterm::terminal::size().unwrap_or((80, 24)); if (self.width != terminal_size.0 as usize) || (self.height != terminal_size.1 as usize) { let _ = std::io::stdout().execute(crossterm::cursor::Hide); diff --git a/crates/nu_plugin_chart/src/line.rs b/crates/nu_plugin_chart/src/line.rs index 6662a2465d..0d1b6bf090 100644 --- a/crates/nu_plugin_chart/src/line.rs +++ b/crates/nu_plugin_chart/src/line.rs @@ -119,9 +119,8 @@ impl<'a> Line<'a> { .marker(marker) .graph_type(GraphType::Line) .style( - Style::default().fg(*DEFAULT_LINE_COLORS - .get(idx) - .unwrap_or_else(|| &DEFAULT_COLOR)), + Style::default() + .fg(*DEFAULT_LINE_COLORS.get(idx).unwrap_or(&DEFAULT_COLOR)), ) .data(data_series) }) diff --git a/crates/nu_plugin_chart/src/nu/bar.rs b/crates/nu_plugin_chart/src/nu/bar.rs index e470762327..b245a0f3a3 100644 --- a/crates/nu_plugin_chart/src/nu/bar.rs +++ b/crates/nu_plugin_chart/src/nu/bar.rs @@ -284,7 +284,7 @@ impl SubCommand { let formatter = if self.format.is_some() { let default = String::from("%b-%Y"); - let string_fmt = self.format.as_ref().unwrap_or_else(|| &default); + let string_fmt = self.format.as_ref().unwrap_or(&default); Some(nu_data::utils::helpers::date_formatter( string_fmt.to_string(), @@ -331,7 +331,7 @@ impl SubCommand { let formatter = if self.format.is_some() { let default = String::from("%b-%Y"); - let string_fmt = self.format.as_ref().unwrap_or_else(|| &default); + let string_fmt = self.format.as_ref().unwrap_or(&default); Some(nu_data::utils::helpers::date_formatter( string_fmt.to_string(), diff --git a/crates/nu_plugin_chart/src/nu/line.rs b/crates/nu_plugin_chart/src/nu/line.rs index d517ab9861..305ccd9f22 100644 --- a/crates/nu_plugin_chart/src/nu/line.rs +++ b/crates/nu_plugin_chart/src/nu/line.rs @@ -282,7 +282,7 @@ impl SubCommand { let formatter = if self.format.is_some() { let default = String::from("%b-%Y"); - let string_fmt = self.format.as_ref().unwrap_or_else(|| &default); + let string_fmt = self.format.as_ref().unwrap_or(&default); Some(nu_data::utils::helpers::date_formatter( string_fmt.to_string(), @@ -329,7 +329,7 @@ impl SubCommand { let formatter = if self.format.is_some() { let default = String::from("%b-%Y"); - let string_fmt = self.format.as_ref().unwrap_or_else(|| &default); + let string_fmt = self.format.as_ref().unwrap_or(&default); Some(nu_data::utils::helpers::date_formatter( string_fmt.to_string(), diff --git a/crates/nu_plugin_textview/src/textview.rs b/crates/nu_plugin_textview/src/textview.rs index e5a527e799..a39363d15d 100644 --- a/crates/nu_plugin_textview/src/textview.rs +++ b/crates/nu_plugin_textview/src/textview.rs @@ -13,7 +13,7 @@ impl TextView { #[allow(clippy::cognitive_complexity)] pub fn view_text_value(value: &Value) { - let (mut term_width, _) = term_size::dimensions().unwrap_or_else(|| (80, 20)); + let (mut term_width, _) = term_size::dimensions().unwrap_or((80, 20)); let mut tab_width: u64 = 4; let mut colored_output = true; let mut true_color = true;