commit 9a08fbe627f8a1495fdd61fd9004badbce1ee81c
parent 88f67a8058ac6d584d78b483180d6de0f0dea0c2
Author: triesap <tyson@radroots.org>
Date: Sun, 2 Aug 2026 19:44:56 +0000
build(desktop): generate UniFFI Kotlin bindings
- run the pinned UniFFI generator from the Rust workspace
- place generated Kotlin under ignored desktop build output
- compile the generated package with its pinned JNA runtime
- avoid generated close and exception-name collisions
Diffstat:
5 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/crates/studio_ffi/src/commands.rs b/crates/studio_ffi/src/commands.rs
@@ -17,13 +17,13 @@ use crate::{AccountDto, AppSnapshotDto};
#[derive(Debug, uniffi::Error)]
pub enum StudioError {
- Failure { code: String, message: String },
+ Failure { code: String, safe_message: String },
}
impl Display for StudioError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
match self {
- Self::Failure { message, .. } => formatter.write_str(message),
+ Self::Failure { safe_message, .. } => formatter.write_str(safe_message),
}
}
}
@@ -34,7 +34,7 @@ impl From<SafeError> for StudioError {
fn from(error: SafeError) -> Self {
Self::Failure {
code: format!("{:?}", error.code()),
- message: error.message().as_str().to_owned(),
+ safe_message: error.message().as_str().to_owned(),
}
}
}
@@ -339,21 +339,21 @@ fn runtime() -> &'static tokio::runtime::Runtime {
fn path_unavailable() -> StudioError {
StudioError::Failure {
code: "StorageUnavailable".to_owned(),
- message: "The application data directory is unavailable.".to_owned(),
+ safe_message: "The application data directory is unavailable.".to_owned(),
}
}
fn runtime_unavailable() -> StudioError {
StudioError::Failure {
code: "InvalidApplicationState".to_owned(),
- message: "The application runtime is unavailable.".to_owned(),
+ safe_message: "The application runtime is unavailable.".to_owned(),
}
}
fn confirmation_expired() -> StudioError {
StudioError::Failure {
code: "InvalidApplicationState".to_owned(),
- message: "The account removal confirmation is no longer valid.".to_owned(),
+ safe_message: "The account removal confirmation is no longer valid.".to_owned(),
}
}
diff --git a/crates/studio_ffi/src/observer.rs b/crates/studio_ffi/src/observer.rs
@@ -29,7 +29,7 @@ pub struct ObserverSubscription {
#[uniffi::export]
impl ObserverSubscription {
- pub fn close(&self) {
+ pub fn unsubscribe(&self) {
let handle = self
.handle
.lock()
@@ -48,7 +48,7 @@ impl ObserverSubscription {
impl Drop for ObserverSubscription {
fn drop(&mut self) {
- self.close();
+ self.unsubscribe();
}
}
@@ -86,7 +86,7 @@ impl StudioAppCore {
}))
}
- pub fn close(&self) {
+ pub fn shutdown(&self) {
if self.inner.closed.swap(true, Ordering::AcqRel) {
return;
}
@@ -107,7 +107,7 @@ impl StudioAppCore {
fn closed_error() -> StudioError {
StudioError::Failure {
code: "InvalidApplicationState".to_owned(),
- message: "The application runtime is closed.".to_owned(),
+ safe_message: "The application runtime is closed.".to_owned(),
}
}
@@ -168,7 +168,7 @@ mod tests {
.bootstrap()
.expect("idempotent bootstrap");
assert_eq!(observer.snapshots.lock().expect("snapshots").len(), 1);
- subscription.close();
+ subscription.unsubscribe();
core.inner.adapter.core().sign_out().expect("sign out");
assert_eq!(observer.snapshots.lock().expect("snapshots").len(), 1);
}
@@ -182,8 +182,8 @@ mod tests {
.subscribe(Box::new(ArcObserver(observer.clone())))
.expect("subscribe");
- core.close();
- core.close();
+ core.shutdown();
+ core.shutdown();
assert!(core.subscribe(Box::new(ArcObserver(observer))).is_err());
assert!(core.inner.observers.lock().expect("observers").is_empty());
diff --git a/crates/studio_ffi/uniffi.toml b/crates/studio_ffi/uniffi.toml
@@ -1,3 +1,3 @@
-[bindings.kotlin]
+[crates.radroots_studio_ffi.bindings.kotlin]
package_name = "org.radroots.studio.ffi"
cdylib_name = "radroots_studio_ffi"
diff --git a/crates/studio_uniffi_bindgen/Cargo.toml b/crates/studio_uniffi_bindgen/Cargo.toml
@@ -7,5 +7,8 @@ license.workspace = true
repository.workspace = true
publish = false
+[dependencies]
+uniffi = { workspace = true, features = ["cli"] }
+
[lints]
workspace = true
diff --git a/crates/studio_uniffi_bindgen/src/main.rs b/crates/studio_uniffi_bindgen/src/main.rs
@@ -1,6 +1,8 @@
#![doc = "Pinned `UniFFI` binding generator entry point."]
-fn main() {}
+fn main() {
+ uniffi::uniffi_bindgen_main();
+}
#[cfg(test)]
mod tests {