Move API Task type to shared crate contextswitch-types

This commit is contained in:
2022-01-09 14:11:36 +01:00
parent 4c94597e8b
commit cbdf35eb53
7 changed files with 180 additions and 414 deletions

347
Cargo.lock generated
View File

@@ -4,15 +4,16 @@ version = 3
[[package]] [[package]]
name = "actix-codec" name = "actix-codec"
version = "0.4.0" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a" checksum = "a36c014a3e811624313b51a227b775ecba55d36ef9462bbaac7d4f13e54c9271"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"bytes", "bytes",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"log", "log",
"memchr",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
"tokio-util", "tokio-util",
@@ -20,14 +21,13 @@ dependencies = [
[[package]] [[package]]
name = "actix-http" name = "actix-http"
version = "3.0.0-beta.11" version = "3.0.0-beta.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9b510d35f13987537289f38bf136e7e702a5c87cc28760310cc459544f40afd" checksum = "dac76407e2be239b5e544c9d83bdac4a0d68ae188031ac0424aa3e4868a669be"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-tls",
"actix-utils", "actix-utils",
"ahash", "ahash",
"base64", "base64",
@@ -39,24 +39,20 @@ dependencies = [
"encoding_rs", "encoding_rs",
"flate2", "flate2",
"futures-core", "futures-core",
"futures-util",
"h2", "h2",
"http", "http",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa 1.0.1",
"language-tags", "language-tags",
"local-channel", "local-channel",
"log", "log",
"mime", "mime",
"once_cell",
"percent-encoding", "percent-encoding",
"pin-project",
"pin-project-lite", "pin-project-lite",
"rand", "rand",
"sha-1", "sha-1",
"smallvec", "smallvec",
"tokio",
"zstd", "zstd",
] ]
@@ -72,9 +68,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-router" name = "actix-router"
version = "0.5.0-beta.2" version = "0.5.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b95ce0d76d1aa2f98b681702807475ade0f99bd4552546a6843a966d42ea3d" checksum = "ddd9f117b910fbcce6e9f45092ffd4ff017785a346d09e2d4fd049f4e20384f4"
dependencies = [ dependencies = [
"bytestring", "bytestring",
"firestorm", "firestorm",
@@ -86,9 +82,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-rt" name = "actix-rt"
version = "2.3.0" version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea360596a50aa9af459850737f99293e5cb9114ae831118cb6026b3bbc7583ad" checksum = "82cf33e04d9911b39bfb7be3c01309568b4315895d3358372dce64ed2c2bf32d"
dependencies = [ dependencies = [
"actix-macros", "actix-macros",
"futures-core", "futures-core",
@@ -97,17 +93,19 @@ dependencies = [
[[package]] [[package]]
name = "actix-server" name = "actix-server"
version = "2.0.0-beta.6" version = "2.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7367665785765b066ad16e1086d26a087f696bc7c42b6f93004ced6cfcf1eeca" checksum = "c9259b4f3cc9ca96d7d91a7da66b7b01c47653a0da5b0ba3f7f45a344480443b"
dependencies = [ dependencies = [
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-utils", "actix-utils",
"futures-core", "futures-core",
"futures-util",
"log", "log",
"mio", "mio 0.8.0",
"num_cpus", "num_cpus",
"socket2",
"tokio", "tokio",
] ]
@@ -122,23 +120,6 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
] ]
[[package]]
name = "actix-tls"
version = "3.0.0-beta.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4af84e13e4600829858a3e68079be710d1ada461431e1e4c5ae663479ea0a3c"
dependencies = [
"actix-codec",
"actix-rt",
"actix-service",
"actix-utils",
"derive_more",
"futures-core",
"http",
"log",
"tokio-util",
]
[[package]] [[package]]
name = "actix-utils" name = "actix-utils"
version = "3.0.0" version = "3.0.0"
@@ -151,9 +132,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-web" name = "actix-web"
version = "4.0.0-beta.10" version = "4.0.0-beta.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a4b9d00991d8da308070a5cea7f1bbaa153a91c3fb5567937d99b9f46d601e" checksum = "a542a92e385844d988b34f1af289dbb0ca927c23740076a56fdf770b1af69fbc"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-http", "actix-http",
@@ -169,17 +150,15 @@ dependencies = [
"cfg-if", "cfg-if",
"cookie", "cookie",
"derive_more", "derive_more",
"either",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"itoa", "itoa 1.0.1",
"language-tags", "language-tags",
"log", "log",
"mime", "mime",
"once_cell", "once_cell",
"paste", "pin-project-lite",
"pin-project",
"regex", "regex",
"serde", "serde",
"serde_json", "serde_json",
@@ -192,9 +171,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-web-codegen" name = "actix-web-codegen"
version = "0.5.0-beta.5" version = "0.5.0-beta.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfe80a8828fa88a0420dc8fdd4c16b8207326c917f17701881b063eadc2a8d3b" checksum = "30a90b7f6c2fde9a1fe3df4da758c2c3c9d620dfa3eae4da0b6925dc0a13444a"
dependencies = [ dependencies = [
"actix-router", "actix-router",
"proc-macro2", "proc-macro2",
@@ -245,12 +224,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "base-x"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.13.0" version = "0.13.0"
@@ -265,9 +238,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.9.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
dependencies = [ dependencies = [
"generic-array", "generic-array",
] ]
@@ -349,13 +322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06821ea598337a8412cf47c5b71c3bc694a7f0aed188ac28b836fab164a2c202" checksum = "06821ea598337a8412cf47c5b71c3bc694a7f0aed188ac28b836fab164a2c202"
[[package]] [[package]]
name = "const_fn" name = "contextswitch-api"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7"
[[package]]
name = "contextswitch"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-http", "actix-http",
@@ -363,6 +330,7 @@ dependencies = [
"actix-web", "actix-web",
"chrono", "chrono",
"configparser", "configparser",
"contextswitch-types",
"dotenv", "dotenv",
"env_logger", "env_logger",
"listenfd", "listenfd",
@@ -374,6 +342,16 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "contextswitch-types"
version = "0.1.0"
dependencies = [
"chrono",
"serde",
"serde_json",
"uuid",
]
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.4.0" version = "0.4.0"
@@ -382,12 +360,12 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]] [[package]]
name = "cookie" name = "cookie"
version = "0.15.1" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05"
dependencies = [ dependencies = [
"percent-encoding", "percent-encoding",
"time 0.2.27", "time 0.3.4",
"version_check", "version_check",
] ]
@@ -425,6 +403,15 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crypto-common"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "derive_more" name = "derive_more"
version = "0.99.16" version = "0.99.16"
@@ -434,37 +421,27 @@ dependencies = [
"convert_case", "convert_case",
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustc_version 0.3.3", "rustc_version",
"syn", "syn",
] ]
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.9.0" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b"
dependencies = [ dependencies = [
"block-buffer",
"crypto-common",
"generic-array", "generic-array",
] ]
[[package]]
name = "discard"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]] [[package]]
name = "dotenv" name = "dotenv"
version = "0.15.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
version = "0.8.29" version = "0.8.29"
@@ -571,7 +548,6 @@ checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"futures-core", "futures-core",
"futures-sink",
"futures-task", "futures-task",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
@@ -600,9 +576,9 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.7" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@@ -640,7 +616,7 @@ checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
"itoa", "itoa 0.4.8",
] ]
[[package]] [[package]]
@@ -687,7 +663,7 @@ dependencies = [
"http-body", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa 0.4.8",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
@@ -751,6 +727,12 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "itoa"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.24" version = "0.1.24"
@@ -875,6 +857,19 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "mio"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"winapi",
]
[[package]] [[package]]
name = "miow" name = "miow"
version = "0.3.7" version = "0.3.7"
@@ -955,12 +950,6 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.37" version = "0.10.37"
@@ -1040,26 +1029,6 @@ dependencies = [
"ucd-trie", "ucd-trie",
] ]
[[package]]
name = "pin-project"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.7" version = "0.2.7"
@@ -1084,12 +1053,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.32" version = "1.0.32"
@@ -1218,22 +1181,13 @@ dependencies = [
"winreg", "winreg",
] ]
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver 0.9.0",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
dependencies = [ dependencies = [
"semver 0.11.0", "semver",
] ]
[[package]] [[package]]
@@ -1281,30 +1235,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser 0.7.0",
]
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.11.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [ dependencies = [
"semver-parser 0.10.2", "semver-parser",
] ]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]] [[package]]
name = "semver-parser" name = "semver-parser"
version = "0.10.2" version = "0.10.2"
@@ -1340,7 +1279,7 @@ version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19"
dependencies = [ dependencies = [
"itoa", "itoa 0.4.8",
"ryu", "ryu",
"serde", "serde",
] ]
@@ -1352,30 +1291,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"itoa", "itoa 0.4.8",
"ryu", "ryu",
"serde", "serde",
] ]
[[package]] [[package]]
name = "sha-1" name = "sha-1"
version = "0.9.8" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
dependencies = [ dependencies = [
"block-buffer",
"cfg-if", "cfg-if",
"cpufeatures", "cpufeatures",
"digest", "digest",
"opaque-debug",
] ]
[[package]]
name = "sha1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.0" version = "1.4.0"
@@ -1407,64 +1338,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "standback"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff"
dependencies = [
"version_check",
]
[[package]]
name = "stdweb"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
dependencies = [
"discard",
"rustc_version 0.2.3",
"stdweb-derive",
"stdweb-internal-macros",
"stdweb-internal-runtime",
"wasm-bindgen",
]
[[package]]
name = "stdweb-derive"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_derive",
"syn",
]
[[package]]
name = "stdweb-internal-macros"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
dependencies = [
"base-x",
"proc-macro2",
"quote",
"serde",
"serde_derive",
"serde_json",
"sha1",
"syn",
]
[[package]]
name = "stdweb-internal-runtime"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.81" version = "1.0.81"
@@ -1510,53 +1383,22 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "time"
version = "0.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242"
dependencies = [
"const_fn",
"libc",
"standback",
"stdweb",
"time-macros",
"version_check",
"winapi",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.4" version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99beeb0daeac2bd1e86ac2c21caddecb244b39a093594da1a661ec2060c7aedd" checksum = "99beeb0daeac2bd1e86ac2c21caddecb244b39a093594da1a661ec2060c7aedd"
dependencies = [ dependencies = [
"itoa", "itoa 0.4.8",
"libc", "libc",
"time-macros",
] ]
[[package]] [[package]]
name = "time-macros" name = "time-macros"
version = "0.1.1" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6"
dependencies = [
"proc-macro-hack",
"time-macros-impl",
]
[[package]]
name = "time-macros-impl"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f"
dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote",
"standback",
"syn",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
@@ -1575,15 +1417,14 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.13.0" version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee" checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
dependencies = [ dependencies = [
"autocfg",
"bytes", "bytes",
"libc", "libc",
"memchr", "memchr",
"mio", "mio 0.7.14",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"pin-project-lite", "pin-project-lite",
@@ -1848,18 +1689,18 @@ dependencies = [
[[package]] [[package]]
name = "zstd" name = "zstd"
version = "0.7.0+zstd.1.4.9" version = "0.9.1+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" checksum = "538b8347df9257b7fbce37677ef7535c00a3c7bf1f81023cc328ed7fe4b41de8"
dependencies = [ dependencies = [
"zstd-safe", "zstd-safe",
] ]
[[package]] [[package]]
name = "zstd-safe" name = "zstd-safe"
version = "3.1.0+zstd.1.4.9" version = "4.1.2+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" checksum = "9fb4cfe2f6e6d35c5d27ecd9d256c4b6f7933c4895654917460ec56c29336cc1"
dependencies = [ dependencies = [
"libc", "libc",
"zstd-sys", "zstd-sys",
@@ -1867,9 +1708,9 @@ dependencies = [
[[package]] [[package]]
name = "zstd-sys" name = "zstd-sys"
version = "1.5.0+zstd.1.4.9" version = "1.6.2+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" checksum = "2daf2f248d9ea44454bfcb2516534e8b8ad2fc91bf818a1885495fc42bc8ac9f"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "contextswitch" name = "contextswitch-api"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
authors = ["David Rousselie <david@rousselie.name>"] authors = ["David Rousselie <david@rousselie.name>"]
@@ -9,20 +9,21 @@ path = "src/lib.rs"
[[bin]] [[bin]]
path = "src/main.rs" path = "src/main.rs"
name = "contextswitch" name = "contextswitch-api"
[dependencies] [dependencies]
actix-web = "=4.0.0-beta.10" contextswitch-types = { path = "../types" }
actix-http = "=3.0.0-beta.11" actix-web = "=4.0.0-beta.18"
serde = "1.0.130" actix-http = "=3.0.0-beta.17"
serde_json = "1.0.71" serde = { version = "1.0.0", features = ["derive"] }
uuid = { version = "0.8.2", features = ["serde"] } serde_json = "1.0"
chrono = { version = "0.4.19", features = ["serde"] } uuid = { version = "0.8.0", features = ["serde"] }
mktemp = "0.4.1" chrono = { version = "0.4.0", features = ["serde"] }
mktemp = "0.4.0"
configparser = "3.0.0" configparser = "3.0.0"
env_logger = "0.9.0" env_logger = "0.9.0"
dotenv = "0.15.0" dotenv = "0.15.0"
listenfd = "0.3.5" listenfd = "0.3.0"
[dev-dependencies] [dev-dependencies]
actix-rt = "2" actix-rt = "2"

45
src/contextswitch.rs Normal file
View File

@@ -0,0 +1,45 @@
use crate::taskwarrior;
use contextswitch_types::{ContextSwitchMetadata, Task};
use std::io::Error;
impl TryFrom<&taskwarrior::Task> for Task {
type Error = std::io::Error;
fn try_from(task: &taskwarrior::Task) -> Result<Self, Self::Error> {
let cs_metadata = task.contextswitch.as_ref().map_or(
Ok(None),
|cs_string| -> Result<Option<ContextSwitchMetadata>, serde_json::Error> {
if cs_string.is_empty() || cs_string == "{}" {
Ok(None)
} else {
Some(serde_json::from_str(&cs_string)).transpose()
}
},
)?;
Ok(Task {
uuid: task.uuid,
id: task.id,
entry: task.entry,
modified: task.modified,
status: task.status,
description: task.description.clone(),
urgency: task.urgency,
due: task.due,
end: task.end,
parent: task.parent,
project: task.project.clone(),
recur: task.recur,
tags: task.tags.clone(),
contextswitch: cs_metadata,
})
}
}
pub fn export(filters: Vec<&str>) -> Result<Vec<Task>, Error> {
let tasks: Result<Vec<Task>, Error> = taskwarrior::export(filters)?
.iter()
.map(|task| Task::try_from(task))
.collect();
tasks
}

View File

@@ -1,11 +1,11 @@
use actix_web::{dev::Server, middleware::Logger, web, App, HttpResponse, HttpServer}; use actix_web::{dev::Server, middleware, web, App, HttpResponse, HttpServer};
use chrono::{DateTime, Utc};
use listenfd::ListenFd; use listenfd::ListenFd;
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use std::env;
use std::io::Error; use std::io::Error;
use std::net::TcpListener; use std::net::TcpListener;
use uuid::Uuid;
pub mod contextswitch;
pub mod taskwarrior; pub mod taskwarrior;
#[derive(Deserialize)] #[derive(Deserialize)]
@@ -13,43 +13,8 @@ struct TaskQuery {
filter: String, filter: String,
} }
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Task {
pub uuid: Uuid,
pub id: u32,
#[serde(with = "taskwarrior::tw_date_format")]
pub entry: DateTime<Utc>,
#[serde(with = "taskwarrior::tw_date_format")]
pub modified: DateTime<Utc>,
pub status: taskwarrior::Status,
pub description: String,
pub urgency: f64,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "taskwarrior::opt_tw_date_format"
)]
pub due: Option<DateTime<Utc>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "taskwarrior::opt_tw_date_format"
)]
pub end: Option<DateTime<Utc>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub parent: Option<Uuid>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub project: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub recur: Option<taskwarrior::Recurrence>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub contextswitch: Option<taskwarrior::ContextSwitchMetadata>,
}
async fn list_tasks(task_query: web::Query<TaskQuery>) -> Result<HttpResponse, Error> { async fn list_tasks(task_query: web::Query<TaskQuery>) -> Result<HttpResponse, Error> {
let tasks = taskwarrior::export(task_query.filter.split(' ').collect())?; let tasks = contextswitch::export(task_query.filter.split(' ').collect())?;
Ok(HttpResponse::Ok() Ok(HttpResponse::Ok()
.content_type("application/json") .content_type("application/json")
@@ -61,9 +26,16 @@ async fn health_check() -> HttpResponse {
} }
pub fn run(listener: TcpListener) -> Result<Server, std::io::Error> { pub fn run(listener: TcpListener) -> Result<Server, std::io::Error> {
let mut server = HttpServer::new(|| { let cs_front_base_url =
env::var("CS_FRONT_BASE_URL").unwrap_or("http://localhost:8080".to_string());
let mut server = HttpServer::new(move || {
App::new() App::new()
.wrap(Logger::default()) .wrap(middleware::Logger::default())
.wrap(middleware::Compress::default())
.wrap(
middleware::DefaultHeaders::new()
.add(("Access-Control-Allow-Origin", cs_front_base_url.as_bytes())),
)
.route("/ping", web::get().to(health_check)) .route("/ping", web::get().to(health_check))
.route("/tasks", web::get().to(list_tasks)) .route("/tasks", web::get().to(list_tasks))
}) })

View File

@@ -2,7 +2,7 @@ extern crate dotenv;
extern crate env_logger; extern crate env_logger;
extern crate listenfd; extern crate listenfd;
use contextswitch::run; use contextswitch_api::run;
use dotenv::dotenv; use dotenv::dotenv;
use std::env; use std::env;
use std::net::TcpListener; use std::net::TcpListener;

View File

@@ -1,6 +1,6 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use configparser::ini::Ini; use configparser::ini::Ini;
use serde::{de, Deserialize, Deserializer, Serialize}; use serde::{Deserialize, Serialize};
use serde_json; use serde_json;
use std::env; use std::env;
use std::io::Error; use std::io::Error;
@@ -9,50 +9,27 @@ use std::process::Command;
use std::str; use std::str;
use uuid::Uuid; use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum Recurrence {
Daily,
Weekly,
Monthly,
Yearly,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum Status {
Pending,
Completed,
Recurring,
Deleted,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct ContextSwitchMetadata {
pub test: u32,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)] #[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Task { pub struct Task {
pub uuid: Uuid, pub uuid: Uuid,
pub id: u32, pub id: u32,
#[serde(with = "tw_date_format")] #[serde(with = "contextswitch_types::tw_date_format")]
pub entry: DateTime<Utc>, pub entry: DateTime<Utc>,
#[serde(with = "tw_date_format")] #[serde(with = "contextswitch_types::tw_date_format")]
pub modified: DateTime<Utc>, pub modified: DateTime<Utc>,
pub status: Status, pub status: contextswitch_types::Status,
pub description: String, pub description: String,
pub urgency: f64, pub urgency: f64,
#[serde( #[serde(
default, default,
skip_serializing_if = "Option::is_none", skip_serializing_if = "Option::is_none",
with = "opt_tw_date_format" with = "contextswitch_types::opt_tw_date_format"
)] )]
pub due: Option<DateTime<Utc>>, pub due: Option<DateTime<Utc>>,
#[serde( #[serde(
default, default,
skip_serializing_if = "Option::is_none", skip_serializing_if = "Option::is_none",
with = "opt_tw_date_format" with = "contextswitch_types::opt_tw_date_format"
)] )]
pub end: Option<DateTime<Utc>>, pub end: Option<DateTime<Utc>>,
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
@@ -60,75 +37,11 @@ pub struct Task {
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub project: Option<String>, pub project: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub recur: Option<Recurrence>, pub recur: Option<contextswitch_types::Recurrence>,
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>, pub tags: Option<Vec<String>>,
#[serde( #[serde(default, skip_serializing_if = "Option::is_none")]
default, pub contextswitch: Option<String>,
skip_serializing_if = "Option::is_none",
deserialize_with = "deserialize_from_json"
)]
pub contextswitch: Option<ContextSwitchMetadata>,
}
fn deserialize_from_json<'de, D>(deserializer: D) -> Result<Option<ContextSwitchMetadata>, D::Error>
where
D: Deserializer<'de>,
{
let s: String = Deserialize::deserialize(deserializer)?;
serde_json::from_str(&s).map_err(de::Error::custom)
}
pub mod tw_date_format {
use chrono::{DateTime, TimeZone, Utc};
use serde::{self, Deserialize, Deserializer, Serializer};
const FORMAT: &'static str = "%Y%m%dT%H%M%SZ";
pub fn serialize<S>(date: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let s = format!("{}", date.format(FORMAT));
serializer.serialize_str(&s)
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Utc.datetime_from_str(&s, FORMAT)
.map_err(serde::de::Error::custom)
}
}
pub mod opt_tw_date_format {
use chrono::{DateTime, TimeZone, Utc};
use serde::{self, Deserialize, Deserializer, Serializer};
const FORMAT: &'static str = "%Y%m%dT%H%M%SZ";
pub fn serialize<S>(date: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
if let Some(ref d) = *date {
return serializer.serialize_str(&d.format(FORMAT).to_string());
}
serializer.serialize_none()
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<DateTime<Utc>>, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Utc.datetime_from_str(&s, FORMAT)
.map(Some)
.map_err(serde::de::Error::custom)
}
} }
pub fn load_config(task_data_location: Option<&str>) -> String { pub fn load_config(task_data_location: Option<&str>) -> String {
@@ -151,13 +64,6 @@ pub fn load_config(task_data_location: Option<&str>) -> String {
}); });
let mut taskrc = Ini::new(); let mut taskrc = Ini::new();
taskrc.setstr("default", "uda.contextswitch.type", Some("string"));
taskrc.setstr(
"default",
"uda.contextswitch.label",
Some("Context Switch metadata"),
);
taskrc.setstr("default", "uda.contextswitch.default", Some("{}"));
taskrc.setstr("default", "data.location", Some(&data_location)); taskrc.setstr("default", "data.location", Some(&data_location));
taskrc.setstr("default", "uda.contextswitch.type", Some("string")); taskrc.setstr("default", "uda.contextswitch.type", Some("string"));
taskrc.setstr( taskrc.setstr(
@@ -173,7 +79,7 @@ pub fn load_config(task_data_location: Option<&str>) -> String {
env::set_var("TASKRC", taskrc_location); env::set_var("TASKRC", taskrc_location);
return data_location; data_location
} }
pub fn export(filters: Vec<&str>) -> Result<Vec<Task>, Error> { pub fn export(filters: Vec<&str>) -> Result<Vec<Task>, Error> {
@@ -183,12 +89,13 @@ pub fn export(filters: Vec<&str>) -> Result<Vec<Task>, Error> {
let tasks: Vec<Task> = serde_json::from_slice(&export_output.stdout)?; let tasks: Vec<Task> = serde_json::from_slice(&export_output.stdout)?;
return Ok(tasks); Ok(tasks)
} }
pub fn add(add_args: Vec<&str>) -> Result<(), Error> { pub fn add(add_args: Vec<&str>) -> Result<(), Error> {
let mut args = vec!["add"]; let mut args = vec!["add"];
args.extend(add_args); args.extend(add_args);
Command::new("task").args(args).output()?; Command::new("task").args(args).output()?;
return Ok(());
Ok(())
} }

View File

@@ -1,7 +1,7 @@
pub mod test_helper; pub mod test_helper;
use contextswitch::taskwarrior; use contextswitch_api::taskwarrior;
use contextswitch::Task; use contextswitch_types::Task;
#[actix_rt::test] #[actix_rt::test]
async fn list_tasks() { async fn list_tasks() {