diff --git a/Cargo.lock b/Cargo.lock index 8c06d9e..10883f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,1086 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bstr" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + +[[package]] +name = "clap" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "cucumber" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cd12917efc3a8b069a4975ef3cb2f2d835d42d04b3814d90838488f9dd9bf69" +dependencies = [ + "anyhow", + "clap", + "console", + "cucumber-codegen", + "cucumber-expressions", + "derive_more", + "drain_filter_polyfill", + "either", + "futures", + "gherkin", + "globwalk", + "humantime", + "inventory", + "itertools", + "lazy-regex", + "linked-hash-map", + "once_cell", + "pin-project", + "regex", + "sealed", + "serde", + "serde_json", + "smart-default", +] + +[[package]] +name = "cucumber-codegen" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e19cd9e8e7cfd79fbf844eb6a7334117973c01f6bad35571262b00891e60f1c" +dependencies = [ + "cucumber-expressions", + "inflections", + "itertools", + "proc-macro2", + "quote", + "regex", + "syn", + "synthez", +] + +[[package]] +name = "cucumber-expressions" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d794fed319eea24246fb5f57632f7ae38d61195817b7eb659455aa5bdd7c1810" +dependencies = [ + "derive_more", + "either", + "nom", + "nom_locate", + "regex", + "regex-syntax 0.7.5", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "drain_filter_polyfill" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669a445ee724c5c69b1b06fe0b63e70a1c84bc9bb7d9696cd4f4e3ec45050408" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gherkin" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20b79820c0df536d1f3a089a2fa958f61cb96ce9e0f3f8f507f5a31179567755" +dependencies = [ + "heck 0.4.1", + "peg", + "quote", + "serde", + "serde_json", + "syn", + "textwrap", + "thiserror", + "typed-builder", +] + +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax 0.8.4", +] + +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "inflections" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" + +[[package]] +name = "inventory" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy-regex" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nom_locate" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e3c83c053b0713da60c5b8de47fe8e494fe3ece5267b2f23090a07a053ba8f3" +dependencies = [ + "bytecount", + "memchr", + "nom", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "peg" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f76678828272f177ac33b7e2ac2e3e73cc6c1cd1e3e387928aa69562fa51367" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "636d60acf97633e48d266d7415a9355d4389cea327a193f87df395d88cd2b14d" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555b1514d2d99d78150d3c799d4c357a3e2c2a8062cd108e93a06d9057629c5" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "sealed" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a8caec23b7800fb97971a1c6ae365b6239aaeddfb934d6265f8505e795699d" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smart-default" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synthez" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d2c2202510a1e186e63e596d9318c91a8cbe85cd1a56a7be0c333e5f59ec8d" +dependencies = [ + "syn", + "synthez-codegen", + "synthez-core", +] + +[[package]] +name = "synthez-codegen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f724aa6d44b7162f3158a57bccd871a77b39a4aef737e01bcdff41f4772c7746" +dependencies = [ + "syn", + "synthez-core", +] + +[[package]] +name = "synthez-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bfa6ec52465e2425fd43ce5bbbe0f0b623964f7c63feb6b10980e816c654ea" +dependencies = [ + "proc-macro2", + "quote", + "sealed", + "syn", +] + +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tlm" version = "0.1.0" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tlm-tests-rust" +version = "0.1.0" +dependencies = [ + "cucumber", + "futures", + "tlm", +] + +[[package]] +name = "typed-builder" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe83c85a85875e8c4cb9ce4a890f05b23d38cd0d47647db7895d3d2a79566d2" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a3151c41d0b13e3d011f98adc24434560ef06673a155a6c7f66b9879eecce2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "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]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +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" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index fd23486..23eba90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,6 @@ resolver = "2" members = [ - "packages/tlm-rust" + "packages/tlm-rust", + "packages/tlm-tests-rust" ] diff --git a/packages/tlm-rust/Cargo.toml b/packages/tlm-rust/Cargo.toml index aa27244..da2e603 100644 --- a/packages/tlm-rust/Cargo.toml +++ b/packages/tlm-rust/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +lazy_static = "1.5.0" diff --git a/packages/tlm-rust/src/core.rs b/packages/tlm-rust/src/core.rs new file mode 100644 index 0000000..8106e31 --- /dev/null +++ b/packages/tlm-rust/src/core.rs @@ -0,0 +1,5 @@ +mod schema; +mod meta; + +pub use schema::*; +pub use meta::*; diff --git a/packages/tlm-rust/src/core/meta.rs b/packages/tlm-rust/src/core/meta.rs new file mode 100644 index 0000000..5b012f3 --- /dev/null +++ b/packages/tlm-rust/src/core/meta.rs @@ -0,0 +1,100 @@ +use lazy_static::lazy_static; +use crate::TlmNamespace; + +lazy_static! { + pub static ref TLM_CORE_NAMESPACES: Vec = vec![ + TlmNamespace::new( + 1, + String::from("tlm"), + String::from("https://type.link.model.tools/ns/tlm/") + ).describe(String::from("The Core TLM namespace.")), + TlmNamespace::new( + 2, + String::from("xs"), + String::from("http://www.w3.org/2001/XMLSchema") + ).describe(String::from("Namespaces for XML Schema DataTypes.")), + ]; + +// pub static ref TLM_CORE_TYPES: Vec = vec![ +// TlmType::new(3, 1, String::from("Namespace"), 4).describe(String::from("The special Type for Namespaces.")), +// TlmType::new(4, 1, String::from("Type"), 4).describe(String::from("The special Type for Types (the meta-Type).")), +// TlmType::new(5, 1, String::from("ValueType"), 4).describe(String::from("Simple kind of Object that is a simple primitive value.")), +// TlmType::new(6, 2, String::from("DataType"), 5).describe(String::from("XML Schema compatible value.")), +// TlmType::new(7, 2, String::from("boolean"), 6).describe(String::from("XML Schema compatible boolean.")), +// TlmType::new(8, 2, String::from("float"), 6).describe(String::from("XML Schema compatible float.")), +// TlmType::new(9, 2, String::from("double"), 6).describe(String::from("XML Schema compatible double.")), +// TlmType::new(10, 2, String::from("decimal"), 6).describe(String::from("XML Schema compatible decimal.")), +// TlmType::new(11, 2, String::from("integer"), 10).describe(String::from("XML Schema compatible integer.")), +// TlmType::new(12, 2, String::from("long"), 11).describe(String::from("XML Schema compatible long.")), +// TlmType::new(13, 2, String::from("int"), 12).describe(String::from("XML Schema compatible int.")), +// TlmType::new(14, 2, String::from("short"), 13).describe(String::from("XML Schema compatible short.")), +// TlmType::new(15, 2, String::from("byte"), 14).describe(String::from("XML Schema compatible byte.")), +// TlmType::new(16, 2, String::from("string"), 6).describe(String::from("XML Schema compatible string.")), +// TlmType::new(17, 2, String::from("anyURI"), 6).describe(String::from("XML Schema compatible anyURI.")), +// TlmType::new(18, 2, String::from("duration"), 6).describe(String::from("XML Schema compatible duration.")), +// TlmType::new(19, 2, String::from("dateTime"), 6).describe(String::from("XML Schema compatible dateTime.")), +// TlmType::new(20, 2, String::from("time"), 6).describe(String::from("XML Schema compatible time.")), +// TlmType::new(21, 2, String::from("date"), 6).describe(String::from("XML Schema compatible date.")), +// TlmType::new(22, 2, String::from("gYearMonth"), 6).describe(String::from("XML Schema compatible date.")), +// TlmType::new(23, 2, String::from("gYear"), 6).describe(String::from("XML Schema compatible gYear.")), +// TlmType::new(24, 2, String::from("gMonthDay"), 6).describe(String::from("XML Schema compatible gMonthDay.")), +// TlmType::new(25, 2, String::from("gDay"), 6).describe(String::from("XML Schema compatible gDay.")), +// TlmType::new(26, 2, String::from("gMonth"), 6).describe(String::from("XML Schema compatible gMonth.")), +// TlmType::new(27, 2, String::from("dateTimeStamp"), 19).describe(String::from("XML Schema compatible dateTimeStamp.")), +// TlmType::new(28, 2, String::from("dayTimeDuration"), 18).describe(String::from("XML Schema compatible dayTimeDuration.")), +// TlmType::new(29, 2, String::from("yearMonthDuration"), 18).describe(String::from("XML Schema compatible yearMonthDuration.")), +// TlmType::new(30, 2, String::from("base64Binary"), 6).describe(String::from("XML Schema compatible base64Binary.")), +// TlmType::new(31, 2, String::from("hexBinary"), 6).describe(String::from("XML Schema compatible hexBinary.")), +// TlmType::new(32, 2, String::from("nonPositiveInteger"), 11).describe(String::from("XML Schema compatible nonPositiveInteger.")), +// TlmType::new(33, 2, String::from("negativeInteger"), 32).describe(String::from("XML Schema compatible negativeInteger.")), +// TlmType::new(34, 2, String::from("nonNegativeInteger"), 11).describe(String::from("XML Schema compatible nonNegativeInteger.")), +// TlmType::new(35, 2, String::from("positiveInteger"), 34).describe(String::from("XML Schema compatible positiveInteger.")), +// TlmType::new(36, 2, String::from("unsignedLong"), 34).describe(String::from("XML Schema compatible unsignedLong.")), +// TlmType::new(37, 2, String::from("unsignedInt"), 36).describe(String::from("XML Schema compatible unsignedInt.")), +// TlmType::new(38, 2, String::from("unsignedShort"), 37).describe(String::from("XML Schema compatible unsignedShort.")), +// TlmType::new(39, 2, String::from("unsignedByte"), 38).describe(String::from("XML Schema compatible unsignedByte.")), +// TlmType::new(40, 2, String::from("normalizedString"), 16).describe(String::from("XML Schema compatible normalizedString.")), +// TlmType::new(41, 2, String::from("token"), 40).describe(String::from("XML Schema compatible token.")), +// TlmType::new(42, 2, String::from("language"), 41).describe(String::from("XML Schema compatible language.")), +// TlmType::new(43, 2, String::from("NMTOKEN"), 41).describe(String::from("XML Schema compatible NMTOKEN.")), +// TlmType::new(44, 2, String::from("Name"), 41).describe(String::from("XML Schema compatible Name.")), +// TlmType::new(45, 2, String::from("NCName"), 44).describe(String::from("XML Schema compatible NCName.")), +// TlmType::new(46, 2, String::from("IDREF"), 45).describe(String::from("XML Schema compatible IDREF.")), +// TlmType::new(47, 2, String::from("ID"), 45).describe(String::from("XML Schema compatible ID.")), +// TlmType::new(48, 2, String::from("ENTITY"), 45).describe(String::from("XML Schema compatible ENTITY.")), +// TlmType::new(49, 1, String::from("URI"), 17).describe(String::from("An ASCII uniform resource identifier per RFC3986.")), +// TlmType::new(50, 1, String::from("URL"), 49).describe(String::from("An ASCII uniform resource locator per WHATWG URL Standard.")), +// TlmType::new(51, 1, String::from("URN"), 49).describe(String::from("An ASCII uniform resource name per RFC8141.")), +// TlmType::new(52, 1, String::from("UUID"), 51).describe(String::from("An ASCII universally unique identifier per RFC4122.")), +// TlmType::new(53, 1, String::from("Link"), 4).describe(String::from("A relation between types.")), +// TlmType::new(71, 1, String::from("Fact"), 4).describe(String::from("A statement about an identified Object in the world considered to be true.")), +// TlmType::new(74, 1, String::from("LinkFact"), 71).describe(String::from("A fact about an object its relation to another object.")), +// TlmType::new(76, 1, String::from("ToggleFact"), 71).describe(String::from("A fact about an object that is either true (defined) or false (absent).")), +// TlmType::new(78, 1, String::from("ValueFact"), 74).describe(String::from("A fact about an object that has as its target a primitive value.")), +// ]; + +// pub static ref TLM_CORE_LINKS: Vec = vec![ +// vec![ +// TlmLink::new(54, 53, 4, String::from("from type"), true, false, true, false, false, false, false).describe(String::from("The type this link belongs to.")), +// TlmLink::new(55, 53, 4, String::from("to type"), true, false, true, false, false, false, false).describe(String::from("The type this link points to.")), +// TlmLink::new(56, 53, 44, String::from("name"), true, false, true, false, false, true, false).describe(String::from("The name of the link.")), +// TlmLink::new(57, 53, 16, String::from("from name"), true, false, false, false, false, true, false).describe(String::from("The name for the link for the "from" type.")), +// TlmLink::new(58, 53, 16, String::from("to name"), true, false, false, false, false, true, false).describe(String::from("The name for the link for the "to" type.")), +// TlmLink::new(59, 53, 7, String::from("is singular"), true, false, true, false, true, true, false).describe(String::from("Whether there can be a single link like this for the "from" type.")), +// TlmLink::new(60, 53, 7, String::from("is mandatory"), true, false, true, false, true, true, false).describe(String::from("Whether there has to be a value for the "from" type.")), +// TlmLink::new(61, 53, 7, String::from("is toggle"), true, false, true, false, true, true, false).describe(String::from("Whether this is a simple boolean link.")), +// TlmLink::new(62, 53, 7, String::from("is value"), true, false, true, false, true, true, false).describe(String::from("Whether this link is to a ValueType.")), +// TlmLink::new(63, 53, 7, String::from("is primary id"), true, false, true, false, true, true, false).describe(String::from("Whether this link is to a primary identifier.")), +// TlmLink::new(64, 3, 45, String::from("prefix"), true, false, true, false, false, true, false).describe(String::from("Shorthand identifier for the Namespace. Must be valid XML namespace prefix, i.e. match [a-z0-9]+.")), +// TlmLink::new(65, 3, 16, String::from("description"), true, false, false, false, false, true, false).describe(String::from("Friendly human-readable description of the Namespace.")), +// TlmLink::new(66, 4, 4, String::from("type"), true, false, true, false, false, false, false).describe(String::from("The Type of the Object itself.")), +// TlmLink::new(67, 4, 3, String::from("namespace"), true, false, true, false, false, false, false).describe(String::from("The namespace this Type belongs to.")), +// TlmLink::new(68, 4, 4, String::from("super"), true, false, true, false, false, false, false).describe(String::from("The supertype of this Type. It inherits all possible Links from its supertype.")), +// TlmLink::new(69, 4, 44, String::from("name"), true, false, true, false, false, false, false).describe(String::from("The name of the Type. Should be unique within a namespace.")), +// TlmLink::new(70, 4, 16, String::from("description"), true, false, false, false, false, true, false).describe(String::from("Friendly human-readable description of the Type.")), +// TlmLink::new(72, 71, 4, String::from("subject"), true, false, true, false, false, false, false).describe(String::from("The object this fact is about.")), +// TlmLink::new(73, 71, 53, String::from("link"), true, false, true, false, false, false, false).describe(String::from("The kind of fact this is, defined by the kind of Link.")), +// TlmLink::new(75, 74, 4, String::from("target"), false, false, true, false, false, false, false).describe(String::from("The target object of this link fact.")), +// TlmLink::new(77, 76, 7, String::from("toggle"), true, false, true, false, true, true, false).describe(String::from("Whether the specific toggle is set or not for this Object.")), +// ]; +} diff --git a/packages/tlm-rust/src/core/schema.rs b/packages/tlm-rust/src/core/schema.rs new file mode 100644 index 0000000..5cf10a6 --- /dev/null +++ b/packages/tlm-rust/src/core/schema.rs @@ -0,0 +1,82 @@ + +pub type TlmOid = i32; // psql serial goes from 1 to 2147483647 + +pub const TLM_TYPE_NAMESPACE: TlmOid = 3; +// const TLM_TYPE_TYPE: TlmOid = 4; +// const TLM_TYPE_LINK: TlmOid = 53; + +pub trait TlmObject : Clone + Eq + Default { + fn oid(&self) -> TlmOid; + fn tlm_type(&self) -> TlmOid; +} + +#[derive(Debug,Clone,Hash,PartialEq,Eq,Default)] +pub struct TlmNamespace { + pub oid: TlmOid, + pub prefix: String, + pub uri: String, + pub description: Option +} + +impl TlmObject for TlmNamespace { + fn oid(&self) -> TlmOid { + self.oid + } + + fn tlm_type(&self) -> TlmOid { + TLM_TYPE_NAMESPACE + } +} + +impl TlmNamespace { + pub fn new(oid: TlmOid, prefix: String, uri: String) -> TlmNamespace { + TlmNamespace { + oid, + prefix, + uri, + ..TlmNamespace::default() + } + } + + pub fn describe(self, description: String) -> TlmNamespace { + TlmNamespace { + description: Some(description), + ..self + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn tlm_namespace() { + let ns = TlmNamespace::default(); + assert_eq!(0, ns.oid()); + assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); + assert_eq!(String::from(""), ns.prefix); + assert_eq!(String::from(""), ns.uri); + + let ns = TlmNamespace::new( + 1, + String::from("foo"), + String::from("https://foo.example.com/")); + assert_eq!(1, ns.oid()); + assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); + assert_eq!("foo", ns.prefix); + assert_eq!("https://foo.example.com/", ns.uri); + assert_eq!(None, ns.description); + + let ns = ns.describe(String::from("A namespace")); + assert_eq!(1, ns.oid()); + assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); + assert_eq!("A namespace", ns.description.as_ref().unwrap()); + + let ns2 = ns.clone(); + assert_eq!(ns.oid, ns2.oid); + assert_eq!(ns.prefix, ns2.prefix); + assert_eq!(ns.uri, ns2.uri); + assert_eq!(ns.description.as_ref(), ns2.description.as_ref()); + } +} diff --git a/packages/tlm-rust/src/lib.rs b/packages/tlm-rust/src/lib.rs index d978812..af56ee5 100644 --- a/packages/tlm-rust/src/lib.rs +++ b/packages/tlm-rust/src/lib.rs @@ -1,81 +1,5 @@ -type TlmOid = i32; // psql serial goes from 1 to 2147483647 +mod core; +mod modeler; -const TLM_TYPE_NAMESPACE: TlmOid = 3; -// const TLM_TYPE_TYPE: TlmOid = 4; -// const TLM_TYPE_LINK: TlmOid = 53; - -pub trait TlmObject : Clone + Eq + Default { - fn oid(&self) -> TlmOid; - fn tlm_type(&self) -> TlmOid; -} - -#[derive(Debug,Clone,Hash,PartialEq,Eq,Default)] -pub struct TlmNamespace { - pub oid: TlmOid, - pub prefix: String, - pub uri: String, - pub description: Option -} - -impl TlmObject for TlmNamespace { - fn oid(&self) -> TlmOid { - self.oid - } - - fn tlm_type(&self) -> TlmOid { - TLM_TYPE_NAMESPACE - } -} - -impl TlmNamespace { - pub fn new(oid: TlmOid, prefix: String, uri: String) -> TlmNamespace { - TlmNamespace { - oid, - prefix, - uri, - ..TlmNamespace::default() - } - } - - pub fn describe(self, description: String) -> TlmNamespace { - TlmNamespace { - description: Some(description), - ..self - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn tlm_namespace() { - let ns = TlmNamespace::default(); - assert_eq!(0, ns.oid()); - assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); - assert_eq!(String::from(""), ns.prefix); - assert_eq!(String::from(""), ns.uri); - - let ns = TlmNamespace::new( - 1, - String::from("foo"), - String::from("https://foo.example.com/")); - assert_eq!(1, ns.oid()); - assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); - assert_eq!("foo", ns.prefix); - assert_eq!("https://foo.example.com/", ns.uri); - assert_eq!(None, ns.description); - - let ns = ns.describe(String::from("A namespace")); - assert_eq!(1, ns.oid()); - assert_eq!(TLM_TYPE_NAMESPACE, ns.tlm_type()); - assert_eq!("A namespace", ns.description.as_ref().unwrap()); - - let ns2 = ns.clone(); - assert_eq!(ns.oid, ns2.oid); - assert_eq!(ns.prefix, ns2.prefix); - assert_eq!(ns.uri, ns2.uri); - assert_eq!(ns.description.as_ref(), ns2.description.as_ref()); - } -} +pub use core::*; +pub use modeler::*; diff --git a/packages/tlm-rust/src/modeler.rs b/packages/tlm-rust/src/modeler.rs new file mode 100644 index 0000000..8bca7bd --- /dev/null +++ b/packages/tlm-rust/src/modeler.rs @@ -0,0 +1,42 @@ +mod namespace; +pub use namespace::*; + +#[derive(Debug,Clone,Default)] +pub struct Modeler { + pub namespace_model: NamespaceModel, +} + +impl Modeler { + pub fn new() -> Modeler { + Modeler { + namespace_model: NamespaceModel::new() + } + } + + pub fn initialize(&mut self) { + self.namespace_model.initialize(); + } + + pub fn add_namespace(&mut self, prefix: String, uri: String, description: Option) { + self.namespace_model.add_namespace(prefix, uri, description); + } + + pub fn set_active_namespace(&mut self, ns: Option) { + if let Some(ns) = ns { + self.namespace_model.set_active_namespace(ns); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn modeler() { + let mut m = Modeler::new(); + m.add_namespace(String::from("foo"), String::from("https://foo.example.com/"), None); + assert_eq!(1, m.namespace_model.namespaces.len()); + assert_eq!("foo", m.namespace_model.namespaces[0].prefix); + } +} diff --git a/packages/tlm-rust/src/modeler/namespace.rs b/packages/tlm-rust/src/modeler/namespace.rs new file mode 100644 index 0000000..543c43b --- /dev/null +++ b/packages/tlm-rust/src/modeler/namespace.rs @@ -0,0 +1,72 @@ +use crate::{TlmNamespace, TLM_CORE_NAMESPACES}; + +#[derive(Debug,Clone,Default)] +pub struct NamespaceModel { + pub(crate) namespaces: Vec, + pub(crate) active_namespace: Option +} + +impl NamespaceModel { + pub fn new() -> NamespaceModel { + NamespaceModel { + namespaces: Vec::new(), + active_namespace: None + } + } + + pub fn initialize(&mut self) { + self.namespaces.extend_from_slice(TLM_CORE_NAMESPACES.as_slice()); + } + + pub fn add_namespace(&mut self, prefix: String, uri: String, description: Option) { + // todo check for duplicates + + let mut ns = TlmNamespace::new( + 1, // fixme use oid generator + prefix, + uri); + if let Some(description) = description { + ns = ns.describe(description); + } + self.namespaces.push(ns) + } + + pub(crate) fn set_active_namespace(&mut self, ns: String) { + // todo check if namespace exists + + self.active_namespace = Some(ns); + } +} + +// tests for NamespaceModel +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_add_namespace() { + let mut m = NamespaceModel::new(); + m.add_namespace(String::from("foo"), String::from("https://foo.example.com/"), None); + assert_eq!(1, m.namespaces.len()); + assert_eq!("foo", m.namespaces[0].prefix); + + m.add_namespace(String::from("bar"), String::from("file:///bar.example.com/"), None); + assert_eq!(2, m.namespaces.len()); + } + + #[test] + fn test_initialize() { + let mut m = NamespaceModel::new(); + m.initialize(); + assert_eq!(TLM_CORE_NAMESPACES.len(), m.namespaces.len()); + assert_eq!("tlm", m.namespaces[0].prefix); + } + + #[test] + fn test_set_active_namespace() { + let mut m = NamespaceModel::new(); + m.add_namespace(String::from("foo"), String::from("https://foo.example.com/"), None); + m.set_active_namespace(String::from("foo")); + assert_eq!(Some("foo".to_string()), m.active_namespace); + } +} diff --git a/packages/tlm-tests-rust/Cargo.toml b/packages/tlm-tests-rust/Cargo.toml new file mode 100644 index 0000000..6f43c7e --- /dev/null +++ b/packages/tlm-tests-rust/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "tlm-tests-rust" +version = "0.1.0" +edition = "2021" + +[dependencies] +tlm = { path = "../tlm-rust" } + +[dev-dependencies] +cucumber = { version = "0.21", features = ["libtest"] } +futures = "0.3" + +[[test]] +name = "cucumber" +harness = false diff --git a/packages/tlm-tests-rust/tests/cucumber.rs b/packages/tlm-tests-rust/tests/cucumber.rs new file mode 100644 index 0000000..28a0b2e --- /dev/null +++ b/packages/tlm-tests-rust/tests/cucumber.rs @@ -0,0 +1,40 @@ +use cucumber::{given, writer, World as _}; + +#[derive(Clone, Debug, Default, cucumber::World)] +#[world(init = Self::new)] +pub struct World { + modeler: tlm::Modeler, +} + +impl World { + fn new() -> World { + World { + modeler: tlm::Modeler::new() + } + } +} + +#[given(regex = "^an empty type-link model is set up$")] +fn given_empty_model(world: &mut World) { + world.modeler.initialize(); +} + +#[given(regex = "^the namespace ([^ ]+) exists with uri ([^ ]+)$")] +fn given_namespace(world: &mut World, ns: String, uri: String) { + world.modeler.add_namespace(ns, uri, None); +} + +#[given(regex = "^the namespace ([^ ]+) is the active namespace$")] +fn given_active_namespace(world: &mut World, ns: String) { + world.modeler.set_active_namespace(Some(ns)); +} + +fn main() { + futures::executor::block_on( + World::cucumber() + .with_writer(writer::Libtest::or_basic()) + .run( + "../tlm-tests/features", + ) + ); +}