Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Deduplicate Apple inference wrapper

Manav Rathi1f79d890308e
diff --git a/.gitignore b/.gitignore
index 518d386d14..21031a7296 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,6 @@ node_modules/
# Build artifacts
mobile/native/android/packages/rust/build/
-mobile/native/darwin/Packages/Rust/build/
mobile/native/darwin/Apps/ensu/build/
mobile/native/darwin/Apps/ensu/build-native-check/
target/
@@ -40,8 +39,6 @@ mobile/native/darwin/Apps/ensu/ensu/Generated/*_uniffi*
mobile/native/darwin/Apps/ensu/ensu/Generated/core*
mobile/native/darwin/Apps/ensu/ensu/Generated/db*
mobile/native/darwin/Apps/ensu/ensu/Generated/sync*
-mobile/native/darwin/Packages/Rust/InferenceRSFFI.xcframework/
-mobile/native/darwin/Packages/Rust/Sources/InferenceRS/inference_rs_uniffi*
# Local ensu endpoint overrides (compile-time)
mobile/native/darwin/Apps/ensu/ensu/Generated/EndpointConfig.swift
diff --git a/mobile/native/darwin/Apps/ensu/README.md b/mobile/native/darwin/Apps/ensu/README.md
index 3683c5c47d..b41ee5c234 100644
--- a/mobile/native/darwin/Apps/ensu/README.md
+++ b/mobile/native/darwin/Apps/ensu/README.md
@@ -35,9 +35,9 @@ Run `./build.sh --help` or `./run.sh --help` for full options.
The Xcode build script (`scripts/build-rust.sh`) builds Rust static libs, but it does
regenerate the `core`, `db`, and `sync` Swift bindings into `ensu/Generated/` as part of the build.
`../Packages/Rust/tool/generate_bindings.sh` and `../Packages/Rust/tool/build_xcframework.sh`
-handle the InferenceRS bindings and xcframework. `./build.sh` will build the
-local `InferenceRSFFI.xcframework` automatically if it is missing, then re-resolve
-Swift package dependencies before building.
+generate the Apple `InferenceRS` package from the shared Rust inference binding crate in
+`rust/uniffi/ensu/inference`. `./build.sh` will build the local `InferenceRSFFI.xcframework`
+automatically if it is missing, then re-resolve Swift package dependencies before building.
If Xcode still shows “Missing package product …” in the IDE, use
`File > Packages > Resolve Package Versions` after the xcframework has been generated.
diff --git a/mobile/native/darwin/Packages/Rust/.gitignore b/mobile/native/darwin/Packages/Rust/.gitignore
new file mode 100644
index 0000000000..40f5319175
--- /dev/null
+++ b/mobile/native/darwin/Packages/Rust/.gitignore
@@ -0,0 +1,3 @@
+build/
+InferenceRSFFI.xcframework/
+Sources/InferenceRS/inference*
diff --git a/mobile/native/darwin/Packages/Rust/README.md b/mobile/native/darwin/Packages/Rust/README.md
index 63c4d85989..65dbe92722 100644
--- a/mobile/native/darwin/Packages/Rust/README.md
+++ b/mobile/native/darwin/Packages/Rust/README.md
@@ -1,6 +1,7 @@
# InferenceRS (Swift)
-Swift bindings generated via UniFFI for the Rust core in `rust/ensu/inference`.
+Swift bindings generated via UniFFI from the shared Rust binding crate in
+`rust/uniffi/ensu/inference`, backed by `rust/ensu/inference`.
## Generate bindings
diff --git a/mobile/native/darwin/Packages/Rust/rust/Cargo.lock b/mobile/native/darwin/Packages/Rust/rust/Cargo.lock
deleted file mode 100644
index c755d50a3c..0000000000
--- a/mobile/native/darwin/Packages/Rust/rust/Cargo.lock
+++ /dev/null
@@ -1,1074 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 4
-
-[[package]]
-name = "aho-corasick"
-version = "1.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
-dependencies = [
- "memchr",
-]
-
-[[package]]
-name = "anyhow"
-version = "1.0.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
-
-[[package]]
-name = "askama"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
-dependencies = [
- "askama_derive",
- "itoa",
- "percent-encoding",
- "serde",
- "serde_json",
-]
-
-[[package]]
-name = "askama_derive"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
-dependencies = [
- "askama_parser",
- "basic-toml",
- "memchr",
- "proc-macro2",
- "quote",
- "rustc-hash",
- "serde",
- "serde_derive",
- "syn",
-]
-
-[[package]]
-name = "askama_parser"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
-dependencies = [
- "memchr",
- "serde",
- "serde_derive",
- "winnow",
-]
-
-[[package]]
-name = "autocfg"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
-
-[[package]]
-name = "basic-toml"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
-dependencies = [
- "serde",
-]
-
-[[package]]
-name = "bindgen"
-version = "0.72.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
-dependencies = [
- "bitflags",
- "cexpr",
- "clang-sys",
- "itertools",
- "log",
- "prettyplease",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash",
- "shlex",
- "syn",
-]
-
-[[package]]
-name = "bitflags"
-version = "2.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
-
-[[package]]
-name = "bytes"
-version = "1.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
-
-[[package]]
-name = "camino"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48"
-dependencies = [
- "serde_core",
-]
-
-[[package]]
-name = "cargo-platform"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea"
-dependencies = [
- "serde",
-]
-
-[[package]]
-name = "cargo_metadata"
-version = "0.19.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"
-dependencies = [
- "camino",
- "cargo-platform",
- "semver",
- "serde",
- "serde_json",
- "thiserror 2.0.17",
-]
-
-[[package]]
-name = "cc"
-version = "1.2.56"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
-dependencies = [
- "find-msvc-tools",
- "jobserver",
- "libc",
- "shlex",
-]
-
-[[package]]
-name = "cexpr"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
-dependencies = [
- "nom",
-]
-
-[[package]]
-name = "cfg-if"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
-
-[[package]]
-name = "clang-sys"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
-dependencies = [
- "glob",
- "libc",
- "libloading",
-]
-
-[[package]]
-name = "cmake"
-version = "0.1.57"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d"
-dependencies = [
- "cc",
-]
-
-[[package]]
-name = "either"
-version = "1.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
-
-[[package]]
-name = "encoding_rs"
-version = "0.8.35"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
-dependencies = [
- "cfg-if",
-]
-
-[[package]]
-name = "enumflags2"
-version = "0.7.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
-dependencies = [
- "enumflags2_derive",
-]
-
-[[package]]
-name = "enumflags2_derive"
-version = "0.7.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "equivalent"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
-
-[[package]]
-name = "errno"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
-dependencies = [
- "libc",
- "windows-sys",
-]
-
-[[package]]
-name = "fastrand"
-version = "2.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
-
-[[package]]
-name = "find-msvc-tools"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
-
-[[package]]
-name = "find_cuda_helper"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9f9e65c593dd01ac77daad909ea4ad17f0d6d1776193fc8ea766356177abdad"
-dependencies = [
- "glob",
-]
-
-[[package]]
-name = "fs-err"
-version = "2.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41"
-dependencies = [
- "autocfg",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
-dependencies = [
- "cfg-if",
- "libc",
- "r-efi",
- "wasip2",
-]
-
-[[package]]
-name = "glob"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
-
-[[package]]
-name = "goblin"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47"
-dependencies = [
- "log",
- "plain",
- "scroll",
-]
-
-[[package]]
-name = "hashbrown"
-version = "0.16.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
-
-[[package]]
-name = "heck"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
-
-[[package]]
-name = "indexmap"
-version = "2.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
-dependencies = [
- "equivalent",
- "hashbrown",
- "serde",
- "serde_core",
-]
-
-[[package]]
-name = "inference_rs"
-version = "0.1.0"
-dependencies = [
- "llama-cpp-2",
- "llama-cpp-sys-2",
- "parking_lot",
- "self_cell",
- "serde",
- "serde_json",
- "thiserror 1.0.69",
-]
-
-[[package]]
-name = "inference_rs_uniffi"
-version = "0.1.0"
-dependencies = [
- "inference_rs",
- "serde",
- "thiserror 1.0.69",
- "uniffi",
-]
-
-[[package]]
-name = "itertools"
-version = "0.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
-dependencies = [
- "either",
-]
-
-[[package]]
-name = "itoa"
-version = "1.0.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
-
-[[package]]
-name = "jobserver"
-version = "0.1.34"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
-dependencies = [
- "getrandom",
- "libc",
-]
-
-[[package]]
-name = "libc"
-version = "0.2.180"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
-
-[[package]]
-name = "libloading"
-version = "0.8.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
-dependencies = [
- "cfg-if",
- "windows-link",
-]
-
-[[package]]
-name = "linux-raw-sys"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
-
-[[package]]
-name = "llama-cpp-2"
-version = "0.1.138"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2947ab625c59d1fdf42e61f538c3fa66f43de2f78316971920873f359483d1d8"
-dependencies = [
- "encoding_rs",
- "enumflags2",
- "llama-cpp-sys-2",
- "thiserror 2.0.17",
- "tracing",
- "tracing-core",
-]
-
-[[package]]
-name = "llama-cpp-sys-2"
-version = "0.1.138"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84a529006bf16af70c7485ba957820dc2bc9467d75697e97970c81d2da73c76f"
-dependencies = [
- "bindgen",
- "cc",
- "cmake",
- "find_cuda_helper",
- "glob",
- "walkdir",
-]
-
-[[package]]
-name = "lock_api"
-version = "0.4.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
-dependencies = [
- "scopeguard",
-]
-
-[[package]]
-name = "log"
-version = "0.4.29"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
-
-[[package]]
-name = "memchr"
-version = "2.7.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
-
-[[package]]
-name = "minimal-lexical"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
-
-[[package]]
-name = "nom"
-version = "7.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
-dependencies = [
- "memchr",
- "minimal-lexical",
-]
-
-[[package]]
-name = "once_cell"
-version = "1.21.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
-
-[[package]]
-name = "parking_lot"
-version = "0.12.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
-dependencies = [
- "lock_api",
- "parking_lot_core",
-]
-
-[[package]]
-name = "parking_lot_core"
-version = "0.9.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
-dependencies = [
- "cfg-if",
- "libc",
- "redox_syscall",
- "smallvec",
- "windows-link",
-]
-
-[[package]]
-name = "percent-encoding"
-version = "2.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
-
-[[package]]
-name = "pin-project-lite"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
-
-[[package]]
-name = "plain"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
-
-[[package]]
-name = "prettyplease"
-version = "0.2.37"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
-dependencies = [
- "proc-macro2",
- "syn",
-]
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.105"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
-dependencies = [
- "unicode-ident",
-]
-
-[[package]]
-name = "quote"
-version = "1.0.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
-dependencies = [
- "proc-macro2",
-]
-
-[[package]]
-name = "r-efi"
-version = "5.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
-
-[[package]]
-name = "redox_syscall"
-version = "0.5.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
-dependencies = [
- "bitflags",
-]
-
-[[package]]
-name = "regex"
-version = "1.12.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-automata",
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-automata"
-version = "0.4.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.8.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
-
-[[package]]
-name = "rustc-hash"
-version = "2.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
-
-[[package]]
-name = "rustix"
-version = "1.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
-dependencies = [
- "bitflags",
- "errno",
- "libc",
- "linux-raw-sys",
- "windows-sys",
-]
-
-[[package]]
-name = "same-file"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
-dependencies = [
- "winapi-util",
-]
-
-[[package]]
-name = "scopeguard"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
-
-[[package]]
-name = "scroll"
-version = "0.12.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6"
-dependencies = [
- "scroll_derive",
-]
-
-[[package]]
-name = "scroll_derive"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "self_cell"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b12e76d157a900eb52e81bc6e9f3069344290341720e9178cde2407113ac8d89"
-
-[[package]]
-name = "semver"
-version = "1.0.27"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
-dependencies = [
- "serde",
- "serde_core",
-]
-
-[[package]]
-name = "serde"
-version = "1.0.228"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
-dependencies = [
- "serde_core",
- "serde_derive",
-]
-
-[[package]]
-name = "serde_core"
-version = "1.0.228"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
-dependencies = [
- "serde_derive",
-]
-
-[[package]]
-name = "serde_derive"
-version = "1.0.228"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "serde_json"
-version = "1.0.149"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
-dependencies = [
- "itoa",
- "memchr",
- "serde",
- "serde_core",
- "zmij",
-]
-
-[[package]]
-name = "serde_spanned"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776"
-dependencies = [
- "serde_core",
-]
-
-[[package]]
-name = "shlex"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
-
-[[package]]
-name = "siphasher"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
-
-[[package]]
-name = "smallvec"
-version = "1.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
-
-[[package]]
-name = "smawk"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
-
-[[package]]
-name = "static_assertions"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
-
-[[package]]
-name = "syn"
-version = "2.0.114"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
-[[package]]
-name = "tempfile"
-version = "3.24.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c"
-dependencies = [
- "fastrand",
- "getrandom",
- "once_cell",
- "rustix",
- "windows-sys",
-]
-
-[[package]]
-name = "textwrap"
-version = "0.16.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
-dependencies = [
- "smawk",
-]
-
-[[package]]
-name = "thiserror"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
-dependencies = [
- "thiserror-impl 1.0.69",
-]
-
-[[package]]
-name = "thiserror"
-version = "2.0.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
-dependencies = [
- "thiserror-impl 2.0.17",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "2.0.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "toml"
-version = "0.9.11+spec-1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46"
-dependencies = [
- "indexmap",
- "serde_core",
- "serde_spanned",
- "toml_datetime",
- "toml_parser",
- "toml_writer",
- "winnow",
-]
-
-[[package]]
-name = "toml_datetime"
-version = "0.7.5+spec-1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347"
-dependencies = [
- "serde_core",
-]
-
-[[package]]
-name = "toml_parser"
-version = "1.0.6+spec-1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44"
-dependencies = [
- "winnow",
-]
-
-[[package]]
-name = "toml_writer"
-version = "1.0.6+spec-1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607"
-
-[[package]]
-name = "tracing"
-version = "0.1.44"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
-dependencies = [
- "pin-project-lite",
- "tracing-attributes",
- "tracing-core",
-]
-
-[[package]]
-name = "tracing-attributes"
-version = "0.1.31"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "tracing-core"
-version = "0.1.36"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
-dependencies = [
- "once_cell",
- "valuable",
-]
-
-[[package]]
-name = "unicode-ident"
-version = "1.0.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
-
-[[package]]
-name = "uniffi"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8c6dec3fc6645f71a16a3fa9ff57991028153bd194ca97f4b55e610c73ce66a"
-dependencies = [
- "anyhow",
- "cargo_metadata",
- "uniffi_bindgen",
- "uniffi_core",
- "uniffi_macros",
- "uniffi_pipeline",
-]
-
-[[package]]
-name = "uniffi_bindgen"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ed0150801958d4825da56a41c71f000a457ac3a4613fa9647df78ac4b6b6881"
-dependencies = [
- "anyhow",
- "askama",
- "camino",
- "cargo_metadata",
- "fs-err",
- "glob",
- "goblin",
- "heck",
- "indexmap",
- "once_cell",
- "serde",
- "tempfile",
- "textwrap",
- "toml",
- "uniffi_internal_macros",
- "uniffi_meta",
- "uniffi_pipeline",
- "uniffi_udl",
-]
-
-[[package]]
-name = "uniffi_core"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0ef62e69762fbb9386dcb6c87cd3dd05d525fa8a3a579a290892e60ddbda47e"
-dependencies = [
- "anyhow",
- "bytes",
- "once_cell",
- "static_assertions",
-]
-
-[[package]]
-name = "uniffi_internal_macros"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "98f51ebca0d9a4b2aa6c644d5ede45c56f73906b96403c08a1985e75ccb64a01"
-dependencies = [
- "anyhow",
- "indexmap",
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "uniffi_macros"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db9d12529f1223d014fd501e5f29ca0884d15d6ed5ddddd9f506e55350327dc3"
-dependencies = [
- "camino",
- "fs-err",
- "once_cell",
- "proc-macro2",
- "quote",
- "serde",
- "syn",
- "toml",
- "uniffi_meta",
-]
-
-[[package]]
-name = "uniffi_meta"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9df6d413db2827c68588f8149d30d49b71d540d46539e435b23a7f7dbd4d4f86"
-dependencies = [
- "anyhow",
- "siphasher",
- "uniffi_internal_macros",
- "uniffi_pipeline",
-]
-
-[[package]]
-name = "uniffi_pipeline"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a806dddc8208f22efd7e95a5cdf88ed43d0f3271e8f63b47e757a8bbdb43b63a"
-dependencies = [
- "anyhow",
- "heck",
- "indexmap",
- "tempfile",
- "uniffi_internal_macros",
-]
-
-[[package]]
-name = "uniffi_udl"
-version = "0.31.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d1a7339539bf6f6fa3e9b534dece13f778bda2d54b1a6d4e40b4d6090ac26e7"
-dependencies = [
- "anyhow",
- "textwrap",
- "uniffi_meta",
- "weedle2",
-]
-
-[[package]]
-name = "valuable"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
-
-[[package]]
-name = "walkdir"
-version = "2.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
-dependencies = [
- "same-file",
- "winapi-util",
-]
-
-[[package]]
-name = "wasip2"
-version = "1.0.2+wasi-0.2.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
-dependencies = [
- "wit-bindgen",
-]
-
-[[package]]
-name = "weedle2"
-version = "5.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e"
-dependencies = [
- "nom",
-]
-
-[[package]]
-name = "winapi-util"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
-dependencies = [
- "windows-sys",
-]
-
-[[package]]
-name = "windows-link"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
-
-[[package]]
-name = "windows-sys"
-version = "0.61.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
-dependencies = [
- "windows-link",
-]
-
-[[package]]
-name = "winnow"
-version = "0.7.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
-dependencies = [
- "memchr",
-]
-
-[[package]]
-name = "wit-bindgen"
-version = "0.51.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
-
-[[package]]
-name = "zmij"
-version = "1.0.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea"
diff --git a/mobile/native/darwin/Packages/Rust/rust/Cargo.toml b/mobile/native/darwin/Packages/Rust/rust/Cargo.toml
deleted file mode 100644
index 7dac98c0de..0000000000
--- a/mobile/native/darwin/Packages/Rust/rust/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "inference_rs_uniffi"
-version = "0.1.0"
-edition = "2024"
-
-[lib]
-name = "inference_rs_uniffi"
-crate-type = ["staticlib", "cdylib"]
-
-[dependencies]
-inference_rs = { path = "../../../../../../rust/ensu/inference" }
-serde = { version = "1", features = ["derive"] }
-thiserror = "1"
-uniffi = { version = "0.31.0" }
diff --git a/mobile/native/darwin/Packages/Rust/rust/src/api.rs b/mobile/native/darwin/Packages/Rust/rust/src/api.rs
deleted file mode 100644
index 9e3eb8a9a3..0000000000
--- a/mobile/native/darwin/Packages/Rust/rust/src/api.rs
+++ /dev/null
@@ -1,376 +0,0 @@
-use inference_rs as core;
-use serde::{Deserialize, Serialize};
-use std::sync::Arc;
-use thiserror::Error;
-
-#[derive(Debug, Error, uniffi::Error)]
-pub enum InferenceError {
- #[error("{0}")]
- Message(String),
-}
-
-impl From<String> for InferenceError {
- fn from(value: String) -> Self {
- Self::Message(value)
- }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct ModelLoadParams {
- pub model_path: String,
- pub n_gpu_layers: Option<i32>,
- pub use_mmap: Option<bool>,
- pub use_mlock: Option<bool>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct ContextParams {
- pub context_size: Option<i32>,
- pub n_threads: Option<i32>,
- pub n_batch: Option<i32>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct ModelInfo {
- pub bos_token_id: Option<i32>,
- pub eos_token_id: Option<i32>,
- pub bos_token: Option<String>,
- pub eos_token: Option<String>,
- pub chat_template: Option<String>,
- pub metadata_json: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct EnsuModelPreset {
- pub id: String,
- pub title: String,
- pub url: String,
- pub mmproj_url: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct EnsuDefaults {
- pub mobile_system_prompt_body: String,
- pub desktop_system_prompt_body: String,
- pub system_prompt_date_placeholder: String,
- pub session_summary_system_prompt: String,
- pub mobile_default_model: EnsuModelPreset,
- pub mobile_model_presets: Vec<EnsuModelPreset>,
- pub desktop_default_model: EnsuModelPreset,
- pub desktop_model_presets: Vec<EnsuModelPreset>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct ChatMessage {
- pub role: String,
- pub content: String,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct GenerateRequest {
- pub prompt: String,
- pub max_tokens: Option<i32>,
- pub temperature: Option<f32>,
- pub top_p: Option<f32>,
- pub top_k: Option<i32>,
- pub repeat_penalty: Option<f32>,
- pub frequency_penalty: Option<f32>,
- pub presence_penalty: Option<f32>,
- pub seed: Option<i64>,
- pub stop_sequences: Option<Vec<String>>,
- pub grammar: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct GenerateChatRequest {
- pub messages: Vec<ChatMessage>,
- pub template_override: Option<String>,
- pub add_assistant: Option<bool>,
- pub image_paths: Option<Vec<String>>,
- pub mmproj_path: Option<String>,
- pub media_marker: Option<String>,
- pub max_tokens: Option<i32>,
- pub temperature: Option<f32>,
- pub top_p: Option<f32>,
- pub top_k: Option<i32>,
- pub repeat_penalty: Option<f32>,
- pub frequency_penalty: Option<f32>,
- pub presence_penalty: Option<f32>,
- pub seed: Option<i64>,
- pub stop_sequences: Option<Vec<String>>,
- pub grammar: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
-pub struct GenerateSummary {
- pub job_id: i64,
- pub prompt_tokens: Option<i32>,
- pub generated_tokens: Option<i32>,
- pub total_time_ms: Option<i64>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Enum)]
-pub enum GenerateEvent {
- Text {
- job_id: i64,
- text: String,
- token_id: Option<i32>,
- },
- Done { summary: GenerateSummary },
- Error { job_id: i64, message: String },
-}
-
-#[derive(uniffi::Object)]
-pub struct ModelHandle {
- handle: core::ModelHandleRef,
-}
-
-#[derive(uniffi::Object)]
-pub struct ContextHandle {
- handle: core::ContextHandleRef,
-}
-
-#[uniffi::export(callback_interface)]
-pub trait GenerateEventCallback: Send + Sync {
- fn on_event(&self, event: GenerateEvent);
-}
-
-impl From<ModelLoadParams> for core::ModelLoadParams {
- fn from(value: ModelLoadParams) -> Self {
- Self {
- model_path: value.model_path,
- n_gpu_layers: value.n_gpu_layers,
- use_mmap: value.use_mmap,
- use_mlock: value.use_mlock,
- }
- }
-}
-
-impl From<ContextParams> for core::ContextParams {
- fn from(value: ContextParams) -> Self {
- Self {
- context_size: value.context_size,
- n_threads: value.n_threads,
- n_batch: value.n_batch,
- }
- }
-}
-
-impl From<core::ModelInfo> for ModelInfo {
- fn from(value: core::ModelInfo) -> Self {
- Self {
- bos_token_id: value.bos_token_id,
- eos_token_id: value.eos_token_id,
- bos_token: value.bos_token,
- eos_token: value.eos_token,
- chat_template: value.chat_template,
- metadata_json: value.metadata_json,
- }
- }
-}
-
-impl From<core::EnsuModelPreset> for EnsuModelPreset {
- fn from(value: core::EnsuModelPreset) -> Self {
- Self {
- id: value.id,
- title: value.title,
- url: value.url,
- mmproj_url: value.mmproj_url,
- }
- }
-}
-
-impl From<core::EnsuDefaults> for EnsuDefaults {
- fn from(value: core::EnsuDefaults) -> Self {
- Self {
- mobile_system_prompt_body: value.mobile_system_prompt_body,
- desktop_system_prompt_body: value.desktop_system_prompt_body,
- system_prompt_date_placeholder: value.system_prompt_date_placeholder,
- session_summary_system_prompt: value.session_summary_system_prompt,
- mobile_default_model: value.mobile_default_model.into(),
- mobile_model_presets: value.mobile_model_presets.into_iter().map(Into::into).collect(),
- desktop_default_model: value.desktop_default_model.into(),
- desktop_model_presets: value.desktop_model_presets.into_iter().map(Into::into).collect(),
- }
- }
-}
-
-impl From<ChatMessage> for core::ChatMessage {
- fn from(value: ChatMessage) -> Self {
- Self {
- role: value.role,
- content: value.content,
- }
- }
-}
-
-impl From<GenerateRequest> for core::GenerateRequest {
- fn from(value: GenerateRequest) -> Self {
- Self {
- prompt: value.prompt,
- max_tokens: value.max_tokens,
- temperature: value.temperature,
- top_p: value.top_p,
- top_k: value.top_k,
- repeat_penalty: value.repeat_penalty,
- frequency_penalty: value.frequency_penalty,
- presence_penalty: value.presence_penalty,
- seed: value.seed,
- stop_sequences: value.stop_sequences,
- grammar: value.grammar,
- }
- }
-}
-
-impl From<GenerateChatRequest> for core::GenerateChatRequest {
- fn from(value: GenerateChatRequest) -> Self {
- Self {
- messages: value.messages.into_iter().map(Into::into).collect(),
- template_override: value.template_override,
- add_assistant: value.add_assistant,
- image_paths: value.image_paths,
- mmproj_path: value.mmproj_path,
- media_marker: value.media_marker,
- max_tokens: value.max_tokens,
- temperature: value.temperature,
- top_p: value.top_p,
- top_k: value.top_k,
- repeat_penalty: value.repeat_penalty,
- frequency_penalty: value.frequency_penalty,
- presence_penalty: value.presence_penalty,
- seed: value.seed,
- stop_sequences: value.stop_sequences,
- grammar: value.grammar,
- }
- }
-}
-
-impl From<core::GenerateSummary> for GenerateSummary {
- fn from(value: core::GenerateSummary) -> Self {
- Self {
- job_id: value.job_id,
- prompt_tokens: value.prompt_tokens,
- generated_tokens: value.generated_tokens,
- total_time_ms: value.total_time_ms,
- }
- }
-}
-
-impl From<core::GenerateEvent> for GenerateEvent {
- fn from(value: core::GenerateEvent) -> Self {
- match value {
- core::GenerateEvent::Text {
- job_id,
- text,
- token_id,
- } => Self::Text {
- job_id,
- text,
- token_id,
- },
- core::GenerateEvent::Done { summary } => Self::Done {
- summary: summary.into(),
- },
- core::GenerateEvent::Error { job_id, message } => Self::Error { job_id, message },
- }
- }
-}
-
-struct CallbackSink {
- callback: Box<dyn GenerateEventCallback>,
-}
-
-impl core::EventSink for CallbackSink {
- fn add(&mut self, event: core::GenerateEvent) {
- self.callback.on_event(event.into());
- }
-}
-
-#[uniffi::export]
-pub fn init_backend() -> Result<(), InferenceError> {
- core::init_backend().map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn load_model(params: ModelLoadParams) -> Result<Arc<ModelHandle>, InferenceError> {
- let model = core::load_model(params.into()).map_err(InferenceError::from)?;
- Ok(Arc::new(ModelHandle { handle: model }))
-}
-
-#[uniffi::export]
-pub fn create_context(
- model: Arc<ModelHandle>,
- params: ContextParams,
-) -> Result<Arc<ContextHandle>, InferenceError> {
- let context = core::create_context(model.handle.clone(), params.into()).map_err(InferenceError::from)?;
- Ok(Arc::new(ContextHandle { handle: context }))
-}
-
-#[uniffi::export]
-pub fn tokenize(
- model: Arc<ModelHandle>,
- text: String,
- add_bos: bool,
- special: bool,
-) -> Result<Vec<i32>, InferenceError> {
- core::tokenize(model.handle.as_ref(), text, add_bos, special)
- .map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn detokenize(model: Arc<ModelHandle>, tokens: Vec<i32>) -> Result<String, InferenceError> {
- core::detokenize(model.handle.as_ref(), tokens).map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn get_model_info(model: Arc<ModelHandle>) -> Result<ModelInfo, InferenceError> {
- core::get_model_info(model.handle.as_ref())
- .map(Into::into)
- .map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn get_ensu_defaults() -> EnsuDefaults {
- core::ensu_defaults().into()
-}
-
-#[uniffi::export]
-pub fn apply_chat_template(
- model: Arc<ModelHandle>,
- messages: Vec<ChatMessage>,
- template_override: Option<String>,
- add_assistant: bool,
-) -> Result<String, InferenceError> {
- let messages = messages.into_iter().map(Into::into).collect();
- core::apply_chat_template(model.handle.as_ref(), messages, template_override, add_assistant)
- .map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn generate_chat_stream(
- context: Arc<ContextHandle>,
- request: GenerateChatRequest,
- callback: Box<dyn GenerateEventCallback>,
-) -> Result<GenerateSummary, InferenceError> {
- let mut sink = CallbackSink { callback };
- core::generate_chat_stream(context.handle.as_ref(), request.into(), &mut sink)
- .map(Into::into)
- .map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn generate_stream(
- context: Arc<ContextHandle>,
- request: GenerateRequest,
- callback: Box<dyn GenerateEventCallback>,
-) -> Result<GenerateSummary, InferenceError> {
- let mut sink = CallbackSink { callback };
- core::generate_stream(context.handle.as_ref(), request.into(), &mut sink)
- .map(Into::into)
- .map_err(InferenceError::from)
-}
-
-#[uniffi::export]
-pub fn cancel(job_id: i64) {
- let _ = core::cancel(job_id);
-}
diff --git a/mobile/native/darwin/Packages/Rust/rust/src/lib.rs b/mobile/native/darwin/Packages/Rust/rust/src/lib.rs
deleted file mode 100644
index dce5d9a1da..0000000000
--- a/mobile/native/darwin/Packages/Rust/rust/src/lib.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#![allow(unexpected_cfgs)]
-
-mod api;
-
-uniffi::setup_scaffolding!("inference_rs_uniffi");
-
-pub use api::*;
diff --git a/mobile/native/darwin/Packages/Rust/rust/uniffi.toml b/mobile/native/darwin/Packages/Rust/rust/uniffi.toml
deleted file mode 100644
index f3de948c2b..0000000000
--- a/mobile/native/darwin/Packages/Rust/rust/uniffi.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[bindings.swift]
-link_frameworks = ["Accelerate", "Metal", "MetalKit", "Foundation"]
-
-[bindings.kotlin]
-package_name = "io.ente.labs.inference_rs"
-cdylib_name = "inference_rs_uniffi"
-android = true
-kotlin_target_version = "1.9.0"
diff --git a/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh b/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
index 8d0288b01d..d7e2b6271d 100755
--- a/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
+++ b/mobile/native/darwin/Packages/Rust/tool/build_xcframework.sh
@@ -3,11 +3,11 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
-RUST_DIR="$ROOT/rust"
+RUST_DIR="$REPO_ROOT/rust/uniffi/ensu/inference"
CORE_ROOT="$REPO_ROOT/rust/ensu/inference"
PATCH_SCRIPT="$CORE_ROOT/tool/patch_llama_mtmd.sh"
APPLY_LLAMA_MTMD_PATCH="${APPLY_LLAMA_MTMD_PATCH:-1}"
-LIB_NAME="libinference_rs_uniffi.a"
+LIB_NAME="libinference.a"
require_command() {
local name="$1"
@@ -60,8 +60,8 @@ fi
"$ROOT/tool/generate_bindings.sh"
HEADER_DIR="$ROOT/build/headers"
-HEADER_SRC="$ROOT/Sources/InferenceRS/inference_rs_uniffiFFI.h"
-MODULEMAP_SRC="$ROOT/Sources/InferenceRS/inference_rs_uniffiFFI.modulemap"
+HEADER_SRC="$ROOT/Sources/InferenceRS/inferenceFFI.h"
+MODULEMAP_SRC="$ROOT/Sources/InferenceRS/inferenceFFI.modulemap"
rm -rf "$HEADER_DIR"
mkdir -p "$ROOT/build/ios" "$ROOT/build/macos" "$HEADER_DIR"
diff --git a/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh b/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
index 3df24f86c3..332a186a93 100755
--- a/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
+++ b/mobile/native/darwin/Packages/Rust/tool/generate_bindings.sh
@@ -3,7 +3,7 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
-RUST_DIR="$ROOT/rust"
+RUST_DIR="$REPO_ROOT/rust/uniffi/ensu/inference"
CORE_ROOT="$REPO_ROOT/rust/ensu/inference"
PATCH_SCRIPT="$CORE_ROOT/tool/patch_llama_mtmd.sh"
APPLY_LLAMA_MTMD_PATCH="${APPLY_LLAMA_MTMD_PATCH:-1}"
@@ -64,7 +64,7 @@ else
LIB_EXT="dll"
fi
-LIB_PATH="$RUST_DIR/target/release/libinference_rs_uniffi.$LIB_EXT"
+LIB_PATH="$RUST_DIR/target/release/libinference.$LIB_EXT"
if [[ ! -f "$LIB_PATH" ]]; then
echo "Expected $LIB_PATH to exist" >&2
@@ -72,8 +72,8 @@ if [[ ! -f "$LIB_PATH" ]]; then
fi
mkdir -p "$OUT_DIR"
-rm -f "$OUT_DIR"/inference_rs_*
+rm -f "$OUT_DIR"/inference* "$OUT_DIR"/inference_rs_uniffi*
pushd "$RUST_DIR" >/dev/null
-uniffi-bindgen generate "$LIB_PATH" --language swift --out-dir "$OUT_DIR" --crate inference_rs_uniffi
+uniffi-bindgen generate "$LIB_PATH" --language swift --out-dir "$OUT_DIR" --crate inference
popd >/dev/null