Files
SpotiFLAC-Mobile/rust_backend/crates/network/src/lib.rs
T
zarzet aa99726439 feat(backend): migrate production backend to Rust
Replace the Go backend with the Rust workspace and route Android/iOS through
UniFFI bindings. Include the migrated extension runtime, network, providers,
media metadata, downloads and library operations, with version 5.0.0+147.

Remove Go sources, adapters, native build selection and CI dependencies.
Build Rust unconditionally and lock the iOS Rust pod using a relative path.
Retain legacy source and migration evidence in a local ignored archive.

Validation: Android Kotlin compile and 53 native tests; Swift Rust-branch
equivalence and syntax; CocoaPods install; workflow, shell, Ruby, plist and
diff checks. Reuse the preceding 100 Rust tests, fmt/Clippy and five-ABI
build checkpoint; no new APK or iOS application build for this cleanup.

Known follow-up: URL/URLSearchParams globals are missing from the Rust JS
runtime. A controlled extension replay confirms a URL-resolution regression;
this commit does not fix that runtime gap.
2026-09-14 22:58:27 +07:00

31 lines
911 B
Rust

//! Shared, cancellable HTTP transport for the embedded backend.
mod client;
mod cookies;
mod dns;
pub mod policy;
pub mod query;
mod tls;
pub mod url;
pub use client::{
HttpRequest, HttpResponse, HttpStream, MAX_RESPONSE_BYTES, NetworkOptions, NetworkService,
NetworkSession,
};
pub use dns::{Lookup, LookupFuture, SystemLookup};
/// Shared browser identity for native clients and `utils.randomUserAgent()`.
pub fn random_user_agent() -> String {
use std::collections::hash_map::RandomState;
use std::hash::BuildHasher;
// Keep the existing 26-major-version window, now ending at Chrome 152.
let random = RandomState::new().hash_one(());
format!(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36",
127 + random % 26,
6000 + (random >> 8) % 1500,
100 + (random >> 24) % 200
)
}