diff --git a/Cargo.lock b/Cargo.lock index 50865c0..fd2ff51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,56 +19,57 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -76,20 +77,20 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.75" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -172,14 +173,14 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.42", + "syn", ] [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -192,9 +193,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" @@ -204,9 +205,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -217,6 +218,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "byteorder" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" + [[package]] name = "byteorder" version = "1.5.0" @@ -225,18 +232,25 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cbor" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e56053652b4b5c0ded5ae6183c7cd547ad2dd6bcce149658bef052a4995533bd" +dependencies = [ + "byteorder 0.5.3", + "rustc-serialize", +] [[package]] name = "cc" -version = "1.0.83" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cfg-if" @@ -246,18 +260,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.11" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -267,15 +281,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "colored" @@ -287,17 +301,11 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -323,22 +331,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "digest" @@ -352,9 +347,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -363,16 +358,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "fnv" version = "1.0.7" @@ -390,50 +375,38 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" - -[[package]] -name = "futures-macro" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.42", -] +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", - "futures-macro", "futures-sink", "futures-task", "pin-project-lite", @@ -453,9 +426,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -468,12 +441,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "headers" version = "0.3.9" @@ -506,9 +473,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "home" @@ -521,9 +488,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -600,20 +567,26 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "itoa" -version = "1.0.10" +name = "is_terminal_polyfill" +version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" @@ -623,31 +596,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" - -[[package]] -name = "linux-raw-sys" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "matchit" @@ -657,9 +614,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -679,18 +636,18 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", @@ -704,21 +661,15 @@ dependencies = [ "axum", "axum-extra", "axum-macros", + "cbor", "clap", "colored", "daemonize", - "derive_more", "env_logger", - "futures-util", "home", "log", "nix", - "serde", - "serde_cbor", - "serde_json", "tokio", - "tokio-stream", - "toml", "uuid", ] @@ -728,26 +679,16 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cfg-if", "libc", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -758,29 +699,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -789,29 +707,29 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -827,18 +745,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -873,20 +791,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" -version = "1.10.2" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -896,9 +805,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -907,97 +816,59 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustc-serialize" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.38.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] +checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401" [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -1006,9 +877,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ "itoa", "serde", @@ -1037,15 +908,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "slab" version = "0.4.9" @@ -1055,44 +917,27 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" dependencies = [ "proc-macro2", "quote", @@ -1107,31 +952,31 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.51" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.51" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn", ] [[package]] @@ -1151,45 +996,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", - "tokio-macros", "windows-sys 0.48.0", ] -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.42", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -1204,9 +1023,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -1215,15 +1034,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "tower" version = "0.4.13" @@ -1308,7 +1118,7 @@ version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ - "byteorder", + "byteorder 1.5.0", "bytes", "data-encoding", "http", @@ -1338,9 +1148,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -1350,9 +1160,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -1382,9 +1192,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "version_check" @@ -1407,37 +1217,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" @@ -1453,7 +1241,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] @@ -1473,17 +1261,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -1494,9 +1283,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -1506,9 +1295,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -1518,9 +1307,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -1530,9 +1325,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -1542,9 +1337,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -1554,9 +1349,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -1566,6 +1361,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index 70b4a76..7baebed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,30 +3,45 @@ name = "mize" version = "0.1.1" edition = "2021" +[lib] +name = "mize" +path = "src/lib.rs" + +[[bin]] +name = "mize" +path = "src/platform/os/main.rs" +required-features = [ "os-binary" ] + +[features] +os-binary = [ "clap", "home", "env_logger", "daemonize", "nix" ] + + [dependencies] -clap = { version = "4.4.11", features = ["cargo"] } -home = "0.5.9" -serde = { version = "1.0.152", features = ["derive"] } -serde_json = "1.0.91" -axum = { version = "0.6.1", features = ["ws", "headers"] } -axum-extra = { version = "0.4.2", features = ["spa"] } -axum-macros = "0.3.0" +# core dependencies colored = "2.0.0" -derive_more = "0.99.17" -futures-util = "0.3.24" +uuid = "1.3.0" +log = "0.4.20" +tokio = { version = "1.21.0", features = ["sync"] } +cbor = "0.4.1" + +clap = { version = "4.4.11", features = ["cargo"], optional = true } +home = { version = "0.5.9", optional = true } +env_logger = { version = "0.10.1", optional = true } +daemonize = { version = "0.5.0", optional = true } +nix = { version = "0.27.1", features = ["signal"], optional = true } + +axum = { version = "0.6.1", features = ["ws", "headers"], optional = true } +axum-extra = { version = "0.4.2", features = ["spa"], optional = true } +axum-macros = { version = "0.3.0", optional = true } + +#tokio-stream = { version = "0.1.9", optional = true } +#derive_more = "0.99.17" +#futures-util = "0.3.24" #itertools = "0.10.5" #lazy_static = "1.4.0" #rmp-serde = "1.1.1" #rmpv = { version = "1.0.0", features = ["serde", "with-serde"] } -tokio = { version = "1.21.0", features = ["full", "net"] } -tokio-stream = "0.1.9" -toml = "0.5.10" +#toml = "0.5.10" #tower-http = "0.3.5" -uuid = "1.3.0" -log = "0.4.20" -env_logger = "0.10.1" -daemonize = "0.5.0" -nix = { version = "0.27.1", features = ["signal"] } -serde_cbor = "0.11.2" diff --git a/flake.lock b/flake.lock index 92eead7..814a2f3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,46 @@ { "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715274763, + "narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", + "owner": "ipetkov", + "repo": "crane", + "rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1715063087, + "narHash": "sha256-cktPkcCmJ2sR0V/FaWEuCWmKuGPbwoMltih/EfF0mXg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "f8f16c1f2c83bea4e51e6522d988ec8bfcc8420e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -36,10 +77,29 @@ }, "root": { "inputs": { + "crane": "crane", + "fenix": "fenix", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1714936835, + "narHash": "sha256-M+PpgfRMBfHo8Jb2ou/s3maAZbps0XnuHXQU9Hv9vL0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "c4618fe14d39992fbbb85c2d6cad028a232c13d2", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index efbe7d0..d0fb590 100644 --- a/flake.nix +++ b/flake.nix @@ -3,15 +3,61 @@ # nixpkgs 35.11 still contains rust 1.73 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { flake-utils, nixpkgs, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { + outputs = { self, flake-utils, nixpkgs, fenix, crane, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: - - #packages.default = - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ cargo rustc ]; +############################## LET BINDINGS ############################## +let + pkgs = nixpkgs.legacyPackages.${system}; + wasmToolchain = fenix.packages.${system}.combine [ + fenix.packages.${system}.targets.wasm32-unknown-unknown.stable.toolchain + fenix.packages.${system}.complete.toolchain + ]; + osToolchain = fenix.packages.${system}.complete.toolchain; + wasmCrane = crane.lib.${system}.overrideToolchain wasmToolchain; + osCrane = crane.lib.${system}.overrideToolchain osToolchain; + +in { +############################## PACKAGES ############################## + packages.default = osCrane.buildPackage { + src = "${self}"; }; + + packages = { + wasm = wasmCrane.buildPackage { + src = "${self}"; + }; + }; + +############################## DEV SHELLS ############################## + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + wasm-pack #pkg-config openssl #cargo rustc + cargo-generate + /* + (fenix.packages.${system}.complete.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]) + */ + (fenix.packages.${system}.combine [ wasmToolchain osToolchain ]) + ]; + }; + }); } diff --git a/run b/run deleted file mode 100644 index 9dc6b07..0000000 --- a/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cargo run -- --folder=./mize-folder run diff --git a/src/cli/call.rs b/src/cli/call.rs deleted file mode 100644 index 0e0c4c7..0000000 --- a/src/cli/call.rs +++ /dev/null @@ -1,4 +0,0 @@ -use clap::ArgMatches; - -pub async fn call(sub_matches: &ArgMatches) { -} diff --git a/src/cli/mount.rs b/src/cli/mount.rs deleted file mode 100644 index dfa3538..0000000 --- a/src/cli/mount.rs +++ /dev/null @@ -1,4 +0,0 @@ -use clap::ArgMatches; - -pub async fn mount(sub_matches: &ArgMatches) { -} diff --git a/src/cli/serve.rs b/src/cli/serve.rs deleted file mode 100644 index 4846dc9..0000000 --- a/src/cli/serve.rs +++ /dev/null @@ -1,4 +0,0 @@ -use clap::ArgMatches; - -pub async fn serve(sub_matches: &ArgMatches) { -} diff --git a/src/cli/set.rs b/src/cli/set.rs deleted file mode 100644 index 0b8596e..0000000 --- a/src/cli/set.rs +++ /dev/null @@ -1,4 +0,0 @@ -use clap::ArgMatches; - -pub async fn set(sub_matches: &ArgMatches) { -} diff --git a/src/cli/sub.rs b/src/cli/sub.rs deleted file mode 100644 index e652cd3..0000000 --- a/src/cli/sub.rs +++ /dev/null @@ -1,4 +0,0 @@ -use clap::ArgMatches; - -pub async fn print(sub_matches: &ArgMatches) { -} diff --git a/src/error.rs b/src/core/error.rs similarity index 98% rename from src/error.rs rename to src/core/error.rs index ddaa874..6133cd3 100644 --- a/src/error.rs +++ b/src/core/error.rs @@ -1,18 +1,12 @@ - use std::collections::HashMap; use std::fmt::Debug; use std::fmt::Display; use std::fmt::format; use std::string::FromUtf8Error; -use toml::Value; -use colored::Colorize; use std::io; +use colored::Colorize; use log::{trace, debug, info, warn, error}; -use serde_json::Value as JsonValue; -use toml; - -use crate::instance::Connection; use crate::proto::MizeMessage; pub type MizeResult = Result; diff --git a/src/core/id.rs b/src/core/id.rs new file mode 100644 index 0000000..5161c6f --- /dev/null +++ b/src/core/id.rs @@ -0,0 +1,13 @@ +use std::hash::Hash; + + +#[derive(Hash, Eq, PartialEq)] +pub struct MizeId { + path: Vec +} + +impl From for MizeId { + fn from(value: String) -> Self { + MizeId{path: vec![value]} + } +} diff --git a/src/core/instance/connection.rs b/src/core/instance/connection.rs new file mode 100644 index 0000000..93db5e7 --- /dev/null +++ b/src/core/instance/connection.rs @@ -0,0 +1,16 @@ +use log::{trace, debug, info, warn, error}; +use tokio::sync::mpsc::{Sender, Receiver}; + +use crate::proto::MizeMessage; +use crate::error::{MizeError, MizeResult, IntoMizeResult}; + +pub trait Connection { +} + + +//#[derive(Debug)] +//pub struct Connection { + //tx: Sender, + //rx: Receiver, +//} + diff --git a/src/core/instance/mod.rs b/src/core/instance/mod.rs new file mode 100644 index 0000000..5518eda --- /dev/null +++ b/src/core/instance/mod.rs @@ -0,0 +1,71 @@ +use std::collections::HashMap; +use std::fs::create_dir; +use log::{trace, debug, info, warn, error}; +use uuid::Uuid; +use std::fs::File; +use colored::Colorize; +use std::path::Path; + +use crate::error::{MizeError, MizeResult, IntoMizeResult, MizeResultTrait}; +use crate::instance::store::Store; +use crate::instance::connection::Connection; +use crate::id::MizeId; +use crate::instance::subscription::Subscription; +use crate::item::{Item, ItemData}; +use crate::memstore::MemStore; + +pub mod connection; +pub mod store; +pub mod subscription; + +static MSG_CHANNEL_SIZE: usize = 200; + +/// The Instance type is the heart of the mize system +pub struct Instance { + // question vec of stores??? + // would mean replication logic and such things is handeled by the instance + // i think it would be better thogh to then implement a ReplicatedStore + store: S, + peers: Vec>, + subs: HashMap +} + +/* +pub enum RealmId { + Uuid(Uuid), + Local(Vec), + Tld(Vec), +} +*/ + + +impl Instance { + // new() opens a + pub async fn new() -> MizeResult> { + trace!("[ {} ] Instance::new()", "CALL".yellow()); + + let memstore = MemStore::new(); + let instance = Instance {store: memstore, peers: Vec::new(), subs: HashMap::new()}; + + // platform specific init code + // TODO + + return Ok(instance); + } + + pub fn new_item(self) -> MizeResult> { + let id = self.store.new_id()?; + return Ok(Item {id, instance: self}); + } + + pub fn get>(self, id: I) -> MizeResult> { + return Ok(Item {id: id.into(), instance: self}); + } + + pub fn set, V: Into>(self, id: I, value: V) -> MizeResult<()> { + self.store.set(id.into(), value) + } + +} + + diff --git a/src/core/instance/store.rs b/src/core/instance/store.rs new file mode 100644 index 0000000..96da4dc --- /dev/null +++ b/src/core/instance/store.rs @@ -0,0 +1,27 @@ +use crate::error::MizeResult; +use crate::item::{Item, ItemData}; +use crate::id::MizeId; + +pub trait Store { + // should have the ability to be multi threaded, if the underlying implementation supports + // multithreaded IO operations + // for now all refs to a store hold a Mutex but this mutex is part of where the MizeStore trait + // is implemented, so that there can be a multithreaded implementation + //fn get(self, id: MizeId) -> MizeResult> where Self: Sized; + + fn set>(self, id: MizeId, data: T) -> MizeResult<()>; + + // in the future should implement transactions, .... + + // funcs to do with links, backlinks + fn get_links(self, item: Item) -> MizeResult> where Self: Sized; + + fn get_backlinks(self, item: Item) -> MizeResult> where Self: Sized; + + fn new_id(&self) -> MizeResult; +} + +/// references an item that is stored in a store +pub trait StoreRef { + // do we need this or is this basically an item +} diff --git a/src/core/instance/subscription.rs b/src/core/instance/subscription.rs new file mode 100644 index 0000000..049ca0d --- /dev/null +++ b/src/core/instance/subscription.rs @@ -0,0 +1,3 @@ + + +pub struct Subscription; diff --git a/src/item.rs b/src/core/item.rs similarity index 89% rename from src/item.rs rename to src/core/item.rs index ded7b17..731f200 100644 --- a/src/item.rs +++ b/src/core/item.rs @@ -1,14 +1,39 @@ use log::{trace, debug, info, warn, error}; use std::{collections::HashMap, path::PathBuf, io::Cursor, fmt::Display}; -use serde_cbor::Value as CborValue; use std::fs::File; use tokio::sync::Mutex; use std::rc::Rc; use crate::error::{MizeError, MizeResult, IntoMizeResult}; -use crate::itemstore::Itemstore; +use crate::instance::Instance; +use crate::instance::store::Store; +use crate::id::MizeId; +use cbor::Cbor as CborValue; +// a item always has to do with a Instance, which takes care of how it is updated +pub struct Item { + pub id: MizeId, + pub instance: Instance +} + +// without an Instance it is not an item, but only the "data of an item" +// and this type for now is just an alias to CborValue +pub type ItemData = CborValue; + +impl Item { + pub fn id(self) -> MizeId { + self.id + } + + pub fn value_raw(self) -> MizeResult> { + // this will call from the instance which gets the value from the store + Ok(Vec::new()) + } +} + + +/* #[derive(Debug)] pub enum Item { Cbor(ItemCbor), @@ -233,4 +258,5 @@ impl Item { todo!() } } +*/ diff --git a/src/core/lib.rs b/src/core/lib.rs new file mode 100644 index 0000000..9b77184 --- /dev/null +++ b/src/core/lib.rs @@ -0,0 +1,3 @@ + +#![ allow( warnings ) ] + diff --git a/src/core/memstore.rs b/src/core/memstore.rs new file mode 100644 index 0000000..8c1420b --- /dev/null +++ b/src/core/memstore.rs @@ -0,0 +1,35 @@ +use std::collections::HashMap; +use cbor::Cbor as CborValue; + +use crate::id::MizeId; +use crate::instance::store::Store; +use crate::error::MizeResult; +use crate::item::{Item, ItemData}; + +pub struct MemStore { + map: HashMap, + next_id: u64, +} + +impl Store for MemStore { + fn set>(mut self, id: MizeId, data: T) -> MizeResult<()> { + self.map.insert(id, data.into()); + return Ok(()) + } + fn get_links(self, item: Item) -> MizeResult> { + Ok(Vec::new()) + } + fn get_backlinks(self, item: Item) -> MizeResult> { + Ok(Vec::new()) + } + fn new_id(&self) -> MizeResult { + let id_string = format!("{}", self.next_id); + return Ok(id_string.into()); + } +} + +impl MemStore { + pub fn new() -> MemStore { + return MemStore { map: HashMap::new(), next_id: 0 }; + } +} diff --git a/src/proto.rs b/src/core/proto/mod.rs similarity index 66% rename from src/proto.rs rename to src/core/proto/mod.rs index e4505b2..58153ee 100644 --- a/src/proto.rs +++ b/src/core/proto/mod.rs @@ -1,5 +1,4 @@ -use serde_cbor::Value as CborValue; - +use cbor::Cbor as CborValue; #[derive(Debug, Clone)] pub struct MizeMessage { diff --git a/src/core/types/mod.rs b/src/core/types/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/instance/mod.rs b/src/instance/mod.rs deleted file mode 100644 index 95ad691..0000000 --- a/src/instance/mod.rs +++ /dev/null @@ -1,192 +0,0 @@ -use std::collections::HashMap; -use std::path::PathBuf; -use std::fs::create_dir; -use colored::Colorize; -use log::{trace, debug, info, warn, error}; -use serde_json::json; -use tokio::net::{UnixListener, UnixStream}; -use uuid::Uuid; -use std::fs::File; -use std::path::Path; -use daemonize::Daemonize; -use nix::unistd::Pid; - -use crate::error::{MizeError, MizeResult, IntoMizeResult, MizeResultTrait}; -use crate::itemstore::{Itemstore, self}; -use crate::item::{Item, MizeId, ItemRef}; - -pub mod peer; -pub mod connection; - -pub use connection::Connection; - -static UNIX_SOCKET_CHANNEL_SIZE: usize = 200; -static WEB_SOCKET_CHANNEL_SIZE: usize = 200; -static TCP_SOCKET_CHANNEL_SIZE: usize = 200; -static UPDATE_CHANNEL_SIZE: usize = 200; - - -/// The Instance type is the heart of the mize system -pub struct Instance { - store: Itemstore, - peers: Vec, - realm_instance: Option<(RealmId, Vec)>, -} - -pub enum RealmId { - Uuid(Uuid), - Local(Vec), - Tld(Vec), -} - -impl Instance { - pub async fn new(instance_path: PathBuf) -> MizeResult { - trace!("[ {} ] Instance::new()", "CALL".yellow()); - trace!("[ {} ] instance_path: {:?}", "ARG".yellow(), instance_path); - - // if path does not exist, create it - if instance_path.exists() == false { - debug!("instance path \"{}\" does not exist, so creating it", instance_path.clone().display()); - File::create(&instance_path) - .mize_result_msg(format!("Could not create Instance at: {}", &instance_path.display())).critical(); - } - - // if a daemon is running, return instance with memory store - // with realm_instance at that daemon - let mut instance = match find_running_ademon(instance_path.clone()).await { - Ok(con) => { - Instance { - store: Itemstore::Memory(itemstore::new_memory_store()?), - peers: vec![con], - realm_instance: None, - } - }, - - // else open the itemstore - Err(err) => { - Instance { - store: Itemstore::Folder(itemstore::new_folder_store(instance_path)?), - peers: vec![], - realm_instance: None, - } - }, - }; - - if !instance.store.has_item(MizeId::main(1)).await? { - instance.store.create_item_from_json(json!({ - "item": { - "kind": "instance", - }, - "daemon": { - "log": "", - "pid": "", - "item": { - "kind": "instance/daemon", - }, - }, - })); - }; - - return Ok(instance); - - } - - pub async fn start_deamon(mut self) -> MizeResult<()> { - trace!("[ {} ] Instance::start_deamon()", "CALL".yellow()); - // daemonize - let stdout = self.get_item(MizeId::main(1).join("daemon").join("log")).await?.value_as_file()?; - - let pid_file = self.get_item(MizeId::main(1).join("daemon").join("pid")).await?.value_as_path()?; - - let daemonize = Daemonize::new() - .pid_file(pid_file) - //.chown_pid_file(true) // is optional, see `Daemonize` documentation - //.working_directory("/tmp") // for default behaviour. - //.user("nobody") - //.group("daemon") // Group name - //.group(2) // or group id. - //.umask(0o777) // Set umask, `0o027` by default. - .stdout(stdout); // Redirect stdout to `/tmp/daemon.out`. - //.privileged_action(|| "Executed before drop privileges"); - - daemonize.start().mize_result_msg("Error daemonizing")?; - - info!("Succesfuly Daemonized"); - - // listen on unix socket - let sock_path = self.get_item(MizeId::main(1).join("daemon").join("sock")).await?.value_as_path()?; - let listener = UnixListener::bind(&sock_path) - .mize_result_msg(format!("Could not bind to unix Socket at: {}", sock_path.display())).critical(); - loop { - match listener.accept().await { - Ok((unix_sock, _addr)) => { - self.peers.push(Connection::from_unix(unix_sock)) - }, - Err(e) => { MizeError::new().msg("New Peer failed").msg(format!("{}", e)).log(); }, - }; - } - } - - pub async fn get_daemon_pid(self) -> MizeResult { - trace!("[ {} ] Instance::get_daemon_pid()", "CALL".yellow()); - todo!() - } - - pub async fn daemon_is_running(&self) -> MizeResult { - trace!("[ {} ] Instance::daemon_is_running()", "CALL".yellow()); - let sock_path = self.get_item(MizeId::main(1).join("daemon").join("sock")).await?.value_as_path()?; - match find_running_ademon(sock_path).await { - Ok(_) => Ok(true), - Err(_) => Ok(false), - } - } - - - // item funcs - pub async fn get_item(&self, id: MizeId) -> MizeResult { - self.store.get_item(id).await - } - pub async fn set_item(&mut self, item: Item) -> MizeResult<()> { - self.store.set_item(item).await - } - pub async fn create_item(&mut self) -> MizeResult { - self.store.create_item().await - } - - //pub fn update_item(self) -> MizeResult { - //todo!() - //} - //pub fn on_item_update(self) -> MizeResult { - //todo!() - //} -} - -async fn find_running_ademon(path: PathBuf) -> MizeResult { - match UnixStream::connect(path).await { - Ok(val) => Ok(Connection::from_unix(val)), - Err(err) => Err(MizeError::new().msg("No Daemon found to connect")), - } -} - - -fn handle_connection() { - todo!() -} - -/* -fn get_instance_type() -> MizeResult { - - let mut types_item = Item::new("types"); - - // instance - let instance_str = include_str!("../../types/mize/instance/item.json"); - let instance = Item::new("type").load_json(instance_str)?; - types_item.set("instance", instance); - - return Ok(types_item); -} -*/ - - - - diff --git a/src/instance/peer.rs b/src/instance/peer.rs deleted file mode 100644 index 8b13789..0000000 --- a/src/instance/peer.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/itemstore.rs b/src/itemstore.rs deleted file mode 100644 index cbbad65..0000000 --- a/src/itemstore.rs +++ /dev/null @@ -1,268 +0,0 @@ -use log::{trace, debug, info, warn, error}; -use std::fs::{self, File}; -use std::path::{PathBuf, Path}; -use std::collections::HashMap; -use std::io::{Read, Write}; -use colored::Colorize; -use std::rc::Rc; - -use crate::item::{Item, MizeId, ItemCbor, ItemRef}; -use crate::error::{MizeError, MizeResult, IntoMizeResult}; - -pub enum Itemstore { - Folder(FolderItemstore), - Memory(MemoryItemstore), -} - -pub struct FolderItemstore { - path: PathBuf, - next_id: u64, -} - -pub struct MemoryItemstore { - inner: HashMap, - next_id: u64, -} - - -/////////////////////////////////////////////////////////////////////////////////////////// - - -pub fn new_memory_store() -> MizeResult { - Ok(MemoryItemstore { - inner: HashMap::new(), - next_id: 100, - }) -} - -pub fn new_folder_store(path: PathBuf) -> MizeResult { - if path.join("store_open").exists() { - let pid_str = fs::read_to_string(path.join("store_open")) - .mize_result_msg("Could not read the store_open file to check which process has the store opened")?; - let pid = pid_str.parse::() - .mize_result_msg("Could not Parse the content of the store_open file into a u32")?; - - if Path::new("/proc").join(format!("{}", pid)).exists() { - return Err(MizeError::new().msg( - format!("the store at {} is already open by process with pid: {}", path.display(), pid) - )); - } else { - warn!("An Instance was not closed properly. (store_open file contained a not running PID)"); - std::fs::remove_file(path.join("store_open")) - .mize_result_msg("Could not remove the store_open file")?; - } - } - - let mut store_open_file = File::create(path.join("store_open")) - .mize_result_msg("Could not create the store_open file")?; - - store_open_file.write_all(format!("{}", std::process::id()).as_bytes()) - .mize_result_msg("Could not write my pid to the store_open file")?; - - // if no store_next_id exists write it with the default 100 - let mut next_id: u64 = 100; // as a default - if !path.join("store_next_id").exists() { - fs::write(path.join("store_next_id"), format!("{}", next_id).as_bytes()) - .mize_result_msg("Could not write the default next_id to store_next_id")?; - } else { - let next_id_string = fs::read_to_string(path.join("store_next_id")) - .mize_result_msg("Could not read store_next_id of this store")?; - - next_id = next_id_string.parse() - .mize_result_msg("Could not parse contents of store_next_id into u64")?; - } - - return Ok(FolderItemstore{ path, next_id}); - -} - - -/////////////////////////////////////////////////////////////////////////////////////////// - - -impl FolderItemstore { - pub async fn write_next_id(&self) -> MizeResult<()> { - fs::write(self.path.join("store_next_id"), format!("{}", self.next_id).as_bytes()) - .mize_result_msg(format!("Could not write the next_id: \"{}\" to \"{}\"", self.next_id, self.path.join("store_next_id").display()))?; - return Ok(()); - } -} - - -/////////////////////////////////////////////////////////////////////////////////////////// - - -impl MemoryItemstore { - // item funcs - async fn get_item(&self, id: MizeId) -> MizeResult { - match self.inner.get(&id) { - None => { - Err(MizeError::new().msg(format!("there was no item with id ({}) in this store", id))) - }, - Some(item) => { - Ok(Item::Cbor(item.as_cbor()?)) - }, - } - } - - async fn set_item(&mut self, item: Item) -> MizeResult<()> { - self.inner.insert(item.id()?, item) - .ok_or(MizeError::new().msg("Could not set an item in a MemoryStore"))?; - return Ok(()); - } - - - async fn create_item(&mut self) -> MizeResult { - // advance the next_id - self.next_id += 1; - return Ok(MizeId::main(self.next_id)) - } - - //fn update_item(self) -> MizeResult; - - // other funcs - async fn close(&self) -> MizeResult<()> { - return Ok(()); - } - - async fn next_id(&self) -> u64 { - self.next_id - } - - async fn has_item(&self, id: MizeId) -> MizeResult { - Ok(self.inner.contains_key(&id)) - } -} - -impl FolderItemstore { - // item funcs - async fn get_item(&self, id: MizeId) -> MizeResult { - let id_string = format!("{}", id.main); - let mut final_path = self.path.join("store"); - if id_string.len() < 2 { - // use path 00 for ids under 10 - final_path.push("00") - } else { - // will not panic, because of prior check if string is more than two long - final_path.push(id_string[..2].to_owned()); - }; - - return Ok(Item::Descriptor(ItemRef { path: final_path, id})); - } - - async fn set_item(&self, item: Item) -> MizeResult<()> { - item.write_to_path(self.get_path_of_item(&item.id()?)?) - } - - async fn create_item(&mut self) -> MizeResult { - // advance the next_id - self.next_id += 1; - match self.write_next_id().await { - // on error revert to old next_id - Ok(_) => {}, - Err(err) => { - self.next_id -= 1; - return Err(err); - }, - } - return Ok(MizeId::main(self.next_id)); - } - - //fn update_item(self) -> MizeResult; - - // other funcs - async fn close(&self) -> MizeResult<()> { - if self.path.join("store_open").exists() { - std::fs::remove_file(self.path.join("store_open")) - .mize_result_msg("Could not remove the store_open file")?; - } - return Ok(()); - } - - async fn next_id(&self) -> u64 { - self.next_id - } - async fn has_item(&self, id: MizeId) -> MizeResult { - Ok(self.get_path_of_item(&id)?.exists()) - } - - fn get_path_of_item(&self, id: &MizeId) -> MizeResult { - // get path of item - let id_string = format!("{}", id.main); - let mut final_path = self.path.join("store"); - if id_string.len() < 2 { - // use path 00 for ids under 10 - final_path.push("00") - } else { - // will not panic, because of prior check if string is more than two long - final_path.push(id_string[..2].to_owned()); - }; - return Ok(final_path); - } -} - -impl Itemstore { - // item funcs - pub async fn get_item(&self, id: MizeId) -> MizeResult { - trace!("[ {} ] Itemstore::get_item()", "CALL".yellow()); - trace!("[ {} ] id: {}", "ARG".yellow(), id); - - match self { - Itemstore::Folder(val) => val.get_item(id).await, - Itemstore::Memory(val) => val.get_item(id).await, - } - } - - pub async fn set_item(&mut self, item: Item) -> MizeResult<()> { - trace!("[ {} ] Itemstore::set_item()", "CALL".yellow()); - trace!("[ {} ] item: {:?}", "ARG".yellow(), item); - - match self { - Itemstore::Folder(val) => val.set_item(item).await, - Itemstore::Memory(val) => val.set_item(item).await, - } - } - - pub async fn create_item(&mut self) -> MizeResult { - trace!("[ {} ] Itemstore::create_item()", "CALL".yellow()); - - match self { - Itemstore::Folder(val) => val.create_item().await, - Itemstore::Memory(val) => val.create_item().await, - } - } - - //pub fn update_item(self) -> MizeResult; - - // other funcs - pub async fn close(&self) -> MizeResult<()> { - trace!("[ {} ] Itemstore::close()", "CALL".yellow()); - match self { - Itemstore::Folder(val) => val.close().await, - Itemstore::Memory(val) => val.close().await, - } - } - - pub async fn next_id(&self) -> u64 { - trace!("[ {} ] Itemstore::next_id()", "CALL".yellow()); - - match self { - Itemstore::Folder(val) => val.next_id().await, - Itemstore::Memory(val) => val.next_id().await, - } - } - pub async fn has_item(&self, id: MizeId) -> MizeResult { - trace!("[ {} ] Itemstore::has_item()", "CAL".yellow()); - trace!("[ {} ] id: {}", "ARG".yellow(), id); - - let ret = match self { - Itemstore::Folder(val) => val.has_item(id).await, - Itemstore::Memory(val) => val.has_item(id).await, - }; - - if let Ok(val) = ret {trace!("[ {} ] Itemstore::has_item(): {}", "RET".yellow(), val)}; - - return ret; - } -} - diff --git a/src/lib.rs b/src/lib.rs index 2de16d5..9698367 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,14 +3,18 @@ static PROTO_VERSION: u8 = 1; +pub mod core { + pub mod memstore; + pub mod instance; + pub mod item; + pub mod id; + pub mod proto; + pub mod error; + pub mod types; +} + +pub use core::*; -// pub mod types; - -pub mod error; -mod instance; -mod proto; -mod item; -mod itemstore; diff --git a/src/platform/os/cli/call.rs b/src/platform/os/cli/call.rs new file mode 100644 index 0000000..20a6047 --- /dev/null +++ b/src/platform/os/cli/call.rs @@ -0,0 +1,4 @@ +use clap::ArgMatches; + +pub fn call(sub_matches: &ArgMatches) { +} diff --git a/src/cli/daemon.rs b/src/platform/os/cli/daemon.rs similarity index 91% rename from src/cli/daemon.rs rename to src/platform/os/cli/daemon.rs index f7a550c..76f6756 100644 --- a/src/cli/daemon.rs +++ b/src/platform/os/cli/daemon.rs @@ -6,11 +6,13 @@ use std::fs::File; use log::{trace, debug, info, warn, error}; use nix::sys::signal::{self, Signal}; -use crate::error::{MizeResultTrait, IntoMizeResult, MizeError}; -use crate::instance::Instance; +use mize::error::{MizeResultTrait, IntoMizeResult, MizeError}; +use mize::instance::Instance; -pub async fn daemon(sub_matches: &ArgMatches) { +pub fn daemon(sub_matches: &ArgMatches) { + println!("not implemented"); + /* let instance_path = match sub_matches.get_one::("store") { Some(a) => PathBuf::from(a), None => { @@ -60,4 +62,5 @@ pub async fn daemon(sub_matches: &ArgMatches) { }; }, } + */ } diff --git a/src/cli/get.rs b/src/platform/os/cli/get.rs similarity index 68% rename from src/cli/get.rs rename to src/platform/os/cli/get.rs index 3adeb15..478b58d 100644 --- a/src/cli/get.rs +++ b/src/platform/os/cli/get.rs @@ -3,12 +3,12 @@ use std::path::PathBuf; use clap::ArgMatches; use home::home_dir; -use crate::error::{MizeResultTrait, IntoMizeResult, MizeError}; -use crate::instance::Instance; +use mize::error::{MizeResultTrait, IntoMizeResult, MizeError}; +use mize::instance::Instance; -pub async fn get(sub_matches: &ArgMatches) { +pub fn get(sub_matches: &ArgMatches) { let instance_folder_path = match sub_matches.get_one::("store") { Some(a) => PathBuf::from(a), None => { @@ -18,6 +18,7 @@ pub async fn get(sub_matches: &ArgMatches) { home_dir }, }; - let instance = Instance::new(instance_folder_path); + println!("unfinished"); + //let instance = Instance::new(instance_folder_path); } diff --git a/src/platform/os/cli/mount.rs b/src/platform/os/cli/mount.rs new file mode 100644 index 0000000..e3d5196 --- /dev/null +++ b/src/platform/os/cli/mount.rs @@ -0,0 +1,4 @@ +use clap::ArgMatches; + +pub fn mount(sub_matches: &ArgMatches) { +} diff --git a/src/platform/os/cli/serve.rs b/src/platform/os/cli/serve.rs new file mode 100644 index 0000000..de6e3e1 --- /dev/null +++ b/src/platform/os/cli/serve.rs @@ -0,0 +1,4 @@ +use clap::ArgMatches; + +pub fn serve(sub_matches: &ArgMatches) { +} diff --git a/src/platform/os/cli/set.rs b/src/platform/os/cli/set.rs new file mode 100644 index 0000000..3abe745 --- /dev/null +++ b/src/platform/os/cli/set.rs @@ -0,0 +1,4 @@ +use clap::ArgMatches; + +pub fn set(sub_matches: &ArgMatches) { +} diff --git a/src/platform/os/cli/show.rs b/src/platform/os/cli/show.rs new file mode 100644 index 0000000..dbaedda --- /dev/null +++ b/src/platform/os/cli/show.rs @@ -0,0 +1,4 @@ +use clap::ArgMatches; + +pub fn show(sub_matches: &ArgMatches) { +} diff --git a/src/platform/os/fsstore.rs b/src/platform/os/fsstore.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/platform/os/main.rs similarity index 94% rename from src/main.rs rename to src/platform/os/main.rs index d9b2fe6..147cd8d 100644 --- a/src/main.rs +++ b/src/platform/os/main.rs @@ -21,34 +21,23 @@ mod cli { pub mod serve; pub mod get; pub mod set; + pub mod show; pub mod mount; - pub mod print; pub mod call; pub use daemon::daemon; pub use serve::serve; pub use get::get; pub use set::set; + pub use show::show; pub use mount::mount; - pub use print::print; pub use call::call; } -mod error; -// mod types; -mod instance; -mod item; -mod itemstore; -mod proto; - -#[cfg(test)] -mod test; - static APPNAME: &str = "mize"; static DEFAULT_LOG_LEVEL: LevelFilter = LevelFilter::Warn; -#[tokio::main] -async fn main() { +fn main() { // welcome to the mize source code // this is the main entry point for platforms with an os (eg: Linux, MacOS, Windows, BSD, ...) // Also let's try to make the most best documented code ever. (eventually) so it's fun to work on @@ -64,25 +53,25 @@ async fn main() { // match command match cli_matches.subcommand() { // mi daemon - Some(("daemon", sub_matches)) => cli::daemon(sub_matches).await, + Some(("daemon", sub_matches)) => cli::daemon(sub_matches), // mi serve - Some(("serve", sub_matches)) => cli::serve(sub_matches).await, + Some(("serve", sub_matches)) => cli::serve(sub_matches), // mi mount - Some(("mount", sub_matches)) => cli::mount(sub_matches).await, + Some(("mount", sub_matches)) => cli::mount(sub_matches), // mi get - Some(("get", sub_matches)) => cli::get(sub_matches).await, + Some(("get", sub_matches)) => cli::get(sub_matches), // mi set - Some(("set", sub_matches)) => cli::set(sub_matches).await, + Some(("set", sub_matches)) => cli::set(sub_matches), - // mi sub - Some(("sub", sub_matches)) => cli::sub(sub_matches).await, + // mi show + Some(("show", sub_matches)) => cli::show(sub_matches), // mi call - Some(("call", sub_matches)) => cli::call(sub_matches).await, + Some(("call", sub_matches)) => cli::call(sub_matches), // some unknown command passed Some((cmd, sub_matches)) => error!("The subcommand: {} is not known. use --help to list availavle commands", cmd), @@ -330,8 +319,8 @@ fn cli_matches() -> clap::ArgMatches { .arg(Arg::new("id").help("The id or path to set")) ) .subcommand( - Command::new("sub") - .aliases(["su"]) + Command::new("show") + .aliases(["so"]) .arg(&store_arg) .arg(Arg::new("id").help("The id or path to sub to and show")) ) diff --git a/src/instance/connection.rs b/src/platform/os/unix-socket.rs similarity index 84% rename from src/instance/connection.rs rename to src/platform/os/unix-socket.rs index d8d20ce..afbd656 100644 --- a/src/instance/connection.rs +++ b/src/platform/os/unix-socket.rs @@ -1,16 +1,3 @@ -use log::{trace, debug, info, warn, error}; -use tokio::{sync::mpsc::{Sender, Receiver}, net::UnixStream}; -use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf}; -use tokio::io::{self, Interest}; - -use crate::proto::MizeMessage; -use crate::error::{MizeError, MizeResult, IntoMizeResult}; - -#[derive(Debug)] -pub struct Connection { - tx: Sender, - rx: Receiver, -} impl Connection { pub fn from_unix(unix_sock: UnixStream) -> Connection { diff --git a/src/instance/web.rs b/src/platform/os/web.rs similarity index 100% rename from src/instance/web.rs rename to src/platform/os/web.rs diff --git a/src/test/mod.rs b/src/test/mod.rs new file mode 100644 index 0000000..52f58df --- /dev/null +++ b/src/test/mod.rs @@ -0,0 +1,31 @@ + +use crate::instance::MizeInstance; + +#[test] +fn most_minimal_instance_usage() { + // so I'm actually starting the effort for a better code base here in the tests + // i want to write down how you would use the very important instance type + // and then implement it to make it usable in this way + + // how every mize based program to run on an os should create a mize instance + // opens the instance the way the user has configured (with env vars, build args, or config + // files) + // and we just call it "new()" and not "default_system()" so that it is clear that this is the + // method that should be used + let mize = MizeInstance::new(); + + // then the most important things you do with your mize instance is to get/set stuff + let name: MizeItem = mize.get("1/namespace"); + let id = mize.new_item(); + mize.set(id.join("name"), "test-item"); + + // or register update callbacks and update + //mize.on_update("5/name", |delta| println!(delta.new_value())); + //mize.update("5/name", "other-item") + + // the goal is that also most things about the MizeInstance itself is controlled by + // get/set/update -ing values at the 0/ paths +} + + +