π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
core 1
Manav Rathi94e1ef89ee26
diff --git a/rust/.gitignore b/rust/.gitignoreindex ea8c4bf7f3..2f7896d1d1 100644--- a/rust/.gitignore+++ b/rust/.gitignore@@ -1 +1 @@-/target+target/diff --git a/rust/core/Cargo.lock b/rust/core/Cargo.locknew file mode 100644index 0000000000..04f6f0341c--- /dev/null+++ b/rust/core/Cargo.lock@@ -0,0 +1,7 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "ente-core"+version = "0.0.1"diff --git a/rust/core/Cargo.toml b/rust/core/Cargo.tomlnew file mode 100644index 0000000000..f8f30bf003--- /dev/null+++ b/rust/core/Cargo.toml@@ -0,0 +1,4 @@+[package]+name = "ente-core"+version = "0.0.1"+edition = "2024"diff --git a/rust/core/README.md b/rust/core/README.mdnew file mode 100644index 0000000000..e0e3115a4d--- /dev/null+++ b/rust/core/README.md@@ -0,0 +1,10 @@+Common Rust code for Ente apps.++## Development++```bash+cargo fmt # format+cargo clippy # lint+cargo build # build+cargo test # test+```diff --git a/rust/core/src/lib.rs b/rust/core/src/lib.rsnew file mode 100644index 0000000000..c8faf421d7--- /dev/null+++ b/rust/core/src/lib.rs@@ -0,0 +1 @@+pub mod urls;diff --git a/rust/core/src/urls.rs b/rust/core/src/urls.rsnew file mode 100644index 0000000000..47b9653cf5--- /dev/null+++ b/rust/core/src/urls.rs@@ -0,0 +1,28 @@+/// Generate the download URL for a file.+///+/// - If api_base_url is production (https://api.ente.io), return CDN URL+/// - Otherwise, return direct API URL+pub fn file_download_url(api_base_url: &str, file_id: i64) -> String {+ if api_base_url == "https://api.ente.io" {+ format!("https://files.ente.io/?fileID={}", file_id)+ } else {+ format!("{}/files/download/{}", api_base_url, file_id)+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_production_url() {+ let url = file_download_url("https://api.ente.io", 12345);+ assert_eq!(url, "https://files.ente.io/?fileID=12345");+ }++ #[test]+ fn test_custom_server() {+ let url = file_download_url("https://my-server.example.com", 99);+ assert_eq!(url, "https://my-server.example.com/files/download/99");+ }+}