π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Upgrade UniFFI and adopt borrowed byte inputs
Manav Rathidefa7295a813
diff --git a/android/apps/ensu/app/src/main/java/io/ente/ensu/ByteBuffers.kt b/android/apps/ensu/app/src/main/java/io/ente/ensu/ByteBuffers.ktnew file mode 100644index 0000000000..9f47885770--- /dev/null+++ b/android/apps/ensu/app/src/main/java/io/ente/ensu/ByteBuffers.kt@@ -0,0 +1,6 @@+package io.ente.ensu++import java.nio.ByteBuffer++internal fun ByteArray.toDirectByteBuffer(): ByteBuffer =+ ByteBuffer.allocateDirect(size).put(this).apply { flip() }diff --git a/android/apps/ensu/app/src/main/java/io/ente/ensu/HomeView.kt b/android/apps/ensu/app/src/main/java/io/ente/ensu/HomeView.ktindex e56db1c748..51682f4ccf 100644--- a/android/apps/ensu/app/src/main/java/io/ente/ensu/HomeView.kt+++ b/android/apps/ensu/app/src/main/java/io/ente/ensu/HomeView.kt@@ -476,7 +476,7 @@ private fun buildAttachmentFromUri(if (type == AttachmentType.Image) {val inputStream = resolver.openInputStream(uri) ?: return@runCatching nullval originalBytes = inputStream.use { input -> input.readAttachmentImageBytes() }- val compressedBytes = compressAttachmentImage(originalBytes)+ val compressedBytes = compressAttachmentImage(originalBytes.toDirectByteBuffer())FileOutputStream(destination).use { output -> output.write(compressedBytes) }finalName = normalizedJpegAttachmentName(name ?: safeName)} else {diff --git a/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/VoiceInput.kt b/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/VoiceInput.ktindex 25c79d67df..46b4580593 100644--- a/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/VoiceInput.kt+++ b/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/VoiceInput.kt@@ -24,6 +24,7 @@ import io.ente.ensu.bindings.voiceActivityModelAssetimport io.ente.ensu.llm.ModelMaintenanceimport io.ente.ensu.llm.withMaintenanceSuspendedimport io.ente.ensu.notes.LocalNotesStore+import io.ente.ensu.toDirectByteBufferimport java.io.ByteArrayOutputStreamimport java.io.IOExceptionimport kotlin.coroutines.CoroutineContext@@ -312,7 +313,7 @@ internal class VoiceTranscriptionController(}transcriber.transcribe(sampleRate.toUInt(),- pcm,+ pcm.toDirectByteBuffer(),)}.trim()diff --git a/android/apps/ensu/app/src/main/java/io/ente/ensu/notes/NotesProvider.kt b/android/apps/ensu/app/src/main/java/io/ente/ensu/notes/NotesProvider.ktindex ff957e3313..ed65d7bec8 100644--- a/android/apps/ensu/app/src/main/java/io/ente/ensu/notes/NotesProvider.kt+++ b/android/apps/ensu/app/src/main/java/io/ente/ensu/notes/NotesProvider.kt@@ -15,6 +15,7 @@ import io.ente.ensu.bindings.NotesExceptionimport io.ente.ensu.bindings.NotesIndexOptionsimport io.ente.ensu.bindings.NotesProgressCallbackimport io.ente.ensu.bindings.notesContentRevision+import io.ente.ensu.toDirectByteBufferimport java.io.ByteArrayOutputStreamimport java.io.Fileimport java.util.UUID@@ -175,7 +176,7 @@ class NotesProvider(private val context: Context) {): ByteArray =NotesCancellation().use { cancel ->val bytes = withSource(record, cancel) { it.readDocument(reference.documentId) }.bytes- if (notesContentRevision(bytes) != reference.indexedRevision)+ if (notesContentRevision(bytes.toDirectByteBuffer()) != reference.indexedRevision)throw NotesException.SourceChanged()bytes}diff --git a/android/apps/ensu/rust/build.gradle.kts b/android/apps/ensu/rust/build.gradle.ktsindex f24509433e..59e4c0481b 100644--- a/android/apps/ensu/rust/build.gradle.kts+++ b/android/apps/ensu/rust/build.gradle.kts@@ -123,13 +123,7 @@ android {}}-kotlin {- compilerOptions {- jvmTarget.set(JvmTarget.JVM_17)- // TODO: Remove when UniFFI releases https://github.com/mozilla/uniffi-rs/pull/2949.- freeCompilerArgs.add("-Xwarning-level=UNUSED_EXPRESSION:warning")- }-}+kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_17) } }tasks.matching { it.name == "preDebugBuild" }.configureEach { dependsOn(buildRustJniDebug) }diff --git a/apple/apps/ensu/EnsuTests/NotesIntegrationTests.swift b/apple/apps/ensu/EnsuTests/NotesIntegrationTests.swiftindex 0c3ea12698..f6b191b366 100644--- a/apple/apps/ensu/EnsuTests/NotesIntegrationTests.swift+++ b/apple/apps/ensu/EnsuTests/NotesIntegrationTests.swift@@ -1,3 +1,4 @@+import CryptoKitimport XCTest@testable import Ensu@@ -11,6 +12,14 @@ private final class UnavailableNotesSource: NotesSource {}final class NotesIntegrationTests: XCTestCase {+ func testContentRevisionReadsBorrowedBytes() {+ let bytes = Data((0..<131_073).map { UInt8(truncatingIfNeeded: $0) })+ for input in [Data(), Data([0]), bytes, bytes.dropFirst()] {+ let expected = SHA256.hash(data: input).map { String(format: "%02x", $0) }.joined()+ XCTAssertEqual(notesContentRevision(bytes: input), expected)+ }+ }+func testNativeSourceFailureAndCancellationCrossTheBridge() throws {let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)defer { try? FileManager.default.removeItem(at: root) }diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex dbe46f253a..2e63168e7d 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -299,11 +299,11 @@ dependencies = [[[package]]name = "askama"-version = "0.14.0"+version = "0.16.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"+checksum = "6024d73179f43f15ccd2b881bfea6fee7f3a46ec53f33b52210dea749ebebaa4"dependencies = [- "askama_derive",+ "askama_macros","itoa","percent-encoding","serde",@@ -312,31 +312,42 @@ dependencies = [[[package]]name = "askama_derive"-version = "0.14.0"+version = "0.16.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"+checksum = "071ee5ebf2138e3ad180e0aacf6940c2cab5e6d8333741d9925c7bee2b153f39"dependencies = ["askama_parser","basic-toml",+ "glob","memchr","proc-macro2","quote","rustc-hash","serde","serde_derive",- "syn 2.0.117",+ "syn 3.0.6",+]++[[package]]+name = "askama_macros"+version = "0.16.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "643e1c7cbb6aec1d920332fe51a7c0d8219e273dcb8602db03f5263e4d16487b"+dependencies = [+ "askama_derive",][[package]]name = "askama_parser"-version = "0.14.0"+version = "0.16.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"+checksum = "2c5ae75772275d268b03ab8bdccdd12117b6169ee23256942b34e46c9f476583"dependencies = [- "memchr",+ "rustc-hash","serde","serde_derive",- "winnow 0.7.15",+ "unicode-ident",+ "winnow 1.0.1",][[package]]@@ -1032,6 +1043,16 @@ dependencies = ["serde",]+[[package]]+name = "cargo-platform"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba"+dependencies = [+ "serde",+ "serde_core",+]+[[package]]name = "cargo_metadata"version = "0.14.2"@@ -1039,7 +1060,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"dependencies = ["camino",- "cargo-platform",+ "cargo-platform 0.1.9","semver","serde","serde_json",@@ -1052,7 +1073,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"dependencies = ["camino",- "cargo-platform",+ "cargo-platform 0.1.9",+ "semver",+ "serde",+ "serde_json",+ "thiserror 2.0.18",+]++[[package]]+name = "cargo_metadata"+version = "0.23.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9"+dependencies = [+ "camino",+ "cargo-platform 0.3.3","semver","serde","serde_json",@@ -3494,9 +3529,9 @@ dependencies = [[[package]]name = "fs-err"-version = "2.11.0"+version = "3.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41"+checksum = "b91aa448ca50d7e79433bdf3ee8d99215430d2ec02ade5aefab2a073a1822e8a"dependencies = ["autocfg",]@@ -9222,6 +9257,17 @@ dependencies = ["unicode-ident",]+[[package]]+name = "syn"+version = "3.0.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]+[[package]]name = "sync_wrapper"version = "1.0.2"@@ -10395,12 +10441,12 @@ checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"[[package]]name = "uniffi"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "46eefd5468602930da46b1f49d3448c6dfc2e81295f93120f23f8174fd70267f"+checksum = "76407f5f396a2c949a069eff4a9fca9ce462410eb872bffef4c2b7b89804a77a"dependencies = ["anyhow",- "cargo_metadata 0.19.2",+ "cargo_metadata 0.23.1","uniffi_bindgen","uniffi_core","uniffi_macros",@@ -10409,14 +10455,14 @@ dependencies = [[[package]]name = "uniffi_bindgen"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c4a0c9b375d32e1365cdb2bdd7cb495eecf6fac851ddbad077412b4ee1888514"+checksum = "3df3ced8f0eda3de99f6d50820e8628f443da8e4f447f477d1403ceba29dacbd"dependencies = ["anyhow","askama","camino",- "cargo_metadata 0.19.2",+ "cargo_metadata 0.23.1","fs-err","glob","goblin",@@ -10426,7 +10472,7 @@ dependencies = ["serde","tempfile","textwrap",- "toml 0.9.12+spec-1.1.0",+ "toml 1.1.2+spec-1.1.0","uniffi_internal_macros","uniffi_meta","uniffi_pipeline",@@ -10435,9 +10481,9 @@ dependencies = [[[package]]name = "uniffi_core"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "eec017b112701681f6fbbe5d92014b5c468eb0b177a94389de03ceec40665095"+checksum = "f7530ae8efeaaa488622865966763fe0294832779fff80508c36d69c6a874a6a"dependencies = ["anyhow","async-compat",@@ -10448,9 +10494,9 @@ dependencies = [[[package]]name = "uniffi_internal_macros"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4641669b48fefbc5e80ff08c5004d9c7617fb91232131a6734ab6712779cb04c"+checksum = "0f4bad017164375d99450d70495014810d15a84ba9da6ed14b9628b1424223ba"dependencies = ["anyhow","indexmap 2.14.0",@@ -10461,9 +10507,9 @@ dependencies = [[[package]]name = "uniffi_macros"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "eeb8617ee814de22caf7417bf514715ba0b3f46bd9d5a5d794413fd8282cb737"+checksum = "5b855a58da153739ce6e863f6e296edc3716a093768c4d3d957f17f5e4317c60"dependencies = ["camino","fs-err",@@ -10472,15 +10518,15 @@ dependencies = ["quote","serde","syn 2.0.117",- "toml 0.9.12+spec-1.1.0",+ "toml 1.1.2+spec-1.1.0","uniffi_meta",][[package]]name = "uniffi_meta"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "58d5b94fc92803d21b2928bd15c6f06e57609b95caf98ea561c99cda1b6d2a25"+checksum = "af0c88664a9cb9559856f5a250283c9708923b303170e2e5c7db8f4ad65e9459"dependencies = ["anyhow","siphasher",@@ -10490,9 +10536,9 @@ dependencies = [[[package]]name = "uniffi_pipeline"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "032739b3ec725576914c15899dedaf080163ced86b6934566c20ec2b20ce90ca"+checksum = "d00f5c044b4a3dca0b1226c92ddaeea626f337470e22180dd182160c87a06b0b"dependencies = ["anyhow","heck 0.5.0",@@ -10503,9 +10549,9 @@ dependencies = [[[package]]name = "uniffi_udl"-version = "0.31.2"+version = "0.32.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fc0a1d0a0252ce1af9e8ce78ba67ac0d8937fb2bedaf10cbddd43d3614d06ec6"+checksum = "55dfd9c778d6b39cb5acd541d9ff63431974035d2bad83c897b766a6ee3152ac"dependencies = ["anyhow","textwrap",diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex f721c607e9..3609dc2fa1 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -113,8 +113,8 @@ thiserror = "2.0.18"tokio = "1.41.0"tsify = { version = "0.5.8", default-features = false, features = ["js"] }unicode-normalization = "0.1.25"-uniffi = { version = "=0.31.2" }-uniffi_bindgen = { version = "=0.31.2", default-features = false, features = ["cargo-metadata"] }+uniffi = { version = "=0.32.2" }+uniffi_bindgen = { version = "=0.32.2", default-features = false, features = ["cargo-metadata"] }url = "2.5.8"urlencoding = "2.1.3"uuid = "1.23.1"diff --git a/rust/bindings/uniffi/cast/src/lib.rs b/rust/bindings/uniffi/cast/src/lib.rsindex e3dbaa8cea..860eb6cb63 100644--- a/rust/bindings/uniffi/cast/src/lib.rs+++ b/rust/bindings/uniffi/cast/src/lib.rs@@ -75,25 +75,25 @@ impl CastReceiver {#[uniffi::export]pub fn open_secret_box(- ciphertext: Vec<u8>,- nonce: Vec<u8>,- key: Vec<u8>,+ ciphertext: &[u8],+ nonce: &[u8],+ key: &[u8],) -> Result<Vec<u8>, CastCryptoError> {- let nonce = crypto::Nonce::try_from_slice(&nonce)?;- let key = crypto::Key::try_from_slice(&key)?;- Ok(crypto::secretbox::decrypt(&ciphertext, &nonce, &key)?)+ let nonce = crypto::Nonce::try_from_slice(nonce)?;+ let key = crypto::Key::try_from_slice(key)?;+ Ok(crypto::secretbox::decrypt(ciphertext, &nonce, &key)?)}#[uniffi::export]pub fn decrypt_secret_stream(- encrypted_data: Vec<u8>,- header: Vec<u8>,- key: Vec<u8>,+ encrypted_data: &[u8],+ header: &[u8],+ key: &[u8],) -> Result<Vec<u8>, CastCryptoError> {- let header = crypto::Header::try_from_slice(&header)?;- let key = crypto::Key::try_from_slice(&key)?;+ let header = crypto::Header::try_from_slice(header)?;+ let key = crypto::Key::try_from_slice(key)?;Ok(crypto::stream::decrypt_file_data(- &encrypted_data,+ encrypted_data,&header,&key,)?)diff --git a/rust/bindings/uniffi/ensu/src/assets.rs b/rust/bindings/uniffi/ensu/src/assets.rsindex 2aebbec706..d6de1aa74f 100644--- a/rust/bindings/uniffi/ensu/src/assets.rs+++ b/rust/bindings/uniffi/ensu/src/assets.rs@@ -113,7 +113,7 @@ impl From<ente_assets::AssetDownloadProgress> for AssetDownloadProgress {}}-#[uniffi::export(callback_interface)]+#[uniffi::export(foreign)]pub trait AssetDownloadCallback: Send + Sync {fn on_progress(&self, progress: AssetDownloadProgress);}@@ -207,7 +207,7 @@ impl AssetStoreCore {pub async fn download(&self,assets: Vec<Arc<Asset>>,- callback: Box<dyn AssetDownloadCallback>,+ callback: Arc<dyn AssetDownloadCallback>,cancellation: Arc<CancellationToken>,) -> Result<(), AssetDownloadError> {let assets = assetsdiff --git a/rust/bindings/uniffi/ensu/src/conversation.rs b/rust/bindings/uniffi/ensu/src/conversation.rsindex b121306a78..a13f7bd255 100644--- a/rust/bindings/uniffi/ensu/src/conversation.rs+++ b/rust/bindings/uniffi/ensu/src/conversation.rs@@ -57,7 +57,7 @@ pub struct ConversationResult {pub max_tokens: u32,}-#[uniffi::export(callback_interface)]+#[uniffi::export(foreign)]pub trait ConversationProgressCallback: Send + Sync {fn on_progress(&self);}@@ -213,7 +213,7 @@ impl ConversationPreparation {pub fn run(&self,- callback: Box<dyn ConversationProgressCallback>,+ callback: Arc<dyn ConversationProgressCallback>,) -> Result<ConversationResult, ConversationError> {let mut work = self.work.lock().map_err(error)?;self.check(&work)?;diff --git a/rust/bindings/uniffi/ensu/src/image.rs b/rust/bindings/uniffi/ensu/src/image.rsindex da52ed94c3..9eeab20231 100644--- a/rust/bindings/uniffi/ensu/src/image.rs+++ b/rust/bindings/uniffi/ensu/src/image.rs@@ -8,8 +8,8 @@ pub enum ImageError {}#[uniffi::export]-pub fn compress_attachment_image(data: Vec<u8>) -> Result<Vec<u8>, ImageError> {- image::compress_attachment_image(&data).map_err(|error| ImageError::Other {+pub fn compress_attachment_image(data: &[u8]) -> Result<Vec<u8>, ImageError> {+ image::compress_attachment_image(data).map_err(|error| ImageError::Other {detail: ente_core::error::chain(&error),})}diff --git a/rust/bindings/uniffi/ensu/src/llm.rs b/rust/bindings/uniffi/ensu/src/llm.rsindex 5620782587..cbff921155 100644--- a/rust/bindings/uniffi/ensu/src/llm.rs+++ b/rust/bindings/uniffi/ensu/src/llm.rs@@ -149,7 +149,7 @@ impl LlmContext {pub fn generate_chat_stream(&self,request: LlmChatRequest,- callback: Box<dyn LlmGenerationEventCallback>,+ callback: Arc<dyn LlmGenerationEventCallback>,) -> Result<LlmGenerationSummary, LlmError> {let mut sink = CallbackSink { callback };self.handle@@ -169,7 +169,7 @@ impl LlmContext {}}-#[uniffi::export(callback_interface)]+#[uniffi::export(foreign)]pub trait LlmGenerationEventCallback: Send + Sync {fn on_event(&self, event: LlmGenerationEvent);}@@ -267,7 +267,7 @@ impl From<llm::GenerationEvent> for LlmGenerationEvent {}struct CallbackSink {- callback: Box<dyn LlmGenerationEventCallback>,+ callback: Arc<dyn LlmGenerationEventCallback>,}impl llm::EventSink for CallbackSink {diff --git a/rust/bindings/uniffi/ensu/src/notes.rs b/rust/bindings/uniffi/ensu/src/notes.rsindex fdaa40d34e..7c468312f7 100644--- a/rust/bindings/uniffi/ensu/src/notes.rs+++ b/rust/bindings/uniffi/ensu/src/notes.rs@@ -105,7 +105,7 @@ pub struct NotesRead {pub source: NotesDocument,}-#[uniffi::export(callback_interface)]+#[uniffi::export(foreign)]pub trait NotesSource: Send + Sync {fn list_documents(&self) -> Result<Vec<NotesDocument>, NotesError>;fn read_document(&self, document_id: String) -> Result<NotesRead, NotesError>;@@ -117,7 +117,7 @@ pub struct NotesProgress {pub indexed_document_count: u64,}-#[uniffi::export(callback_interface)]+#[uniffi::export(foreign)]pub trait NotesProgressCallback: Send + Sync {fn on_progress(&self, progress: NotesProgress);}@@ -283,7 +283,7 @@ impl NotesCollection {pub fn inspect_freshness(&self,- source: Box<dyn NotesSource>,+ source: Arc<dyn NotesSource>,cancellation: Arc<NotesCancellation>,) -> Result<NotesFreshness, NotesError> {cancellation.check()?;@@ -308,10 +308,10 @@ impl NotesCollection {pub fn index(&self,- source: Box<dyn NotesSource>,+ source: Arc<dyn NotesSource>,context: Arc<LlmContext>,cancellation: Arc<NotesCancellation>,- progress: Box<dyn NotesProgressCallback>,+ progress: Arc<dyn NotesProgressCallback>,options: NotesIndexOptions,) -> Result<NotesOutcome, NotesError> {let NotesIndexOptions {@@ -453,8 +453,8 @@ fn read(}#[uniffi::export]-pub fn notes_content_revision(bytes: Vec<u8>) -> String {- core::notes_content_revision(&bytes)+pub fn notes_content_revision(bytes: &[u8]) -> String {+ core::notes_content_revision(bytes)}#[uniffi::export]diff --git a/rust/bindings/uniffi/ensu/src/transcription.rs b/rust/bindings/uniffi/ensu/src/transcription.rsindex e1d8f0507f..f149f83b5b 100644--- a/rust/bindings/uniffi/ensu/src/transcription.rs+++ b/rust/bindings/uniffi/ensu/src/transcription.rs@@ -64,7 +64,7 @@ impl Transcriber {pub fn transcribe(&self,input_sample_rate: u32,- pcm_le: Vec<u8>,+ pcm_le: &[u8],) -> Result<String, TranscriptionError> {self.inner.transcribe(input_sample_rate, pcm_le)diff --git a/rust/bindings/uniffi/log/src/lib.rs b/rust/bindings/uniffi/log/src/lib.rsindex e4829774d4..f7a521192c 100644--- a/rust/bindings/uniffi/log/src/lib.rs+++ b/rust/bindings/uniffi/log/src/lib.rs@@ -10,20 +10,20 @@ macro_rules! setup {Info,}- #[uniffi::export(callback_interface)]+ #[uniffi::export(foreign)]pub trait RustLogSink: Send + Sync {fn log(&self, level: RustLogLevel, target: String, message: String);}#[uniffi::export]- pub fn init_rust_logging(sink: Box<dyn RustLogSink>) {+ pub fn init_rust_logging(sink: std::sync::Arc<dyn RustLogSink>) {$crate::__log::set_boxed_logger(Box::new(UniffiLogger { sink })).expect("Rust logger already initialized");$crate::__log::set_max_level($crate::__log::LevelFilter::Info);}struct UniffiLogger {- sink: Box<dyn RustLogSink>,+ sink: std::sync::Arc<dyn RustLogSink>,}impl $crate::__log::Log for UniffiLogger {diff --git a/rust/crates/ensu/src/transcription/transcriber.rs b/rust/crates/ensu/src/transcription/transcriber.rsindex 2dfc700bb0..cbfd111cef 100644--- a/rust/crates/ensu/src/transcription/transcriber.rs+++ b/rust/crates/ensu/src/transcription/transcriber.rs@@ -35,7 +35,7 @@ impl Transcriber {*self.lock() = None;}- pub fn transcribe(&self, input_sample_rate: u32, pcm_le: Vec<u8>) -> Result<String> {+ pub fn transcribe(&self, input_sample_rate: u32, pcm_le: &[u8]) -> Result<String> {if pcm_le.is_empty() {return Ok(String::new());}@@ -46,7 +46,7 @@ impl Transcriber {return Err(TranscriptionError::VadNotDownloaded);}- let speech = extract_speech_from_pcm16(&self.vad_model_path, input_sample_rate, &pcm_le)?;+ let speech = extract_speech_from_pcm16(&self.vad_model_path, input_sample_rate, pcm_le)?;if speech.is_empty() {return Ok(String::new());}