From 0c7d6a9d9a9468f745e1f8cd4047148c7df219b6 Mon Sep 17 00:00:00 2001 From: Emil Sayahi <97276123+emmyoh@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:15:04 -0500 Subject: [PATCH] wip: Embeddings over OkuNet TODO: - Finish embedding-related code - Upgrade dependencies - Build out CLI - Modify function signatures to take references as arguments - Switch from Iroh documents to `iroh-willow` when it releases --- .gitignore | 2 +- Cargo.lock | 2164 ++++++++++++++++- Cargo.toml | 4 +- _rust-toolchain.toml | 2 - rust-toolchain.toml | 2 + src/database/core.rs | 11 +- src/database/posts/core.rs | 196 ++ src/database/posts/mod.rs | 4 + .../{posts.rs => posts/operations.rs} | 205 +- src/database/users.rs | 2 +- src/fs/core.rs | 2 +- src/fs/directory.rs | 3 + src/fs/file.rs | 2 + src/fs/mod.rs | 24 +- src/fs/net/core.rs | 37 + src/fs/net/embeddings.rs | 95 + src/fs/net/mod.rs | 8 + src/fs/net/posts.rs | 272 +++ src/fs/{net.rs => net/users.rs} | 287 +-- src/fs/replica.rs | 1 + src/lib.rs | 3 +- 21 files changed, 2767 insertions(+), 559 deletions(-) delete mode 100644 _rust-toolchain.toml create mode 100644 rust-toolchain.toml create mode 100644 src/database/posts/core.rs create mode 100644 src/database/posts/mod.rs rename src/database/{posts.rs => posts/operations.rs} (53%) create mode 100644 src/fs/net/core.rs create mode 100644 src/fs/net/embeddings.rs create mode 100644 src/fs/net/mod.rs create mode 100644 src/fs/net/posts.rs rename src/fs/{net.rs => net/users.rs} (67%) diff --git a/.gitignore b/.gitignore index afac012..bbd9839 100644 --- a/.gitignore +++ b/.gitignore @@ -103,4 +103,4 @@ target/ target-old/ tree.txt test/ -src/*_old.rs \ No newline at end of file +*_old.rs \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a1a43e3..7f138ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aead" version = "0.5.2" @@ -63,6 +69,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" + [[package]] name = "allocator-api2" version = "0.2.18" @@ -135,9 +147,21 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +dependencies = [ + "backtrace", +] + +[[package]] +name = "arbitrary" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "arc-swap" @@ -145,6 +169,17 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -253,6 +288,29 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62" +dependencies = [ + "arrayvec", +] + [[package]] name = "axum" version = "0.7.9" @@ -366,6 +424,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.22.1" @@ -393,6 +457,51 @@ dependencies = [ "serde", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitcode" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee1bce7608560cd4bf0296a4262d0dbf13e6bcec5ff2105724c8ab88cc7fc784" +dependencies = [ + "arrayvec", + "bitcode_derive", + "bytemuck", + "glam", + "serde", +] + +[[package]] +name = "bitcode_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a539389a13af092cd345a2b47ae7dec12deb306d660b2223d25cd3419b253ebe" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -414,6 +523,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + [[package]] name = "bitvec" version = "1.0.1" @@ -450,6 +565,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "built" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" + [[package]] name = "bumpalo" version = "3.16.0" @@ -462,12 +583,38 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" +[[package]] +name = "bytemuck" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.9.0" @@ -486,6 +633,104 @@ dependencies = [ "serde", ] +[[package]] +name = "candle-core" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1e306c8a4276ba57ce9fac76d823cc8c8a7fca14bf222ac20ad8b12c4273152" +dependencies = [ + "byteorder", + "gemm", + "half", + "memmap2", + "num-traits", + "num_cpus", + "rand", + "rand_distr", + "rayon", + "safetensors", + "thiserror 1.0.68", + "ug", + "yoke", + "zip", +] + +[[package]] +name = "candle-examples" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bdceca3faa253f7140230f8eb9ac05ed0c10c7e33afeb9ee0d7fa6305a5d946" +dependencies = [ + "anyhow", + "candle-core", + "candle-hf-hub", + "candle-nn", + "candle-transformers", + "csv", + "image", + "num-traits", + "rayon", + "safetensors", + "serde", + "serde_json", + "tokenizers", +] + +[[package]] +name = "candle-hf-hub" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca5f45ce8fe55a9e9246a3fc60000d7ed11b88a84d72f753488f7264ce04b102" +dependencies = [ + "dirs", + "futures", + "http 1.1.0", + "indicatif", + "log", + "num_cpus", + "rand", + "reqwest", + "serde", + "serde_json", + "thiserror 1.0.68", + "tokio", + "ureq", +] + +[[package]] +name = "candle-nn" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39d417059c44d719fd03a0f711ccfe148d341469c9273d4b5731ebe965b2c97e" +dependencies = [ + "candle-core", + "half", + "num-traits", + "rayon", + "safetensors", + "serde", + "thiserror 1.0.68", +] + +[[package]] +name = "candle-transformers" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "962a277e90dea20968164175138b836bba8b51b57505579fd628d79933da2b70" +dependencies = [ + "byteorder", + "candle-core", + "candle-nn", + "fancy-regex", + "num-traits", + "rand", + "rayon", + "serde", + "serde_json", + "serde_plain", + "tracing", +] + [[package]] name = "cargo-platform" version = "0.1.8" @@ -531,6 +776,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -620,6 +875,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.2" @@ -645,6 +906,19 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width 0.1.14", + "windows-sys 0.52.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -744,6 +1018,16 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-skiplist" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df29de440c58ca2cc6e587ec3d22347551a32435fbde9d2bff64e78a9ffa151b" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -811,6 +1095,27 @@ dependencies = [ "zeroize", ] +[[package]] +name = "csv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +dependencies = [ + "memchr", +] + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -838,6 +1143,41 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + [[package]] name = "dashmap" version = "6.1.0" @@ -850,6 +1190,7 @@ dependencies = [ "lock_api", "once_cell", "parking_lot_core", + "rayon", ] [[package]] @@ -858,6 +1199,16 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +[[package]] +name = "deflate" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" +dependencies = [ + "adler32", + "byteorder", +] + [[package]] name = "der" version = "0.7.9" @@ -904,6 +1255,48 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_arbitrary" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.87", +] + [[package]] name = "derive_more" version = "1.0.0" @@ -943,6 +1336,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -954,6 +1368,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "distances" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcbf1ea592606d7836c33c1f939ca79fe32e0a45c0f4f65f8a4e4bf0e499ef2" +dependencies = [ + "libm", + "rand", + "serde", +] + [[package]] name = "dlopen2" version = "0.5.0" @@ -965,6 +1390,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "document-features" version = "0.2.10" @@ -974,6 +1405,12 @@ dependencies = [ "litrs", ] +[[package]] +name = "double-ended-peekable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d05e1c0dbad51b52c38bda7adceef61b9efc2baf04acfe8726a8c4630a6f57" + [[package]] name = "downcast-rs" version = "1.2.1" @@ -992,6 +1429,16 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +[[package]] +name = "dyn-stack" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e53799688f5632f364f8fb387488dd05db9fe45db7011be066fc20e7027f8b" +dependencies = [ + "bytemuck", + "reborrow", +] + [[package]] name = "ecdsa" version = "0.16.9" @@ -1069,6 +1516,21 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[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 = "enum-as-inner" version = "0.6.1" @@ -1081,6 +1543,18 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "enum_dispatch" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "enumflags2" version = "0.7.10" @@ -1164,6 +1638,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "esaxx-rs" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6" + [[package]] name = "event-listener" version = "4.0.3" @@ -1196,18 +1676,75 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "exr" +version = "1.73.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "extended" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" + [[package]] name = "fallible-iterator" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" +[[package]] +name = "fallible_collections" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88c69768c0a15262df21899142bc6df9b9b823546d4b4b9a7bc2d6c448ec6fd" +dependencies = [ + "hashbrown 0.13.2", +] + +[[package]] +name = "fancy-regex" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" +dependencies = [ + "bit-set", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + [[package]] name = "fastdivide" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59668941c55e5c186b8b58c391629af56774ec768f73c08bbcd56f09348eb00b" +[[package]] +name = "fastembed" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32ee8c9f4219e3700aa9e201028e1c8206072794cae0b8323c1463f7b93466" +dependencies = [ + "anyhow", + "hf-hub 0.3.2", + "image", + "ndarray", + "ort", + "rayon", + "serde_json", + "tokenizers", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1223,6 +1760,15 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + [[package]] name = "ff" version = "0.13.0" @@ -1239,6 +1785,44 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + +[[package]] +name = "fjall" +version = "2.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cd1bb382d52e527f10f5ed3f126bb4a87c77fbf878a1432010820a71aaa6322" +dependencies = [ + "byteorder", + "dashmap", + "log", + "lsm-tree", + "path-absolutize", + "std-semaphore", + "tempfile", + "xxhash-rust", +] + +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flume" version = "0.11.1" @@ -1263,6 +1847,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1465,6 +2064,124 @@ dependencies = [ "slab", ] +[[package]] +name = "gemm" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab24cc62135b40090e31a76a9b2766a501979f3070fa27f689c27ec04377d32" +dependencies = [ + "dyn-stack", + "gemm-c32", + "gemm-c64", + "gemm-common", + "gemm-f16", + "gemm-f32", + "gemm-f64", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "seq-macro", +] + +[[package]] +name = "gemm-c32" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9c030d0b983d1e34a546b86e08f600c11696fde16199f971cd46c12e67512c0" +dependencies = [ + "dyn-stack", + "gemm-common", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "seq-macro", +] + +[[package]] +name = "gemm-c64" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb5f2e79fefb9693d18e1066a557b4546cd334b226beadc68b11a8f9431852a" +dependencies = [ + "dyn-stack", + "gemm-common", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "seq-macro", +] + +[[package]] +name = "gemm-common" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2e7ea062c987abcd8db95db917b4ffb4ecdfd0668471d8dc54734fdff2354e8" +dependencies = [ + "bytemuck", + "dyn-stack", + "half", + "num-complex", + "num-traits", + "once_cell", + "paste", + "pulp", + "raw-cpuid 10.7.0", + "rayon", + "seq-macro", + "sysctl", +] + +[[package]] +name = "gemm-f16" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca4c06b9b11952071d317604acb332e924e817bd891bec8dfb494168c7cedd4" +dependencies = [ + "dyn-stack", + "gemm-common", + "gemm-f32", + "half", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "rayon", + "seq-macro", +] + +[[package]] +name = "gemm-f32" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9a69f51aaefbd9cf12d18faf273d3e982d9d711f60775645ed5c8047b4ae113" +dependencies = [ + "dyn-stack", + "gemm-common", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "seq-macro", +] + +[[package]] +name = "gemm-f64" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa397a48544fadf0b81ec8741e5c0fba0043008113f71f2034def1935645d2b0" +dependencies = [ + "dyn-stack", + "gemm-common", + "num-complex", + "num-traits", + "paste", + "raw-cpuid 10.7.0", + "seq-macro", +] + [[package]] name = "genawaiter" version = "0.99.1" @@ -1533,12 +2250,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gif" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +[[package]] +name = "glam" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677" + [[package]] name = "glob" version = "0.3.1" @@ -1577,6 +2310,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "guardian" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "493913a18c0d7bebb75127a26a432162c59edbe06f6cf712001e3e769345e8b5" + [[package]] name = "h2" version = "0.4.6" @@ -1596,6 +2335,35 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "bytemuck", + "cfg-if", + "crunchy", + "num-traits", + "rand", + "rand_distr", +] + +[[package]] +name = "hamming-bitwise-fast" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d16627a786f2f40f9079bd54a3c7987df493d421f2a6fecca7dc0886ebc7b9" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -1643,6 +2411,45 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hf-hub" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b780635574b3d92f036890d8373433d6f9fc7abb320ee42a5c25897fc8ed732" +dependencies = [ + "dirs", + "indicatif", + "log", + "native-tls", + "rand", + "serde", + "serde_json", + "thiserror 1.0.68", + "ureq", +] + +[[package]] +name = "hf-hub" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112fa2f6ad4ab815b9e1b938b4b1e437032d055e2f92ed10fd6ab2e62d02c6b6" +dependencies = [ + "dirs", + "futures", + "http 1.1.0", + "indicatif", + "log", + "native-tls", + "num_cpus", + "rand", + "reqwest", + "serde", + "serde_json", + "thiserror 2.0.6", + "tokio", + "ureq", +] + [[package]] name = "hickory-proto" version = "0.24.2" @@ -1767,6 +2574,12 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2" +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + [[package]] name = "htmlescape" version = "0.3.1" @@ -1875,6 +2688,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.9" @@ -2035,6 +2864,12 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -2087,6 +2922,45 @@ dependencies = [ "xmltree", ] +[[package]] +name = "image" +version = "0.25.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "num-traits", + "png 0.17.15", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f" +dependencies = [ + "byteorder-lite", + "quick-error 2.0.1", +] + +[[package]] +name = "imgref" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" + [[package]] name = "indexmap" version = "2.5.0" @@ -2097,6 +2971,28 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "indicatif" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width 0.2.0", + "web-time", +] + +[[package]] +name = "inflate" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" +dependencies = [ + "adler32", +] + [[package]] name = "inout" version = "0.1.3" @@ -2127,6 +3023,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ipconfig" version = "0.3.2" @@ -2154,7 +3061,7 @@ dependencies = [ "anyhow", "axum", "backoff", - "base64", + "base64 0.22.1", "bytes", "der", "derive_more", @@ -2514,7 +3421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28a0d0d7317795a01caa47ffdaeec84211d1b394530bdb31dbe15f642e58bcff" dependencies = [ "anyhow", - "base64", + "base64 0.22.1", "bytes", "clap", "derive_more", @@ -2580,6 +3487,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -2624,6 +3540,12 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" + [[package]] name = "js-sys" version = "0.3.70" @@ -2642,6 +3564,12 @@ dependencies = [ "spin", ] +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + [[package]] name = "levenshtein_automata" version = "0.2.1" @@ -2654,12 +3582,33 @@ version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +[[package]] +name = "libfuzzer-sys" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b9569d2f74e257076d8c6bfa73fb505b46b851e51ddaecc825944aa3bed17fa" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libm" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2713,6 +3662,15 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "lru" version = "0.12.5" @@ -2731,11 +3689,53 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "lsm-tree" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7952bc71e90c0b58ce441dcf6cf8624cac042125dec1183ec9c48144f74378d" +dependencies = [ + "byteorder", + "crossbeam-skiplist", + "double-ended-peekable", + "enum_dispatch", + "guardian", + "log", + "lz4_flex", + "path-absolutize", + "quick_cache", + "rustc-hash 2.0.0", + "self_cell", + "tempfile", + "value-log", + "varint-rs", + "xxhash-rust", +] + [[package]] name = "lz4_flex" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] + +[[package]] +name = "macro_rules_attribute" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a82271f7bc033d84bbca59a3ce3e4159938cb08a9c3aebbe54d215131518a13" +dependencies = [ + "macro_rules_attribute-proc_macro", + "paste", +] + +[[package]] +name = "macro_rules_attribute-proc_macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dd856d451cc0da70e2ef2ce95a18e39a93b7558bedf10201ad28503f918568" [[package]] name = "mainline" @@ -2799,6 +3799,26 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matrixmultiply" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "md5" version = "0.7.0" @@ -2828,6 +3848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", + "stable_deref_trait", ] [[package]] @@ -2847,7 +3868,7 @@ dependencies = [ "terminal_size", "textwrap", "thiserror 1.0.68", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2867,6 +3888,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "min-max-heap" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2687e6cf9c00f48e9284cf9fd15f2ef341d03cc7743abf9df4c5f07fdee50b18" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2880,6 +3907,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -2894,6 +3922,27 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "monostate" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d208407d7552cd041d8cdb69a1bc3303e029c598738177a3d87082004dc0e1e" +dependencies = [ + "monostate-impl", + "serde", +] + +[[package]] +name = "monostate-impl" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ce64b975ed4f123575d11afd9491f2e37bbd5813fbfbc0f09ae1fbddea74e0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "murmurhash32" version = "0.3.1" @@ -2909,6 +3958,23 @@ dependencies = [ "getrandom", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "native_db" version = "0.8.1" @@ -2962,6 +4028,21 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "ndarray" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + [[package]] name = "nested_enum_utils" version = "0.1.0" @@ -3118,6 +4199,12 @@ dependencies = [ "wmi", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nix" version = "0.26.4" @@ -3168,6 +4255,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3178,6 +4271,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -3205,12 +4312,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "bytemuck", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -3231,6 +4359,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -3272,6 +4411,12 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.36.4" @@ -3323,6 +4468,7 @@ dependencies = [ "tokio", "toml", "url", + "zebra", ] [[package]] @@ -3337,18 +4483,108 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "opaque-debug" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ort" +version = "2.0.0-rc.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52afb44b6b0cffa9bf45e4d37e5a4935b0334a51570658e279e9e3e6cf324aa5" +dependencies = [ + "ndarray", + "ort-sys", + "tracing", +] + +[[package]] +name = "ort-sys" +version = "2.0.0-rc.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41d7757331aef2d04b9cb09b45583a59217628beaf91895b7e76187b6e8c088" +dependencies = [ + "flate2", + "pkg-config", + "sha2", + "tar", + "ureq", +] + [[package]] name = "overload" version = "0.1.1" @@ -3453,19 +4689,37 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "path-absolutize" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" +dependencies = [ + "path-dedot", +] + [[package]] name = "path-clean" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + [[package]] name = "pem" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64", + "base64 0.22.1", "serde", ] @@ -3656,6 +4910,31 @@ dependencies = [ "pnet_macros_support", ] +[[package]] +name = "png" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" +dependencies = [ + "bitflags 1.3.2", + "deflate", + "inflate", + "num-iter", +] + +[[package]] +name = "png" +version = "0.17.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67582bd5b65bdff614270e2ea89a1cf15bef71245cc1e5f7ea126977144211d" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + [[package]] name = "poly1305" version = "0.8.0" @@ -3673,6 +4952,15 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "portmapper" version = "0.2.1" @@ -3680,7 +4968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ea24e7552a28ee4a3478ae116c89080957d6816526d0a533bee6cd67048279" dependencies = [ "anyhow", - "base64", + "base64 0.22.1", "bytes", "derive_more", "futures-lite 2.5.0", @@ -3785,6 +5073,15 @@ dependencies = [ "ucd-parse", ] +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -3844,6 +5141,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" +dependencies = [ + "quote", + "syn 2.0.87", +] + [[package]] name = "prometheus-client" version = "0.22.3" @@ -3878,6 +5194,27 @@ dependencies = [ "unicase", ] +[[package]] +name = "pulp" +version = "0.18.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0a01a0dc67cf4558d279f0c25b0962bd08fc6dec0137699eae304103e882fe6" +dependencies = [ + "bytemuck", + "libm", + "num-complex", + "reborrow", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quanta" version = "0.12.3" @@ -3887,7 +5224,7 @@ dependencies = [ "crossbeam-utils", "libc", "once_cell", - "raw-cpuid", + "raw-cpuid 11.1.0", "wasi", "web-sys", "winapi", @@ -3933,6 +5270,22 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick_cache" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d7c94f8935a9df96bb6380e8592c70edf497a643f94bd23b2f76b399385dbf4" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + [[package]] name = "quinn" version = "0.11.5" @@ -4058,6 +5411,65 @@ dependencies = [ "smallvec", ] +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror 1.0.68", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error 2.0.1", + "rav1e", + "rayon", + "rgb", +] + +[[package]] +name = "raw-cpuid" +version = "10.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "raw-cpuid" version = "11.1.0" @@ -4067,6 +5479,12 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "rayon" version = "1.10.0" @@ -4077,6 +5495,17 @@ dependencies = [ "rayon-core", ] +[[package]] +name = "rayon-cond" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "059f538b55efd2309c9794130bc149c6a553db90e9d99c2030785c82f0bd7df9" +dependencies = [ + "either", + "itertools 0.11.0", + "rayon", +] + [[package]] name = "rayon-core" version = "1.12.1" @@ -4100,6 +5529,12 @@ dependencies = [ "yasna", ] +[[package]] +name = "reborrow" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430" + [[package]] name = "redb" version = "1.5.1" @@ -4127,6 +5562,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror 1.0.68", +] + [[package]] name = "ref-cast" version = "1.0.23" @@ -4214,20 +5660,24 @@ version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ - "base64", + "base64 0.22.1", "bytes", + "encoding_rs", "futures-core", "futures-util", + "h2", "http 1.1.0", "http-body", "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -4239,17 +5689,31 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots", "windows-registry", ] +[[package]] +name = "resize" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e7bdfff05e26408cf8f82fe896ce3d7624f0c0b06c84b2f1009c50452ead41" +dependencies = [ + "fallible_collections", + "rgb", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -4257,7 +5721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" dependencies = [ "hostname 0.3.1", - "quick-error", + "quick-error 1.2.3", ] [[package]] @@ -4270,6 +5734,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "rgb" +version = "0.8.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.8" @@ -4379,6 +5852,21 @@ dependencies = [ "semver", ] +[[package]] +name = "rustfft" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43806561bc506d0c5d160643ad742e3161049ac01027b5e6d7524091fd401d86" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", + "version_check", +] + [[package]] name = "rusticata-macros" version = "4.1.0" @@ -4435,7 +5923,7 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ - "base64", + "base64 0.22.1", "rustls-pki-types", ] @@ -4495,6 +5983,16 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "safetensors" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44560c11236a6130a46ce36c836a62936dc81ebf8c36a37947423571be0e55b6" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "salsa20" version = "0.10.2" @@ -4587,11 +6085,17 @@ dependencies = [ "serde", ] +[[package]] +name = "seq-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" + [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -4626,9 +6130,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -4657,6 +6161,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_plain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50" +dependencies = [ + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.8" @@ -4750,6 +6263,21 @@ dependencies = [ "rand_core", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "simple-dns" version = "0.6.2" @@ -4759,6 +6287,15 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "simsimd" +version = "6.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56838e1a0aceaef39fc1327227033efa84a294f54a39b356eefa5c60c885e9f0" +dependencies = [ + "cc", +] + [[package]] name = "skeptic" version = "0.13.7" @@ -4817,6 +6354,41 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socks" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b" +dependencies = [ + "byteorder", + "libc", + "winapi", +] + +[[package]] +name = "sonogram" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6db9516dfca7334890db434476cc205fe2d4cd2dad46f6e972970d730879b9f" +dependencies = [ + "csv", + "hound", + "png 0.14.1", + "resize", + "rgb", + "rustfft", +] + +[[package]] +name = "space" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83919a544070dcfac65f430251bb69e62f1e4ef6f0754fd714a1ac14cfc41a68" +dependencies = [ + "doc-comment", + "num-traits", +] + [[package]] name = "spin" version = "0.9.8" @@ -4845,6 +6417,18 @@ dependencies = [ "der", ] +[[package]] +name = "spm_precompiled" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5851699c4033c63636f7ea4cf7b7c1f1bf06d0cc03cfb42e711de5a5c46cf326" +dependencies = [ + "base64 0.13.1", + "nom", + "serde", + "unicode-segmentation", +] + [[package]] name = "ssh-cipher" version = "0.2.0" @@ -4893,6 +6477,24 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "std-semaphore" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ae9eec00137a8eed469fb4148acd9fc6ac8c3f9b110f52cd34698c8b5bfa0e" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + [[package]] name = "strsim" version = "0.11.1" @@ -4956,7 +6558,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0adebf9fb8fba5c39ee34092b0383f247e4d1255b98fcffec94b4b797b85b677" dependencies = [ - "base64", + "base64 0.22.1", "bounded-integer", "byteorder", "crc", @@ -4978,58 +6580,191 @@ dependencies = [ name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "supports-color" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" +dependencies = [ + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" + +[[package]] +name = "supports-unicode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" + +[[package]] +name = "surge-ping" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbf95ce4c7c5b311d2ce3f088af2b93edef0f09727fa50fbe03c7a979afce77" +dependencies = [ + "hex", + "parking_lot", + "pnet_packet", + "rand", + "socket2", + "thiserror 1.0.68", + "tokio", + "tracing", +] + +[[package]] +name = "swarm-discovery" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39769914108ae68e261d85ceac7bce7095947130f79c29d4535e9b31fc702a40" +dependencies = [ + "acto", + "anyhow", + "hickory-proto 0.24.2", + "rand", + "socket2", + "tokio", + "tracing", +] + +[[package]] +name = "symphonia" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9" +dependencies = [ + "lazy_static", + "symphonia-bundle-flac", + "symphonia-codec-adpcm", + "symphonia-codec-pcm", + "symphonia-codec-vorbis", + "symphonia-core", + "symphonia-format-mkv", + "symphonia-format-ogg", + "symphonia-format-riff", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-bundle-flac" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e34f34298a7308d4397a6c7fbf5b84c5d491231ce3dd379707ba673ab3bd97" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-codec-adpcm" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94e1feac3327cd616e973d5be69ad36b3945f16b06f19c6773fc3ac0b426a0f" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-pcm" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f395a67057c2ebc5e84d7bb1be71cce1a7ba99f64e0f0f0e303a03f79116f89b" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-vorbis" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a98765fb46a0a6732b007f7e2870c2129b6f78d87db7987e6533c8f164a9f30" +dependencies = [ + "log", + "symphonia-core", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-core" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "798306779e3dc7d5231bd5691f5a813496dc79d3f56bf82e25789f2094e022c3" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "bytemuck", + "lazy_static", + "log", +] [[package]] -name = "supports-color" -version = "3.0.1" +name = "symphonia-format-mkv" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" +checksum = "1bb43471a100f7882dc9937395bd5ebee8329298e766250b15b3875652fe3d6f" dependencies = [ - "is_ci", + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", ] [[package]] -name = "supports-hyperlinks" -version = "3.0.0" +name = "symphonia-format-ogg" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" +checksum = "ada3505789516bcf00fc1157c67729eded428b455c27ca370e41f4d785bfa931" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] [[package]] -name = "supports-unicode" -version = "3.0.0" +name = "symphonia-format-riff" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" +checksum = "05f7be232f962f937f4b7115cbe62c330929345434c834359425e043bfd15f50" +dependencies = [ + "extended", + "log", + "symphonia-core", + "symphonia-metadata", +] [[package]] -name = "surge-ping" -version = "0.8.1" +name = "symphonia-metadata" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbf95ce4c7c5b311d2ce3f088af2b93edef0f09727fa50fbe03c7a979afce77" +checksum = "bc622b9841a10089c5b18e99eb904f4341615d5aa55bbf4eedde1be721a4023c" dependencies = [ - "hex", - "parking_lot", - "pnet_packet", - "rand", - "socket2", - "thiserror 1.0.68", - "tokio", - "tracing", + "encoding_rs", + "lazy_static", + "log", + "symphonia-core", ] [[package]] -name = "swarm-discovery" -version = "0.2.1" +name = "symphonia-utils-xiph" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39769914108ae68e261d85ceac7bce7095947130f79c29d4535e9b31fc702a40" +checksum = "484472580fa49991afda5f6550ece662237b00c6f562c7d9638d1b086ed010fe" dependencies = [ - "acto", - "anyhow", - "hickory-proto 0.24.2", - "rand", - "socket2", - "tokio", - "tracing", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -5091,6 +6826,20 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "sysctl" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7dddc5f0fee506baf8b9fdb989e242f17e4b11c61dfbb0635b705217199eea" +dependencies = [ + "bitflags 2.6.0", + "byteorder", + "enum-as-inner", + "libc", + "thiserror 1.0.68", + "walkdir", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -5112,6 +6861,19 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + [[package]] name = "tantivy" version = "0.22.0" @@ -5120,7 +6882,7 @@ checksum = "f8d0582f186c0a6d55655d24543f15e43607299425c5ad8352c242b914b31856" dependencies = [ "aho-corasick", "arc-swap", - "base64", + "base64 0.22.1", "bitpacking", "byteorder", "census", @@ -5131,7 +6893,7 @@ dependencies = [ "fnv", "fs4", "htmlescape", - "itertools", + "itertools 0.12.1", "levenshtein_automata", "log", "lru", @@ -5180,7 +6942,7 @@ checksum = "12722224ffbe346c7fec3275c699e508fd0d4710e629e933d5736ec524a1f44e" dependencies = [ "downcast-rs", "fastdivide", - "itertools", + "itertools 0.12.1", "serde", "tantivy-bitpacker", "tantivy-common", @@ -5259,6 +7021,23 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + [[package]] name = "tempfile" version = "3.12.0" @@ -5289,7 +7068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -5351,6 +7130,17 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "tiff" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "time" version = "0.3.36" @@ -5407,6 +7197,37 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokenizers" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e500fad1dd3af3d626327e6a3fe5050e664a6eaa4708b8ca92f1794aaf73e6fd" +dependencies = [ + "aho-corasick", + "derive_builder", + "esaxx-rs", + "getrandom", + "itertools 0.12.1", + "lazy_static", + "log", + "macro_rules_attribute", + "monostate", + "onig", + "paste", + "rand", + "rayon", + "rayon-cond", + "regex", + "regex-syntax 0.8.4", + "serde", + "serde_json", + "spm_precompiled", + "thiserror 1.0.68", + "unicode-normalization-alignments", + "unicode-segmentation", + "unicode_categories", +] + [[package]] name = "tokio" version = "1.42.0" @@ -5435,6 +7256,16 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -5453,7 +7284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3184e8e292a828dd4bca5b2a60aba830ec5ed873a66c9ebb6e65038fa649e827" dependencies = [ "async-trait", - "base64", + "base64 0.22.1", "chrono", "futures", "log", @@ -5678,6 +7509,16 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -5730,6 +7571,16 @@ dependencies = [ "utf-8", ] +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "typenum" version = "1.17.0" @@ -5751,6 +7602,19 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +[[package]] +name = "ug" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4eef2ebfc18c67a6dbcacd9d8a4d85e0568cc58c82515552382312c2730ea13" +dependencies = [ + "half", + "num", + "serde", + "serde_json", + "thiserror 1.0.68", +] + [[package]] name = "unicase" version = "2.8.0" @@ -5784,18 +7648,45 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-normalization-alignments" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f613e4fa046e69818dd287fdc4bc78175ff20331479dab6e1b0f98d57062de" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-width" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "universal-hash" version = "0.5.1" @@ -5818,11 +7709,16 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" dependencies = [ - "base64", + "base64 0.22.1", + "flate2", "log", + "native-tls", "once_cell", "rustls", "rustls-pki-types", + "serde", + "serde_json", + "socks", "url", "webpki-roots", ] @@ -5876,15 +7772,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", + "rand", "serde", ] +[[package]] +name = "v_frame" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-log" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc2af068c21c0b0531624fbdb5b2c950cf8e7dc72cedf77a9ec10bb677450f" +dependencies = [ + "byteorder", + "log", + "min-max-heap", + "path-absolutize", + "quick_cache", + "rustc-hash 2.0.0", + "tempfile", + "xxhash-rust", +] + +[[package]] +name = "varint-rs" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + [[package]] name = "version_check" version = "0.9.5" @@ -5989,6 +7931,19 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wasm-streams" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "watchable" version = "1.1.2" @@ -6011,6 +7966,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.6" @@ -6020,6 +7985,12 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "weezl" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" + [[package]] name = "widestring" version = "1.1.0" @@ -6380,6 +8351,17 @@ dependencies = [ "time", ] +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] + [[package]] name = "xml-rs" version = "0.8.22" @@ -6395,6 +8377,12 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "xxhash-rust" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" + [[package]] name = "yasna" version = "0.5.2" @@ -6434,6 +8422,35 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb37266251c28b03d08162174a91c3a092e3bd4f476f8205ee1c507b78b7bdc" +[[package]] +name = "zebra" +version = "0.1.0" +source = "git+https://github.com/emmyoh/zebra#46566359e5fd5857be37e682e199a3cb1a96289b" +dependencies = [ + "anyhow", + "bitcode", + "bytes", + "candle-core", + "candle-examples", + "candle-nn", + "candle-transformers", + "dashmap", + "distances", + "fastembed", + "fjall", + "hamming-bitwise-fast", + "hf-hub 0.4.1", + "image", + "lz4_flex", + "rand", + "rayon", + "simsimd", + "sonogram", + "space", + "symphonia", + "uuid", +] + [[package]] name = "zerocopy" version = "0.6.6" @@ -6545,6 +8562,21 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zip" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cc23c04387f4da0374be4533ad1208cbb091d5c11d070dfef13676ad6497164" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "displaydoc", + "indexmap", + "num_enum", + "thiserror 1.0.68", +] + [[package]] name = "zstd" version = "0.13.2" @@ -6572,3 +8604,27 @@ dependencies = [ "cc", "pkg-config", ] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" +dependencies = [ + "zune-core", +] diff --git a/Cargo.toml b/Cargo.toml index 6a98fdf..f1053f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,11 +48,13 @@ bs58 = "0.5.1" anyhow = "1.0.94" native_db = "0.8.1" native_model = "0.4.20" -serde = "1.0.215" +serde = "1.0.216" toml = "0.8.19" rayon = "1.10.0" url = { version = "2.5.4", features = ["serde"] } tantivy = "0.22.0" +zebra = { git = "https://github.com/emmyoh/zebra", version = "0.1.0", features = ["default_db"]} +# zebra = { path = "/home/emil/Documents/GitHub/zebra", version = "0.1.0", features = ["default_db"]} [features] default = [] diff --git a/_rust-toolchain.toml b/_rust-toolchain.toml deleted file mode 100644 index 31578d3..0000000 --- a/_rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "stable" \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..271800c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" \ No newline at end of file diff --git a/src/database/core.rs b/src/database/core.rs index 9751970..6b97229 100644 --- a/src/database/core.rs +++ b/src/database/core.rs @@ -1,5 +1,5 @@ use super::dht::*; -use super::posts::*; +use super::posts::core::OkuPost; use super::users::*; use crate::fs::FS_PATH; use miette::IntoDiagnostic; @@ -36,4 +36,13 @@ impl OkuDatabase { .into_diagnostic()?, }) } + + /// Perform a database migration. + pub fn migrate(&self) -> miette::Result<()> { + let rw = self.database.rw_transaction().into_diagnostic()?; + rw.migrate::().into_diagnostic()?; + rw.migrate::().into_diagnostic()?; + rw.migrate::().into_diagnostic()?; + rw.commit().into_diagnostic() + } } diff --git a/src/database/posts/core.rs b/src/database/posts/core.rs new file mode 100644 index 0000000..807f686 --- /dev/null +++ b/src/database/posts/core.rs @@ -0,0 +1,196 @@ +use super::super::core::*; +use super::super::users::*; +use crate::fs::FS_PATH; +use iroh_docs::rpc::client::docs::Entry; +use iroh_docs::AuthorId; +use native_db::*; +use native_model::{native_model, Model}; +use serde::{Deserialize, Serialize}; +use std::hash::{Hash, Hasher}; +use std::{ + collections::{HashMap, HashSet}, + path::PathBuf, + str::FromStr, + sync::{Arc, LazyLock}, + time::SystemTime, +}; +use tantivy::{ + directory::MmapDirectory, + schema::{Field, Schema, Value, FAST, STORED, TEXT}, + Directory, Index, IndexReader, IndexWriter, TantivyDocument, Term, +}; +use tokio::sync::Mutex; +use url::Url; + +pub(crate) static POST_INDEX_PATH: LazyLock = + LazyLock::new(|| PathBuf::from(FS_PATH).join("POST_INDEX")); +pub(crate) static POST_SCHEMA: LazyLock<(Schema, HashMap<&str, Field>)> = LazyLock::new(|| { + let mut schema_builder = Schema::builder(); + let fields = HashMap::from([ + ("id", schema_builder.add_bytes_field("id", STORED)), + ( + "author_id", + schema_builder.add_text_field("author_id", TEXT | STORED), + ), + ("path", schema_builder.add_text_field("path", TEXT | STORED)), + ("url", schema_builder.add_text_field("url", TEXT | STORED)), + ( + "title", + schema_builder.add_text_field("title", TEXT | STORED), + ), + ("body", schema_builder.add_text_field("body", TEXT | STORED)), + ("tag", schema_builder.add_text_field("tag", TEXT | STORED)), + ( + "timestamp", + schema_builder.add_date_field("timestamp", FAST), + ), + ]); + let schema = schema_builder.build(); + (schema, fields) +}); +pub(crate) static POST_INDEX: LazyLock = LazyLock::new(|| { + let _ = std::fs::create_dir_all(&*POST_INDEX_PATH); + let mmap_directory: Box = + Box::new(MmapDirectory::open(&*POST_INDEX_PATH).unwrap()); + Index::open_or_create(mmap_directory, POST_SCHEMA.0.clone()).unwrap() +}); +pub(crate) static POST_INDEX_READER: LazyLock = + LazyLock::new(|| POST_INDEX.reader().unwrap()); +pub(crate) static POST_INDEX_WRITER: LazyLock>> = + LazyLock::new(|| Arc::new(Mutex::new(POST_INDEX.writer(50_000_000).unwrap()))); + +#[derive(Serialize, Deserialize, Debug, Clone)] +#[native_model(id = 2, version = 2)] +#[native_db( + primary_key(primary_key -> (Vec, Vec)) +)] +/// An OkuNet post. +pub struct OkuPost { + /// A record of a version of the post file. + pub entry: Entry, + /// The content of the post on OkuNet. + pub note: OkuNote, +} + +impl PartialEq for OkuPost { + fn eq(&self, other: &Self) -> bool { + self.primary_key() == other.primary_key() + } +} +impl Eq for OkuPost {} +impl Hash for OkuPost { + fn hash(&self, state: &mut H) { + self.primary_key().hash(state); + } +} + +impl From for TantivyDocument { + fn from(value: OkuPost) -> Self { + let post_key: [Vec; 2] = value.primary_key().into(); + let post_key_bytes = post_key.concat(); + + let mut doc = TantivyDocument::default(); + doc.add_bytes(POST_SCHEMA.1["id"], post_key_bytes); + doc.add_text( + POST_SCHEMA.1["author_id"], + iroh_base::base32::fmt(value.entry.author()), + ); + doc.add_text( + POST_SCHEMA.1["path"], + String::from_utf8_lossy(value.entry.key()), + ); + doc.add_text(POST_SCHEMA.1["url"], value.note.url.to_string()); + doc.add_text(POST_SCHEMA.1["title"], value.note.title); + doc.add_text(POST_SCHEMA.1["body"], value.note.body); + for tag in value.note.tags { + doc.add_text(POST_SCHEMA.1["tag"], tag); + } + doc.add_date( + POST_SCHEMA.1["timestamp"], + tantivy::DateTime::from_timestamp_micros(value.entry.timestamp() as i64), + ); + doc + } +} + +impl TryFrom for OkuPost { + type Error = anyhow::Error; + + fn try_from(value: TantivyDocument) -> Result { + let author_id = AuthorId::from_str( + value + .get_first(POST_SCHEMA.1["author_id"]) + .ok_or(anyhow::anyhow!("No author ID for document in index … "))? + .as_str() + .ok_or(anyhow::anyhow!("No author ID for document in index … "))?, + )?; + let path = value + .get_first(POST_SCHEMA.1["path"]) + .ok_or(anyhow::anyhow!("No path for document in index … "))? + .as_str() + .ok_or(anyhow::anyhow!("No path for document in index … "))? + .to_string(); + DATABASE + .get_post(author_id, path.clone().into()) + .ok() + .flatten() + .ok_or(anyhow::anyhow!( + "No post with author {} and path {} found … ", + author_id, + path + )) + } +} + +impl OkuPost { + pub(crate) fn primary_key(&self) -> (Vec, Vec) { + ( + self.entry.author().as_bytes().to_vec(), + self.entry.key().to_vec(), + ) + } + + pub(crate) fn index_term(&self) -> Term { + let post_key: [Vec; 2] = self.primary_key().into(); + let post_key_bytes = post_key.concat(); + Term::from_field_bytes(POST_SCHEMA.1["id"], &post_key_bytes) + } + + /// Obtain the author of this post from the OkuNet database. + pub fn user(&self) -> OkuUser { + match DATABASE.get_user(self.entry.author()).ok().flatten() { + Some(user) => user, + None => OkuUser { + author_id: self.entry.author(), + last_fetched: SystemTime::now(), + posts: vec![self.entry.clone()], + identity: None, + }, + } + } +} + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] +/// A note left by an Oku user regarding some URL-addressed content. +pub struct OkuNote { + /// The URL the note is regarding. + pub url: Url, + /// The title of the note. + pub title: String, + /// The body of the note. + pub body: String, + /// A list of tags associated with the note. + pub tags: HashSet, +} + +impl OkuNote { + /// Generate a suggested post path for the note. + pub fn suggested_post_path(&self) -> String { + Self::suggested_post_path_from_url(self.url.to_string()) + } + + /// Generate a suggested post path using a URL. + pub fn suggested_post_path_from_url(url: String) -> String { + format!("/posts/{}.toml", bs58::encode(url.as_bytes()).into_string()) + } +} diff --git a/src/database/posts/mod.rs b/src/database/posts/mod.rs new file mode 100644 index 0000000..80160cf --- /dev/null +++ b/src/database/posts/mod.rs @@ -0,0 +1,4 @@ +/// Definition of an OkuNet post. +pub mod core; +/// Implementation of OkuNet post-related database operations. +pub mod operations; diff --git a/src/database/posts.rs b/src/database/posts/operations.rs similarity index 53% rename from src/database/posts.rs rename to src/database/posts/operations.rs index 3314396..4d6aa42 100644 --- a/src/database/posts.rs +++ b/src/database/posts/operations.rs @@ -1,203 +1,16 @@ -use super::core::*; -use super::users::*; -use crate::fs::{path_to_entry_key, FS_PATH}; -use iroh_docs::rpc::client::docs::Entry; +use super::super::core::*; +use super::core::OkuPost; +use super::core::POST_INDEX; +use super::core::POST_INDEX_READER; +use super::core::POST_INDEX_WRITER; +use super::core::POST_SCHEMA; +use crate::fs::util::path_to_entry_key; use iroh_docs::AuthorId; use miette::IntoDiagnostic; use native_db::*; -use native_model::{native_model, Model}; use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}; -use serde::{Deserialize, Serialize}; -use std::hash::{Hash, Hasher}; -use std::{ - collections::{HashMap, HashSet}, - path::PathBuf, - str::FromStr, - sync::{Arc, LazyLock}, - time::SystemTime, -}; -use tantivy::{ - collector::TopDocs, - directory::MmapDirectory, - query::QueryParser, - schema::{Field, Schema, Value, FAST, STORED, TEXT}, - Directory, Index, IndexReader, IndexWriter, TantivyDocument, Term, -}; -use tokio::sync::Mutex; -use url::Url; - -pub(crate) static POST_INDEX_PATH: LazyLock = - LazyLock::new(|| PathBuf::from(FS_PATH).join("POST_INDEX")); -pub(crate) static POST_SCHEMA: LazyLock<(Schema, HashMap<&str, Field>)> = LazyLock::new(|| { - let mut schema_builder = Schema::builder(); - let fields = HashMap::from([ - ("id", schema_builder.add_bytes_field("id", STORED)), - ( - "author_id", - schema_builder.add_text_field("author_id", TEXT | STORED), - ), - ("path", schema_builder.add_text_field("path", TEXT | STORED)), - ("url", schema_builder.add_text_field("url", TEXT | STORED)), - ( - "title", - schema_builder.add_text_field("title", TEXT | STORED), - ), - ("body", schema_builder.add_text_field("body", TEXT | STORED)), - ("tag", schema_builder.add_text_field("tag", TEXT | STORED)), - ( - "timestamp", - schema_builder.add_date_field("timestamp", FAST), - ), - ]); - let schema = schema_builder.build(); - (schema, fields) -}); -pub(crate) static POST_INDEX: LazyLock = LazyLock::new(|| { - let _ = std::fs::create_dir_all(&*POST_INDEX_PATH); - let mmap_directory: Box = - Box::new(MmapDirectory::open(&*POST_INDEX_PATH).unwrap()); - Index::open_or_create(mmap_directory, POST_SCHEMA.0.clone()).unwrap() -}); -pub(crate) static POST_INDEX_READER: LazyLock = - LazyLock::new(|| POST_INDEX.reader().unwrap()); -pub(crate) static POST_INDEX_WRITER: LazyLock>> = - LazyLock::new(|| Arc::new(Mutex::new(POST_INDEX.writer(50_000_000).unwrap()))); - -#[derive(Serialize, Deserialize, Debug, Clone)] -#[native_model(id = 2, version = 1)] -#[native_db( - primary_key(primary_key -> (Vec, Vec)) -)] -/// An OkuNet post. -pub struct OkuPost { - /// A record of a version of the post file. - pub entry: Entry, - /// The content of the post on OkuNet. - pub note: OkuNote, -} - -impl PartialEq for OkuPost { - fn eq(&self, other: &Self) -> bool { - self.primary_key() == other.primary_key() - } -} -impl Eq for OkuPost {} -impl Hash for OkuPost { - fn hash(&self, state: &mut H) { - self.primary_key().hash(state); - } -} - -impl From for TantivyDocument { - fn from(value: OkuPost) -> Self { - let post_key: [Vec; 2] = value.primary_key().into(); - let post_key_bytes = post_key.concat(); - - let mut doc = TantivyDocument::default(); - doc.add_bytes(POST_SCHEMA.1["id"], post_key_bytes); - doc.add_text( - POST_SCHEMA.1["author_id"], - iroh_base::base32::fmt(value.entry.author()), - ); - doc.add_text( - POST_SCHEMA.1["path"], - String::from_utf8_lossy(value.entry.key()), - ); - doc.add_text(POST_SCHEMA.1["url"], value.note.url.to_string()); - doc.add_text(POST_SCHEMA.1["title"], value.note.title); - doc.add_text(POST_SCHEMA.1["body"], value.note.body); - for tag in value.note.tags { - doc.add_text(POST_SCHEMA.1["tag"], tag); - } - doc.add_date( - POST_SCHEMA.1["timestamp"], - tantivy::DateTime::from_timestamp_micros(value.entry.timestamp() as i64), - ); - doc - } -} - -impl TryFrom for OkuPost { - type Error = anyhow::Error; - - fn try_from(value: TantivyDocument) -> Result { - let author_id = AuthorId::from_str( - value - .get_first(POST_SCHEMA.1["author_id"]) - .ok_or(anyhow::anyhow!("No author ID for document in index … "))? - .as_str() - .ok_or(anyhow::anyhow!("No author ID for document in index … "))?, - )?; - let path = value - .get_first(POST_SCHEMA.1["path"]) - .ok_or(anyhow::anyhow!("No path for document in index … "))? - .as_str() - .ok_or(anyhow::anyhow!("No path for document in index … "))? - .to_string(); - DATABASE - .get_post(author_id, path.clone().into()) - .ok() - .flatten() - .ok_or(anyhow::anyhow!( - "No post with author {} and path {} found … ", - author_id, - path - )) - } -} - -impl OkuPost { - fn primary_key(&self) -> (Vec, Vec) { - ( - self.entry.author().as_bytes().to_vec(), - self.entry.key().to_vec(), - ) - } - - fn index_term(&self) -> Term { - let post_key: [Vec; 2] = self.primary_key().into(); - let post_key_bytes = post_key.concat(); - Term::from_field_bytes(POST_SCHEMA.1["id"], &post_key_bytes) - } - - /// Obtain the author of this post from the OkuNet database. - pub fn user(&self) -> OkuUser { - match DATABASE.get_user(self.entry.author()).ok().flatten() { - Some(user) => user, - None => OkuUser { - author_id: self.entry.author(), - last_fetched: SystemTime::now(), - posts: vec![self.entry.clone()], - identity: None, - }, - } - } -} - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -/// A note left by an Oku user regarding some URL-addressed content. -pub struct OkuNote { - /// The URL the note is regarding. - pub url: Url, - /// The title of the note. - pub title: String, - /// The body of the note. - pub body: String, - /// A list of tags associated with the note. - pub tags: HashSet, -} - -impl OkuNote { - /// Generate a suggested post path for the note. - pub fn suggested_post_path(&self) -> String { - Self::suggested_post_path_from_url(self.url.to_string()) - } - - /// Generate a suggested post path using a URL. - pub fn suggested_post_path_from_url(url: String) -> String { - format!("/posts/{}.toml", bs58::encode(url.as_bytes()).into_string()) - } -} +use std::{collections::HashSet, path::PathBuf}; +use tantivy::{collector::TopDocs, query::QueryParser, TantivyDocument}; impl OkuDatabase { /// Search OkuNet posts with a query string. diff --git a/src/database/users.rs b/src/database/users.rs index 6f416f1..86e3d53 100644 --- a/src/database/users.rs +++ b/src/database/users.rs @@ -1,5 +1,5 @@ use super::core::*; -use super::posts::*; +use super::posts::core::OkuPost; use iroh_docs::rpc::client::docs::Entry; use iroh_docs::AuthorId; use log::error; diff --git a/src/fs/core.rs b/src/fs/core.rs index cacca57..c013738 100644 --- a/src/fs/core.rs +++ b/src/fs/core.rs @@ -152,7 +152,7 @@ impl OkuFs { /// /// # Returns /// - /// Tye content of the entry, as raw bytes. + /// The content of the entry, as raw bytes. pub async fn content_bytes(&self, entry: &iroh_docs::Entry) -> anyhow::Result { let mut data_reader = self .docs_engine diff --git a/src/fs/directory.rs b/src/fs/directory.rs index 2fc5f19..b64784e 100644 --- a/src/fs/directory.rs +++ b/src/fs/directory.rs @@ -14,6 +14,9 @@ use rayon::iter::{ IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, }; use std::path::PathBuf; +use util::entry_key_to_path; +use util::normalise_path; +use util::path_to_entry_prefix; impl OkuFs { /// Reads the contents of the files in a directory. diff --git a/src/fs/file.rs b/src/fs/file.rs index 7fdfad9..3494cf5 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -13,6 +13,8 @@ use iroh_docs::NamespaceId; use log::{error, info}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use std::path::PathBuf; +use util::path_to_entry_key; +use util::path_to_entry_prefix; impl OkuFs { /// Lists files in a replica. diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 10ae361..3a9fec1 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -13,29 +13,17 @@ use tokio::runtime::Handle; use tokio::sync::watch::Sender; /// Core functionality of an Oku file system. -mod core; +pub mod core; /// Directory-related functionality of an Oku file system. -mod directory; +pub mod directory; /// File-related functionality of an Oku file system. -mod file; +pub mod file; /// Implementation of OkuNet. -mod net; +pub mod net; /// Replica-related functionality of an Oku file system. -mod replica; +pub mod replica; /// Useful functions for implementing the Oku file system. -mod util; -#[allow(unused_imports)] -pub use self::core::*; -#[allow(unused_imports)] -pub use self::directory::*; -#[allow(unused_imports)] -pub use self::file::*; -#[allow(unused_imports)] -pub use self::net::*; -#[allow(unused_imports)] -pub use self::replica::*; -#[allow(unused_imports)] -pub use self::util::*; +pub mod util; /// The path on disk where the file system is stored. pub const FS_PATH: &str = ".oku"; diff --git a/src/fs/net/core.rs b/src/fs/net/core.rs new file mode 100644 index 0000000..6142212 --- /dev/null +++ b/src/fs/net/core.rs @@ -0,0 +1,37 @@ +use crate::fs::util::{path_to_entry_key, path_to_entry_prefix}; +use iroh_docs::store::FilterKind; +use iroh_docs::Author; +use iroh_docs::DocTicket; +use iroh_docs::NamespaceId; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug, Clone)] +/// An Oku user's credentials, which are sensitive, exported from a node, able to be imported into another. +pub struct ExportedUser { + pub(crate) author: Author, + pub(crate) home_replica: Option, + pub(crate) home_replica_ticket: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +/// The modality of the data used to create an embedding vector. +pub enum EmbeddingModality { + /// Text + Text, + /// Image + Image, + /// Audio + Audio, +} + +/// Filters to prevent downloading the entirety of a home replica. +/// Only the `/profile.toml` file and the `/posts/` directory are downloaded. +/// +/// # Returns +/// +/// The download filters specifying the only content allowed to be downloaded from a home replica. +pub fn home_replica_filters() -> Vec { + let profile_filter = FilterKind::Exact(path_to_entry_key("/profile.toml".into())); + let posts_filter = FilterKind::Prefix(path_to_entry_prefix("/posts/".into())); + vec![profile_filter, posts_filter] +} diff --git a/src/fs/net/embeddings.rs b/src/fs/net/embeddings.rs new file mode 100644 index 0000000..8fb14f2 --- /dev/null +++ b/src/fs/net/embeddings.rs @@ -0,0 +1,95 @@ +use super::core::{home_replica_filters, EmbeddingModality}; +use crate::fs::OkuFs; +use iroh_docs::DocTicket; +use miette::IntoDiagnostic; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::{collections::HashMap, path::PathBuf}; +use zebra::model::core::{DIM_BGESMALL_EN_1_5, DIM_VIT_BASE_PATCH16_224}; + +impl OkuFs { + /// Fetch an embedding file associated with a post. + /// + /// # Arguments + /// + /// * `ticket` - A ticket for the replica containing the file to retrieve. + /// + /// * `path` - The path to the file to retrieve. + /// + /// * `uri` - The URI associated with the OkuNet post. + pub async fn fetch_post_embeddings( + &self, + ticket: &DocTicket, + path: PathBuf, + uri: String, + ) -> miette::Result<()> { + if let Ok(bytes) = self + .fetch_file_with_ticket(ticket, path.clone(), Some(home_replica_filters())) + .await + { + let embeddings = toml::from_str::>>( + String::from_utf8_lossy(&bytes).as_ref(), + ) + .into_diagnostic()?; + let text_db = zebra::database::default::text::DefaultTextDatabase::open_or_create( + &"text.zebra".into(), + ); + let image_db = zebra::database::default::image::DefaultImageDatabase::open_or_create( + &"image.zebra".into(), + ); + let audio_db = zebra::database::default::audio::DefaultAudioDatabase::open_or_create( + &"audio.zebra".into(), + ); + embeddings + .into_par_iter() + .map(|(modality, embedding)| -> miette::Result<()> { + match modality { + EmbeddingModality::Text => { + text_db + .insert_records( + &vec![embedding + .try_into() + .unwrap_or([0.0; DIM_BGESMALL_EN_1_5])], + &vec![uri.clone().into()], + ) + .map_err(|e| miette::miette!("{e}"))?; + } + EmbeddingModality::Image => { + image_db + .insert_records( + &vec![embedding + .try_into() + .unwrap_or([0.0; DIM_VIT_BASE_PATCH16_224])], + &vec![uri.clone().into()], + ) + .map_err(|e| miette::miette!("{e}"))?; + } + EmbeddingModality::Audio => { + audio_db + .insert_records( + &vec![embedding + .try_into() + .unwrap_or([0.0; DIM_VIT_BASE_PATCH16_224])], + &vec![uri.clone().into()], + ) + .map_err(|e| miette::miette!("{e}"))?; + } + } + Ok(()) + }) + .collect::>>()?; + text_db + .index + .deduplicate() + .map_err(|e| miette::miette!("{e}"))?; + image_db + .index + .deduplicate() + .map_err(|e| miette::miette!("{e}"))?; + audio_db + .index + .deduplicate() + .map_err(|e| miette::miette!("{e}"))?; + } + Ok(()) + } +} diff --git a/src/fs/net/mod.rs b/src/fs/net/mod.rs new file mode 100644 index 0000000..2e2000e --- /dev/null +++ b/src/fs/net/mod.rs @@ -0,0 +1,8 @@ +/// Common OkuNet code. +pub mod core; +/// Embedding vector-related node functionality. +pub mod embeddings; +/// OkuNet post-related node functionality. +pub mod posts; +/// OkuNet user-related node functionality. +pub mod users; diff --git a/src/fs/net/posts.rs b/src/fs/net/posts.rs new file mode 100644 index 0000000..7a1fee9 --- /dev/null +++ b/src/fs/net/posts.rs @@ -0,0 +1,272 @@ +use super::core::home_replica_filters; +use crate::{ + database::{ + core::DATABASE, + posts::core::{OkuNote, OkuPost}, + users::OkuUser, + }, + fs::OkuFs, +}; +use iroh_base::hash::Hash; +use iroh_docs::rpc::client::docs::Entry; +use iroh_docs::AuthorId; +use miette::IntoDiagnostic; +use rayon::iter::{ + FromParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; +use std::{collections::HashSet, path::PathBuf}; +use url::Url; + +impl OkuFs { + /// Retrieves the OkuNet posts by the local user, if any. + /// + /// # Returns + /// + /// A list of the OkuNet posts by the local user. + pub async fn posts(&self) -> Option> { + let post_files = self + .read_directory(self.home_replica().await?, "/posts/".into()) + .await + .ok() + .unwrap_or_default(); + Some( + post_files + .par_iter() + .filter_map(|(entry, bytes)| { + toml::from_str::(String::from_utf8_lossy(bytes).as_ref()) + .ok() + .map(|x| OkuPost { + entry: entry.clone(), + note: x, + }) + }) + .collect(), + ) + } + + /// Retrieves all posts containing a given tag, whether they are authored by the local user or an OkuNet user. + /// + /// # Arguments + /// + /// * `tag` - A tag. + /// + /// # Returns + /// + /// A list of OkuNet posts with the given tag. + pub async fn all_posts_with_tag(&self, tag: String) -> Vec { + let mut posts = HashSet::<_>::from_par_iter(self.posts().await.unwrap_or_default()); + posts.extend(DATABASE.get_posts().unwrap_or_default()); + posts + .into_par_iter() + .filter(|x| x.note.tags.contains(&tag)) + .collect() + } + + /// Retrieves the set of all tags that appear in posts authored by the local user or an OkuNet user. + /// + /// # Returns + /// + /// All tags that appear across all posts on the local machine. + pub async fn all_tags(&self) -> HashSet { + let mut tags = HashSet::<_>::from_par_iter( + self.posts() + .await + .unwrap_or_default() + .into_par_iter() + .flat_map(|x| x.note.tags), + ); + tags.extend( + DATABASE + .get_posts() + .unwrap_or_default() + .into_iter() + .flat_map(|x| x.note.tags), + ); + tags + } + + /// Retrieves an OkuNet post authored by the local user using its path. + /// + /// # Arguments + /// + /// * `path` - A path to a post in the user's home replica. + /// + /// # Returns + /// + /// The OkuNet post at the given path. + pub async fn post(&self, path: PathBuf) -> miette::Result { + let namespace_id = self + .home_replica() + .await + .ok_or(miette::miette!("Home replica not set … "))?; + match self.read_file(namespace_id, path.clone()).await { + Ok(bytes) => { + let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) + .into_diagnostic()?; + Ok(OkuPost { + entry: self.get_entry(namespace_id, path).await?, + note, + }) + } + Err(e) => Err(miette::miette!("{}", e)), + } + } + + /// Attempts to retrieve an OkuNet post from a file entry. + /// + /// # Arguments + /// + /// * `entry` - The file entry to parse. + /// + /// # Returns + /// + /// An OkuNet post, if the entry represents one. + pub async fn post_from_entry(&self, entry: &Entry) -> miette::Result { + let bytes = self + .content_bytes(entry) + .await + .map_err(|e| miette::miette!("{}", e))?; + let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) + .into_diagnostic()?; + Ok(OkuPost { + entry: entry.clone(), + note, + }) + } + + /// Retrieves OkuNet posts from the file entries in an [`OkuUser`]. + /// + /// # Arguments + /// + /// * `user` - The OkuNet user record containing the file entries. + /// + /// # Returns + /// + /// A list of OkuNet posts contained within the user record. + pub async fn posts_from_user(&self, user: &OkuUser) -> miette::Result> { + let mut posts: Vec<_> = Vec::new(); + for post in user.posts.clone() { + posts.push(self.post_from_entry(&post).await?); + } + Ok(posts) + } + + /// Create or modify an OkuNet post in the user's home replica. + /// + /// # Arguments + /// + /// * `path` - The path to create, or modify, the post at; a suggested path is generated if none is provided. + /// + /// * `url` - The URL the post is regarding. + /// + /// * `title` - The title of the post. + /// + /// * `body` - The body of the post. + /// + /// * `tags` - A list of tags associated with the post. + /// + /// # Returns + /// + /// A hash of the post's content. + pub async fn create_or_modify_post( + &self, + path: Option, + url: Url, + title: String, + body: String, + tags: HashSet, + ) -> miette::Result { + let home_replica_id = self + .home_replica() + .await + .ok_or(miette::miette!("No home replica set … "))?; + let new_note = OkuNote { + url, + title, + body, + tags, + }; + let post_path = match path { + Some(given_path) => given_path, + None => new_note.suggested_post_path().into(), + }; + self.create_or_modify_file( + home_replica_id, + post_path, + toml::to_string_pretty(&new_note).into_diagnostic()?, + ) + .await + } + + /// Delete an OkuNet post in the user's home replica. + /// + /// # Arguments + /// + /// * `path` - A path to a post in the user's home replica. + /// + /// # Returns + /// + /// The number of entries deleted in the replica, which should be 1 if the file was successfully deleted. + pub async fn delete_post(&self, path: PathBuf) -> miette::Result { + let home_replica_id = self + .home_replica() + .await + .ok_or(miette::miette!("No home replica set … "))?; + self.delete_file(home_replica_id, path).await + } + + /// Join a swarm to fetch the latest version of an OkuNet post. + /// + /// # Arguments + /// + /// * `author_id` - The authorship ID of the post's author. + /// + /// * `path` - The path to the post in the author's home replica. + /// + /// # Returns + /// + /// The requested OkuNet post. + pub async fn fetch_post(&self, author_id: AuthorId, path: PathBuf) -> miette::Result { + let ticket = self + .resolve_author_id(author_id) + .await + .map_err(|e| miette::miette!("{}", e))?; + let namespace_id = ticket.capability.id(); + match self + .fetch_file_with_ticket(&ticket, path.clone(), Some(home_replica_filters())) + .await + { + Ok(bytes) => { + let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) + .into_diagnostic()?; + Ok(OkuPost { + entry: self.get_entry(namespace_id, path).await?, + note, + }) + } + Err(e) => Err(miette::miette!("{}", e)), + } + } + + /// Retrieves an OkuNet post from the database, or from the mainline DHT if not found locally. + /// + /// # Arguments + /// + /// * `author_id` - The authorship ID of the post's author. + /// + /// * `path` - The path to the post in the author's home replica. + /// + /// # Returns + /// + /// The requested OkuNet post. + pub async fn get_or_fetch_post( + &self, + author_id: AuthorId, + path: PathBuf, + ) -> miette::Result { + match DATABASE.get_post(author_id, path.clone()).ok().flatten() { + Some(post) => Ok(post), + None => self.fetch_post(author_id, path).await, + } + } +} diff --git a/src/fs/net.rs b/src/fs/net/users.rs similarity index 67% rename from src/fs/net.rs rename to src/fs/net/users.rs index 90c10fc..9f0d1b0 100644 --- a/src/fs/net.rs +++ b/src/fs/net/users.rs @@ -1,25 +1,21 @@ -use std::{collections::HashSet, path::PathBuf, time::SystemTime}; - +use super::core::{home_replica_filters, ExportedUser}; use crate::{ config::OkuFsConfig, database::{ core::DATABASE, dht::ReplicaAnnouncement, - posts::{OkuNote, OkuPost}, + posts::core::{OkuNote, OkuPost}, users::{OkuIdentity, OkuUser}, }, discovery::REPUBLISH_DELAY, - fs::{merge_tickets, OkuFs}, + fs::{util::merge_tickets, OkuFs}, }; use anyhow::anyhow; use futures::StreamExt; use iroh_base::hash::Hash; use iroh_base::ticket::Ticket; -use iroh_docs::rpc::client::docs::Entry; use iroh_docs::rpc::client::docs::ShareMode; -use iroh_docs::store::FilterKind; use iroh_docs::sync::CapabilityKind; -use iroh_docs::Author; use iroh_docs::AuthorId; use iroh_docs::DocTicket; use iroh_docs::NamespaceId; @@ -27,30 +23,7 @@ use miette::IntoDiagnostic; use rayon::iter::{ FromParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, }; -use serde::{Deserialize, Serialize}; -use url::Url; - -use super::{path_to_entry_key, path_to_entry_prefix}; - -#[derive(Serialize, Deserialize, Debug, Clone)] -/// An Oku user's credentials, which are sensitive, exported from a node, able to be imported into another. -pub struct ExportedUser { - author: Author, - home_replica: Option, - home_replica_ticket: Option, -} - -/// Filters to prevent downloading the entirety of a home replica. -/// Only the `/profile.toml` file and the `/posts/` directory are downloaded. -/// -/// # Returns -/// -/// The download filters specifying the only content allowed to be downloaded from a home replica. -pub fn home_replica_filters() -> Vec { - let profile_filter = FilterKind::Exact(path_to_entry_key("/profile.toml".into())); - let posts_filter = FilterKind::Prefix(path_to_entry_prefix("/posts/".into())); - vec![profile_filter, posts_filter] -} +use std::{collections::HashSet, time::SystemTime}; impl OkuFs { /// Retrieve the content authorship ID used by the node. @@ -178,100 +151,6 @@ impl OkuFs { Ok(()) } - /// Retrieves the OkuNet posts by the local user, if any. - /// - /// # Returns - /// - /// A list of the OkuNet posts by the local user. - pub async fn posts(&self) -> Option> { - let post_files = self - .read_directory(self.home_replica().await?, "/posts/".into()) - .await - .ok() - .unwrap_or_default(); - Some( - post_files - .par_iter() - .filter_map(|(entry, bytes)| { - toml::from_str::(String::from_utf8_lossy(bytes).as_ref()) - .ok() - .map(|x| OkuPost { - entry: entry.clone(), - note: x, - }) - }) - .collect(), - ) - } - - /// Retrieves all posts containing a given tag, whether they are authored by the local user or an OkuNet user. - /// - /// # Arguments - /// - /// * `tag` - A tag. - /// - /// # Returns - /// - /// A list of OkuNet posts with the given tag. - pub async fn all_posts_with_tag(&self, tag: String) -> Vec { - let mut posts = HashSet::<_>::from_par_iter(self.posts().await.unwrap_or_default()); - posts.extend(DATABASE.get_posts().unwrap_or_default()); - posts - .into_par_iter() - .filter(|x| x.note.tags.contains(&tag)) - .collect() - } - - /// Retrieves the set of all tags that appear in posts authored by the local user or an OkuNet user. - /// - /// # Returns - /// - /// All tags that appear across all posts on the local machine. - pub async fn all_tags(&self) -> HashSet { - let mut tags = HashSet::<_>::from_par_iter( - self.posts() - .await - .unwrap_or_default() - .into_par_iter() - .flat_map(|x| x.note.tags), - ); - tags.extend( - DATABASE - .get_posts() - .unwrap_or_default() - .into_iter() - .flat_map(|x| x.note.tags), - ); - tags - } - - /// Retrieves an OkuNet post authored by the local user using its path. - /// - /// # Arguments - /// - /// * `path` - A path to a post in the user's home replica. - /// - /// # Returns - /// - /// The OkuNet post at the given path. - pub async fn post(&self, path: PathBuf) -> miette::Result { - let namespace_id = self - .home_replica() - .await - .ok_or(miette::miette!("Home replica not set … "))?; - match self.read_file(namespace_id, path.clone()).await { - Ok(bytes) => { - let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) - .into_diagnostic()?; - Ok(OkuPost { - entry: self.get_entry(namespace_id, path).await?, - note, - }) - } - Err(e) => Err(miette::miette!("{}", e)), - } - } - /// Retrieves the OkuNet identity of the local user. /// /// # Returns @@ -430,109 +309,6 @@ impl OkuFs { }) } - /// Attempts to retrieve an OkuNet post from a file entry. - /// - /// # Arguments - /// - /// * `entry` - The file entry to parse. - /// - /// # Returns - /// - /// An OkuNet post, if the entry represents one. - pub async fn post_from_entry(&self, entry: &Entry) -> miette::Result { - let bytes = self - .content_bytes(entry) - .await - .map_err(|e| miette::miette!("{}", e))?; - let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) - .into_diagnostic()?; - Ok(OkuPost { - entry: entry.clone(), - note, - }) - } - - /// Retrieves OkuNet posts from the file entries in an [`OkuUser`]. - /// - /// # Arguments - /// - /// * `user` - The OkuNet user record containing the file entries. - /// - /// # Returns - /// - /// A list of OkuNet posts contained within the user record. - pub async fn posts_from_user(&self, user: &OkuUser) -> miette::Result> { - let mut posts: Vec<_> = Vec::new(); - for post in user.posts.clone() { - posts.push(self.post_from_entry(&post).await?); - } - Ok(posts) - } - - /// Create or modify an OkuNet post in the user's home replica. - /// - /// # Arguments - /// - /// * `path` - The path to create, or modify, the post at; a suggested path is generated if none is provided. - /// - /// * `url` - The URL the post is regarding. - /// - /// * `title` - The title of the post. - /// - /// * `body` - The body of the post. - /// - /// * `tags` - A list of tags associated with the post. - /// - /// # Returns - /// - /// A hash of the post's content. - pub async fn create_or_modify_post( - &self, - path: Option, - url: Url, - title: String, - body: String, - tags: HashSet, - ) -> miette::Result { - let home_replica_id = self - .home_replica() - .await - .ok_or(miette::miette!("No home replica set … "))?; - let new_note = OkuNote { - url, - title, - body, - tags, - }; - let post_path = match path { - Some(given_path) => given_path, - None => new_note.suggested_post_path().into(), - }; - self.create_or_modify_file( - home_replica_id, - post_path, - toml::to_string_pretty(&new_note).into_diagnostic()?, - ) - .await - } - - /// Delete an OkuNet post in the user's home replica. - /// - /// # Arguments - /// - /// * `path` - A path to a post in the user's home replica. - /// - /// # Returns - /// - /// The number of entries deleted in the replica, which should be 1 if the file was successfully deleted. - pub async fn delete_post(&self, path: PathBuf) -> miette::Result { - let home_replica_id = self - .home_replica() - .await - .ok_or(miette::miette!("No home replica set … "))?; - self.delete_file(home_replica_id, path).await - } - /// Refreshes any user data last retrieved longer than [`REPUBLISH_DELAY`] ago according to the system time; the users one is following, and the users they're following, are recorded locally. /// Blocked users are not recorded. pub async fn refresh_users(&self) -> miette::Result<()> { @@ -629,61 +405,6 @@ impl OkuFs { )) } - /// Join a swarm to fetch the latest version of an OkuNet post. - /// - /// # Arguments - /// - /// * `author_id` - The authorship ID of the post's author. - /// - /// * `path` - The path to the post in the author's home replica. - /// - /// # Returns - /// - /// The requested OkuNet post. - pub async fn fetch_post(&self, author_id: AuthorId, path: PathBuf) -> miette::Result { - let ticket = self - .resolve_author_id(author_id) - .await - .map_err(|e| miette::miette!("{}", e))?; - let namespace_id = ticket.capability.id(); - match self - .fetch_file_with_ticket(&ticket, path.clone(), Some(home_replica_filters())) - .await - { - Ok(bytes) => { - let note = toml::from_str::(String::from_utf8_lossy(&bytes).as_ref()) - .into_diagnostic()?; - Ok(OkuPost { - entry: self.get_entry(namespace_id, path).await?, - note, - }) - } - Err(e) => Err(miette::miette!("{}", e)), - } - } - - /// Retrieves an OkuNet post from the database, or from the mainline DHT if not found locally. - /// - /// # Arguments - /// - /// * `author_id` - The authorship ID of the post's author. - /// - /// * `path` - The path to the post in the author's home replica. - /// - /// # Returns - /// - /// The requested OkuNet post. - pub async fn get_or_fetch_post( - &self, - author_id: AuthorId, - path: PathBuf, - ) -> miette::Result { - match DATABASE.get_post(author_id, path.clone()).ok().flatten() { - Some(post) => Ok(post), - None => self.fetch_post(author_id, path).await, - } - } - /// Join a swarm to fetch the latest version of a home replica and obtain the OkuNet identity within it. /// /// # Arguments diff --git a/src/fs/replica.rs b/src/fs/replica.rs index 29b1597..e2fd494 100644 --- a/src/fs/replica.rs +++ b/src/fs/replica.rs @@ -16,6 +16,7 @@ use iroh_docs::NamespaceId; use log::{error, info}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use std::path::PathBuf; +use util::{merge_tickets, path_to_entry_prefix}; impl OkuFs { /// Creates a new replica in the file system. diff --git a/src/lib.rs b/src/lib.rs index 8b1f045..e448fed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![doc = include_str!("../README.md")] -// #![feature(doc_auto_cfg)] +#![feature(doc_auto_cfg)] +#![feature(trait_upcasting)] #![warn(missing_docs)] /// Configuration of an Oku file system node.