Skip to content

armgit / ente

Public Imported from GitHub
0

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

Clean up Rust workspace docs and lint workflow

Manav Rathi5f83cf331c21
diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.yml
index 84cc640bc4..652c6e1363 100644
--- a/.github/workflows/rust-lint.yml
+++ b/.github/workflows/rust-lint.yml
@@ -3,8 +3,8 @@ name: "Lint (rust)"
on:
pull_request:
paths:
- - "rust/**"
- ".github/workflows/rust-lint.yml"
+ - "rust/**"
permissions:
contents: read
@@ -26,21 +26,17 @@ jobs:
run:
working-directory: rust
steps:
- - name: Checkout code
- uses: actions/checkout@v6
+ - uses: actions/checkout@v6
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y g++-12 libwebkit2gtk-4.0-dev libsoup2.4-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- - name: Prepare Ensu desktop distDir
- run: mkdir -p ../web/apps/ensu/out
-
- - run: cargo fmt --all --check
+ - run: cargo fmt --check
- - run: cargo clippy --workspace --all-targets --locked
+ - run: cargo clippy --all-targets --locked
# ORT rc.12's Linux test binary links glibc 2.38 symbols that are
# unavailable on the Ubuntu 22.04 runner required by Tauri v1.
- - run: cargo test --workspace --locked --exclude transcription --exclude ensu-transcription
+ - run: cargo test --locked --workspace --exclude transcription --exclude ensu-transcription
diff --git a/rust/README.md b/rust/README.md
index b8401a5d0b..702928303b 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -1,214 +1,27 @@
-# Rust in Ente
+# Rust
-```
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
- β”‚ rust/crates/core/ β”‚
- β”‚ (ente-core crate) β”‚
- β”‚ β”‚
- β”‚ Pure Rust - NO FFI annotations β”‚
- β”‚ Stateless business logic β”‚
- β”‚ Fully testable with cargo test β”‚
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
- β”‚
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
- β”‚ β”‚ β”‚
- β–Ό β–Ό β–Ό
-β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
-β”‚ rust/bindings/frb/ β”‚ β”‚ rust/bindings/wasm/ β”‚ β”‚ rust/apps/cli/ β”‚
-β”‚ ente-rust/ β”‚ β”‚ ente-wasm/ β”‚ β”‚ β”‚
-β”‚ (ente_rust crate) β”‚ β”‚ (ente-wasm crate) β”‚ β”‚ β”‚
-β”‚ β”‚ β”‚ β”‚ β”‚ CLI binary, depends β”‚
-β”‚ Shared #[frb] wrappers β”‚ β”‚ #[wasm_bindgen] wrappers β”‚ β”‚ on ente-core β”‚
-β”‚ for all mobile apps β”‚ β”‚ for all web apps β”‚ β”‚ β”‚
-β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
- β”‚ β”‚ β”‚
- β”‚ └──────────────┐ β”‚
- β–Ό β–Ό β–Ό
-β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
-β”‚ Photos App β”‚ β”‚ Other apps β”‚ β”‚ Web Apps β”‚
-β”‚ β”‚ β”‚ (Auth ...) β”‚ β”‚ (Photos, Auth, etc.) β”‚
-β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
- β–²
- β”‚
-β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
-β”‚ rust/bindings/frb/photos/ β”‚
-β”‚ (ente_photos_rust crate) β”‚
-β”‚ β”‚
-β”‚ Thin app-specific #[frb] β”‚
-β”‚ wrappers for crates/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/photos/` (`ente_photos`) - shared Photos Rust logic (motion photo, ML, image processing, vector DB).
-- `rust/apps/cli/` (`ente-rs`) - Rust CLI.
-- `rust/bindings/frb/ente-rust/` (`ente_rust`) - shared Flutter Rust Bridge bindings for mobile.
-- `rust/bindings/frb/photos/` (`ente_photos_rust`) - Photos app-specific Flutter Rust Bridge bindings.
-- `rust/bindings/wasm/ente-wasm/` (`ente-wasm`) - wasm-bindgen bindings for web.
-- `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
-
-```
-rust/
-β”œβ”€β”€ apps/
-β”‚ β”œβ”€β”€ cli/ # CLI package (ente-rs)
-β”‚ β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ β”‚ └── main.rs
-β”‚ β”‚ └── Cargo.toml
-β”‚ β”‚
-β”‚ └── codegen/ # Cargo-powered repo codegen helper
-β”‚ β”œβ”€β”€ src/
-β”‚ └── Cargo.toml
-β”‚
-β”œβ”€β”€ crates/
-β”‚ β”œβ”€β”€ accounts/ # Shared account helpers
-β”‚ β”œβ”€β”€ contacts/ # Shared contacts logic
-β”‚ β”œβ”€β”€ core/ # Pure Rust shared logic (ente-core)
-β”‚ β”œβ”€β”€ ensu/ # LLM chat stack
-β”‚ β”œβ”€β”€ image/ # Shared image crate
-β”‚ └── photos/ # Shared Photos Rust logic
-β”‚
-β”œβ”€β”€ e2e/ # Rust e2e tests requiring live Museum
-β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ └── lib.rs
-β”‚ β”œβ”€β”€ tests/
-β”‚ └── Cargo.toml
-β”‚
-└── Cargo.toml # Rust workspace manifest
-
-rust/bindings/uniffi/ # UniFFI bindings for core crypto/auth + ensu
-β”œβ”€β”€ core/
-└── ensu/
-
-rust/bindings/frb/ # Flutter Rust Bridge binding crates
-β”œβ”€β”€ ente-rust/
-β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ └── api/ # #[frb] wrappers around ente-core
-β”‚ └── Cargo.toml # crate name: ente_rust
-└── photos/
- β”œβ”€β”€ src/
- β”‚ └── api/ # #[frb] thin wrappers over rust/crates/photos
- └── Cargo.toml # crate name: ente_photos_rust
-
-rust/bindings/wasm/ente-wasm/ # WASM bindings Rust crate
-β”œβ”€β”€ src/
-β”‚ └── lib.rs # #[wasm_bindgen] wrappers around ente-core
-└── Cargo.toml # crate name: ente-wasm
-
-web/packages/wasm/ # JS package surface for ente-wasm
-β”œβ”€β”€ package.json # includes wasm-pack as devDependency
-└── pkg/ # generated output (gitignored)
-
-mobile/packages/rust/ # Shared FRB bindings for all mobile apps
-β”œβ”€β”€ lib/ # Generated Dart bindings
-└── pubspec.yaml # Flutter plugin package
-```
-
-**Crates:**
-
-- `ente-core` - shared business logic (pure Rust, no FFI)
- - Docs: `rust/crates/core/docs/crypto.md`, `rust/crates/core/docs/auth.md`
-- `ente_photos` - shared Photos 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
-- `ente_rust` - shared FRB wrappers for mobile (Dart class: `EnteRust`)
-- `ente_photos_rust` - Photos app-specific FRB (Dart class: `EntePhotosRust`)
-
-## Tooling
-
-### [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen)
-
-A Rust library that provides the `#[wasm_bindgen]` attribute macro. When you annotate a function with `#[wasm_bindgen]`, it:
-
-1. Marks the function for export to JavaScript
-2. Handles type conversions between Rust and JS (e.g., `String` ↔ JS string, `i64` ↔ `BigInt`)
-3. Generates metadata that the wasm-bindgen CLI uses to create JS/TS glue code
-
-### [wasm-pack](https://github.com/drager/wasm-pack)
-
-A CLI tool that orchestrates the WASM build process:
-
-1. Runs `cargo build --target wasm32-unknown-unknown`
-2. Invokes `wasm-bindgen` CLI to generate JS/TS bindings from the compiled WASM
-3. Outputs everything to a `pkg/` directory ready for npm/bundlers
-
-wasm-pack is installed via npm as a devDependency, so `yarn install` handles it.
-
-### [Flutter Rust Bridge (FRB)](https://github.com/fzyzcjy/flutter_rust_bridge)
-
-Used for Flutter integration. FRB is used on two crates:
-
-- **`ente_rust`** (`rust/bindings/frb/ente-rust/`) - Shared wrappers around `ente-core`, used by multiple mobile apps (Photos, Auth, etc.)
-- **`ente_photos_rust`** (`rust/bindings/frb/photos/`) - Thin Photos-specific wrappers around `rust/crates/photos`
-
-Both depend on `ente-core` and use `#[frb]` annotations to generate Dart bindings.
+Cargo workspace for Ente's Rust code.
## Development
-### Commands
-
-**ente-core (rust/crates/core/):**
-
-```sh
-cargo fmt # format
-cargo clippy # lint
-cargo build # build
-cargo test # test
-```
-
-**ente-cli (rust/apps/cli/):**
-
```sh
-cargo fmt # format
-cargo clippy # lint
-cargo build # build
-cargo test # test
-cargo run --bin ente-cli -- --help
-```
-
-**ente-e2e (rust/e2e/):**
+cargo fmt # Format
+cargo clippy # Lint
+cargo build # Build
+cargo test # Test
-```sh
-cargo test --manifest-path rust/Cargo.toml -p ente-e2e # compile-only sanity check
-rust/e2e/scripts/run.sh # starts Docker + runs ignored live suite
-cargo test --manifest-path rust/Cargo.toml -p ente-e2e -- --ignored --nocapture
+cargo run --bin ente-cli -- --help # Run the Ente Rust CLI
```
-**ente-wasm (Rust source in rust/bindings/wasm/ente-wasm/, JS package in web/packages/wasm/):**
-
-```sh
-yarn install # installs wasm-pack
-yarn build # runs wasm-pack against the Rust crate
-```
+CI runs with `RUSTFLAGS="-D warnings"` so warnings will cause checks to fail.
-Or from web/ root:
+Other useful commands:
```sh
-yarn build:wasm # builds the WASM package
-```
-
-> [!TIP]
->
-> For active Rust development, use watch mode in a separate terminal:
->
-> ```sh
-> cargo install cargo-watch
-> cd web/
-> cargo watch -w ../rust/crates/core -w ../rust/bindings/wasm/ente-wasm/src -s "yarn build:wasm"
-> ```
-
-**Generated bindings:**
+cargo codegen native # Regenerate bindings used by native apps
+cargo codegen frb # Regenerate bindings used by Flutter apps
-```sh
-cd rust
-cargo codegen native
-cargo codegen frb
+# Starts Docker + runs the E2E tests (ignored by default)
+./e2e/scripts/run.sh
+cargo test -p ente-e2e -- --ignored --nocapture
```
-
-`native` regenerates the UniFFI bindings used by native mobile apps.
-`frb` regenerates both `ente_rust` and `ente_photos_rust`.
diff --git a/rust/apps/cli/README.md b/rust/apps/cli/README.md
index d5e51e68e9..69da9729aa 100644
--- a/rust/apps/cli/README.md
+++ b/rust/apps/cli/README.md
@@ -3,9 +3,5 @@ WIP Ente Rust CLI.
## Development
```sh
-cargo fmt # format
-cargo clippy # lint
-cargo build # build
-cargo test # test
cargo run --bin ente-cli -- --help
```
diff --git a/rust/bindings/frb/README.md b/rust/bindings/frb/README.md
new file mode 100644
index 0000000000..c5e26ddf1d
--- /dev/null
+++ b/rust/bindings/frb/README.md
@@ -0,0 +1,3 @@
+# Flutter Rust Bridge
+
+[Flutter Rust Bridge (FRB)](https://github.com/fzyzcjy/flutter_rust_bridge) generates Dart bindings from Rust APIs annotated with `#[frb]`. This is used for Flutter integration of Rust code.
diff --git a/rust/bindings/wasm/README.md b/rust/bindings/wasm/README.md
new file mode 100644
index 0000000000..9a38c7b2f7
--- /dev/null
+++ b/rust/bindings/wasm/README.md
@@ -0,0 +1,19 @@
+# Wasm bindings for Rust code
+
+## [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen)
+
+A Rust library that provides the `#[wasm_bindgen]` attribute macro. When you annotate a function with `#[wasm_bindgen]`, it:
+
+1. Marks the function for export to JavaScript
+2. Handles type conversions between Rust and JS (e.g., `String` ↔ JS string, `i64` ↔ `BigInt`)
+3. Generates metadata that the wasm-bindgen CLI uses to create JS/TS glue code
+
+## [wasm-pack](https://github.com/drager/wasm-pack)
+
+A CLI tool that orchestrates the WASM build process:
+
+1. Runs `cargo build --target wasm32-unknown-unknown`
+2. Invokes `wasm-bindgen` CLI to generate JS/TS bindings from the compiled WASM
+3. Outputs everything to a `pkg/` directory ready for npm/bundlers
+
+wasm-pack is installed via npm as a devDependency, so `yarn install` handles it.
diff --git a/rust/crates/core/README.md b/rust/crates/core/README.md
index dd05a7dc10..854cc47873 100644
--- a/rust/crates/core/README.md
+++ b/rust/crates/core/README.md
@@ -50,12 +50,3 @@ let decrypted = crypto::secretbox::decrypt_box(&encrypted, &key).unwrap();
```
πŸ“– **[Full Crypto Docs](docs/crypto.md)**
-
-## Development
-
-```sh
-cargo fmt # format
-cargo clippy # lint
-cargo build # build
-cargo test # test
-```