This commit is contained in:
Michael Zhang 2021-02-16 04:45:41 -06:00
parent 49367abb58
commit 00d67d429f
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
8 changed files with 268 additions and 316 deletions

442
Cargo.lock generated
View file

@ -6,7 +6,16 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
@ -46,7 +55,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -118,12 +127,6 @@ version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -140,7 +143,7 @@ dependencies = [
"num-integer",
"num-traits",
"time",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -149,7 +152,7 @@ version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"ansi_term",
"ansi_term 0.11.0",
"atty",
"bitflags",
"strsim",
@ -174,6 +177,27 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]]
name = "crossbeam-channel"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "crossterm"
version = "0.19.0"
@ -184,10 +208,10 @@ dependencies = [
"crossterm_winapi",
"lazy_static",
"libc",
"mio 0.7.7",
"mio",
"parking_lot",
"signal-hook",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -196,7 +220,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0da8964ace4d3e4a044fd027919b2237000b24315a37c916f61809f1ff2140b9"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -217,18 +241,6 @@ dependencies = [
"log",
]
[[package]]
name = "filetime"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"winapi 0.3.9",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
@ -244,41 +256,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "fsevent"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
dependencies = [
"bitflags",
"fsevent-sys",
]
[[package]]
name = "fsevent-sys"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
dependencies = [
"libc",
]
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "funty"
version = "1.1.0"
@ -386,7 +363,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"wasi",
]
@ -421,13 +398,15 @@ dependencies = [
[[package]]
name = "inotify"
version = "0.7.1"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
checksum = "d19f57db1baad9d09e43a3cd76dcf82ebdafd37d75c9498b87762dba77c93f15"
dependencies = [
"bitflags",
"futures-core",
"inotify-sys",
"libc",
"tokio",
]
[[package]]
@ -445,16 +424,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
"cfg-if",
]
[[package]]
@ -472,28 +442,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "lettre"
version = "0.9.5"
@ -533,7 +487,16 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
name = "matchers"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
"regex-automata",
]
[[package]]
@ -542,25 +505,6 @@ version = "2.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow 0.2.2",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]]
name = "mio"
version = "0.7.7"
@ -569,33 +513,9 @@ checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7"
dependencies = [
"libc",
"log",
"miow 0.3.6",
"miow",
"ntapi",
"winapi 0.3.9",
]
[[package]]
name = "mio-extras"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
dependencies = [
"lazycell",
"log",
"mio 0.6.23",
"slab",
]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
"winapi",
]
[[package]]
@ -605,7 +525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"socket2",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -626,17 +546,6 @@ dependencies = [
"tempfile",
]
[[package]]
name = "net2"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "nom"
version = "4.2.3"
@ -659,31 +568,13 @@ dependencies = [
"version_check 0.9.2",
]
[[package]]
name = "notify"
version = "4.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd"
dependencies = [
"bitflags",
"filetime",
"fsevent",
"fsevent-sys",
"inotify",
"libc",
"mio 0.6.23",
"mio-extras",
"walkdir",
"winapi 0.3.9",
]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -728,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"cfg-if",
"foreign-types",
"lazy_static",
"libc",
@ -760,14 +651,14 @@ version = "0.0.1"
dependencies = [
"anyhow",
"async-trait",
"cfg-if 1.0.0",
"cfg-if",
"chrono",
"crossterm",
"fern",
"futures",
"inotify",
"lettre",
"log",
"notify",
"panorama-imap",
"pin-project",
"rustls-connector",
@ -778,6 +669,9 @@ dependencies = [
"tokio-stream",
"tokio-util",
"toml",
"tracing",
"tracing-appender",
"tracing-subscriber",
"webpki-roots",
"xdg",
]
@ -807,12 +701,12 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -968,13 +862,38 @@ dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
dependencies = [
"byteorder",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -989,7 +908,7 @@ dependencies = [
"spin",
"untrusted",
"web-sys",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1035,15 +954,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "schannel"
version = "0.1.19"
@ -1051,7 +961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [
"lazy_static",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1124,6 +1034,15 @@ dependencies = [
"serde",
]
[[package]]
name = "sharded-slab"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3"
dependencies = [
"lazy_static",
]
[[package]]
name = "signal-hook"
version = "0.1.17"
@ -1131,7 +1050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729"
dependencies = [
"libc",
"mio 0.7.7",
"mio",
"signal-hook-registry",
]
@ -1162,9 +1081,9 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1226,12 +1145,12 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"rand",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1243,6 +1162,15 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "thread_local"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.1.44"
@ -1251,7 +1179,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1264,14 +1192,14 @@ dependencies = [
"bytes",
"libc",
"memchr",
"mio 0.7.7",
"mio",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1333,6 +1261,92 @@ dependencies = [
"serde",
]
[[package]]
name = "tracing"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d40a22fd029e33300d8d89a5cc8ffce18bb7c587662f54629e94c9de5487f3"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-appender"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9965507e507f12c8901432a33e31131222abac31edd90cabbcf85cf544b7127a"
dependencies = [
"chrono",
"crossbeam-channel",
"tracing-subscriber",
]
[[package]]
name = "tracing-attributes"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43f080ea7e4107844ef4766459426fa2d5c1ada2e47edba05dc7fa99d9629f47"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
dependencies = [
"lazy_static",
]
[[package]]
name = "tracing-log"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401"
dependencies = [
"ansi_term 0.12.1",
"chrono",
"lazy_static",
"matchers",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]]
name = "unicode-segmentation"
version = "1.7.1"
@ -1381,17 +1395,6 @@ version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "walkdir"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
dependencies = [
"same-file",
"winapi 0.3.9",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
@ -1404,7 +1407,7 @@ version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"wasm-bindgen-macro",
]
@ -1481,12 +1484,6 @@ dependencies = [
"webpki",
]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.9"
@ -1497,27 +1494,12 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[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 0.3.9",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -1530,17 +1512,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
"winapi",
]
[[package]]

View file

@ -22,7 +22,6 @@ futures = "0.3.12"
panorama-imap = { path = "imap", version = "0" }
lettre = "0.9.5"
log = "0.4.14"
notify = "4.0.15"
pin-project = "1.0.4"
rustls-connector = "0.13.1"
serde = { version = "1.0.123", features = ["derive"] }
@ -34,6 +33,10 @@ tokio-util = { version = "0.6.3", features = ["full"] }
toml = "0.5.8"
webpki-roots = "0.21.0"
xdg = "2.2.0"
tracing = "0.1.23"
tracing-subscriber = "0.2.15"
inotify = { version = "0.9.2", features = ["stream"] }
tracing-appender = "0.1.2"
[features]
clippy = []

View file

@ -1,2 +1,5 @@
doc:
cargo doc --document-private-items
watch:
cargo watch -x 'clippy --all --all-features'

View file

@ -4,17 +4,17 @@
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::mpsc::{self, Receiver};
use std::time::Duration;
use std::path::{Path, PathBuf};
use anyhow::{Context, Result};
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use anyhow::Result;
use futures::{future::TryFutureExt, stream::StreamExt};
use inotify::{Inotify, WatchMask};
use tokio::{sync::watch, task::JoinHandle};
use xdg::BaseDirectories;
use crate::report_err;
/// Alias for a MailConfig receiver.
pub type ConfigWatcher = watch::Receiver<Option<Config>>;
pub type ConfigWatcher = watch::Receiver<Config>;
/// Configuration
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
@ -70,22 +70,6 @@ pub enum TlsMethod {
Off,
}
/// Spawns a notify::RecommendedWatcher to watch the XDG config directory. Whenever the config file
/// is updated, the config file is parsed and sent to the receiver.
fn start_watcher() -> Result<(RecommendedWatcher, Receiver<DebouncedEvent>)> {
let (tx, rx) = mpsc::channel();
let mut watcher = RecommendedWatcher::new(tx, Duration::from_secs(5))?;
let xdg = BaseDirectories::new()?;
let config_home = xdg.get_config_home();
debug!("config_home: {:?}", config_home);
watcher
.watch(config_home.join("panorama"), RecursiveMode::Recursive)
.context("could not watch config_home")?;
Ok((watcher, rx))
}
async fn read_config(path: impl AsRef<Path>) -> Result<Config> {
let mut file = File::open(path.as_ref())?;
let mut contents = Vec::new();
@ -95,40 +79,22 @@ async fn read_config(path: impl AsRef<Path>) -> Result<Config> {
Ok(config)
}
/// The inner loop of the watcher, which is responsible for taking events received by the watcher
/// and trying to parse and return the config.
///
/// This exists so all errors are able to be caught in one go.
async fn watcher_loop(
fs_events: Receiver<DebouncedEvent>,
config_tx: watch::Sender<Option<Config>>,
async fn start_inotify_stream(
mut inotify: Inotify,
config_tx: watch::Sender<Config>,
) -> Result<()> {
// first try opening the config file directly when the program is opened
// (so the config isn't blank until the user touches the config file)
let xdg = BaseDirectories::new()?;
let mut buffer = vec![0; 1024];
let mut event_stream = inotify.event_stream(&mut buffer)?;
if let Some(config_path) = xdg.find_config_file("panorama/panorama.toml") {
debug!("found config at {:?}", config_path);
let config = read_config(config_path).await?;
debug!("read config: {:?}, sending to output", config);
config_tx.send(Some(config))?;
}
while let Some(v) = event_stream.next().await {
let event = v?;
// start listening for events from the notify::Watcher
for event in fs_events {
debug!("new event: {:?}", event);
use notify::DebouncedEvent::*;
match event {
NoticeWrite(path) | Write(path) => match read_config(path).await {
Ok(config) => {
debug!("read new config: {:?}", config);
config_tx.send(Some(config))?;
}
Err(err) => {
debug!("error reading new config: {:?}", err);
}
},
_ => {}
debug!("event: {:?}", event);
if let Some(name) = event.name {
let path = PathBuf::from(name);
let config = read_config(path).await?;
config_tx.send(config)?;
}
}
@ -138,18 +104,10 @@ async fn watcher_loop(
/// Start the entire config watcher system, and return a [ConfigWatcher][self::ConfigWatcher],
/// which is a cloneable receiver of config update events.
pub fn spawn_config_watcher_system() -> Result<(JoinHandle<()>, ConfigWatcher)> {
let (watcher, config_rx) = start_watcher()?;
let (config_tx, config_update) = watch::channel(None);
let mut inotify = Inotify::init()?;
inotify.add_watch(".", WatchMask::all())?;
let config_thread = tokio::spawn(async move {
let _watcher = watcher;
match watcher_loop(config_rx, config_tx).await {
Ok(_) => {}
Err(err) => {
debug!("config watcher bugged: {:?}", err);
}
}
});
Ok((config_thread, config_update))
let (config_tx, config_update) = watch::channel(Config::default());
let handle = tokio::spawn(start_inotify_stream(inotify, config_tx).unwrap_or_else(report_err));
Ok((handle, config_update))
}

View file

@ -11,6 +11,8 @@ extern crate crossterm;
extern crate log;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate tracing;
pub mod config;
pub mod mail;
@ -18,3 +20,8 @@ pub mod ui;
/// A cloneable type that allows sending an exit-"signal" to stop the application.
pub type ExitSender = tokio::sync::mpsc::Sender<()>;
/// Consumes any error and dumps it to the logger.
pub fn report_err(err: anyhow::Error) {
error!("error: {:?}", err);
}

View file

@ -33,12 +33,10 @@ pub async fn run_mail(
loop {
debug!("listening for configs");
let config: Config = match config_watcher.changed().await {
Ok(_) => match *config_watcher.borrow() {
Some(ref v) => v.clone(),
_ => break,
},
Ok(_) => config_watcher.borrow().clone(),
_ => break,
};
debug!("got");
// TODO: gracefully shut down connection
// just gonna drop the connection for now
@ -52,6 +50,7 @@ pub async fn run_mail(
open_imap_connection(acct.imap).await.unwrap();
}
});
curr_conn = Some(handle);
}

View file

@ -5,7 +5,7 @@ use std::path::PathBuf;
use anyhow::Result;
use futures::future::TryFutureExt;
use panorama::{config::spawn_config_watcher_system, mail, ui};
use panorama::{config::spawn_config_watcher_system, mail, report_err, ui};
use structopt::StructOpt;
use tokio::sync::mpsc;
use xdg::BaseDirectories;
@ -22,7 +22,7 @@ struct Opt {
log_file: Option<PathBuf>,
}
#[tokio::main]
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<()> {
// parse command line arguments into options struct
let opt = Opt::from_args();
@ -39,7 +39,12 @@ async fn main() -> Result<()> {
// used to send commands to the mail service
let (_mail_tx, mail_rx) = mpsc::unbounded_channel();
tokio::spawn(mail::run_mail(config_update.clone(), mail_rx).unwrap_or_else(report_err));
tokio::spawn(async move {
let config_update = config_update.clone();
mail::run_mail(config_update, mail_rx)
.unwrap_or_else(report_err)
.await;
});
let stdout = std::io::stdout();
tokio::spawn(ui::run_ui(stdout, exit_tx).unwrap_or_else(report_err));
@ -70,10 +75,8 @@ fn setup_logger(opt: &Opt) -> Result<()> {
fern = fern.chain(fern::log_file(path)?);
}
fern.apply()?;
// fern.apply()?;
tracing_subscriber::fmt::init();
Ok(())
}
fn report_err(err: anyhow::Error) {
error!("error: {:?}", err);
}

View file

@ -2,6 +2,7 @@
mod table;
use std::fmt::Debug;
use std::io::Write;
use std::time::Duration;
@ -26,7 +27,13 @@ const FRAME: Duration = Duration::from_millis(20);
pub struct Rect(u16, u16, u16, u16);
/// UI entrypoint.
pub async fn run_ui(mut w: impl Write, exit: ExitSender) -> Result<()> {
#[instrument]
pub async fn run_ui(mut w: impl Write + Debug, exit: ExitSender) -> Result<()> {
loop {
tokio::time::sleep(Duration::from_secs(5)).await;
debug!("1");
}
execute!(w, cursor::Hide, terminal::EnterAlternateScreen)?;
terminal::enable_raw_mode()?;