Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Reorganize rust llmchat and UniFFI bindings

Prateek Sunal437bc3c54b24
diff --git a/.gitignore b/.gitignore
index 6714756010..66853ef8de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,7 +25,7 @@ target/
# Generated native bindings / binaries (regenerate locally)
mobile/native/android/apps/ensu/crypto-auth-core/src/main/jniLibs/
-mobile/native/android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/ensu_uniffi.kt
+mobile/native/android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/core_uniffi.kt
mobile/native/android/packages/rust/.gradle/
mobile/native/android/packages/rust/src/main/jniLibs/
mobile/native/android/packages/rust/src/main/kotlin/io/ente/labs/inference_rs/inference_rs_uniffi.kt
diff --git a/mobile/native/android/apps/ensu/README.md b/mobile/native/android/apps/ensu/README.md
index a61ad0e87c..cfc5d3b1d6 100644
--- a/mobile/native/android/apps/ensu/README.md
+++ b/mobile/native/android/apps/ensu/README.md
@@ -22,11 +22,11 @@ cd mobile/native/android/packages/rust/tool
This script produces the JNI `.so` artifacts in `android/packages/rust/src/main/jniLibs/`.
The UniFFI Kotlin bindings are generated separately into:
-- `android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/ensu_uniffi.kt`
+- `android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/core_uniffi.kt`
- `android/packages/rust/src/main/kotlin/io/ente/labs/*/*_uniffi.kt`
These generated files are gitignored. If bindings are missing, rebuild the corresponding
-`rust/*_uniffi` crate(s) and run `uniffi-bindgen generate` for Kotlin (see each crate’s
+`rust/uniffi/*` and `rust/llmchat/uniffi/*` crates and run `uniffi-bindgen generate` for Kotlin (see each crate’s
`uniffi.toml` for package names).
### 2. Build Debug APK
diff --git a/mobile/native/android/packages/rust/tool/build_android.sh b/mobile/native/android/packages/rust/tool/build_android.sh
index bd0735585b..a08531012e 100755
--- a/mobile/native/android/packages/rust/tool/build_android.sh
+++ b/mobile/native/android/packages/rust/tool/build_android.sh
@@ -3,11 +3,11 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
-INFERENCE_UNIFFI_RUST_DIR="$REPO_ROOT/rust/inference_rs_uniffi"
-CHATDB_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat_db_uniffi"
-CHAT_SYNC_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat_sync_uniffi"
+INFERENCE_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat/uniffi/inference_rs_uniffi"
+CHATDB_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat/uniffi/llmchat_db_uniffi"
+CHAT_SYNC_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat/uniffi/llmchat_sync_uniffi"
# Patch llama.cpp mtmd sources so mmproj models load correctly.
-PATCH_SCRIPT="$REPO_ROOT/rust/inference_rs/tool/patch_llama_mtmd.sh"
+PATCH_SCRIPT="$REPO_ROOT/rust/llmchat/inference/tool/patch_llama_mtmd.sh"
APPLY_LLAMA_MTMD_PATCH="${APPLY_LLAMA_MTMD_PATCH:-1}"
OUT_DIR="$ROOT/src/main/jniLibs"
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}"
diff --git a/mobile/native/darwin/Apps/ensu/README.md b/mobile/native/darwin/Apps/ensu/README.md
index 46fca1325f..e6b183a665 100644
--- a/mobile/native/darwin/Apps/ensu/README.md
+++ b/mobile/native/darwin/Apps/ensu/README.md
@@ -14,7 +14,7 @@ All commands below assume you run them from `darwin/Apps/ensu`.
The Xcode build script (`scripts/build-rust.sh`) builds Rust static libs, but it does
not regenerate the Swift bindings. If bindings are missing, build the corresponding
-`rust/*_uniffi` crate and run `uniffi-bindgen generate` to output into the paths above.
+`rust/uniffi/*` or `rust/llmchat/uniffi/*` crate and run `uniffi-bindgen generate` to output into the paths above.
`../Packages/Rust/tool/generate_bindings.sh` and `../Packages/Rust/tool/build_xcframework.sh`
handle the InferenceRS bindings and xcframework.
diff --git a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
index 07658e5fb3..93fceef9d4 100644
--- a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
+++ b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
@@ -133,7 +133,7 @@
isa = PBXNativeTarget;
buildConfigurationList = DA72BC872E5F87A100D128FF /* Build configuration list for PBXNativeTarget "ensu" */;
buildPhases = (
- CC142736A470612F436ECF8E /* Build Rust (ensu_uniffi) */,
+ CC142736A470612F436ECF8E /* Build Rust (core_uniffi) */,
DA72BC5D2E5F87A000D128FF /* Sources */,
DA72BC5E2E5F87A000D128FF /* Frameworks */,
DA72BC5F2E5F87A000D128FF /* Resources */,
@@ -161,7 +161,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 9C5C5C140967470293DCAAF2 /* Build configuration list for PBXNativeTarget "ensu-macos" */;
buildPhases = (
- 25484CE4873ED7217FB27990 /* Build Rust (ensu_uniffi) */,
+ 25484CE4873ED7217FB27990 /* Build Rust (core_uniffi) */,
BB83D829CC14232E7E8BDD51 /* Sources */,
0BCBB02794980AFFDC386B69 /* Frameworks */,
1FDE2B245F9DADEF5E026D0B /* Resources */,
@@ -310,16 +310,16 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
- CC142736A470612F436ECF8E /* Build Rust (ensu_uniffi) */ = {
+ CC142736A470612F436ECF8E /* Build Rust (core_uniffi) */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
- name = "Build Rust (ensu_uniffi)";
+ name = "Build Rust (core_uniffi)";
outputPaths = (
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
@@ -327,16 +327,16 @@
shellPath = /bin/sh;
shellScript = "ENTE_API_ENDPOINT=\"${ENTE_API_ENDPOINT}\" \"${SRCROOT}/scripts/build-rust.sh\"\n";
};
- 25484CE4873ED7217FB27990 /* Build Rust (ensu_uniffi) */ = {
+ 25484CE4873ED7217FB27990 /* Build Rust (core_uniffi) */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
- name = "Build Rust (ensu_uniffi)";
+ name = "Build Rust (core_uniffi)";
outputPaths = (
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
@@ -544,14 +544,14 @@
OTHER_LDFLAGS = (
"$(inherited)",
"-force_load",
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
"-Xcc",
- "-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/core_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
"-Xcc",
@@ -605,14 +605,14 @@
OTHER_LDFLAGS = (
"$(inherited)",
"-force_load",
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
"-Xcc",
- "-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/core_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
"-Xcc",
@@ -664,14 +664,14 @@
"-framework",
"SystemConfiguration",
"-force_load",
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
"-Xcc",
- "-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/core_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
"-Xcc",
@@ -724,14 +724,14 @@
"-framework",
"SystemConfiguration",
"-force_load",
- "$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libcore_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
"-Xcc",
- "-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/core_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
"-Xcc",
diff --git a/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh b/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
index 152b32ce81..a99e111efe 100755
--- a/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
+++ b/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
@@ -4,7 +4,7 @@ set -euo pipefail
# Build the UniFFI Rust static libraries for the current Xcode build platform.
#
# Outputs universal static libraries at:
-# $TARGET_TEMP_DIR/ensu_rust/libensu_uniffi.a
+# $TARGET_TEMP_DIR/ensu_rust/libcore_uniffi.a
# $TARGET_TEMP_DIR/ensu_rust/libllmchat_db_uniffi.a
# $TARGET_TEMP_DIR/ensu_rust/libllmchat_sync_uniffi.a
@@ -126,9 +126,9 @@ HOST_SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
export SDKROOT="${HOST_SDKROOT}"
build_crate_universal() {
- crate_name="$1" # e.g. ensu_uniffi
+ crate_name="$1" # e.g. core_uniffi
crate_dir="$2" # absolute path
- lib_name="$3" # e.g. libensu_uniffi.a
+ lib_name="$3" # e.g. libcore_uniffi.a
echo "πŸ”§ Building ${crate_name} β†’ ${lib_name}"
@@ -189,6 +189,6 @@ build_crate_universal() {
echo "βœ… Built ${universal_lib}"
}
-build_crate_universal "ensu_uniffi" "${REPO_ROOT}/rust/ensu_uniffi" "libensu_uniffi.a"
-build_crate_universal "llmchat_db_uniffi" "${REPO_ROOT}/rust/llmchat_db_uniffi" "libllmchat_db_uniffi.a"
-build_crate_universal "llmchat_sync_uniffi" "${REPO_ROOT}/rust/llmchat_sync_uniffi" "libllmchat_sync_uniffi.a"
+build_crate_universal "core_uniffi" "${REPO_ROOT}/rust/uniffi/core_uniffi" "libcore_uniffi.a"
+build_crate_universal "llmchat_db_uniffi" "${REPO_ROOT}/rust/llmchat/uniffi/llmchat_db_uniffi" "libllmchat_db_uniffi.a"
+build_crate_universal "llmchat_sync_uniffi" "${REPO_ROOT}/rust/llmchat/uniffi/llmchat_sync_uniffi" "libllmchat_sync_uniffi.a"
diff --git a/mobile/native/darwin/Packages/Rust/README.md b/mobile/native/darwin/Packages/Rust/README.md
index 9262024546..af3e32e77a 100644
--- a/mobile/native/darwin/Packages/Rust/README.md
+++ b/mobile/native/darwin/Packages/Rust/README.md
@@ -1,6 +1,6 @@
# InferenceRS (Swift)
-Swift bindings generated via UniFFI for the Rust core in `../rust`.
+Swift bindings generated via UniFFI for the Rust core in `rust/llmchat/inference`.
## Generate bindings
diff --git a/mobile/native/darwin/Packages/Rust/rust/Cargo.toml b/mobile/native/darwin/Packages/Rust/rust/Cargo.toml
index c27283923d..ecbcb6b423 100644
--- a/mobile/native/darwin/Packages/Rust/rust/Cargo.toml
+++ b/mobile/native/darwin/Packages/Rust/rust/Cargo.toml
@@ -8,7 +8,7 @@ name = "inference_rs_uniffi"
crate-type = ["staticlib", "cdylib"]
[dependencies]
-inference_rs = { path = "../../../../../../rust/inference_rs" }
+inference_rs = { path = "../../../../../../rust/llmchat/inference" }
serde = { version = "1", features = ["derive"] }
thiserror = "1"
uniffi = { version = "0.31.0" }
diff --git a/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh b/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
index 48710938ab..2c5f72ba12 100755
--- a/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
+++ b/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
@@ -4,7 +4,7 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
RUST_DIR="$ROOT/rust"
-CORE_ROOT="$REPO_ROOT/rust/inference_rs"
+CORE_ROOT="$REPO_ROOT/rust/llmchat/inference"
PATCH_SCRIPT="$CORE_ROOT/tool/patch_llama_mtmd.sh"
APPLY_LLAMA_MTMD_PATCH="${APPLY_LLAMA_MTMD_PATCH:-1}"
LIB_NAME="libinference_rs_uniffi.a"
diff --git a/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh b/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
index b06200f41f..3b499a6ec8 100755
--- a/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
+++ b/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
@@ -4,7 +4,7 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
RUST_DIR="$ROOT/rust"
-CORE_ROOT="$REPO_ROOT/rust/inference_rs"
+CORE_ROOT="$REPO_ROOT/rust/llmchat/inference"
PATCH_SCRIPT="$CORE_ROOT/tool/patch_llama_mtmd.sh"
APPLY_LLAMA_MTMD_PATCH="${APPLY_LLAMA_MTMD_PATCH:-1}"
OUT_DIR="$ROOT/Sources/InferenceRS"
diff --git a/rust/README.md b/rust/README.md
index 5cdbc1f742..b6ae216059 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -41,55 +41,62 @@
## Contents (this repo)
- `rust/core/` (`ente-core`) - shared, pure Rust code used by clients (crypto + auth, plus small HTTP/URL helpers).
-- `rust/cli/` - Rust CLI (work-in-progress).
+- `rust/cli/` (`ente-rs`) - Rust CLI.
+- `rust/llmchat/` - LLM chat stack (see `rust/llmchat/README.md`).
## Directory Structure
```
rust/
-β”œβ”€β”€ cli/ # CLI package
+β”œβ”€β”€ cli/ # CLI package (ente-rs)
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ └── main.rs
β”‚ β”œβ”€β”€ Cargo.toml
β”‚ └── Cargo.lock
β”‚
-└── core/ # Pure Rust shared logic
- β”œβ”€β”€ src/
- β”‚ β”œβ”€β”€ lib.rs
- β”‚ β”œβ”€β”€ crypto/
- β”‚ └── auth/
- β”œβ”€β”€ docs/
- β”‚ β”œβ”€β”€ crypto.md
- β”‚ └── auth.md
- └── Cargo.toml # crate name: ente-core
-
-web/packages/wasm/ # WASM bindings (lives in web workspace)
+β”œβ”€β”€ core/ # Pure Rust shared logic (ente-core)
+β”‚ β”œβ”€β”€ src/
+β”‚ β”‚ β”œβ”€β”€ lib.rs
+β”‚ β”‚ β”œβ”€β”€ crypto/
+β”‚ β”‚ └── auth/
+β”‚ β”œβ”€β”€ docs/
+β”‚ β”‚ β”œβ”€β”€ crypto.md
+β”‚ β”‚ └── auth.md
+β”‚ └── Cargo.toml
+β”‚
+└── llmchat/ # LLM chat stack (see rust/llmchat/README.md)
+
+rust/uniffi/ # UniFFI bindings for core crypto/auth
+β”œβ”€β”€ core_uniffi/
+
+web/packages/wasm/ # WASM bindings (lives in web workspace)
β”œβ”€β”€ src/
-β”‚ └── lib.rs # #[wasm_bindgen] wrappers around ente-core
-β”œβ”€β”€ Cargo.toml # crate name: ente-wasm
-β”œβ”€β”€ package.json # includes wasm-pack as devDependency
-└── pkg/ # generated output (gitignored)
+β”‚ └── lib.rs # #[wasm_bindgen] wrappers around ente-core
+β”œβ”€β”€ Cargo.toml # crate name: ente-wasm
+β”œβ”€β”€ package.json # includes wasm-pack as devDependency
+└── pkg/ # generated output (gitignored)
-mobile/packages/rust/ # Shared FRB bindings for all mobile apps
+mobile/packages/rust/ # Shared FRB bindings for all mobile apps
β”œβ”€β”€ rust/
β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ └── api/ # #[frb] wrappers around ente-core
-β”‚ └── Cargo.toml # crate name: ente_rust
-β”œβ”€β”€ lib/ # Generated Dart bindings
-└── pubspec.yaml # Flutter plugin package
+β”‚ β”‚ └── api/ # #[frb] wrappers around ente-core
+β”‚ └── Cargo.toml # crate name: ente_rust
+β”œβ”€β”€ lib/ # Generated Dart bindings
+└── pubspec.yaml # Flutter plugin package
-mobile/apps/photos/rust/ # Photos app-specific FRB bindings
+mobile/apps/photos/rust/ # Photos app-specific FRB bindings
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ lib.rs
-β”‚ └── api/ # #[frb] app-specific code (usearch, ML)
+β”‚ └── api/ # #[frb] app-specific code (usearch, ML)
β”‚ └── *.rs
-└── Cargo.toml # crate name: ente_photos_rust
+└── Cargo.toml # crate name: ente_photos_rust
```
**Crates:**
- `ente-core` - shared business logic (pure Rust, no FFI)
- Docs: `rust/core/docs/crypto.md`, `rust/core/docs/auth.md`
+- `ente-rs` - CLI binary
- `ente-wasm` - wasm-bindgen wrappers for web
- `ente_rust` - shared FRB wrappers for mobile (Dart class: `EnteRust`)
- `ente_photos_rust` - Photos app-specific FRB (Dart class: `EntePhotosRust`)
diff --git a/rust/ensu_uniffi/build.rs b/rust/ensu_uniffi/build.rs
deleted file mode 100644
index 7fdeb625f3..0000000000
--- a/rust/ensu_uniffi/build.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- uniffi::generate_scaffolding("./src/ensu_uniffi.udl").unwrap();
-}
diff --git a/rust/llmchat/README.md b/rust/llmchat/README.md
new file mode 100644
index 0000000000..1782286f0d
--- /dev/null
+++ b/rust/llmchat/README.md
@@ -0,0 +1,17 @@
+# LLM Chat (Rust)
+
+This directory contains the Rust crates for the Ensu LLM chat stack.
+
+## Crates
+
+- `db/` (`llmchat-db`) β€” local chat database.
+- `sync/` (`llmchat-sync`) β€” sync engine (uses `llmchat-db`).
+- `inference/` (`inference_rs`) β€” inference runtime.
+
+## UniFFI bindings
+
+UniFFI wrapper crates live under `uniffi/`:
+
+- `uniffi/llmchat_db_uniffi`
+- `uniffi/llmchat_sync_uniffi`
+- `uniffi/inference_rs_uniffi`
diff --git a/rust/llmchat-db/Cargo.lock b/rust/llmchat/db/Cargo.lock
similarity index 100%
rename from rust/llmchat-db/Cargo.lock
rename to rust/llmchat/db/Cargo.lock
diff --git a/rust/llmchat-db/Cargo.toml b/rust/llmchat/db/Cargo.toml
similarity index 92%
rename from rust/llmchat-db/Cargo.toml
rename to rust/llmchat/db/Cargo.toml
index c27112f66e..6f52b2b850 100644
--- a/rust/llmchat-db/Cargo.toml
+++ b/rust/llmchat/db/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
-ente-core = { path = "../core" }
+ente-core = { path = "../../core" }
rusqlite = { version = "0.38", features = ["bundled"], optional = true }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
diff --git a/rust/llmchat-db/src/attachments_db.rs b/rust/llmchat/db/src/attachments_db.rs
similarity index 100%
rename from rust/llmchat-db/src/attachments_db.rs
rename to rust/llmchat/db/src/attachments_db.rs
diff --git a/rust/llmchat-db/src/attachments_migrations.rs b/rust/llmchat/db/src/attachments_migrations.rs
similarity index 100%
rename from rust/llmchat-db/src/attachments_migrations.rs
rename to rust/llmchat/db/src/attachments_migrations.rs
diff --git a/rust/llmchat-db/src/attachments_schema.rs b/rust/llmchat/db/src/attachments_schema.rs
similarity index 100%
rename from rust/llmchat-db/src/attachments_schema.rs
rename to rust/llmchat/db/src/attachments_schema.rs
diff --git a/rust/llmchat-db/src/backend/mod.rs b/rust/llmchat/db/src/backend/mod.rs
similarity index 100%
rename from rust/llmchat-db/src/backend/mod.rs
rename to rust/llmchat/db/src/backend/mod.rs
diff --git a/rust/llmchat-db/src/backend/sqlite.rs b/rust/llmchat/db/src/backend/sqlite.rs
similarity index 100%
rename from rust/llmchat-db/src/backend/sqlite.rs
rename to rust/llmchat/db/src/backend/sqlite.rs
diff --git a/rust/llmchat-db/src/crypto.rs b/rust/llmchat/db/src/crypto.rs
similarity index 100%
rename from rust/llmchat-db/src/crypto.rs
rename to rust/llmchat/db/src/crypto.rs
diff --git a/rust/llmchat-db/src/db.rs b/rust/llmchat/db/src/db.rs
similarity index 100%
rename from rust/llmchat-db/src/db.rs
rename to rust/llmchat/db/src/db.rs
diff --git a/rust/llmchat-db/src/error.rs b/rust/llmchat/db/src/error.rs
similarity index 100%
rename from rust/llmchat-db/src/error.rs
rename to rust/llmchat/db/src/error.rs
diff --git a/rust/llmchat-db/src/lib.rs b/rust/llmchat/db/src/lib.rs
similarity index 100%
rename from rust/llmchat-db/src/lib.rs
rename to rust/llmchat/db/src/lib.rs
diff --git a/rust/llmchat-db/src/llmchat.rs b/rust/llmchat/db/src/llmchat.rs
similarity index 100%
rename from rust/llmchat-db/src/llmchat.rs
rename to rust/llmchat/db/src/llmchat.rs
diff --git a/rust/llmchat-db/src/migrations.rs b/rust/llmchat/db/src/migrations.rs
similarity index 100%
rename from rust/llmchat-db/src/migrations.rs
rename to rust/llmchat/db/src/migrations.rs
diff --git a/rust/llmchat-db/src/models.rs b/rust/llmchat/db/src/models.rs
similarity index 100%
rename from rust/llmchat-db/src/models.rs
rename to rust/llmchat/db/src/models.rs
diff --git a/rust/llmchat-db/src/schema.rs b/rust/llmchat/db/src/schema.rs
similarity index 100%
rename from rust/llmchat-db/src/schema.rs
rename to rust/llmchat/db/src/schema.rs
diff --git a/rust/llmchat-db/src/traits.rs b/rust/llmchat/db/src/traits.rs
similarity index 100%
rename from rust/llmchat-db/src/traits.rs
rename to rust/llmchat/db/src/traits.rs
diff --git a/rust/inference_rs/Cargo.lock b/rust/llmchat/inference/Cargo.lock
similarity index 100%
rename from rust/inference_rs/Cargo.lock
rename to rust/llmchat/inference/Cargo.lock
diff --git a/rust/inference_rs/Cargo.toml b/rust/llmchat/inference/Cargo.toml
similarity index 100%
rename from rust/inference_rs/Cargo.toml
rename to rust/llmchat/inference/Cargo.toml
diff --git a/rust/inference_rs/src/api.rs b/rust/llmchat/inference/src/api.rs
similarity index 100%
rename from rust/inference_rs/src/api.rs
rename to rust/llmchat/inference/src/api.rs
diff --git a/rust/inference_rs/src/capi.rs b/rust/llmchat/inference/src/capi.rs
similarity index 100%
rename from rust/inference_rs/src/capi.rs
rename to rust/llmchat/inference/src/capi.rs
diff --git a/rust/inference_rs/src/lib.rs b/rust/llmchat/inference/src/lib.rs
similarity index 100%
rename from rust/inference_rs/src/lib.rs
rename to rust/llmchat/inference/src/lib.rs
diff --git a/rust/inference_rs/tool/patch_llama_mtmd.sh b/rust/llmchat/inference/tool/patch_llama_mtmd.sh
similarity index 100%
rename from rust/inference_rs/tool/patch_llama_mtmd.sh
rename to rust/llmchat/inference/tool/patch_llama_mtmd.sh
diff --git a/rust/llmchat-sync/Cargo.lock b/rust/llmchat/sync/Cargo.lock
similarity index 100%
rename from rust/llmchat-sync/Cargo.lock
rename to rust/llmchat/sync/Cargo.lock
diff --git a/rust/llmchat-sync/Cargo.toml b/rust/llmchat/sync/Cargo.toml
similarity index 85%
rename from rust/llmchat-sync/Cargo.toml
rename to rust/llmchat/sync/Cargo.toml
index 781b8d0f00..a95c2aef8b 100644
--- a/rust/llmchat-sync/Cargo.toml
+++ b/rust/llmchat/sync/Cargo.toml
@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2024"
[dependencies]
-llmchat-db = { path = "../llmchat-db" }
-ente-core = { path = "../core" }
+llmchat-db = { path = "../db" }
+ente-core = { path = "../../core" }
reqwest = { version = "0.12", default-features = false, features = ["json", "blocking", "http2", "charset", "system-proxy", "rustls-tls-native-roots"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
diff --git a/rust/llmchat-sync/src/conflict.rs b/rust/llmchat/sync/src/conflict.rs
similarity index 100%
rename from rust/llmchat-sync/src/conflict.rs
rename to rust/llmchat/sync/src/conflict.rs
diff --git a/rust/llmchat-sync/src/crypto.rs b/rust/llmchat/sync/src/crypto.rs
similarity index 100%
rename from rust/llmchat-sync/src/crypto.rs
rename to rust/llmchat/sync/src/crypto.rs
diff --git a/rust/llmchat-sync/src/diff_cursor.rs b/rust/llmchat/sync/src/diff_cursor.rs
similarity index 100%
rename from rust/llmchat-sync/src/diff_cursor.rs
rename to rust/llmchat/sync/src/diff_cursor.rs
diff --git a/rust/llmchat-sync/src/errors.rs b/rust/llmchat/sync/src/errors.rs
similarity index 100%
rename from rust/llmchat-sync/src/errors.rs
rename to rust/llmchat/sync/src/errors.rs
diff --git a/rust/llmchat-sync/src/http.rs b/rust/llmchat/sync/src/http.rs
similarity index 100%
rename from rust/llmchat-sync/src/http.rs
rename to rust/llmchat/sync/src/http.rs
diff --git a/rust/llmchat-sync/src/lib.rs b/rust/llmchat/sync/src/lib.rs
similarity index 100%
rename from rust/llmchat-sync/src/lib.rs
rename to rust/llmchat/sync/src/lib.rs
diff --git a/rust/llmchat-sync/src/models.rs b/rust/llmchat/sync/src/models.rs
similarity index 100%
rename from rust/llmchat-sync/src/models.rs
rename to rust/llmchat/sync/src/models.rs
diff --git a/rust/llmchat-sync/src/sync.rs b/rust/llmchat/sync/src/sync.rs
similarity index 100%
rename from rust/llmchat-sync/src/sync.rs
rename to rust/llmchat/sync/src/sync.rs
diff --git a/rust/inference_rs_uniffi/Cargo.lock b/rust/llmchat/uniffi/inference_rs_uniffi/Cargo.lock
similarity index 100%
rename from rust/inference_rs_uniffi/Cargo.lock
rename to rust/llmchat/uniffi/inference_rs_uniffi/Cargo.lock
diff --git a/rust/inference_rs_uniffi/Cargo.toml b/rust/llmchat/uniffi/inference_rs_uniffi/Cargo.toml
similarity index 85%
rename from rust/inference_rs_uniffi/Cargo.toml
rename to rust/llmchat/uniffi/inference_rs_uniffi/Cargo.toml
index c3921f47bc..ee3ec2eab1 100644
--- a/rust/inference_rs_uniffi/Cargo.toml
+++ b/rust/llmchat/uniffi/inference_rs_uniffi/Cargo.toml
@@ -8,7 +8,7 @@ name = "inference_rs_uniffi"
crate-type = ["staticlib", "cdylib"]
[dependencies]
-inference_rs = { path = "../inference_rs" }
+inference_rs = { path = "../../inference" }
serde = { version = "1", features = ["derive"] }
thiserror = "1"
uniffi = { version = "0.31.0" }
diff --git a/rust/inference_rs_uniffi/src/api.rs b/rust/llmchat/uniffi/inference_rs_uniffi/src/api.rs
similarity index 100%
rename from rust/inference_rs_uniffi/src/api.rs
rename to rust/llmchat/uniffi/inference_rs_uniffi/src/api.rs
diff --git a/rust/inference_rs_uniffi/src/lib.rs b/rust/llmchat/uniffi/inference_rs_uniffi/src/lib.rs
similarity index 100%
rename from rust/inference_rs_uniffi/src/lib.rs
rename to rust/llmchat/uniffi/inference_rs_uniffi/src/lib.rs
diff --git a/rust/inference_rs_uniffi/uniffi.toml b/rust/llmchat/uniffi/inference_rs_uniffi/uniffi.toml
similarity index 100%
rename from rust/inference_rs_uniffi/uniffi.toml
rename to rust/llmchat/uniffi/inference_rs_uniffi/uniffi.toml
diff --git a/rust/llmchat_db_uniffi/Cargo.lock b/rust/llmchat/uniffi/llmchat_db_uniffi/Cargo.lock
similarity index 100%
rename from rust/llmchat_db_uniffi/Cargo.lock
rename to rust/llmchat/uniffi/llmchat_db_uniffi/Cargo.lock
diff --git a/rust/llmchat_db_uniffi/Cargo.toml b/rust/llmchat/uniffi/llmchat_db_uniffi/Cargo.toml
similarity index 87%
rename from rust/llmchat_db_uniffi/Cargo.toml
rename to rust/llmchat/uniffi/llmchat_db_uniffi/Cargo.toml
index 440ef828ca..bd2ffcc380 100644
--- a/rust/llmchat_db_uniffi/Cargo.toml
+++ b/rust/llmchat/uniffi/llmchat_db_uniffi/Cargo.toml
@@ -8,7 +8,7 @@ name = "llmchat_db_uniffi"
crate-type = ["staticlib", "cdylib"]
[dependencies]
-llmchat-db = { path = "../llmchat-db" }
+llmchat-db = { path = "../../db" }
serde = { version = "1", features = ["derive"] }
thiserror = "2"
uniffi = { version = "0.31.0" }
diff --git a/rust/llmchat_db_uniffi/build.rs b/rust/llmchat/uniffi/llmchat_db_uniffi/build.rs
similarity index 100%
rename from rust/llmchat_db_uniffi/build.rs
rename to rust/llmchat/uniffi/llmchat_db_uniffi/build.rs
diff --git a/rust/llmchat_db_uniffi/src/api.rs b/rust/llmchat/uniffi/llmchat_db_uniffi/src/api.rs
similarity index 100%
rename from rust/llmchat_db_uniffi/src/api.rs
rename to rust/llmchat/uniffi/llmchat_db_uniffi/src/api.rs
diff --git a/rust/llmchat_db_uniffi/src/api.udl b/rust/llmchat/uniffi/llmchat_db_uniffi/src/api.udl
similarity index 100%
rename from rust/llmchat_db_uniffi/src/api.udl
rename to rust/llmchat/uniffi/llmchat_db_uniffi/src/api.udl
diff --git a/rust/llmchat_db_uniffi/src/lib.rs b/rust/llmchat/uniffi/llmchat_db_uniffi/src/lib.rs
similarity index 100%
rename from rust/llmchat_db_uniffi/src/lib.rs
rename to rust/llmchat/uniffi/llmchat_db_uniffi/src/lib.rs
diff --git a/rust/llmchat_db_uniffi/uniffi.toml b/rust/llmchat/uniffi/llmchat_db_uniffi/uniffi.toml
similarity index 100%
rename from rust/llmchat_db_uniffi/uniffi.toml
rename to rust/llmchat/uniffi/llmchat_db_uniffi/uniffi.toml
diff --git a/rust/llmchat_sync_uniffi/Cargo.lock b/rust/llmchat/uniffi/llmchat_sync_uniffi/Cargo.lock
similarity index 100%
rename from rust/llmchat_sync_uniffi/Cargo.lock
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/Cargo.lock
diff --git a/rust/llmchat_sync_uniffi/Cargo.toml b/rust/llmchat/uniffi/llmchat_sync_uniffi/Cargo.toml
similarity index 86%
rename from rust/llmchat_sync_uniffi/Cargo.toml
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/Cargo.toml
index 684f7e405c..145636a2bf 100644
--- a/rust/llmchat_sync_uniffi/Cargo.toml
+++ b/rust/llmchat/uniffi/llmchat_sync_uniffi/Cargo.toml
@@ -8,7 +8,7 @@ name = "llmchat_sync_uniffi"
crate-type = ["staticlib", "cdylib"]
[dependencies]
-llmchat-sync = { path = "../llmchat-sync" }
+llmchat-sync = { path = "../../sync" }
serde = { version = "1", features = ["derive"] }
thiserror = "2"
uniffi = { version = "0.31.0" }
diff --git a/rust/llmchat_sync_uniffi/build.rs b/rust/llmchat/uniffi/llmchat_sync_uniffi/build.rs
similarity index 100%
rename from rust/llmchat_sync_uniffi/build.rs
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/build.rs
diff --git a/rust/llmchat_sync_uniffi/src/api.rs b/rust/llmchat/uniffi/llmchat_sync_uniffi/src/api.rs
similarity index 100%
rename from rust/llmchat_sync_uniffi/src/api.rs
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/src/api.rs
diff --git a/rust/llmchat_sync_uniffi/src/api.udl b/rust/llmchat/uniffi/llmchat_sync_uniffi/src/api.udl
similarity index 100%
rename from rust/llmchat_sync_uniffi/src/api.udl
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/src/api.udl
diff --git a/rust/llmchat_sync_uniffi/src/lib.rs b/rust/llmchat/uniffi/llmchat_sync_uniffi/src/lib.rs
similarity index 100%
rename from rust/llmchat_sync_uniffi/src/lib.rs
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/src/lib.rs
diff --git a/rust/llmchat_sync_uniffi/uniffi.toml b/rust/llmchat/uniffi/llmchat_sync_uniffi/uniffi.toml
similarity index 100%
rename from rust/llmchat_sync_uniffi/uniffi.toml
rename to rust/llmchat/uniffi/llmchat_sync_uniffi/uniffi.toml
diff --git a/rust/ensu_uniffi/.gitignore b/rust/uniffi/core_uniffi/.gitignore
similarity index 100%
rename from rust/ensu_uniffi/.gitignore
rename to rust/uniffi/core_uniffi/.gitignore
diff --git a/rust/ensu_uniffi/Cargo.lock b/rust/uniffi/core_uniffi/Cargo.lock
similarity index 99%
rename from rust/ensu_uniffi/Cargo.lock
rename to rust/uniffi/core_uniffi/Cargo.lock
index f9c1bf1529..134eef3972 100644
--- a/rust/ensu_uniffi/Cargo.lock
+++ b/rust/uniffi/core_uniffi/Cargo.lock
@@ -281,6 +281,17 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+[[package]]
+name = "core_uniffi"
+version = "0.1.0"
+dependencies = [
+ "base64",
+ "ente-core",
+ "once_cell",
+ "thiserror 1.0.69",
+ "uniffi",
+]
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -372,17 +383,6 @@ dependencies = [
"cfg-if",
]
-[[package]]
-name = "ensu_uniffi"
-version = "0.1.0"
-dependencies = [
- "base64",
- "ente-core",
- "once_cell",
- "thiserror 1.0.69",
- "uniffi",
-]
-
[[package]]
name = "ente-core"
version = "0.0.1"
diff --git a/rust/ensu_uniffi/Cargo.toml b/rust/uniffi/core_uniffi/Cargo.toml
similarity index 72%
rename from rust/ensu_uniffi/Cargo.toml
rename to rust/uniffi/core_uniffi/Cargo.toml
index c48838f749..e4ece8704b 100644
--- a/rust/ensu_uniffi/Cargo.toml
+++ b/rust/uniffi/core_uniffi/Cargo.toml
@@ -1,10 +1,10 @@
[package]
-name = "ensu_uniffi"
+name = "core_uniffi"
version = "0.1.0"
edition = "2021"
[lib]
-name = "ensu_uniffi"
+name = "core_uniffi"
crate-type = ["cdylib", "staticlib"]
[dependencies]
@@ -12,7 +12,7 @@ base64 = "0.22"
once_cell = "1.19"
thiserror = "1.0"
uniffi = "0.31.0"
-ente-core = { path = "../core", features = ["srp"] }
+ente-core = { path = "../../core", features = ["srp"] }
[build-dependencies]
uniffi = { version = "0.31.0", features = ["build"] }
diff --git a/rust/uniffi/core_uniffi/build.rs b/rust/uniffi/core_uniffi/build.rs
new file mode 100644
index 0000000000..374ce75562
--- /dev/null
+++ b/rust/uniffi/core_uniffi/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+ uniffi::generate_scaffolding("./src/core_uniffi.udl").unwrap();
+}
diff --git a/rust/ensu_uniffi/src/ensu_uniffi.udl b/rust/uniffi/core_uniffi/src/core_uniffi.udl
similarity index 98%
rename from rust/ensu_uniffi/src/ensu_uniffi.udl
rename to rust/uniffi/core_uniffi/src/core_uniffi.udl
index fd3ad7c86a..e957181d80 100644
--- a/rust/ensu_uniffi/src/ensu_uniffi.udl
+++ b/rust/uniffi/core_uniffi/src/core_uniffi.udl
@@ -37,7 +37,7 @@ interface EnsuError {
Message(string message);
};
-namespace ensu_uniffi {
+namespace core_uniffi {
[Throws=EnsuError]
void init_crypto();
diff --git a/rust/ensu_uniffi/src/lib.rs b/rust/uniffi/core_uniffi/src/lib.rs
similarity index 99%
rename from rust/ensu_uniffi/src/lib.rs
rename to rust/uniffi/core_uniffi/src/lib.rs
index 24fe6fdc28..2e92e84480 100644
--- a/rust/ensu_uniffi/src/lib.rs
+++ b/rust/uniffi/core_uniffi/src/lib.rs
@@ -7,7 +7,7 @@ use std::sync::{Mutex, MutexGuard};
use ente_core::{auth, crypto};
-uniffi::include_scaffolding!("ensu_uniffi");
+uniffi::include_scaffolding!("core_uniffi");
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AuthSecrets {
diff --git a/rust/ensu_uniffi/uniffi.toml b/rust/uniffi/core_uniffi/uniffi.toml
similarity index 100%
rename from rust/ensu_uniffi/uniffi.toml
rename to rust/uniffi/core_uniffi/uniffi.toml