diff --git a/Cargo.lock b/Cargo.lock index 0723cf1..3a473b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,12 +3,12 @@ version = 3 [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "aho-corasick" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ - "libc", + "memchr", ] [[package]] @@ -28,12 +28,17 @@ name = "automation" version = "0.1.0" dependencies = [ "dotenv", + "env_logger", "google-home", "impl_cast", + "log", "paste", + "pollster", "rumqttc", "serde", "serde_json", + "tokio", + "warp", ] [[package]] @@ -48,12 +53,37 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "buf_redux" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" +dependencies = [ + "memchr", + "safemem", +] + [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.3.0" @@ -72,29 +102,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "num-integer", - "num-traits", - "serde", - "winapi", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "core-foundation" version = "0.9.3" @@ -112,82 +119,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] -name = "cxx" -version = "1.0.83" +name = "cpufeatures" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", + "libc", ] [[package]] -name = "cxx-build" -version = "1.0.83" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", + "generic-array", + "typenum", ] [[package]] -name = "cxxbridge-flags" -version = "1.0.83" +name = "digest" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "darling" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" -dependencies = [ - "darling_core", - "quote", - "syn", + "block-buffer", + "crypto-common", ] [[package]] @@ -196,6 +153,49 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + [[package]] name = "flume" version = "0.10.14" @@ -215,6 +215,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.25" @@ -304,6 +313,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -325,9 +344,26 @@ dependencies = [ "impl_cast", "serde", "serde_json", - "serde_with", "thiserror", - "uuid", +] + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] @@ -337,40 +373,112 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "hex" -version = "0.4.3" +name = "headers" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", + "base64", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", ] [[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" +name = "headers-core" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "cxx", - "cxx-build", + "http", ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "hermit-abi" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] [[package]] name = "impl_cast" @@ -387,7 +495,37 @@ checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", "hashbrown", - "serde", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys 0.42.0", ] [[package]] @@ -418,13 +556,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" [[package]] -name = "link-cplusplus" -version = "1.0.7" +name = "linux-raw-sys" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "lock_api" @@ -451,6 +586,22 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "mio" version = "0.8.5" @@ -463,6 +614,24 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "multipart" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182" +dependencies = [ + "buf_redux", + "httparse", + "log", + "mime", + "mime_guess", + "quick-error", + "rand", + "safemem", + "tempfile", + "twoway", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -473,22 +642,13 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "num_cpus" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", + "hermit-abi", + "libc", ] [[package]] @@ -503,12 +663,41 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + [[package]] name = "paste" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b" +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pin-project" version = "1.0.12" @@ -547,6 +736,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5da3b0203fd7ee5720aa0b5e790b591aa5d3f41c3ed2c34a3a393382198af2f7" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro2" version = "1.0.47" @@ -556,6 +751,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.21" @@ -565,6 +766,71 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + [[package]] name = "ring" version = "0.16.20" @@ -598,6 +864,20 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "rustix" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "rustls" version = "0.20.7" @@ -622,6 +902,15 @@ dependencies = [ "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "rustls-pemfile" version = "0.3.0" @@ -646,6 +935,12 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "schannel" version = "0.1.20" @@ -656,18 +951,18 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "sct" version = "0.7.0" @@ -733,31 +1028,46 @@ dependencies = [ ] [[package]] -name = "serde_with" -version = "2.1.0" +name = "serde_urlencoded" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ - "base64", - "chrono", - "hex", - "indexmap", + "form_urlencoded", + "itoa", + "ryu", "serde", - "serde_json", - "serde_with_macros", - "time", ] [[package]] -name = "serde_with_macros" -version = "2.1.0" +name = "sha-1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", ] [[package]] @@ -769,6 +1079,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "socket2" version = "0.4.7" @@ -794,12 +1110,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" version = "1.0.105" @@ -811,6 +1121,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -841,31 +1165,19 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.3.17" +name = "tinyvec" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", + "tinyvec_macros", ] [[package]] -name = "time-core" +name = "tinyvec_macros" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" -dependencies = [ - "time-core", -] +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" @@ -878,7 +1190,10 @@ dependencies = [ "libc", "memchr", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.42.0", @@ -906,6 +1221,125 @@ dependencies = [ "webpki", ] +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand", + "sha-1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "twoway" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" +dependencies = [ + "memchr", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + [[package]] name = "unicode-ident" version = "1.0.5" @@ -913,10 +1347,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] -name = "unicode-width" -version = "0.1.10" +name = "unicode-normalization" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] [[package]] name = "untrusted" @@ -925,13 +1362,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] -name = "uuid" -version = "1.2.2" +name = "url" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ - "getrandom", + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "warp" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7b8be92646fc3d18b06147664ebc5f48d222686cb11a8755e561a735aacc6d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "headers", + "http", + "hyper", + "log", + "mime", + "mime_guess", + "multipart", + "percent-encoding", + "pin-project", + "rustls-pemfile 0.2.1", + "scoped-tls", "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-stream", + "tokio-tungstenite", + "tokio-util", + "tower-service", + "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d6b320f..cce90a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,11 @@ dotenv = "0.15.0" impl_cast = {path = "./impl_cast"} google-home = {path = "./google-home"} paste = "1.0.10" +tokio = { version = "1", features = ["full"] } +warp = "0.3" +log = "0.4" +env_logger = "0.10" +pollster = "0.2.5" [profile.release] lto=true diff --git a/google-home/Cargo.lock b/google-home/Cargo.lock index 1a81c7a..f4d297e 100644 --- a/google-home/Cargo.lock +++ b/google-home/Cargo.lock @@ -2,165 +2,12 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "bumpalo" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" - -[[package]] -name = "cc" -version = "1.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "num-integer", - "num-traits", - "serde", - "winapi", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "cxx" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "darling" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "google-home" version = "0.1.0" @@ -169,52 +16,9 @@ dependencies = [ "impl_cast", "serde", "serde_json", - "serde_with", "thiserror", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "impl_cast" version = "0.1.0" @@ -222,81 +26,12 @@ dependencies = [ "paste", ] -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - [[package]] name = "itoa" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" -[[package]] -name = "js-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.138" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" - -[[package]] -name = "link-cplusplus" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" - [[package]] name = "paste" version = "1.0.10" @@ -327,12 +62,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "serde" version = "1.0.149" @@ -364,40 +93,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef" -dependencies = [ - "base64", - "chrono", - "hex", - "indexmap", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" version = "1.0.105" @@ -409,15 +104,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.37" @@ -438,126 +124,8 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" -dependencies = [ - "time-core", -] - [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/google-home/Cargo.toml b/google-home/Cargo.toml index 1e7f7f7..cd89f18 100644 --- a/google-home/Cargo.toml +++ b/google-home/Cargo.toml @@ -10,5 +10,4 @@ anyhow = "1.0.66" impl_cast = { path = "../impl_cast" } serde = { version ="1.0.149", features = ["derive"] } serde_json = "1.0.89" -serde_with = "2.1.0" thiserror = "1.0.37" diff --git a/google-home/src/attributes.rs b/google-home/src/attributes.rs index 6ab43d6..44dee16 100644 --- a/google-home/src/attributes.rs +++ b/google-home/src/attributes.rs @@ -1,11 +1,12 @@ use serde::Serialize; -use serde_with::skip_serializing_none; -#[skip_serializing_none] #[derive(Debug, Default, Serialize)] #[serde(rename_all = "camelCase")] pub struct Attributes { + #[serde(skip_serializing_if = "Option::is_none")] pub command_only_on_off: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub query_only_on_off: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub scene_reversible: Option, } diff --git a/google-home/src/device.rs b/google-home/src/device.rs index 87985b9..8a25359 100644 --- a/google-home/src/device.rs +++ b/google-home/src/device.rs @@ -1,5 +1,4 @@ use serde::Serialize; -use serde_with::skip_serializing_none; use crate::{response, types::Type, traits::{AsOnOff, Trait, AsScene}, errors::{DeviceError, ErrorCode}, request::execute::CommandType}; @@ -19,10 +18,9 @@ pub trait GoogleHomeDevice: AsOnOff + AsScene { fn get_device_info(&self) -> Option { None } -} -// This trait exists just to hide the sync, query and execute function from the user -pub trait Fullfillment: GoogleHomeDevice { + + fn sync(&self) -> response::sync::Device { let name = self.get_device_name(); let mut device = response::sync::Device::new(&self.get_id(), &name.name, self.get_device_type()); @@ -93,8 +91,6 @@ pub trait Fullfillment: GoogleHomeDevice { } } -impl Fullfillment for T {} - #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Name { @@ -119,13 +115,16 @@ impl Name { } } -#[skip_serializing_none] #[derive(Debug, Default, Serialize)] #[serde(rename_all = "camelCase")] pub struct Info { + #[serde(skip_serializing_if = "Option::is_none")] pub manufacturer: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub model: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub hw_version: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub sw_version: Option, // attributes // customData diff --git a/google-home/src/fullfillment.rs b/google-home/src/fullfillment.rs index 6b674f0..adaa7c2 100644 --- a/google-home/src/fullfillment.rs +++ b/google-home/src/fullfillment.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use crate::{request::{Request, Intent, self}, device::Fullfillment, response::{sync, ResponsePayload, query, execute, Response, self, State}, errors::{DeviceError, ErrorCode}}; +use crate::{request::{Request, Intent, self}, device::GoogleHomeDevice, response::{sync, ResponsePayload, query, execute, Response, self, State}, errors::{DeviceError, ErrorCode}}; pub struct GoogleHome { user_id: String, @@ -12,7 +12,7 @@ impl GoogleHome { Self { user_id: user_id.into() } } - pub fn handle_request(&self, request: Request, mut devices: &mut HashMap) -> Result { + pub fn handle_request(&self, request: Request, mut devices: &mut HashMap) -> Result { // @TODO What do we do if we actually get more then one thing in the input array, right now // we only respond to the first thing let payload = request @@ -30,7 +30,7 @@ impl GoogleHome { } } - fn sync(&self, devices: &HashMap) -> sync::Payload { + fn sync(&self, devices: &HashMap) -> sync::Payload { let mut resp_payload = sync::Payload::new(&self.user_id); resp_payload.devices = devices .iter() @@ -40,7 +40,7 @@ impl GoogleHome { return resp_payload; } - fn query(&self, payload: request::query::Payload, devices: &HashMap) -> query::Payload { + fn query(&self, payload: request::query::Payload, devices: &HashMap) -> query::Payload { let mut resp_payload = query::Payload::new(); resp_payload.devices = payload.devices .into_iter() @@ -62,7 +62,7 @@ impl GoogleHome { } - fn execute(&self, payload: request::execute::Payload, devices: &mut HashMap) -> execute::Payload { + fn execute(&self, payload: request::execute::Payload, devices: &mut HashMap) -> execute::Payload { let mut resp_payload = response::execute::Payload::new(); payload.commands @@ -240,7 +240,7 @@ mod tests { let mut nightstand = TestOutlet::new("bedroom/nightstand"); let mut lamp = TestOutlet::new("living/lamp"); let mut scene = TestScene::new(); - let mut devices: HashMap = HashMap::new(); + let mut devices: HashMap = HashMap::new(); devices.insert(nightstand.get_id(), &mut nightstand); devices.insert(lamp.get_id(), &mut lamp); devices.insert(scene.get_id(), &mut scene); @@ -280,7 +280,7 @@ mod tests { let mut nightstand = TestOutlet::new("bedroom/nightstand"); let mut lamp = TestOutlet::new("living/lamp"); let mut scene = TestScene::new(); - let mut devices: HashMap = HashMap::new(); + let mut devices: HashMap = HashMap::new(); devices.insert(nightstand.get_id(), &mut nightstand); devices.insert(lamp.get_id(), &mut lamp); devices.insert(scene.get_id(), &mut scene); @@ -332,7 +332,7 @@ mod tests { let mut nightstand = TestOutlet::new("bedroom/nightstand"); let mut lamp = TestOutlet::new("living/lamp"); let mut scene = TestScene::new(); - let mut devices: HashMap = HashMap::new(); + let mut devices: HashMap = HashMap::new(); devices.insert(nightstand.get_id(), &mut nightstand); devices.insert(lamp.get_id(), &mut lamp); devices.insert(scene.get_id(), &mut scene); diff --git a/google-home/src/lib.rs b/google-home/src/lib.rs index 6f22ec3..f22d1b1 100644 --- a/google-home/src/lib.rs +++ b/google-home/src/lib.rs @@ -11,5 +11,5 @@ pub mod errors; mod attributes; pub use fullfillment::GoogleHome; -pub use device::Fullfillment; +pub use request::Request; pub use device::GoogleHomeDevice; diff --git a/google-home/src/response.rs b/google-home/src/response.rs index e4b79a0..ef4b6b7 100644 --- a/google-home/src/response.rs +++ b/google-home/src/response.rs @@ -3,7 +3,6 @@ pub mod query; pub mod execute; use serde::Serialize; -use serde_with::skip_serializing_none; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -26,9 +25,9 @@ pub enum ResponsePayload { Execute(execute::Payload), } -#[skip_serializing_none] #[derive(Debug, Default, Serialize)] #[serde(rename_all = "camelCase")] pub struct State { + #[serde(skip_serializing_if = "Option::is_none")] pub on: Option, } diff --git a/google-home/src/response/execute.rs b/google-home/src/response/execute.rs index 665cfb4..fe9f7bc 100644 --- a/google-home/src/response/execute.rs +++ b/google-home/src/response/execute.rs @@ -1,13 +1,13 @@ use serde::Serialize; -use serde_with::skip_serializing_none; use crate::{response::State, errors::ErrorCode}; -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Payload { + #[serde(skip_serializing_if = "Option::is_none")] pub error_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub debug_string: Option, commands: Vec, } @@ -24,14 +24,15 @@ impl Payload { } } -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Command { + #[serde(skip_serializing_if = "Option::is_none")] pub error_code: Option, ids: Vec, status: Status, + #[serde(skip_serializing_if = "Option::is_none")] pub states: Option, } diff --git a/google-home/src/response/query.rs b/google-home/src/response/query.rs index af24b3d..4c2eaca 100644 --- a/google-home/src/response/query.rs +++ b/google-home/src/response/query.rs @@ -1,15 +1,15 @@ use std::collections::HashMap; use serde::Serialize; -use serde_with::skip_serializing_none; use crate::{response::State, errors::ErrorCode}; -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Payload { + #[serde(skip_serializing_if = "Option::is_none")] pub error_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub debug_string: Option, pub devices: HashMap, } @@ -33,12 +33,12 @@ pub enum Status { Error, } -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Device { online: bool, status: Status, + #[serde(skip_serializing_if = "Option::is_none")] error_code: Option, #[serde(flatten)] diff --git a/google-home/src/response/sync.rs b/google-home/src/response/sync.rs index 2f3820b..a5c9e9e 100644 --- a/google-home/src/response/sync.rs +++ b/google-home/src/response/sync.rs @@ -1,5 +1,4 @@ use serde::Serialize; -use serde_with::skip_serializing_none; use crate::attributes::Attributes; use crate::device; @@ -7,12 +6,13 @@ use crate::errors::ErrorCode; use crate::types::Type; use crate::traits::Trait; -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Payload { agent_user_id: String, + #[serde(skip_serializing_if = "Option::is_none")] pub error_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub debug_string: Option, pub devices: Vec, } @@ -27,7 +27,6 @@ impl Payload { } } -#[skip_serializing_none] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Device { @@ -37,8 +36,11 @@ pub struct Device { pub traits: Vec, pub name: device::Name, pub will_report_state: bool, + #[serde(skip_serializing_if = "Option::is_none")] pub notification_supported_by_agent: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub room_hint: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub device_info: Option, pub attributes: Attributes, } diff --git a/src/devices.rs b/src/devices.rs index 9f44259..77768a6 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -6,20 +6,22 @@ pub use self::test_outlet::TestOutlet; use std::collections::HashMap; -use google_home::{Fullfillment, traits::OnOff}; +use google_home::{GoogleHomeDevice, traits::OnOff}; use crate::mqtt::Listener; impl_cast::impl_cast!(Device, Listener); -impl_cast::impl_cast!(Device, Fullfillment); +impl_cast::impl_cast!(Device, GoogleHomeDevice); impl_cast::impl_cast!(Device, OnOff); -pub trait Device: Sync + Send + AsFullfillment + AsListener + AsOnOff { +pub trait Device: AsGoogleHomeDevice + AsListener + AsOnOff { fn get_id(&self) -> String; } +// @TODO Add an inner type that we can wrap with Arc> to make this type a little bit nicer +// to work with pub struct Devices { - devices: HashMap>, + devices: HashMap>, } macro_rules! get_cast { @@ -44,12 +46,12 @@ impl Devices { Self { devices: HashMap::new() } } - pub fn add_device(&mut self, device: T) { + pub fn add_device(&mut self, device: T) { self.devices.insert(device.get_id(), Box::new(device)); } get_cast!(Listener); - get_cast!(Fullfillment); + get_cast!(GoogleHomeDevice); get_cast!(OnOff); pub fn get_device(&mut self, name: &str) -> Option<&mut dyn Device> { diff --git a/src/devices/ikea_outlet.rs b/src/devices/ikea_outlet.rs index c4690f6..c5ec419 100644 --- a/src/devices/ikea_outlet.rs +++ b/src/devices/ikea_outlet.rs @@ -1,7 +1,10 @@ +use pollster::FutureExt as _; + use google_home::errors::ErrorCode; use google_home::{GoogleHomeDevice, device, types::Type, traits}; -use rumqttc::{Client, Publish}; +use rumqttc::{AsyncClient, Publish}; use serde::{Deserialize, Serialize}; +use log::debug; use crate::devices::Device; use crate::mqtt::Listener; @@ -10,13 +13,13 @@ use crate::zigbee::Zigbee; pub struct IkeaOutlet { name: String, zigbee: Zigbee, - client: Client, + client: AsyncClient, last_known_state: bool, } impl IkeaOutlet { - pub fn new(name: String, zigbee: Zigbee, mut client: Client) -> Self { - client.subscribe(zigbee.get_topic(), rumqttc::QoS::AtLeastOnce).unwrap(); + pub fn new(name: String, zigbee: Zigbee, client: AsyncClient) -> Self { + client.subscribe(zigbee.get_topic(), rumqttc::QoS::AtLeastOnce).block_on().unwrap(); Self{ name, zigbee, client, last_known_state: false } } } @@ -51,16 +54,16 @@ impl Listener for IkeaOutlet { if message.topic == self.zigbee.get_topic() { let state = StateMessage::from(message); - print!("Updating state: {} => ", self.last_known_state); - self.last_known_state = state.state == "ON"; - println!("{}", self.last_known_state); + let new_state = state.state == "ON"; + debug!("Updating state: {} => {}", self.last_known_state, new_state); + self.last_known_state = new_state; } } } impl GoogleHomeDevice for IkeaOutlet { fn get_device_type(&self) -> Type { - Type::Outlet + Type::Kettle } fn get_device_name(&self) -> device::Name { @@ -91,8 +94,10 @@ impl traits::OnOff for IkeaOutlet { } }; - // @TODO Handle potential error here - self.client.publish(topic + "/set", rumqttc::QoS::AtLeastOnce, false, serde_json::to_string(&message).unwrap()).unwrap(); + // @TODO Handle potential errors here + // @NOTE We are blocking here, ideally this function would just be async, however that is + // currently not really possible + self.client.publish(topic + "/set", rumqttc::QoS::AtLeastOnce, false, serde_json::to_string(&message).unwrap()).block_on().unwrap(); Ok(()) } diff --git a/src/devices/test_outlet.rs b/src/devices/test_outlet.rs index 6d41840..07a5878 100644 --- a/src/devices/test_outlet.rs +++ b/src/devices/test_outlet.rs @@ -1,3 +1,5 @@ +use log::debug; + use google_home::{errors::ErrorCode, traits}; use super::Device; @@ -24,7 +26,7 @@ impl traits::OnOff for TestOutlet { } fn set_on(&mut self, on: bool) -> Result<(), ErrorCode> { - println!("Setting on: {on}"); + debug!("Setting on: {on}"); self.on = on; Ok(()) } diff --git a/src/main.rs b/src/main.rs index f1d13bc..032880f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,90 +1,86 @@ -use std::{time::Duration, sync::{Arc, RwLock}, process::exit, thread}; +use std::{time::Duration, sync::{Arc, RwLock}, process::exit, net::SocketAddr}; +use warp::Filter; +use rumqttc::{MqttOptions, Transport, AsyncClient}; use dotenv::dotenv; +use env_logger::Builder; +use log::{error, info, LevelFilter}; use automation::{devices::{Devices, IkeaOutlet, TestOutlet}, zigbee::Zigbee, mqtt::Notifier}; -use google_home::GoogleHome; -use rumqttc::{MqttOptions, Transport, Client}; +use google_home::{GoogleHome, Request}; fn get_required_env(name: &str) -> String { match std::env::var(name) { Ok(value) => value, _ => { - eprintln!("Environment variable ${name} is not set!"); + error!("Environment variable ${name} is not set!"); exit(-1); } } } -fn main() { +#[tokio::main] +async fn main() { + // Setup logger + Builder::new() + .filter_module("automation", LevelFilter::Info) + .parse_default_env() + .init(); + + // Load dotfiles dotenv().ok(); + info!("Starting automation_rs..."); + + // Create device holder + // @TODO Make this nices to work with, we devices.rs + let devices = Arc::new(RwLock::new(Devices::new())); + // Setup MQTT let mut mqttoptions = MqttOptions::new("rust-test", get_required_env("MQTT_HOST"), 8883); mqttoptions.set_credentials(get_required_env("MQTT_USERNAME"), get_required_env("MQTT_PASSWORD")); mqttoptions.set_keep_alive(Duration::from_secs(5)); mqttoptions.set_transport(Transport::tls_with_default_config()); - let (client, connection) = Client::new(mqttoptions, 10); - - // Create device holder - let devices = Arc::new(RwLock::new(Devices::new())); + // Create a notifier and move it to a new thread + // @TODO Maybe rename this to make it clear it has to do with mqtt + let mut notifier = Notifier::new(); + let (client, eventloop) = AsyncClient::new(mqttoptions, 10); + notifier.add_listener(Arc::downgrade(&devices)); + tokio::spawn(async move { + info!("Connecting to MQTT broker"); + notifier.start(eventloop).await; + todo!("Error in MQTT (most likely lost connection to mqtt server), we need to handle these errors!"); + }); + // @TODO Load these from a config // Create a new device and add it to the holder devices.write().unwrap().add_device(IkeaOutlet::new("Kettle".into(), Zigbee::new("kitchen/kettle", "zigbee2mqtt/kitchen/kettle"), client.clone())); - devices.write().unwrap().add_device(TestOutlet::new()); - { - for (_, d) in devices.write().unwrap().as_on_offs().iter_mut() { - d.set_on(false).unwrap(); - } - } + // Google Home fullfillments + let fullfillment_google_home = warp::path("google_home") + .and(warp::post()) + .and(warp::body::json()) + .map(move |request: Request| { + // @TODO Verify that we are actually logged in + // Might also be smart to get the username from here + let gc = GoogleHome::new("Dreaded_X"); + let result = gc.handle_request(request, &mut devices.write().unwrap().as_google_home_devices()).unwrap(); - let ptr = Arc::downgrade(&devices); - { - let mut notifier = Notifier::new(); - notifier.add_listener(ptr); - notifier.start(connection); - } + warp::reply::json(&result) + }); - // Google Home test - let gc = GoogleHome::new("Dreaded_X"); - let json = r#"{ - "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", - "inputs": [ - { - "intent": "action.devices.EXECUTE", - "payload": { - "commands": [ - { - "devices": [ - { - "id": "kitchen/kettle" - }, - { - "id": "test_device" - } - ], - "execution": [ - { - "command": "action.devices.commands.OnOff", - "params": { - "on": false - } - } - ] - } - ] - } - } - ] -}"#; - let request = serde_json::from_str(json).unwrap(); - let mut binding = devices.write().unwrap(); - let mut ghd = binding.as_fullfillments(); + // Combine all fullfillments together + let fullfillment = warp::path("fullfillment").and(fullfillment_google_home); - let response = gc.handle_request(request, &mut ghd).unwrap(); + // Combine all routes together + let routes = fullfillment; - println!("{response:?}"); + // Start the web server + let addr: SocketAddr = ([127, 0, 0, 1], 7878).into(); + info!("Server started on http://{addr}"); + warp::serve(routes) + .run(addr) + .await; } diff --git a/src/mqtt.rs b/src/mqtt.rs index c1d35fa..0322458 100644 --- a/src/mqtt.rs +++ b/src/mqtt.rs @@ -1,13 +1,15 @@ use std::sync::{Weak, RwLock}; +use log::error; -use rumqttc::{Publish, Connection, Event, Incoming}; +use rumqttc::{Publish, Event, Incoming, EventLoop}; +use log::trace; -pub trait Listener: Sync + Send { +pub trait Listener { fn notify(&mut self, message: &Publish); } pub struct Notifier { - listeners: Vec>>, + listeners: Vec>>, } impl Notifier { @@ -26,20 +28,21 @@ impl Notifier { }) } - pub fn add_listener(&mut self, listener: Weak>) { + pub fn add_listener(&mut self, listener: Weak>) { self.listeners.push(listener); } - pub fn start(&mut self, mut connection: Connection) { - for notification in connection.iter() { + pub async fn start(&mut self, mut eventloop: EventLoop) { + loop { + let notification = eventloop.poll().await; match notification { Ok(Event::Incoming(Incoming::Publish(p))) => { - println!("{:?}", p); + trace!("{:?}", p); self.notify(p); }, Ok(..) => continue, Err(err) => { - eprintln!("{}", err); + error!("{}", err); break }, }