Skip to content

armgit / ente

Public Imported from GitHub
0

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

Clean up Rust workspace reorg

Manav Rathib17cefd6abe7
diff --git a/.github/workflows/locker-lint.yml b/.github/workflows/locker-lint.yml
index f2eb4f2f8a..c48ffd58a5 100644
--- a/.github/workflows/locker-lint.yml
+++ b/.github/workflows/locker-lint.yml
@@ -9,10 +9,6 @@ on:
- "mobile/packages/legacy/**"
- "mobile/packages/rust/**"
- "mobile/packages/sharing/**"
- - "rust/crates/core/**"
- - "rust/crates/contacts/**"
- - "rust/Cargo.toml"
- - "rust/Cargo.lock"
- ".github/workflows/locker-lint.yml"
- "mobile/scripts/check_source_arb_plurals.rb"
@@ -65,10 +61,6 @@ jobs:
- name: Install Flutter Rust Bridge
run: cargo install flutter_rust_bridge_codegen
- - name: Check Rust API without generated bindings (Core package)
- run: cargo check --locked
- working-directory: mobile/packages/rust/rust
-
- name: Generate Rust bindings (Core package)
run: flutter_rust_bridge_codegen generate
working-directory: mobile/packages/rust
diff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.yml
index 2fa73a308e..308314800d 100644
--- a/.github/workflows/mobile-lint.yml
+++ b/.github/workflows/mobile-lint.yml
@@ -96,16 +96,6 @@ jobs:
- run: flutter pub get --enforce-lockfile
- - name: Check Rust API without generated bindings (ente_rust)
- if: steps.rust_changes.outputs.ente_rust == 'true'
- working-directory: mobile/packages/rust/rust
- run: cargo check --locked
-
- - name: Check Rust API without generated bindings (ente_photos_rust)
- if: steps.rust_changes.outputs.ente_photos_rust == 'true'
- working-directory: mobile/apps/photos/rust
- run: cargo check --locked
-
- name: Install Flutter Rust Bridge
run: cargo install flutter_rust_bridge_codegen
@@ -129,17 +119,17 @@ jobs:
- name: Run clippy (ente_rust)
if: steps.rust_changes.outputs.ente_rust == 'true'
working-directory: mobile/packages/rust/rust
- run: cargo clippy --all-targets --all-features --locked
+ run: cargo clippy --all-targets --all-features
- name: Build (ente_rust)
if: steps.rust_changes.outputs.ente_rust == 'true'
working-directory: mobile/packages/rust/rust
- run: cargo build --features frb-generated --locked
+ run: cargo build
- name: Test (ente_rust)
if: steps.rust_changes.outputs.ente_rust == 'true'
working-directory: mobile/packages/rust/rust
- run: cargo test --features frb-generated --locked
+ run: cargo test
- name: Check formatting (ente_photos_rust)
if: steps.rust_changes.outputs.ente_photos_rust == 'true'
@@ -149,14 +139,14 @@ jobs:
- name: Run clippy (ente_photos_rust)
if: steps.rust_changes.outputs.ente_photos_rust == 'true'
working-directory: mobile/apps/photos/rust
- run: cargo clippy --all-targets --all-features --locked
+ run: cargo clippy --all-targets --all-features
- name: Build (ente_photos_rust)
if: steps.rust_changes.outputs.ente_photos_rust == 'true'
working-directory: mobile/apps/photos/rust
- run: cargo build --features frb-generated --locked
+ run: cargo build
- name: Test (ente_photos_rust)
if: steps.rust_changes.outputs.ente_photos_rust == 'true'
working-directory: mobile/apps/photos/rust
- run: cargo test --features frb-generated --locked
+ run: cargo test
diff --git a/.github/workflows/mobile-packages-lint.yml b/.github/workflows/mobile-packages-lint.yml
index dfc13fc85f..c66861c508 100644
--- a/.github/workflows/mobile-packages-lint.yml
+++ b/.github/workflows/mobile-packages-lint.yml
@@ -1,18 +1,13 @@
name: "Lint (mobile packages)"
on:
- # Run when mobile/packages or shared mobile Rust changes
+ # Run when mobile/packages or shared photos Rust changes
pull_request:
paths:
- "mobile/packages/**"
- "mobile/**/pubspec*.yaml"
- "mobile/**/pubspec.lock"
- "rust/photos/**"
- - "rust/crates/core/**"
- - "rust/crates/contacts/**"
- - "rust/crates/image/**"
- - "rust/Cargo.toml"
- - "rust/Cargo.lock"
- ".github/workflows/mobile-packages-lint.yml"
- "mobile/scripts/check_frozen_pubspecs.rb"
- "mobile/scripts/check_source_arb_plurals.rb"
@@ -53,16 +48,10 @@ jobs:
- 'mobile/packages/rust/**/*.rs'
- 'mobile/packages/rust/**/Cargo.toml'
- 'mobile/packages/rust/**/Cargo.lock'
- - 'mobile/packages/rust/**/cargokit.yaml'
- 'mobile/apps/photos/rust/**/*.rs'
- 'mobile/apps/photos/rust/**/Cargo.toml'
- - 'mobile/apps/photos/rust/**/cargokit.yaml'
- 'rust/photos/**'
- - 'rust/crates/core/**'
- - 'rust/crates/contacts/**'
- - 'rust/crates/image/**'
- - 'rust/Cargo.toml'
- - 'rust/Cargo.lock'
+ - 'rust/crates/core/**/*.rs'
workflow:
- '.github/workflows/mobile-packages-lint.yml'
analysis:
@@ -151,10 +140,6 @@ jobs:
- name: Install Flutter Rust Bridge
run: cargo install flutter_rust_bridge_codegen
- - name: Check Rust API without generated bindings (Core)
- run: cargo check --locked
- working-directory: mobile/packages/rust/rust
-
- name: Generate Rust bindings (Core)
run: flutter_rust_bridge_codegen generate
working-directory: mobile/packages/rust
@@ -297,10 +282,6 @@ jobs:
- name: Install Flutter Rust Bridge
run: cargo install flutter_rust_bridge_codegen
- - name: Check Rust API without generated bindings (Core)
- run: cargo check --locked
- working-directory: mobile/packages/rust/rust
-
- name: Generate Rust bindings (Core)
run: flutter_rust_bridge_codegen generate
working-directory: mobile/packages/rust
@@ -311,19 +292,15 @@ jobs:
- name: Run clippy (ente_rust)
working-directory: mobile/packages/rust/rust
- run: cargo clippy --all-targets --all-features --locked
+ run: cargo clippy --all-targets --all-features
- name: Build (ente_rust)
working-directory: mobile/packages/rust/rust
- run: cargo build --features frb-generated --locked
+ run: cargo build
- name: Test (ente_rust)
working-directory: mobile/packages/rust/rust
- run: cargo test --features frb-generated --locked
-
- - name: Check Rust API without generated bindings (photos app)
- run: cargo check --locked
- working-directory: mobile/apps/photos/rust
+ run: cargo test
- name: Generate Rust bindings (photos app)
run: flutter_rust_bridge_codegen generate
@@ -335,15 +312,15 @@ jobs:
- name: Run clippy (ente_photos_rust)
working-directory: mobile/apps/photos/rust
- run: cargo clippy --all-targets --all-features --locked
+ run: cargo clippy --all-targets --all-features
- name: Build (ente_photos_rust)
working-directory: mobile/apps/photos/rust
- run: cargo build --features frb-generated --locked
+ run: cargo build
- name: Test (ente_photos_rust)
working-directory: mobile/apps/photos/rust
- run: cargo test --features frb-generated --locked
+ run: cargo test
apps-lint:
needs: detect-changes
diff --git a/.github/workflows/rust-e2e-test.yml b/.github/workflows/rust-e2e-test.yml
index c40a502706..5cf51da640 100644
--- a/.github/workflows/rust-e2e-test.yml
+++ b/.github/workflows/rust-e2e-test.yml
@@ -5,7 +5,6 @@ on:
paths:
- "rust/e2e/**"
- "rust/apps/cli/**"
- - "rust/crates/accounts/**"
- "rust/crates/contacts/**"
- "rust/crates/core/**"
- "rust/Cargo.lock"
diff --git a/.github/workflows/rust-lint-cli.yml b/.github/workflows/rust-lint-cli.yml
index c72d23b93d..2bd5450378 100644
--- a/.github/workflows/rust-lint-cli.yml
+++ b/.github/workflows/rust-lint-cli.yml
@@ -9,8 +9,6 @@ on:
pull_request:
paths:
- "rust/apps/cli/**"
- - "rust/crates/accounts/**"
- - "rust/crates/core/**"
- "rust/Cargo.lock"
- "rust/Cargo.toml"
- ".github/workflows/rust-lint-cli.yml"
diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.yml
index df8b054904..749588f831 100644
--- a/.github/workflows/rust-lint.yml
+++ b/.github/workflows/rust-lint.yml
@@ -7,8 +7,6 @@ on:
pull_request:
paths:
- "rust/crates/core/**"
- - "rust/crates/contacts/**"
- - "rust/crates/image/**"
- "rust/photos/**"
- "rust/Cargo.lock"
- "rust/Cargo.toml"
diff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.yml
index ebdde270e2..eb1d259978 100644
--- a/.github/workflows/web-lint.yml
+++ b/.github/workflows/web-lint.yml
@@ -6,7 +6,6 @@ on:
paths:
- "web/**"
- "rust/crates/core/**"
- - "rust/crates/contacts/**"
- ".github/workflows/web-lint.yml"
permissions:
diff --git a/mobile/apps/photos/rust/Cargo.toml b/mobile/apps/photos/rust/Cargo.toml
index a31be19d57..8781925746 100644
--- a/mobile/apps/photos/rust/Cargo.toml
+++ b/mobile/apps/photos/rust/Cargo.toml
@@ -16,7 +16,6 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }
[features]
default = []
-frb-generated = []
[profile.dev.package."*"]
opt-level = 2
diff --git a/mobile/apps/photos/rust/cargokit.yaml b/mobile/apps/photos/rust/cargokit.yaml
deleted file mode 100644
index 020d511756..0000000000
--- a/mobile/apps/photos/rust/cargokit.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-cargo:
- debug:
- extra_flags: ["--features", "frb-generated"]
- release:
- extra_flags: ["--features", "frb-generated"]
- profile:
- extra_flags: ["--features", "frb-generated"]
diff --git a/mobile/apps/photos/rust/src/lib.rs b/mobile/apps/photos/rust/src/lib.rs
index 9f9dee1a84..cbb071f8bf 100644
--- a/mobile/apps/photos/rust/src/lib.rs
+++ b/mobile/apps/photos/rust/src/lib.rs
@@ -1,4 +1,2 @@
pub mod api;
-
-#[cfg(feature = "frb-generated")]
mod frb_generated;
diff --git a/mobile/packages/rust/rust/Cargo.toml b/mobile/packages/rust/rust/Cargo.toml
index 2166f4c2c7..688ae878a9 100644
--- a/mobile/packages/rust/rust/Cargo.toml
+++ b/mobile/packages/rust/rust/Cargo.toml
@@ -14,7 +14,3 @@ ente-contacts = { path = "../../../../rust/crates/contacts" }
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }
missing_docs = "warn"
-
-[features]
-default = []
-frb-generated = []
diff --git a/mobile/packages/rust/rust/cargokit.yaml b/mobile/packages/rust/rust/cargokit.yaml
deleted file mode 100644
index 020d511756..0000000000
--- a/mobile/packages/rust/rust/cargokit.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-cargo:
- debug:
- extra_flags: ["--features", "frb-generated"]
- release:
- extra_flags: ["--features", "frb-generated"]
- profile:
- extra_flags: ["--features", "frb-generated"]
diff --git a/mobile/packages/rust/rust/src/lib.rs b/mobile/packages/rust/rust/src/lib.rs
index 9d18cd2e7e..fe77e8251d 100644
--- a/mobile/packages/rust/rust/src/lib.rs
+++ b/mobile/packages/rust/rust/src/lib.rs
@@ -1,6 +1,4 @@
//! Flutter Rust Bridge bindings for Ente mobile apps.
pub mod api;
-
-#[cfg(feature = "frb-generated")]
mod frb_generated;
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 46e98927d7..30cb235d55 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -19,8 +19,6 @@ members = [
]
exclude = [
"apps/ensu/src-tauri",
- # Photos stays outside the root workspace until its app-provided ONNX Runtime
- # can move from ort rc.4 to the workspace's ort rc.12.
"photos",
"e2e",
]
diff --git a/rust/README.md b/rust/README.md
index 857deb2091..614aa9a951 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -2,7 +2,7 @@
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
- β”‚ rust/crates/core/ β”‚
+ β”‚ rust/crates/core/ β”‚
β”‚ (ente-core crate) β”‚
β”‚ β”‚
β”‚ Pure Rust - NO FFI annotations β”‚
@@ -34,20 +34,17 @@
β”‚ (ente_photos_rust crate) β”‚
β”‚ β”‚
β”‚ Thin app-specific #[frb] β”‚
-β”‚ wrappers for rust/photos β”‚
+β”‚ wrappers for rust/photos β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
## Contents (this repo)
- `rust/crates/core/` (`ente-core`) - shared, pure Rust code used by clients (crypto + auth, plus small HTTP/URL helpers).
-- `rust/crates/accounts/` (`ente-accounts`) - shared account/auth flows built on `ente-core`.
-- `rust/crates/contacts/` (`ente-contacts`) - shared contacts/domain logic.
- `rust/photos/` (`ente_photos`) - shared Photos Rust logic (motion photo, ML, image processing, vector DB).
-- `rust/crates/ensu/` - shared Ensu logic (see `rust/crates/ensu/README.md`).
-- `rust/bindings/uniffi/` - UniFFI bindings for core crypto/auth + Ensu.
- `rust/apps/cli/` (`ente-rs`) - Rust CLI.
- `rust/e2e/` (`ente-e2e`) - live Museum-backed Rust end-to-end tests.
+- `rust/crates/ensu/` - LLM chat stack (see `rust/crates/ensu/README.md`).
## Directory Structure
@@ -64,33 +61,37 @@ rust/
β”‚ └── Cargo.toml
β”‚
β”œβ”€β”€ crates/
-β”‚ β”œβ”€β”€ accounts/ # Shared account/auth flows
-β”‚ β”œβ”€β”€ contacts/ # Shared contacts/domain logic
-β”‚ β”œβ”€β”€ core/ # Pure Rust shared logic (ente-core)
-β”‚ β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ β”œβ”€β”€ docs/
-β”‚ β”‚ └── Cargo.toml
-β”‚ β”œβ”€β”€ ensu/ # Ensu shared logic
-β”‚ β”‚ β”œβ”€β”€ db/
-β”‚ β”‚ β”œβ”€β”€ inference/
-β”‚ β”‚ β”œβ”€β”€ sync/
-β”‚ β”‚ └── transcription/
β”‚ └── image/ # Shared image crate
β”‚
-β”œβ”€β”€ photos/ # Shared Photos Rust logic
+β”œβ”€β”€ e2e/ # Rust e2e tests requiring live Museum
β”‚ β”œβ”€β”€ src/
+β”‚ β”‚ └── lib.rs
+β”‚ β”œβ”€β”€ tests/
β”‚ └── Cargo.toml
β”‚
-β”œβ”€β”€ bindings/
-β”‚ └── uniffi/ # UniFFI bindings for core crypto/auth + Ensu
-β”‚ β”œβ”€β”€ core/
-β”‚ └── ensu/
+β”œβ”€β”€ core/ # Pure Rust shared logic (ente-core)
+β”‚ β”œβ”€β”€ src/
+β”‚ β”‚ β”œβ”€β”€ lib.rs
+β”‚ β”‚ β”œβ”€β”€ crypto/
+β”‚ β”‚ └── auth/
+β”‚ β”œβ”€β”€ docs/
+β”‚ β”‚ β”œβ”€β”€ crypto.md
+β”‚ β”‚ └── auth.md
+β”‚ └── Cargo.toml
β”‚
-β”œβ”€β”€ e2e/ # Rust e2e tests requiring live Museum
+β”œβ”€β”€ photos/ # Shared Photos Rust logic
β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ └── lib.rs
-β”‚ β”œβ”€β”€ tests/
+β”‚ β”‚ β”œβ”€β”€ lib.rs
+β”‚ β”‚ β”œβ”€β”€ image/
+β”‚ β”‚ β”œβ”€β”€ ml/
+β”‚ β”‚ └── vector_db.rs
β”‚ └── Cargo.toml
+β”‚
+└── ensu/ # LLM chat stack (see rust/crates/ensu/README.md)
+
+rust/bindings/uniffi/ # UniFFI bindings for core crypto/auth + ensu
+β”œβ”€β”€ core/
+└── ensu/
web/packages/wasm/ # WASM bindings (lives in web workspace)
β”œβ”€β”€ src/
@@ -119,10 +120,7 @@ mobile/apps/photos/rust/ # Photos app-specific FRB bindings
- `ente-core` - shared business logic (pure Rust, no FFI)
- Docs: `rust/crates/core/docs/crypto.md`, `rust/crates/core/docs/auth.md`
-- `ente-accounts` - shared account/auth flows
-- `ente-contacts` - shared contacts/domain logic
- `ente_photos` - shared Photos Rust logic
-- `ensu-db`, `ensu-sync`, `inference_rs`, `ensu-transcription` - shared Ensu Rust logic
- `ente-rs` - Rust CLI package (`ente-cli` binary)
- `ente-e2e` - ignored Rust integration tests that run against a live Museum
- `ente-wasm` - wasm-bindgen wrappers for web
diff --git a/rust/crates/accounts/src/flow.rs b/rust/crates/accounts/src/flow.rs
index 4083948239..d3fa730aed 100644
--- a/rust/crates/accounts/src/flow.rs
+++ b/rust/crates/accounts/src/flow.rs
@@ -206,6 +206,7 @@ impl fmt::Debug for CheckSessionValidityParams {
/// Outcome of a session-validity check.
#[derive(Debug)]
+#[expect(clippy::large_enum_variant)]
pub enum SessionValidity {
/// Token is invalid.
Invalid,
diff --git a/rust/crates/ensu/sync/tests/sync_integration.rs b/rust/crates/ensu/sync/tests/sync_integration.rs
index 3e365d7ffd..0f5607757f 100644
--- a/rust/crates/ensu/sync/tests/sync_integration.rs
+++ b/rust/crates/ensu/sync/tests/sync_integration.rs
@@ -1,7 +1,4 @@
-use std::sync::{Mutex, MutexGuard};
-
use ensu_db::EnsuDb;
-use ensu_db::SyncStateDb;
use ensu_db::crypto::KEY_BYTES;
use ensu_sync::SyncAuth;
use ensu_sync::SyncEngine;
@@ -16,8 +13,6 @@ use tempfile::TempDir;
use uuid::Uuid;
use zeroize::Zeroizing;
-static SYNC_TEST_LOCK: Mutex<()> = Mutex::new(());
-
struct TestEnv {
_dir: TempDir,
main_db_path: String,
@@ -45,10 +40,6 @@ impl TestEnv {
}
}
-fn sync_test_lock() -> MutexGuard<'static, ()> {
- SYNC_TEST_LOCK.lock().unwrap_or_else(|err| err.into_inner())
-}
-
fn make_auth(server: &MockServer, master_key: Vec<u8>) -> SyncAuth {
SyncAuth {
base_url: server.base_url(),
@@ -85,7 +76,6 @@ fn mock_empty_diff(server: &MockServer, timestamp: i64) {
#[test]
fn pull_applies_remote_sessions_and_messages() {
- let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![42u8; KEY_BYTES];
let engine = SyncEngine::new(
@@ -174,7 +164,6 @@ fn pull_applies_remote_sessions_and_messages() {
#[test]
fn push_only_needs_sync_messages() {
- let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![11u8; KEY_BYTES];
let engine = SyncEngine::new(
@@ -203,10 +192,6 @@ fn push_only_needs_sync_messages() {
.expect("message two");
db.mark_message_synced(message_one.uuid)
.expect("mark synced");
- SyncStateDb::open_sqlite_with_defaults(env.attachments_db_path.clone())
- .expect("sync state")
- .set_message_state(message_one.uuid, Some(&Uuid::new_v4().to_string()), Some(5))
- .expect("message sync state");
let master_key = vec![7u8; KEY_BYTES];
let chat_key = ente_core::crypto::keys::generate_stream_key();
@@ -216,18 +201,12 @@ fn push_only_needs_sync_messages() {
let session_mock = server.mock(|when, then| {
when.method(POST).path("/llmchat/chat/session");
- then.status(200).json_body_obj(&serde_json::json!({
- "sessionUUID": Uuid::new_v4().to_string(),
- "updatedAt": 20,
- }));
+ then.status(200).json_body_obj(&serde_json::json!({}));
});
let message_mock = server.mock(|when, then| {
when.method(POST).path("/llmchat/chat/message");
- then.status(200).json_body_obj(&serde_json::json!({
- "messageUUID": Uuid::new_v4().to_string(),
- "updatedAt": 21,
- }));
+ then.status(200).json_body_obj(&serde_json::json!({}));
});
let auth = make_auth(&server, master_key);
@@ -242,7 +221,6 @@ fn push_only_needs_sync_messages() {
#[test]
fn tombstone_removes_messages() {
- let _guard = sync_test_lock();
let env = TestEnv::new();
let db_key = vec![3u8; KEY_BYTES];
let engine = SyncEngine::new(
diff --git a/rust/e2e/Cargo.lock b/rust/e2e/Cargo.lock
index fcc77991e1..8ac0a0762a 100644
--- a/rust/e2e/Cargo.lock
+++ b/rust/e2e/Cargo.lock
@@ -2465,9 +2465,9 @@ dependencies = [
[[package]]
name = "sqlite-wasm-rs"
-version = "0.5.3"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b2c760607300407ddeaee518acf28c795661b7108c75421303dbefb237d3a36"
+checksum = "2f4206ed3a67690b9c29b77d728f6acc3ce78f16bf846d83c94f76400320181b"
dependencies = [
"cc",
"js-sys",