Skip to content

armgit / ente

Public Imported from GitHub
0

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

docs(rust): restore README detail and include auth

Prateek Sunal06023e6b6b6f
diff --git a/rust/README.md b/rust/README.md
index ddf6c3d051..2b7ad66e99 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -38,9 +38,12 @@
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
-## Directory Structure
+## 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 crates live under `rust/`.
+## Directory Structure
```
rust/
@@ -52,55 +55,122 @@ rust/
β”‚
└── core/ # Pure Rust shared logic
β”œβ”€β”€ src/
+ β”‚ β”œβ”€β”€ lib.rs
+ β”‚ β”œβ”€β”€ crypto/
+ β”‚ └── auth/
β”œβ”€β”€ docs/
+ β”‚ β”œβ”€β”€ crypto.md
+ β”‚ └── auth.md
└── Cargo.toml # crate name: ente-core
-```
-Related integrations (outside this folder):
+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)
-- `web/packages/wasm/` - WASM bindings around `ente-core` (`ente-wasm`)
-- `mobile/packages/rust/` - Flutter Rust Bridge bindings around `ente-core` (`ente_rust`)
-- `mobile/apps/photos/rust/` - Photos app-specific Rust crate (`ente_photos_rust`)
+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
+
+mobile/apps/photos/rust/ # Photos app-specific FRB bindings
+β”œβ”€β”€ src/
+β”‚ β”œβ”€β”€ lib.rs
+β”‚ └── api/ # #[frb] app-specific code (usearch, ML)
+β”‚ └── *.rs
+└── Cargo.toml # crate name: ente_photos_rust
+```
-## Crates
+**Crates:**
-- `ente-core` (`rust/core`) - shared crypto + auth helpers
- - Docs:
- - `rust/core/docs/crypto.md`
- - `rust/core/docs/auth.md`
-- `ente-rs` (`rust/cli`) - Rust CLI
-- `ente-wasm` (`web/packages/wasm`) - wasm-bindgen wrapper for web
-- `ente_rust` (`mobile/packages/rust`) - shared FRB wrapper for mobile
-- `ente_photos_rust` (`mobile/apps/photos/rust`) - Photos-specific FRB crate
+- `ente-core` - shared business logic (pure Rust, no FFI)
+ - Docs: `rust/core/docs/crypto.md`, `rust/core/docs/auth.md`
+- `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
+### [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)
+
+A Rust library that provides the `#[wasm_bindgen]` attribute macro. When you annotate a function with `#[wasm_bindgen]`, it:
-`#[wasm_bindgen]` exports Rust APIs to JavaScript and handles type conversions.
+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
+### [wasm-pack](https://github.com/rustwasm/wasm-pack)
-Build helper for WASM crates. In this repo it’s used via the web workspace scripts.
+A CLI tool that orchestrates the WASM build process:
-### Flutter Rust Bridge (FRB)
+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
-Used for Flutter integration. The FRB crates wrap `ente-core` and generate Dart bindings.
+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`** (`mobile/packages/rust/`) - Shared wrappers around `ente-core`, used by multiple mobile apps (Photos, Auth, etc.)
+- **`ente_photos_rust`** (`mobile/apps/photos/rust/`) - Photos app-specific functionality (usearch, ML)
+
+Both depend on `ente-core` and use `#[frb]` annotations to generate Dart bindings.
## Development
+### Commands
+
**ente-core (rust/core/):**
```sh
-cargo fmt
-cargo clippy
-cargo build
-cargo test
+cargo fmt # format
+cargo clippy # lint
+cargo build # build
+cargo test # test
+```
+
+**ente-wasm (web/packages/wasm/):**
+
+```sh
+yarn install # installs wasm-pack
+yarn build # runs wasm-pack build --target bundler
+```
+
+Or from web/ root:
+
+```sh
+yarn build:wasm # builds the WASM package
```
-**ente-rs (rust/cli/):**
+> [!TIP]
+>
+> For active Rust development, use watch mode in a separate terminal:
+>
+> ```sh
+> cargo install cargo-watch
+> cd web/
+> cargo watch -w ../rust/core -w packages/wasm/src -s "yarn build:wasm"
+> ```
+
+**ente_rust (mobile/packages/rust/):**
+
+```sh
+cargo install flutter_rust_bridge_codegen
+flutter_rust_bridge_codegen generate
+```
+
+`flutter_rust_bridge_codegen generate` needs to be run either manually (or in watch mode, `flutter_rust_bridge_codegen generate --watch`) whenever the Rust source changes to get the bindings to update.
+
+**ente_photos_rust (mobile/apps/photos/rust/):**
```sh
-cargo test
-cargo run -- --help
+flutter_rust_bridge_codegen generate
+flutter test
```