Current state commit

This commit is contained in:
Nadja Reitzenstein 2021-10-19 11:16:24 +02:00
parent 41142ecb4c
commit 80b6807f21
12 changed files with 845 additions and 317 deletions

633
Cargo.lock generated
View File

@ -34,6 +34,15 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "annotate-snippets" name = "annotate-snippets"
version = "0.9.0" version = "0.9.0"
@ -43,6 +52,24 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.5.2" version = "0.5.2"
@ -132,7 +159,7 @@ checksum = "b21b63ab5a0db0369deb913540af2892750e42d949faacc7a61495ac418a1692"
dependencies = [ dependencies = [
"async-io", "async-io",
"blocking", "blocking",
"cfg-if", "cfg-if 1.0.0",
"event-listener", "event-listener",
"futures-lite", "futures-lite",
"libc", "libc",
@ -164,6 +191,17 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.1" version = "1.0.1"
@ -179,6 +217,30 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bindgen"
version = "0.55.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b13ce559e6433d360c26305643803cb52cfbabbc2b9c47ce04a58493dfb443"
dependencies = [
"bitflags",
"cexpr",
"cfg-if 0.1.10",
"clang-sys",
"clap",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"which",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
@ -310,12 +372,75 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]]
name = "clang-sys"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10612c0ec0e0a1ff0e97980647cb058a6e7aedb913d01d009c406b8b7d0b26ee"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"ansi_term 0.11.0",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "cmake"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7b858541263efe664aead4a5209a4ae5c5d2811167d4ed4ee0944503f8d2089"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "concurrent-queue" name = "concurrent-queue"
version = "1.2.2" version = "1.2.2"
@ -334,6 +459,26 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
]
[[package]] [[package]]
name = "ctor" name = "ctor"
version = "0.1.21" version = "0.1.21"
@ -389,6 +534,7 @@ dependencies = [
"capnp-futures", "capnp-futures",
"capnp-rpc", "capnp-rpc",
"capnpc", "capnpc",
"clap",
"erased-serde", "erased-serde",
"futures 0.3.16", "futures 0.3.16",
"futures-signals", "futures-signals",
@ -397,18 +543,24 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"lmdb-rkv", "lmdb-rkv",
"paho-mqtt",
"ptr_meta", "ptr_meta",
"rand", "rand",
"rkyv", "rkyv",
"rkyv_dyn", "rkyv_dyn",
"rkyv_typename", "rkyv_typename",
"rsasl",
"serde", "serde",
"serde_dhall", "serde_dhall",
"serde_json", "serde_json",
"signal-hook", "signal-hook",
"slog",
"slog-async",
"slog-term",
"smol", "smol",
"tempfile", "tempfile",
"tracing", "tracing",
"tracing-subscriber",
"uuid", "uuid",
"walkdir", "walkdir",
] ]
@ -431,6 +583,27 @@ dependencies = [
"generic-array 0.14.4", "generic-array 0.14.4",
] ]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if 1.0.0",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]] [[package]]
name = "discard" name = "discard"
version = "1.0.4" version = "1.0.4"
@ -458,6 +631,19 @@ dependencies = [
"stable_deref_trait", "stable_deref_trait",
] ]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]] [[package]]
name = "erased-serde" name = "erased-serde"
version = "0.3.16" version = "0.3.16"
@ -529,12 +715,28 @@ dependencies = [
"futures-sink", "futures-sink",
] ]
[[package]]
name = "futures-channel-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a"
dependencies = [
"futures-core-preview",
"futures-sink-preview",
]
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.16" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99"
[[package]]
name = "futures-core-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a"
[[package]] [[package]]
name = "futures-executor" name = "futures-executor"
version = "0.3.16" version = "0.3.16"
@ -547,12 +749,29 @@ dependencies = [
"num_cpus", "num_cpus",
] ]
[[package]]
name = "futures-executor-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98"
dependencies = [
"futures-core-preview",
"futures-util-preview",
"num_cpus",
]
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.16" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582"
[[package]]
name = "futures-io-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda"
[[package]] [[package]]
name = "futures-lite" name = "futures-lite"
version = "1.12.0" version = "1.12.0"
@ -581,6 +800,20 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "futures-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e"
dependencies = [
"futures-channel-preview",
"futures-core-preview",
"futures-executor-preview",
"futures-io-preview",
"futures-sink-preview",
"futures-util-preview",
]
[[package]] [[package]]
name = "futures-signals" name = "futures-signals"
version = "0.3.22" version = "0.3.22"
@ -601,6 +834,12 @@ version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53"
[[package]]
name = "futures-sink-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.16" version = "0.3.16"
@ -624,6 +863,16 @@ dependencies = [
"pin-utils", "pin-utils",
] ]
[[package]]
name = "futures-timer"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9eb554aa23143abc64ec4d0016f038caf53bb7cbc3d91490835c54edc96550"
dependencies = [
"futures-preview",
"pin-utils",
]
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.16" version = "0.3.16"
@ -646,6 +895,21 @@ dependencies = [
"slab", "slab",
] ]
[[package]]
name = "futures-util-preview"
version = "0.3.0-alpha.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d"
dependencies = [
"futures-channel-preview",
"futures-core-preview",
"futures-io-preview",
"futures-sink-preview",
"memchr",
"pin-utils",
"slab",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.12.4" version = "0.12.4"
@ -671,7 +935,7 @@ 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 = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"wasi", "wasi",
] ]
@ -687,6 +951,21 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "gsasl-sys"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89192b27c2356690cddc81ef17438cede69f0e6794a645debe579de3a6bb835"
dependencies = [
"bindgen",
]
[[package]] [[package]]
name = "half" name = "half"
version = "1.7.1" version = "1.7.1"
@ -717,6 +996,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "humantime"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
dependencies = [
"quick-error",
]
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.2.3" version = "0.2.3"
@ -744,7 +1032,7 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -790,6 +1078,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "lexical-core" name = "lexical-core"
version = "0.7.6" version = "0.7.6"
@ -798,7 +1092,7 @@ checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitflags", "bitflags",
"cfg-if", "cfg-if 1.0.0",
"ryu", "ryu",
"static_assertions", "static_assertions",
] ]
@ -809,6 +1103,16 @@ version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
[[package]]
name = "libloading"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0"
dependencies = [
"cfg-if 1.0.0",
"winapi",
]
[[package]] [[package]]
name = "lmdb-rkv" name = "lmdb-rkv"
version = "0.14.0" version = "0.14.0"
@ -838,7 +1142,7 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -847,6 +1151,15 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "matchers"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
"regex-automata",
]
[[package]] [[package]]
name = "matches" name = "matches"
version = "0.1.9" version = "0.1.9"
@ -870,6 +1183,25 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.13.0" version = "1.13.0"
@ -898,12 +1230,40 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "paho-mqtt"
version = "0.8.0"
source = "git+https://github.com/dequbed/paho.mqtt.rust.git?branch=master#14ec804ecf284564ee71b04345d1fdf1f75571df"
dependencies = [
"futures 0.3.16",
"futures-timer",
"libc",
"log",
"paho-mqtt-sys",
"thiserror",
]
[[package]]
name = "paho-mqtt-sys"
version = "0.4.1"
source = "git+https://github.com/dequbed/paho.mqtt.rust.git?branch=master#14ec804ecf284564ee71b04345d1fdf1f75571df"
dependencies = [
"bindgen",
"cmake",
]
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.0.0" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"
@ -1019,7 +1379,7 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25" checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"log", "log",
"wepoll-ffi", "wepoll-ffi",
@ -1082,6 +1442,12 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.9" version = "1.0.9"
@ -1140,6 +1506,42 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "redox_users"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [
"getrandom",
"redox_syscall",
]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.3" version = "0.5.3"
@ -1228,6 +1630,29 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "rsasl"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebe65252e630e3b9c4185ce0073bb6b2f12136e5116344804600bb4bd9ede47a"
dependencies = [
"discard",
"gsasl-sys",
"libc",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustversion"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.5" version = "1.0.5"
@ -1322,12 +1747,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3" checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3"
dependencies = [ dependencies = [
"block-buffer 0.9.0", "block-buffer 0.9.0",
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"digest 0.9.0", "digest 0.9.0",
"opaque-debug 0.3.0", "opaque-debug 0.3.0",
] ]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.9" version = "0.3.9"
@ -1353,6 +1793,43 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590"
[[package]]
name = "slog"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06"
[[package]]
name = "slog-async"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "766c59b252e62a34651412870ff55d8c4e6d04df19b43eecb2703e417b097ffe"
dependencies = [
"crossbeam-channel",
"slog",
"take_mut",
"thread_local",
]
[[package]]
name = "slog-term"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95c1e7e5aab61ced6006149ea772770b84a0d16ce0f7885def313e4829946d76"
dependencies = [
"atty",
"chrono",
"slog",
"term",
"thread_local",
]
[[package]]
name = "smallvec"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]] [[package]]
name = "smol" name = "smol"
version = "1.2.5" version = "1.2.5"
@ -1393,6 +1870,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.75" version = "1.0.75"
@ -1404,13 +1887,19 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "take_mut"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.2.0" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"rand", "rand",
"redox_syscall", "redox_syscall",
@ -1418,6 +1907,74 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "term"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
dependencies = [
"dirs-next",
"rustversion",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[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.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.3.1" version = "1.3.1"
@ -1439,7 +1996,7 @@ version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"pin-project-lite", "pin-project-lite",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
@ -1465,6 +2022,49 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "tracing-log"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
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.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
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]] [[package]]
name = "typed-arena" name = "typed-arena"
version = "1.7.0" version = "1.7.0"
@ -1532,6 +2132,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.3" version = "0.9.3"
@ -1570,6 +2176,15 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "which"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View File

@ -23,12 +23,13 @@ futures-signals = "0.3.22"
smol = "1.2.5" smol = "1.2.5"
tracing = "0.1.28" tracing = "0.1.28"
tracing-subscriber = "0.2.25"
signal-hook = "0.3.9" signal-hook = "0.3.9"
#slog = { version = "2.7.0", features = ["max_level_trace"] } slog = { version = "2.7.0", features = ["max_level_trace"] }
#slog-term = "2.8.0" slog-term = "2.8.0"
#slog-async = "2.7.0" slog-async = "2.7.0"
capnp = "0.14.3" capnp = "0.14.3"
capnpc = "0.14.4" capnpc = "0.14.4"
@ -51,14 +52,14 @@ serde_json = "1.0"
uuid = { version = "0.8.2", features = ["serde", "v4"] } uuid = { version = "0.8.2", features = ["serde", "v4"] }
#clap = "2.33.3" clap = "2.33.3"
# TODO update this if bindgen breaks (again) # TODO update this if bindgen breaks (again)
#rsasl = "1.4.0" rsasl = "1.4.0"
#rsasl = { path = "../../rsasl" } #rsasl = { path = "../../rsasl" }
# rumqtt needs tokio which I'm trying to get away from # rumqtt needs tokio which I'm trying to get away from
#paho-mqtt = { git = "https://github.com/dequbed/paho.mqtt.rust.git", branch = "master", features = ["build_bindgen"] } paho-mqtt = { git = "https://github.com/dequbed/paho.mqtt.rust.git", branch = "master", features = ["build_bindgen"] }
#mlua = { version = "0.4", features = ["async", "luajit"] } #mlua = { version = "0.4", features = ["async", "luajit"] }
@ -72,10 +73,6 @@ lazy_static = "1.4.0"
#rust-argon2 = "0.8.3" #rust-argon2 = "0.8.3"
#rand = "0.8.4" #rand = "0.8.4"
#async-channel = "1.6.1"
#easy-parallel = "3.1.0"
#genawaiter = "0.99.1"
[build-dependencies] [build-dependencies]
capnpc = "0.14.4" capnpc = "0.14.4"
# Used in build.rs to iterate over all files in schema/ # Used in build.rs to iterate over all files in schema/

View File

@ -11,7 +11,6 @@ use futures_signals::signal::Signal;
use crate::db::machine::MachineState; use crate::db::machine::MachineState;
use crate::config::Config; use crate::config::Config;
use crate::error::Result; use crate::error::Result;
use crate::network::ActorMap;
use paho_mqtt::AsyncClient; use paho_mqtt::AsyncClient;
use slog::Logger; use slog::Logger;

View File

@ -1,3 +1,150 @@
fn main() { use std::{
diflouroborane::main() io,
io::Write,
path::PathBuf,
sync::Arc,
};
use clap::{App, Arg, crate_version, crate_description, crate_name};
use std::str::FromStr;
fn main_res() -> Result<(), dyn std::error::Error> {
// Argument parsing
// values for the name, description and version are pulled from `Cargo.toml`.
let matches = App::new(crate_name!())
.about(crate_description!())
.version(crate_version!())
.arg(Arg::with_name("config")
.help("Path to the config file to use")
.long("config")
.short("c")
.takes_value(true
))
.arg(Arg::with_name("print default")
.help("Print a default config to stdout instead of running")
.long("print-default")
)
.arg(Arg::with_name("check config")
.help("Check config for validity")
.long("check")
)
.arg(Arg::with_name("dump")
.help("Dump all internal databases")
.long("dump")
.conflicts_with("load")
)
.arg(Arg::with_name("load")
.help("Load values into the internal databases")
.long("load")
.conflicts_with("dump")
)
.get_matches();
// Check for the --print-default option first because we don't need to do anything else in that
// case.
if matches.is_present("print default") {
let config = config::Config::default();
let encoded = serde_dhall::serialize(&config).to_string().unwrap();
// Direct writing to fd 1 is faster but also prevents any print-formatting that could
// invalidate the generated TOML
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.write_all(&encoded.as_bytes()).unwrap();
// Early return to exit.
return Ok(());
} else if matches.is_present("check config") {
let configpath = matches.value_of("config").unwrap_or("/etc/diflouroborane.dhall");
match config::read(&PathBuf::from_str(configpath).unwrap()) {
Ok(cfg) => {
//TODO: print a normalized version of the supplied config
println!("config is valid");
std::process::exit(0);
}
Err(e) => {
eprintln!("{}", e);
std::process::exit(-1);
}
}
}
// If no `config` option is given use a preset default.
let configpath = matches.value_of("config").unwrap_or("/etc/diflouroborane.dhall");
let config = config::read(&PathBuf::from_str(configpath).unwrap())?;
tracing::debug!("Loaded Config: {:?}", config);
if matches.is_present("dump") {
let db = db::Databases::new(&log, &config)?;
let v = db.access.dump_roles().unwrap();
for (id, role) in v.iter() {
tracing::info!("Role {}:\n{}", id, role);
}
let v = db.userdb.list_users()?;
for user in v.iter() {
tracing::info!("User {}:\n{:?}", user.id, user.data);
}
Ok(())
} else if matches.is_present("load") {
let db = db::Databases::new(&log, &config)?;
let mut dir = PathBuf::from(matches.value_of_os("load").unwrap());
dir.push("users.toml");
let map = db::user::load_file(&dir)?;
for (uid,user) in map.iter() {
db.userdb.put_user(uid, user)?;
}
tracing::debug!("Loaded users: {:?}", map);
dir.pop();
Ok(())
} else {
let ex = smol::Executor::new();
let db = db::Databases::new(&log, &config)?;
let machines = machine::load(&config)?;
let (actor_map, actors) = actor::load(&log, &config)?;
let (init_map, initiators) = initiator::load(&log, &config, db.userdb.clone(), db.access.clone())?;
let mut network = network::Network::new(machines, actor_map, init_map);
for (a,b) in config.actor_connections.iter() {
if let Err(e) = network.connect_actor(a,b) {
tracing::error!("{}", e);
}
tracing::info!("[Actor] Connected {} to {}", a, b);
}
for (a,b) in config.init_connections.iter() {
if let Err(e) = network.connect_init(a,b) {
tracing::error!("{}", e);
}
tracing::info!("[Initi] Connected {} to {}", a, b);
}
for actor in actors.into_iter() {
ex.spawn(actor).detach();
}
for init in initiators.into_iter() {
ex.spawn(init).detach();
}
server::serve_api_connections(log.clone(), config, db, network, ex)
}
}
fn main() {
let retval;
// Scope to drop everything before exiting.
{
tracing_subscriber::fmt::init();
match main_res() {
Ok(_) => retval = 0,
Err(e) => {
tracing::error!("{}", e);
retval = -1;
}
}
}
std::process::exit(retval);
} }

View File

@ -6,8 +6,6 @@ use serde::{Serialize, Deserialize};
use crate::error::Result; use crate::error::Result;
use crate::machine::MachineDescription; use crate::machine::MachineDescription;
use crate::db::machine::MachineIdentifier;
use crate::db::access::*;
pub fn read(path: &Path) -> Result<Config> { pub fn read(path: &Path) -> Result<Config> {
serde_dhall::from_file(path) serde_dhall::from_file(path)

View File

@ -11,12 +11,6 @@ use crate::error::Result;
use capnp_rpc::{rpc_twoparty_capnp, twoparty}; use capnp_rpc::{rpc_twoparty_capnp, twoparty};
use crate::schema::connection_capnp;
use crate::db::access::{AccessControl, PermRule, RoleIdentifier};
use crate::db::user::UserId;
use crate::db::Databases;
use crate::network::Network;
#[derive(Debug)] #[derive(Debug)]
/// Connection context /// Connection context

View File

@ -14,11 +14,7 @@ pub use lmdb::{
RwTransaction, RwTransaction,
}; };
use rkyv::{ use rkyv::{Fallible, Serialize, ser::serializers::AllocSerializer, AlignedVec};
Fallible,
Serialize,
ser::serializers::AllocSerializer,
};
mod raw; mod raw;
use raw::RawDB; use raw::RawDB;
@ -52,6 +48,8 @@ mod resources;
pub use resources::{ pub use resources::{
ResourceDB, ResourceDB,
}; };
use lmdb::Error;
use rkyv::ser::serializers::AlignedSerializer;
#[derive(Debug)] #[derive(Debug)]
pub enum DBError { pub enum DBError {
@ -90,3 +88,27 @@ impl<V: Serialize<Ser>> Adapter for AllocAdapter<V> {
e.into() e.into()
} }
} }
#[derive(Copy, Clone)]
pub struct AlignedAdapter<V> {
phantom: PhantomData<V>,
}
impl<V> Fallible for AlignedAdapter<V> {
type Error = lmdb::Error;
}
impl<V: Serialize<AlignedSerializer<AlignedVec>>> Adapter for AlignedAdapter<V> {
type Serializer = AlignedSerializer<AlignedVec>;
type Value = V;
fn new_serializer() -> Self::Serializer {
Self::Serializer::default()
}
fn from_ser_err(_: <Self::Serializer as Fallible>::Error) -> <Self as Fallible>::Error {
unreachable!()
}
fn from_db_err(e: Error) -> <Self as Fallible>::Error {
e
}
}

View File

@ -1,13 +1,14 @@
use rkyv::{ use rkyv::{Archive, Serialize, Deserialize};
Archive,
Serialize,
Deserialize,
};
use super::{ use super::{
AllocAdapter, AllocAdapter,
DB, DB,
}; };
use crate::db::AlignedAdapter;
use crate::db::raw::RawDB;
use std::sync::Arc;
use lmdb::Environment;
use crate::db;
#[derive(Archive, Serialize, Deserialize)] #[derive(Archive, Serialize, Deserialize)]
pub struct Resource { pub struct Resource {
@ -18,5 +19,23 @@ pub struct Resource {
} }
pub struct ResourceDB { pub struct ResourceDB {
env: Arc<Environment>,
db: DB<AllocAdapter<Resource>>, db: DB<AllocAdapter<Resource>>,
id_index: DB<AlignedAdapter<u64>>,
}
impl ResourceDB {
pub unsafe fn new(env: Arc<Environment>, db: RawDB, id_index: RawDB) -> Self {
let db = DB::new_unchecked(db);
let id_index = DB::new_unchecked(id_index);
Self { env, db, id_index }
}
pub fn lookup_id<S: AsRef<str>>(&self, id: S) -> Result<Option<u64>, db::Error> {
let txn = self.env.begin_ro_txn()?;
self.id_index.get(&txn, &id.as_ref().as_bytes()).map(|ok| {
ok.map(|num| *num)
})
}
} }

View File

@ -94,10 +94,14 @@ impl<A: Adapter> fmt::Debug for DB<A> {
} }
impl<A> DB<A> { impl<A> DB<A> {
fn new(db: RawDB) -> Self { pub unsafe fn new_unchecked(db: RawDB) -> Self {
Self { db, phantom: PhantomData } Self { db, phantom: PhantomData }
} }
fn new(db: RawDB) -> Self {
unsafe { Self::new_unchecked(db) }
}
/// Open the underlying DB, creating it if necessary /// Open the underlying DB, creating it if necessary
/// ///
/// This function is unsafe since if the DB does not contain `A::Archived` we may end up doing /// This function is unsafe since if the DB does not contain `A::Archived` we may end up doing

View File

@ -1,6 +1,5 @@
use std::io; use std::io;
use std::fmt; use std::fmt;
use toml;
use serde_dhall; use serde_dhall;
use rsasl::SaslError; use rsasl::SaslError;
@ -14,33 +13,21 @@ use paho_mqtt::errors as mqtt;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
TomlDe(toml::de::Error),
TomlSer(toml::ser::Error),
Dhall(serde_dhall::Error), Dhall(serde_dhall::Error),
SASL(SaslError), SASL(SaslError),
IO(io::Error), IO(io::Error),
Boxed(Box<dyn std::error::Error>), Boxed(Box<dyn std::error::Error>),
Capnp(capnp::Error), Capnp(capnp::Error),
LMDB(lmdb::Error), LMDB(lmdb::Error),
FlexbuffersDe(flexbuffers::DeserializationError),
FlexbuffersSer(flexbuffers::SerializationError),
FuturesSpawn(futures_task::SpawnError), FuturesSpawn(futures_task::SpawnError),
MQTT(mqtt::Error), MQTT(mqtt::Error),
BadVersion((u32,u32)), BadVersion((u32,u32)),
Argon2(argon2::Error),
//EventNetwork(network::Error),
Denied, Denied,
} }
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
Error::TomlDe(e) => {
write!(f, "TOML Decoding error: {}", e)
},
Error::TomlSer(e) => {
write!(f, "TOML Serialization error: {}", e)
},
Error::Dhall(e) => { Error::Dhall(e) => {
write!(f, "Dhall coding error: {}", e) write!(f, "Dhall coding error: {}", e)
}, },
@ -59,30 +46,18 @@ impl fmt::Display for Error {
Error::LMDB(e) => { Error::LMDB(e) => {
write!(f, "LMDB Error: {}", e) write!(f, "LMDB Error: {}", e)
}, },
Error::FlexbuffersDe(e) => {
write!(f, "Flexbuffers decoding error: {}", e)
},
Error::FlexbuffersSer(e) => {
write!(f, "Flexbuffers encoding error: {}", e)
},
Error::FuturesSpawn(e) => { Error::FuturesSpawn(e) => {
write!(f, "Future could not be spawned: {}", e) write!(f, "Future could not be spawned: {}", e)
}, },
Error::MQTT(e) => { Error::MQTT(e) => {
write!(f, "Paho MQTT encountered an error: {}", e) write!(f, "Paho MQTT encountered an error: {}", e)
}, },
Error::Argon2(e) => {
write!(f, "Argon2 en/decoding failure: {}", e)
}
Error::BadVersion((major,minor)) => { Error::BadVersion((major,minor)) => {
write!(f, "Peer uses API version {}.{} which is incompatible!", major, minor) write!(f, "Peer uses API version {}.{} which is incompatible!", major, minor)
} }
Error::Denied => { Error::Denied => {
write!(f, "You do not have the permission required to do that.") write!(f, "You do not have the permission required to do that.")
} }
/*Error::EventNetwork(e) => {
e.fmt(f)
}*/
} }
} }
} }
@ -99,18 +74,6 @@ impl From<io::Error> for Error {
} }
} }
impl From<toml::de::Error> for Error {
fn from(e: toml::de::Error) -> Error {
Error::TomlDe(e)
}
}
impl From<toml::ser::Error> for Error {
fn from(e: toml::ser::Error) -> Error {
Error::TomlSer(e)
}
}
impl From<serde_dhall::Error> for Error { impl From<serde_dhall::Error> for Error {
fn from(e: serde_dhall::Error) -> Error { fn from(e: serde_dhall::Error) -> Error {
Error::Dhall(e) Error::Dhall(e)
@ -135,18 +98,6 @@ impl From<lmdb::Error> for Error {
} }
} }
impl From<flexbuffers::DeserializationError> for Error {
fn from(e: flexbuffers::DeserializationError) -> Error {
Error::FlexbuffersDe(e)
}
}
impl From<flexbuffers::SerializationError> for Error {
fn from(e: flexbuffers::SerializationError) -> Error {
Error::FlexbuffersSer(e)
}
}
impl From<futures_task::SpawnError> for Error { impl From<futures_task::SpawnError> for Error {
fn from(e: futures_task::SpawnError) -> Error { fn from(e: futures_task::SpawnError) -> Error {
Error::FuturesSpawn(e) Error::FuturesSpawn(e)
@ -165,10 +116,4 @@ impl From<mqtt::Error> for Error {
} }
}*/ }*/
impl From<argon2::Error> for Error {
fn from(e: argon2::Error) -> Error {
Error::Argon2(e)
}
}
pub(crate) type Result<T> = std::result::Result<T, Error>; pub(crate) type Result<T> = std::result::Result<T, Error>;

View File

@ -2,25 +2,16 @@
#![allow(dead_code)] #![allow(dead_code)]
#![forbid(unused_imports)] #![forbid(unused_imports)]
/* //mod modules;
mod modules; //mod log;
mod log; //mod config;
mod config; //mod connection;
mod connection; //mod machine;
mod db; //mod builtin;
mod machine; //mod server;
mod builtin; //mod actor;
mod server; //mod initiator;
mod network;
mod actor;
mod initiator;
mod space; mod space;
*/
use rkyv::ser::serializers::AllocSerializer;
use rkyv::{SerializeUnsized, archived_value, Infallible, Deserialize};
use crate::oid::ObjectIdentifier;
use std::str::FromStr;
mod resource; mod resource;
mod schema; mod schema;
@ -29,6 +20,7 @@ mod db;
mod network; mod network;
pub mod oid; pub mod oid;
mod varint; mod varint;
mod error;
/* /*
@ -50,205 +42,3 @@ use slog::Logger;
use paho_mqtt::AsyncClient; use paho_mqtt::AsyncClient;
use crate::config::Config; use crate::config::Config;
*/ */
pub fn main() {
let db = db::StateDB::init("/tmp/state").unwrap();
println!("{:#?}", db);
let b = true;
//println!("{}", b.archived_type_oid());
let boid = &state::value::OID_BOOL;
let b2 = false;
let ent = state::Entry { oid: boid, val: &b2 };
println!("ent {:?}", &ent);
let s = serde_json::to_string(&ent).unwrap();
println!("{}", &s);
let ent2: state::OwnedEntry = serde_json::from_str(&s).unwrap();
println!("ent2: {:?}", ent2);
println!("Hello");
let mut ser = AllocSerializer::<32>::default();
//let b3 = Box::new(u32::from_ne_bytes([0xDE, 0xAD, 0xBE, 0xEF])) as Box<dyn state::value::SerializeValue>;
let b3 = Box::new(true) as Box<dyn state::value::SerializeValue>;
let pos3 = b3.serialize_unsized(&mut ser).unwrap();
let pos4 = 0;
//let pos4 = b4.serialize_unsized(&mut ser).unwrap();
let buf = ser.into_serializer().into_inner();
println!("({}) {:?} | {:?}", pos3, &buf[..pos3], &buf[pos3..]);
//println!("Serialized {} bytes: {:?} | {:?} | {:?}", pos4, &buf[..pos3], &buf[pos3+12..pos4], &buf[pos4+12..]);
let r3 = unsafe {
archived_value::<Box<dyn state::value::SerializeValue>>(&buf.as_slice(), pos3)
};
let v3: Box<dyn state::value::SerializeValue> = r3.deserialize(&mut Infallible).unwrap();
println!("{:?}", v3);
let koid = ObjectIdentifier::from_str("1.3.6.1.4.1.48398.612.2.1").unwrap();
let state = state::State::build()
.add(koid, Box::new(0xDEADBEEFu32))
.finish();
println!("{:?}", state);
let json = serde_json::to_string(&state).unwrap();
println!("{}", json);
let state_back: state::State = serde_json::from_str(&json).unwrap();
println!("{:?}", state_back);
let val = state_back.inner;
}
/*fn main() {
use clap::{crate_version, crate_description, crate_name};
// Argument parsing
// values for the name, description and version are pulled from `Cargo.toml`.
let matches = App::new(crate_name!())
.about(crate_description!())
.version(crate_version!())
.arg(Arg::with_name("config")
.help("Path to the config file to use")
.long("config")
.short("c")
.takes_value(true)
)
.arg(Arg::with_name("print default")
.help("Print a default config to stdout instead of running")
.long("print-default")
)
.arg(Arg::with_name("check config")
.help("Check config for validity")
.long("check")
)
.arg(Arg::with_name("dump")
.help("Dump all databases into the given directory")
.long("dump")
.conflicts_with("load")
)
.arg(Arg::with_name("load")
.help("Load databases from the given directory")
.long("load")
.conflicts_with("dump")
.takes_value(true)
)
.get_matches();
// Check for the --print-default option first because we don't need to do anything else in that
// case.
if matches.is_present("print default") {
let config = config::Config::default();
let encoded = serde_dhall::serialize(&config).to_string().unwrap();
// Direct writing to fd 1 is faster but also prevents any print-formatting that could
// invalidate the generated TOML
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.write_all(&encoded.as_bytes()).unwrap();
// Early return to exit.
return;
} else if matches.is_present("check config") {
let configpath = matches.value_of("config").unwrap_or("/etc/diflouroborane.dhall");
match config::read(&PathBuf::from_str(configpath).unwrap()) {
Ok(cfg) => {
//TODO: print a normalized version of the supplied config
println!("config is valid");
std::process::exit(0);
}
Err(e) => {
eprintln!("{}", e);
std::process::exit(-1);
}
}
}
let retval;
// Scope to drop everything before exiting.
{
// Initialize the logging subsystem first to be able to better document the progress from now
// on.
// TODO: Now would be a really good time to close stdin/out and move logging to syslog
// Log is in an Arc so we can do very cheap clones in closures.
let log = Arc::new(log::init());
info!(log, "Starting");
match maybe(matches, log.clone()) {
Ok(_) => retval = 0,
Err(e) => {
error!(log, "{}", e);
retval = -1;
}
}
}
std::process::exit(retval);
}
// Returning a `Result` from `main` allows us to use the `?` shorthand.
// In the case of an Err it will be printed using `fmt::Debug`
fn maybe(matches: clap::ArgMatches, log: Arc<Logger>) -> Result<(), Error> {
// If no `config` option is given use a preset default.
let configpath = matches.value_of("config").unwrap_or("/etc/diflouroborane.dhall");
let config = config::read(&PathBuf::from_str(configpath).unwrap())?;
debug!(log, "Loaded Config: {:?}", config);
if matches.is_present("dump") {
let db = db::Databases::new(&log, &config)?;
let v = db.access.dump_roles().unwrap();
for (id, role) in v.iter() {
info!(log, "Role {}:\n{}", id, role);
}
let v = db.userdb.list_users()?;
for user in v.iter() {
info!(log, "User {}:\n{:?}", user.id, user.data);
}
Ok(())
} else if matches.is_present("load") {
let db = db::Databases::new(&log, &config)?;
let mut dir = PathBuf::from(matches.value_of_os("load").unwrap());
dir.push("users.toml");
let map = db::user::load_file(&dir)?;
for (uid,user) in map.iter() {
db.userdb.put_user(uid, user)?;
}
debug!(log, "Loaded users: {:?}", map);
dir.pop();
Ok(())
} else {
let ex = Executor::new();
let db = db::Databases::new(&log, &config)?;
let machines = machine::load(&config)?;
let (actor_map, actors) = actor::load(&log, &config)?;
let (init_map, initiators) = initiator::load(&log, &config, db.userdb.clone(), db.access.clone())?;
let mut network = network::Network::new(machines, actor_map, init_map);
for (a,b) in config.actor_connections.iter() {
if let Err(e) = network.connect_actor(a,b) {
error!(log, "{}", e);
}
info!(log, "[Actor] Connected {} to {}", a, b);
}
for (a,b) in config.init_connections.iter() {
if let Err(e) = network.connect_init(a,b) {
error!(log, "{}", e);
}
info!(log, "[Initi] Connected {} to {}", a, b);
}
for actor in actors.into_iter() {
ex.spawn(actor).detach();
}
for init in initiators.into_iter() {
ex.spawn(init).detach();
}
server::serve_api_connections(log.clone(), config, db, network, ex)
}
}
*/

View File

@ -1,7 +1,6 @@
use std::ops::Deref; use std::ops::Deref;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::sync::Arc; use std::sync::Arc;
use futures_util::lock::Mutex;
use std::path::Path; use std::path::Path;
use std::task::{Poll, Context}; use std::task::{Poll, Context};
use std::pin::Pin; use std::pin::Pin;
@ -26,7 +25,6 @@ use crate::db::access::{AccessControl, PrivilegesBuf, PermissionBuf};
use crate::db::machine::{MachineIdentifier, MachineState, Status}; use crate::db::machine::{MachineIdentifier, MachineState, Status};
use crate::db::user::{User, UserData, UserId}; use crate::db::user::{User, UserData, UserId};
use crate::network::MachineMap;
use crate::space; use crate::space;
pub struct Machines { pub struct Machines {