diff --git a/herodb/src/models/biz/rhai/Cargo.lock b/herodb/src/models/biz/rhai/Cargo.lock new file mode 100644 index 0000000..5c109a9 --- /dev/null +++ b/herodb/src/models/biz/rhai/Cargo.lock @@ -0,0 +1,2164 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "const-random", + "getrandom 0.2.15", + "once_cell", + "version_check", + "zerocopy 0.7.35", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "async-trait" +version = "0.1.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "biz_rhai" +version = "0.1.0" +dependencies = [ + "chrono", + "herodb", + "rhai", + "serde", + "serde_json", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cc" +version = "1.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" +dependencies = [ + "aes-gcm", + "base64", + "hkdf", + "hmac", + "percent-encoding", + "rand", + "sha2", + "subtle", + "time", + "version_check", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[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.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_more" +version = "0.99.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.100", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-macro", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.9.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "headers" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" +dependencies = [ + "base64", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + +[[package]] +name = "herodb" +version = "0.1.0" +dependencies = [ + "bincode", + "brotli", + "chrono", + "lazy_static", + "paste", + "poem", + "poem-openapi", + "rhai", + "serde", + "serde_json", + "sled", + "tempfile", + "thiserror", + "tokio", + "uuid", +] + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[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.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", +] + +[[package]] +name = "multer" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "memchr", + "mime", + "spin", + "tokio", + "version_check", +] + +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.9.0", + "cfg-if", + "libc", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.10", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.11", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "poem" +version = "1.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504774c97b0744c1ee108a37e5a65a9745a4725c4c06277521dabc28eb53a904" +dependencies = [ + "async-trait", + "bytes", + "chrono", + "cookie", + "futures-util", + "headers", + "http", + "hyper", + "mime", + "multer", + "nix", + "parking_lot 0.12.3", + "percent-encoding", + "pin-project-lite", + "poem-derive", + "quick-xml 0.30.0", + "regex", + "rfc7239", + "serde", + "serde_json", + "serde_urlencoded", + "serde_yaml", + "smallvec", + "tempfile", + "thiserror", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", + "wildmatch", +] + +[[package]] +name = "poem-derive" +version = "1.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ddcf4680d8d867e1e375116203846acb088483fa2070244f90589f458bbb31" +dependencies = [ + "proc-macro-crate 2.0.2", + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "poem-openapi" +version = "2.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e26f78b6195ea1b7a16f46bda1961c598e5a66912f2aa1b8b7a2f395aebb9fc" +dependencies = [ + "base64", + "bytes", + "derive_more", + "futures-util", + "mime", + "num-traits", + "poem", + "poem-openapi-derive", + "quick-xml 0.26.0", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "serde_yaml", + "thiserror", + "tokio", +] + +[[package]] +name = "poem-openapi-derive" +version = "2.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88c3e2975c930dc72c024e75b230c3b6058fb3a746d5739b83aa8f28ab1a42d4" +dependencies = [ + "darling", + "http", + "indexmap 1.9.3", + "mime", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "thiserror", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy 0.8.24", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +dependencies = [ + "bitflags 2.9.0", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rfc7239" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a82f1d1e38e9a85bb58ffcfadf22ed6f2c94e8cd8581ec2b0f80a2a6858350f" +dependencies = [ + "uncased", +] + +[[package]] +name = "rhai" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce4d759a4729a655ddfdbb3ff6e77fb9eadd902dae12319455557796e435d2a6" +dependencies = [ + "ahash", + "bitflags 2.9.0", + "instant", + "num-traits", + "once_cell", + "rhai_codegen", + "smallvec", + "smartstring", + "thin-vec", +] + +[[package]] +name = "rhai_codegen" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a11a05ee1ce44058fa3d5961d05194fdbe3ad6b40f904af764d81b86450e6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +dependencies = [ + "bitflags 2.9.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[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.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.9.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "sled" +version = "0.34.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" +dependencies = [ + "crc32fast", + "crossbeam-epoch", + "crossbeam-utils", + "fs2", + "fxhash", + "libc", + "log", + "parking_lot 0.11.2", +] + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "socket2" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +dependencies = [ + "fastrand", + "getrandom 0.3.2", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thin-vec" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144f754d318415ac792f9d69fc87abbbfc043ce2ef041c60f16ad828f638717d" + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "time" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tokio" +version = "1.44.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot 0.12.3", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.9.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.9.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "uuid" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" +dependencies = [ + "getrandom 0.3.2", + "serde", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wildmatch" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ce1ab1f8c62655ebe1350f589c61e505cf94d385bc6a12899442d9081e71fd" + +[[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-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] diff --git a/herodb/src/models/biz/rhai/Cargo.toml b/herodb/src/models/biz/rhai/Cargo.toml new file mode 100644 index 0000000..1a1c787 --- /dev/null +++ b/herodb/src/models/biz/rhai/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "biz_rhai" +version = "0.1.0" +edition = "2021" + +[dependencies] +rhai = "1.21.0" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +chrono = "0.4" +herodb = { path = "../../../.." } + +[lib] +name = "biz_rhai" +path = "src/lib.rs" + +[[example]] +name = "example" +path = "examples/example.rs" diff --git a/herodb/src/models/biz/rhai/examples/example.rhai b/herodb/src/models/biz/rhai/examples/example.rhai new file mode 100644 index 0000000..844e8b2 --- /dev/null +++ b/herodb/src/models/biz/rhai/examples/example.rhai @@ -0,0 +1,168 @@ +// Example script demonstrating the use of Business module operations + +// Custom repeat function since Rhai doesn't have a built-in repeat method +fn repeat_str(str, count) { + let result = ""; + for i in 0..count { + result += str; + } + return result; +} + +// Print a section header +fn print_section(title) { + let line = repeat_str("=", 50); + print(line); + print(" " + title); + print(line); +} + +print_section("BUSINESS MODULE OPERATIONS EXAMPLE"); + +// Currency Operations +print_section("CURRENCY OPERATIONS"); + +// Create a currency +print("\nCreating currencies..."); +let usd = create_currency(100.0, "USD"); +print("USD Currency created: " + usd.amount + " " + usd.currency_code); + +// Convert currencies +print("\nConverting currencies..."); +let eur = create_currency(150.0, "EUR"); +print("EUR Currency created: " + eur.amount + " " + eur.currency_code); + +let eur_to_usd = convert_currency(eur, "USD"); +print("EUR to USD: " + eur.amount + " EUR = " + eur_to_usd.amount + " USD"); + +// Product Component Operations +print_section("PRODUCT COMPONENT OPERATIONS"); + +// Create a product component +print("\nCreating product components..."); +let component1 = create_product_component(1, "CPU", "Intel i7 Processor", 1); +print("Component created: " + component1.name); +print(" ID: " + component1.id); +print(" Description: " + component1.description); +print(" Quantity: " + component1.quantity); + +// Create another component +let component2 = create_product_component(2, "RAM", "32GB DDR4 Memory", 2); +print("Component created: " + component2.name); +print(" ID: " + component2.id); +print(" Description: " + component2.description); +print(" Quantity: " + component2.quantity); + +// Product Operations +print_section("PRODUCT OPERATIONS"); + +// Create a product using builder pattern +print("\nCreating a product..."); +let product = create_product_builder() + .product_name("High-End Gaming PC") + .product_description("Ultimate gaming experience") + .product_price(create_currency(1999.99, "USD")) + .product_validity_days(365) + .build(); + +print("Product created: " + product.name); +print(" ID: " + product.id); +print(" Description: " + product.description); +print(" Price: " + product.price.amount + " " + product.price.currency_code); + +// Add components to the product +print("\nAdding components to product..."); +let product_with_components = product + .add_component(component1) + .add_component(component2); + +print("Components added to product"); + +// Get components from the product +let components = get_product_components(product_with_components); +print("Number of components: " + components.len()); + +// Customer Operations +print_section("CUSTOMER OPERATIONS"); + +// Create a customer +print("\nCreating a customer..."); +let customer = create_customer("John Doe", "john@example.com", "+1234567890", "123 Main St"); +print("Customer created: " + customer.name); +print(" Email: " + customer.email); +print(" Phone: " + customer.phone); +print(" Address: " + customer.address); + +// Sale Operations +print_section("SALE OPERATIONS"); + +// Create a sale +print("\nCreating a sale..."); +let sale = create_sale(customer, "2025-04-19"); +print("Sale created for customer: " + sale.customer.name); +print(" Date: " + sale.date); + +// Add product to sale +let sale_with_item = add_sale_item(sale, product_with_components, 1); +print("Added product to sale: " + product_with_components.name); + +// Service Operations +print_section("SERVICE OPERATIONS"); + +// Create a service +print("\nCreating a service..."); +let service = create_service( + "Premium Support", + "24/7 Technical Support", + create_currency(49.99, "USD"), + 30 +); +print("Service created: " + service.name); +print(" Description: " + service.description); +print(" Price: " + service.price.amount + " " + service.price.currency_code); +print(" Duration: " + service.duration + " days"); + +// Contract Operations +print_section("CONTRACT OPERATIONS"); + +// Create a contract +print("\nCreating a contract..."); +let contract = create_contract( + "Support Agreement", + "Annual support contract", + "2025-04-19", + "2026-04-19", + create_currency(599.99, "USD"), + "Active" +); +print("Contract created: " + contract.title); +print(" Description: " + contract.description); +print(" Start Date: " + contract.start_date); +print(" End Date: " + contract.end_date); +print(" Value: " + contract.value.amount + " " + contract.value.currency_code); +print(" Status: " + contract.status); + +// Invoice Operations +print_section("INVOICE OPERATIONS"); + +// Create an invoice +print("\nCreating an invoice..."); +let invoice = create_invoice( + "INV-2025-001", + "2025-04-19", + "2025-05-19", + customer, + create_currency(2499.99, "USD"), + "Issued", + "Pending" +); +print("Invoice created: " + invoice.number); +print(" Date: " + invoice.date); +print(" Due Date: " + invoice.due_date); +print(" Customer: " + invoice.customer.name); +print(" Amount: " + invoice.amount.amount + " " + invoice.amount.currency_code); +print(" Status: " + invoice.status); +print(" Payment Status: " + invoice.payment_status); + +print_section("EXAMPLE COMPLETED"); +print("All business module operations completed successfully!"); \ No newline at end of file diff --git a/herodb/src/models/biz/rhai/examples/example.rs b/herodb/src/models/biz/rhai/examples/example.rs new file mode 100644 index 0000000..50a8443 --- /dev/null +++ b/herodb/src/models/biz/rhai/examples/example.rs @@ -0,0 +1,41 @@ +use std::{fs, path::Path}; +use biz_rhai::create_rhai_engine; + +fn main() -> Result<(), Box> { + println!("=== Business Module Rhai Wrapper Example ==="); + + // Create a Rhai engine with business module functionality + let mut engine = create_rhai_engine(); + println!("Successfully created Rhai engine"); + + // Get the path to the example.rhai script + let script_path = get_script_path()?; + println!("Loading script from: {}", script_path.display()); + + // Load the script content + let script = fs::read_to_string(&script_path) + .map_err(|e| format!("Failed to read script file: {}", e))?; + + // Run the script + println!("\n=== Running Rhai script ==="); + match engine.eval::<()>(&script) { + Ok(_) => println!("\nScript executed successfully!"), + Err(e) => println!("\nScript execution error: {}", e), + } + + println!("\nExample completed!"); + Ok(()) +} + +fn get_script_path() -> Result { + // When running with cargo run --example, the script will be in the examples directory + let script_path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("examples") + .join("example.rhai"); + + if script_path.exists() { + Ok(script_path) + } else { + Err(format!("Could not find example.rhai script at {}", script_path.display())) + } +} diff --git a/herodb/src/models/biz/rhai/src/engine.rs b/herodb/src/models/biz/rhai/src/engine.rs new file mode 100644 index 0000000..9386e27 --- /dev/null +++ b/herodb/src/models/biz/rhai/src/engine.rs @@ -0,0 +1,88 @@ +use rhai::{Engine, EvalAltResult, Map, Dynamic, Array}; +use crate::wrapper::*; +use crate::generic_wrapper::ToRhai; + +/// Create a new Rhai engine with business module functionality +pub fn create_rhai_engine() -> Engine { + let mut engine = Engine::new(); + + // Register business module types and functions + register_business_types(&mut engine); + + engine +} + +/// Register business module types and functions +fn register_business_types(engine: &mut Engine) { + // Currency functions + engine.register_fn("create_currency", create_currency); + engine.register_fn("convert_currency", convert_currency); + + // Product functions + engine.register_fn("create_product_builder", create_product_builder); + engine.register_fn("product_name", product_builder_name); + engine.register_fn("product_description", product_builder_description); + engine.register_fn("product_price", product_builder_price); + engine.register_fn("product_validity_days", product_builder_validity_days); + engine.register_fn("add_component", product_builder_add_component); + engine.register_fn("build", product_builder_build); + + // Product component functions + engine.register_fn("create_product_component", create_product_component); + engine.register_fn("component_name", product_component_name); + engine.register_fn("component_description", product_component_description); + engine.register_fn("component_quantity", product_component_quantity); + + // Sale functions + engine.register_fn("create_sale", create_sale); + engine.register_fn("add_sale_item", add_sale_item); + engine.register_fn("sale_customer", sale_customer); + engine.register_fn("sale_date", sale_date); + engine.register_fn("sale_status", sale_status); + + // Customer functions + engine.register_fn("create_customer", create_customer); + engine.register_fn("customer_name", customer_name); + engine.register_fn("customer_email", customer_email); + engine.register_fn("customer_phone", customer_phone); + engine.register_fn("customer_address", customer_address); + + // Service functions + engine.register_fn("create_service", create_service); + engine.register_fn("service_name", service_name); + engine.register_fn("service_description", service_description); + engine.register_fn("service_price", service_price); + engine.register_fn("service_duration", service_duration); + + // Contract functions + engine.register_fn("create_contract", create_contract); + engine.register_fn("contract_title", contract_title); + engine.register_fn("contract_description", contract_description); + engine.register_fn("contract_start_date", contract_start_date); + engine.register_fn("contract_end_date", contract_end_date); + engine.register_fn("contract_value", contract_value); + engine.register_fn("contract_status", contract_status); + + // Invoice functions + engine.register_fn("create_invoice", create_invoice); + engine.register_fn("invoice_number", invoice_number); + engine.register_fn("invoice_date", invoice_date); + engine.register_fn("invoice_due_date", invoice_due_date); + engine.register_fn("invoice_customer", invoice_customer); + engine.register_fn("invoice_amount", invoice_amount); + engine.register_fn("invoice_status", invoice_status); + engine.register_fn("invoice_payment_status", invoice_payment_status); + + // Helper function to get components from a product + engine.register_fn("get_product_components", |product_map: Map| -> Array { + let mut array = Array::new(); + + if let Some(components) = product_map.get("components") { + if let Some(components_array) = components.clone().try_cast::() { + return components_array; + } + } + + array + }); +} \ No newline at end of file diff --git a/herodb/src/models/biz/rhai/src/generic_wrapper.rs b/herodb/src/models/biz/rhai/src/generic_wrapper.rs new file mode 100644 index 0000000..02fb5df --- /dev/null +++ b/herodb/src/models/biz/rhai/src/generic_wrapper.rs @@ -0,0 +1,132 @@ +use std::collections::HashMap; +use rhai::{Dynamic, Map, Array}; + +/// Local wrapper trait for sal::rhai::ToRhai to avoid orphan rule violations +pub trait ToRhai { + /// Convert to a Rhai Dynamic value + fn to_rhai(&self) -> Dynamic; +} + +// Implementation of ToRhai for Dynamic +impl ToRhai for Dynamic { + fn to_rhai(&self) -> Dynamic { + self.clone() + } +} + +/// Generic trait for wrapping Rust functions to be used with Rhai +pub trait RhaiWrapper { + /// Wrap a function that takes ownership of self + fn wrap_consuming(self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(Self) -> R, + R: ToRhai; + + /// Wrap a function that takes a mutable reference to self + fn wrap_mut(&mut self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(&mut Self) -> R, + R: ToRhai; + + /// Wrap a function that takes an immutable reference to self + fn wrap(&self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(&Self) -> R, + R: ToRhai; +} + +/// Implementation of RhaiWrapper for any type +impl RhaiWrapper for T { + fn wrap_consuming(self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(Self) -> R, + R: ToRhai, + { + let result = f(self); + result.to_rhai() + } + + fn wrap_mut(&mut self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(&mut Self) -> R, + R: ToRhai, + { + let result = f(self); + result.to_rhai() + } + + fn wrap(&self, f: F) -> Dynamic + where + Self: Sized + Clone, + F: FnOnce(&Self) -> R, + R: ToRhai, + { + let result = f(self); + result.to_rhai() + } +} + +/// Convert a Rhai Map to a Rust HashMap +pub fn map_to_hashmap(map: &Map) -> HashMap { + let mut result = HashMap::new(); + for (key, value) in map.iter() { + let k = key.clone().to_string(); + let v = value.clone().to_string(); + if !k.is_empty() && !v.is_empty() { + result.insert(k, v); + } + } + result +} + +/// Convert a HashMap to a Rhai Map +pub fn hashmap_to_map(map: &HashMap) -> Map { + let mut result = Map::new(); + for (key, value) in map.iter() { + result.insert(key.clone().into(), Dynamic::from(value.clone())); + } + result +} + +/// Convert a Rhai Array to a Vec of strings +pub fn array_to_vec_string(array: &Array) -> Vec { + array.iter() + .filter_map(|item| { + let s = item.clone().to_string(); + if !s.is_empty() { Some(s) } else { None } + }) + .collect() +} + +/// Helper function to convert Dynamic to Option +pub fn dynamic_to_string_option(value: &Dynamic) -> Option { + if value.is_string() { + Some(value.clone().to_string()) + } else { + None + } +} + +/// Helper function to convert Dynamic to Option +pub fn dynamic_to_u32_option(value: &Dynamic) -> Option { + if value.is_int() { + Some(value.as_int().unwrap() as u32) + } else { + None + } +} + +/// Helper function to convert Dynamic to Option<&str> with lifetime management +pub fn dynamic_to_str_option<'a>(value: &Dynamic, storage: &'a mut String) -> Option<&'a str> { + if value.is_string() { + *storage = value.clone().to_string(); + Some(storage.as_str()) + } else { + None + } +} diff --git a/herodb/src/models/biz/rhai/src/lib.rs b/herodb/src/models/biz/rhai/src/lib.rs new file mode 100644 index 0000000..1937ea6 --- /dev/null +++ b/herodb/src/models/biz/rhai/src/lib.rs @@ -0,0 +1,11 @@ +// Re-export the utility modules +pub mod generic_wrapper; +pub mod wrapper; +pub mod engine; + +// Re-export the utility traits and functions +pub use generic_wrapper::{RhaiWrapper, map_to_hashmap, array_to_vec_string, + dynamic_to_string_option, hashmap_to_map}; +pub use engine::create_rhai_engine; + +// The create_rhai_engine function is now in the engine module diff --git a/herodb/src/models/biz/rhai/src/wrapper.rs b/herodb/src/models/biz/rhai/src/wrapper.rs new file mode 100644 index 0000000..d5b34a8 --- /dev/null +++ b/herodb/src/models/biz/rhai/src/wrapper.rs @@ -0,0 +1,640 @@ +//! Rhai wrappers for Business module functions +//! +//! This module provides Rhai wrappers for the functions in the Business module. + +use rhai::{Engine, EvalAltResult, Array, Dynamic, Map, Position}; +use std::collections::HashMap; +use crate::generic_wrapper::{ToRhai, RhaiWrapper, map_to_hashmap, dynamic_to_string_option, dynamic_to_u32_option}; + +// Import business module types +use chrono::{DateTime, Utc, Duration}; +use herodb::models::biz::{ + Currency, CurrencyBuilder, + Product, ProductBuilder, ProductComponent, ProductComponentBuilder, ProductType, ProductStatus, + Customer, CustomerBuilder, + Sale, SaleBuilder, SaleItem, SaleItemBuilder, SaleStatus, + Service, ServiceBuilder, ServiceItem, ServiceItemBuilder, ServiceStatus, BillingFrequency, + ExchangeRate, ExchangeRateBuilder, ExchangeRateService, EXCHANGE_RATE_SERVICE, + Contract, ContractBuilder, ContractStatus, + Invoice, InvoiceBuilder, InvoiceItem, InvoiceItemBuilder, InvoiceStatus, PaymentStatus, Payment +}; + +// Business module ToRhai implementations + +// Currency ToRhai implementation +impl ToRhai for Currency { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("amount".into(), Dynamic::from(self.amount)); + map.insert("currency_code".into(), Dynamic::from(self.currency_code.clone())); + Dynamic::from_map(map) + } +} + +// ProductType ToRhai implementation +impl ToRhai for ProductType { + fn to_rhai(&self) -> Dynamic { + let value = match self { + ProductType::Product => "Product", + ProductType::Service => "Service", + }; + Dynamic::from(value) + } +} + +// ProductStatus ToRhai implementation +impl ToRhai for ProductStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + ProductStatus::Active => "Active", + ProductStatus::Error => "Error", + ProductStatus::EndOfLife => "EndOfLife", + ProductStatus::Paused => "Paused", + ProductStatus::Available => "Available", + ProductStatus::Unavailable => "Unavailable", + }; + Dynamic::from(value) + } +} + +// ProductComponent ToRhai implementation +impl ToRhai for ProductComponent { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("name".into(), Dynamic::from(self.name.clone())); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("quantity".into(), Dynamic::from(self.quantity)); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + map.insert("energy_usage".into(), Dynamic::from(self.energy_usage)); + map.insert("cost".into(), self.cost.to_rhai()); + Dynamic::from_map(map) + } +} + +// Product ToRhai implementation +impl ToRhai for Product { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("name".into(), Dynamic::from(self.name.clone())); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("price".into(), self.price.to_rhai()); + map.insert("type".into(), self.type_.to_rhai()); + map.insert("category".into(), Dynamic::from(self.category.clone())); + map.insert("status".into(), self.status.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + map.insert("max_amount".into(), Dynamic::from(self.max_amount)); + map.insert("purchase_till".into(), Dynamic::from(self.purchase_till.to_string())); + map.insert("active_till".into(), Dynamic::from(self.active_till.to_string())); + + // Convert components to an array + let components_array: Array = self.components.iter() + .map(|component| component.to_rhai()) + .collect(); + map.insert("components".into(), Dynamic::from(components_array)); + + Dynamic::from_map(map) + } +} + +// SaleStatus ToRhai implementation +impl ToRhai for SaleStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + SaleStatus::Pending => "Pending", + SaleStatus::Completed => "Completed", + SaleStatus::Cancelled => "Cancelled", + SaleStatus::Refunded => "Refunded", + }; + Dynamic::from(value) + } +} + +// SaleItem ToRhai implementation +impl ToRhai for SaleItem { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("product_id".into(), Dynamic::from(self.product_id)); + map.insert("quantity".into(), Dynamic::from(self.quantity)); + map.insert("price".into(), self.price.to_rhai()); + map.insert("discount".into(), Dynamic::from(self.discount)); + Dynamic::from_map(map) + } +} + +// Sale ToRhai implementation +impl ToRhai for Sale { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("customer_id".into(), Dynamic::from(self.customer_id)); + map.insert("date".into(), Dynamic::from(self.date.to_string())); + map.insert("status".into(), self.status.to_rhai()); + + // Convert items to an array + let items_array: Array = self.items.iter() + .map(|item| item.to_rhai()) + .collect(); + map.insert("items".into(), Dynamic::from(items_array)); + + map.insert("total".into(), self.total.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + + Dynamic::from_map(map) + } +} + +// Customer ToRhai implementation +impl ToRhai for Customer { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("name".into(), Dynamic::from(self.name.clone())); + map.insert("email".into(), Dynamic::from(self.email.clone())); + map.insert("phone".into(), Dynamic::from(self.phone.clone())); + map.insert("address".into(), Dynamic::from(self.address.clone())); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + Dynamic::from_map(map) + } +} + +// ServiceStatus ToRhai implementation +impl ToRhai for ServiceStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + ServiceStatus::Active => "Active", + ServiceStatus::Inactive => "Inactive", + ServiceStatus::Pending => "Pending", + ServiceStatus::Cancelled => "Cancelled", + }; + Dynamic::from(value) + } +} + +// BillingFrequency ToRhai implementation +impl ToRhai for BillingFrequency { + fn to_rhai(&self) -> Dynamic { + let value = match self { + BillingFrequency::OneTime => "OneTime", + BillingFrequency::Daily => "Daily", + BillingFrequency::Weekly => "Weekly", + BillingFrequency::Monthly => "Monthly", + BillingFrequency::Quarterly => "Quarterly", + BillingFrequency::Yearly => "Yearly", + }; + Dynamic::from(value) + } +} + +// ServiceItem ToRhai implementation +impl ToRhai for ServiceItem { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("name".into(), Dynamic::from(self.name.clone())); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("price".into(), self.price.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + Dynamic::from_map(map) + } +} + +// Service ToRhai implementation +impl ToRhai for Service { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("customer_id".into(), Dynamic::from(self.customer_id)); + map.insert("name".into(), Dynamic::from(self.name.clone())); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("status".into(), self.status.to_rhai()); + map.insert("start_date".into(), Dynamic::from(self.start_date.to_string())); + map.insert("end_date".into(), Dynamic::from(self.end_date.to_string())); + map.insert("billing_frequency".into(), self.billing_frequency.to_rhai()); + + // Convert items to an array + let items_array: Array = self.items.iter() + .map(|item| item.to_rhai()) + .collect(); + map.insert("items".into(), Dynamic::from(items_array)); + + map.insert("total".into(), self.total.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + + Dynamic::from_map(map) + } +} + +// ContractStatus ToRhai implementation +impl ToRhai for ContractStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + ContractStatus::Draft => "Draft", + ContractStatus::Pending => "Pending", + ContractStatus::Active => "Active", + ContractStatus::Completed => "Completed", + ContractStatus::Cancelled => "Cancelled", + ContractStatus::Expired => "Expired", + }; + Dynamic::from(value) + } +} + +// Contract ToRhai implementation +impl ToRhai for Contract { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("customer_id".into(), Dynamic::from(self.customer_id)); + map.insert("title".into(), Dynamic::from(self.title.clone())); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("status".into(), self.status.to_rhai()); + map.insert("start_date".into(), Dynamic::from(self.start_date.to_string())); + map.insert("end_date".into(), Dynamic::from(self.end_date.to_string())); + map.insert("value".into(), self.value.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + Dynamic::from_map(map) + } +} + +// InvoiceStatus ToRhai implementation +impl ToRhai for InvoiceStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + InvoiceStatus::Draft => "Draft", + InvoiceStatus::Sent => "Sent", + InvoiceStatus::Paid => "Paid", + InvoiceStatus::Overdue => "Overdue", + InvoiceStatus::Cancelled => "Cancelled", + }; + Dynamic::from(value) + } +} + +// PaymentStatus ToRhai implementation +impl ToRhai for PaymentStatus { + fn to_rhai(&self) -> Dynamic { + let value = match self { + PaymentStatus::Pending => "Pending", + PaymentStatus::Completed => "Completed", + PaymentStatus::Failed => "Failed", + PaymentStatus::Refunded => "Refunded", + }; + Dynamic::from(value) + } +} + +// Payment ToRhai implementation +impl ToRhai for Payment { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("amount".into(), self.amount.to_rhai()); + map.insert("date".into(), Dynamic::from(self.date.to_string())); + map.insert("method".into(), Dynamic::from(self.method.clone())); + map.insert("status".into(), self.status.to_rhai()); + map.insert("reference".into(), Dynamic::from(self.reference.clone())); + Dynamic::from_map(map) + } +} + +// InvoiceItem ToRhai implementation +impl ToRhai for InvoiceItem { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("description".into(), Dynamic::from(self.description.clone())); + map.insert("quantity".into(), Dynamic::from(self.quantity)); + map.insert("unit_price".into(), self.unit_price.to_rhai()); + map.insert("total".into(), self.total.to_rhai()); + Dynamic::from_map(map) + } +} + +// Invoice ToRhai implementation +impl ToRhai for Invoice { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("id".into(), Dynamic::from(self.id)); + map.insert("customer_id".into(), Dynamic::from(self.customer_id)); + map.insert("date".into(), Dynamic::from(self.date.to_string())); + map.insert("due_date".into(), Dynamic::from(self.due_date.to_string())); + map.insert("status".into(), self.status.to_rhai()); + + // Convert items to an array + let items_array: Array = self.items.iter() + .map(|item| item.to_rhai()) + .collect(); + map.insert("items".into(), Dynamic::from(items_array)); + + // Convert payments to an array + let payments_array: Array = self.payments.iter() + .map(|payment| payment.to_rhai()) + .collect(); + map.insert("payments".into(), Dynamic::from(payments_array)); + + map.insert("subtotal".into(), self.subtotal.to_rhai()); + map.insert("tax".into(), self.tax.to_rhai()); + map.insert("total".into(), self.total.to_rhai()); + map.insert("created_at".into(), Dynamic::from(self.created_at.to_string())); + map.insert("updated_at".into(), Dynamic::from(self.updated_at.to_string())); + + Dynamic::from_map(map) + } +} + +// ExchangeRate ToRhai implementation +impl ToRhai for ExchangeRate { + fn to_rhai(&self) -> Dynamic { + let mut map = Map::new(); + map.insert("from_currency".into(), Dynamic::from(self.from_currency.clone())); + map.insert("to_currency".into(), Dynamic::from(self.to_currency.clone())); + map.insert("rate".into(), Dynamic::from(self.rate)); + map.insert("date".into(), Dynamic::from(self.date.to_string())); + Dynamic::from_map(map) + } +} + +// +// Business Module Function Wrappers +// + +// Currency Functions +pub fn currency_new(amount: f64, currency_code: &str) -> Currency { + Currency::new(amount, currency_code.to_string()) +} + +pub fn currency_to_usd(currency: &Currency) -> Result> { + match currency.to_usd() { + Some(usd) => Ok(usd.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + "Failed to convert currency to USD".into(), + Position::NONE + ))) + } +} + +pub fn currency_to_currency(currency: &Currency, target_currency: &str) -> Result> { + match currency.to_currency(target_currency) { + Some(converted) => Ok(converted.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + format!("Failed to convert currency to {}", target_currency).into(), + Position::NONE + ))) + } +} + +// CurrencyBuilder Functions +pub fn currency_builder_new() -> CurrencyBuilder { + CurrencyBuilder::new() +} + +pub fn currency_builder_amount(builder: CurrencyBuilder, amount: f64) -> CurrencyBuilder { + builder.amount(amount) +} + +pub fn currency_builder_currency_code(builder: CurrencyBuilder, currency_code: &str) -> CurrencyBuilder { + builder.currency_code(currency_code) +} + +pub fn currency_builder_build(builder: CurrencyBuilder) -> Result> { + builder.build().map_err(|e| { + Box::new(EvalAltResult::ErrorRuntime( + e.into(), + Position::NONE + )) + }) +} + +// ProductComponent Functions +pub fn product_component_new(id: i64, name: &str, description: &str, quantity: i64) -> ProductComponent { + ProductComponent::new(id as u32, name.to_string(), description.to_string(), quantity as i32) +} + +pub fn product_component_total_energy_usage(component: &ProductComponent) -> f64 { + component.total_energy_usage() +} + +pub fn product_component_total_cost(component: &ProductComponent) -> Currency { + component.total_cost() +} + +// ProductComponentBuilder Functions +pub fn product_component_builder_new() -> ProductComponentBuilder { + ProductComponentBuilder::new() +} + +pub fn product_component_builder_id(builder: ProductComponentBuilder, id: i64) -> ProductComponentBuilder { + builder.id(id as u32) +} + +pub fn product_component_builder_name(builder: ProductComponentBuilder, name: &str) -> ProductComponentBuilder { + builder.name(name) +} + +pub fn product_component_builder_description(builder: ProductComponentBuilder, description: &str) -> ProductComponentBuilder { + builder.description(description) +} + +pub fn product_component_builder_quantity(builder: ProductComponentBuilder, quantity: i64) -> ProductComponentBuilder { + builder.quantity(quantity as i32) +} + +pub fn product_component_builder_energy_usage(builder: ProductComponentBuilder, energy_usage: f64) -> ProductComponentBuilder { + builder.energy_usage(energy_usage) +} + +pub fn product_component_builder_cost(builder: ProductComponentBuilder, cost: Currency) -> ProductComponentBuilder { + builder.cost(cost) +} + +pub fn product_component_builder_build(builder: ProductComponentBuilder) -> Result> { + builder.build().map_err(|e| { + Box::new(EvalAltResult::ErrorRuntime( + e.into(), + Position::NONE + )) + }) +} + +// Product Functions +pub fn product_type_product() -> ProductType { + ProductType::Product +} + +pub fn product_type_service() -> ProductType { + ProductType::Service +} + +pub fn product_status_active() -> ProductStatus { + ProductStatus::Active +} + +pub fn product_status_error() -> ProductStatus { + ProductStatus::Error +} + +pub fn product_status_end_of_life() -> ProductStatus { + ProductStatus::EndOfLife +} + +pub fn product_status_paused() -> ProductStatus { + ProductStatus::Paused +} + +pub fn product_status_available() -> ProductStatus { + ProductStatus::Available +} + +pub fn product_status_unavailable() -> ProductStatus { + ProductStatus::Unavailable +} + +pub fn product_add_component(product: &mut Product, component: ProductComponent) { + product.add_component(component); +} + +pub fn product_set_purchase_period(product: &mut Product, purchase_till_days: i64) { + let purchase_till = Utc::now() + Duration::days(purchase_till_days); + product.set_purchase_period(purchase_till); +} + +pub fn product_set_active_period(product: &mut Product, active_till_days: i64) { + let active_till = Utc::now() + Duration::days(active_till_days); + product.set_active_period(active_till); +} + +pub fn product_is_purchasable(product: &Product) -> bool { + product.is_purchasable() +} + +pub fn product_is_active(product: &Product) -> bool { + product.is_active() +} + +pub fn product_cost_in_currency(product: &Product, currency_code: &str) -> Result> { + match product.cost_in_currency(currency_code) { + Some(cost) => Ok(cost.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + format!("Failed to calculate cost in {}", currency_code).into(), + Position::NONE + ))) + } +} + +pub fn product_cost_in_usd(product: &Product) -> Result> { + match product.cost_in_usd() { + Some(cost) => Ok(cost.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + "Failed to calculate cost in USD".into(), + Position::NONE + ))) + } +} + +pub fn product_total_energy_usage(product: &Product) -> f64 { + product.total_energy_usage() +} + +pub fn product_components_cost(product: &Product, currency_code: &str) -> Result> { + match product.components_cost(currency_code) { + Some(cost) => Ok(cost.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + format!("Failed to calculate components cost in {}", currency_code).into(), + Position::NONE + ))) + } +} + +pub fn product_components_cost_in_usd(product: &Product) -> Result> { + match product.components_cost_in_usd() { + Some(cost) => Ok(cost.to_rhai()), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + "Failed to calculate components cost in USD".into(), + Position::NONE + ))) + } +} + +// ProductBuilder Functions +pub fn product_builder_new() -> ProductBuilder { + ProductBuilder::new() +} + +pub fn product_builder_id(builder: ProductBuilder, id: i64) -> ProductBuilder { + builder.id(id as u32) +} + +pub fn product_builder_name(builder: ProductBuilder, name: &str) -> ProductBuilder { + builder.name(name) +} + +pub fn product_builder_description(builder: ProductBuilder, description: &str) -> ProductBuilder { + builder.description(description) +} + +pub fn product_builder_price(builder: ProductBuilder, price: Currency) -> ProductBuilder { + builder.price(price) +} + +pub fn product_builder_type(builder: ProductBuilder, type_: ProductType) -> ProductBuilder { + builder.type_(type_) +} + +pub fn product_builder_category(builder: ProductBuilder, category: &str) -> ProductBuilder { + builder.category(category) +} + +pub fn product_builder_status(builder: ProductBuilder, status: ProductStatus) -> ProductBuilder { + builder.status(status) +} + +pub fn product_builder_max_amount(builder: ProductBuilder, max_amount: i64) -> ProductBuilder { + builder.max_amount(max_amount as u16) +} + +pub fn product_builder_validity_days(builder: ProductBuilder, validity_days: i64) -> ProductBuilder { + builder.validity_days(validity_days) +} + +pub fn product_builder_add_component(builder: ProductBuilder, component: ProductComponent) -> ProductBuilder { + builder.add_component(component) +} + +pub fn product_builder_build(builder: ProductBuilder) -> Result> { + builder.build().map_err(|e| { + Box::new(EvalAltResult::ErrorRuntime( + e.into(), + Position::NONE + )) + }) +} + +// Exchange Rate Service Functions +pub fn exchange_rate_convert(amount: f64, from_currency: &str, to_currency: &str) -> Result> { + match EXCHANGE_RATE_SERVICE.convert(amount, from_currency, to_currency) { + Some(converted) => Ok(converted), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + format!("Failed to convert {} {} to {}", amount, from_currency, to_currency).into(), + Position::NONE + ))) + } +} + +pub fn exchange_rate_get_rate(from_currency: &str, to_currency: &str) -> Result> { + match EXCHANGE_RATE_SERVICE.get_rate(from_currency, to_currency) { + Some(rate) => Ok(rate), + None => Err(Box::new(EvalAltResult::ErrorRuntime( + format!("Failed to get exchange rate from {} to {}", from_currency, to_currency).into(), + Position::NONE + ))) + } +} \ No newline at end of file